# HG changeset patch # User Da Risk # Date 1239817295 -7200 # Node ID c60aa223786530d77fb20493c9f71ae987c42509 # Parent 71ad42062140a8476625df263af82e7bdaaba0e9# Parent b31649abe73117504dc1bc93697b3d2e08d5f878 merge with ui diff -r b31649abe731 -r c60aa2237865 .hgignore --- a/.hgignore Wed Apr 15 16:50:15 2009 +0200 +++ b/.hgignore Wed Apr 15 19:41:35 2009 +0200 @@ -3,3 +3,5 @@ R.java doc/javadoc src/com/beem/project/beem/service/aidl/*.java +gen/* +local.properties diff -r b31649abe731 -r c60aa2237865 build.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/build.properties Wed Apr 15 19:41:35 2009 +0200 @@ -0,0 +1,3 @@ +external-libs=libs +javadoc-output=doc/javadoc + diff -r b31649abe731 -r c60aa2237865 build.xml --- a/build.xml Wed Apr 15 16:50:15 2009 +0200 +++ b/build.xml Wed Apr 15 19:41:35 2009 +0200 @@ -1,316 +1,75 @@ - - + + + + + + by the 'android' tool. This is the place to change some of the default property values + used by the Ant rules. + Here are some properties you may want to change/update: + + application-package + the name of your application package as defined in the manifest. Used by the + 'uninstall' rule. + source-folder + the name of the source folder. Default is 'src'. + out-folder + the name of the output folder. Default is 'bin'. + + Properties related to the SDK location or the project target should be updated + using the 'android' tool with the 'update' action. + + This file is an integral part of the build system for your application and + should be checked in in Version Control Systems. + + --> - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Creating output directories if needed... - - - - - - - - Generating R.java / Manifest.java from the resources... - - - - - - - - - - - - - - - - - Compiling aidl files into Java classes... - - - - - - - - - - + - - - - - - - - - - - - Converting compiled files and external libraries into ${outdir}/${dex-file}... - - - - - - - - - - - Packaging resources and assets... - - - - - - - - - - - - - - - - - - - Packaging resources... - - - - - - - - - - - - - - - - - - - - - - + + + + + + - - - Packaging ${out-debug-package}, and signing it with a debug key... - - - - - - - - - - - - - - - - - - Packaging ${out-unsigned-package} for release... - - - - - - - - - - - - - - - It will need to be signed with jarsigner before being published. - - - - - Installing ${out-debug-package} onto default emulator... - - - - - - - - Installing ${out-debug-package} onto default emulator... - - - - - - - - - - Uninstalling ${application-package} from the default emulator... - - - - - - - - - - - - - - - - - - + + + + + + + diff -r b31649abe731 -r c60aa2237865 default.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default.properties Wed Apr 15 19:41:35 2009 +0200 @@ -0,0 +1,22 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "build.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-3 +# apk configurations. This property allows creation of APK files with limited +# resources. For example, if your application contains many locales and +# you wish to release multiple smaller apks instead of a large one, you can +# define configuration to create apks with limited language sets. +# Format is a comma separated list of configuration names. For each +# configuration, a property will declare the resource configurations to +# include. Example: +# apk-configurations=european,northamerica +# apk-config-european=en,fr,it,de,es +# apk-config-northamerica=en,es +apk-configurations= diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/BeemApplication.java --- a/src/com/beem/project/beem/BeemApplication.java Wed Apr 15 16:50:15 2009 +0200 +++ b/src/com/beem/project/beem/BeemApplication.java Wed Apr 15 19:41:35 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(); diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/BeemService.java diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/service/BeemChatManager.java --- a/src/com/beem/project/beem/service/BeemChatManager.java Wed Apr 15 16:50:15 2009 +0200 +++ b/src/com/beem/project/beem/service/BeemChatManager.java Wed Apr 15 19:41:35 2009 +0200 @@ -120,6 +120,7 @@ IChat newchat = getChat(chat); if (!locally) { mChats.put(chat.getParticipant(), newchat); + // TODO startActivity } final int n = mRemoteChatCreationListeners.beginBroadcast(); diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/service/Contact.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/Contact.aidl Wed Apr 15 19:41:35 2009 +0200 @@ -0,0 +1,3 @@ +package com.beem.project.beem.service; + +parcelable Contact; diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/service/Contact.java --- a/src/com/beem/project/beem/service/Contact.java Wed Apr 15 16:50:15 2009 +0200 +++ b/src/com/beem/project/beem/service/Contact.java Wed Apr 15 19:41:35 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(); 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); } /** diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/service/Message.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/Message.aidl Wed Apr 15 19:41:35 2009 +0200 @@ -0,0 +1,3 @@ +package com.beem.project.beem.service; + +parcelable Message; \ No newline at end of file diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/service/PresenceAdapter.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/PresenceAdapter.aidl Wed Apr 15 19:41:35 2009 +0200 @@ -0,0 +1,3 @@ +package com.beem.project.beem.service; + +parcelable PresenceAdapter; \ No newline at end of file diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/service/XmppFacade.java --- a/src/com/beem/project/beem/service/XmppFacade.java Wed Apr 15 16:50:15 2009 +0200 +++ b/src/com/beem/project/beem/service/XmppFacade.java Wed Apr 15 19:41:35 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; diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/service/aidl/IXmppFacade.aidl --- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Wed Apr 15 16:50:15 2009 +0200 +++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Wed Apr 15 19:41:35 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); } diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Wed Apr 15 16:50:15 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Wed Apr 15 19:41:35 2009 +0200 @@ -9,7 +9,6 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; -import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; @@ -33,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 { @@ -246,27 +246,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; diff -r b31649abe731 -r c60aa2237865 src/com/beem/project/beem/utils/Status.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/utils/Status.java Wed Apr 15 19:41:35 2009 +0200 @@ -0,0 +1,112 @@ +/** + * + */ +package com.beem.project.beem.utils; + +import org.jivesoftware.smack.packet.Presence; +import org.jivesoftware.smack.packet.Presence.Mode; + +/** + * @author darisk + */ +public class Status { + + /** + * 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; + + /** + * Get the status of from a presence packet. + * @param presence the presence containing status + */ + public static int getStatusFromPresence(Presence presence) { + int res = Status.CONTACT_STATUS_DISCONNECT; + if (presence.getType().equals(Presence.Type.unavailable)) { + res = Status.CONTACT_STATUS_DISCONNECT; + } else { + Mode mode = presence.getMode(); + if (mode == null) { + res = Status.CONTACT_STATUS_AVAILABLE; + } else { + switch (mode) { + case available: + res = Status.CONTACT_STATUS_AVAILABLE; + break; + case away: + res = Status.CONTACT_STATUS_AWAY; + break; + case chat: + res = Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT; + break; + case dnd: + res = Status.CONTACT_STATUS_BUSY; + break; + case xa: + res = Status.CONTACT_STATUS_UNAVAILABLE; + break; + default: + res = Status.CONTACT_STATUS_DISCONNECT; + break; + } + } + } + return res; + } + + /** + * Get the smack presence mode for a status + * @param status the status in beem + * @return the presence mode to use in presence packet + * or null if there is no mode to use + */ + public static Presence.Mode getPresenceModeFromStatus(int status){ + Presence.Mode res; + switch (status) { + case CONTACT_STATUS_AVAILABLE: + res = Presence.Mode.available; + break; + case CONTACT_STATUS_AVAILABLE_FOR_CHAT: + res = Presence.Mode.chat; + break; + case CONTACT_STATUS_AWAY: + res = Presence.Mode.away; + break; + case CONTACT_STATUS_BUSY: + res = Presence.Mode.dnd; + break; + case CONTACT_STATUS_UNAVAILABLE: + res = Presence.Mode.xa; + break; + default: + return null; + } + return res; + } + +}