adapt caps on whether or not message confirmation is on

This commit is contained in:
iNPUTmice 2015-01-26 00:48:56 +01:00
parent 94086bb9b7
commit 91e85d2faf
5 changed files with 31 additions and 11 deletions

View File

@ -5,24 +5,30 @@ import android.util.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import eu.siacs.conversations.services.XmppConnectionService;
public abstract class AbstractGenerator {
public final String[] FEATURES = {"urn:xmpp:jingle:1",
public final String[] FEATURES = {
"urn:xmpp:jingle:1",
"urn:xmpp:jingle:apps:file-transfer:3",
"urn:xmpp:jingle:transports:s5b:1",
"urn:xmpp:jingle:transports:ibb:1", "urn:xmpp:receipts",
"urn:xmpp:chat-markers:0", "http://jabber.org/protocol/muc",
"jabber:x:conference", "http://jabber.org/protocol/caps",
"urn:xmpp:jingle:transports:ibb:1",
"http://jabber.org/protocol/muc",
"jabber:x:conference",
"http://jabber.org/protocol/caps",
"http://jabber.org/protocol/disco#info",
"urn:xmpp:avatar:metadata+notify",
"urn:xmpp:ping"};
public final String[] MESSAGE_CONFIRMATION_FEATURES = {
"urn:xmpp:chat-markers:0",
"urn:xmpp:receipts"
};
public final String IDENTITY_NAME = "Conversations 1.0-beta";
public final String IDENTITY_TYPE = "phone";
@ -43,7 +49,11 @@ public abstract class AbstractGenerator {
} catch (NoSuchAlgorithmException e) {
return null;
}
List<String> features = Arrays.asList(FEATURES);
ArrayList<String> features = new ArrayList<>();
features.addAll(Arrays.asList(FEATURES));
if (mXmppConnectionService.confirmMessages()) {
features.addAll(Arrays.asList(MESSAGE_CONFIRMATION_FEATURES));
}
Collections.sort(features);
for (String feature : features) {
s.append(feature + "<");

View File

@ -49,7 +49,7 @@ public class PresenceGenerator extends AbstractGenerator {
Element cap = packet.addChild("c",
"http://jabber.org/protocol/caps");
cap.setAttribute("hash", "sha-1");
cap.setAttribute("node", "http://conversions.siacs.eu");
cap.setAttribute("node", "http://conversions.im");
cap.setAttribute("ver", capHash);
}
return packet;

View File

@ -140,7 +140,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
account.pendingConferenceLeaves.clear();
fetchRosterFromServer(account);
fetchBookmarks(account);
sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
sendPresence(account);
connectMultiModeConversations(account);
updateConversationUi();
}
@ -2150,6 +2150,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
public void sendPresence(final Account account) {
sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
}
public MessageGenerator getMessageGenerator() {
return this.mMessageGenerator;
}

View File

@ -71,6 +71,14 @@ public class SettingsActivity extends XmppActivity implements
}
} else if (name.equals("keep_foreground_service")) {
xmppConnectionService.toggleForegroundService();
} else if (name.equals("confirm_messages")) {
if (xmppConnectionServiceBound) {
for (Account account : xmppConnectionService.getAccounts()) {
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
xmppConnectionService.sendPresence(account);
}
}
}
}
}

View File

@ -402,9 +402,7 @@ public abstract class XmppActivity extends Activity {
public void success(Account account) {
xmppConnectionService.databaseBackend
.updateAccount(account);
xmppConnectionService.sendPresencePacket(account,
xmppConnectionService.getPresenceGenerator()
.sendPresence(account));
xmppConnectionService.sendPresence(account);
if (conversation != null) {
conversation
.setNextEncryption(Message.ENCRYPTION_PGP);