M src/main/java/eu/siacs/conversations/entities/Conversation.java => src/main/java/eu/siacs/conversations/entities/Conversation.java +9 -3
@@ 1309,7 1309,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"));
@@ 2046,6 2046,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;
@@ 2056,9 2057,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) {
@@ 2104,6 2106,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()) {
@@ 2368,7 2374,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);
M src/main/java/eu/siacs/conversations/services/XmppConnectionService.java => src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +9 -2
@@ 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 {
M src/main/java/eu/siacs/conversations/ui/ConversationFragment.java => src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +15 -1
@@ 2641,6 2641,10 @@ public class ConversationFragment extends XmppFragment
return true;
}
+ public void refreshForNewCaps() {
+ refreshCommands();
+ }
+
protected void refreshCommands() {
if (commandAdapter == null) return;
@@ 2760,7 2764,17 @@ public class ConversationFragment extends XmppFragment
if (adapter != null && adapter.getCount() > 1) {
binding.conversationViewPager.setCurrentItem(1);
}
- final Jid commandJid = conversation.getContact().resourceWhichSupport(Namespace.COMMANDS);
+ final String jid = extras.getString(ConversationsActivity.EXTRA_JID);
+ Jid commandJid = null;
+ if (jid != null) {
+ try {
+ commandJid = Jid.of(jid);
+ } catch (final IllegalArgumentException e) { }
+ }
+ if (commandJid == null || !commandJid.isFullJid()) {
+ final Jid discoJid = conversation.getContact().resourceWhichSupport(Namespace.COMMANDS);
+ if (discoJid != null) commandJid = discoJid;
+ }
if (node != null && commandJid != null) {
conversation.startCommand(commandFor(commandJid, node), activity.xmppConnectionService);
}
M src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java => src/main/java/eu/siacs/conversations/ui/ConversationsActivity.java +7 -1
@@ 100,6 100,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
public static final String POST_ACTION_RECORD_VOICE = "record_voice";
public static final String EXTRA_TYPE = "type";
public static final String EXTRA_NODE = "node";
+ public static final String EXTRA_JID = "jid";
private static final List<String> VIEW_AND_SHARE_ACTIONS = Arrays.asList(
ACTION_VIEW_CONVERSATION,
@@ 119,6 120,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 140,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
refreshFragment(id);
}
+ refreshForNewCaps = false;
}
@Override
@@ 256,6 259,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 709,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();
}
M src/main/java/eu/siacs/conversations/ui/XmppActivity.java => src/main/java/eu/siacs/conversations/ui/XmppActivity.java +1 -0
@@ 480,6 480,7 @@ public abstract class XmppActivity extends ActionBarActivity {
intent.putExtra(ConversationsActivity.EXTRA_CONVERSATION, xmppConnectionService.findOrCreateConversation(account, jid, false, false).getUuid());
intent.putExtra(ConversationsActivity.EXTRA_POST_INIT_ACTION, "command");
intent.putExtra(ConversationsActivity.EXTRA_NODE, node);
+ intent.putExtra(ConversationsActivity.EXTRA_JID, (CharSequence) jid);
intent.setFlags(intent.getFlags() | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
M src/main/java/eu/siacs/conversations/ui/XmppFragment.java => src/main/java/eu/siacs/conversations/ui/XmppFragment.java +1 -0
@@ 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();