aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-03-21 22:14:52 +0100
committerDaniel Gultsch <daniel.gultsch@rwth-aachen.de>2014-03-21 22:14:52 +0100
commita9e34d34926d7df3fb01143d6733b481c31c292d (patch)
tree964a4baba3106f775692d4aec7c674f04be38cfb
parent079712060c2a61515867e97ffb98c7c4e88e0d5a (diff)
tryed to fix more otr bugs. new resource setting
-rw-r--r--res/values/arrays.xml19
-rw-r--r--res/xml/preferences.xml16
-rw-r--r--src/eu/siacs/conversations/entities/Account.java6
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java6
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java84
-rw-r--r--src/eu/siacs/conversations/utils/MessageParser.java7
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java2
-rw-r--r--src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java1
8 files changed, 69 insertions, 72 deletions
diff --git a/res/values/arrays.xml b/res/values/arrays.xml
index b8135cde..2210fbb8 100644
--- a/res/values/arrays.xml
+++ b/res/values/arrays.xml
@@ -1,17 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <array name="conversation_encryption_type_entries">
- <item>None</item>
- <item>OpenPGP</item>
- <item>Off the record</item>
- </array>
- <array name="conversation_encryption_type_values">
- <item>none</item>
- <item>pgp</item>
- <item>otr</item>
- </array>
- <array name="manage_account_options">
- <item>Delete</item>
- <item>Disable</item>
+ <array name="resources">
+ <item>Mobile</item>
+ <item>Phone</item>
+ <item>Tablet</item>
+ <item>Conversations</item>
+ <item>Android</item>
</array>
</resources>
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
index 904ea07e..49b3e580 100644
--- a/res/xml/preferences.xml
+++ b/res/xml/preferences.xml
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory
- android:title="Security and Privacy Options">
- <ListPreference
- android:key="default_conversation_encryption_type"
- android:title="Default conversation encryption"
- android:dialogTitle="Default conversation encryption"
- android:entries="@array/conversation_encryption_type_entries"
- android:entryValues="@array/conversation_encryption_type_values"
- android:defaultValue="none"/>
+ android:title="General">
<CheckBoxPreference
android:key="grant_new_contacts"
android:title="Grant presence updates"
android:summary="Preemptivly grant and ask for presence subscription for contacts you created"
android:defaultValue="true"
/>
+ <ListPreference
+ android:key="resource"
+ android:title="XMPP Resource"
+ android:summary="The name this client identifies itself"
+ android:entries="@array/resources"
+ android:entryValues="@array/resources"
+ android:defaultValue="Mobile"/>
</PreferenceCategory>
<PreferenceCategory
android:title="Notification Settings">
diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java
index 3f9510b3..8fd9444a 100644
--- a/src/eu/siacs/conversations/entities/Account.java
+++ b/src/eu/siacs/conversations/entities/Account.java
@@ -52,7 +52,7 @@ public class Account extends AbstractEntity{
protected String password;
protected int options = 0;
protected String rosterVersion;
- protected String resource;
+ protected String resource = "mobile";
protected int status = -1;
protected JSONObject keys = new JSONObject();
@@ -137,6 +137,10 @@ public class Account extends AbstractEntity{
this.resource = resource;
}
+ public String getResource() {
+ return this.resource;
+ }
+
public String getJid() {
return username+"@"+server;
}
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 2c905fec..8bc1b389 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -7,6 +7,7 @@ import java.util.Comparator;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
+import java.util.Locale;
import java.util.Random;
import org.openintents.openpgp.util.OpenPgpApi;
@@ -550,6 +551,9 @@ public class XmppConnectionService extends Service {
}
public XmppConnection createConnection(Account account) {
+ SharedPreferences sharedPref = PreferenceManager
+ .getDefaultSharedPreferences(getApplicationContext());
+ account.setResource(sharedPref.getString("resource", "mobile").toLowerCase(Locale.getDefault()));
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
XmppConnection connection = new XmppConnection(account, pm);
connection.setOnMessagePacketReceivedListener(this.messageListener);
@@ -588,7 +592,7 @@ public class XmppConnectionService extends Service {
return connection;
}
- public void sendMessage(Message message, String presence) {
+ synchronized public void sendMessage(Message message, String presence) {
Account account = message.getConversation().getAccount();
Conversation conv = message.getConversation();
boolean saveInDb = false;
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 4ae85dc2..6e5105f5 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -388,52 +388,54 @@ public class ConversationFragment extends Fragment {
public void updateMessages() {
ConversationActivity activity = (ConversationActivity) getActivity();
- List<Message> encryptedMessages = new LinkedList<Message>();
- for (Message message : this.conversation.getMessages()) {
- if (message.getEncryption() == Message.ENCRYPTION_PGP) {
- encryptedMessages.add(message);
- }
- }
- if (encryptedMessages.size() > 0) {
- DecryptMessage task = new DecryptMessage();
- Message[] msgs = new Message[encryptedMessages.size()];
- task.execute(encryptedMessages.toArray(msgs));
- }
- this.messageList.clear();
- this.messageList.addAll(this.conversation.getMessages());
- this.messageListAdapter.notifyDataSetChanged();
- if (conversation.getMode() == Conversation.MODE_SINGLE) {
- if (messageList.size() >= 1) {
- int latestEncryption = this.conversation.getLatestMessage()
- .getEncryption();
- if (latestEncryption == Message.ENCRYPTION_DECRYPTED) {
- conversation.nextMessageEncryption = Message.ENCRYPTION_PGP;
- } else {
- conversation.nextMessageEncryption = latestEncryption;
+ if (this.conversation != null) {
+ List<Message> encryptedMessages = new LinkedList<Message>();
+ for (Message message : this.conversation.getMessages()) {
+ if (message.getEncryption() == Message.ENCRYPTION_PGP) {
+ encryptedMessages.add(message);
}
- makeFingerprintWarning(latestEncryption);
}
- } else {
- if (conversation.getMucOptions().getError() != 0) {
- mucError.setVisibility(View.VISIBLE);
- if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) {
- mucErrorText.setText(getString(R.string.nick_in_use));
+ if (encryptedMessages.size() > 0) {
+ DecryptMessage task = new DecryptMessage();
+ Message[] msgs = new Message[encryptedMessages.size()];
+ task.execute(encryptedMessages.toArray(msgs));
+ }
+ this.messageList.clear();
+ this.messageList.addAll(this.conversation.getMessages());
+ this.messageListAdapter.notifyDataSetChanged();
+ if (conversation.getMode() == Conversation.MODE_SINGLE) {
+ if (messageList.size() >= 1) {
+ int latestEncryption = this.conversation.getLatestMessage()
+ .getEncryption();
+ if (latestEncryption == Message.ENCRYPTION_DECRYPTED) {
+ conversation.nextMessageEncryption = Message.ENCRYPTION_PGP;
+ } else {
+ conversation.nextMessageEncryption = latestEncryption;
+ }
+ makeFingerprintWarning(latestEncryption);
}
} else {
- mucError.setVisibility(View.GONE);
+ if (conversation.getMucOptions().getError() != 0) {
+ mucError.setVisibility(View.VISIBLE);
+ if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) {
+ mucErrorText.setText(getString(R.string.nick_in_use));
+ }
+ } else {
+ mucError.setVisibility(View.GONE);
+ }
+ }
+ getActivity().invalidateOptionsMenu();
+ updateChatMsgHint();
+ int size = this.messageList.size();
+ if (size >= 1)
+ messagesView.setSelection(size - 1);
+ if (!activity.shouldPaneBeOpen()) {
+ conversation.markRead();
+ // TODO update notifications
+ UIHelper.updateNotification(getActivity(),
+ activity.getConversationList(), null, false);
+ activity.updateConversationList();
}
- }
- getActivity().invalidateOptionsMenu();
- updateChatMsgHint();
- int size = this.messageList.size();
- if (size >= 1)
- messagesView.setSelection(size - 1);
- if (!activity.shouldPaneBeOpen()) {
- conversation.markRead();
- // TODO update notifications
- UIHelper.updateNotification(getActivity(),
- activity.getConversationList(), null, false);
- activity.updateConversationList();
}
}
diff --git a/src/eu/siacs/conversations/utils/MessageParser.java b/src/eu/siacs/conversations/utils/MessageParser.java
index 5cbdfd7b..58235678 100644
--- a/src/eu/siacs/conversations/utils/MessageParser.java
+++ b/src/eu/siacs/conversations/utils/MessageParser.java
@@ -2,7 +2,6 @@ package eu.siacs.conversations.utils;
import java.util.List;
-import net.java.otr4j.OtrException;
import net.java.otr4j.session.Session;
import net.java.otr4j.session.SessionStatus;
import android.util.Log;
@@ -89,11 +88,7 @@ public class MessageParser {
Log.d(LOGTAG,"otr session stoped");
}
} catch (Exception e) {
- Log.d(LOGTAG,"otr execption");
- if (justStarted) {
- Log.d(LOGTAG,"ran into safeguard");
- } else {
- Log.d(LOGTAG,"resett otr session");
+ if (!justStarted) {
conversation.resetOtrSession();
}
return null;
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index 9b332c94..1d386f91 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -524,7 +524,7 @@ public class XmppConnection implements Runnable {
private void sendBindRequest() throws IOException {
IqPacket iq = new IqPacket(IqPacket.TYPE_SET);
- iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind").addChild("resource").setContent("Conversations");
+ iq.addChild("bind", "urn:ietf:params:xml:ns:xmpp-bind").addChild("resource").setContent(account.getResource());
this.sendIqPacket(iq, new OnIqPacketReceived() {
@Override
public void onIqPacketReceived(Account account, IqPacket packet) {
diff --git a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java
index 8cd1abc0..3ab3b6c3 100644
--- a/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java
+++ b/src/eu/siacs/conversations/xmpp/stanzas/IqPacket.java
@@ -1,6 +1,5 @@
package eu.siacs.conversations.xmpp.stanzas;
-import android.graphics.YuvImage;
import eu.siacs.conversations.xml.Element;