aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/AndroidManifest.xml103
-rw-r--r--src/main/java/eu/siacs/conversations/parser/MessageParser.java6
-rw-r--r--src/main/java/eu/siacs/conversations/services/XmppConnectionService.java14
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java43
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java2
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java24
-rw-r--r--src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java10
-rw-r--r--src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java23
-rw-r--r--src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java99
-rw-r--r--src/main/res/values/strings.xml2
10 files changed, 183 insertions, 143 deletions
diff --git a/src/main/AndroidManifest.xml b/src/main/AndroidManifest.xml
index 34f3e9098..23273162e 100644
--- a/src/main/AndroidManifest.xml
+++ b/src/main/AndroidManifest.xml
@@ -3,29 +3,30 @@
xmlns:tools="http://schemas.android.com/tools"
package="eu.siacs.conversations" >
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
- <uses-permission android:name="android.permission.READ_CONTACTS" />
- <uses-permission android:name="android.permission.READ_PROFILE" />
- <uses-permission android:name="android.permission.INTERNET" />
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
- <uses-permission android:name="android.permission.WAKE_LOCK" />
- <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
- <uses-permission android:name="android.permission.VIBRATE" />
- <uses-permission android:name="android.permission.NFC" />
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
+ <uses-permission android:name="android.permission.READ_CONTACTS"/>
+ <uses-permission android:name="android.permission.READ_PROFILE"/>
+ <uses-permission android:name="android.permission.INTERNET"/>
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
+ <uses-permission android:name="android.permission.WAKE_LOCK"/>
+ <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
+ <uses-permission android:name="android.permission.VIBRATE"/>
+ <uses-permission android:name="android.permission.NFC"/>
+
<uses-permission
android:name="android.permission.READ_PHONE_STATE"
- tools:node="remove" />
+ tools:node="remove"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/ConversationsTheme"
- tools:replace="android:label" >
- <service android:name=".services.XmppConnectionService" />
+ tools:replace="android:label">
+ <service android:name=".services.XmppConnectionService"/>
- <receiver android:name=".services.EventReceiver" >
+ <receiver android:name=".services.EventReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
@@ -43,11 +44,11 @@
android:name=".ui.ConversationActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
- android:windowSoftInputMode="stateHidden" >
+ android:windowSoftInputMode="stateHidden">
<intent-filter>
- <action android:name="android.intent.action.MAIN" />
+ <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER" />
+ <category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity
@@ -56,87 +57,89 @@
android:label="@string/title_activity_start_conversation"
android:launchMode="singleTask" >
<intent-filter>
- <action android:name="android.intent.action.SENDTO" />
+ <action android:name="android.intent.action.SENDTO"/>
- <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.DEFAULT"/>
- <data android:scheme="imto" />
- <data android:host="jabber" />
+ <data android:scheme="imto"/>
+ <data android:host="jabber"/>
</intent-filter>
<intent-filter>
- <action android:name="android.intent.action.VIEW" />
+ <action android:name="android.intent.action.VIEW"/>
- <category android:name="android.intent.category.DEFAULT" />
- <category android:name="android.intent.category.BROWSABLE" />
+ <category android:name="android.intent.category.DEFAULT"/>
+ <category android:name="android.intent.category.BROWSABLE"/>
- <data android:scheme="xmpp" />
+ <data android:scheme="xmpp"/>
</intent-filter>
<intent-filter>
- <action android:name="android.nfc.action.NDEF_DISCOVERED" />
+ <action android:name="android.nfc.action.NDEF_DISCOVERED"/>
- <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.DEFAULT"/>
- <data android:scheme="xmpp" />
+ <data android:scheme="xmpp"/>
</intent-filter>
</activity>
<activity
android:name=".ui.SettingsActivity"
- android:label="@string/title_activity_settings" />
+ android:label="@string/title_activity_settings"/>
<activity
android:name=".ui.ChooseContactActivity"
- android:label="@string/title_activity_choose_contact" />
+ android:label="@string/title_activity_choose_contact"/>
<activity
android:name=".ui.BlocklistActivity"
- android:label="@string/title_activity_block_list" />
+ android:label="@string/title_activity_block_list"/>
<activity
android:name=".ui.ChangePasswordActivity"
- android:label="@string/change_password_on_server" />
+ android:label="@string/change_password_on_server"/>
<activity
android:name=".ui.ManageAccountActivity"
android:configChanges="orientation|screenSize"
- android:label="@string/title_activity_manage_accounts" />
+ android:label="@string/title_activity_manage_accounts"
+ android:launchMode="singleTask"/>
<activity
android:name=".ui.EditAccountActivity"
- android:windowSoftInputMode="stateHidden|adjustResize" />
+ android:launchMode="singleTask"
+ android:windowSoftInputMode="stateHidden|adjustResize"/>
<activity
android:name=".ui.ConferenceDetailsActivity"
android:label="@string/title_activity_conference_details"
- android:windowSoftInputMode="stateHidden" />
+ android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.ContactDetailsActivity"
android:label="@string/title_activity_contact_details"
- android:windowSoftInputMode="stateHidden" />
+ android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.PublishProfilePictureActivity"
android:label="@string/mgmt_account_publish_avatar"
- android:windowSoftInputMode="stateHidden" />
+ android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.VerifyOTRActivity"
android:label="@string/verify_otr"
- android:windowSoftInputMode="stateHidden" />
+ android:windowSoftInputMode="stateHidden"/>
<activity
android:name=".ui.ShareWithActivity"
- android:label="@string/app_name" >
+ android:label="@string/app_name">
<intent-filter>
- <action android:name="android.intent.action.SEND" />
+ <action android:name="android.intent.action.SEND"/>
- <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.DEFAULT"/>
- <data android:mimeType="text/plain" />
+ <data android:mimeType="text/plain"/>
</intent-filter>
<intent-filter>
- <action android:name="android.intent.action.SEND" />
+ <action android:name="android.intent.action.SEND"/>
- <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.DEFAULT"/>
- <data android:mimeType="*/*" />
+ <data android:mimeType="*/*"/>
</intent-filter>
<intent-filter>
- <action android:name="android.intent.action.SEND_MULTIPLE" />
+ <action android:name="android.intent.action.SEND_MULTIPLE"/>
- <category android:name="android.intent.category.DEFAULT" />
+ <category android:name="android.intent.category.DEFAULT"/>
- <data android:mimeType="image/*" />
+ <data android:mimeType="image/*"/>
</intent-filter>
</activity>
<activity
@@ -150,10 +153,10 @@
<activity
android:name=".ui.AboutActivity"
android:label="@string/title_activity_about"
- android:parentActivityName=".ui.SettingsActivity" >
+ android:parentActivityName=".ui.SettingsActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
- android:value="eu.siacs.conversations.ui.SettingsActivity" />
+ android:value="eu.siacs.conversations.ui.SettingsActivity"/>
</activity>
<activity
android:name=".ui.UpdaterActivity"
diff --git a/src/main/java/eu/siacs/conversations/parser/MessageParser.java b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
index c53e50ac4..e39df085f 100644
--- a/src/main/java/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/main/java/eu/siacs/conversations/parser/MessageParser.java
@@ -353,7 +353,11 @@ public class MessageParser extends AbstractParser implements
message.setTime(timestamp);
message.markable = packet.hasChild("markable", "urn:xmpp:chat-markers:0");
if (conversation.getMode() == Conversation.MODE_MULTI) {
- message.setTrueCounterpart(conversation.getMucOptions().getTrueCounterpart(counterpart.getResourcepart()));
+ Jid trueCounterpart = conversation.getMucOptions().getTrueCounterpart(counterpart.getResourcepart());
+ message.setTrueCounterpart(trueCounterpart);
+ if (trueCounterpart != null) {
+ updateLastseen(packet,account,trueCounterpart,false);
+ }
if (!isTypeGroupChat) {
message.setType(Message.TYPE_PRIVATE);
}
diff --git a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
index d9ae6a921..ba74280db 100644
--- a/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/main/java/eu/siacs/conversations/services/XmppConnectionService.java
@@ -722,7 +722,13 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
for (final Account account : accounts) {
databaseBackend.writeRoster(account.getRoster());
if (account.getXmppConnection() != null) {
- disconnect(account, false);
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ disconnect(account, false);
+ }
+ }).start();
+
}
}
Context context = getApplicationContext();
@@ -1630,6 +1636,9 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
private void switchToForeground() {
+ for (Conversation conversation : getConversations()) {
+ conversation.setIncomingChatState(ChatState.ACTIVE);
+ }
for (Account account : getAccounts()) {
if (account.getStatus() == Account.State.ONLINE) {
XmppConnection connection = account.getXmppConnection();
@@ -1650,9 +1659,6 @@ public class XmppConnectionService extends Service implements OnPhoneContactsLoa
}
}
}
- for (Conversation conversation : getConversations()) {
- conversation.setIncomingChatState(ChatState.ACTIVE);
- }
this.mNotificationService.setIsInForeground(false);
Log.d(Config.LOGTAG, "app switched into background");
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 451dd41ee..fdda2ac10 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -37,6 +37,7 @@ import net.java.otr4j.session.SessionStatus;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import de.timroes.android.listview.EnhancedListView;
import eu.siacs.conversations.Config;
@@ -109,7 +110,7 @@ public class ConversationActivity extends XmppActivity
private Toast prepareFileToast;
private boolean mActivityPaused = false;
- private boolean mRedirected = true;
+ private AtomicBoolean mRedirected = new AtomicBoolean(false);
public Conversation getSelectedConversation() {
return this.mSelectedConversation;
@@ -679,6 +680,12 @@ public class ConversationActivity extends XmppActivity
this.mConversationFragment.reInit(getSelectedConversation());
} else {
setSelectedConversation(null);
+ if (mRedirected.compareAndSet(false,true)) {
+ Intent intent = new Intent(this, StartConversationActivity.class);
+ intent.putExtra("init",true);
+ startActivity(intent);
+ finish();
+ }
}
}
}
@@ -1033,7 +1040,7 @@ public class ConversationActivity extends XmppActivity
@Override
public void onStart() {
super.onStart();
- this.mRedirected = false;
+ this.mRedirected.set(false);
if (this.xmppConnectionServiceBound) {
this.onBackendConnected();
}
@@ -1098,14 +1105,16 @@ public class ConversationActivity extends XmppActivity
}
if (xmppConnectionService.getAccounts().size() == 0) {
- if (!mRedirected) {
- this.mRedirected = true;
- startActivity(new Intent(this, EditAccountActivity.class));
+ if (mRedirected.compareAndSet(false,true)) {
+ if (Config.X509_VERIFICATION) {
+ startActivity(new Intent(this, ManageAccountActivity.class));
+ } else {
+ startActivity(new Intent(this, EditAccountActivity.class));
+ }
finish();
}
} else if (conversationList.size() <= 0) {
- if (!mRedirected) {
- this.mRedirected = true;
+ if (mRedirected.compareAndSet(false,true)) {
Intent intent = new Intent(this, StartConversationActivity.class);
intent.putExtra("init",true);
startActivity(intent);
@@ -1398,7 +1407,7 @@ public class ConversationActivity extends XmppActivity
@Override
public void userInputRequried(PendingIntent pi,
- Message message) {
+ Message message) {
ConversationActivity.this.runIntent(pi,
ConversationActivity.REQUEST_SEND_MESSAGE);
}
@@ -1455,25 +1464,11 @@ public class ConversationActivity extends XmppActivity
@Override
protected void refreshUiReal() {
updateConversationList();
- if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 0) {
- if (!mRedirected) {
- this.mRedirected = true;
- startActivity(new Intent(this, EditAccountActivity.class));
- finish();
- }
- } else if (conversationList.size() == 0) {
- if (!mRedirected) {
- this.mRedirected = true;
- Intent intent = new Intent(this, StartConversationActivity.class);
- intent.putExtra("init",true);
- startActivity(intent);
- finish();
- }
- } else {
+ if (conversationList.size() > 0) {
ConversationActivity.this.mConversationFragment.updateMessages();
updateActionBarTitle();
+ invalidateOptionsMenu();
}
- invalidateOptionsMenu();
}
@Override
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
index 16ccceb28..1982781fd 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java
@@ -541,7 +541,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa
shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
String mime = message.getMimeType();
if (mime == null) {
- mime = "image/jpeg";
+ mime = "*/*";
}
shareIntent.setType(mime);
}
diff --git a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java
index 6024177ae..ebc50566d 100644
--- a/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -1,6 +1,8 @@
package eu.siacs.conversations.ui;
+import android.app.ActionBar;
import android.app.AlertDialog;
+import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
@@ -20,6 +22,7 @@ import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
@@ -35,6 +38,7 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
protected final List<Account> accountList = new ArrayList<>();
protected ListView accountListView;
protected AccountAdapter mAccountAdapter;
+ protected AtomicBoolean mInvokedAddAccount = new AtomicBoolean(false);
@Override
public void onAccountUpdate() {
@@ -47,6 +51,11 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
accountList.clear();
accountList.addAll(xmppConnectionService.getAccounts());
}
+ ActionBar actionBar = getActionBar();
+ if (actionBar != null) {
+ actionBar.setHomeButtonEnabled(this.accountList.size() > 0);
+ actionBar.setDisplayHomeAsUpEnabled(this.accountList.size() > 0);
+ }
invalidateOptionsMenu();
mAccountAdapter.notifyDataSetChanged();
}
@@ -93,9 +102,12 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
@Override
void onBackendConnected() {
- this.accountList.clear();
- this.accountList.addAll(xmppConnectionService.getAccounts());
- mAccountAdapter.notifyDataSetChanged();
+ refreshUiReal();
+ if (Config.X509_VERIFICATION && this.accountList.size() == 0) {
+ if (mInvokedAddAccount.compareAndSet(false,true)) {
+ addAccountFromKey();
+ }
+ }
}
@Override
@@ -195,7 +207,11 @@ public class ManageAccountActivity extends XmppActivity implements OnAccountUpda
}
private void addAccountFromKey() {
- KeyChain.choosePrivateKeyAlias(this, this, null, null, null, -1, null);
+ try {
+ KeyChain.choosePrivateKeyAlias(this, this, null, null, null, -1, null);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(this,R.string.device_does_not_support_certificates,Toast.LENGTH_LONG).show();
+ }
}
private void publishAvatar(Account account) {
diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
index 74621fc4c..df04567f1 100644
--- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java
@@ -458,16 +458,18 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
} else {
final Bookmark bookmark = new Bookmark(account,conferenceJid.toBareJid());
bookmark.setAutojoin(true);
+ String nick = conferenceJid.getResourcepart();
+ if (nick != null && !nick.isEmpty()) {
+ bookmark.setNick(nick);
+ }
account.getBookmarks().add(bookmark);
- xmppConnectionService
- .pushBookmarks(account);
+ xmppConnectionService.pushBookmarks(account);
final Conversation conversation = xmppConnectionService
.findOrCreateConversation(account,
conferenceJid, true);
conversation.setBookmark(bookmark);
if (!conversation.getMucOptions().online()) {
- xmppConnectionService
- .joinMuc(conversation);
+ xmppConnectionService.joinMuc(conversation);
}
dialog.dismiss();
switchToConversation(conversation);
diff --git a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 99af14cd8..89a15ece3 100644
--- a/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/main/java/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -607,7 +607,7 @@ public class MessageAdapter extends ArrayAdapter<Message> {
Toast.LENGTH_SHORT).show();
}
} else if (message.treatAsDownloadable() != Message.Decision.NEVER) {
- activity.xmppConnectionService.getHttpConnectionManager().createNewDownloadConnection(message,true);
+ activity.xmppConnectionService.getHttpConnectionManager().createNewDownloadConnection(message, true);
}
}
@@ -618,16 +618,21 @@ public class MessageAdapter extends ArrayAdapter<Message> {
return;
}
Intent openIntent = new Intent(Intent.ACTION_VIEW);
- openIntent.setDataAndType(Uri.fromFile(file), file.getMimeType());
+ String mime = file.getMimeType();
+ if (mime == null) {
+ mime = "*/*";
+ }
+ openIntent.setDataAndType(Uri.fromFile(file), mime);
PackageManager manager = activity.getPackageManager();
List<ResolveInfo> infos = manager.queryIntentActivities(openIntent, 0);
- if (infos.size() > 0) {
- try {
- getContext().startActivity(openIntent);
- return;
- } catch (ActivityNotFoundException e) {
- //ignored
- }
+ if (infos.size() == 0) {
+ openIntent.setDataAndType(Uri.fromFile(file),"*/*");
+ }
+ try {
+ getContext().startActivity(openIntent);
+ return;
+ } catch (ActivityNotFoundException e) {
+ //ignored
}
Toast.makeText(activity,R.string.no_application_found_to_open_file,Toast.LENGTH_SHORT).show();
}
diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
index 186672488..1549aeb5d 100644
--- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -678,7 +678,7 @@ public class XmppConnection implements Runnable {
.findChild("mechanisms"));
final Element auth = new Element("auth");
auth.setAttribute("xmlns", "urn:ietf:params:xml:ns:xmpp-sasl");
- if (mechanisms.contains("EXTERNAL")) {
+ if (mechanisms.contains("EXTERNAL") && account.getPrivateKeyAlias() != null) {
saslMechanism = new External(tagWriter, account, mXmppConnectionService.getRNG());
} else if (mechanisms.contains("SCRAM-SHA-1")) {
saslMechanism = new ScramSha1(tagWriter, account, mXmppConnectionService.getRNG());
@@ -812,7 +812,7 @@ public class XmppConnection implements Runnable {
}
private void sendBindRequest() {
- while(!mXmppConnectionService.areMessagesInitialized()) {
+ while(!mXmppConnectionService.areMessagesInitialized() && socket != null && !socket.isClosed()) {
try {
Thread.sleep(500);
} catch (final InterruptedException ignored) {
@@ -907,7 +907,9 @@ public class XmppConnection implements Runnable {
}
features.carbonsEnabled = false;
features.blockListRequested = false;
- disco.clear();
+ synchronized (this.disco) {
+ this.disco.clear();
+ }
sendServiceDiscoveryInfo(account.getServer());
sendServiceDiscoveryInfo(account.getJid().toBareJid());
sendServiceDiscoveryItems(account.getServer());
@@ -920,19 +922,16 @@ public class XmppConnection implements Runnable {
}
private void sendServiceDiscoveryInfo(final Jid jid) {
- if (disco.containsKey(jid)) {
- if (account.getServer().equals(jid)) {
- enableAdvancedStreamFeatures();
- }
- } else {
- final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
- iq.setTo(jid);
- iq.query("http://jabber.org/protocol/disco#info");
- this.sendIqPacket(iq, new OnIqPacketReceived() {
+ final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
+ iq.setTo(jid);
+ iq.query("http://jabber.org/protocol/disco#info");
+ this.sendIqPacket(iq, new OnIqPacketReceived() {
- @Override
- public void onIqPacketReceived(final Account account, final IqPacket packet) {
- if (packet.getType() == IqPacket.TYPE.RESULT) {
+ @Override
+ public void onIqPacketReceived(final Account account, final IqPacket packet) {
+ if (packet.getType() == IqPacket.TYPE.RESULT) {
+ boolean advancedStreamFeaturesLoaded = false;
+ synchronized (XmppConnection.this.disco) {
final List<Element> elements = packet.query().getChildren();
final Info info = new Info();
for (final Element element : elements) {
@@ -947,17 +946,17 @@ public class XmppConnection implements Runnable {
}
}
disco.put(jid, info);
- if ((jid.equals(account.getServer()) || jid.equals(account.getJid().toBareJid()))
- && disco.containsKey(account.getServer())
- && disco.containsKey(account.getJid().toBareJid())) {
- enableAdvancedStreamFeatures();
- }
- } else {
- Log.d(Config.LOGTAG,account.getJid().toBareJid()+": could not query disco info for "+jid.toString());
+ advancedStreamFeaturesLoaded = disco.containsKey(account.getServer())
+ && disco.containsKey(account.getJid().toBareJid());
+ }
+ if (advancedStreamFeaturesLoaded && (jid.equals(account.getServer()) || jid.equals(account.getJid().toBareJid()))) {
+ enableAdvancedStreamFeatures();
}
+ } else {
+ Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": could not query disco info for " + jid.toString());
}
- });
- }
+ }
+ });
}
private void enableAdvancedStreamFeatures() {
@@ -1184,13 +1183,15 @@ public class XmppConnection implements Runnable {
}
public List<Jid> findDiscoItemsByFeature(final String feature) {
- final List<Jid> items = new ArrayList<>();
- for (final Entry<Jid, Info> cursor : disco.entrySet()) {
- if (cursor.getValue().features.contains(feature)) {
- items.add(cursor.getKey());
+ synchronized (this.disco) {
+ final List<Jid> items = new ArrayList<>();
+ for (final Entry<Jid, Info> cursor : this.disco.entrySet()) {
+ if (cursor.getValue().features.contains(feature)) {
+ items.add(cursor.getKey());
+ }
}
+ return items;
}
- return items;
}
public Jid findDiscoItemByFeature(final String feature) {
@@ -1211,12 +1212,14 @@ public class XmppConnection implements Runnable {
}
public String getMucServer() {
- for (final Entry<Jid, Info> cursor : disco.entrySet()) {
- final Info value = cursor.getValue();
- if (value.features.contains("http://jabber.org/protocol/muc")
- && !value.features.contains("jabber:iq:gateway")
- && !value.identities.contains(new Pair<>("conference","irc"))) {
- return cursor.getKey().toString();
+ synchronized (this.disco) {
+ for (final Entry<Jid, Info> cursor : disco.entrySet()) {
+ final Info value = cursor.getValue();
+ if (value.features.contains("http://jabber.org/protocol/muc")
+ && !value.features.contains("jabber:iq:gateway")
+ && !value.identities.contains(new Pair<>("conference", "irc"))) {
+ return cursor.getKey().toString();
+ }
}
}
return null;
@@ -1302,8 +1305,10 @@ public class XmppConnection implements Runnable {
}
private boolean hasDiscoFeature(final Jid server, final String feature) {
- return connection.disco.containsKey(server) &&
- connection.disco.get(server).features.contains(feature);
+ synchronized (XmppConnection.this.disco) {
+ return connection.disco.containsKey(server) &&
+ connection.disco.get(server).features.contains(feature);
+ }
}
public boolean carbons() {
@@ -1328,13 +1333,15 @@ public class XmppConnection implements Runnable {
}
public boolean pep() {
- final Pair<String,String> needle = new Pair<>("pubsub","pep");
- Info info = disco.get(account.getServer());
- if (info != null && info.identities.contains(needle)) {
- return true;
- } else {
- info = disco.get(account.getJid().toBareJid());
- return info != null && info.identities.contains(needle);
+ synchronized (XmppConnection.this.disco) {
+ final Pair<String, String> needle = new Pair<>("pubsub", "pep");
+ Info info = disco.get(account.getServer());
+ if (info != null && info.identities.contains(needle)) {
+ return true;
+ } else {
+ info = disco.get(account.getJid().toBareJid());
+ return info != null && info.identities.contains(needle);
+ }
}
}
@@ -1347,7 +1354,9 @@ public class XmppConnection implements Runnable {
}
public boolean advancedStreamFeaturesLoaded() {
- return disco.containsKey(account.getServer());
+ synchronized (XmppConnection.this.disco) {
+ return disco.containsKey(account.getServer());
+ }
}
public boolean rosterVersioning() {
diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml
index 90aa7a8e5..9331bb752 100644
--- a/src/main/res/values/strings.xml
+++ b/src/main/res/values/strings.xml
@@ -548,5 +548,5 @@
<string name="action_renew_certificate">Renew certificate</string>
<string name="error_fetching_omemo_key">Error fetching OMEMO key!</string>
<string name="verified_omemo_key_with_certificate">Verified OMEMO key with certificate!</string>
-
+ <string name="device_does_not_support_certificates">Your device does not support the selection of client certificates!</string>
</resources>