set autojoin=true after following invite

This commit is contained in:
Daniel Gultsch 2019-10-07 09:51:03 +02:00
parent b96ef1e591
commit 4df8343b05
3 changed files with 2414 additions and 2406 deletions

View File

@ -297,7 +297,7 @@ public class XmppConnectionService extends Service {
if (loggedInSuccessfully) { if (loggedInSuccessfully) {
if (!TextUtils.isEmpty(account.getDisplayName())) { if (!TextUtils.isEmpty(account.getDisplayName())) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": display name wasn't empty on first log in. publishing"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": display name wasn't empty on first log in. publishing");
publishDisplayName(account); publishDisplayName(account);
} }
} }
@ -526,8 +526,8 @@ public class XmppConnectionService extends Service {
message.setCounterpart(conversation.getNextCounterpart()); message.setCounterpart(conversation.getNextCounterpart());
message.setType(Message.TYPE_FILE); message.setType(Message.TYPE_FILE);
} }
Log.d(Config.LOGTAG,"attachFile: type="+message.getType()); Log.d(Config.LOGTAG, "attachFile: type=" + message.getType());
Log.d(Config.LOGTAG,"counterpart="+message.getCounterpart()); Log.d(Config.LOGTAG, "counterpart=" + message.getCounterpart());
final AttachFileToConversationRunnable runnable = new AttachFileToConversationRunnable(this, uri, type, message, callback); final AttachFileToConversationRunnable runnable = new AttachFileToConversationRunnable(this, uri, type, message, callback);
if (runnable.isVideoMessage()) { if (runnable.isVideoMessage()) {
mVideoCompressionExecutor.execute(runnable); mVideoCompressionExecutor.execute(runnable);
@ -558,7 +558,7 @@ public class XmppConnectionService extends Service {
message.setCounterpart(conversation.getNextCounterpart()); message.setCounterpart(conversation.getNextCounterpart());
message.setType(Message.TYPE_IMAGE); message.setType(Message.TYPE_IMAGE);
} }
Log.d(Config.LOGTAG,"attachImage: type="+message.getType()); Log.d(Config.LOGTAG, "attachImage: type=" + message.getType());
mFileAddingExecutor.execute(() -> { mFileAddingExecutor.execute(() -> {
try { try {
getFileBackend().copyImageToPrivateStorage(message, uri); getFileBackend().copyImageToPrivateStorage(message, uri);
@ -601,7 +601,7 @@ public class XmppConnectionService extends Service {
final String action = intent == null ? null : intent.getAction(); final String action = intent == null ? null : intent.getAction();
final boolean needsForegroundService = intent != null && intent.getBooleanExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, false); final boolean needsForegroundService = intent != null && intent.getBooleanExtra(EventReceiver.EXTRA_NEEDS_FOREGROUND_SERVICE, false);
if (needsForegroundService) { if (needsForegroundService) {
Log.d(Config.LOGTAG,"toggle forced foreground service after receiving event (action="+action+")"); Log.d(Config.LOGTAG, "toggle forced foreground service after receiving event (action=" + action + ")");
toggleForegroundService(true); toggleForegroundService(true);
} }
String pushedAccountHash = null; String pushedAccountHash = null;
@ -837,12 +837,12 @@ public class XmppConnectionService extends Service {
} }
private void checkMucStillJoined(final Account account, final String hash, final String androidId) { private void checkMucStillJoined(final Account account, final String hash, final String androidId) {
for(final Conversation conversation : this.conversations) { for (final Conversation conversation : this.conversations) {
if (conversation.getAccount() == account && conversation.getMode() == Conversational.MODE_MULTI) { if (conversation.getAccount() == account && conversation.getMode() == Conversational.MODE_MULTI) {
Jid jid = conversation.getJid().asBareJid(); Jid jid = conversation.getJid().asBareJid();
final String currentHash = CryptoHelper.getFingerprint(jid, androidId); final String currentHash = CryptoHelper.getFingerprint(jid, androidId);
if (currentHash.equals(hash)) { if (currentHash.equals(hash)) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received cloud push notification for MUC "+jid); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received cloud push notification for MUC " + jid);
return; return;
} }
} }
@ -1050,7 +1050,7 @@ public class XmppConnectionService extends Service {
try { try {
Security.insertProviderAt(Conscrypt.newProvider(), 1); Security.insertProviderAt(Conscrypt.newProvider(), 1);
} catch (Throwable throwable) { } catch (Throwable throwable) {
Log.e(Config.LOGTAG,"unable to initialize security provider", throwable); Log.e(Config.LOGTAG, "unable to initialize security provider", throwable);
} }
Resolver.init(this); Resolver.init(this);
this.mRandom = new SecureRandom(); this.mRandom = new SecureRandom();
@ -1137,7 +1137,7 @@ public class XmppConnectionService extends Service {
final long start = SystemClock.elapsedRealtime(); final long start = SystemClock.elapsedRealtime();
final List<DatabaseBackend.FilePathInfo> relativeFilePaths = databaseBackend.getFilePathInfo(); final List<DatabaseBackend.FilePathInfo> relativeFilePaths = databaseBackend.getFilePathInfo();
final List<DatabaseBackend.FilePathInfo> changed = new ArrayList<>(); final List<DatabaseBackend.FilePathInfo> changed = new ArrayList<>();
for(final DatabaseBackend.FilePathInfo filePath : relativeFilePaths) { for (final DatabaseBackend.FilePathInfo filePath : relativeFilePaths) {
if (destroyed) { if (destroyed) {
Log.d(Config.LOGTAG, "Stop checking for deleted files because service has been destroyed"); Log.d(Config.LOGTAG, "Stop checking for deleted files because service has been destroyed");
return; return;
@ -1148,7 +1148,7 @@ public class XmppConnectionService extends Service {
} }
} }
final long duration = SystemClock.elapsedRealtime() - start; final long duration = SystemClock.elapsedRealtime() - start;
Log.d(Config.LOGTAG,"found "+changed.size()+" changed files on start up. total="+relativeFilePaths.size()+". ("+duration+"ms)"); Log.d(Config.LOGTAG, "found " + changed.size() + " changed files on start up. total=" + relativeFilePaths.size() + ". (" + duration + "ms)");
if (changed.size() > 0) { if (changed.size() > 0) {
databaseBackend.markFilesAsChanged(changed); databaseBackend.markFilesAsChanged(changed);
markChangedFiles(changed); markChangedFiles(changed);
@ -1229,7 +1229,7 @@ public class XmppConnectionService extends Service {
if (!mForceForegroundService.get()) { if (!mForceForegroundService.get()) {
mNotificationService.dismissForcedForegroundNotification(); //if the channel was changed the previous call might fail mNotificationService.dismissForcedForegroundNotification(); //if the channel was changed the previous call might fail
} }
Log.d(Config.LOGTAG,"ForegroundService: "+(status?"on":"off")); Log.d(Config.LOGTAG, "ForegroundService: " + (status ? "on" : "off"));
} }
public boolean foregroundNotificationNeedsUpdatingWhenErrorStateChanges() { public boolean foregroundNotificationNeedsUpdatingWhenErrorStateChanges() {
@ -1369,7 +1369,7 @@ public class XmppConnectionService extends Service {
if (QuickConversationsService.isQuicksy() && conversation.getMode() == Conversation.MODE_SINGLE) { if (QuickConversationsService.isQuicksy() && conversation.getMode() == Conversation.MODE_SINGLE) {
final Contact contact = conversation.getContact(); final Contact contact = conversation.getContact();
if (!contact.showInRoster() && contact.getOption(Contact.Options.SYNCED_VIA_OTHER)) { if (!contact.showInRoster() && contact.getOption(Contact.Options.SYNCED_VIA_OTHER)) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": adding "+contact.getJid()+" on sending message"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": adding " + contact.getJid() + " on sending message");
createContact(contact, true); createContact(contact, true);
} }
} }
@ -1460,7 +1460,7 @@ public class XmppConnectionService extends Service {
message.setBody(decryptedBody); message.setBody(decryptedBody);
message.setEncryption(Message.ENCRYPTION_DECRYPTED); message.setEncryption(Message.ENCRYPTION_DECRYPTED);
if (!databaseBackend.updateMessage(message, message.getEditedId())) { if (!databaseBackend.updateMessage(message, message.getEditedId())) {
Log.e(Config.LOGTAG,"error updated message in DB after edit"); Log.e(Config.LOGTAG, "error updated message in DB after edit");
} }
updateConversationUi(); updateConversationUi();
return; return;
@ -1500,7 +1500,7 @@ public class XmppConnectionService extends Service {
databaseBackend.createMessage(message); databaseBackend.createMessage(message);
} else if (message.edited()) { } else if (message.edited()) {
if (!databaseBackend.updateMessage(message, message.getEditedId())) { if (!databaseBackend.updateMessage(message, message.getEditedId())) {
Log.e(Config.LOGTAG,"error updated message in DB after edit"); Log.e(Config.LOGTAG, "error updated message in DB after edit");
} }
} }
updateConversationUi(); updateConversationUi();
@ -1526,7 +1526,7 @@ public class XmppConnectionService extends Service {
final boolean pending = account.pendingConferenceJoins.contains(conversation); final boolean pending = account.pendingConferenceJoins.contains(conversation);
final boolean inProgressJoin = inProgress || pending; final boolean inProgressJoin = inProgress || pending;
if (inProgressJoin) { if (inProgressJoin) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": holding back message to group. inProgress="+inProgress+", pending="+pending); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": holding back message to group. inProgress=" + inProgress + ", pending=" + pending);
} }
return inProgressJoin; return inProgressJoin;
} else { } else {
@ -1586,7 +1586,7 @@ public class XmppConnectionService extends Service {
}); });
} }
public void processBookmarksInitial(Account account, Map<Jid,Bookmark> bookmarks, final boolean pep) { public void processBookmarksInitial(Account account, Map<Jid, Bookmark> bookmarks, final boolean pep) {
final Set<Jid> previousBookmarks = account.getBookmarkedJids(); final Set<Jid> previousBookmarks = account.getBookmarkedJids();
final boolean synchronizeWithBookmarks = synchronizeWithBookmarks(); final boolean synchronizeWithBookmarks = synchronizeWithBookmarks();
for (Bookmark bookmark : bookmarks.values()) { for (Bookmark bookmark : bookmarks.values()) {
@ -1605,7 +1605,7 @@ public class XmppConnectionService extends Service {
public void processDeletedBookmark(Account account, Jid jid) { public void processDeletedBookmark(Account account, Jid jid) {
final Conversation conversation = find(account, jid); final Conversation conversation = find(account, jid);
if (conversation != null && conversation.getMucOptions().getError() == MucOptions.Error.DESTROYED) { if (conversation != null && conversation.getMucOptions().getError() == MucOptions.Error.DESTROYED) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": archiving destroyed conference ("+conversation.getJid()+") after receiving pep"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving destroyed conference (" + conversation.getJid() + ") after receiving pep");
archiveConversation(conversation, false); archiveConversation(conversation, false);
} }
} }
@ -1619,7 +1619,7 @@ public class XmppConnectionService extends Service {
} }
bookmark.setConversation(conversation); bookmark.setConversation(conversation);
if (pep && synchronizeWithBookmarks && !bookmark.autojoin()) { if (pep && synchronizeWithBookmarks && !bookmark.autojoin()) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": archiving conference ("+conversation.getJid()+") after receiving pep"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": archiving conference (" + conversation.getJid() + ") after receiving pep");
archiveConversation(conversation, false); archiveConversation(conversation, false);
} else { } else {
final MucOptions mucOptions = conversation.getMucOptions(); final MucOptions mucOptions = conversation.getMucOptions();
@ -1627,7 +1627,7 @@ public class XmppConnectionService extends Service {
final String current = mucOptions.getActualNick(); final String current = mucOptions.getActualNick();
final String proposed = mucOptions.getProposedNick(); final String proposed = mucOptions.getProposedNick();
if (current != null && !current.equals(proposed)) { if (current != null && !current.equals(proposed)) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": proposed nick changed after bookmark push "+current+"->"+proposed); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": proposed nick changed after bookmark push " + current + "->" + proposed);
joinMuc(conversation); joinMuc(conversation);
} }
} }
@ -1661,10 +1661,9 @@ public class XmppConnectionService extends Service {
final XmppConnection connection = account.getXmppConnection(); final XmppConnection connection = account.getXmppConnection();
if (connection.getFeatures().bookmarksConversion()) { if (connection.getFeatures().bookmarksConversion()) {
IqPacket request = mIqGenerator.deleteItem(Namespace.BOOKMARKS2, bookmark.getJid().asBareJid().toEscapedString()); IqPacket request = mIqGenerator.deleteItem(Namespace.BOOKMARKS2, bookmark.getJid().asBareJid().toEscapedString());
sendIqPacket(account, request, new OnIqPacketReceived() { sendIqPacket(account, request, (a, response) -> {
@Override if (response.getType() == IqPacket.TYPE.ERROR) {
public void onIqPacketReceived(Account account, IqPacket packet) { Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": unable to delete bookmark " + response.getError());
Log.d(Config.LOGTAG,packet.toString());
} }
}); });
} else if (connection.getFeatures().bookmarksConversion()) { } else if (connection.getFeatures().bookmarksConversion()) {
@ -1691,7 +1690,7 @@ public class XmppConnectionService extends Service {
for (Bookmark bookmark : account.getBookmarks()) { for (Bookmark bookmark : account.getBookmarks()) {
storage.addChild(bookmark); storage.addChild(bookmark);
} }
pushNodeAndEnforcePublishOptions(account,Namespace.BOOKMARKS,storage, PublishOptions.persistentWhitelistAccess()); pushNodeAndEnforcePublishOptions(account, Namespace.BOOKMARKS, storage, PublishOptions.persistentWhitelistAccess());
} }
@ -1720,11 +1719,11 @@ public class XmppConnectionService extends Service {
@Override @Override
public void onPushFailed() { public void onPushFailed() {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": unable to push node configuration ("+node+")"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to push node configuration (" + node + ")");
} }
}); });
} else { } else {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": error publishing bookmarks (retry="+Boolean.toString(retry)+") "+response); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": error publishing bookmarks (retry=" + Boolean.toString(retry) + ") " + response);
} }
}); });
} }
@ -1771,7 +1770,7 @@ public class XmppConnectionService extends Service {
restoreMessages(quickLoad); restoreMessages(quickLoad);
updateConversationUi(); updateConversationUi();
final long diffMessageRestore = SystemClock.elapsedRealtime() - startMessageRestore; final long diffMessageRestore = SystemClock.elapsedRealtime() - startMessageRestore;
Log.d(Config.LOGTAG,"quickly restored "+quickLoad.getName()+" after " + diffMessageRestore + "ms"); Log.d(Config.LOGTAG, "quickly restored " + quickLoad.getName() + " after " + diffMessageRestore + "ms");
} }
for (Conversation conversation : this.conversations) { for (Conversation conversation : this.conversations) {
if (quickLoad != conversation) { if (quickLoad != conversation) {
@ -1835,7 +1834,7 @@ public class XmppConnectionService extends Service {
final File file = new File(path); final File file = new File(path);
final boolean isInternalFile = fileBackend.isInternalFile(file); final boolean isInternalFile = fileBackend.isInternalFile(file);
final List<String> uuids = databaseBackend.markFileAsDeleted(file, isInternalFile); final List<String> uuids = databaseBackend.markFileAsDeleted(file, isInternalFile);
Log.d(Config.LOGTAG, "deleted file " + path+" internal="+isInternalFile+", database hits="+uuids.size()); Log.d(Config.LOGTAG, "deleted file " + path + " internal=" + isInternalFile + ", database hits=" + uuids.size());
markUuidsAsDeletedFiles(uuids); markUuidsAsDeletedFiles(uuids);
} }
@ -1873,7 +1872,7 @@ public class XmppConnectionService extends Service {
orderedUuids = null; orderedUuids = null;
} else { } else {
orderedUuids = new ArrayList<>(); orderedUuids = new ArrayList<>();
for(Conversation conversation : list) { for (Conversation conversation : list) {
orderedUuids.add(conversation.getUuid()); orderedUuids.add(conversation.getUuid());
} }
} }
@ -2149,7 +2148,7 @@ public class XmppConnectionService extends Service {
final int targetState = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED; final int targetState = enabled ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED : PackageManager.COMPONENT_ENABLED_STATE_DISABLED;
getPackageManager().setComponentEnabledSetting(name, targetState, PackageManager.DONT_KILL_APP); getPackageManager().setComponentEnabledSetting(name, targetState, PackageManager.DONT_KILL_APP);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
Log.d(Config.LOGTAG,"unable to toggle profile picture actvitiy"); Log.d(Config.LOGTAG, "unable to toggle profile picture actvitiy");
} }
} }
@ -2292,7 +2291,7 @@ public class XmppConnectionService extends Service {
synchronized (LISTENER_LOCK) { synchronized (LISTENER_LOCK) {
remainingListeners = checkListeners(); remainingListeners = checkListeners();
if (!this.mOnConversationUpdates.add(listener)) { if (!this.mOnConversationUpdates.add(listener)) {
Log.w(Config.LOGTAG,listener.getClass().getName()+" is already registered as ConversationListChangedListener"); Log.w(Config.LOGTAG, listener.getClass().getName() + " is already registered as ConversationListChangedListener");
} }
this.mNotificationService.setIsInForeground(this.mOnConversationUpdates.size() > 0); this.mNotificationService.setIsInForeground(this.mOnConversationUpdates.size() > 0);
} }
@ -2318,7 +2317,7 @@ public class XmppConnectionService extends Service {
synchronized (LISTENER_LOCK) { synchronized (LISTENER_LOCK) {
remainingListeners = checkListeners(); remainingListeners = checkListeners();
if (!this.mOnShowErrorToasts.add(listener)) { if (!this.mOnShowErrorToasts.add(listener)) {
Log.w(Config.LOGTAG,listener.getClass().getName()+" is already registered as OnShowErrorToastListener"); Log.w(Config.LOGTAG, listener.getClass().getName() + " is already registered as OnShowErrorToastListener");
} }
} }
if (remainingListeners) { if (remainingListeners) {
@ -2342,7 +2341,7 @@ public class XmppConnectionService extends Service {
synchronized (LISTENER_LOCK) { synchronized (LISTENER_LOCK) {
remainingListeners = checkListeners(); remainingListeners = checkListeners();
if (!this.mOnAccountUpdates.add(listener)) { if (!this.mOnAccountUpdates.add(listener)) {
Log.w(Config.LOGTAG,listener.getClass().getName()+" is already registered as OnAccountListChangedtListener"); Log.w(Config.LOGTAG, listener.getClass().getName() + " is already registered as OnAccountListChangedtListener");
} }
} }
if (remainingListeners) { if (remainingListeners) {
@ -2366,7 +2365,7 @@ public class XmppConnectionService extends Service {
synchronized (LISTENER_LOCK) { synchronized (LISTENER_LOCK) {
remainingListeners = checkListeners(); remainingListeners = checkListeners();
if (!this.mOnCaptchaRequested.add(listener)) { if (!this.mOnCaptchaRequested.add(listener)) {
Log.w(Config.LOGTAG,listener.getClass().getName()+" is already registered as OnCaptchaRequestListener"); Log.w(Config.LOGTAG, listener.getClass().getName() + " is already registered as OnCaptchaRequestListener");
} }
} }
if (remainingListeners) { if (remainingListeners) {
@ -2390,7 +2389,7 @@ public class XmppConnectionService extends Service {
synchronized (LISTENER_LOCK) { synchronized (LISTENER_LOCK) {
remainingListeners = checkListeners(); remainingListeners = checkListeners();
if (!this.mOnRosterUpdates.add(listener)) { if (!this.mOnRosterUpdates.add(listener)) {
Log.w(Config.LOGTAG,listener.getClass().getName()+" is already registered as OnRosterUpdateListener"); Log.w(Config.LOGTAG, listener.getClass().getName() + " is already registered as OnRosterUpdateListener");
} }
} }
if (remainingListeners) { if (remainingListeners) {
@ -2414,7 +2413,7 @@ public class XmppConnectionService extends Service {
synchronized (LISTENER_LOCK) { synchronized (LISTENER_LOCK) {
remainingListeners = checkListeners(); remainingListeners = checkListeners();
if (!this.mOnUpdateBlocklist.add(listener)) { if (!this.mOnUpdateBlocklist.add(listener)) {
Log.w(Config.LOGTAG,listener.getClass().getName()+" is already registered as OnUpdateBlocklistListener"); Log.w(Config.LOGTAG, listener.getClass().getName() + " is already registered as OnUpdateBlocklistListener");
} }
} }
if (remainingListeners) { if (remainingListeners) {
@ -2438,7 +2437,7 @@ public class XmppConnectionService extends Service {
synchronized (LISTENER_LOCK) { synchronized (LISTENER_LOCK) {
remainingListeners = checkListeners(); remainingListeners = checkListeners();
if (!this.mOnKeyStatusUpdated.add(listener)) { if (!this.mOnKeyStatusUpdated.add(listener)) {
Log.w(Config.LOGTAG,listener.getClass().getName()+" is already registered as OnKeyStatusUpdateListener"); Log.w(Config.LOGTAG, listener.getClass().getName() + " is already registered as OnKeyStatusUpdateListener");
} }
} }
if (remainingListeners) { if (remainingListeners) {
@ -2462,7 +2461,7 @@ public class XmppConnectionService extends Service {
synchronized (LISTENER_LOCK) { synchronized (LISTENER_LOCK) {
remainingListeners = checkListeners(); remainingListeners = checkListeners();
if (!this.mOnMucRosterUpdate.add(listener)) { if (!this.mOnMucRosterUpdate.add(listener)) {
Log.w(Config.LOGTAG,listener.getClass().getName()+" is already registered as OnMucRosterListener"); Log.w(Config.LOGTAG, listener.getClass().getName() + " is already registered as OnMucRosterListener");
} }
} }
if (remainingListeners) { if (remainingListeners) {
@ -2562,7 +2561,7 @@ public class XmppConnectionService extends Service {
} }
synchronized (account.inProgressConferencePings) { synchronized (account.inProgressConferencePings) {
if (!account.inProgressConferencePings.add(conversation)) { if (!account.inProgressConferencePings.add(conversation)) {
Log.d(Config.LOGTAG, account.getJid().asBareJid()+": canceling muc self ping because ping is already under way"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": canceling muc self ping because ping is already under way");
return; return;
} }
} }
@ -2574,13 +2573,13 @@ public class XmppConnectionService extends Service {
if (response.getType() == IqPacket.TYPE.ERROR) { if (response.getType() == IqPacket.TYPE.ERROR) {
Element error = response.findChild("error"); Element error = response.findChild("error");
if (error == null || error.hasChild("service-unavailable") || error.hasChild("feature-not-implemented") || error.hasChild("item-not-found")) { if (error == null || error.hasChild("service-unavailable") || error.hasChild("feature-not-implemented") || error.hasChild("item-not-found")) {
Log.d(Config.LOGTAG,a.getJid().asBareJid()+": ping to "+self+" came back as ignorable error"); Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": ping to " + self + " came back as ignorable error");
} else { } else {
Log.d(Config.LOGTAG,a.getJid().asBareJid()+": ping to "+self+" failed. attempting rejoin"); Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": ping to " + self + " failed. attempting rejoin");
joinMuc(conversation); joinMuc(conversation);
} }
} else if (response.getType() == IqPacket.TYPE.RESULT) { } else if (response.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG,a.getJid().asBareJid()+": ping to "+self+" came back fine"); Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": ping to " + self + " came back fine");
} }
synchronized (account.inProgressConferencePings) { synchronized (account.inProgressConferencePings) {
account.inProgressConferencePings.remove(conversation); account.inProgressConferencePings.remove(conversation);
@ -2668,10 +2667,19 @@ public class XmppConnectionService extends Service {
} }
if (mucOptions.isPrivateAndNonAnonymous()) { if (mucOptions.isPrivateAndNonAnonymous()) {
fetchConferenceMembers(conversation); fetchConferenceMembers(conversation);
if (followedInvite && conversation.getBookmark() == null) {
if (followedInvite) {
final Bookmark bookmark = conversation.getBookmark();
if (bookmark != null) {
if (!bookmark.autojoin()) {
bookmark.setAutojoin(true);
createBookmark(account, bookmark);
}
} else {
saveConversationAsBookmark(conversation, null); saveConversationAsBookmark(conversation, null);
} }
} }
}
if (mucOptions.push()) { if (mucOptions.push()) {
enableMucPush(conversation); enableMucPush(conversation);
} }
@ -2684,7 +2692,7 @@ public class XmppConnectionService extends Service {
@Override @Override
public void onConferenceConfigurationFetched(Conversation conversation) { public void onConferenceConfigurationFetched(Conversation conversation) {
if (conversation.getStatus() == Conversation.STATUS_ARCHIVED) { if (conversation.getStatus() == Conversation.STATUS_ARCHIVED) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": conversation ("+conversation.getJid()+") got archived before IQ result"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": conversation (" + conversation.getJid() + ") got archived before IQ result");
return; return;
} }
join(conversation); join(conversation);
@ -2693,7 +2701,7 @@ public class XmppConnectionService extends Service {
@Override @Override
public void onFetchFailed(final Conversation conversation, Element error) { public void onFetchFailed(final Conversation conversation, Element error) {
if (conversation.getStatus() == Conversation.STATUS_ARCHIVED) { if (conversation.getStatus() == Conversation.STATUS_ARCHIVED) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": conversation ("+conversation.getJid()+") got archived before IQ result"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": conversation (" + conversation.getJid() + ") got archived before IQ result");
return; return;
} }
@ -2727,9 +2735,9 @@ public class XmppConnectionService extends Service {
enable.setTo(room); enable.setTo(room);
sendIqPacket(account, enable, (a, response) -> { sendIqPacket(account, enable, (a, response) -> {
if (response.getType() == IqPacket.TYPE.RESULT) { if (response.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG,a.getJid().asBareJid()+": enabled direct push for muc "+room); Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": enabled direct push for muc " + room);
} else if (response.getType() == IqPacket.TYPE.ERROR) { } else if (response.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG,a.getJid().asBareJid()+": unable to enable direct push for muc "+room+" "+response.getError()); Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": unable to enable direct push for muc " + room + " " + response.getError());
} }
}); });
} }
@ -2746,9 +2754,9 @@ public class XmppConnectionService extends Service {
disable.setTo(room); disable.setTo(room);
sendIqPacket(account, disable, (a, response) -> { sendIqPacket(account, disable, (a, response) -> {
if (response.getType() == IqPacket.TYPE.RESULT) { if (response.getType() == IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG,a.getJid().asBareJid()+": disabled direct push for muc "+room); Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": disabled direct push for muc " + room);
} else if (response.getType() == IqPacket.TYPE.ERROR) { } else if (response.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG,a.getJid().asBareJid()+": unable to disable direct push for muc "+room+" "+response.getError()); Log.d(Config.LOGTAG, a.getJid().asBareJid() + ": unable to disable direct push for muc " + room + " " + response.getError());
} }
}); });
} }
@ -2851,7 +2859,7 @@ public class XmppConnectionService extends Service {
} }
public void getAttachments(final Account account, final Jid jid, final int limit, final OnMediaLoaded onMediaLoaded) { public void getAttachments(final Account account, final Jid jid, final int limit, final OnMediaLoaded onMediaLoaded) {
getAttachments(account.getUuid(),jid.asBareJid(),limit, onMediaLoaded); getAttachments(account.getUuid(), jid.asBareJid(), limit, onMediaLoaded);
} }
@ -2875,7 +2883,7 @@ public class XmppConnectionService extends Service {
final Account account = conversation.getAccount(); final Account account = conversation.getAccount();
final String defaultNick = MucOptions.defaultNick(account); final String defaultNick = MucOptions.defaultNick(account);
if (TextUtils.isEmpty(bookmarkedNick) && full.getResource().equals(defaultNick)) { if (TextUtils.isEmpty(bookmarkedNick) && full.getResource().equals(defaultNick)) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": do not overwrite empty bookmark nick with default nick for "+conversation.getJid().asBareJid()); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": do not overwrite empty bookmark nick with default nick for " + conversation.getJid().asBareJid());
return; return;
} }
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": persist nick '" + full.getResource() + "' into bookmark for " + conversation.getJid().asBareJid()); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": persist nick '" + full.getResource() + "' into bookmark for " + conversation.getJid().asBareJid());
@ -3024,9 +3032,9 @@ public class XmppConnectionService extends Service {
for (Jid invite : jids) { for (Jid invite : jids) {
invite(conversation, invite); invite(conversation, invite);
} }
for(String resource : account.getSelfContact().getPresences().toResourceArray()) { for (String resource : account.getSelfContact().getPresences().toResourceArray()) {
Jid other = account.getJid().withResource(resource); Jid other = account.getJid().withResource(resource);
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": sending direct invite to "+other); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": sending direct invite to " + other);
directInvite(conversation, other); directInvite(conversation, other);
} }
saveConversationAsBookmark(conversation, name); saveConversationAsBookmark(conversation, name);
@ -3095,7 +3103,7 @@ public class XmppConnectionService extends Service {
updateConversationUi(); updateConversationUi();
} else if (packet.getType() == IqPacket.TYPE.TIMEOUT) { } else if (packet.getType() == IqPacket.TYPE.TIMEOUT) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": received timeout waiting for conference configuration fetch"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": received timeout waiting for conference configuration fetch");
} else { } else {
if (callback != null) { if (callback != null) {
callback.onFetchFailed(conversation, packet.getError()); callback.onFetchFailed(conversation, packet.getError());
@ -3110,7 +3118,7 @@ public class XmppConnectionService extends Service {
} }
public void pushNodeConfiguration(Account account, final Jid jid, final String node, final Bundle options, final OnConfigurationPushed callback) { public void pushNodeConfiguration(Account account, final Jid jid, final String node, final Bundle options, final OnConfigurationPushed callback) {
Log.d(Config.LOGTAG,"pushing node configuration"); Log.d(Config.LOGTAG, "pushing node configuration");
sendIqPacket(account, mIqGenerator.requestPubsubConfiguration(jid, node), new OnIqPacketReceived() { sendIqPacket(account, mIqGenerator.requestPubsubConfiguration(jid, node), new OnIqPacketReceived() {
@Override @Override
public void onIqPacketReceived(Account account, IqPacket packet) { public void onIqPacketReceived(Account account, IqPacket packet) {
@ -3125,7 +3133,7 @@ public class XmppConnectionService extends Service {
@Override @Override
public void onIqPacketReceived(Account account, IqPacket packet) { public void onIqPacketReceived(Account account, IqPacket packet) {
if (packet.getType() == IqPacket.TYPE.RESULT && callback != null) { if (packet.getType() == IqPacket.TYPE.RESULT && callback != null) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": successfully changed node configuration for node "+node); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": successfully changed node configuration for node " + node);
callback.onPushSucceeded(); callback.onPushSucceeded();
} else if (packet.getType() == IqPacket.TYPE.ERROR && callback != null) { } else if (packet.getType() == IqPacket.TYPE.ERROR && callback != null) {
callback.onPushFailed(); callback.onPushFailed();
@ -3143,8 +3151,8 @@ public class XmppConnectionService extends Service {
} }
public void pushConferenceConfiguration(final Conversation conversation, final Bundle options, final OnConfigurationPushed callback) { public void pushConferenceConfiguration(final Conversation conversation, final Bundle options, final OnConfigurationPushed callback) {
if (options.getString("muc#roomconfig_whois","moderators").equals("anyone")) { if (options.getString("muc#roomconfig_whois", "moderators").equals("anyone")) {
conversation.setAttribute("accept_non_anonymous",true); conversation.setAttribute("accept_non_anonymous", true);
updateConversation(conversation); updateConversation(conversation);
} }
IqPacket request = new IqPacket(IqPacket.TYPE.GET); IqPacket request = new IqPacket(IqPacket.TYPE.GET);
@ -3218,7 +3226,7 @@ public class XmppConnectionService extends Service {
Log.d(Config.LOGTAG, request.toString()); Log.d(Config.LOGTAG, request.toString());
sendIqPacket(conference.getAccount(), request, (account, packet) -> { sendIqPacket(conference.getAccount(), request, (account, packet) -> {
if (packet.getType() != IqPacket.TYPE.RESULT) { if (packet.getType() != IqPacket.TYPE.RESULT) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+" unable to change role of "+nick); Log.d(Config.LOGTAG, account.getJid().asBareJid() + " unable to change role of " + nick);
} }
}); });
} }
@ -3278,7 +3286,7 @@ public class XmppConnectionService extends Service {
public void updateMessage(Message message, String uuid) { public void updateMessage(Message message, String uuid) {
if (!databaseBackend.updateMessage(message, uuid)) { if (!databaseBackend.updateMessage(message, uuid)) {
Log.e(Config.LOGTAG,"error updated message in DB after edit"); Log.e(Config.LOGTAG, "error updated message in DB after edit");
} }
updateConversationUi(); updateConversationUi();
} }
@ -3350,7 +3358,7 @@ public class XmppConnectionService extends Service {
final Avatar avatar = getFileBackend().getPepAvatar(image, size, format); final Avatar avatar = getFileBackend().getPepAvatar(image, size, format);
if (avatar != null) { if (avatar != null) {
if (!getFileBackend().save(avatar)) { if (!getFileBackend().save(avatar)) {
Log.d(Config.LOGTAG,"unable to save vcard"); Log.d(Config.LOGTAG, "unable to save vcard");
callback.onAvatarPublicationFailed(R.string.error_saving_avatar); callback.onAvatarPublicationFailed(R.string.error_saving_avatar);
return; return;
} }
@ -3407,25 +3415,25 @@ public class XmppConnectionService extends Service {
} }
public void publishAvatar(Account account, final Avatar avatar, final Bundle options, final boolean retry, final OnAvatarPublication callback) { public void publishAvatar(Account account, final Avatar avatar, final Bundle options, final boolean retry, final OnAvatarPublication callback) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": publishing avatar. options="+options); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": publishing avatar. options=" + options);
IqPacket packet = this.mIqGenerator.publishAvatar(avatar, options); IqPacket packet = this.mIqGenerator.publishAvatar(avatar, options);
this.sendIqPacket(account, packet, new OnIqPacketReceived() { this.sendIqPacket(account, packet, new OnIqPacketReceived() {
@Override @Override
public void onIqPacketReceived(Account account, IqPacket result) { public void onIqPacketReceived(Account account, IqPacket result) {
if (result.getType() == IqPacket.TYPE.RESULT) { if (result.getType() == IqPacket.TYPE.RESULT) {
publishAvatarMetadata(account, avatar, options,true, callback); publishAvatarMetadata(account, avatar, options, true, callback);
} else if (retry && PublishOptions.preconditionNotMet(result)) { } else if (retry && PublishOptions.preconditionNotMet(result)) {
pushNodeConfiguration(account, "urn:xmpp:avatar:data", options, new OnConfigurationPushed() { pushNodeConfiguration(account, "urn:xmpp:avatar:data", options, new OnConfigurationPushed() {
@Override @Override
public void onPushSucceeded() { public void onPushSucceeded() {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": changed node configuration for avatar node"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": changed node configuration for avatar node");
publishAvatar(account, avatar, options, false, callback); publishAvatar(account, avatar, options, false, callback);
} }
@Override @Override
public void onPushFailed() { public void onPushFailed() {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": unable to change node configuration for avatar node"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to change node configuration for avatar node");
publishAvatar(account, avatar, null, false, callback); publishAvatar(account, avatar, null, false, callback);
} }
}); });
@ -3459,14 +3467,14 @@ public class XmppConnectionService extends Service {
pushNodeConfiguration(account, "urn:xmpp:avatar:metadata", options, new OnConfigurationPushed() { pushNodeConfiguration(account, "urn:xmpp:avatar:metadata", options, new OnConfigurationPushed() {
@Override @Override
public void onPushSucceeded() { public void onPushSucceeded() {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": changed node configuration for avatar meta data node"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": changed node configuration for avatar meta data node");
publishAvatarMetadata(account, avatar, options,false, callback); publishAvatarMetadata(account, avatar, options, false, callback);
} }
@Override @Override
public void onPushFailed() { public void onPushFailed() {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": unable to change node configuration for avatar meta data node"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": unable to change node configuration for avatar meta data node");
publishAvatarMetadata(account, avatar, null,false, callback); publishAvatarMetadata(account, avatar, null, false, callback);
} }
}); });
} else { } else {
@ -3543,7 +3551,7 @@ public class XmppConnectionService extends Service {
} else if (avatar.origin == Avatar.Origin.PEP) { } else if (avatar.origin == Avatar.Origin.PEP) {
mOmittedPepAvatarFetches.add(KEY); mOmittedPepAvatarFetches.add(KEY);
} else { } else {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": already fetching "+avatar.origin+" avatar for "+avatar.owner); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": already fetching " + avatar.origin + " avatar for " + avatar.owner);
} }
} }
} }
@ -3620,7 +3628,7 @@ public class XmppConnectionService extends Service {
avatar.image = image; avatar.image = image;
if (getFileBackend().save(avatar)) { if (getFileBackend().save(avatar)) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() Log.d(Config.LOGTAG, account.getJid().asBareJid()
+ ": successfully fetched vCard avatar for " + avatar.owner+" omittedPep="+previouslyOmittedPepFetch); + ": successfully fetched vCard avatar for " + avatar.owner + " omittedPep=" + previouslyOmittedPepFetch);
if (avatar.owner.isBareJid()) { if (avatar.owner.isBareJid()) {
if (account.getJid().asBareJid().equals(avatar.owner) && account.getAvatar() == null) { if (account.getJid().asBareJid().equals(avatar.owner) && account.getAvatar() == null) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": had no avatar. replacing with vcard"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": had no avatar. replacing with vcard");
@ -3701,8 +3709,8 @@ public class XmppConnectionService extends Service {
public void notifyAccountAvatarHasChanged(final Account account) { public void notifyAccountAvatarHasChanged(final Account account) {
final XmppConnection connection = account.getXmppConnection(); final XmppConnection connection = account.getXmppConnection();
if (connection != null && connection.getFeatures().bookmarksConversion()) { if (connection != null && connection.getFeatures().bookmarksConversion()) {
Log.d(Config.LOGTAG,account.getJid().asBareJid()+": avatar changed. resending presence to online group chats"); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": avatar changed. resending presence to online group chats");
for(Conversation conversation : conversations) { for (Conversation conversation : conversations) {
if (conversation.getAccount() == account && conversation.getMode() == Conversational.MODE_MULTI) { if (conversation.getAccount() == account && conversation.getMode() == Conversational.MODE_MULTI) {
final MucOptions mucOptions = conversation.getMucOptions(); final MucOptions mucOptions = conversation.getMucOptions();
if (mucOptions.online()) { if (mucOptions.online()) {
@ -3979,7 +3987,7 @@ public class XmppConnectionService extends Service {
} }
public Account findAccountByUuid(final String uuid) { public Account findAccountByUuid(final String uuid) {
for(Account account : this.accounts) { for (Account account : this.accounts) {
if (account.getUuid().equals(uuid)) { if (account.getUuid().equals(uuid)) {
return account; return account;
} }
@ -4162,7 +4170,7 @@ public class XmppConnectionService extends Service {
if (connection != null) { if (connection != null) {
connection.sendIqPacket(packet, callback); connection.sendIqPacket(packet, callback);
} else if (callback != null) { } else if (callback != null) {
callback.onIqPacketReceived(account,new IqPacket(IqPacket.TYPE.TIMEOUT)); callback.onIqPacketReceived(account, new IqPacket(IqPacket.TYPE.TIMEOUT));
} }
} }
@ -4386,7 +4394,7 @@ public class XmppConnectionService extends Service {
mAvatarService.clear(account); mAvatarService.clear(account);
sendIqPacket(account, request, (account1, packet) -> { sendIqPacket(account, request, (account1, packet) -> {
if (packet.getType() == IqPacket.TYPE.ERROR) { if (packet.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, account1.getJid().asBareJid() + ": unable to modify nick name "+packet.toString()); Log.d(Config.LOGTAG, account1.getJid().asBareJid() + ": unable to modify nick name " + packet.toString());
} }
}); });
} }
@ -4418,7 +4426,7 @@ public class XmppConnectionService extends Service {
final String ver = presence.getVer(); final String ver = presence.getVer();
final Element query = request.query("http://jabber.org/protocol/disco#info"); final Element query = request.query("http://jabber.org/protocol/disco#info");
if (node != null && ver != null) { if (node != null && ver != null) {
query.setAttribute("node",node+"#"+ver); query.setAttribute("node", node + "#" + ver);
} }
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid); Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": making disco request for " + key.second + " to " + jid);
sendIqPacket(account, request, (a, response) -> { sendIqPacket(account, request, (a, response) -> {
@ -4643,7 +4651,7 @@ public class XmppConnectionService extends Service {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
onStartCommand(intent,0,0); onStartCommand(intent, 0, 0);
} }
} }
} }

View File

@ -225,13 +225,13 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O
final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, result.getRoom(), true, true, true); final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, result.getRoom(), true, true, true);
Bookmark bookmark = conversation.getBookmark(); Bookmark bookmark = conversation.getBookmark();
if (bookmark != null) { if (bookmark != null) {
if (!bookmark.autojoin() && syncAutojoin) { if (!bookmark.autojoin() && syncAutoJoin) {
conversation.getBookmark().setAutojoin(true); bookmark.setAutojoin(true);
xmppConnectionService.createBookmark(account, bookmark); xmppConnectionService.createBookmark(account, bookmark);
} }
} else { } else {
bookmark = new Bookmark(account, conversation.getJid().asBareJid()); bookmark = new Bookmark(account, conversation.getJid().asBareJid());
bookmark.setAutojoin(syncAutojoin); bookmark.setAutojoin(syncAutoJoin);
xmppConnectionService.createBookmark(account, bookmark); xmppConnectionService.createBookmark(account, bookmark);
} }
switchToConversation(conversation); switchToConversation(conversation);

View File

@ -1880,7 +1880,7 @@ public class XmppConnection implements Runnable {
} }
public boolean bookmarks2() { public boolean bookmarks2() {
return Config.USE_BOOKMARKS2 || hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARKS2_COMPAT); return Config.USE_BOOKMARKS2 /* || hasDiscoFeature(account.getJid().asBareJid(), Namespace.BOOKMARKS2_COMPAT)*/;
} }
} }
} }