String gnupgPublicKey = buddy.getPubKey();
if (JBotherLoader.isGPGEnabled() &&
// BuddyList.getInstance().isEncrypting()
buddy.isEncrypting() && (gnupgSecretKey != null)
&& (gnupgPublicKey != null)) {
GnuPG gnupg = new GnuPG();
String encryptedData = null;
String signedData = null;
if (gnupgSecurityVariant == null) {
gnupgSecurityVariant = "0";
Settings.getInstance().setProperty("gnupgSecurityVariant", "0");
}
if ((gnupgSecurityVariant.equals("0"))
|| (gnupgSecurityVariant.equals("1"))) {
encryptedData = gnupg.encryptExtension(text, gnupgSecretKey,
gnupgPublicKey);
if (encryptedData != null) {
secureExtension.setData(encryptedData);
}
}
if ((gnupgSecurityVariant.equals("0"))
|| (gnupgSecurityVariant.equals("2"))) {
signedData = gnupg.signExtension(text, gnupgSecretKey);
if (signedData != null) {
signedExtension.setData(signedData);
}
}
if ((encryptedData == null) && (signedData == null)) {
buddy.isEncrypting(false);
encryptButton.setIcon(Standard.getIcon("images/buttons/ssl_no.png"));
Standard.warningMessage(null,
resources.getString("gnupgError"), resources.getString("gnupgErrorEncrypting")
+ ".\n\n"
+ resources.getString("reason")
+ ":\n\n"
+ gnupg.getResult()
+ gnupg.getErrorString()
+ "\n"
+ resources.getString("gnupgTryOrSendUnencrypted")
+ ".");
return false;
}