aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/eu/siacs/conversations/entities/AbstractEntity.java5
-rw-r--r--src/eu/siacs/conversations/entities/Account.java6
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java3
-rw-r--r--src/eu/siacs/conversations/entities/Message.java2
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java111
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java59
6 files changed, 105 insertions, 81 deletions
diff --git a/src/eu/siacs/conversations/entities/AbstractEntity.java b/src/eu/siacs/conversations/entities/AbstractEntity.java
index 0297fa66..4891723e 100644
--- a/src/eu/siacs/conversations/entities/AbstractEntity.java
+++ b/src/eu/siacs/conversations/entities/AbstractEntity.java
@@ -1,12 +1,9 @@
package eu.siacs.conversations.entities;
-import java.io.Serializable;
-
import android.content.ContentValues;
-public abstract class AbstractEntity implements Serializable {
+public abstract class AbstractEntity {
- private static final long serialVersionUID = -1895605706690653719L;
public static final String UUID = "uuid";
diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java
index ac62cf7b..0910516c 100644
--- a/src/eu/siacs/conversations/entities/Account.java
+++ b/src/eu/siacs/conversations/entities/Account.java
@@ -4,6 +4,7 @@ import java.security.interfaces.DSAPublicKey;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
+import java.util.concurrent.CopyOnWriteArrayList;
import net.java.otr4j.crypto.OtrCryptoEngineImpl;
import net.java.otr4j.crypto.OtrCryptoException;
@@ -18,8 +19,6 @@ import android.content.Context;
import android.database.Cursor;
public class Account extends AbstractEntity{
-
- private static final long serialVersionUID = 6174825093869578035L;
public static final String TABLENAME = "accounts";
@@ -72,6 +71,9 @@ public class Account extends AbstractEntity{
private List<Bookmark> bookmarks = new ArrayList<Bookmark>();
+ public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<Conversation>();
+ public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<Conversation>();
+
public Account() {
this.uuid = "0";
}
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index 70752adc..4e8c1834 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -16,9 +16,6 @@ import android.database.Cursor;
import android.net.Uri;
public class Conversation extends AbstractEntity {
-
- private static final long serialVersionUID = -6727528868973996739L;
-
public static final String TABLENAME = "conversations";
public static final int STATUS_AVAILABLE = 0;
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java
index 8e669c65..49c5ce58 100644
--- a/src/eu/siacs/conversations/entities/Message.java
+++ b/src/eu/siacs/conversations/entities/Message.java
@@ -7,8 +7,6 @@ import android.content.Context;
import android.database.Cursor;
public class Message extends AbstractEntity {
-
- private static final long serialVersionUID = 7222081895167103025L;
public static final String TABLENAME = "messages";
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index bbc9861a..339438da 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -148,6 +148,12 @@ public class XmppConnectionService extends Service {
mOnAccountUpdate.onAccountUpdate();;
}
if (account.getStatus() == Account.STATUS_ONLINE) {
+ for(Conversation conversation : account.pendingConferenceLeaves) {
+ leaveMuc(conversation);
+ }
+ for(Conversation conversation : account.pendingConferenceJoins) {
+ joinMuc(conversation);
+ }
mJingleConnectionManager.cancelInTransmission();
List<Conversation> conversations = getConversations();
for (int i = 0; i < conversations.size(); ++i) {
@@ -196,6 +202,21 @@ public class XmppConnectionService extends Service {
private PendingIntent pendingPingIntent = null;
private WakeLock wakeLock;
private PowerManager pm;
+ private OnBindListener mOnBindListener = new OnBindListener() {
+
+ @Override
+ public void onBind(final Account account) {
+ account.getRoster().clearPresences();
+ account.clearPresences(); // self presences
+ account.pendingConferenceJoins.clear();
+ account.pendingConferenceLeaves.clear();
+ fetchRosterFromServer(account);
+ fetchBookmarks(account);
+ sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
+ connectMultiModeConversations(account);
+ updateConversationUi();
+ }
+ };
public PgpEngine getPgpEngine() {
if (pgpServiceConnection.isBound()) {
@@ -465,19 +486,7 @@ public class XmppConnectionService extends Service {
}
}
});
- connection.setOnBindListener(new OnBindListener() {
-
- @Override
- public void onBind(final Account account) {
- account.getRoster().clearPresences();
- account.clearPresences(); // self presences
- fetchRosterFromServer(account);
- fetchBookmarks(account);
- sendPresencePacket(account, mPresenceGenerator.sendPresence(account));
- connectMultiModeConversations(account);
- updateConversationUi();
- }
- });
+ connection.setOnBindListener(this.mOnBindListener);
return connection;
}
@@ -682,7 +691,6 @@ public class XmppConnectionService extends Service {
if (storage!=null) {
for(Element item : storage.getChildren()) {
if (item.getName().equals("conference")) {
- Log.d(LOGTAG,item.toString());
Bookmark bookmark = Bookmark.parse(item,account);
bookmarks.add(bookmark);
Conversation conversation = findMuc(bookmark);
@@ -939,30 +947,36 @@ public class XmppConnectionService extends Service {
}
public void joinMuc(Conversation conversation) {
- Log.d(LOGTAG,"joining conversation "+conversation.getContactJid());
Account account = conversation.getAccount();
- String nick = conversation.getMucOptions().getProposedNick();
- conversation.getMucOptions().setJoinNick(nick);
- PresencePacket packet = new PresencePacket();
- packet.setAttribute("to",conversation.getMucOptions().getJoinJid());
- Element x = new Element("x");
- x.setAttribute("xmlns", "http://jabber.org/protocol/muc");
- String sig = account.getPgpSignature();
- if (sig != null) {
- packet.addChild("status").setContent("online");
- packet.addChild("x", "jabber:x:signed").setContent(sig);
- }
- if (conversation.getMessages().size() != 0) {
- final SimpleDateFormat mDateFormat = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
- mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
- Date date = new Date(
- conversation.getLatestMessage().getTimeSent() + 1000);
- x.addChild("history").setAttribute("since",
- mDateFormat.format(date));
+ account.pendingConferenceJoins.remove(conversation);
+ account.pendingConferenceLeaves.remove(conversation);
+ if (account.getStatus() == Account.STATUS_ONLINE) {
+ Log.d(LOGTAG,"joining conversation "+conversation.getContactJid());
+ String nick = conversation.getMucOptions().getProposedNick();
+ conversation.getMucOptions().setJoinNick(nick);
+ PresencePacket packet = new PresencePacket();
+ packet.setAttribute("to",conversation.getMucOptions().getJoinJid());
+ Element x = new Element("x");
+ x.setAttribute("xmlns", "http://jabber.org/protocol/muc");
+ String sig = account.getPgpSignature();
+ if (sig != null) {
+ packet.addChild("status").setContent("online");
+ packet.addChild("x", "jabber:x:signed").setContent(sig);
+ }
+ if (conversation.getMessages().size() != 0) {
+ final SimpleDateFormat mDateFormat = new SimpleDateFormat(
+ "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
+ mDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
+ Date date = new Date(
+ conversation.getLatestMessage().getTimeSent() + 1000);
+ x.addChild("history").setAttribute("since",
+ mDateFormat.format(date));
+ }
+ packet.addChild(x);
+ sendPresencePacket(account, packet);
+ } else {
+ account.pendingConferenceJoins.add(conversation);
}
- packet.addChild(x);
- sendPresencePacket(account, packet);
}
private OnRenameListener renameListener = null;
@@ -1020,14 +1034,21 @@ public class XmppConnectionService extends Service {
}
public void leaveMuc(Conversation conversation) {
- PresencePacket packet = new PresencePacket();
- packet.setAttribute("to", conversation.getMucOptions().getJoinJid());
- packet.setAttribute("from", conversation.getAccount().getFullJid());
- packet.setAttribute("type", "unavailable");
- sendPresencePacket(conversation.getAccount(),packet);
- conversation.getMucOptions().setOffline();
- conversation.deregisterWithBookmark();
- Log.d(LOGTAG,conversation.getAccount().getJid()+" leaving muc "+conversation.getContactJid());
+ Account account = conversation.getAccount();
+ account.pendingConferenceJoins.remove(conversation);
+ account.pendingConferenceLeaves.remove(conversation);
+ if (account.getStatus() == Account.STATUS_ONLINE) {
+ PresencePacket packet = new PresencePacket();
+ packet.setAttribute("to", conversation.getMucOptions().getJoinJid());
+ packet.setAttribute("from", conversation.getAccount().getFullJid());
+ packet.setAttribute("type", "unavailable");
+ sendPresencePacket(conversation.getAccount(),packet);
+ conversation.getMucOptions().setOffline();
+ conversation.deregisterWithBookmark();
+ Log.d(LOGTAG,conversation.getAccount().getJid()+" leaving muc "+conversation.getContactJid());
+ } else {
+ account.pendingConferenceLeaves.add(conversation);
+ }
}
public void disconnect(Account account, boolean force) {
@@ -1210,7 +1231,7 @@ public class XmppConnectionService extends Service {
x.addChild(invite);
packet.addChild(x);
sendMessagePacket(account,packet);
-
+ Log.d(LOGTAG,packet.toString());
}
public boolean markMessage(Account account, String recipient, String uuid,
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index e33e2cf3..202bab2e 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -8,6 +8,7 @@ import java.util.Set;
import net.java.otr4j.session.SessionStatus;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.PgpEngine;
+import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Contact;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
@@ -61,7 +62,7 @@ public class ConversationFragment extends Fragment {
protected ArrayAdapter<Message> messageListAdapter;
protected Contact contact;
protected BitmapCache mBitmapCache = new BitmapCache();
-
+
protected int mPrimaryTextColor;
protected int mSecondaryTextColor;
@@ -113,20 +114,21 @@ public class ConversationFragment extends Fragment {
}
}
};
-
+
private OnClickListener clickToMuc = new OnClickListener() {
@Override
public void onClick(View v) {
- Intent intent = new Intent(getActivity(), ConferenceDetailsActivity.class);
+ Intent intent = new Intent(getActivity(),
+ ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
};
-
+
private OnClickListener leaveMuc = new OnClickListener() {
-
+
@Override
public void onClick(View v) {
activity.endConversation(conversation);
@@ -187,12 +189,12 @@ public class ConversationFragment extends Fragment {
mPrimaryTextColor = getResources().getColor(R.color.primarytext);
mSecondaryTextColor = getResources().getColor(R.color.secondarytext);
-
+
final View view = inflater.inflate(R.layout.fragment_conversation,
container, false);
chatMsg = (EditText) view.findViewById(R.id.textinput);
chatMsg.setOnClickListener(new OnClickListener() {
-
+
@Override
public void onClick(View v) {
if (activity.getSlidingPaneLayout().isSlideable()) {
@@ -672,7 +674,8 @@ public class ConversationFragment extends Fragment {
@Override
public void userInputRequried(PendingIntent pi, Message message) {
askForPassphraseIntent = pi.getIntentSender();
- showSnackbar(R.string.openpgp_messages_found,R.string.decrypt,clickToDecryptListener);
+ showSnackbar(R.string.openpgp_messages_found,
+ R.string.decrypt, clickToDecryptListener);
}
@Override
@@ -724,11 +727,14 @@ public class ConversationFragment extends Fragment {
makeFingerprintWarning(conversation.getLatestEncryption());
}
} else {
- if (!conversation.getMucOptions().online()) {
+ if (!conversation.getMucOptions().online()
+ && conversation.getAccount().getStatus() == Account.STATUS_ONLINE) {
if (conversation.getMucOptions().getError() == MucOptions.ERROR_NICK_IN_USE) {
- showSnackbar(R.string.nick_in_use, R.string.edit,clickToMuc);
+ showSnackbar(R.string.nick_in_use, R.string.edit,
+ clickToMuc);
} else if (conversation.getMucOptions().getError() == MucOptions.ERROR_ROOM_NOT_FOUND) {
- showSnackbar(R.string.conference_not_found,R.string.leave,leaveMuc);
+ showSnackbar(R.string.conference_not_found,
+ R.string.leave, leaveMuc);
}
}
}
@@ -783,28 +789,31 @@ public class ConversationFragment extends Fragment {
&& (conversation.hasValidOtrSession()
&& (conversation.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) && (!knownFingerprints
.contains(conversation.getOtrFingerprint())))) {
- showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify, new OnClickListener() {
+ showSnackbar(R.string.unknown_otr_fingerprint, R.string.verify,
+ new OnClickListener() {
- @Override
- public void onClick(View v) {
- if (conversation.getOtrFingerprint() != null) {
- AlertDialog dialog = UIHelper.getVerifyFingerprintDialog(
- (ConversationActivity) getActivity(), conversation,
- snackbar);
- dialog.show();
- }
- }
- });
+ @Override
+ public void onClick(View v) {
+ if (conversation.getOtrFingerprint() != null) {
+ AlertDialog dialog = UIHelper
+ .getVerifyFingerprintDialog(
+ (ConversationActivity) getActivity(),
+ conversation, snackbar);
+ dialog.show();
+ }
+ }
+ });
}
}
-
- protected void showSnackbar(int message, int action, OnClickListener clickListener) {
+
+ protected void showSnackbar(int message, int action,
+ OnClickListener clickListener) {
snackbar.setVisibility(View.VISIBLE);
snackbarMessage.setText(message);
snackbarAction.setText(action);
snackbarAction.setOnClickListener(clickListener);
}
-
+
protected void hideSnackbar() {
snackbar.setVisibility(View.GONE);
}