aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/services/XmppConnectionService.java
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-28 18:46:01 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-02-28 18:46:01 +0100
commitacf80bddd07d5579cdb20a888b3f9e99e53030a5 (patch)
tree034a8e364488c89c8e1997f56313d919019afa65 /src/eu/siacs/conversations/services/XmppConnectionService.java
parent03d96266f8bbb76e25610e903d74a0afa7dcd03b (diff)
rebranding
Diffstat (limited to '')
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java (renamed from src/de/gultsch/chat/services/XmppConnectionService.java)168
1 files changed, 85 insertions, 83 deletions
diff --git a/src/de/gultsch/chat/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 7ff09957..218d5088 100644
--- a/src/de/gultsch/chat/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -1,4 +1,4 @@
-package de.gultsch.chat.services;
+package eu.siacs.conversations.services;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -14,31 +14,31 @@ import net.java.otr4j.OtrException;
import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionStatus;
-import de.gultsch.chat.crypto.PgpEngine;
-import de.gultsch.chat.crypto.PgpEngine.OpenPgpException;
-import de.gultsch.chat.entities.Account;
-import de.gultsch.chat.entities.Contact;
-import de.gultsch.chat.entities.Conversation;
-import de.gultsch.chat.entities.Message;
-import de.gultsch.chat.entities.Presences;
-import de.gultsch.chat.persistance.DatabaseBackend;
-import de.gultsch.chat.persistance.OnPhoneContactsMerged;
-import de.gultsch.chat.ui.OnAccountListChangedListener;
-import de.gultsch.chat.ui.OnConversationListChangedListener;
-import de.gultsch.chat.ui.OnRosterFetchedListener;
-import de.gultsch.chat.utils.MessageParser;
-import de.gultsch.chat.utils.OnPhoneContactsLoadedListener;
-import de.gultsch.chat.utils.PhoneHelper;
-import de.gultsch.chat.utils.UIHelper;
-import de.gultsch.chat.xml.Element;
-import de.gultsch.chat.xmpp.IqPacket;
-import de.gultsch.chat.xmpp.MessagePacket;
-import de.gultsch.chat.xmpp.OnIqPacketReceived;
-import de.gultsch.chat.xmpp.OnMessagePacketReceived;
-import de.gultsch.chat.xmpp.OnPresencePacketReceived;
-import de.gultsch.chat.xmpp.OnStatusChanged;
-import de.gultsch.chat.xmpp.PresencePacket;
-import de.gultsch.chat.xmpp.XmppConnection;
+import eu.siacs.conversations.crypto.PgpEngine;
+import eu.siacs.conversations.crypto.PgpEngine.OpenPgpException;
+import eu.siacs.conversations.entities.Account;
+import eu.siacs.conversations.entities.Contact;
+import eu.siacs.conversations.entities.Conversation;
+import eu.siacs.conversations.entities.Message;
+import eu.siacs.conversations.entities.Presences;
+import eu.siacs.conversations.persistance.DatabaseBackend;
+import eu.siacs.conversations.persistance.OnPhoneContactsMerged;
+import eu.siacs.conversations.ui.OnAccountListChangedListener;
+import eu.siacs.conversations.ui.OnConversationListChangedListener;
+import eu.siacs.conversations.ui.OnRosterFetchedListener;
+import eu.siacs.conversations.utils.MessageParser;
+import eu.siacs.conversations.utils.OnPhoneContactsLoadedListener;
+import eu.siacs.conversations.utils.PhoneHelper;
+import eu.siacs.conversations.utils.UIHelper;
+import eu.siacs.conversations.xml.Element;
+import eu.siacs.conversations.xmpp.IqPacket;
+import eu.siacs.conversations.xmpp.MessagePacket;
+import eu.siacs.conversations.xmpp.OnIqPacketReceived;
+import eu.siacs.conversations.xmpp.OnMessagePacketReceived;
+import eu.siacs.conversations.xmpp.OnPresencePacketReceived;
+import eu.siacs.conversations.xmpp.OnStatusChanged;
+import eu.siacs.conversations.xmpp.PresencePacket;
+import eu.siacs.conversations.xmpp.XmppConnection;
import android.app.NotificationManager;
import android.app.Service;
import android.content.Context;
@@ -188,71 +188,73 @@ public class XmppConnectionService extends Service {
@Override
public void onPresencePacketReceived(Account account,
PresencePacket packet) {
- String[] fromParts = packet.getAttribute("from").split("/");
- Contact contact = findContact(account, fromParts[0]);
- if (contact == null) {
- // most likely muc, self or roster not synced
- Log.d(LOGTAG,
- "got presence for non contact " + packet.toString());
- return;
- }
- String type = packet.getAttribute("type");
- if (type == null) {
- Element show = packet.findChild("show");
- if (show == null) {
- contact.updatePresence(fromParts[1], Presences.ONLINE);
- } else if (show.getContent().equals("away")) {
- contact.updatePresence(fromParts[1], Presences.AWAY);
- } else if (show.getContent().equals("xa")) {
- contact.updatePresence(fromParts[1], Presences.XA);
- } else if (show.getContent().equals("chat")) {
- contact.updatePresence(fromParts[1], Presences.CHAT);
- } else if (show.getContent().equals("dnd")) {
- contact.updatePresence(fromParts[1], Presences.DND);
+ if (packet.hasChild("x")&&(packet.findChild("x").getAttribute("xmlns").startsWith("http://jabber.org/protocol/muc"))) {
+ Log.d(LOGTAG,"got muc presence "+packet.toString());
+ } else {
+ String[] fromParts = packet.getAttribute("from").split("/");
+ Contact contact = findContact(account, fromParts[0]);
+ if (contact == null) {
+ // most likely self or roster not synced
+ return;
}
- PgpEngine pgp = getPgpEngine();
- if (pgp!=null) {
- Element x = packet.findChild("x");
- if ((x != null)
- && (x.getAttribute("xmlns").equals("jabber:x:signed"))) {
- try {
- Log.d(LOGTAG,"pgp signature for contact" +packet.getAttribute("from"));
- contact.setPgpKeyId(pgp.fetchKeyId(packet.findChild("status")
- .getContent(), x.getContent()));
- } catch (OpenPgpException e) {
- Log.d(LOGTAG,"faulty pgp. just ignore");
+ String type = packet.getAttribute("type");
+ if (type == null) {
+ Element show = packet.findChild("show");
+ if (show == null) {
+ contact.updatePresence(fromParts[1], Presences.ONLINE);
+ } else if (show.getContent().equals("away")) {
+ contact.updatePresence(fromParts[1], Presences.AWAY);
+ } else if (show.getContent().equals("xa")) {
+ contact.updatePresence(fromParts[1], Presences.XA);
+ } else if (show.getContent().equals("chat")) {
+ contact.updatePresence(fromParts[1], Presences.CHAT);
+ } else if (show.getContent().equals("dnd")) {
+ contact.updatePresence(fromParts[1], Presences.DND);
+ }
+ PgpEngine pgp = getPgpEngine();
+ if (pgp!=null) {
+ Element x = packet.findChild("x");
+ if ((x != null)
+ && (x.getAttribute("xmlns").equals("jabber:x:signed"))) {
+ try {
+ Log.d(LOGTAG,"pgp signature for contact" +packet.getAttribute("from"));
+ contact.setPgpKeyId(pgp.fetchKeyId(packet.findChild("status")
+ .getContent(), x.getContent()));
+ } catch (OpenPgpException e) {
+ Log.d(LOGTAG,"faulty pgp. just ignore");
+ }
}
}
- }
- databaseBackend.updateContact(contact);
- } else if (type.equals("unavailable")) {
- if (fromParts.length != 2) {
- // Log.d(LOGTAG,"received presence with no resource "+packet.toString());
- } else {
- contact.removePresence(fromParts[1]);
databaseBackend.updateContact(contact);
- }
- } else if (type.equals("subscribe")) {
- if (contact
- .getSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT)) {
- sendPresenceUpdatesTo(contact);
- contact.setSubscriptionOption(Contact.Subscription.FROM);
- contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
- replaceContactInConversation(contact.getJid(), contact);
- databaseBackend.updateContact(contact);
- if ((contact
- .getSubscriptionOption(Contact.Subscription.ASKING))
- && (!contact
- .getSubscriptionOption(Contact.Subscription.TO))) {
- requestPresenceUpdatesFrom(contact);
+ } else if (type.equals("unavailable")) {
+ if (fromParts.length != 2) {
+ // Log.d(LOGTAG,"received presence with no resource "+packet.toString());
+ } else {
+ contact.removePresence(fromParts[1]);
+ databaseBackend.updateContact(contact);
+ }
+ } else if (type.equals("subscribe")) {
+ if (contact
+ .getSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT)) {
+ sendPresenceUpdatesTo(contact);
+ contact.setSubscriptionOption(Contact.Subscription.FROM);
+ contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
+ replaceContactInConversation(contact.getJid(), contact);
+ databaseBackend.updateContact(contact);
+ if ((contact
+ .getSubscriptionOption(Contact.Subscription.ASKING))
+ && (!contact
+ .getSubscriptionOption(Contact.Subscription.TO))) {
+ requestPresenceUpdatesFrom(contact);
+ }
+ } else {
+ // TODO: ask user to handle it maybe
}
} else {
- // TODO: ask user to handle it maybe
+ //Log.d(LOGTAG, packet.toString());
}
- } else {
- Log.d(LOGTAG, packet.toString());
+ replaceContactInConversation(contact.getJid(), contact);
}
- replaceContactInConversation(contact.getJid(), contact);
}
};