Suppression du contact.
authormarseille@marseille-desktop
Mon, 22 Jun 2009 22:14:25 +0200
changeset 267 ab5493f08c57
parent 263 ff0b4790a5ed
child 268 68eb7cb08ba3
Suppression du contact. Mettre a jour la contactlist ...
res/layout/contactdialog.xml
res/values/strings.xml
src/com/beem/project/beem/service/Contact.java
src/com/beem/project/beem/service/RosterAdapter.java
src/com/beem/project/beem/service/aidl/IRoster.aidl
src/com/beem/project/beem/ui/ContactDialog.java
src/com/beem/project/beem/ui/ContactList.java
--- a/res/layout/contactdialog.xml	Mon Jun 22 19:16:38 2009 +0200
+++ b/res/layout/contactdialog.xml	Mon Jun 22 22:14:25 2009 +0200
@@ -9,8 +9,8 @@
 	<Button android:id="@+id/CDAlias" android:layout_width="fill_parent"
 		android:layout_height="wrap_content" android:text="@string/CDAlias" />
 
-	<Button android:id="@+id/CDGroup" android:layout_width="fill_parent"
-		android:layout_height="wrap_content" android:text="@string/CDGroup" />
+	<Button android:id="@+id/CDDelete" android:layout_width="fill_parent"
+		android:layout_height="wrap_content" android:text="@string/CDDelete" />
 
 	<Button android:id="@+id/CDResend" android:layout_width="fill_parent"
 		android:layout_height="wrap_content" android:text="@string/CDResend" />
--- a/res/values/strings.xml	Mon Jun 22 19:16:38 2009 +0200
+++ b/res/values/strings.xml	Mon Jun 22 22:14:25 2009 +0200
@@ -5,23 +5,23 @@
 	<string name="ClearButton">Clear</string>
 	<string name="AcceptButton">Accept</string>
 	<string name="RefuseButton">Refuse</string>
-	
+
 	<!--  Beem class -->
-	
+
 	<string name="BeemJabberID">Jabber ID</string>
-	
+
 	<!--  BeemApplication class -->
-	
+
 	<string name="BeemApplicationConnect">Connecting...</string>
-	
+
 	<!--  BeemService class -->
-	
+
 	<string name="BeemServiceDescription">Use the Beem Service</string>
 	<string name="BeemServiceCreated">BeemService Created</string>
 	<string name="BeemServiceDestroyed">BeemService destroyed</string>
 
 	<!--  Preferences informations -->
-	
+
 	<string name="PreferenceFileName">Beem</string>
 	<string name="PreferenceHostKey">host</string>
 	<string name="PreferenceJID">Jabber ID</string>
@@ -51,14 +51,18 @@
 	<string name="CLSProxyInfo">Proxy informations</string>
 	<string name="CLSLogin">Login:</string>
 	<string name="CLSOkButton">Ok</string>
-	
+
 	<!--  ContactDialog class -->
 	<string name="CDChat">Chat</string>
 	<string name="CDAlias">Alias</string>
-	<string name="CDGroup">Change group</string>
 	<string name="CDResend">Resend suscription</string>
 	<string name="CDInfos">User infos</string>
-	
+	<string name="CDDelete">Delete user</string>
+	<string name="CDSure2Delete">Are you sure you want to delete this contact?
+	</string>
+	<string name="CDSure2DeleteYes">Yes</string>
+	<string name="CDSure2DeleteNo">No</string>
+
 	<!-- AccountCreation class -->
 	<string name="ACLogin">Login:</string>
 	<string name="ACEmail">Email:</string>
@@ -68,7 +72,7 @@
 	<string name="ACOkLoginButton">Log with</string>
 	<string name="ACBadForm">Bad form</string>
 	<string name="ACCreated">Account created</string>
-	
+
 	<!-- AddContact class -->
 	<string name="AddCActTitle">Beem - Add contact</string>
 	<string name="AddCLogin">Login:</string>
@@ -77,7 +81,7 @@
 	<string name="AddCOkButton">Ok</string>
 	<string name="AddCContactAdded">Contact added</string>
 	<string name="AddCBadForm">Bad form</string>
