aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs
diff options
context:
space:
mode:
Diffstat (limited to 'src/eu/siacs')
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java2
-rw-r--r--src/eu/siacs/conversations/entities/Message.java6
-rw-r--r--src/eu/siacs/conversations/entities/MucOptions.java8
-rw-r--r--src/eu/siacs/conversations/entities/Roster.java4
-rw-r--r--src/eu/siacs/conversations/generator/MessageGenerator.java8
-rw-r--r--src/eu/siacs/conversations/parser/AbstractParser.java2
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java16
-rw-r--r--src/eu/siacs/conversations/parser/PresenceParser.java4
-rw-r--r--src/eu/siacs/conversations/services/ImageProvider.java2
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java2
-rw-r--r--src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java2
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java32
-rw-r--r--src/eu/siacs/conversations/ui/ManageAccountActivity.java8
-rw-r--r--src/eu/siacs/conversations/ui/XmppActivity.java6
-rw-r--r--src/eu/siacs/conversations/ui/adapter/MessageAdapter.java57
-rw-r--r--src/eu/siacs/conversations/xmpp/XmppConnection.java2
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java4
17 files changed, 91 insertions, 74 deletions
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index 005b83db..8395449d 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -230,7 +230,7 @@ public class Conversation extends AbstractEntity {
return this.otrSession;
} else {
SessionID sessionId = new SessionID(
- this.getContactJid().split("/")[0], presence, "xmpp");
+ this.getContactJid().split("/",2)[0], presence, "xmpp");
this.otrSession = new SessionImpl(sessionId, getAccount()
.getOtrEngine(service));
try {
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java
index 63b6be92..9507b3fc 100644
--- a/src/eu/siacs/conversations/entities/Message.java
+++ b/src/eu/siacs/conversations/entities/Message.java
@@ -246,9 +246,9 @@ public class Message extends AbstractEntity {
public void setPresence(String presence) {
if (presence == null) {
- this.counterpart = this.counterpart.split("/")[0];
+ this.counterpart = this.counterpart.split("/",2)[0];
} else {
- this.counterpart = this.counterpart.split("/")[0] + "/" + presence;
+ this.counterpart = this.counterpart.split("/",2)[0] + "/" + presence;
}
}
@@ -257,7 +257,7 @@ public class Message extends AbstractEntity {
}
public String getPresence() {
- String[] counterparts = this.counterpart.split("/");
+ String[] counterparts = this.counterpart.split("/",2);
if (counterparts.length == 2) {
return counterparts[1];
} else {
diff --git a/src/eu/siacs/conversations/entities/MucOptions.java b/src/eu/siacs/conversations/entities/MucOptions.java
index e9ab6908..676fb4f4 100644
--- a/src/eu/siacs/conversations/entities/MucOptions.java
+++ b/src/eu/siacs/conversations/entities/MucOptions.java
@@ -134,7 +134,7 @@ public class MucOptions {
}
public void processPacket(PresencePacket packet, PgpEngine pgp) {
- String[] fromParts = packet.getFrom().split("/");
+ String[] fromParts = packet.getFrom().split("/",2);
if (fromParts.length >= 2) {
String name = fromParts[1];
String type = packet.getAttribute("type");
@@ -180,7 +180,7 @@ public class MucOptions {
}
}
} else if (type.equals("unavailable")) {
- deleteUser(packet.getAttribute("from").split("/")[1]);
+ deleteUser(packet.getAttribute("from").split("/",2)[1]);
} else if (type.equals("error")) {
Element error = packet.findChild("error");
if (error.hasChild("conflict")) {
@@ -209,7 +209,7 @@ public class MucOptions {
}
public String getProposedNick() {
- String[] mucParts = conversation.getContactJid().split("/");
+ String[] mucParts = conversation.getContactJid().split("/",2);
if (conversation.getBookmark() != null
&& conversation.getBookmark().getNick() != null) {
return conversation.getBookmark().getNick();
@@ -309,7 +309,7 @@ public class MucOptions {
}
public String getJoinJid() {
- return this.conversation.getContactJid().split("/")[0] + "/"
+ return this.conversation.getContactJid().split("/",2)[0] + "/"
+ this.joinnick;
}
diff --git a/src/eu/siacs/conversations/entities/Roster.java b/src/eu/siacs/conversations/entities/Roster.java
index c6212f77..f11f0250 100644
--- a/src/eu/siacs/conversations/entities/Roster.java
+++ b/src/eu/siacs/conversations/entities/Roster.java
@@ -15,12 +15,12 @@ public class Roster {
}
public boolean hasContact(String jid) {
- String cleanJid = jid.split("/")[0];
+ String cleanJid = jid.split("/",2)[0];
return contacts.containsKey(cleanJid);
}
public Contact getContact(String jid) {
- String cleanJid = jid.split("/")[0].toLowerCase(Locale.getDefault());
+ String cleanJid = jid.split("/",2)[0].toLowerCase(Locale.getDefault());
if (contacts.containsKey(cleanJid)) {
return contacts.get(cleanJid);
} else {
diff --git a/src/eu/siacs/conversations/generator/MessageGenerator.java b/src/eu/siacs/conversations/generator/MessageGenerator.java
index acfa3db7..d4cab3ed 100644
--- a/src/eu/siacs/conversations/generator/MessageGenerator.java
+++ b/src/eu/siacs/conversations/generator/MessageGenerator.java
@@ -34,7 +34,7 @@ public class MessageGenerator extends AbstractGenerator {
packet.setTo(message.getCounterpart());
packet.setType(MessagePacket.TYPE_CHAT);
} else {
- packet.setTo(message.getCounterpart().split("/")[0]);
+ packet.setTo(message.getCounterpart().split("/",2)[0]);
packet.setType(MessagePacket.TYPE_GROUPCHAT);
}
packet.setFrom(account.getFullJid());
@@ -134,7 +134,7 @@ public class MessageGenerator extends AbstractGenerator {
String subject) {
MessagePacket packet = new MessagePacket();
packet.setType(MessagePacket.TYPE_GROUPCHAT);
- packet.setTo(conversation.getContactJid().split("/")[0]);
+ packet.setTo(conversation.getContactJid().split("/",2)[0]);
Element subjectChild = new Element("subject");
subjectChild.setContent(subject);
packet.addChild(subjectChild);
@@ -148,13 +148,13 @@ public class MessageGenerator extends AbstractGenerator {
packet.setTo(contact);
packet.setFrom(conversation.getAccount().getFullJid());
Element x = packet.addChild("x", "jabber:x:conference");
- x.setAttribute("jid", conversation.getContactJid().split("/")[0]);
+ x.setAttribute("jid", conversation.getContactJid().split("/",2)[0]);
return packet;
}
public MessagePacket invite(Conversation conversation, String contact) {
MessagePacket packet = new MessagePacket();
- packet.setTo(conversation.getContactJid().split("/")[0]);
+ packet.setTo(conversation.getContactJid().split("/",2)[0]);
packet.setFrom(conversation.getAccount().getFullJid());
Element x = new Element("x");
x.setAttribute("xmlns", "http://jabber.org/protocol/muc#user");
diff --git a/src/eu/siacs/conversations/parser/AbstractParser.java b/src/eu/siacs/conversations/parser/AbstractParser.java
index 25fcd921..efbf5aef 100644
--- a/src/eu/siacs/conversations/parser/AbstractParser.java
+++ b/src/eu/siacs/conversations/parser/AbstractParser.java
@@ -60,7 +60,7 @@ public abstract class AbstractParser {
protected void updateLastseen(Element packet, Account account,
boolean presenceOverwrite) {
- String[] fromParts = packet.getAttribute("from").split("/");
+ String[] fromParts = packet.getAttribute("from").split("/",2);
String from = fromParts[0];
String presence = null;
if (fromParts.length >= 2) {
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index d2274000..0e15c60f 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -25,7 +25,7 @@ public class MessageParser extends AbstractParser implements
}
private Message parseChat(MessagePacket packet, Account account) {
- String[] fromParts = packet.getFrom().split("/");
+ String[] fromParts = packet.getFrom().split("/",2);
Conversation conversation = mXmppConnectionService
.findOrCreateConversation(account, fromParts[0], false);
conversation.setLatestMarkableMessageId(getMarkableMessageId(packet));
@@ -57,9 +57,9 @@ public class MessageParser extends AbstractParser implements
}
private Message parseOtrChat(MessagePacket packet, Account account) {
- boolean properlyAddressed = (packet.getTo().split("/").length == 2)
+ boolean properlyAddressed = (packet.getTo().split("/",2).length == 2)
|| (account.countPresences() == 1);
- String[] fromParts = packet.getFrom().split("/");
+ String[] fromParts = packet.getFrom().split("/",2);
Conversation conversation = mXmppConnectionService
.findOrCreateConversation(account, fromParts[0], false);
String presence;
@@ -132,7 +132,7 @@ public class MessageParser extends AbstractParser implements
private Message parseGroupchat(MessagePacket packet, Account account) {
int status;
- String[] fromParts = packet.getFrom().split("/");
+ String[] fromParts = packet.getFrom().split("/",2);
if (mXmppConnectionService.find(account.pendingConferenceLeaves,
account, fromParts[0]) != null) {
return null;
@@ -221,7 +221,7 @@ public class MessageParser extends AbstractParser implements
return null;
}
}
- String[] parts = fullJid.split("/");
+ String[] parts = fullJid.split("/",2);
Conversation conversation = mXmppConnectionService
.findOrCreateConversation(account, parts[0], false);
conversation.setLatestMarkableMessageId(getMarkableMessageId(packet));
@@ -253,7 +253,7 @@ public class MessageParser extends AbstractParser implements
}
private void parseError(MessagePacket packet, Account account) {
- String[] fromParts = packet.getFrom().split("/");
+ String[] fromParts = packet.getFrom().split("/",2);
mXmppConnectionService.markMessage(account, fromParts[0],
packet.getId(), Message.STATUS_SEND_FAILED);
}
@@ -267,14 +267,14 @@ public class MessageParser extends AbstractParser implements
String id = packet
.findChild("displayed", "urn:xmpp:chat-markers:0")
.getAttribute("id");
- String[] fromParts = packet.getAttribute("from").split("/");
+ String[] fromParts = packet.getAttribute("from").split("/",2);
updateLastseen(packet, account, true);
mXmppConnectionService.markMessage(account, fromParts[0], id,
Message.STATUS_SEND_DISPLAYED);
} else if (packet.hasChild("received", "urn:xmpp:chat-markers:0")) {
String id = packet.findChild("received", "urn:xmpp:chat-markers:0")
.getAttribute("id");
- String[] fromParts = packet.getAttribute("from").split("/");
+ String[] fromParts = packet.getAttribute("from").split("/",2);
updateLastseen(packet, account, false);
mXmppConnectionService.markMessage(account, fromParts[0], id,
Message.STATUS_SEND_RECEIVED);
diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java
index 05ffa67e..e240a858 100644
--- a/src/eu/siacs/conversations/parser/PresenceParser.java
+++ b/src/eu/siacs/conversations/parser/PresenceParser.java
@@ -22,7 +22,7 @@ public class PresenceParser extends AbstractParser implements
PgpEngine mPgpEngine = mXmppConnectionService.getPgpEngine();
if (packet.hasChild("x", "http://jabber.org/protocol/muc#user")) {
Conversation muc = mXmppConnectionService.find(account, packet
- .getAttribute("from").split("/")[0]);
+ .getAttribute("from").split("/",2)[0]);
if (muc != null) {
boolean before = muc.getMucOptions().online();
muc.getMucOptions().processPacket(packet, mPgpEngine);
@@ -32,7 +32,7 @@ public class PresenceParser extends AbstractParser implements
}
} else if (packet.hasChild("x", "http://jabber.org/protocol/muc")) {
Conversation muc = mXmppConnectionService.find(account, packet
- .getAttribute("from").split("/")[0]);
+ .getAttribute("from").split("/",2)[0]);
if (muc != null) {
boolean before = muc.getMucOptions().online();
muc.getMucOptions().processPacket(packet, mPgpEngine);
diff --git a/src/eu/siacs/conversations/services/ImageProvider.java b/src/eu/siacs/conversations/services/ImageProvider.java
index 15b86802..af8ab4b2 100644
--- a/src/eu/siacs/conversations/services/ImageProvider.java
+++ b/src/eu/siacs/conversations/services/ImageProvider.java
@@ -31,7 +31,7 @@ public class ImageProvider extends ContentProvider {
if (uuids == null) {
throw new FileNotFoundException();
}
- String[] uuidsSplited = uuids.split("/");
+ String[] uuidsSplited = uuids.split("/",2);
if (uuidsSplited.length != 3) {
throw new FileNotFoundException();
}
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 5bc25552..f80bb9ef 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -847,7 +847,7 @@ public class XmppConnectionService extends Service {
String jid) {
for (Conversation conversation : haystack) {
if ((conversation.getAccount().equals(account))
- && (conversation.getContactJid().split("/")[0].equals(jid))) {
+ && (conversation.getContactJid().split("/",2)[0].equals(jid))) {
return conversation;
}
}
diff --git a/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
index 2cfa1635..76c12a47 100644
--- a/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
+++ b/src/eu/siacs/conversations/ui/ConferenceDetailsActivity.java
@@ -201,7 +201,7 @@ public class ConferenceDetailsActivity extends XmppActivity {
private void populateView() {
mYourPhoto.setImageBitmap(conversation.getAccount().getImage(this, 48));
setTitle(conversation.getName());
- mFullJid.setText(conversation.getContactJid().split("/")[0]);
+ mFullJid.setText(conversation.getContactJid().split("/",2)[0]);
mYourNick.setText(conversation.getMucOptions().getActualNick());
mRoleAffiliaton = (TextView) findViewById(R.id.muc_role);
if (conversation.getMucOptions().online()) {
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index ea0a6f14..299bf281 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -275,11 +275,23 @@ public class ConversationFragment extends Fragment {
@Override
public void onContactPictureClicked(Message message) {
- if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
- if (message.getPresence() != null) {
- highlightInConference(message.getPresence());
+ if (message.getStatus() <= Message.STATUS_RECEIVED) {
+ if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
+ if (message.getPresence() != null) {
+ highlightInConference(message.getPresence());
+ } else {
+ highlightInConference(message
+ .getCounterpart());
+ }
} else {
- highlightInConference(message.getCounterpart());
+ Contact contact = message.getConversation()
+ .getContact();
+ if (contact.showInRoster()) {
+ activity.switchToContactDetails(contact);
+ } else {
+ activity.showAddToRosterDialog(message
+ .getConversation());
+ }
}
}
}
@@ -289,11 +301,13 @@ public class ConversationFragment extends Fragment {
@Override
public void onContactPictureLongClicked(Message message) {
- if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
- if (message.getPresence() != null) {
- privateMessageWith(message.getPresence());
- } else {
- privateMessageWith(message.getCounterpart());
+ if (message.getStatus() <= Message.STATUS_RECEIVED) {
+ if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
+ if (message.getPresence() != null) {
+ privateMessageWith(message.getPresence());
+ } else {
+ privateMessageWith(message.getCounterpart());
+ }
}
}
}
diff --git a/src/eu/siacs/conversations/ui/ManageAccountActivity.java b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
index c57121da..ca17eb0d 100644
--- a/src/eu/siacs/conversations/ui/ManageAccountActivity.java
+++ b/src/eu/siacs/conversations/ui/ManageAccountActivity.java
@@ -62,7 +62,7 @@ public class ManageAccountActivity extends XmppActivity {
@Override
public void onItemClick(AdapterView<?> arg0, View view,
int position, long arg3) {
- editAccount(accountList.get(position));
+ switchToAccount(accountList.get(position));
}
});
registerForContextMenu(accountListView);
@@ -163,12 +163,6 @@ public class ManageAccountActivity extends XmppActivity {
}
}
- private void editAccount(Account account) {
- Intent intent = new Intent(this, EditAccountActivity.class);
- intent.putExtra("jid", account.getJid());
- startActivity(intent);
- }
-
private void publishAvatar(Account account) {
Intent intent = new Intent(getApplicationContext(),
PublishProfilePictureActivity.class);
diff --git a/src/eu/siacs/conversations/ui/XmppActivity.java b/src/eu/siacs/conversations/ui/XmppActivity.java
index 4ee51580..351462ae 100644
--- a/src/eu/siacs/conversations/ui/XmppActivity.java
+++ b/src/eu/siacs/conversations/ui/XmppActivity.java
@@ -247,6 +247,12 @@ public abstract class XmppActivity extends Activity {
intent.putExtra("contact", contact.getJid());
startActivity(intent);
}
+
+ public void switchToAccount(Account account) {
+ Intent intent = new Intent(this, EditAccountActivity.class);
+ intent.putExtra("jid", account.getJid());
+ startActivity(intent);
+ }
protected void inviteToConversation(Conversation conversation) {
Intent intent = new Intent(getApplicationContext(),
diff --git a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 87565b93..2392bbcf 100644
--- a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -421,6 +421,36 @@ public class MessageAdapter extends ArrayAdapter<Message> {
return view;
}
+ if (viewHolder.contact_picture != null) {
+ viewHolder.contact_picture
+ .setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ if (MessageAdapter.this.mOnContactPictureClickedListener != null) {
+ MessageAdapter.this.mOnContactPictureClickedListener
+ .onContactPictureClicked(item);
+ ;
+ }
+
+ }
+ });
+ viewHolder.contact_picture
+ .setOnLongClickListener(new OnLongClickListener() {
+
+ @Override
+ public boolean onLongClick(View v) {
+ if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) {
+ MessageAdapter.this.mOnContactPictureLongClickedListener
+ .onContactPictureLongClicked(item);
+ return true;
+ } else {
+ return false;
+ }
+ }
+ });
+ }
+
if (type == RECEIVED) {
if (item.getConversation().getMode() == Conversation.MODE_MULTI) {
Contact contact = item.getContact();
@@ -435,33 +465,6 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.contact_picture.setImageBitmap(mBitmapCache.get(
name, getContext()));
}
- viewHolder.contact_picture
- .setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- if (MessageAdapter.this.mOnContactPictureClickedListener != null) {
- MessageAdapter.this.mOnContactPictureClickedListener
- .onContactPictureClicked(item);
- ;
- }
-
- }
- });
- viewHolder.contact_picture
- .setOnLongClickListener(new OnLongClickListener() {
-
- @Override
- public boolean onLongClick(View v) {
- if (MessageAdapter.this.mOnContactPictureLongClickedListener != null) {
- MessageAdapter.this.mOnContactPictureLongClickedListener
- .onContactPictureLongClicked(item);
- return true;
- } else {
- return false;
- }
- }
- });
}
}
diff --git a/src/eu/siacs/conversations/xmpp/XmppConnection.java b/src/eu/siacs/conversations/xmpp/XmppConnection.java
index e7b25e26..e02c772d 100644
--- a/src/eu/siacs/conversations/xmpp/XmppConnection.java
+++ b/src/eu/siacs/conversations/xmpp/XmppConnection.java
@@ -657,7 +657,7 @@ public class XmppConnection implements Runnable {
if (bind != null) {
Element jid = bind.findChild("jid");
if (jid != null) {
- account.setResource(jid.getContent().split("/")[1]);
+ account.setResource(jid.getContent().split("/",2)[1]);
if (streamFeatures.hasChild("sm", "urn:xmpp:sm:3")) {
smVersion = 3;
EnablePacket enable = new EnablePacket(smVersion);
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index f42482e8..4eac99e6 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -256,12 +256,12 @@ public class JingleConnection implements Downloadable {
this.status = STATUS_INITIATED;
Conversation conversation = this.mXmppConnectionService
.findOrCreateConversation(account,
- packet.getFrom().split("/")[0], false);
+ packet.getFrom().split("/",2)[0], false);
this.message = new Message(conversation, "", Message.ENCRYPTION_NONE);
this.message.setType(Message.TYPE_IMAGE);
this.message.setStatus(Message.STATUS_RECEIVED_OFFER);
this.message.setDownloadable(this);
- String[] fromParts = packet.getFrom().split("/");
+ String[] fromParts = packet.getFrom().split("/",2);
this.message.setPresence(fromParts[1]);
this.account = account;
this.initiator = packet.getFrom();