aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md14
-rw-r--r--res/values-fr/strings.xml65
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/eu/siacs/conversations/Config.java2
-rw-r--r--src/eu/siacs/conversations/entities/Account.java27
-rw-r--r--src/eu/siacs/conversations/entities/Conversation.java16
-rw-r--r--src/eu/siacs/conversations/entities/Downloadable.java2
-rw-r--r--src/eu/siacs/conversations/http/HttpConnection.java18
-rw-r--r--src/eu/siacs/conversations/http/HttpConnectionManager.java2
-rw-r--r--src/eu/siacs/conversations/parser/MessageParser.java6
-rw-r--r--src/eu/siacs/conversations/parser/PresenceParser.java3
-rw-r--r--src/eu/siacs/conversations/services/NotificationService.java27
-rw-r--r--src/eu/siacs/conversations/services/XmppConnectionService.java37
-rw-r--r--src/eu/siacs/conversations/ui/adapter/MessageAdapter.java42
-rw-r--r--src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java23
15 files changed, 177 insertions, 108 deletions
diff --git a/README.md b/README.md
index 9fc74fdd..4f31904a 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
#Conversations
-Conversations - the very last word in instant messaging
+Conversations: the very last word in instant messaging
[![Google Play](http://developer.android.com/images/brand/en_generic_rgb_wo_45.png)](https://play.google.com/store/apps/details?id=eu.siacs.conversations)
@@ -10,10 +10,10 @@ Conversations - the very last word in instant messaging
privacy
* Rely on existing, well established protocols (XMPP)
* Do not require a Google Account or specifically Google Cloud Messaging (GCM)
-* Require as little permissons as possible
+* Require as few permissions as possible
##Features
-* End-to-end encryption with either OTR or openPGP
+* End-to-end encryption with either [OTR](https://otr.cypherpunks.ca/) or [OpenPGP](http://www.openpgp.org/about_openpgp/)
* Sending and receiving images
* Indication when your contact has read your message
* Intuitive UI that follows Android Design guidelines
@@ -21,7 +21,7 @@ Conversations - the very last word in instant messaging
* Syncs with desktop client
* Conferences (with support for bookmarks)
* Address book integration
-* Multiple Accounts / unified inbox
+* Multiple accounts / unified inbox
* Very low impact on battery life
@@ -31,10 +31,10 @@ protocol. These extensions are standardized as well in so called XEP’s.
Conversations supports a couple of those to make the overall user experience better. There is a
chance that your current XMPP server does not support these extensions.
Therefore to get the most out of Conversations you should consider either switching to an
-XMPP server that does or - even better - run your own XMPP server for you and
+XMPP server that does or — even better — run your own XMPP server for you and
your friends.
These XEPs are - as of now:
-* XEP-0065: SOCKS5 Bytestreams - or rather mod_proxy65. Will be used to transfer files if both parties are behind a firewall (NAT).
+* XEP-0065: SOCKS5 Bytestreams (or rather mod_proxy65). Will be used to transfer files if both parties are behind a firewall (NAT).
* XEP-0138: Stream Compression saves bandwidth
* XEP-0163: Personal Eventing Protocol for avatars
* XEP-0198: Stream Management allows XMPP to survive small network outages and changes of the underlying TCP connection.
@@ -44,7 +44,7 @@ These XEPs are - as of now:
* XEP-0237: Roster Versioning mainly to save bandwidth on poor mobile connections
* XEP-0352: Client State Indication let the server know whether or not
Conversations is in the background. Allows the server to save bandwidth by
- withholding unimportent packages.
+ withholding unimportant packages.
##Team
####Head of Development
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index e15ef416..48031ee8 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -87,6 +87,7 @@
<string name="encrypted_message_received"><i>Message chiffré reçu. Appuyez pour le déchiffrer.</i></string>
<string name="encrypted_image_received"><i>Image chiffrée reçue. Appuyez pour la déchiffrer.</i></string>
<string name="image_file"><i>Image reçue. Appuyez pour visualiser.</i></string>
+ <string name="pref_general">Général</string>
<string name="pref_xmpp_resource">Ressource XMPP</string>
<string name="pref_xmpp_resource_summary">Nom permettant d\'identifier ce client XMPP</string>
<string name="pref_accept_files">Accepter les fichiers</string>
@@ -107,6 +108,7 @@
<string name="pref_never_send_crash_summary">En envoyant des logs vous aidez au développement de Conversations.</string>
<string name="pref_confirm_messages">Confirmation de lecture</string>
<string name="pref_confirm_messages_summary">Informer l\'expéditeur d\'un message de sa bonne réception.</string>
+ <string name="pref_ui_options">Options d\'affichage</string>
<string name="openpgp_error">Une erreur s\'est produite via OpenKeychain</string>
<string name="error_decrypting_file">Erreur d\'E/S lors du déchiffrement du fichier</string>
<string name="accept">Accepter</string>
@@ -145,6 +147,8 @@
<string name="mgmt_account_edit">Modifier le compte</string>
<string name="mgmt_account_delete">Supprimer</string>
<string name="mgmt_account_disable">Désactiver temporairement</string>
+ <string name="mgmt_account_publish_avatar">Publier un avatar</string>
+ <string name="mgmt_account_publish_pgp">Publier la clef publique OpenPGP</string>
<string name="mgmt_account_enable">Activer</string>
<string name="mgmt_account_are_you_sure">Êtes-vous sûr?</string>
<string name="mgmt_account_delete_confirm_text">En supprimant votre compte, votre historique de conversations sera perdu!</string>
@@ -169,6 +173,9 @@
<string name="muc_details_other_members">Autres membres</string>
<string name="server_info_carbon_messages">Copies carbone</string>
<string name="server_info_stream_management">Gestion des flux</string>
+ <string name="server_info_pep">XEP-0163: PEP (Avatars)</string>
+ <string name="server_info_available">disponible</string>
+ <string name="server_info_unavailable">indisponible</string>
<string name="missing_public_keys">Aucune annonce de clef publique</string>
<string name="last_seen_now">en ligne à l\'instant</string>
<string name="last_seen_min">en ligne il y a 1 minute</string>
@@ -207,6 +214,60 @@
<string name="contact_added_you">Votre correspondant vous a ajouté dans sa liste de contacts</string>
<string name="add_back">Ajouter également</string>
<string name="contact_has_read_up_to_this_point">%s a lu les messages précédents.</string>
- <string name="pref_ui_options">Options d\'affichage</string>
+ <string name="publish">Publier</string>
+ <string name="touch_to_choose_picture">Toucher l\'avatar pour choisir une image depuis la galerie.</string>
+ <string name="publish_avatar_explanation">Nota Bene: Les personnes ayant activé les mises jour de présence verront cette image.</string>
+ <string name="publishing">Mise à jour&#8230;</string>
+ <string name="error_publish_avatar_server_reject">Le serveur a rejeté votre envoi d\'image</string>
+ <string name="error_publish_avatar_converting">Une erreur s\'est produite pendant la conversion de votre image.</string>
+ <string name="error_saving_avatar">Impossible de stocker l\'image sur le disque</string>
+ <string name="or_long_press_for_default">(Un appui long réinitialise le paramètre par defaut)</string>
+ <string name="error_publish_avatar_no_server_support">Votre serveur n\'autorise pas l\'envoi d\'avatars</string>
+ <string name="private_message">chuchoté</string>
+ <string name="private_message_to">pour %s</string>
+ <string name="send_private_message_to">Envoyer un message privé à %s</string>
+ <string name="connect">Se connecter</string>
+ <string name="account_already_exists">Ce compte existe déjà</string>
+ <string name="next">suivant</string>
+ <string name="server_info_session_established">Session établie</string>
+ <string name="additional_information">Informations supplémentaires</string>
+ <string name="skip">Passer</string>
+ <string name="disable_notifications"Désactiver les notifications</string>
+ <string name="disable_notifications_for_this_conversation">Désactiver les notifications pour cette conversation</string>
+ <string name="notifications_disabled">Notifications are Désactivées</string>
+ <string name="enable">Activer</string>
+ <string name="conference_requires_password">La conférence necessite un mot de passe</string>
+ <string name="enter_password">Entrer le mot de passe</string>
+ <string name="missing_presence_updates">Mise à jour de présence non connue</string>
+ <string name="request_presence_updates">Merci de demander à votre contact de fournir les mises à jour de présence.\n\n<small>Cela permettra de savoir quel matériel utilise votre contact.</small></string>
+ <string name="request_now">Demander maintenant</string>
+ <string name="delete_fingerprint">Supprimer l\'empreinte</string>
+ <string name="sure_delete_fingerprint">Etes-vous sûr de vouloir supprimer l\'empreinte?</string>
+ <string name="ignore">Ignorer</string>
+ <string name="without_mutual_presence_updates"><b>Attention:</b> Ceci peut poser problème si l\'un des deux correspondants n\'a pas activé les mises à jour de présence.\n\n<small>Go to contact details to verify your presence subscriptions.</small></string>
+ <string name="pref_encryption_settings">Paramètres de chiffrement</string>
+ <string name="pref_force_encryption">Forcer le chiffrement de bout en bout</string>
+ <string name="pref_force_encryption_summary">Toujours envoyer des messages chiffrés (sauf pour les conférences)</string>
+ <string name="pref_dont_save_encrypted">Ne pas sauvegarder les messages chiffrés</string>
+ <string name="pref_dont_save_encrypted_summary">Attention: Celà peut mener à une perte de messages</string>
+ <string name="pref_expert_options">Options avancées</string>
+ <string name="pref_expert_options_summary">A utiliser avec précautions</string>
+ <string name="pref_use_larger_font">Augmenter la taille du texte</string>
+ <string name="pref_use_larger_font_summary">Augmenter la taille du texte partout dans l\'application</string>
+ <string name="pref_use_send_button_to_indicate_status">Le bouton Envoyer permet d\'indiquer le statut</string>
+ <string name="pref_use_indicate_received">Accusé de reception</string>
+ <string name="pref_use_indicate_received_summary">Les messages recus seront marqués d\'une coche verte si disponible</string>
+ <string name="pref_use_send_button_to_indicate_status_summary">Adapter la couleur du bouton Envoyer pour indiquer le statut</string>
+ <string name="pref_expert_options_other">Autres</string>
+ <string name="pref_conference_name">Nom de la conférence </string>
+ <string name="pref_conference_name_summary">Identifier la conférence par son nom plutot que par son JID</string>
+ <string name="toast_message_otr_fingerprint">Empreinte OTR copiée dans le presse-papier!</string>
+ <string name="conference_banned">Vous êtes interdit de cette conférence</string>
+ <string name="conference_members_only">Cette conférence est réservée aux membres</string>
+ <string name="conference_kicked">Vous avez été éjecté de cette conférence</string>
+ <string name="using_account">utiliser le compte %s</string>
+ <string name="checking_image">Vérification de l\'image</string>
+ <string name="image_file_deleted">L\'image a été suprimée</string>
+ <string name="not_connected_try_again">Vous n\'êtes pas connecté. Merci de retenter plus tard.</string>
-</resources> \ No newline at end of file
+</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 18eec00a..b08b793e 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -268,5 +268,6 @@
<string name="using_account">using account %s</string>
<string name="checking_image">Checking image on HTTP host</string>
<string name="image_file_deleted">The image file has been deleted</string>
+ <string name="not_connected_try_again">You are not connected. Try again later</string>
</resources>
diff --git a/src/eu/siacs/conversations/Config.java b/src/eu/siacs/conversations/Config.java
index a11e1763..1725eca6 100644
--- a/src/eu/siacs/conversations/Config.java
+++ b/src/eu/siacs/conversations/Config.java
@@ -10,7 +10,7 @@ public final class Config {
public static final int PING_MIN_INTERVAL = 30;
public static final int PING_TIMEOUT = 10;
public static final int CONNECT_TIMEOUT = 90;
- public static final int CARBON_GRACE_PERIOD = 120;
+ public static final int CARBON_GRACE_PERIOD = 60;
public static final int AVATAR_SIZE = 192;
public static final Bitmap.CompressFormat AVATAR_FORMAT = Bitmap.CompressFormat.WEBP;
diff --git a/src/eu/siacs/conversations/entities/Account.java b/src/eu/siacs/conversations/entities/Account.java
index 9b1cbcab..ff509ba1 100644
--- a/src/eu/siacs/conversations/entities/Account.java
+++ b/src/eu/siacs/conversations/entities/Account.java
@@ -11,6 +11,7 @@ import net.java.otr4j.crypto.OtrCryptoException;
import org.json.JSONException;
import org.json.JSONObject;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
import eu.siacs.conversations.crypto.OtrEngine;
import eu.siacs.conversations.persistance.FileBackend;
@@ -21,6 +22,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
+import android.os.SystemClock;
public class Account extends AbstractEntity {
@@ -64,16 +66,14 @@ public class Account extends AbstractEntity {
protected boolean online = false;
- transient OtrEngine otrEngine = null;
- transient XmppConnection xmppConnection = null;
- transient protected Presences presences = new Presences();
-
+ private OtrEngine otrEngine = null;
+ private XmppConnection xmppConnection = null;
+ private Presences presences = new Presences();
+ private long mEndGracePeriod = 0L;
private String otrFingerprint;
-
private Roster roster = null;
-
+
private List<Bookmark> bookmarks = new CopyOnWriteArrayList<Bookmark>();
-
public List<Conversation> pendingConferenceJoins = new CopyOnWriteArrayList<Conversation>();
public List<Conversation> pendingConferenceLeaves = new CopyOnWriteArrayList<Conversation>();
@@ -401,4 +401,17 @@ public class Account extends AbstractEntity {
return R.string.account_status_unknown;
}
}
+
+ public void activateGracePeriod() {
+ this.mEndGracePeriod = SystemClock.elapsedRealtime()
+ + (Config.CARBON_GRACE_PERIOD * 1000);
+ }
+
+ public void deactivateGracePeriod() {
+ this.mEndGracePeriod = 0L;
+ }
+
+ public boolean inGracePeriod() {
+ return SystemClock.elapsedRealtime() < this.mEndGracePeriod;
+ }
}
diff --git a/src/eu/siacs/conversations/entities/Conversation.java b/src/eu/siacs/conversations/entities/Conversation.java
index 5f204ec2..c984933f 100644
--- a/src/eu/siacs/conversations/entities/Conversation.java
+++ b/src/eu/siacs/conversations/entities/Conversation.java
@@ -72,8 +72,6 @@ public class Conversation extends AbstractEntity {
private byte[] symmetricKey;
- private boolean otrSessionNeedsStarting = false;
-
private Bookmark bookmark;
public Conversation(String name, Account account, String contactJid,
@@ -264,10 +262,7 @@ public class Conversation extends AbstractEntity {
try {
if (sendStart) {
this.otrSession.startSession();
- this.otrSessionNeedsStarting = false;
return this.otrSession;
- } else {
- this.otrSessionNeedsStarting = true;
}
return this.otrSession;
} catch (OtrException e) {
@@ -283,12 +278,12 @@ public class Conversation extends AbstractEntity {
public void resetOtrSession() {
this.otrFingerprint = null;
- this.otrSessionNeedsStarting = false;
this.otrSession = null;
}
public void startOtrIfNeeded() {
- if (this.otrSession != null && this.otrSessionNeedsStarting) {
+ if (this.otrSession != null
+ && this.otrSession.getSessionStatus() != SessionStatus.ENCRYPTED) {
try {
this.otrSession.startSession();
} catch (OtrException e) {
@@ -297,18 +292,23 @@ public class Conversation extends AbstractEntity {
}
}
- public void endOtrIfNeeded() {
+ public boolean endOtrIfNeeded() {
if (this.otrSession != null) {
if (this.otrSession.getSessionStatus() == SessionStatus.ENCRYPTED) {
try {
this.otrSession.endSession();
this.resetOtrSession();
+ return true;
} catch (OtrException e) {
this.resetOtrSession();
+ return false;
}
} else {
this.resetOtrSession();
+ return false;
}
+ } else {
+ return false;
}
}
diff --git a/src/eu/siacs/conversations/entities/Downloadable.java b/src/eu/siacs/conversations/entities/Downloadable.java
index c8ca599f..36584ab0 100644
--- a/src/eu/siacs/conversations/entities/Downloadable.java
+++ b/src/eu/siacs/conversations/entities/Downloadable.java
@@ -12,7 +12,7 @@ public interface Downloadable {
public static final int STATUS_DOWNLOADING = 0x204;
public static final int STATUS_DELETED = 0x205;
- public void start();
+ public boolean start();
public int getStatus();
diff --git a/src/eu/siacs/conversations/http/HttpConnection.java b/src/eu/siacs/conversations/http/HttpConnection.java
index 34036412..0254dc2f 100644
--- a/src/eu/siacs/conversations/http/HttpConnection.java
+++ b/src/eu/siacs/conversations/http/HttpConnection.java
@@ -12,7 +12,9 @@ import javax.net.ssl.HttpsURLConnection;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.net.Uri;
+import android.util.Log;
+import eu.siacs.conversations.Config;
import eu.siacs.conversations.entities.Downloadable;
import eu.siacs.conversations.entities.DownloadableFile;
import eu.siacs.conversations.entities.Message;
@@ -35,9 +37,14 @@ public class HttpConnection implements Downloadable {
}
@Override
- public void start() {
- changeStatus(STATUS_DOWNLOADING);
- new Thread(new FileDownloader()).start();
+ public boolean start() {
+ if (mXmppConnectionService.hasInternetConnection()) {
+ changeStatus(STATUS_DOWNLOADING);
+ new Thread(new FileDownloader()).start();
+ return true;
+ } else {
+ return false;
+ }
}
public void init(Message message) {
@@ -62,8 +69,7 @@ public class HttpConnection implements Downloadable {
public void cancel() {
mHttpConnectionManager.finishConnection(this);
message.setDownloadable(null);
- message.setBody(mUrl.toString());
- mXmppConnectionService.updateMessage(message);
+ mXmppConnectionService.updateConversationUi();
}
private void finish() {
@@ -91,7 +97,6 @@ public class HttpConnection implements Downloadable {
return;
}
file.setExpectedSize(size);
- message.setType(Message.TYPE_IMAGE);
if (size <= mHttpConnectionManager.getAutoAcceptFileSize() && mAutostart) {
start();
} else {
@@ -159,6 +164,7 @@ public class HttpConnection implements Downloadable {
int imageWidth = options.outWidth;
message.setBody(mUrl.toString() + "," + file.getSize() + ','
+ imageWidth + ',' + imageHeight);
+ message.setType(Message.TYPE_IMAGE);
mXmppConnectionService.updateMessage(message);
}
diff --git a/src/eu/siacs/conversations/http/HttpConnectionManager.java b/src/eu/siacs/conversations/http/HttpConnectionManager.java
index ff71d45c..9a2a2405 100644
--- a/src/eu/siacs/conversations/http/HttpConnectionManager.java
+++ b/src/eu/siacs/conversations/http/HttpConnectionManager.java
@@ -1,11 +1,9 @@
package eu.siacs.conversations.http;
-import java.net.URL;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import eu.siacs.conversations.entities.Message;
-import eu.siacs.conversations.entities.Message.ImageParams;
import eu.siacs.conversations.services.AbstractConnectionManager;
import eu.siacs.conversations.services.XmppConnectionService;
diff --git a/src/eu/siacs/conversations/parser/MessageParser.java b/src/eu/siacs/conversations/parser/MessageParser.java
index 486dd389..4090ed39 100644
--- a/src/eu/siacs/conversations/parser/MessageParser.java
+++ b/src/eu/siacs/conversations/parser/MessageParser.java
@@ -417,8 +417,7 @@ public class MessageParser extends AbstractParser implements
message = this.parseCarbonMessage(packet, account);
if (message != null) {
if (message.getStatus() == Message.STATUS_SEND) {
- mXmppConnectionService.getNotificationService()
- .activateGracePeriod();
+ account.activateGracePeriod();
notify = false;
mXmppConnectionService.markRead(
message.getConversation(), false);
@@ -440,8 +439,7 @@ public class MessageParser extends AbstractParser implements
} else {
mXmppConnectionService.markRead(message.getConversation(),
false);
- mXmppConnectionService.getNotificationService()
- .activateGracePeriod();
+ account.activateGracePeriod();
notify = false;
}
}
diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java
index 2c3a7dbc..d54ddca0 100644
--- a/src/eu/siacs/conversations/parser/PresenceParser.java
+++ b/src/eu/siacs/conversations/parser/PresenceParser.java
@@ -58,8 +58,7 @@ public class PresenceParser extends AbstractParser implements
Presences.parseShow(packet.findChild("show")));
} else if (type.equals("unavailable")) {
account.removePresence(fromParts[1]);
- mXmppConnectionService.getNotificationService()
- .deactivateGracePeriod();
+ account.deactivateGracePeriod();
}
}
} else {
diff --git a/src/eu/siacs/conversations/services/NotificationService.java b/src/eu/siacs/conversations/services/NotificationService.java
index e65085fb..0b30e58e 100644
--- a/src/eu/siacs/conversations/services/NotificationService.java
+++ b/src/eu/siacs/conversations/services/NotificationService.java
@@ -13,13 +13,12 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.PowerManager;
-import android.os.SystemClock;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.TaskStackBuilder;
import android.text.Html;
-import eu.siacs.conversations.Config;
import eu.siacs.conversations.R;
+import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.ui.ConversationActivity;
@@ -34,9 +33,7 @@ public class NotificationService {
public int NOTIFICATION_ID = 0x2342;
private Conversation mOpenConversation;
private boolean mIsInForeground;
-
- private long mEndGracePeriod = 0L;
-
+
public NotificationService(XmppConnectionService service) {
this.mXmppConnectionService = service;
this.mNotificationManager = (NotificationManager) service
@@ -62,8 +59,9 @@ public class NotificationService {
notifications.put(conversationUuid, mList);
}
}
+ Account account = message.getConversation().getAccount();
updateNotification((!(this.mIsInForeground && this.mOpenConversation == null) || !isScreenOn)
- && !inGracePeriod());
+ && !account.inGracePeriod());
}
public void clear() {
@@ -170,9 +168,7 @@ public class NotificationService {
}
}
mBuilder.setDeleteIntent(createDeleteIntent());
- if (!inGracePeriod()) {
- mBuilder.setLights(0xffffffff, 2000, 4000);
- }
+ mBuilder.setLights(0xffffffff, 2000, 4000);
Notification notification = mBuilder.build();
mNotificationManager.notify(NOTIFICATION_ID, notification);
}
@@ -231,17 +227,4 @@ public class NotificationService {
public void setIsInForeground(boolean foreground) {
this.mIsInForeground = foreground;
}
-
- public void activateGracePeriod() {
- this.mEndGracePeriod = SystemClock.elapsedRealtime()
- + (Config.CARBON_GRACE_PERIOD * 1000);
- }
-
- public void deactivateGracePeriod() {
- this.mEndGracePeriod = 0L;
- }
-
- private boolean inGracePeriod() {
- return SystemClock.elapsedRealtime() < this.mEndGracePeriod;
- }
}
diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java
index 9a540df0..36ea350b 100644
--- a/src/eu/siacs/conversations/services/XmppConnectionService.java
+++ b/src/eu/siacs/conversations/services/XmppConnectionService.java
@@ -346,15 +346,10 @@ public class XmppConnectionService extends Service {
}
}
this.wakeLock.acquire();
- ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
- .getSystemService(Context.CONNECTIVITY_SERVICE);
- NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
- boolean isConnected = activeNetwork != null
- && activeNetwork.isConnected();
-
+
for (Account account : accounts) {
if (!account.isOptionSet(Account.OPTION_DISABLED)) {
- if (!isConnected) {
+ if (!hasInternetConnection()) {
account.setStatus(Account.STATUS_NO_INTERNET);
if (statusListener != null) {
statusListener.onStatusChanged(account);
@@ -412,6 +407,13 @@ public class XmppConnectionService extends Service {
}
return START_STICKY;
}
+
+ public boolean hasInternetConnection() {
+ ConnectivityManager cm = (ConnectivityManager) getApplicationContext()
+ .getSystemService(Context.CONNECTIVITY_SERVICE);
+ NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
+ return activeNetwork != null && activeNetwork.isConnected();
+ }
@SuppressLint("TrulyRandom")
@Override
@@ -529,6 +531,7 @@ public class XmppConnectionService extends Service {
synchronized public void sendMessage(Message message) {
Account account = message.getConversation().getAccount();
+ account.deactivateGracePeriod();
Conversation conv = message.getConversation();
MessagePacket packet = null;
boolean saveInDb = true;
@@ -1019,7 +1022,6 @@ public class XmppConnectionService extends Service {
return;
}
synchronized (this.convChangedListenerCount) {
- this.mNotificationService.deactivateGracePeriod();
if (checkListeners()) {
switchToForeground();
}
@@ -1049,7 +1051,6 @@ public class XmppConnectionService extends Service {
return;
}
synchronized (this.accountChangedListenerCount) {
- this.mNotificationService.deactivateGracePeriod();
if (checkListeners()) {
switchToForeground();
}
@@ -1077,7 +1078,6 @@ public class XmppConnectionService extends Service {
return;
}
synchronized (this.rosterChangedListenerCount) {
- this.mNotificationService.deactivateGracePeriod();
if (checkListeners()) {
switchToForeground();
}
@@ -1110,11 +1110,10 @@ public class XmppConnectionService extends Service {
XmppConnection connection = account.getXmppConnection();
if (connection != null && connection.getFeatures().csi()) {
connection.sendActive();
- Log.d(Config.LOGTAG, account.getJid()
- + " sending csi//active");
}
}
}
+ Log.d(Config.LOGTAG,"app switched into foreground");
}
private void switchToBackground() {
@@ -1123,11 +1122,11 @@ public class XmppConnectionService extends Service {
XmppConnection connection = account.getXmppConnection();
if (connection != null && connection.getFeatures().csi()) {
connection.sendInactive();
- Log.d(Config.LOGTAG, account.getJid()
- + " sending csi//inactive");
}
}
}
+ this.mNotificationService.setIsInForeground(false);
+ Log.d(Config.LOGTAG,"app switched into background");
}
private boolean isScreenOn() {
@@ -1271,7 +1270,7 @@ public class XmppConnectionService extends Service {
conversation.getMucOptions().setOffline();
conversation.deregisterWithBookmark();
Log.d(Config.LOGTAG, conversation.getAccount().getJid()
- + " leaving muc " + conversation.getContactJid());
+ + ": leaving muc " + conversation.getContactJid());
} else {
account.pendingConferenceLeaves.add(conversation);
}
@@ -1288,7 +1287,9 @@ public class XmppConnectionService extends Service {
if (conversation.getMode() == Conversation.MODE_MULTI) {
leaveMuc(conversation);
} else {
- conversation.endOtrIfNeeded();
+ if (conversation.endOtrIfNeeded()) {
+ Log.d(Config.LOGTAG,account.getJid()+": ended otr session with "+conversation.getContactJid());
+ }
}
}
}
@@ -1874,8 +1875,8 @@ public class XmppConnectionService extends Service {
private class DeletedDownloadable implements Downloadable {
@Override
- public void start() {
- return;
+ public boolean start() {
+ return false;
}
@Override
diff --git a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
index 24a824b3..6b2a0094 100644
--- a/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
+++ b/src/eu/siacs/conversations/ui/adapter/MessageAdapter.java
@@ -102,7 +102,8 @@ public class MessageAdapter extends ArrayAdapter<Message> {
}
boolean multiReceived = message.getConversation().getMode() == Conversation.MODE_MULTI
&& message.getMergedStatus() <= Message.STATUS_RECEIVED;
- if (message.getType() == Message.TYPE_IMAGE) {
+ if (message.getType() == Message.TYPE_IMAGE
+ || message.getDownloadable() != null) {
ImageParams params = message.getImageParams();
if (params.size != 0) {
filesize = params.size / 1024 + " KB";
@@ -262,6 +263,20 @@ public class MessageAdapter extends ArrayAdapter<Message> {
viewHolder.messageBody.setTextIsSelectable(true);
}
+ private void displayDownloadableMessage(ViewHolder viewHolder,
+ final Message message) {
+ viewHolder.image.setVisibility(View.GONE);
+ viewHolder.messageBody.setVisibility(View.GONE);
+ viewHolder.download_button.setVisibility(View.VISIBLE);
+ viewHolder.download_button.setOnClickListener(new OnClickListener() {
+
+ @Override
+ public void onClick(View v) {
+ startDonwloadable(message);
+ }
+ });
+ }
+
private void displayImageMessage(ViewHolder viewHolder,
final Message message) {
if (viewHolder.download_button != null) {
@@ -474,20 +489,11 @@ public class MessageAdapter extends ArrayAdapter<Message> {
} else if (d != null
&& d.getStatus() == Downloadable.STATUS_CHECKING) {
displayInfoMessage(viewHolder, R.string.checking_image);
- } else if (d != null && d.getStatus() == Downloadable.STATUS_DELETED) {
+ } else if (d != null
+ && d.getStatus() == Downloadable.STATUS_DELETED) {
displayInfoMessage(viewHolder, R.string.image_file_deleted);
} else if (d != null && d.getStatus() == Downloadable.STATUS_OFFER) {
- viewHolder.image.setVisibility(View.GONE);
- viewHolder.messageBody.setVisibility(View.GONE);
- viewHolder.download_button.setVisibility(View.VISIBLE);
- viewHolder.download_button
- .setOnClickListener(new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- startDonwloadable(item);
- }
- });
+ displayDownloadableMessage(viewHolder, item);
} else if ((item.getEncryption() == Message.ENCRYPTION_DECRYPTED)
|| (item.getEncryption() == Message.ENCRYPTION_NONE)
|| (item.getEncryption() == Message.ENCRYPTION_OTR)) {
@@ -525,13 +531,13 @@ public class MessageAdapter extends ArrayAdapter<Message> {
return view;
}
- public boolean startDonwloadable(Message message) {
+ public void startDonwloadable(Message message) {
Downloadable downloadable = message.getDownloadable();
if (downloadable != null) {
- downloadable.start();
- return true;
- } else {
- return false;
+ if (!downloadable.start()) {
+ Toast.makeText(activity, R.string.not_connected_try_again,
+ Toast.LENGTH_SHORT).show();
+ }
}
}
diff --git a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
index bfc3c18c..e7e1a33d 100644
--- a/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
+++ b/src/eu/siacs/conversations/xmpp/jingle/JingleConnection.java
@@ -875,17 +875,20 @@ public class JingleConnection implements Downloadable {
return this.transport;
}
- public void start() {
- if (mJingleStatus == JINGLE_STATUS_INITIATED) {
- new Thread(new Runnable() {
-
- @Override
- public void run() {
- sendAccept();
- }
- }).start();
+ public boolean start() {
+ if (account.getStatus() == Account.STATUS_ONLINE) {
+ if (mJingleStatus == JINGLE_STATUS_INITIATED) {
+ new Thread(new Runnable() {
+
+ @Override
+ public void run() {
+ sendAccept();
+ }
+ }).start();
+ }
+ return true;
} else {
- Log.d(Config.LOGTAG, "status (" + mJingleStatus + ") was not ok");
+ return false;
}
}