try to make openpgp a little more reliable
This commit is contained in:
		
							parent
							
								
									5477ff1aea
								
							
						
					
					
						commit
						07e6873025
					
				| 
						 | 
					@ -54,9 +54,18 @@ public class PgpEngine {
 | 
				
			||||||
					switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
 | 
										switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
 | 
				
			||||||
							OpenPgpApi.RESULT_CODE_ERROR)) {
 | 
												OpenPgpApi.RESULT_CODE_ERROR)) {
 | 
				
			||||||
					case OpenPgpApi.RESULT_CODE_SUCCESS:
 | 
										case OpenPgpApi.RESULT_CODE_SUCCESS:
 | 
				
			||||||
 | 
											try {
 | 
				
			||||||
 | 
												os.flush();
 | 
				
			||||||
 | 
												if (message.getEncryption() == Message.ENCRYPTION_PGP) {
 | 
				
			||||||
								message.setBody(os.toString());
 | 
													message.setBody(os.toString());
 | 
				
			||||||
								message.setEncryption(Message.ENCRYPTION_DECRYPTED);
 | 
													message.setEncryption(Message.ENCRYPTION_DECRYPTED);
 | 
				
			||||||
								callback.success(message);
 | 
													callback.success(message);
 | 
				
			||||||
 | 
												}
 | 
				
			||||||
 | 
											} catch (IOException e) {
 | 
				
			||||||
 | 
												callback.error(R.string.openpgp_error, message);
 | 
				
			||||||
 | 
												return;
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											
 | 
				
			||||||
						return;
 | 
											return;
 | 
				
			||||||
					case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
 | 
										case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
 | 
				
			||||||
						callback.userInputRequried((PendingIntent) result
 | 
											callback.userInputRequried((PendingIntent) result
 | 
				
			||||||
| 
						 | 
					@ -64,6 +73,8 @@ public class PgpEngine {
 | 
				
			||||||
								message);
 | 
													message);
 | 
				
			||||||
						return;
 | 
											return;
 | 
				
			||||||
					case OpenPgpApi.RESULT_CODE_ERROR:
 | 
										case OpenPgpApi.RESULT_CODE_ERROR:
 | 
				
			||||||
 | 
											OpenPgpError error = result.getParcelableExtra(OpenPgpApi.RESULT_ERROR);
 | 
				
			||||||
 | 
											Log.d("xmppService",error.getMessage());
 | 
				
			||||||
						callback.error(R.string.openpgp_error, message);
 | 
											callback.error(R.string.openpgp_error, message);
 | 
				
			||||||
						return;
 | 
											return;
 | 
				
			||||||
					default:
 | 
										default:
 | 
				
			||||||
| 
						 | 
					@ -153,6 +164,8 @@ public class PgpEngine {
 | 
				
			||||||
					switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
 | 
										switch (result.getIntExtra(OpenPgpApi.RESULT_CODE,
 | 
				
			||||||
							OpenPgpApi.RESULT_CODE_ERROR)) {
 | 
												OpenPgpApi.RESULT_CODE_ERROR)) {
 | 
				
			||||||
					case OpenPgpApi.RESULT_CODE_SUCCESS:
 | 
										case OpenPgpApi.RESULT_CODE_SUCCESS:
 | 
				
			||||||
 | 
											try {
 | 
				
			||||||
 | 
												os.flush();
 | 
				
			||||||
							StringBuilder encryptedMessageBody = new StringBuilder();
 | 
												StringBuilder encryptedMessageBody = new StringBuilder();
 | 
				
			||||||
							String[] lines = os.toString().split("\n");
 | 
												String[] lines = os.toString().split("\n");
 | 
				
			||||||
							for (int i = 3; i < lines.length - 1; ++i) {
 | 
												for (int i = 3; i < lines.length - 1; ++i) {
 | 
				
			||||||
| 
						 | 
					@ -161,6 +174,10 @@ public class PgpEngine {
 | 
				
			||||||
							message.setEncryptedBody(encryptedMessageBody
 | 
												message.setEncryptedBody(encryptedMessageBody
 | 
				
			||||||
									.toString());
 | 
														.toString());
 | 
				
			||||||
							callback.success(message);
 | 
												callback.success(message);
 | 
				
			||||||
 | 
											} catch (IOException e) {
 | 
				
			||||||
 | 
												callback.error(R.string.openpgp_error, message);
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											
 | 
				
			||||||
						break;
 | 
											break;
 | 
				
			||||||
					case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
 | 
										case OpenPgpApi.RESULT_CODE_USER_INTERACTION_REQUIRED:
 | 
				
			||||||
						callback.userInputRequried((PendingIntent) result
 | 
											callback.userInputRequried((PendingIntent) result
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue