# HG changeset patch
# User nikita@nikita-laptop
# Date 1266535903 -3600
# Node ID 9ca0e29b386f3032901d5e5e901fcb2e9fec7bd3
# Parent 803a4f1dc590c67dcaba8dede3570c6face0ef21# Parent b8d5e0378bcb2a33ba73ccf112db2aacc2f03931
merge
diff -r b8d5e0378bcb -r 9ca0e29b386f .classpath
--- a/.classpath Thu Feb 18 20:02:01 2010 +0100
+++ b/.classpath Fri Feb 19 00:31:43 2010 +0100
@@ -1,9 +1,8 @@
-
-
-
+
+
diff -r b8d5e0378bcb -r 9ca0e29b386f AndroidManifest.xml
--- a/AndroidManifest.xml Thu Feb 18 20:02:01 2010 +0100
+++ b/AndroidManifest.xml Fri Feb 19 00:31:43 2010 +0100
@@ -76,6 +76,8 @@
android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
+
+
diff -r b8d5e0378bcb -r 9ca0e29b386f res/layout/preferences.xml
--- a/res/layout/preferences.xml Thu Feb 18 20:02:01 2010 +0100
+++ b/res/layout/preferences.xml Fri Feb 19 00:31:43 2010 +0100
@@ -10,6 +10,13 @@
+
+
diff -r b8d5e0378bcb -r 9ca0e29b386f res/values-fr/strings.xml
--- a/res/values-fr/strings.xml Thu Feb 18 20:02:01 2010 +0100
+++ b/res/values-fr/strings.xml Fri Feb 19 00:31:43 2010 +0100
@@ -83,8 +83,6 @@
Saisissez votre identifiant de connexion
Saisissez votre mot de passe
- Utilisation de Gmail
- Cochez cette option si vous souhaitez utiliser votre compte Gmail
Proxy
Utiliser un proxy
Connectez vous à travers un serveur proxy
@@ -104,6 +102,39 @@
Priorité
Saisissez la resource à partir de laquelle vous vous connectez
Saisissez la priorité de votre client
+ Liste d\'ami(e)s
+ Une série d\'options d\'affichage de votre liste
+ d\'ami(e)s
+ Cachez les groupes
+ Cochez cette option pour cacher les groupes
+ Cachez les contacts
+ Cochez cette option pour cacher les contacts déconnectés
+ Nom d\'utilisateur
+ beem@beem-project.com
+ Mot de passe
+ Serveur
+ Port
+ Comportement du service
+ Une série d\'options pour les utilisateurs avertis
+ Serveur
+ example.com
+ Port
+ Default: 5222
+ SSL/TLS obligatoire
+ Délai de reconnexion
+ Paramètrez un serveur proxy
+ Utiliser un proxy
+ Choisir un type de proxy
+ Serveur
+ Port
+ Default: 1080
+ Nom d\'utilisateur
+ Mot de passe
+ Activer l'absence automatique
+ Change votre status en Absent automatiquement quand l\'écran du telephone s\'éteind
+ Message d'asbence
+ Votre Message d'absence
+ Je suis absent car mon ecran est éteind
Inscription acceptée
@@ -199,44 +230,6 @@
edit_settings_tab_proxy
Proxy
-
- Liste d\'ami(e)s
- Une série d\'options d\'affichage de votre liste
- d\'ami(e)s
-
- Cachez les groupes
- Cochez cette option pour cacher les groupes
- Cachez les contacts
- Cochez cette option pour cacher les contacts déconnectés
-
-
- Nom d\'utilisateur
- beem@beem-project.com
- Mot de passe
- Serveur
- Port
-
-
- Comportement du service
- Une série d\'options pour les utilisateurs avertis
- Serveur
- example.com
- Port
- Default: 5222
- SSL/TLS obligatoire
- Délai de reconnexion
-
-
-
- Paramètrez un serveur proxy
- Utiliser un proxy
- Choisir un type de proxy
- Serveur
- Port
- Default: 1080
- Nom d\'utilisateur
- Mot de passe
-
diff -r b8d5e0378bcb -r 9ca0e29b386f res/values/strings.xml
--- a/res/values/strings.xml Thu Feb 18 20:02:01 2010 +0100
+++ b/res/values/strings.xml Fri Feb 19 00:31:43 2010 +0100
@@ -71,7 +71,6 @@
My status
My personal message
Open contact list
-
Add new contact
Beem Project
@@ -83,8 +82,6 @@
Edit your username
Edit your password
- Using Gmail
- Use my Gmail account
Proxy
Use a proxy server
Login through a proxy server
@@ -104,6 +101,40 @@
Priority
Set the XMPP resource of your client
Set the priority of your client
+ Buddy list
+ A set of display options for your buddy list
+
+ Hide groups
+ Check this option to hide groups
+ Hide buddies
+ Check this option to hide unconnected buddies
+
+ Username
+ beem@beem-project.com
+ Password
+ Server
+ Port
+ Service behaviour
+ A set of options for advanced users
+ Address
+ example.com
+ Port
+ Require SSL/TLS
+ Reconnection delay
+ Default: 5222
+ Settings for proxy usage
+ Connect using a proxy
+ Choose a type of proxy
+ Server
+ Port
+ Default: 1080
+ Username
+ Password
+ Enable Auto-away
+ Change status to Away when the screen is turned off
+ Away message
+ The away message that will be displayed
+ I'm away, my cellphone screen is off
Subscription accepted
@@ -190,42 +221,10 @@
Proxy
- Buddy list
- A set of display options for your buddy list
-
-
- Hide groups
- Check this option to hide groups
- Hide buddies
- Check this option to hide unconnected buddies
-
-
-
- Username
- beem@beem-project.com
- Password
- Server
- Port
-
- Service behaviour
- A set of options for advanced users
- Address
- example.com
- Port
- Require SSL/TLS
- Reconnection delay
- Default: 5222
+
-
- Settings for proxy usage
- Connect using a proxy
- Choose a type of proxy
- Server
- Port
- Default: 1080
- Username
- Password
+
Create an account - Instructions
diff -r b8d5e0378bcb -r 9ca0e29b386f src/com/beem/project/beem/BeemService.java
--- a/src/com/beem/project/beem/BeemService.java Thu Feb 18 20:02:01 2010 +0100
+++ b/src/com/beem/project/beem/BeemService.java Fri Feb 19 00:31:43 2010 +0100
@@ -40,7 +40,7 @@
Flavien Astraud, November 26, 2009
Head of the EIP Laboratory.
-*/
+ */
package com.beem.project.beem;
import org.jivesoftware.smack.ConnectionConfiguration;
@@ -57,6 +57,8 @@
import android.app.Notification;
import android.app.NotificationManager;
import android.app.Service;
+import android.content.BroadcastReceiver;
+import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
@@ -72,6 +74,7 @@
import com.beem.project.beem.service.aidl.IXmppFacade;
import com.beem.project.beem.utils.BeemBroadcastReceiver;
import com.beem.project.beem.utils.BeemConnectivity;
+import com.beem.project.beem.utils.Status;
/**
* This class is for the Beem service. The connection to the xmpp server will be made asynchronously when the service
@@ -85,7 +88,7 @@
private static final String TAG = "BeemService";
private static final int DEFAULT_XMPP_PORT = 5222;
- private static final String COMMAND_NAMESPACE = "http://jabber.org/protocol/commands";
+ //private static final String COMMAND_NAMESPACE = "http://jabber.org/protocol/commands";
private NotificationManager mNotificationManager;
private XmppConnectionAdapter mConnection;
@@ -101,6 +104,10 @@
private IXmppFacade.Stub mBind;
private BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver();
+ private BeemServiceBroadcastReceiver mOnOffReceiver = new BeemServiceBroadcastReceiver();
+ private BeemServicePreferenceListener mPreferenceListener = new BeemServicePreferenceListener();
+
+ private boolean mOnOffReceiverIsRegistered;
/**
* Constructor.
@@ -109,10 +116,9 @@
}
/**
- * Initialise la configuration de la connexion.
+ * Initialize the connection.
*/
private void initConnectionConfig() {
- //java.security.Security.addProvider(new com.sun.security.sasl.Provider());
mUseProxy = mSettings.getBoolean("settings_key_proxy_use", false);
if (mUseProxy) {
String stype = mSettings.getString("settings_key_proxy_type", "HTTP");
@@ -160,6 +166,8 @@
return true;
}
+
+
/**
* {@inheritDoc}
*/
@@ -168,6 +176,12 @@
super.onCreate();
registerReceiver(mReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
+ mSettings.registerOnSharedPreferenceChangeListener(mPreferenceListener);
+ if (mSettings.getBoolean("settings_away_chk", false)) {
+ mOnOffReceiverIsRegistered = true;
+ registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
+ registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
+ }
String tmpJid = mSettings.getString("settings_key_account_username", "");
mLogin = StringUtils.parseName(tmpJid);
mPassword = mSettings.getString("settings_key_account_password", "");
@@ -206,6 +220,9 @@
Log.d("Service", "onDestroy");
mNotificationManager.cancelAll();
unregisterReceiver(mReceiver);
+ mSettings.unregisterOnSharedPreferenceChangeListener(mPreferenceListener);
+ if (mOnOffReceiverIsRegistered)
+ unregisterReceiver(mOnOffReceiver);
if (mConnection.isAuthentificated() && BeemConnectivity.isConnected(this))
mConnection.disconnect();
Log.d(TAG, "ONDESTROY");
@@ -243,7 +260,7 @@
}
/**
- * Reset the status to online after a deconnection.
+ * Reset the status to online after a disconnect.
*/
public void resetStatus() {
Editor edit = mSettings.edit();
@@ -364,5 +381,42 @@
new AdHocCommandDataProvider.SessionExpiredError());
*/
}
+
+ private class BeemServicePreferenceListener implements SharedPreferences.OnSharedPreferenceChangeListener {
+ @Override
+ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+ if (key.equals("settings_away_chk")) {
+ if (sharedPreferences.getBoolean("settings_away_chk", false)) {
+ mOnOffReceiverIsRegistered = true;
+ registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_OFF));
+ registerReceiver(mOnOffReceiver, new IntentFilter(Intent.ACTION_SCREEN_ON));
+ } else {
+ mOnOffReceiverIsRegistered = false;
+ unregisterReceiver(mOnOffReceiver);
+ }
+ }
+ }
+ }
+
+ private class BeemServiceBroadcastReceiver extends BroadcastReceiver {
+
+ private String mOldStatus;
+ private int mOldMode;
+
+ public BeemServiceBroadcastReceiver() {
+ }
+
+ @Override
+ public void onReceive(final Context context, final Intent intent) {
+ String intentAction = intent.getAction();
+ if (intentAction.equals(Intent.ACTION_SCREEN_OFF)) {
+ mOldMode = mConnection.getPreviousMode();
+ mOldStatus = mConnection.getPreviousStatus();
+ mConnection.changeStatus(Status.CONTACT_STATUS_AWAY, mSettings.getString("settings_away_message", "Away"));
+ } else if (intentAction.equals(Intent.ACTION_SCREEN_ON)) {
+ mConnection.changeStatus(mOldMode, mOldStatus);
+ }
+ }
+ }
}
diff -r b8d5e0378bcb -r 9ca0e29b386f src/com/beem/project/beem/service/XmppConnectionAdapter.java
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Feb 18 20:02:01 2010 +0100
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Fri Feb 19 00:31:43 2010 +0100
@@ -97,12 +97,16 @@
private String mErrorMsg;
private RosterAdapter mRoster;
private int mPreviousPriority;
+ private int mPreviousMode;
+ private String mPreviousStatus;
private PrivacyListManagerAdapter mPrivacyListManager;
private final BeemService mService;
private final RemoteCallbackList mRemoteConnListeners = new RemoteCallbackList();
private final SubscribePacketListener mSubscribePacketListener = new SubscribePacketListener();
private final ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter();
+
+
/**
* Constructor.
@@ -270,11 +274,16 @@
if (msg != null)
m = msg;
else
- m = "";
+ m = mPreviousStatus;
pres.setStatus(m);
+ mPreviousStatus = m;
Presence.Mode mode = Status.getPresenceModeFromStatus(status);
- if (mode != null)
+ if (mode != null) {
pres.setMode(mode);
+ mPreviousMode = status;
+ } else {
+ pres.setMode(Status.getPresenceModeFromStatus(mPreviousMode));
+ }
int p = priority;
if (priority < SMACK_PRIORITY_MIN)
p = SMACK_PRIORITY_MIN;
@@ -285,25 +294,21 @@
mAdaptee.sendPacket(pres);
updateNotification(m);
}
-
+
/**
* {@inheritDoc}
*/
@Override
public void changeStatus(int status, String msg) {
- Presence pres = new Presence(Presence.Type.available);
- String m;
- if (msg != null)
- m = msg;
- else
- m = "";
- pres.setStatus(m);
- Presence.Mode mode = Status.getPresenceModeFromStatus(status);
- if (mode != null)
- pres.setMode(mode);
- pres.setPriority(mPreviousPriority);
- mAdaptee.sendPacket(pres);
- updateNotification(msg);
+ changeStatusAndPriority(status, msg, mPreviousPriority);
+ }
+
+ public String getPreviousStatus() {
+ return mPreviousStatus;
+ }
+
+ public int getPreviousMode() {
+ return mPreviousMode;
}
/**
@@ -349,14 +354,6 @@
}
/**
- * Get the context of the adapter.
- * @return The context of the adapter
- */
- public BeemService getContext() {
- return mService;
- }
-
- /**
* {@inheritDoc}
*/
@Override
diff -r b8d5e0378bcb -r 9ca0e29b386f src/com/beem/project/beem/utils/BeemBroadcastReceiver.java
--- a/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Thu Feb 18 20:02:01 2010 +0100
+++ b/src/com/beem/project/beem/utils/BeemBroadcastReceiver.java Fri Feb 19 00:31:43 2010 +0100
@@ -51,6 +51,7 @@
import android.widget.Toast;
import com.beem.project.beem.BeemService;
+import com.beem.project.beem.R;
/**
* Manage broadcast disconnect intent.
@@ -83,6 +84,7 @@
}
} else if (intentAction.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
if (intent.getBooleanExtra(ConnectivityManager.EXTRA_NO_CONNECTIVITY, false)) {
+ Toast.makeText(context, context.getString(R.string.BeemBroadcastReceiverDisconnect), Toast.LENGTH_SHORT).show();
context.stopService(new Intent(context, BeemService.class));
}
}