Amelioration de la methode change status.
--- a/src/com/beem/project/beem/BeemApplication.java Tue Apr 14 16:56:20 2009 +0200
+++ b/src/com/beem/project/beem/BeemApplication.java Thu Apr 16 00:27:49 2009 +0200
@@ -25,6 +25,7 @@
import com.beem.project.beem.service.aidl.IBeemConnectionListener;
import com.beem.project.beem.service.aidl.IXmppConnection;
import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.Status;
/**
* The Beem application. This class has some methods utiliy needs by the activities.
@@ -216,7 +217,7 @@
public void connectionClosedOnError() throws RemoteException {
mBeemApp.mProgressDialog.setMessage("Connexion closed on error");
Log.e(TAG,"onnectionClosedOnError");
- // afficher une notification et reafficher le progress dialog
+ // TODO afficher une notification et reafficher le progress dialog
}
/**
@@ -226,7 +227,8 @@
public void onConnect() throws RemoteException {
// TODO Auto-generated method stub
mProgressDialog.dismiss();
- mFacade.changeStatus();
+ // TODO recuperer les informations de status dans les preferences
+ mFacade.changeStatus(Status.CONTACT_STATUS_AVAILABLE, null);
synchronized (mQueue) {
for (Message msg : mQueue) {
msg.sendToTarget();
--- a/src/com/beem/project/beem/service/BeemChatManager.java Tue Apr 14 16:56:20 2009 +0200
+++ b/src/com/beem/project/beem/service/BeemChatManager.java Thu Apr 16 00:27:49 2009 +0200
@@ -120,6 +120,7 @@
IChat newchat = getChat(chat);
if (!locally) {
mChats.put(chat.getParticipant(), newchat);
+ // TODO startActivity
}
final int n = mRemoteChatCreationListeners.beginBroadcast();
--- a/src/com/beem/project/beem/service/Contact.java Tue Apr 14 16:56:20 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java Thu Apr 16 00:27:49 2009 +0200
@@ -9,6 +9,8 @@
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.packet.Presence.Mode;
+import com.beem.project.beem.utils.Status;
+
import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;
@@ -19,36 +21,6 @@
*/
public class Contact implements Parcelable {
- /**
- * Status of a disconnected contact.
- */
- public static final int CONTACT_STATUS_DISCONNECT = 100;
-
- /**
- * Status of a unavailable (long away) contact.
- */
- public static final int CONTACT_STATUS_UNAVAILABLE = 200;
-
- /**
- * Status of a away contact.
- */
- public static final int CONTACT_STATUS_AWAY = 300;
-
- /**
- * Status of a busy contact.
- */
- public static final int CONTACT_STATUS_BUSY = 400;
-
- /**
- * Status of a available contact.
- */
- public static final int CONTACT_STATUS_AVAILABLE = 500;
-
- /**
- * Status of a available for chat contact.
- */
- public static final int CONTACT_STATUS_AVAILABLE_FOR_CHAT = 600;
-
private static final String TAG = "Contact";
private int mID;
@@ -86,7 +58,7 @@
*/
public Contact(final String jid) {
mJID = jid;
- mStatus = Contact.CONTACT_STATUS_DISCONNECT;
+ mStatus = Status.CONTACT_STATUS_DISCONNECT;
mRes = new ArrayList<String>();
mRes.add("none");
}
@@ -163,44 +135,7 @@
*/
public void setStatus(Presence presence) {
Log.i(TAG,"PRESENCE");
- if (presence.getType().equals(Presence.Type.unavailable)) {
- Log.d(TAG, "Presence pas dispo");
- mStatus = Contact.CONTACT_STATUS_DISCONNECT;
- } else {
- Log.d(TAG, "Presence OK");
- Mode mode = presence.getMode();
- if (mode == null) {
- mStatus = Contact.CONTACT_STATUS_AVAILABLE;
- }
- else {
- switch (mode) {
- case available:
- Log.d(TAG, "Available");
- mStatus = Contact.CONTACT_STATUS_AVAILABLE;
- break;
- case away:
- Log.d(TAG, "Away");
- mStatus = Contact.CONTACT_STATUS_AWAY;
- break;
- case chat:
- Log.d(TAG, "Chat");
- mStatus = Contact.CONTACT_STATUS_AVAILABLE_FOR_CHAT;
- break;
- case dnd:
- Log.d(TAG, "Dnd");
- mStatus = Contact.CONTACT_STATUS_BUSY;
- break;
- case xa:
- Log.d(TAG, "Xa");
- mStatus = Contact.CONTACT_STATUS_UNAVAILABLE;
- break;
- default:
- Log.d(TAG, "Status mode non gere");
- mStatus = Contact.CONTACT_STATUS_DISCONNECT;
- break;
- }
- }
- }
+ mStatus = Status.getStatusFromPresence(presence);
}
/**
--- a/src/com/beem/project/beem/service/XmppFacade.java Tue Apr 14 16:56:20 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppFacade.java Thu Apr 16 00:27:49 2009 +0200
@@ -1,9 +1,13 @@
package com.beem.project.beem.service;
+import org.jivesoftware.smack.packet.Presence;
+
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Intent;
+import android.graphics.Bitmap.CompressFormat;
import android.os.RemoteException;
+
import com.beem.project.beem.BeemService;
import com.beem.project.beem.service.aidl.IChatManager;
import com.beem.project.beem.service.aidl.IRoster;
@@ -16,7 +20,7 @@
*/
public class XmppFacade extends IXmppFacade.Stub {
- private IXmppConnection mConnexion;
+ private XmppConnectionAdapter mConnexion;
private BeemService mBeemService;
/**
@@ -24,7 +28,7 @@
* @param connection the connection use by the facade
* @param service the service which holds the facade
*/
- public XmppFacade(final IXmppConnection connection, final BeemService service) {
+ public XmppFacade(final XmppConnectionAdapter connection, final BeemService service) {
this.mConnexion = connection;
this.mBeemService = service;
}
@@ -80,9 +84,18 @@
/**
* {@inheritDoc}
*/
- public void changeStatus() {
+ @Override
+ public void changeStatus(int status, String msg) {
+ Presence pres = new Presence(Presence.Type.available);
+ if (msg != null)
+ pres.setStatus(msg);
+ Presence.Mode mode = com.beem.project.beem.utils.Status.getPresenceModeFromStatus(status);
+ if (mode != null)
+ pres.setMode(mode);
+ mConnexion.getAdaptee().sendPacket(pres);
+
Notification mStatusNotification;
- String text = "Salut les amirs !!!!";
+ String text = (msg == null ? "" : msg);
mStatusNotification = new Notification(com.beem.project.beem.R.drawable.logo, text, System.currentTimeMillis());
mStatusNotification.defaults = Notification.DEFAULT_ALL;
mStatusNotification.flags = Notification.FLAG_NO_CLEAR;
--- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Tue Apr 14 16:56:20 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Thu Apr 16 00:27:49 2009 +0200
@@ -6,19 +6,41 @@
interface IXmppFacade {
+ /**
+ * Get the XmppConnection of the facade.
+ */
IXmppConnection createConnection();
+ /**
+ * Get the roster of the user
+ */
IRoster getRoster();
+ /**
+ * Connect and login synchronously on the server.
+ */
void connectSync();
+ /**
+ * Connect and login asynchronously on the server.
+ */
void connectAsync();
+ /**
+ * Disconnect from the server
+ */
void disconnect();
+ /**
+ * Get the chat manager.
+ */
IChatManager getChatManager();
- // to ameliore
- void changeStatus();
+ /**
+ * Change the status of the user.
+ * @param status the status to set
+ * @param msg the message state to set
+ */
+ void changeStatus(in int status, in String msg);
}
--- a/src/com/beem/project/beem/ui/ContactList.java Tue Apr 14 16:56:20 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Thu Apr 16 00:27:49 2009 +0200
@@ -32,6 +32,7 @@
import com.beem.project.beem.service.aidl.IBeemRosterListener;
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppFacade;
+import com.beem.project.beem.utils.Status;
public class ContactList extends ExpandableListActivity {
@@ -244,27 +245,27 @@
ImageView imgV = (ImageView) view.findViewById(to[0]);
Drawable imageDrawable = null;
switch (c.getStatus()) {
- case Contact.CONTACT_STATUS_AVAILABLE:
+ case Status.CONTACT_STATUS_AVAILABLE:
imageDrawable = (Drawable) getResources().getDrawable(
R.drawable.online);
break;
- case Contact.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
+ case Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT:
imageDrawable = (Drawable) getResources().getDrawable(
R.drawable.chat);
break;
- case Contact.CONTACT_STATUS_AWAY:
+ case Status.CONTACT_STATUS_AWAY:
imageDrawable = (Drawable) getResources().getDrawable(
R.drawable.away);
break;
- case Contact.CONTACT_STATUS_BUSY:
+ case Status.CONTACT_STATUS_BUSY:
imageDrawable = (Drawable) getResources().getDrawable(
R.drawable.dnd);
break;
- case Contact.CONTACT_STATUS_DISCONNECT:
+ case Status.CONTACT_STATUS_DISCONNECT:
imageDrawable = (Drawable) getResources().getDrawable(
R.drawable.offline);
break;
- case Contact.CONTACT_STATUS_UNAVAILABLE:
+ case Status.CONTACT_STATUS_UNAVAILABLE:
imageDrawable = (Drawable) getResources().getDrawable(
R.drawable.requested);
break;