aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/eu/siacs/conversations/entities/Message.java7
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java47
-rw-r--r--src/eu/siacs/conversations/ui/ConversationActivity.java4
-rw-r--r--src/eu/siacs/conversations/ui/ConversationFragment.java8
5 files changed, 47 insertions, 23 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 52e141991..f73258052 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -97,9 +97,6 @@
<string name="error_loading_image">Error loading image (File not found)</string>
<string name="image_offered_for_download"><i>Image file offered for download</i></string>
<string name="not_connected">Not Connected</string>
- <string name="you_are_offline">You have to be online to send %s but your account assoziated with this Conversation is currently offline.</string>
- <string name="you_are_offline_blank">You can not perform this action while being offline</string>
- <string name="files">files</string>
<string name="otr_messages">OTR encrypted messages</string>
<string name="manage_account">Manage account</string>
<string name="contact_offline">Your Contact is Offline</string>
@@ -112,6 +109,7 @@
<string name="restart">Restart</string>
<string name="install">Install</string>
<string name="offering">offering&#8230;</string>
+ <string name="waiting">waiting&#8230;</string>
<string name="no_pgp_key">No OpenPGP Key found</string>
<string name="contact_has_no_pgp_key">Conversations is unable to encrypt your messages because your contact is not announcing his or hers public key.\n\n<small>Please ask your contact to setup OpenPGP.</small></string>
<string name="no_pgp_keys">No OpenPGP Keys found</string>
diff --git a/src/eu/siacs/conversations/entities/Message.java b/src/eu/siacs/conversations/entities/Message.java
index c298a6522..1e82fe6aa 100644
--- a/src/eu/siacs/conversations/entities/Message.java
+++ b/src/eu/siacs/conversations/entities/Message.java
@@ -19,6 +19,7 @@ public class Message extends AbstractEntity {
public static final int STATUS_SEND = 2;
public static final int STATUS_SEND_FAILED = 3;
public static final int STATUS_SEND_REJECTED = 4;
+ public static final int STATUS_WAITING = 5;
public static final int STATUS_OFFERED = 6;
public static final int STATUS_SEND_RECEIVED = 7;
public static final int STATUS_SEND_DISPLAYED = 8;
@@ -200,7 +201,11 @@ public class Message extends AbstractEntity {
}
public void setPresence(String presence) {
- this.counterpart = this.counterpart.split("/")[0] + "/" + presence;
+ if (presence == null) {
+ this.counterpart = this.counterpart.split("/")[0];
+ } else {
+ this.counterpart = this.counterpart.split("/")[0] + "/" + presence;
+ }
}
public String getPresence() {
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 44964c7c2..154b317e5 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -102,7 +102,7 @@ public class XmppConnectionService extends Service {
Conversation conversation = findActiveConversation(contact);
if (conversation != null) {
conversation.endOtrIfNeeded();
- if (online&&(contact.getPresences().size() == 1)) {
+ if (online && (contact.getPresences().size() == 1)) {
sendUnsendMessages(conversation);
}
}
@@ -653,17 +653,19 @@ public class XmppConnectionService extends Service {
mJingleConnectionManager.createNewConnection(message);
} else {
if (message.getEncryption() == Message.ENCRYPTION_OTR) {
- if (!conv.hasValidOtrSession()) {
+ if (!conv.hasValidOtrSession()&&(message.getPresence() != null)) {
// starting otr session. messages will be send later
- conv.startOtrSession(getApplicationContext(), message.getPresence(),
- true);
- } else if (conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
+ conv.startOtrSession(getApplicationContext(),
+ message.getPresence(), true);
+ } else if (conv.hasValidOtrSession() && conv.getOtrSession().getSessionStatus() == SessionStatus.ENCRYPTED) {
// otr session aleary exists, creating message packet
// accordingly
packet = prepareMessagePacket(account, message,
conv.getOtrSession());
send = true;
message.setStatus(Message.STATUS_SEND);
+ } else if (message.getPresence() == null) {
+ message.setStatus(Message.STATUS_WAITING);
}
saveInDb = true;
addToConversation = true;
@@ -700,10 +702,15 @@ public class XmppConnectionService extends Service {
message.setBody(decryptedBody);
addToConversation = true;
} else if (message.getEncryption() == Message.ENCRYPTION_OTR) {
- if (!conv.hasValidOtrSession()) {
- conv.startOtrSession(getApplicationContext(), message.getPresence(),false);
+ if (conv.hasValidOtrSession()) {
+ message.setPresence(conv.getOtrSession().getSessionID()
+ .getUserID());
+ } else if (!conv.hasValidOtrSession() && message.getPresence() != null) {
+ conv.startOtrSession(getApplicationContext(),
+ message.getPresence(), false);
+ } else if (message.getPresence() == null) {
+ message.setStatus(Message.STATUS_WAITING);
}
- message.setPresence(conv.getOtrSession().getSessionID().getUserID());
saveInDb = true;
addToConversation = true;
} else {
@@ -729,7 +736,9 @@ public class XmppConnectionService extends Service {
private void sendUnsendMessages(Conversation conversation) {
for (int i = 0; i < conversation.getMessages().size(); ++i) {
- if (conversation.getMessages().get(i).getStatus() == Message.STATUS_UNSEND) {
+ int status = conversation.getMessages().get(i).getStatus();
+ if ((status == Message.STATUS_UNSEND)
+ || (status == Message.STATUS_WAITING)) {
resendMessage(conversation.getMessages().get(i));
}
}
@@ -756,14 +765,19 @@ public class XmppConnectionService extends Service {
packet.addChild("x", "jabber:x:encrypted").setContent(
message.getBody());
} else if (message.getEncryption() == Message.ENCRYPTION_OTR) {
- Presences presences = message.getConversation().getContact().getPresences();
+ Presences presences = message.getConversation().getContact()
+ .getPresences();
if (!message.getConversation().hasValidOtrSession()) {
- if ((message.getPresence() != null)&&(presences.has(message.getPresence()))) {
- message.getConversation().startOtrSession(getApplicationContext(), message.getPresence(), true);
+ if ((message.getPresence() != null)
+ && (presences.has(message.getPresence()))) {
+ message.getConversation().startOtrSession(
+ getApplicationContext(), message.getPresence(),
+ true);
} else {
if (presences.size() == 1) {
String presence = presences.asStringArray()[0];
- message.getConversation().startOtrSession(getApplicationContext(), presence, true);
+ message.getConversation().startOtrSession(
+ getApplicationContext(), presence, true);
}
}
}
@@ -774,6 +788,7 @@ public class XmppConnectionService extends Service {
}
} else if (message.getType() == Message.TYPE_IMAGE) {
// TODO: send images
+
}
}
@@ -1194,10 +1209,12 @@ public class XmppConnectionService extends Service {
Account account = conversation.getAccount();
List<Message> messages = conversation.getMessages();
Session otrSession = conversation.getOtrSession();
- Log.d(LOGTAG,account.getJid()+" otr session established with "+conversation.getContactJid()+"/"+otrSession.getSessionID().getUserID());
+ Log.d(LOGTAG, account.getJid() + " otr session established with "
+ + conversation.getContactJid() + "/"
+ + otrSession.getSessionID().getUserID());
for (int i = 0; i < messages.size(); ++i) {
Message msg = messages.get(i);
- if ((msg.getStatus() == Message.STATUS_UNSEND)
+ if ((msg.getStatus() == Message.STATUS_UNSEND || msg.getStatus() == Message.STATUS_WAITING)
&& (msg.getEncryption() == Message.ENCRYPTION_OTR)) {
MessagePacket outPacket = prepareMessagePacket(account, msg,
otrSession);
diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java
index 995568903..06efff4b9 100644
--- a/src/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/eu/siacs/conversations/ui/ConversationActivity.java
@@ -389,7 +389,7 @@ public class ConversationActivity extends XmppActivity {
// TODO Auto-generated method stub
}
- }, "file");
+ });
}
private void attachFile(final int attachmentChoice) {
@@ -868,7 +868,7 @@ public class ConversationActivity extends XmppActivity {
}
public void selectPresence(final Conversation conversation,
- final OnPresenceSelected listener, String reason) {
+ final OnPresenceSelected listener) {
Contact contact = conversation.getContact();
if (contact == null) {
showAddToRosterDialog(conversation);
diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java
index 5d7e9f94d..1939ae727 100644
--- a/src/eu/siacs/conversations/ui/ConversationFragment.java
+++ b/src/eu/siacs/conversations/ui/ConversationFragment.java
@@ -207,6 +207,9 @@ public class ConversationFragment extends Fragment {
}
}
switch (message.getStatus()) {
+ case Message.STATUS_WAITING:
+ info = getString(R.string.waiting);
+ break;
case Message.STATUS_UNSEND:
info = getString(R.string.sending);
break;
@@ -883,7 +886,7 @@ public class ConversationFragment extends Fragment {
}
protected void sendOtrMessage(final Message message) {
- ConversationActivity activity = (ConversationActivity) getActivity();
+ final ConversationActivity activity = (ConversationActivity) getActivity();
final XmppConnectionService xmppService = activity.xmppConnectionService;
if (conversation.hasValidOtrSession()) {
activity.xmppConnectionService.sendMessage(message);
@@ -896,6 +899,7 @@ public class ConversationFragment extends Fragment {
public void onPresenceSelected(boolean success,
String presence) {
if (success) {
+ Log.d("xmppService","selected presence "+presence);
message.setPresence(presence);
xmppService.sendMessage(message);
messageSent();
@@ -908,7 +912,7 @@ public class ConversationFragment extends Fragment {
xmppService.sendMessage(message);
messageSent();
}
- }, "otr");
+ });
}
}