otr messages are now ignored if conversations isnt 100% sure the message is ours
This commit is contained in:
parent
389d4db311
commit
6be2a08f19
|
@ -81,8 +81,24 @@
|
||||||
android:textSize="18sp"/>
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/features_header"
|
android:id="@+id/textView10"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/textView4"
|
android:layout_below="@+id/textView4"
|
||||||
|
android:text="Connected accounts"
|
||||||
|
android:textSize="18sp"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/number_presences"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignBaseline="@+id/textView10"
|
||||||
|
android:layout_alignBottom="@+id/textView10"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/features_header"
|
||||||
|
android:layout_below="@+id/textView10"
|
||||||
style="@style/sectionHeader"
|
style="@style/sectionHeader"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class Account extends AbstractEntity{
|
||||||
|
|
||||||
transient OtrEngine otrEngine = null;
|
transient OtrEngine otrEngine = null;
|
||||||
transient XmppConnection xmppConnection = null;
|
transient XmppConnection xmppConnection = null;
|
||||||
|
transient protected Presences presences = new Presences();
|
||||||
|
|
||||||
private String otrFingerprint;
|
private String otrFingerprint;
|
||||||
|
|
||||||
|
@ -249,4 +250,20 @@ public class Account extends AbstractEntity{
|
||||||
this.getOtrEngine(applicationContext);
|
this.getOtrEngine(applicationContext);
|
||||||
return this.getOtrFingerprint();
|
return this.getOtrFingerprint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updatePresence(String resource, int status) {
|
||||||
|
this.presences.updatePresence(resource, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePresence(String resource) {
|
||||||
|
this.presences.removePresence(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearPresences() {
|
||||||
|
this.presences = new Presences();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int countPresences() {
|
||||||
|
return this.presences.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,8 @@ import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import eu.siacs.conversations.xml.Element;
|
||||||
|
|
||||||
public class Presences {
|
public class Presences {
|
||||||
|
|
||||||
public static final int CHAT = -1;
|
public static final int CHAT = -1;
|
||||||
|
@ -73,4 +75,24 @@ public class Presences {
|
||||||
}
|
}
|
||||||
return presences;
|
return presences;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int parseShow(Element show) {
|
||||||
|
if (show == null) {
|
||||||
|
return Presences.ONLINE;
|
||||||
|
} else if (show.getContent().equals("away")) {
|
||||||
|
return Presences.AWAY;
|
||||||
|
} else if (show.getContent().equals("xa")) {
|
||||||
|
return Presences.XA;
|
||||||
|
} else if (show.getContent().equals("chat")) {
|
||||||
|
return Presences.CHAT;
|
||||||
|
} else if (show.getContent().equals("dnd")) {
|
||||||
|
return Presences.DND;
|
||||||
|
} else {
|
||||||
|
return Presences.OFFLINE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return presences.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package eu.siacs.conversations.services;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -152,11 +154,13 @@ public class XmppConnectionService extends Service {
|
||||||
if (packet.hasChild("x")) {
|
if (packet.hasChild("x")) {
|
||||||
Element x = packet.findChild("x");
|
Element x = packet.findChild("x");
|
||||||
if (x.hasChild("invite")) {
|
if (x.hasChild("invite")) {
|
||||||
findOrCreateConversation(account, packet.getFrom(), true);
|
findOrCreateConversation(account, packet.getFrom(),
|
||||||
|
true);
|
||||||
if (convChangedListener != null) {
|
if (convChangedListener != null) {
|
||||||
convChangedListener.onConversationListChanged();
|
convChangedListener.onConversationListChanged();
|
||||||
}
|
}
|
||||||
Log.d(LOGTAG,"invitation received to "+packet.getFrom());
|
Log.d(LOGTAG,
|
||||||
|
"invitation received to " + packet.getFrom());
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -221,8 +225,8 @@ public class XmppConnectionService extends Service {
|
||||||
if (packet.hasChild("x")
|
if (packet.hasChild("x")
|
||||||
&& (packet.findChild("x").getAttribute("xmlns")
|
&& (packet.findChild("x").getAttribute("xmlns")
|
||||||
.startsWith("http://jabber.org/protocol/muc"))) {
|
.startsWith("http://jabber.org/protocol/muc"))) {
|
||||||
Conversation muc = findMuc(packet.getAttribute("from").split(
|
Conversation muc = findMuc(
|
||||||
"/")[0],account);
|
packet.getAttribute("from").split("/")[0], account);
|
||||||
if (muc != null) {
|
if (muc != null) {
|
||||||
int error = muc.getMucOptions().getError();
|
int error = muc.getMucOptions().getError();
|
||||||
muc.getMucOptions().processPacket(packet);
|
muc.getMucOptions().processPacket(packet);
|
||||||
|
@ -234,26 +238,25 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String[] fromParts = packet.getAttribute("from").split("/");
|
String[] fromParts = packet.getAttribute("from").split("/");
|
||||||
|
String type = packet.getAttribute("type");
|
||||||
|
if (fromParts[0].equals(account.getJid())) {
|
||||||
|
if (fromParts.length==2) {
|
||||||
|
if (type == null) {
|
||||||
|
account.updatePresence(fromParts[1],Presences.parseShow(packet.findChild("show")));
|
||||||
|
} else if (type.equals("unavailable")) {
|
||||||
|
account.removePresence(fromParts[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
Contact contact = findContact(account, fromParts[0]);
|
Contact contact = findContact(account, fromParts[0]);
|
||||||
if (contact == null) {
|
if (contact == null) {
|
||||||
// most likely self or roster not synced
|
// most likely roster not synced
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String type = packet.getAttribute("type");
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
if (fromParts.length == 2) {
|
if (fromParts.length == 2) {
|
||||||
Element show = packet.findChild("show");
|
contact.updatePresence(fromParts[1], Presences.parseShow(packet.findChild("show")));
|
||||||
if (show == null) {
|
|
||||||
contact.updatePresence(fromParts[1], Presences.ONLINE);
|
|
||||||
} else if (show.getContent().equals("away")) {
|
|
||||||
contact.updatePresence(fromParts[1], Presences.AWAY);
|
|
||||||
} else if (show.getContent().equals("xa")) {
|
|
||||||
contact.updatePresence(fromParts[1], Presences.XA);
|
|
||||||
} else if (show.getContent().equals("chat")) {
|
|
||||||
contact.updatePresence(fromParts[1], Presences.CHAT);
|
|
||||||
} else if (show.getContent().equals("dnd")) {
|
|
||||||
contact.updatePresence(fromParts[1], Presences.DND);
|
|
||||||
}
|
|
||||||
PgpEngine pgp = getPgpEngine();
|
PgpEngine pgp = getPgpEngine();
|
||||||
if (pgp != null) {
|
if (pgp != null) {
|
||||||
Element x = packet.findChild("x");
|
Element x = packet.findChild("x");
|
||||||
|
@ -261,8 +264,9 @@ public class XmppConnectionService extends Service {
|
||||||
&& (x.getAttribute("xmlns")
|
&& (x.getAttribute("xmlns")
|
||||||
.equals("jabber:x:signed"))) {
|
.equals("jabber:x:signed"))) {
|
||||||
try {
|
try {
|
||||||
contact.setPgpKeyId(pgp.fetchKeyId(packet
|
contact.setPgpKeyId(pgp.fetchKeyId(
|
||||||
.findChild("status").getContent(), x
|
packet.findChild("status")
|
||||||
|
.getContent(), x
|
||||||
.getContent()));
|
.getContent()));
|
||||||
} catch (OpenPgpException e) {
|
} catch (OpenPgpException e) {
|
||||||
Log.d(LOGTAG, "faulty pgp. just ignore");
|
Log.d(LOGTAG, "faulty pgp. just ignore");
|
||||||
|
@ -286,7 +290,8 @@ public class XmppConnectionService extends Service {
|
||||||
sendPresenceUpdatesTo(contact);
|
sendPresenceUpdatesTo(contact);
|
||||||
contact.setSubscriptionOption(Contact.Subscription.FROM);
|
contact.setSubscriptionOption(Contact.Subscription.FROM);
|
||||||
contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
|
contact.resetSubscriptionOption(Contact.Subscription.PREEMPTIVE_GRANT);
|
||||||
replaceContactInConversation(contact.getJid(), contact);
|
replaceContactInConversation(contact.getJid(),
|
||||||
|
contact);
|
||||||
databaseBackend.updateContact(contact);
|
databaseBackend.updateContact(contact);
|
||||||
if ((contact
|
if ((contact
|
||||||
.getSubscriptionOption(Contact.Subscription.ASKING))
|
.getSubscriptionOption(Contact.Subscription.ASKING))
|
||||||
|
@ -303,6 +308,7 @@ public class XmppConnectionService extends Service {
|
||||||
replaceContactInConversation(contact.getJid(), contact);
|
replaceContactInConversation(contact.getJid(), contact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
private OnIqPacketReceived unknownIqListener = new OnIqPacketReceived() {
|
private OnIqPacketReceived unknownIqListener = new OnIqPacketReceived() {
|
||||||
|
@ -341,7 +347,8 @@ public class XmppConnectionService extends Service {
|
||||||
|
|
||||||
protected Conversation findMuc(String name, Account account) {
|
protected Conversation findMuc(String name, Account account) {
|
||||||
for (Conversation conversation : this.conversations) {
|
for (Conversation conversation : this.conversations) {
|
||||||
if (conversation.getContactJid().split("/")[0].equals(name)&&(conversation.getAccount() == account)) {
|
if (conversation.getContactJid().split("/")[0].equals(name)
|
||||||
|
&& (conversation.getAccount() == account)) {
|
||||||
return conversation;
|
return conversation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,7 +439,8 @@ public class XmppConnectionService extends Service {
|
||||||
this.reconnectAccount(account, true);
|
this.reconnectAccount(account, true);
|
||||||
} else if (SystemClock.elapsedRealtime() - lastReceived >= PING_MIN_INTERVAL * 1000) {
|
} else if (SystemClock.elapsedRealtime() - lastReceived >= PING_MIN_INTERVAL * 1000) {
|
||||||
account.getXmppConnection().sendPing();
|
account.getXmppConnection().sendPing();
|
||||||
account.getXmppConnection().lastPingSent = SystemClock.elapsedRealtime();
|
account.getXmppConnection().lastPingSent = SystemClock
|
||||||
|
.elapsedRealtime();
|
||||||
this.scheduleWakeupCall(2, false);
|
this.scheduleWakeupCall(2, false);
|
||||||
}
|
}
|
||||||
} else if (account.getStatus() == Account.STATUS_OFFLINE) {
|
} else if (account.getStatus() == Account.STATUS_OFFLINE) {
|
||||||
|
@ -440,15 +448,25 @@ public class XmppConnectionService extends Service {
|
||||||
account.setXmppConnection(this
|
account.setXmppConnection(this
|
||||||
.createConnection(account));
|
.createConnection(account));
|
||||||
}
|
}
|
||||||
account.getXmppConnection().lastPingSent = SystemClock.elapsedRealtime();
|
account.getXmppConnection().lastPingSent = SystemClock
|
||||||
|
.elapsedRealtime();
|
||||||
new Thread(account.getXmppConnection()).start();
|
new Thread(account.getXmppConnection()).start();
|
||||||
} else if ((account.getStatus() == Account.STATUS_CONNECTING)&&((SystemClock.elapsedRealtime() - account.getXmppConnection().lastConnect) / 1000 >= CONNECT_TIMEOUT)) {
|
} else if ((account.getStatus() == Account.STATUS_CONNECTING)
|
||||||
Log.d(LOGTAG,account.getJid()+": time out during connect reconnecting");
|
&& ((SystemClock.elapsedRealtime() - account
|
||||||
|
.getXmppConnection().lastConnect) / 1000 >= CONNECT_TIMEOUT)) {
|
||||||
|
Log.d(LOGTAG, account.getJid()
|
||||||
|
+ ": time out during connect reconnecting");
|
||||||
reconnectAccount(account, true);
|
reconnectAccount(account, true);
|
||||||
} else {
|
} else {
|
||||||
Log.d(LOGTAG,"seconds since last connect:"+((SystemClock.elapsedRealtime() - account.getXmppConnection().lastConnect) / 1000));
|
Log.d(LOGTAG,
|
||||||
Log.d(LOGTAG,account.getJid()+": status="+account.getStatus());
|
"seconds since last connect:"
|
||||||
// TODO notify user of ssl cert problem or auth problem or what ever
|
+ ((SystemClock.elapsedRealtime() - account
|
||||||
|
.getXmppConnection().lastConnect) / 1000));
|
||||||
|
Log.d(LOGTAG,
|
||||||
|
account.getJid() + ": status="
|
||||||
|
+ account.getStatus());
|
||||||
|
// TODO notify user of ssl cert problem or auth problem
|
||||||
|
// or what ever
|
||||||
}
|
}
|
||||||
// in any case. reschedule wakup call
|
// in any case. reschedule wakup call
|
||||||
this.scheduleWakeupCall(PING_MAX_INTERVAL, true);
|
this.scheduleWakeupCall(PING_MAX_INTERVAL, true);
|
||||||
|
@ -491,8 +509,6 @@ public class XmppConnectionService extends Service {
|
||||||
AlarmManager alarmManager = (AlarmManager) context
|
AlarmManager alarmManager = (AlarmManager) context
|
||||||
.getSystemService(Context.ALARM_SERVICE);
|
.getSystemService(Context.ALARM_SERVICE);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (ping) {
|
if (ping) {
|
||||||
if (this.pingIntent == null) {
|
if (this.pingIntent == null) {
|
||||||
this.pingIntent = new Intent(context, EventReceiver.class);
|
this.pingIntent = new Intent(context, EventReceiver.class);
|
||||||
|
@ -500,16 +516,19 @@ public class XmppConnectionService extends Service {
|
||||||
this.pingIntent.putExtra("time", timeToWake);
|
this.pingIntent.putExtra("time", timeToWake);
|
||||||
this.pendingPingIntent = PendingIntent.getBroadcast(context, 0,
|
this.pendingPingIntent = PendingIntent.getBroadcast(context, 0,
|
||||||
this.pingIntent, 0);
|
this.pingIntent, 0);
|
||||||
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,timeToWake, pendingPingIntent);
|
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
|
timeToWake, pendingPingIntent);
|
||||||
// Log.d(LOGTAG,"schedule ping in "+seconds+" seconds");
|
// Log.d(LOGTAG,"schedule ping in "+seconds+" seconds");
|
||||||
} else {
|
} else {
|
||||||
long scheduledTime = this.pingIntent.getLongExtra("time", 0);
|
long scheduledTime = this.pingIntent.getLongExtra("time", 0);
|
||||||
if (scheduledTime<SystemClock.elapsedRealtime() || (scheduledTime > timeToWake)) {
|
if (scheduledTime < SystemClock.elapsedRealtime()
|
||||||
|
|| (scheduledTime > timeToWake)) {
|
||||||
this.pingIntent.putExtra("time", timeToWake);
|
this.pingIntent.putExtra("time", timeToWake);
|
||||||
alarmManager.cancel(this.pendingPingIntent);
|
alarmManager.cancel(this.pendingPingIntent);
|
||||||
this.pendingPingIntent = PendingIntent.getBroadcast(context, 0,
|
this.pendingPingIntent = PendingIntent.getBroadcast(
|
||||||
this.pingIntent, 0);
|
context, 0, this.pingIntent, 0);
|
||||||
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,timeToWake, pendingPingIntent);
|
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,
|
||||||
|
timeToWake, pendingPingIntent);
|
||||||
// Log.d(LOGTAG,"reschedule old ping to ping in "+seconds+" seconds");
|
// Log.d(LOGTAG,"reschedule old ping to ping in "+seconds+" seconds");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -518,7 +537,8 @@ public class XmppConnectionService extends Service {
|
||||||
intent.setAction("ping_check");
|
intent.setAction("ping_check");
|
||||||
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0,
|
PendingIntent alarmIntent = PendingIntent.getBroadcast(context, 0,
|
||||||
intent, 0);
|
intent, 0);
|
||||||
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP,timeToWake, alarmIntent);
|
alarmManager.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, timeToWake,
|
||||||
|
alarmIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -549,6 +569,7 @@ public class XmppConnectionService extends Service {
|
||||||
@Override
|
@Override
|
||||||
public void onBind(Account account) {
|
public void onBind(Account account) {
|
||||||
databaseBackend.clearPresences(account);
|
databaseBackend.clearPresences(account);
|
||||||
|
account.clearPresences(); // self presences
|
||||||
if (account.getXmppConnection().hasFeatureRosterManagment()) {
|
if (account.getXmppConnection().hasFeatureRosterManagment()) {
|
||||||
updateRoster(account, null);
|
updateRoster(account, null);
|
||||||
}
|
}
|
||||||
|
@ -834,6 +855,13 @@ public class XmppConnectionService extends Service {
|
||||||
conv.setMessages(databaseBackend.getMessages(conv, 50));
|
conv.setMessages(databaseBackend.getMessages(conv, 50));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Collections.sort(this.conversations, new Comparator<Conversation>() {
|
||||||
|
@Override
|
||||||
|
public int compare(Conversation lhs, Conversation rhs) {
|
||||||
|
return (int) (rhs.getLatestMessage().getTimeSent() - lhs
|
||||||
|
.getLatestMessage().getTimeSent());
|
||||||
|
}
|
||||||
|
});
|
||||||
return this.conversations;
|
return this.conversations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -870,7 +898,8 @@ public class XmppConnectionService extends Service {
|
||||||
} else {
|
} else {
|
||||||
conversation.setMode(Conversation.MODE_SINGLE);
|
conversation.setMode(Conversation.MODE_SINGLE);
|
||||||
}
|
}
|
||||||
conversation.setMessages(databaseBackend.getMessages(conversation, 50));
|
conversation.setMessages(databaseBackend.getMessages(conversation,
|
||||||
|
50));
|
||||||
this.databaseBackend.updateConversation(conversation);
|
this.databaseBackend.updateConversation(conversation);
|
||||||
conversation.setContact(findContact(account,
|
conversation.setContact(findContact(account,
|
||||||
conversation.getContactJid()));
|
conversation.getContactJid()));
|
||||||
|
@ -1065,7 +1094,8 @@ public class XmppConnectionService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(Account account, boolean force) {
|
public void disconnect(Account account, boolean force) {
|
||||||
if ((account.getStatus() == Account.STATUS_ONLINE)||(account.getStatus() == Account.STATUS_DISABLED)) {
|
if ((account.getStatus() == Account.STATUS_ONLINE)
|
||||||
|
|| (account.getStatus() == Account.STATUS_DISABLED)) {
|
||||||
if (!force) {
|
if (!force) {
|
||||||
List<Conversation> conversations = getConversations();
|
List<Conversation> conversations = getConversations();
|
||||||
for (int i = 0; i < conversations.size(); i++) {
|
for (int i = 0; i < conversations.size(); i++) {
|
||||||
|
@ -1258,7 +1288,8 @@ public class XmppConnectionService extends Service {
|
||||||
x.addChild(invite);
|
x.addChild(invite);
|
||||||
packet.addChild(x);
|
packet.addChild(x);
|
||||||
Log.d(LOGTAG, packet.toString());
|
Log.d(LOGTAG, packet.toString());
|
||||||
conversation.getAccount().getXmppConnection().sendMessagePacket(packet);
|
conversation.getAccount().getXmppConnection()
|
||||||
|
.sendMessagePacket(packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
package eu.siacs.conversations.ui;
|
package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
|
@ -62,9 +60,6 @@ public class ConversationActivity extends XmppActivity {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConversationListChanged() {
|
public void onConversationListChanged() {
|
||||||
conversationList.clear();
|
|
||||||
conversationList.addAll(xmppConnectionService
|
|
||||||
.getConversations());
|
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -120,18 +115,6 @@ public class ConversationActivity extends XmppActivity {
|
||||||
return paneShouldBeOpen;
|
return paneShouldBeOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateConversationList() {
|
|
||||||
if (conversationList.size() >= 1) {
|
|
||||||
Collections.sort(this.conversationList, new Comparator<Conversation>() {
|
|
||||||
@Override
|
|
||||||
public int compare(Conversation lhs, Conversation rhs) {
|
|
||||||
return (int) (rhs.getLatestMessage().getTimeSent() - lhs.getLatestMessage().getTimeSent());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.listView.invalidateViews();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
@ -229,7 +212,7 @@ public class ConversationActivity extends XmppActivity {
|
||||||
if (!getSelectedConversation().isRead()) {
|
if (!getSelectedConversation().isRead()) {
|
||||||
getSelectedConversation().markRead();
|
getSelectedConversation().markRead();
|
||||||
UIHelper.updateNotification(getApplicationContext(), getConversationList(), null, false);
|
UIHelper.updateNotification(getApplicationContext(), getConversationList(), null, false);
|
||||||
updateConversationList();
|
listView.invalidateViews();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,10 +417,7 @@ public class ConversationActivity extends XmppActivity {
|
||||||
|
|
||||||
this.registerListener();
|
this.registerListener();
|
||||||
if (conversationList.size()==0) {
|
if (conversationList.size()==0) {
|
||||||
conversationList.addAll(xmppConnectionService
|
updateConversationList();
|
||||||
.getConversations());
|
|
||||||
|
|
||||||
this.updateConversationList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((getIntent().getAction()!=null)&&(getIntent().getAction().equals(Intent.ACTION_VIEW) && (!handledViewIntent))) {
|
if ((getIntent().getAction()!=null)&&(getIntent().getAction().equals(Intent.ACTION_VIEW) && (!handledViewIntent))) {
|
||||||
|
@ -495,4 +475,11 @@ public class ConversationActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateConversationList() {
|
||||||
|
conversationList.clear();
|
||||||
|
conversationList.addAll(xmppConnectionService
|
||||||
|
.getConversations());
|
||||||
|
listView.invalidateViews();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,6 +316,8 @@ public class ManageAccountActivity extends XmppActivity {
|
||||||
TextView carbon = (TextView) view.findViewById(R.id.carbon);
|
TextView carbon = (TextView) view.findViewById(R.id.carbon);
|
||||||
TextView stream = (TextView) view.findViewById(R.id.stream);
|
TextView stream = (TextView) view.findViewById(R.id.stream);
|
||||||
TextView roster = (TextView) view.findViewById(R.id.roster);
|
TextView roster = (TextView) view.findViewById(R.id.roster);
|
||||||
|
TextView presences = (TextView) view.findViewById(R.id.number_presences);
|
||||||
|
presences.setText(selectedAccountForActionMode.countPresences()+"");
|
||||||
pcks_received.setText(""+xmpp.getReceivedStanzas());
|
pcks_received.setText(""+xmpp.getReceivedStanzas());
|
||||||
pcks_sent.setText(""+xmpp.getSentStanzas());
|
pcks_sent.setText(""+xmpp.getSentStanzas());
|
||||||
if (connectionAgeHours >= 2) {
|
if (connectionAgeHours >= 2) {
|
||||||
|
|
|
@ -31,18 +31,26 @@ public class MessageParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Message parseOtrChat(MessagePacket packet, Account account, XmppConnectionService service) {
|
public static Message parseOtrChat(MessagePacket packet, Account account, XmppConnectionService service) {
|
||||||
|
boolean properlyAddressed = (packet.getTo().split("/").length == 2) || (account.countPresences() == 1);
|
||||||
String[] fromParts = packet.getFrom().split("/");
|
String[] fromParts = packet.getFrom().split("/");
|
||||||
Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false);
|
Conversation conversation = service.findOrCreateConversation(account, fromParts[0],false);
|
||||||
String body = packet.getBody();
|
String body = packet.getBody();
|
||||||
if (!conversation.hasValidOtrSession()) {
|
if (!conversation.hasValidOtrSession()) {
|
||||||
|
if (properlyAddressed) {
|
||||||
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
|
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
|
||||||
|
} else {
|
||||||
|
Log.d("xmppService",account.getJid()+": ignoring otr session with "+fromParts[0]);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
|
String foreignPresence = conversation.getOtrSession().getSessionID().getUserID();
|
||||||
if (!foreignPresence.equals(fromParts[1])) {
|
if (!foreignPresence.equals(fromParts[1])) {
|
||||||
Log.d(LOGTAG,"new otr during existing otr session requested. ending old one");
|
|
||||||
conversation.resetOtrSession();
|
conversation.resetOtrSession();
|
||||||
Log.d("xmppService","starting new one with "+fromParts[1]);
|
if (properlyAddressed) {
|
||||||
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
|
conversation.startOtrSession(service.getApplicationContext(), fromParts[1]);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -554,7 +554,7 @@ public class XmppConnection implements Runnable {
|
||||||
if (bindListener !=null) {
|
if (bindListener !=null) {
|
||||||
bindListener.onBind(account);
|
bindListener.onBind(account);
|
||||||
}
|
}
|
||||||
account.setStatus(Account.STATUS_ONLINE);
|
changeStatus(Account.STATUS_ONLINE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue