adapt caps on whether or not message confirmation is on
This commit is contained in:
parent
94086bb9b7
commit
91e85d2faf
|
@ -5,24 +5,30 @@ import android.util.Base64;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
|
|
||||||
import eu.siacs.conversations.services.XmppConnectionService;
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
|
|
||||||
public abstract class AbstractGenerator {
|
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:apps:file-transfer:3",
|
||||||
"urn:xmpp:jingle:transports:s5b:1",
|
"urn:xmpp:jingle:transports:s5b:1",
|
||||||
"urn:xmpp:jingle:transports:ibb:1", "urn:xmpp:receipts",
|
"urn:xmpp:jingle:transports:ibb:1",
|
||||||
"urn:xmpp:chat-markers:0", "http://jabber.org/protocol/muc",
|
"http://jabber.org/protocol/muc",
|
||||||
"jabber:x:conference", "http://jabber.org/protocol/caps",
|
"jabber:x:conference",
|
||||||
|
"http://jabber.org/protocol/caps",
|
||||||
"http://jabber.org/protocol/disco#info",
|
"http://jabber.org/protocol/disco#info",
|
||||||
"urn:xmpp:avatar:metadata+notify",
|
"urn:xmpp:avatar:metadata+notify",
|
||||||
"urn:xmpp:ping"};
|
"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_NAME = "Conversations 1.0-beta";
|
||||||
public final String IDENTITY_TYPE = "phone";
|
public final String IDENTITY_TYPE = "phone";
|
||||||
|
|
||||||
|
@ -43,7 +49,11 @@ public abstract class AbstractGenerator {
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
return null;
|
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);
|
Collections.sort(features);
|
||||||
for (String feature : features) {
|
for (String feature : features) {
|
||||||
s.append(feature + "<");
|
s.append(feature + "<");
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class PresenceGenerator extends AbstractGenerator {
|
||||||
Element cap = packet.addChild("c",
|
Element cap = packet.addChild("c",
|
||||||
"http://jabber.org/protocol/caps");
|
"http://jabber.org/protocol/caps");
|
||||||
cap.setAttribute("hash", "sha-1");
|
cap.setAttribute("hash", "sha-1");
|
||||||
cap.setAttribute("node", "http://conversions.siacs.eu");
|
cap.setAttribute("node", "http://conversions.im");
|
||||||
cap.setAttribute("ver", capHash);
|
cap.setAttribute("ver", capHash);
|
||||||
}
|
}
|
||||||
return packet;
|
return packet;
|
||||||
|
|
|
@ -140,7 +140,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
account.pendingConferenceLeaves.clear();
|
account.pendingConferenceLeaves.clear();
|
||||||
fetchRosterFromServer(account);
|
fetchRosterFromServer(account);
|
||||||
fetchBookmarks(account);
|
fetchBookmarks(account);
|
||||||
sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
|
sendPresence(account);
|
||||||
connectMultiModeConversations(account);
|
connectMultiModeConversations(account);
|
||||||
updateConversationUi();
|
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() {
|
public MessageGenerator getMessageGenerator() {
|
||||||
return this.mMessageGenerator;
|
return this.mMessageGenerator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,6 +71,14 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
}
|
}
|
||||||
} else if (name.equals("keep_foreground_service")) {
|
} else if (name.equals("keep_foreground_service")) {
|
||||||
xmppConnectionService.toggleForegroundService();
|
xmppConnectionService.toggleForegroundService();
|
||||||
|
} else if (name.equals("confirm_messages")) {
|
||||||
|
if (xmppConnectionServiceBound) {
|
||||||
|
for (Account account : xmppConnectionService.getAccounts()) {
|
||||||
|
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
||||||
|
xmppConnectionService.sendPresence(account);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -402,9 +402,7 @@ public abstract class XmppActivity extends Activity {
|
||||||
public void success(Account account) {
|
public void success(Account account) {
|
||||||
xmppConnectionService.databaseBackend
|
xmppConnectionService.databaseBackend
|
||||||
.updateAccount(account);
|
.updateAccount(account);
|
||||||
xmppConnectionService.sendPresencePacket(account,
|
xmppConnectionService.sendPresence(account);
|
||||||
xmppConnectionService.getPresenceGenerator()
|
|
||||||
.sendPresence(account));
|
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
conversation
|
conversation
|
||||||
.setNextEncryption(Message.ENCRYPTION_PGP);
|
.setNextEncryption(Message.ENCRYPTION_PGP);
|
||||||
|
|
Loading…
Reference in a new issue