-	
+
 	<!--  SendIM class -->
 
 	<string name="SendIMActTitle">Beem - Chat</string>
--- a/src/com/beem/project/beem/service/Contact.java	Mon Jun 22 19:16:38 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java	Mon Jun 22 22:14:25 2009 +0200
@@ -19,7 +19,6 @@
 
 /**
  * This class contains informations on a jabber contact.
- * 
  * @author darisk
  */
 public class Contact implements Parcelable {
@@ -29,24 +28,24 @@
      */
     public static final Parcelable.Creator<Contact> CREATOR = new Parcelable.Creator<Contact>() {
 
-	                                                        @Override
-	                                                        public Contact createFromParcel(Parcel source) {
-		                                                    return new Contact(source);
-	                                                        }
+	@Override
+	public Contact createFromParcel(Parcel source) {
+	    return new Contact(source);
+	}
 
-	                                                        @Override
-	                                                        public Contact[] newArray(int size) {
-		                                                    return new Contact[size];
-	                                                        }
-	                                                    };
+	@Override
+	public Contact[] newArray(int size) {
+	    return new Contact[size];
+	}
+    };
 
-    private int                                     mID;
-    private int                                     mStatus;
-    private String                                  mJID;
-    private String                                  mMsgState;
-    private List<String>                            mRes;
-    private List<String>                            mGroups;
-    private String                                  mName;
+    private int mID;
+    private int mStatus;
+    private String mJID;
+    private String mMsgState;
+    private List<String> mRes;
+    private List<String> mGroups;
+    private String mName;
 
     /**
      * Constructor.
@@ -56,9 +55,7 @@
 
     /**
      * 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();
@@ -74,9 +71,7 @@
 
     /**
      * Constructor.
-     * 
-     * @param jid
-     *            JID of the contact
+     * @param jid JID of the contact
      */
     public Contact(final String jid) {
 	mJID = jid;
@@ -89,11 +84,8 @@
 
     /**
      * Create a contact from a Uri.
-     * 
-     * @param uri
-     *            an uri for the contact
-     * @throws IllegalArgumentException
-     *             if it is not a xmpp uri
+     * @param uri an uri for the contact
+     * @throws IllegalArgumentException if it is not a xmpp uri
      */
     public Contact(Uri uri) {
 	if (!uri.getScheme().equals("xmpp"))
@@ -103,19 +95,20 @@
 
     /**
      * Add a group for the contact.
-     * 
-     * @param group
-     *            the group
+     * @param group the group
      */
     public void addGroup(String group) {
-	mGroups.add(group);
+	if (!mGroups.contains(group))
+	    mGroups.add(group);
+    }
+
+    public void delGroup(String group) {
+	mGroups.remove(group);
     }
 
     /**
      * Add a resource for this contact.
-     * 
-     * @param res
-     *            the resource to add
+     * @param res the resource to add
      */
     public void addRes(String res) {
 	if (!mRes.contains(res))
@@ -124,9 +117,7 @@
 
     /**
      * Delete a resource for this contact.
-     * 
-     * @param res
-     *            the resource de delete
+     * @param res the resource de delete
      */
     public void delRes(String res) {
 	mRes.remove(res);
@@ -143,7 +134,6 @@
 
     /**
      * Get the groups the contact is in.
-     * 
      * @return the mGroups
      */
     public List<String> getGroups() {
@@ -152,7 +142,6 @@
 
     /**
      * Get the id of the contact on the phone contact list.
-     * 
      * @return the mID
      */
     public int getID() {
@@ -161,7 +150,6 @@
 
     /**
      * Get the Jabber ID of the contact.
-     * 
      * @return the Jabber ID
      */
     public String getJID() {
@@ -170,7 +158,6 @@
 
     /**
      * Get the list of resource for the contact.
-     * 
      * @return the mRes
      */
     public List<String> getMRes() {
@@ -179,7 +166,6 @@
 
     /**
      * Get the message status of the contact.
-     * 
      * @return the message status of the contact.
      */
     public String getMsgState() {
@@ -195,7 +181,6 @@
 
     /**
      * Get the status of the contact.
-     * 
      * @return the mStatus
      */
     public int getStatus() {
@@ -204,9 +189,7 @@
 
     /**
      * Set the groups the contact is in.
-     * 
-     * @param groups
-     *            list of groups
+     * @param groups list of groups
      */
     public void setGroups(Collection<RosterGroup> groups) {
 	this.mGroups.clear();
@@ -217,9 +200,7 @@
 
     /**
      * Set the groups the contact is in.
-     * 
-     * @param mGroups
-     *            the mGroups to set
+     * @param mGroups the mGroups to set
      */
     public void setGroups(List<String> mGroups) {
 	this.mGroups = mGroups;
@@ -227,9 +208,7 @@
 
     /**
      * 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;
@@ -237,9 +216,7 @@
 
     /**
      * Set the Jabber ID of the contact.
-     * 
-     * @param jid
-     *            the jabber ID to set
+     * @param jid the jabber ID to set
      */
     public void setJID(String jid) {
 	mJID = jid;
@@ -247,9 +224,7 @@
 
     /**
      * Set a list of resource for the contact.
-     * 
-     * @param mRes
-     *            the mRes to set
+     * @param mRes the mRes to set
      */
     public void setMRes(List<String> mRes) {
 	this.mRes = mRes;
@@ -257,17 +232,14 @@
 
     /**
      * Set the message status of the contact.
-     * 
-     * @param msgState
-     *            the message status of the contact to set
+     * @param msgState the message status of the contact to set
      */
     public void setMsgState(String msgState) {
 	mMsgState = msgState;
     }
 
     /**
-     * @param mName
-     *            the mName to set
+     * @param mName the mName to set
      */
     public void setName(String mName) {
 	if (mName != null)
@@ -276,9 +248,7 @@
 
     /**
      * 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;
@@ -286,9 +256,7 @@
 
     /**
      * 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) {
 	mStatus = Status.getStatusFromPresence(presence);
@@ -297,9 +265,7 @@
 
     /**
      * Set status for the contact.
-     * 
-     * @param presence
-     *            The presence packet which contains the status
+     * @param presence The presence packet which contains the status
      */
     public void setStatus(PresenceAdapter presence) {
 	mStatus = presence.getStatus();
@@ -319,7 +285,6 @@
 
     /**
      * Get a URI to access the contact.
-     * 
      * @return the URI
      */
     public Uri toUri() {
--- a/src/com/beem/project/beem/service/RosterAdapter.java	Mon Jun 22 19:16:38 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java	Mon Jun 22 22:14:25 2009 +0200
@@ -27,281 +27,282 @@
 
 /**
  * This class implement a Roster adapter for BEEM.
- * 
  * @author darisk
  */
 public class RosterAdapter extends com.beem.project.beem.service.aidl.IRoster.Stub {
 
-	/**
-	 * Listener for the roster events. It will call the remote listeners registered.
-	 * 
-	 * @author darisk
-	 */
-	private class RosterListenerAdapter implements RosterListener {
-
-		/**
-		 * Constructor.
-		 */
-		public RosterListenerAdapter() {
-			// TODO Auto-generated constructor stub
-		}
-
-		/**
-		 * {@inheritDoc}
-		 */
-		@Override
-		public void entriesAdded(Collection<String> addresses) {
-			Log.i(TAG, "Ajout de l'entry");
-			final int n = mRemoteRosListeners.beginBroadcast();
-
-			List<String> tab = new ArrayList<String>();
-			tab.addAll(addresses);
-			for (int i = 0; i < n; i++) {
-				IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
-				try {					
-					listener.onEntriesAdded(tab);
-				} catch (RemoteException e) {
-					Log.w(TAG, "Error while adding roster entries", e);
-				}
-			}
-			mRemoteRosListeners.finishBroadcast();
-		}
-
-		/**
-		 * {@inheritDoc}
-		 */
-		@Override
-		public void entriesDeleted(Collection<String> addresses) {
-			Log.i(TAG, "Suppression de l'entry");
-			final int n = mRemoteRosListeners.beginBroadcast();
-
-			List<String> tab = new ArrayList<String>();
-			tab.addAll(addresses);
-			for (int i = 0; i < n; i++) {
-				IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
-				try {					
-					listener.onEntriesDeleted(tab);
-				} catch (RemoteException e) {
-					Log.w(TAG, "Error while deleting roster entries", e);
-				}
-			}
-			mRemoteRosListeners.finishBroadcast();
-		}
-
-		/**
-		 * {@inheritDoc}
-		 */
-		@Override
-		public void entriesUpdated(Collection<String> addresses) {
-			Log.d(TAG, "Update de l'entry");
-			final int n = mRemoteRosListeners.beginBroadcast();
-
-			List<String> tab = new ArrayList<String>();
-			tab.addAll(addresses);
-			for (int i = 0; i < n; i++) {
-				IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
-				try {					
-					listener.onEntriesUpdated(tab);
-				} catch (RemoteException e) {
-					Log.w(TAG, "Error while updating roster entries", e);
-				}
-			}
-			mRemoteRosListeners.finishBroadcast();
-		}
-
-		/**
-		 * {@inheritDoc}
-		 */
-		@Override
-		public void presenceChanged(Presence presence) {
-			Log.i(TAG, "Changement de Presence");
-			String user = StringUtils.parseBareAddress(presence.getFrom());
-			Log.d(TAG, "User : " + user);
-			Contact c = mContacts.get(StringUtils.parseBareAddress(user));
-			if (c == null) {
-				c = new Contact(user);
-				mContacts.put(user, c);
-			}
-			c.addRes(StringUtils.parseResource(presence.getFrom()));
-			c.setStatus(mAdaptee.getPresence(presence.getFrom()));
-			c.setMsgState(presence.getStatus());
-			c.setName(mAdaptee.getEntry(user).getName());
-			/* redispatch vers les IBeemRosterListener */
-			final int n = mRemoteRosListeners.beginBroadcast();
-
-			for (int i = 0; i < n; i++) {
-				IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
-				try {
-					listener.onPresenceChanged(new PresenceAdapter(presence));
-				} catch (RemoteException e) {
-					// The RemoteCallbackList will take care of removing the
-					// dead listeners.
-					Log.w(TAG, "Error while updating roster entries", e);
-				}
-			}
-			mRemoteRosListeners.finishBroadcast();
-		}
-	}
-
-	private static final String                     TAG                 = "RosterAdapter";
-	private Roster                                  mAdaptee;
-	private RemoteCallbackList<IBeemRosterListener> mRemoteRosListeners = new RemoteCallbackList<IBeemRosterListener>();
-
-	private Map<String, Contact>                    mContacts           = new HashMap<String, Contact>();
-
-	private RosterListenerAdapter                   mRosterListener     = new RosterListenerAdapter();
+    /**
+     * Listener for the roster events. It will call the remote listeners registered.
+     * @author darisk
+     */
+    private class RosterListenerAdapter implements RosterListener {
 
 	/**
 	 * Constructor.
-	 * 
-	 * @param roster
-	 *            the roster to adapt
+	 */
+	public RosterListenerAdapter() {
+	    // TODO Auto-generated constructor stub
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void entriesAdded(Collection<String> addresses) {
+	    Log.i(TAG, "Ajout de l'entry");
+	    final int n = mRemoteRosListeners.beginBroadcast();
+
+	    List<String> tab = new ArrayList<String>();
+	    tab.addAll(addresses);
+	    for (int i = 0; i < n; i++) {
+		IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
+		try {
+		    listener.onEntriesAdded(tab);
+		} catch (RemoteException e) {
+		    Log.w(TAG, "Error while adding roster entries", e);
+		}
+	    }
+	    mRemoteRosListeners.finishBroadcast();
+	}
+
+	/**
+	 * {@inheritDoc}
 	 */
-	public RosterAdapter(final Roster roster) {
-		mAdaptee = roster;
-		roster.addRosterListener(mRosterListener);
-		for (RosterEntry entry : roster.getEntries()) {
-			String user = StringUtils.parseBareAddress(entry.getUser());
-			if (!mContacts.containsKey(user)) {
-				Contact c = new Contact(user);
-				c.setStatus(roster.getPresence(user));
-				c.setGroups(entry.getGroups());
-				c.setName(entry.getName());
-				mContacts.put(user, c);
-			}
+	@Override
+	public void entriesDeleted(Collection<String> addresses) {
+	    Log.i(TAG, "Suppression de l'entry");
+	    final int n = mRemoteRosListeners.beginBroadcast();
+
+	    List<String> tab = new ArrayList<String>();
+	    tab.addAll(addresses);
+	    for (int i = 0; i < n; i++) {
+		IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
+		try {
+		    listener.onEntriesDeleted(tab);
+		} catch (RemoteException e) {
+		    Log.w(TAG, "Error while deleting roster entries", e);
 		}
+	    }
+	    mRemoteRosListeners.finishBroadcast();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 */
+	@Override
+	public void entriesUpdated(Collection<String> addresses) {
+	    Log.d(TAG, "Update de l'entry");
+	    final int n = mRemoteRosListeners.beginBroadcast();
+
+	    List<String> tab = new ArrayList<String>();
+	    tab.addAll(addresses);
+	    for (int i = 0; i < n; i++) {
+		IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
+		try {
+		    listener.onEntriesUpdated(tab);
+		} catch (RemoteException e) {
+		    Log.w(TAG, "Error while updating roster entries", e);
+		}
+	    }
+	    mRemoteRosListeners.finishBroadcast();
 	}
 
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
-	public void addRosterListener(IBeemRosterListener listen) throws RemoteException {
-		if (listen != null)
-			mRemoteRosListeners.register(listen);
+	public void presenceChanged(Presence presence) {
+	    Log.i(TAG, "Changement de Presence");
+	    String user = StringUtils.parseBareAddress(presence.getFrom());
+	    Log.d(TAG, "User : " + user);
+	    Contact c = mContacts.get(StringUtils.parseBareAddress(user));
+	    if (c == null) {
+		c = new Contact(user);
+		mContacts.put(user, c);
+	    }
+	    c.addRes(StringUtils.parseResource(presence.getFrom()));
+	    c.setStatus(mAdaptee.getPresence(presence.getFrom()));
+	    c.setMsgState(presence.getStatus());
+	    c.setName(mAdaptee.getEntry(user).getName());
+	    /* redispatch vers les IBeemRosterListener */
+	    final int n = mRemoteRosListeners.beginBroadcast();
+
+	    for (int i = 0; i < n; i++) {
+		IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i);
+		try {
+		    listener.onPresenceChanged(new PresenceAdapter(presence));
+		} catch (RemoteException e) {
+		    // The RemoteCallbackList will take care of removing the
+		    // dead listeners.
+		    Log.w(TAG, "Error while updating roster entries", e);
+		}
+	    }
+	    mRemoteRosListeners.finishBroadcast();
 	}
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public Contact addContact(String user, String name, String[] groups) throws RemoteException {
-		Contact res = null;
-		RosterEntry contact = mAdaptee.getEntry(user);
-		if (contact != null)  {
-			res = mContacts.get(user);
-			for (String groupStr : groups) {
-				boolean found = false;
-				for (RosterGroup group: mAdaptee.getGroups()) {
-					if (group.getName().equals(groupStr) && !group.contains(contact)) {
-						try {
-							group.addEntry(contact);
-							res.addGroup(groupStr);
-							found = true;
-						} catch (XMPPException e) {
-							e.printStackTrace();
-						}
-					}
-				}
-				if (!found) {
-					try {
-						mAdaptee.createGroup(groupStr).addEntry(contact);
-					} catch (XMPPException e) {
-						e.printStackTrace();
-					} catch (IllegalArgumentException e) {
-					}
-					res.addGroup(groupStr);
-				}
-			}
-		} else {
-			try {
-				mAdaptee.createEntry(user, name, groups);
-				res = new Contact(user);
-				mContacts.put(user, res);
-				for (String groupStr : groups) {
-					try {
-						mAdaptee.createGroup(groupStr);
-					} catch (IllegalArgumentException e) {
-						//e.printStackTrace();
-					}
-					res.addGroup(groupStr);
-				}
-			} catch (XMPPException e) {
-				Log.e(TAG, "Error while adding new contact", e);
-				return null;
-			}
-		}
-		return res;
+    private static final String TAG = "RosterAdapter";
+    private Roster mAdaptee;
+    private RemoteCallbackList<IBeemRosterListener> mRemoteRosListeners = new RemoteCallbackList<IBeemRosterListener>();
+
+    private Map<String, Contact> mContacts = new HashMap<String, Contact>();
+
+    private RosterListenerAdapter mRosterListener = new RosterListenerAdapter();
+
+    /**
+     * Constructor.
+     * @param roster the roster to adapt
+     */
+    public RosterAdapter(final Roster roster) {
+	mAdaptee = roster;
+	roster.addRosterListener(mRosterListener);
+	for (RosterEntry entry : roster.getEntries()) {
+	    String user = StringUtils.parseBareAddress(entry.getUser());
+	    if (!mContacts.containsKey(user)) {
+		Contact c = new Contact(user);
+		c.setStatus(roster.getPresence(user));
+		c.setGroups(entry.getGroups());
+		c.setName(entry.getName());
+		mContacts.put(user, c);
+	    }
 	}
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addRosterListener(IBeemRosterListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteRosListeners.register(listen);
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void createGroup(String groupname) throws RemoteException {
-		mAdaptee.createGroup(groupname);
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Contact addContact(String user, String name, String[] groups) throws RemoteException {
+	Contact res = null;
+	RosterEntry contact = mAdaptee.getEntry(user);
+	if (contact != null) {
+	    res = mContacts.get(user);
+	    for (String groupStr : groups) {
+		boolean found = false;
+		for (RosterGroup group : mAdaptee.getGroups()) {
+		    if (group.getName().equals(groupStr) && !group.contains(contact)) {
+			try {
+			    group.addEntry(contact);
+			    res.addGroup(groupStr);
+			    found = true;
+			} catch (XMPPException e) {
+			    e.printStackTrace();
+			}
+		    }
+		}
+		if (!found) {
+		    try {
+			mAdaptee.createGroup(groupStr).addEntry(contact);
+		    } catch (XMPPException e) {
+			e.printStackTrace();
+		    } catch (IllegalArgumentException e) {
+		    }
+		    res.addGroup(groupStr);
+		}
+	    }
+	} else {
+	    try {
+		mAdaptee.createEntry(user, name, groups);
+		res = new Contact(user);
+		mContacts.put(user, res);
+		for (String groupStr : groups) {
+		    try {
+			mAdaptee.createGroup(groupStr);
+		    } catch (IllegalArgumentException e) {
+			// e.printStackTrace();
+		    }
+		    res.addGroup(groupStr);
+		}
+	    } catch (XMPPException e) {
+		Log.e(TAG, "Error while adding new contact", e);
+		return null;
+	    }
 	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void deleteContact(Contact contact) throws RemoteException {
-		mContacts.remove(contact.getJID());
-	}
-
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public Contact getContact(String jid) throws RemoteException {
-		return mContacts.get(jid);
-	}
+	return res;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public List<Contact> getContactList() throws RemoteException {
-		List<Contact> res = new ArrayList<Contact>();
-		res.addAll(mContacts.values());
-		return res;
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void createGroup(String groupname) throws RemoteException {
+	mAdaptee.createGroup(groupname);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void deleteContact(Contact contact, String group) throws RemoteException {
+	mContacts.get(contact.getJID()).delGroup(group);
+	try {
+	    mAdaptee.getGroup(group).removeEntry(mAdaptee.getEntry(contact.getJID()));
+	} catch (XMPPException e) {
+	    e.printStackTrace();
 	}
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Contact getContact(String jid) throws RemoteException {
+	return mContacts.get(jid);
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public List<String> getGroupsNames() throws RemoteException {
-		Collection<RosterGroup> groups = mAdaptee.getGroups();
-		ArrayList<String> result = new ArrayList<String>(groups.size());
-		for (RosterGroup rosterGroup : groups) {
-			result.add(rosterGroup.getName());
-		}
-		return result;
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<Contact> getContactList() throws RemoteException {
+	List<Contact> res = new ArrayList<Contact>();
+	res.addAll(mContacts.values());
+	return res;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List<String> getGroupsNames() throws RemoteException {
+	Collection<RosterGroup> groups = mAdaptee.getGroups();
+	ArrayList<String> result = new ArrayList<String>(groups.size());
+	for (RosterGroup rosterGroup : groups) {
+	    result.add(rosterGroup.getName());
 	}
+	return result;
+    }
 
-	/**
-	 * {@inheritDoc}
-	 */
-	@Override
-	public void removeRosterListener(IBeemRosterListener listen) throws RemoteException {
-		if (listen != null)
-			mRemoteRosListeners.unregister(listen);
-	}
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeRosterListener(IBeemRosterListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteRosListeners.unregister(listen);
+    }
 
-	/**
+    /**
 	 * 
 	 */
-	@Override
-	public void setContactName(String jid, String name) throws RemoteException {
-		mContacts.get(jid).setName(name);
-		mAdaptee.getEntry(jid).setName(name);
-	}
+    @Override
+    public void setContactName(String jid, String name) throws RemoteException {
+	mContacts.get(jid).setName(name);
+	mAdaptee.getEntry(jid).setName(name);
+    }
 
-	@Override
-	public PresenceAdapter getPresence(String jid) throws RemoteException {
-		return new PresenceAdapter(mAdaptee.getPresence(jid));
-	}
+    @Override
+    public PresenceAdapter getPresence(String jid) throws RemoteException {
+	return new PresenceAdapter(mAdaptee.getPresence(jid));
+    }
 
 }
--- a/src/com/beem/project/beem/service/aidl/IRoster.aidl	Mon Jun 22 19:16:38 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IRoster.aidl	Mon Jun 22 22:14:25 2009 +0200
@@ -8,7 +8,7 @@
     
     Contact addContact(in String user, in String name, in String[] groups);
     
-    void deleteContact(in Contact contact);
+    void deleteContact(in Contact contact, in String group);
     
     Contact getContact(in String jid);
     void setContactName(in String jid, in String name);
--- a/src/com/beem/project/beem/ui/ContactDialog.java	Mon Jun 22 19:16:38 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactDialog.java	Mon Jun 22 22:14:25 2009 +0200
@@ -3,10 +3,12 @@
 import org.jivesoftware.smack.packet.Presence;
 
 import android.app.Activity;
+import android.app.AlertDialog;
 import android.app.Dialog;
 import android.app.Service;
 import android.content.ComponentName;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.ServiceConnection;
 import android.os.IBinder;
@@ -25,23 +27,25 @@
 
     public static final String TAG = "Option Dialog";
     private final Contact mContact;
+    private final String mGroup;
     private final Context mContext;
     private IXmppFacade xmppFacade = null;
     private final ServiceConnection mServConn = new BeemServiceConnection();
 
-    public ContactDialog(final Context context, Contact curContact) {
+    public ContactDialog(final Context context, Contact curContact, String group) {
 	super(context);
 	mContext = context;
 
 	setContentView(R.layout.contactdialog);
 	mContact = curContact;
+	mGroup = group;
 	setTitle(curContact.getJID());
 
 	Button button = (Button) findViewById(R.id.CDChat);
 	button.setOnClickListener(new chatListener());
 	button = (Button) findViewById(R.id.CDAlias);
 	button.setOnClickListener(new aliasListener());
-	button = (Button) findViewById(R.id.CDGroup);
+	button = (Button) findViewById(R.id.CDDelete);
 	button.setOnClickListener(new groupListener());
 	button = (Button) findViewById(R.id.CDResend);
 	button.setOnClickListener(new resendListener());
@@ -51,6 +55,12 @@
 	mContext.bindService(new Intent(mContext, BeemService.class), mServConn, Service.BIND_AUTO_CREATE);
     }
 
+    @Override
+    public void dismiss() {
+	super.dismiss();
+	mContext.unbindService(mServConn);
+    }
+
     class aliasListener implements View.OnClickListener {
 
 	@Override
@@ -81,8 +91,26 @@
 
 	@Override
 	public void onClick(View v) {
-	    // TODO Auto-generated method stub
-	    dismiss();
+	    final Activity a = ContactDialog.this.getOwnerActivity();
+	    AlertDialog.Builder builder = new AlertDialog.Builder(a);
+	    builder.setMessage(a.getString(R.string.CDDelete)).setCancelable(false).setPositiveButton(
+		a.getString(R.string.CDSure2DeleteYes), new DialogInterface.OnClickListener() {
+		    public void onClick(DialogInterface dialog, int id) {
+			try {
+			    xmppFacade.getRoster().deleteContact(mContact, mGroup);
+			    Log.i("CONTACTDIALOG", "CONTACT DELETED");
+			} catch (RemoteException e) {
+			    e.printStackTrace();
+			}
+			dismiss();
+		    }
+		}).setNegativeButton(a.getString(R.string.CDSure2DeleteNo), new DialogInterface.OnClickListener() {
+		public void onClick(DialogInterface dialog, int id) {
+		    dialog.cancel();
+		}
+	    });
+	    AlertDialog alert = builder.create();
+	    alert.show();
 	}
 
     }
--- a/src/com/beem/project/beem/ui/ContactList.java	Mon Jun 22 19:16:38 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Mon Jun 22 22:14:25 2009 +0200
@@ -52,7 +52,7 @@
     private List<String> groupName;
     private List<Contact> mListContact;
     private Handler mHandler;
-    private IXmppFacade xmppFacade = null;
+    public IXmppFacade xmppFacade = null;
     private final ServiceConnection mServConn = new BeemServiceConnection();
     private int REQUEST_CODE = 1;
 
@@ -191,6 +191,7 @@
 
 	@Override
 	public void onEntriesDeleted(List<String> addresses) throws RemoteException {
+	    Log.i("CONTACTLIST", "EntreiesDeleted");
 	    for (List<Contact> cList : groupMap.values()) {
 		for (Contact curContact : cList) {
 		    for (String addr : addresses) {
@@ -206,8 +207,14 @@
 	    mHandler.post(new RunnableChange());
 	}
 
+	
+	/**
+	 * TODO: sur la suppression de contact, on passe tt le temps dans entries updated ...
+	 * probleme comment reconnaitre si on supprime ou ajoute un contact ....
+	 */
 	@Override
 	public void onEntriesUpdated(List<String> addresses) throws RemoteException {
+	    Log.e("CONTACTLIST", "ENTRIESUPDATED");
 	    for (String str : addresses) {
 		Contact curContact = mRoster.getContact(str);
 		for (String group : curContact.getGroups()) {
@@ -274,14 +281,16 @@
 	class MyOnLongClickListener implements OnLongClickListener {
 
 	    private final Contact mContact;
+	    private final String mGroup;
 
-	    public MyOnLongClickListener(Contact contact) {
+	    public MyOnLongClickListener(Contact contact, String group) {
 		mContact = contact;
+		mGroup = group;
 	    }
 
 	    @Override
 	    public boolean onLongClick(View v) {
-		createDialog(mContact);
+		createDialog(mContact, mGroup);
 		return true;
 	    }
 	}
@@ -356,8 +365,8 @@
 	    }
 	}
 
-	void createDialog(Contact contact) {
-	    ContactDialog dialogContact = new ContactDialog(ContactList.this, contact);
+	void createDialog(Contact contact, String group) {
+	    ContactDialog dialogContact = new ContactDialog(ContactList.this, contact, group);
 	    dialogContact.setOwnerActivity(ContactList.this);
 	    dialogContact.show();
 	}
@@ -405,7 +414,7 @@
 	    Contact contact = groupMap.get(groupName.get(groupPosition)).get(childPosition);
 	    bindView(v, contact);
 
-	    v.setOnLongClickListener(new MyOnLongClickListener(contact));
+	    v.setOnLongClickListener(new MyOnLongClickListener(contact, groupName.get(groupPosition)));
 	    v.setOnClickListener(new MyOnClickListener(contact));
 	    return v;
 	}