aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/entities/Contact.java2
-rw-r--r--src/eu/siacs/conversations/parser/PresenceParser.java2
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java62
-rw-r--r--src/eu/siacs/conversations/ui/ContactDetailsActivity.java24
4 files changed, 49 insertions, 41 deletions
diff --git a/src/eu/siacs/conversations/entities/Contact.java b/src/eu/siacs/conversations/entities/Contact.java
index 248d41b7..a0f77f7c 100644
--- a/src/eu/siacs/conversations/entities/Contact.java
+++ b/src/eu/siacs/conversations/entities/Contact.java
@@ -272,9 +272,11 @@ public class Contact implements ListItem {
} else if (subscription.equals("from")) {
this.resetOption(Contact.Options.TO);
this.setOption(Contact.Options.FROM);
+ this.resetOption(Contact.Options.PREEMPTIVE_GRANT);
} else if (subscription.equals("both")) {
this.setOption(Contact.Options.TO);
this.setOption(Contact.Options.FROM);
+ this.resetOption(Contact.Options.PREEMPTIVE_GRANT);
} else if (subscription.equals("none")) {
this.resetOption(Contact.Options.FROM);
this.resetOption(Contact.Options.TO);
diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java
index 8cc57bad..ab32c707 100644
--- a/src/eu/siacs/conversations/parser/PresenceParser.java
+++ b/src/eu/siacs/conversations/parser/PresenceParser.java
@@ -90,8 +90,6 @@ public class PresenceParser extends AbstractParser {
} else if (type.equals("subscribe")) {
if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
mXmppConnectionService.sendPresenceUpdatesTo(contact);
- contact.setOption(Contact.Options.FROM);
- contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
if ((contact.getOption(Contact.Options.ASKING))
&& (!contact.getOption(Contact.Options.TO))) {
mXmppConnectionService
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 6c652f8d..dcdd21dd 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -429,6 +429,7 @@ public class XmppConnectionService extends Service {
if (subscription.equals("remove")) {
contact.resetOption(Contact.Options.IN_ROSTER);
contact.resetOption(Contact.Options.DIRTY_DELETE);
+ contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
} else {
contact.setOption(Contact.Options.IN_ROSTER);
contact.resetOption(Contact.Options.DIRTY_PUSH);
@@ -516,7 +517,10 @@ public class XmppConnectionService extends Service {
}
}
if (wakeLock.isHeld()) {
- try { wakeLock.release();} catch (RuntimeException re) {}
+ try {
+ wakeLock.release();
+ } catch (RuntimeException re) {
+ }
}
return START_STICKY;
}
@@ -693,13 +697,14 @@ public class XmppConnectionService extends Service {
message.setStatus(Message.STATUS_WAITING);
} else if (conv.hasValidOtrSession()
&& conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
- message.setPresence(conv.getOtrSession().getSessionID().getUserID());
+ message.setPresence(conv.getOtrSession().getSessionID()
+ .getUserID());
try {
packet = mMessageGenerator.generateOtrChat(message);
send = true;
message.setStatus(Message.STATUS_SEND);
} catch (OtrException e) {
- Log.e(LOGTAG,"error generating otr packet");
+ Log.e(LOGTAG, "error generating otr packet");
packet = null;
}
} else if (message.getPresence() == null) {
@@ -784,9 +789,11 @@ public class XmppConnectionService extends Service {
}
}
} else {
- if (message.getConversation().getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
+ if (message.getConversation().getOtrSession()
+ .getSessionStatus() == SessionStatus.ENCRYPTED) {
if (message.getType() == Message.TYPE_TEXT) {
- packet = mMessageGenerator.generateOtrChat(message,true);
+ packet = mMessageGenerator.generateOtrChat(message,
+ true);
} else if (message.getType() == Message.TYPE_IMAGE) {
mJingleConnectionManager.createNewConnection(message);
}
@@ -794,9 +801,10 @@ public class XmppConnectionService extends Service {
}
} else if (message.getType() == Message.TYPE_TEXT) {
if (message.getEncryption() == Message.ENCRYPTION_NONE) {
- packet = mMessageGenerator.generateChat(message,true);
- } else if ((message.getEncryption() == Message.ENCRYPTION_DECRYPTED)||(message.getEncryption() == Message.ENCRYPTION_PGP)) {
- packet = mMessageGenerator.generatePgpChat(message,true);
+ packet = mMessageGenerator.generateChat(message, true);
+ } else if ((message.getEncryption() == Message.ENCRYPTION_DECRYPTED)
+ || (message.getEncryption() == Message.ENCRYPTION_PGP)) {
+ packet = mMessageGenerator.generatePgpChat(message, true);
}
} else if (message.getType() == Message.TYPE_IMAGE) {
Presences presences = message.getConversation().getContact()
@@ -1087,10 +1095,13 @@ public class XmppConnectionService extends Service {
packet.addChild("x", "jabber:x:signed").setContent(sig);
}
if (conversation.getMessages().size() != 0) {
- final SimpleDateFormat mDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",Locale.US);
+ final SimpleDateFormat mDateFormat = new SimpleDateFormat(
+ "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- Date date = new Date(conversation.getLatestMessage().getTimeSent() + 1000);
- x.addChild("history").setAttribute("since",mDateFormat.format(date));
+ Date date = new Date(
+ conversation.getLatestMessage().getTimeSent() + 1000);
+ x.addChild("history").setAttribute("since",
+ mDateFormat.format(date));
}
packet.addChild(x);
account.getXmppConnection().sendPresencePacket(packet);
@@ -1221,11 +1232,13 @@ public class XmppConnectionService extends Service {
&& (msg.getEncryption() == Message.ENCRYPTION_OTR)) {
msg.setPresence(otrSession.getSessionID().getUserID());
if (msg.getType() == Message.TYPE_TEXT) {
- MessagePacket outPacket = mMessageGenerator.generateOtrChat(msg,true);
- if (outPacket!=null) {
+ MessagePacket outPacket = mMessageGenerator
+ .generateOtrChat(msg, true);
+ if (outPacket != null) {
msg.setStatus(Message.STATUS_SEND);
databaseBackend.updateMessage(msg);
- account.getXmppConnection().sendMessagePacket(outPacket);
+ account.getXmppConnection()
+ .sendMessagePacket(outPacket);
}
} else if (msg.getType() == Message.TYPE_IMAGE) {
mJingleConnectionManager.createNewConnection(msg);
@@ -1273,7 +1286,8 @@ public class XmppConnectionService extends Service {
if (contact.getOption(Contact.Options.ASKING)) {
requestPresenceUpdatesFrom(contact);
}
- if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
+ if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)
+ && contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
Log.d("xmppService", "contact had pending subscription");
sendPresenceUpdatesTo(contact);
}
@@ -1281,6 +1295,7 @@ public class XmppConnectionService extends Service {
}
public void deleteContactOnServer(Contact contact) {
+ contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
contact.resetOption(Contact.Options.DIRTY_PUSH);
contact.setOption(Contact.Options.DIRTY_DELETE);
Account account = contact.getAccount();
@@ -1480,32 +1495,33 @@ public class XmppConnectionService extends Service {
public void replyWithNotAcceptable(Account account, MessagePacket packet) {
if (account.getStatus() == Account.STATUS_ONLINE) {
- MessagePacket error = this.mMessageGenerator.generateNotAcceptable(packet);
+ MessagePacket error = this.mMessageGenerator
+ .generateNotAcceptable(packet);
account.getXmppConnection().sendMessagePacket(error);
}
}
-
+
public void syncRosterToDisk(final Account account) {
new Thread(new Runnable() {
-
+
@Override
public void run() {
databaseBackend.writeRoster(account.getRoster());
}
}).start();
-
+
}
-
+
public List<String> getKnownHosts() {
List<String> hosts = new ArrayList<String>();
- for(Account account : getAccounts()) {
+ for (Account account : getAccounts()) {
if (!hosts.contains(account.getServer())) {
hosts.add(account.getServer());
}
- for(Contact contact : account.getRoster().getContacts()) {
+ for (Contact contact : account.getRoster().getContacts()) {
if (contact.showInRoster()) {
String server = contact.getServer();
- if (server!=null && !hosts.contains(server)) {
+ if (server != null && !hosts.contains(server)) {
hosts.add(server);
}
}
diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
index bee93713..06b5a809 100644
--- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java
@@ -47,7 +47,6 @@ public class ContactDetailsActivity extends XmppActivity {
private TextView contactJidTv;
private TextView accountJidTv;
private TextView status;
- private TextView askAgain;
private TextView lastseen;
private CheckBox send;
private CheckBox receive;
@@ -115,7 +114,6 @@ public class ContactDetailsActivity extends XmppActivity {
lastseen = (TextView) findViewById(R.id.details_lastseen);
send = (CheckBox) findViewById(R.id.details_send_presence);
receive = (CheckBox) findViewById(R.id.details_receive_presence);
- askAgain = (TextView) findViewById(R.id.ask_again);
badge = (QuickContactBadge) findViewById(R.id.details_contact_badge);
keys = (LinearLayout) findViewById(R.id.details_contact_keys);
getActionBar().setHomeButtonEnabled(true);
@@ -174,6 +172,8 @@ public class ContactDetailsActivity extends XmppActivity {
setTitle(contact.getDisplayName());
if (contact.getOption(Contact.Options.FROM)) {
send.setChecked(true);
+ } else if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)){
+ send.setChecked(false);
} else {
send.setText(R.string.preemptively_grant);
if (contact
@@ -187,17 +187,6 @@ public class ContactDetailsActivity extends XmppActivity {
receive.setChecked(true);
} else {
receive.setText(R.string.ask_for_presence_updates);
- askAgain.setVisibility(View.VISIBLE);
- askAgain.setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- Toast.makeText(getApplicationContext(), getString(R.string.asked_for_presence_updates),
- Toast.LENGTH_SHORT).show();
- xmppConnectionService.requestPresenceUpdatesFrom(contact);
-
- }
- });
if (contact.getOption(Contact.Options.ASKING)) {
receive.setChecked(true);
} else {
@@ -317,8 +306,7 @@ public class ContactDetailsActivity extends XmppActivity {
updated = true;
}
} else {
- if (contact
- .getOption(Contact.Options.PREEMPTIVE_GRANT)) {
+ if (contact.getOption(Contact.Options.PREEMPTIVE_GRANT)) {
if (!send.isChecked()) {
if (online) {
contact.resetOption(Contact.Options.PREEMPTIVE_GRANT);
@@ -328,7 +316,11 @@ public class ContactDetailsActivity extends XmppActivity {
} else {
if (send.isChecked()) {
if (online) {
- contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
+ if (contact.getOption(Contact.Options.PENDING_SUBSCRIPTION_REQUEST)) {
+ xmppConnectionService.sendPresenceUpdatesTo(contact);
+ } else {
+ contact.setOption(Contact.Options.PREEMPTIVE_GRANT);
+ }
}
updated = true;
}