# HG changeset patch # User marseille@KungFuh # Date 1239128082 -7200 # Node ID 84cad8522aa65e26c1e35c18873763a322f728ec # Parent 23a0dfdff5893394986b8bcd8a44a1f5a63b560a# Parent 29f0d6a23321a115c3881a2f1c1afd0f66717fcd merge. diff -r 29f0d6a23321 -r 84cad8522aa6 AndroidManifest.xml --- a/AndroidManifest.xml Tue Apr 07 10:25:40 2009 +0200 +++ b/AndroidManifest.xml Tue Apr 07 20:14:42 2009 +0200 @@ -2,7 +2,7 @@ - + diff -r 29f0d6a23321 -r 84cad8522aa6 res/drawable/background.png Binary file res/drawable/background.png has changed diff -r 29f0d6a23321 -r 84cad8522aa6 res/drawable/xmpp.jpg Binary file res/drawable/xmpp.jpg has changed diff -r 29f0d6a23321 -r 84cad8522aa6 res/layout/contactlistcontact.xml --- a/res/layout/contactlistcontact.xml Tue Apr 07 10:25:40 2009 +0200 +++ b/res/layout/contactlistcontact.xml Tue Apr 07 20:14:42 2009 +0200 @@ -6,7 +6,7 @@ android:gravity="center_vertical" > diff -r 29f0d6a23321 -r 84cad8522aa6 res/values/style.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/values/style.xml Tue Apr 07 20:14:42 2009 +0200 @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff -r 29f0d6a23321 -r 84cad8522aa6 src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Tue Apr 07 10:25:40 2009 +0200 +++ b/src/com/beem/project/beem/BeemService.java Tue Apr 07 20:14:42 2009 +0200 @@ -91,7 +91,7 @@ } else { mConnectionConfiguration = new ConnectionConfiguration(mHost); } - mConnectionConfiguration.setSendPresence(false); + mConnectionConfiguration.setSendPresence(true); } /** diff -r 29f0d6a23321 -r 84cad8522aa6 src/com/beem/project/beem/service/Contact.java --- a/src/com/beem/project/beem/service/Contact.java Tue Apr 07 10:25:40 2009 +0200 +++ b/src/com/beem/project/beem/service/Contact.java Tue Apr 07 20:14:42 2009 +0200 @@ -20,36 +20,12 @@ */ 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; @@ -75,26 +51,9 @@ }; /** - * Constructor. - */ - public Contact() { - // TODO Auto-generated constructor stub - } - - /** - * Constructor. - * @param jid JID of the contact - */ - public Contact(final String jid) { - mJID = jid; - mStatus = Contact.CONTACT_STATUS_DISCONNECT; - mRes = new ArrayList(); - mRes.add("none"); - } - - /** * Construct a contact from a parcel. - * @param in parcel to use for construction + * @param in + * parcel to use for construction */ private Contact(final Parcel in) { mID = in.readInt(); @@ -127,7 +86,25 @@ } /** - * Get the id of the contact on the phone contact list. + * Constructor. + */ + public Contact() { + // TODO Auto-generated constructor stub + } + + /** + * Constructor. + * @param jid + * JID of the contact + */ + public Contact(final String jid) { + mJID = jid; + mStatus = Contact.CONTACT_STATUS_DISCONNECT; + mRes = new ArrayList(); + mRes.add("none"); + } + + /** * @return the mID */ public int getID() { @@ -135,15 +112,14 @@ } /** - * set the id of te contact on the phone contact list. - * @param mid the mID to set + * @param mid + * the mID to set */ public void setID(int mid) { mID = mid; } /** - * Get the status of the contact. * @return the mStatus */ public int getStatus() { @@ -151,22 +127,22 @@ } /** - * Set the status of the contact. - * @param status the mStatus to set + * @param status + * the mStatus to set */ public void setStatus(int status) { mStatus = status; } /** - * Set the status of the contact using a presence packet. - * @param presence the presence containing status + * @param presence + * the presence containing status */ public void setStatus(Presence presence) { - if (presence.getType().equals(Presence.Type.unavailable)) { - Log.d(TAG, "Presence pas dispo"); - mStatus = Contact.CONTACT_STATUS_DISCONNECT; - } else { + Log.i(TAG, "NIKITAAAA"); + /* presence.isAvailable() !?!? */ + if (presence.getType().equals(Presence.Type.available)) { + mStatus = Contact.CONTACT_STATUS_AVAILABLE; Log.d(TAG, "Presence OK"); Mode mode = presence.getMode(); switch (mode) { @@ -187,25 +163,27 @@ break; default: Log.e("RosterAdapter", "Status mode non gere"); - mStatus = Contact.CONTACT_STATUS_DISCONNECT; + mStatus = Contact.CONTACT_STATUS_AVAILABLE; break; } + } else { + Log.d(TAG, "Presence pas dispo"); + mStatus = Contact.CONTACT_STATUS_DISCONNECT; } } /** - * Get the message status of the contact. - * @return the message status of the contact. + * @return the mMsgState */ - public String getMsgState() { + public String getMMsgState() { return mMsgState; } /** - * Set the message status of the contact. - * @param msgState the message status of the contact to set + * @param msgState + * the mMsgState to set */ - public void setMsgState(String msgState) { + public void setMMsgState(String msgState) { mMsgState = msgState; } @@ -219,31 +197,25 @@ /** * Set the Jabber ID of the contact. - * @param mjid the jabber ID to set + * @param mjid + * the jabber ID to set */ public void setJID(String mjid) { mJID = mjid; } - /** - * - * @param res - */ public void addRes(String res) { if (!mRes.contains(res)) mRes.add(res); } - /** - * - * @param res - */ public void delRes(String res) { mRes.remove(res); } /** - * @param mRes the mRes to set + * @param mRes + * the mRes to set */ public void setMRes(List mRes) { this.mRes = mRes; diff -r 29f0d6a23321 -r 84cad8522aa6 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Tue Apr 07 10:25:40 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Tue Apr 07 20:14:42 2009 +0200 @@ -13,6 +13,7 @@ import android.graphics.drawable.Drawable; import android.os.Bundle; import android.os.Handler; +import android.os.IBinder; import android.os.RemoteException; import android.util.Log; import android.view.Menu; @@ -29,6 +30,8 @@ import com.beem.project.beem.BeemApplication; import com.beem.project.beem.R; import com.beem.project.beem.service.Contact; +import com.beem.project.beem.service.PresenceAdapter; +import com.beem.project.beem.service.aidl.IBeemRosterListener; import com.beem.project.beem.service.aidl.IXmppFacade; import com.beem.project.beem.service.aidl.IRoster; @@ -40,6 +43,8 @@ private Handler mHandler; private BeemApplication mBeemApplication; private ContactListDialogSettings mDialog; + private BeemRosterListener mRosterListener; + private IRoster mRoster; @SuppressWarnings("unchecked") @Override @@ -62,33 +67,22 @@ mSettings = getSharedPreferences( getString(R.string.PreferenceFileName), MODE_PRIVATE); mDialog = new ContactListDialogSettings(this, mSettings); + mRosterListener = new BeemRosterListener(); mSettings .registerOnSharedPreferenceChangeListener(new OnSharedPreferenceChangeListener() { @Override public void onSharedPreferenceChanged( SharedPreferences sharedPreferences, String key) { - /* - * TODO : A faire apres listener nikita - * - * mBeemApplication.stopBeemService(); - * mBeemApplication.startBeemService(); - * mBeemApplication.callWhenServiceConnected(mHandler, - * new Runnable() { - * - * @Override public void run() { - * callbackShowContactList(); } }); - */ + Log.i(TAG, "On Preference Changed"); } }); - } @Override protected void onStart() { super.onStart(); - Log.i(TAG, "onStart"); - mBeemApplication.startBeemService(); + } @Override @@ -102,6 +96,15 @@ mBeemApplication.callWhenConnectedToServer(mHandler, new Runnable() { @Override public void run() { + mService = mBeemApplication.getXmppFacade(); + try { + if (mRoster != null) { + mRoster = mService.getRoster(); + mRoster.addConnectionListener(mRosterListener); + } + } catch (RemoteException e) { + e.printStackTrace(); + } callbackShowContactList(); } }); @@ -111,17 +114,13 @@ /* * @TODO: A ameliorer apres listener de nikita */ - mService = mBeemApplication.getXmppFacade(); - if (mService != null) { + if (mRoster != null) try { - IRoster r = mService.getRoster(); - if (r != null) - showContactList(r.getGroupsNames(), r.getContactList()); + showContactList(mRoster.getGroupsNames(), mRoster + .getContactList()); } catch (RemoteException e) { - // TODO Auto-generated catch block e.printStackTrace(); } - } } /** @@ -178,7 +177,7 @@ Map curChildMap = new HashMap(); children.add(curChildMap); Contact c = listContact.get(j); - Log.i(TAG, c.getID() + " " +c.getJID()); + Log.i(TAG, c.getID() + " " + c.getJID()); curChildMap.put("CHILD", c); } childData.add(children); @@ -245,25 +244,32 @@ switch (c.getStatus()) { case Contact.CONTACT_STATUS_AVAILABLE: imageDrawable = (Drawable) getResources().getDrawable( - R.drawable.avatar); + R.drawable.online); + break; case Contact.CONTACT_STATUS_AVAILABLE_FOR_CHAT: imageDrawable = (Drawable) getResources().getDrawable( R.drawable.chat); + break; case Contact.CONTACT_STATUS_AWAY: imageDrawable = (Drawable) getResources().getDrawable( R.drawable.away); + break; case Contact.CONTACT_STATUS_BUSY: imageDrawable = (Drawable) getResources().getDrawable( R.drawable.dnd); + break; case Contact.CONTACT_STATUS_DISCONNECT: imageDrawable = (Drawable) getResources().getDrawable( R.drawable.offline); + break; case Contact.CONTACT_STATUS_UNAVAILABLE: imageDrawable = (Drawable) getResources().getDrawable( R.drawable.requested); + break; default: imageDrawable = (Drawable) getResources().getDrawable( R.drawable.error); + break; } imgV.setImageDrawable(imageDrawable); @@ -292,4 +298,36 @@ } } } + + private class BeemRosterListener extends IBeemRosterListener.Stub { + + @Override + public void onEntriesAdded(List addresses) + throws RemoteException { + Log.i(TAG, "ENTRIES ADDED"); + + } + + @Override + public void onEntriesDeleted(List addresses) + throws RemoteException { + Log.i(TAG, "ENTRIES DEL"); + + } + + @Override + public void onEntriesUpdated(List addresses) + throws RemoteException { + Log.i(TAG, "ENTRIES UPD"); + + } + + @Override + public void onPresenceChanged(PresenceAdapter presence) + throws RemoteException { + Log.i(TAG, "PRESENCE CHANGED"); + + } + + } } \ No newline at end of file