don't resume old session when changing resource
This commit is contained in:
parent
f880473435
commit
332fe0fd19
|
@ -229,12 +229,18 @@ public class Account extends AbstractEntity {
|
||||||
return jid.getResourcepart();
|
return jid.getResourcepart();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResource(final String resource) {
|
public boolean setResource(final String resource) {
|
||||||
|
final String oldResource = jid.getResourcepart();
|
||||||
|
if (oldResource == null || !oldResource.equals(resource)) {
|
||||||
try {
|
try {
|
||||||
jid = Jid.fromParts(jid.getLocalpart(), jid.getDomainpart(), resource);
|
jid = Jid.fromParts(jid.getLocalpart(), jid.getDomainpart(), resource);
|
||||||
|
return true;
|
||||||
} catch (final InvalidJidException ignored) {
|
} catch (final InvalidJidException ignored) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public Jid getJid() {
|
public Jid getJid() {
|
||||||
return jid;
|
return jid;
|
||||||
|
|
|
@ -54,4 +54,11 @@ public class PresenceGenerator extends AbstractGenerator {
|
||||||
}
|
}
|
||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PresencePacket sendOfflinePresence(Account account) {
|
||||||
|
PresencePacket packet = new PresencePacket();
|
||||||
|
packet.setFrom(account.getJid());
|
||||||
|
packet.setAttribute("type","unavailable");
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1701,6 +1701,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sendOfflinePresence(account);
|
||||||
}
|
}
|
||||||
account.getXmppConnection().disconnect(force);
|
account.getXmppConnection().disconnect(force);
|
||||||
}
|
}
|
||||||
|
@ -2261,6 +2262,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
|
||||||
sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
|
sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sendOfflinePresence(final Account account) {
|
||||||
|
sendPresencePacket(account, mPresenceGenerator.sendOfflinePresence(account));
|
||||||
|
}
|
||||||
|
|
||||||
public MessageGenerator getMessageGenerator() {
|
public MessageGenerator getMessageGenerator() {
|
||||||
return this.mMessageGenerator;
|
return this.mMessageGenerator;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
import eu.siacs.conversations.xmpp.XmppConnection;
|
||||||
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
|
||||||
|
@ -63,12 +64,17 @@ public class SettingsActivity extends XmppActivity implements
|
||||||
.toLowerCase(Locale.US);
|
.toLowerCase(Locale.US);
|
||||||
if (xmppConnectionServiceBound) {
|
if (xmppConnectionServiceBound) {
|
||||||
for (Account account : xmppConnectionService.getAccounts()) {
|
for (Account account : xmppConnectionService.getAccounts()) {
|
||||||
account.setResource(resource);
|
if (account.setResource(resource)) {
|
||||||
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
|
||||||
|
XmppConnection connection = account.getXmppConnection();
|
||||||
|
if (connection != null) {
|
||||||
|
connection.resetStreamId();
|
||||||
|
}
|
||||||
xmppConnectionService.reconnectAccountInBackground(account);
|
xmppConnectionService.reconnectAccountInBackground(account);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (name.equals("keep_foreground_service")) {
|
} else if (name.equals("keep_foreground_service")) {
|
||||||
xmppConnectionService.toggleForegroundService();
|
xmppConnectionService.toggleForegroundService();
|
||||||
} else if (name.equals("confirm_messages")) {
|
} else if (name.equals("confirm_messages")) {
|
||||||
|
|
|
@ -981,6 +981,10 @@ public class XmppConnection implements Runnable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetStreamId() {
|
||||||
|
this.streamId = null;
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> findDiscoItemsByFeature(final String feature) {
|
public List<String> findDiscoItemsByFeature(final String feature) {
|
||||||
final List<String> items = new ArrayList<>();
|
final List<String> items = new ArrayList<>();
|
||||||
for (final Entry<String, List<String>> cursor : disco.entrySet()) {
|
for (final Entry<String, List<String>> cursor : disco.entrySet()) {
|
||||||
|
|
Loading…
Reference in a new issue