aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-07-12 03:44:23 +0200
committeriNPUTmice <daniel@gultsch.de>2014-07-12 03:44:23 +0200
commit99935dd630b59d6cff05714c888b01e4c88c6351 (patch)
treee84968da60ea8bc8f117bed39cf430259f9958aa /src/eu/siacs/conversations/ui/ContactDetailsActivity.java
parent789383e5cb900baf55595e91f47f6d3ab4cec75e (diff)
moved most of the message/presence generation into seperate classes
Diffstat (limited to 'src/eu/siacs/conversations/ui/ContactDetailsActivity.java')
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
index 06b5a809..9321f229 100644
--- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -31,7 +31,9 @@ import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Presences;
+import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.utils.UIHelper;
+import eu.siacs.conversations.xmpp.stanzas.PresencePacket;
public class ContactDetailsActivity extends XmppActivity {
public static final String ACTION_VIEW_CONTACT = "view_contact";
@@ -293,6 +295,8 @@ public class ContactDetailsActivity extends XmppActivity {
@Override
protected void onStop() {
super.onStop();
+ XmppConnectionService xcs = activity.xmppConnectionService;
+ PresencePacket packet = null;
boolean updated = false;
if (contact!=null) {
boolean online = contact.getAccount().getStatus() == Account.STATUS_ONLINE;
@@ -301,7 +305,7 @@ public class ContactDetailsActivity extends XmppActivity {
if (online) {
contact.resetOption(Contact.Options.FROM);
contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
- activity.xmppConnectionService.stopPresenceUpdatesTo(contact);
+ packet = xcs.getPresenceGenerator().stopPresenceUpdatesTo(contact);
}
updated = true;
}
@@ -317,7 +321,7 @@ public class ContactDetailsActivity extends XmppActivity {
if (send.isChecked()) {
if (online) {
if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
- xmppConnectionService.sendPresenceUpdatesTo(contact);
+ packet = xcs.getPresenceGenerator().sendPresenceUpdatesTo(contact);
} else {
contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
}
@@ -330,7 +334,7 @@ public class ContactDetailsActivity extends XmppActivity {
if (!receive.isChecked()) {
if (online) {
contact.resetOption(Contact.Options.TO);
- activity.xmppConnectionService.stopPresenceUpdatesFrom(contact);
+ packet = xcs.getPresenceGenerator().stopPresenceUpdatesFrom(contact);
}
updated = true;
}
@@ -339,8 +343,7 @@ public class ContactDetailsActivity extends XmppActivity {
if (!receive.isChecked()) {
if (online) {
contact.resetOption(Contact.Options.ASKING);
- activity.xmppConnectionService
- .stopPresenceUpdatesFrom(contact);
+ packet = xcs.getPresenceGenerator().stopPresenceUpdatesFrom(contact);
}
updated = true;
}
@@ -348,8 +351,7 @@ public class ContactDetailsActivity extends XmppActivity {
if (receive.isChecked()) {
if (online) {
contact.setOption(Contact.Options.ASKING);
- activity.xmppConnectionService
- .requestPresenceUpdatesFrom(contact);
+ packet = xcs.getPresenceGenerator().requestPresenceUpdatesFrom(contact);
}
updated = true;
}
@@ -357,6 +359,9 @@ public class ContactDetailsActivity extends XmppActivity {
}
if (updated) {
if (online) {
+ if (packet!=null) {
+ xcs.sendPresencePacket(contact.getAccount(), packet);
+ }
Toast.makeText(getApplicationContext(), getString(R.string.subscription_updated), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(getApplicationContext(), getString(R.string.subscription_not_updated_offline), Toast.LENGTH_SHORT).show();