diff options
author | Christian Schneppe <christian@pix-art.de> | 2016-05-27 20:44:02 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2016-05-27 20:44:02 +0200 |
commit | 25547747b37770b6ca8227c784488dd4deb5436f (patch) | |
tree | 04274e9063bd17c8d09b1d4663f035d0d8a2ae8f /src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | |
parent | 5edcb7714985e24e0a068eb0970135170f9a17ed (diff) | |
parent | 25f6651848b67d225967cf1bb35e037c998a5682 (diff) |
Merge remote-tracking branch 'refs/remotes/siacs/master'
Diffstat (limited to 'src/main/java/eu/siacs/conversations/services/XmppConnectionService.java')
-rw-r--r-- | src/main/java/eu/siacs/conversations/services/XmppConnectionService.java | 39 |
1 files changed, 30 insertions, 9 deletions
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java index 67370e3ff..ad45d8e9a 100644 --- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java @@ -26,6 +26,7 @@ import android.os.SystemClock; import android.preference.PreferenceManager; import android.provider.ContactsContract; import android.security.KeyChain; +import android.util.Base64; import android.util.DisplayMetrics; import android.util.Log; import android.util.LruCache; @@ -1827,6 +1828,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa account.pendingConferenceLeaves.remove(conversation); if (account.getStatus() == Account.State.ONLINE) { conversation.resetMucOptions(); + if (onConferenceJoined != null) { + conversation.getMucOptions().flagNoAutoPushConfiguration(); + } conversation.setHasMessagesLeftOnServer(false); fetchConferenceConfiguration(conversation, new OnConferenceConfigurationFetched() { @@ -2030,7 +2034,10 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa return null; } - public void createAdhocConference(final Account account, final Iterable<Jid> jids, final UiCallback<Conversation> callback) { + public void createAdhocConference(final Account account, + final String subject, + final Iterable<Jid> jids, + final UiCallback<Conversation> callback) { Log.d(Config.LOGTAG, account.getJid().toBareJid().toString() + ": creating adhoc conference with " + jids.toString()); if (account.getStatus() == Account.State.ONLINE) { try { @@ -2041,26 +2048,24 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa } return; } - String name = new BigInteger(75, getRNG()).toString(32); - Jid jid = Jid.fromParts(name, server, null); + final Jid jid = Jid.fromParts(new BigInteger(64, getRNG()).toString(Character.MAX_RADIX), server, null); final Conversation conversation = findOrCreateConversation(account, jid, true); joinMuc(conversation, new OnConferenceJoined() { @Override public void onConferenceJoined(final Conversation conversation) { - Bundle options = new Bundle(); - options.putString("muc#roomconfig_persistentroom", "1"); - options.putString("muc#roomconfig_membersonly", "1"); - options.putString("muc#roomconfig_publicroom", "0"); - options.putString("muc#roomconfig_whois", "anyone"); - pushConferenceConfiguration(conversation, options, new OnConferenceOptionsPushed() { + pushConferenceConfiguration(conversation, IqGenerator.defaultRoomConfiguration(), new OnConferenceOptionsPushed() { @Override public void onPushSucceeded() { + if (subject != null && !subject.trim().isEmpty()) { + pushSubjectToConference(conversation, subject.trim()); + } for (Jid invite : jids) { invite(conversation, invite); } if (account.countPresences() > 1) { directInvite(conversation, account.getJid().toBareJid()); } + saveConversationAsBookmark(conversation, subject); if (callback != null) { callback.success(conversation); } @@ -2068,6 +2073,7 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa @Override public void onPushFailed() { + archiveConversation(conversation); if (callback != null) { callback.error(R.string.conference_creation_failed, conversation); } @@ -3301,6 +3307,21 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa return templates; } + public void saveConversationAsBookmark(Conversation conversation, String name) { + Account account = conversation.getAccount(); + Bookmark bookmark = new Bookmark(account, conversation.getJid().toBareJid()); + if (!conversation.getJid().isBareJid()) { + bookmark.setNick(conversation.getJid().getResourcepart()); + } + if (name != null && !name.trim().isEmpty()) { + bookmark.setBookmarkName(name.trim()); + } + bookmark.setAutojoin(getPreferences().getBoolean("autojoin",true)); + account.getBookmarks().add(bookmark); + pushBookmarks(account); + conversation.setBookmark(bookmark); + } + public interface OnMamPreferencesFetched { void onPreferencesFetched(Element prefs); void onPreferencesFetchFailed(); |