aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs/conversations/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs/conversations/ui')
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java19
-rw-r--r--src/eu/siacs/conversations/ui/MucDetailsActivity.java5
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java12
3 files changed, 22 insertions, 14 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();
diff --git a/src/eu/siacs/conversations/ui/MucDetailsActivity.java b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
index b34a02e0..c94f1b11 100644
--- a/src/eu/siacs/conversations/ui/MucDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/MucDetailsActivity.java
@@ -11,9 +11,9 @@ import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.MucOptions;
import eu.siacs.conversations.entities.MucOptions.User;
import eu.siacs.conversations.utils.UIHelper;
+import eu.siacs.conversations.xmpp.stanzas.MessagePacket;
import android.app.PendingIntent;
import android.content.Context;
-import android.content.Intent;
import android.content.SharedPreferences;
import android.content.IntentSender.SendIntentException;
import android.os.Bundle;
@@ -62,7 +62,8 @@ public class MucDetailsActivity extends XmppActivity {
String subject = mSubject.getText().toString();
MucOptions options = conversation.getMucOptions();
if (!subject.equals(options.getSubject())) {
- xmppConnectionService.sendConversationSubject(conversation,subject);
+ MessagePacket packet = xmppConnectionService.getMessageGenerator().conversationSubject(conversation, subject);
+ xmppConnectionService.sendMessagePacket(conversation.getAccount(), packet);
finish();
}
}
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 7abb2cef..217bae55 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -152,7 +152,7 @@ public abstract class XmppActivity extends Activity {
public void switchToConversation(Conversation conversation) {
switchToConversation(conversation, null, false);
}
-
+
public void switchToConversation(Conversation conversation, String text,
boolean newTask) {
Intent viewConversationIntent = new Intent(this,
@@ -174,7 +174,7 @@ public abstract class XmppActivity extends Activity {
}
startActivity(viewConversationIntent);
}
-
+
public void switchToContactDetails(Contact contact) {
Intent intent = new Intent(this, ContactDetailsActivity.class);
intent.setAction(ContactDetailsActivity.ACTION_VIEW_CONTACT);
@@ -203,7 +203,9 @@ public abstract class XmppActivity extends Activity {
public void success(Account account) {
xmppConnectionService.databaseBackend
.updateAccount(account);
- xmppConnectionService.sendPresence(account);
+ xmppConnectionService.sendPresencePacket(account,
+ xmppConnectionService.getPresenceGenerator()
+ .sendPresence(account));
if (conversation != null) {
conversation
.setNextEncryption(Message.ENCRYPTION_PGP);
@@ -233,7 +235,7 @@ public abstract class XmppActivity extends Activity {
});
}
-
+
protected void showAddToRosterDialog(final Conversation conversation) {
String jid = conversation.getContactJid();
AlertDialog.Builder builder = new AlertDialog.Builder(this);
@@ -253,7 +255,7 @@ public abstract class XmppActivity extends Activity {
});
builder.create().show();
}
-
+
public void selectPresence(final Conversation conversation,
final OnPresenceSelected listener) {
Contact contact = conversation.getContact();