@@ -1308,7 +1308,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
public void startCommand(Element command, XmppConnectionService xmppConnectionService) {
show();
- CommandSession session = new CommandSession(command.getAttribute("name"), xmppConnectionService);
+ CommandSession session = new CommandSession(command.getAttribute("name"), command.getAttribute("node"), xmppConnectionService);
final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
packet.setTo(command.getAttributeAsJid("jid"));
@@ -2045,6 +2045,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
protected boolean loading = false;
protected Timer loadingTimer = new Timer();
protected String mTitle;
+ protected String mNode;
protected CommandPageBinding mBinding = null;
protected IqPacket response = null;
protected Element responseElement = null;
@@ -2055,9 +2056,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
protected GridLayoutManager layoutManager;
protected WebView actionToWebview = null;
- CommandSession(String title, XmppConnectionService xmppConnectionService) {
+ CommandSession(String title, String node, XmppConnectionService xmppConnectionService) {
loading();
mTitle = title;
+ mNode = node;
this.xmppConnectionService = xmppConnectionService;
if (mPager != null) setupLayoutManager();
actionsAdapter = new ArrayAdapter<String>(xmppConnectionService, R.layout.simple_list_item) {
@@ -2103,6 +2105,10 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
Element command = iq.findChild("command", "http://jabber.org/protocol/commands");
if (iq.getType() == IqPacket.TYPE.RESULT && command != null) {
+ if (mNode.equals("jabber:iq:register") && command.getAttribute("status").equals("completed")) {
+ xmppConnectionService.createContact(getAccount().getRoster().getContact(iq.getFrom()), true);
+ }
+
for (Element el : command.getChildren()) {
if (el.getName().equals("actions") && el.getNamespace().equals("http://jabber.org/protocol/commands")) {
for (Element action : el.getChildren()) {
@@ -2367,7 +2373,7 @@ public class Conversation extends AbstractEntity implements Blockable, Comparabl
final IqPacket packet = new IqPacket(IqPacket.TYPE.SET);
packet.setTo(response.getFrom());
final Element c = packet.addChild("command", Namespace.COMMANDS);
- c.setAttribute("node", command.getAttribute("node"));
+ c.setAttribute("node", mNode);
c.setAttribute("sessionid", command.getAttribute("sessionid"));
c.setAttribute("action", action);
@@ -4271,8 +4271,12 @@ public class XmppConnectionService extends Service {
}
public void updateConversationUi() {
+ updateConversationUi(false);
+ }
+
+ public void updateConversationUi(boolean newCaps) {
for (OnConversationUpdate listener : threadSafeList(this.mOnConversationUpdates)) {
- listener.onConversationUpdate();
+ listener.onConversationUpdate(newCaps);
}
}
@@ -4801,6 +4805,7 @@ public class XmppConnectionService extends Service {
contact.registerAsPhoneAccount(this);
mQuickConversationsService.considerSyncBackground(false);
}
+ updateConversationUi(true);
} else {
final IqPacket request = new IqPacket(IqPacket.TYPE.GET);
request.setTo(jid);
@@ -4822,6 +4827,7 @@ public class XmppConnectionService extends Service {
contact.registerAsPhoneAccount(this);
mQuickConversationsService.considerSyncBackground(false);
}
+ updateConversationUi(true);
if (cb != null) cb.run();
} else {
Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": mismatch in caps for contact " + jid + " " + presence.getVer() + " vs " + discoveryResult.getVer());
@@ -5017,7 +5023,8 @@ public class XmppConnectionService extends Service {
}
public interface OnConversationUpdate {
- void onConversationUpdate();
+ default void onConversationUpdate() { onConversationUpdate(false); }
+ default void onConversationUpdate(boolean newCaps) { onConversationUpdate(); }
}
public interface OnJingleRtpConnectionUpdate {
@@ -119,6 +119,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
private ActivityConversationsBinding binding;
private boolean mActivityPaused = true;
private final AtomicBoolean mRedirectInProcess = new AtomicBoolean(false);
+ private boolean refreshForNewCaps = false;
private static boolean isViewOrShareIntent(Intent i) {
Log.d(Config.LOGTAG, "action: " + (i == null ? null : i.getAction()));
@@ -138,6 +139,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
refreshFragment(id);
}
+ refreshForNewCaps = false;
}
@Override
@@ -256,6 +258,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
final Fragment fragment = getFragmentManager().findFragmentById(id);
if (fragment instanceof XmppFragment) {
((XmppFragment) fragment).refresh();
+ if (refreshForNewCaps) ((XmppFragment) fragment).refreshForNewCaps();
}
}
@@ -705,15 +708,17 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
}
@Override
- public void onConversationUpdate() {
+ public void onConversationUpdate(boolean newCaps) {
if (performRedirectIfNecessary(false)) {
return;
}
+ refreshForNewCaps = newCaps;
this.refreshUi();
}
@Override
public void onRosterUpdate() {
+ refreshForNewCaps = true;
this.refreshUi();
}
@@ -37,6 +37,7 @@ import eu.siacs.conversations.ui.interfaces.OnBackendConnected;
public abstract class XmppFragment extends Fragment implements OnBackendConnected {
abstract void refresh();
+ public void refreshForNewCaps() { }
protected void runOnUiThread(Runnable runnable) {
final Activity activity = getActivity();