aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/utils')
-rw-r--r--src/eu/siacs/conversations/utils/CryptoHelper.java7
-rw-r--r--src/eu/siacs/conversations/utils/UIHelper.java48
2 files changed, 43 insertions, 12 deletions
diff --git a/src/eu/siacs/conversations/utils/CryptoHelper.java b/src/eu/siacs/conversations/utils/CryptoHelper.java
index c1be56c88..98dbea4de 100644
--- a/src/eu/siacs/conversations/utils/CryptoHelper.java
+++ b/src/eu/siacs/conversations/utils/CryptoHelper.java
@@ -44,10 +44,6 @@ public class CryptoHelper {
public static String saslDigestMd5(Account account, String challenge) {
try {
Random random = new SecureRandom();
- Log.d("xmppService",
- "challenge="
- + new String(Base64.decode(challenge,
- Base64.DEFAULT)));
String[] challengeParts = new String(Base64.decode(challenge,
Base64.DEFAULT)).split(",");
String nonce = "";
@@ -67,7 +63,6 @@ public class CryptoHelper {
byte[] y = md
.digest(x.getBytes(Charset.defaultCharset()));
String cNonce = new BigInteger(100, random).toString(32);
- Log.d("xmppService", "conce=" + cNonce);
byte[] a1 = concatenateByteArrays(y,(":"+nonce+":"+cNonce).getBytes(Charset.defaultCharset()));
String a2 = "AUTHENTICATE:"+digestUri;
String ha1 = bytesToHex(md.digest(a1));
@@ -75,7 +70,6 @@ public class CryptoHelper {
.defaultCharset())));
String kd = ha1 + ":" + nonce + ":"+nonceCount+":" + cNonce + ":auth:"
+ ha2;
- Log.d("xmppService", "kd=" + kd);
String response = bytesToHex(md.digest(kd.getBytes(Charset
.defaultCharset())));
String saslString = "username=\"" + account.getUsername()
@@ -83,7 +77,6 @@ public class CryptoHelper {
+ nonce + "\",cnonce=\"" + cNonce
+ "\",nc="+nonceCount+",qop=auth,digest-uri=\""+digestUri+"\",response=" + response
+ ",charset=utf-8";
- Log.d("xmppService", "saslString=" + saslString);
return Base64.encodeToString(
saslString.getBytes(Charset.defaultCharset()),
Base64.NO_WRAP);
diff --git a/src/eu/siacs/conversations/utils/UIHelper.java b/src/eu/siacs/conversations/utils/UIHelper.java
index 2558ca718..a05d590db 100644
--- a/src/eu/siacs/conversations/utils/UIHelper.java
+++ b/src/eu/siacs/conversations/utils/UIHelper.java
@@ -13,6 +13,7 @@ import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
+import eu.siacs.conversations.ui.ManageAccountActivity;
import android.app.Activity;
import android.app.AlertDialog;
@@ -126,6 +127,44 @@ public class UIHelper {
return bitmap;
}
+
+ public static void showErrorNotification(Context context, List<Account> accounts) {
+ NotificationManager mNotificationManager = (NotificationManager) context
+ .getSystemService(Context.NOTIFICATION_SERVICE);
+ List<Account> accountsWproblems = new ArrayList<Account>();
+ for(Account account : accounts) {
+ if (account.hasErrorStatus()) {
+ accountsWproblems.add(account);
+ }
+ }
+ NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context);
+ if (accountsWproblems.size() == 0) {
+ mNotificationManager.cancel(1111);
+ return;
+ } else if (accountsWproblems.size() == 1) {
+ mBuilder.setContentTitle(context.getString(R.string.problem_connecting_to_account));
+ mBuilder.setContentText(accountsWproblems.get(0).getJid());
+ } else {
+ mBuilder.setContentTitle(context.getString(R.string.problem_connecting_to_accounts));
+ mBuilder.setContentText(context.getString(R.string.touch_to_fix));
+ }
+ mBuilder.setOngoing(true);
+ mBuilder.setLights(0xffffffff, 2000, 4000);
+ mBuilder.setSmallIcon(R.drawable.notification);
+ TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
+ stackBuilder.addParentStack(ConversationActivity.class);
+
+ Intent manageAccountsIntent = new Intent(context,
+ ManageAccountActivity.class);
+ stackBuilder.addNextIntent(manageAccountsIntent);
+
+ PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(
+ 0, PendingIntent.FLAG_UPDATE_CURRENT);
+
+ mBuilder.setContentIntent(resultPendingIntent);
+ Notification notification = mBuilder.build();
+ mNotificationManager.notify(1111, notification);
+ }
public static void updateNotification(Context context,
List<Conversation> conversations, Conversation currentCon, boolean notify) {
@@ -139,6 +178,7 @@ public class UIHelper {
boolean alwaysNotify = preferences.getBoolean("notify_in_conversation_when_highlighted", false);
if (!showNofifications) {
+ mNotificationManager.cancel(2342);
return;
}
@@ -148,6 +188,7 @@ public class UIHelper {
String nick = currentCon.getMucOptions().getNick();
notify = currentCon.getLatestMessage().getBody().contains(nick);
if (!notify) {
+ mNotificationManager.cancel(2342);
return;
}
}
@@ -164,14 +205,11 @@ public class UIHelper {
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
context);
if (unread.size() == 0) {
- mNotificationManager.cancelAll();
+ mNotificationManager.cancel(2342);
+ return;
} else if (unread.size() == 1) {
Conversation conversation = unread.get(0);
targetUuid = conversation.getUuid();
- /*mBuilder.setLargeIcon(UIHelper.getUnknownContactPicture(
- conversation.getName(),
- (int) res
- .getDimension(android.R.dimen.notification_large_icon_width)));*/
mBuilder.setLargeIcon(UIHelper.getContactPicture(conversation.getContact(), conversation.getName(useSubject), (int) res
.getDimension(android.R.dimen.notification_large_icon_width), context));
mBuilder.setContentTitle(conversation.getName(useSubject));