Merge.
authorVincent Veronis <veroni_v@epitech.net>
Thu, 24 Sep 2009 14:06:24 +0200
changeset 374 295cc30ae84a
parent 373 da35534975cd (current diff)
parent 371 f2c9564a3cc7 (diff)
child 376 76d505cbe7db
child 378 735a00bd56cb
Merge.
src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl
src/com/beem/project/beem/ui/ContactList.java
--- a/.classpath	Thu Sep 17 20:39:09 2009 +0200
+++ b/.classpath	Thu Sep 24 14:06:24 2009 +0200
@@ -2,7 +2,7 @@
 <classpath>
 	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
 	<classpathentry kind="lib" path="libs/smackx-debug.jar"/>
-	<classpathentry kind="lib" path="libs/smackx-jingle.jar"/>
+	<classpathentry kind="lib" path="libs/smackx-jingle.jar" sourcepath="/home/darisk/devel/smack_src_3_1_0/jingle/extension/source"/>
 	<classpathentry kind="src" path=".apt_generated">
 		<attributes>
 			<attribute name="optional" value="true"/>
--- a/AndroidManifest.xml	Thu Sep 17 20:39:09 2009 +0200
+++ b/AndroidManifest.xml	Thu Sep 24 14:06:24 2009 +0200
@@ -2,7 +2,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
 	package="com.beem.project.beem" android:versionCode="1"
 	android:versionName="1.0">
-	<application android:label="@string/app_name" android:icon="@drawable/signal" android:theme="@style/Theme.BEEM.Default">
+	<application android:label="@string/app_name" android:icon="@drawable/signal" android:theme="@style/Theme.BEEM.Default" android:debuggable="true">
 		<activity android:name=".ui.Login" android:label="@string/app_name"
 			android:launchMode="singleTask">
 			<intent-filter>
--- a/INSTALL	Thu Sep 17 20:39:09 2009 +0200
+++ b/INSTALL	Thu Sep 24 14:06:24 2009 +0200
@@ -1,15 +1,13 @@
 Howto Install Beem ?
 
 1. Dependencies
-   First you will need the Android SDK.
+   First you will need the Android SDK-1.5.
 
-2. ActivityCreator
+2. Android project
    Use the script provides by the SDK to set the Android platform directory.
-   > $SDK_DIR/tools/activitycreator --out . com.beem.project.beem.Beem
+   > $SDK_DIR/tools/android update project -t 2 -p $BEEM_DIRECTORY
 
 3. Compile and install
    Use ant to compile and install the application on the Android emulator
    > ant install
 
-
-
--- a/res/menu/sendimmenu.xml	Thu Sep 17 20:39:09 2009 +0200
+++ b/res/menu/sendimmenu.xml	Thu Sep 24 14:06:24 2009 +0200
@@ -1,3 +1,4 @@
 <menu xmlns:android="http://schemas.android.com/apk/res/android">
 	<item android:title="Insert a smiley" android:id="@+id/sendim_smiley"/>
+<item android:title="Call" android:id="@+id/sendim_call"></item>
 </menu>
--- a/src/com/beem/project/beem/jingle/JingleService.java	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/jingle/JingleService.java	Thu Sep 24 14:06:24 2009 +0200
@@ -5,7 +5,6 @@
 
 import java.util.ArrayList;
 import java.util.List;
-
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
 import org.jivesoftware.smackx.jingle.JingleManager;
@@ -18,11 +17,14 @@
 import org.jivesoftware.smackx.jingle.nat.BasicTransportManager;
 import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
 
+import android.util.Log;
+
 /**
  * Beem Jingle Service, manage jingle call.
  * @author nikita
  */
 public class JingleService {
+    private static final String TAG = "JingleService";
     private JingleManager mJingleManager;
     private List<JingleMediaManager> mMediaManagers;
     private JingleSession mIn;
@@ -34,6 +36,7 @@
      */
     public JingleService(final XMPPConnection xmppConnection) {
 	BasicTransportManager bt = new BasicTransportManager();
+	//JingleTransportManager tm = new ICETransportManager();
 
 	mMediaManagers = new ArrayList<JingleMediaManager>();
 	mMediaManagers.add(new MicrophoneRTPManager(bt));
@@ -98,8 +101,7 @@
 
 	@Override
 	public void sessionDeclined(String reason, JingleSession jingleSession) {
-	    // TODO Auto-generated method stub
-	    //System.out.println("Session " + jingleSession.getResponder() + "declined because " + reason);
+	    Log.d(TAG, "Session " + jingleSession.getResponder() + "declined because " + reason);
 	}
 
 	@Override
@@ -109,6 +111,7 @@
 	    //System.out.println("Je recois sur " + remoteCandidate.getIp() + ":" + remoteCandidate.getPort());
 	    // TODO choose the right RTPReceiver depending on the payload type
 	    //RTPReceiver rtpReceiver = new RTPReceiver(remoteCandidate.getPort());
+	    Log.d(TAG, "Session " + jingleSession.getResponder() + "established");
 	}
 
 	@Override
@@ -149,12 +152,13 @@
 	@Override
 	public void sessionDeclined(final String reason, final JingleSession jingleSession) {
 	   // System.out.println("Session " + jingleSession.getResponder() + "declined because " + reason);
+	    Log.d(TAG, "Session " + jingleSession.getResponder() + "declined because " + reason);
 	}
 
 	@Override
 	public void sessionEstablished(final PayloadType pt, final TransportCandidate remoteCandidate,
 	    final TransportCandidate localCandidate, final JingleSession jingleSession) {
-	   // System.out.println("Session established");
+	    Log.d(TAG, "Session " + jingleSession.getResponder() + "established");
 	    // String name = localCandidate.getName();
 	    String ip = localCandidate.getIp();
 	    int port = localCandidate.getPort();
--- a/src/com/beem/project/beem/service/Contact.java	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java	Thu Sep 24 14:06:24 2009 +0200
@@ -6,15 +6,12 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
-
 import org.jivesoftware.smack.RosterGroup;
 import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smack.util.StringUtils;
-
 import android.net.Uri;
 import android.os.Parcel;
 import android.os.Parcelable;
-
 import com.beem.project.beem.utils.Status;
 
 /**
@@ -76,11 +73,13 @@
      *            JID of the contact
      */
     public Contact(final String jid) {
-	mJID = jid;
-	mName = jid;
+	mJID = StringUtils.parseBareAddress(jid);
+	mName = mJID;
 	mStatus = Status.CONTACT_STATUS_DISCONNECT;
 	mRes = new ArrayList<String>();
-	mRes.add("none");
+	String res = StringUtils.parseResource(jid);
+	if (!"".equals(res))
+	    mRes.add(res);
 	mGroups = new ArrayList<String>();
     }
 
@@ -94,7 +93,13 @@
     public Contact(final Uri uri) {
 	if (!"xmpp".equals(uri.getScheme()))
 	    throw new IllegalArgumentException();
-	mJID = uri.getSchemeSpecificPart();
+	String enduri = uri.getEncodedSchemeSpecificPart();
+	mJID = StringUtils.parseBareAddress(enduri);
+	mName = mJID;
+	mStatus = Status.CONTACT_STATUS_DISCONNECT;
+	mRes = new ArrayList<String>();
+	mRes.add(StringUtils.parseResource(enduri));
+	mGroups = new ArrayList<String>();
     }
 
     /**
@@ -322,6 +327,26 @@
     }
 
     /**
+     * Get a URI to access the specific contact on this resource.
+     * @param resource the resource of the contact
+     * @return the URI
+     */
+    public Uri toUri(String resource) {
+	StringBuilder build = new StringBuilder("xmpp:");
+	String name = StringUtils.parseName(mJID);
+	build.append(name);
+	if (!"".equals(name))
+	    build.append('@');
+	build.append(StringUtils.parseServer(mJID));
+	if (!"".equals(resource)) {
+	    build.append('/');
+	    build.append(resource);
+	}
+	Uri u = Uri.parse(build.toString());
+	return u;
+    }
+
+    /**
      * {@inheritDoc}
      */
     @Override
--- a/src/com/beem/project/beem/service/RosterAdapter.java	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java	Thu Sep 24 14:06:24 2009 +0200
@@ -1,3 +1,6 @@
+/**
+ *
+ */
 package com.beem.project.beem.service;
 
 
@@ -11,7 +14,6 @@
 import org.jivesoftware.smack.RosterListener;
 import org.jivesoftware.smack.XMPPException;
 import org.jivesoftware.smack.packet.Presence;
-import org.jivesoftware.smack.util.StringUtils;
 
 import android.os.RemoteCallbackList;
 import android.os.RemoteException;
@@ -90,6 +92,7 @@
 		mAdaptee.removeEntry(entry);
 	    } else {
 		mAdaptee.getGroup(group).removeEntry(entry);
+		mRosterListener.onEntryDeleteFromGroup(group, contact.getJID());
 	    }
 	} catch (XMPPException e) {
 	    e.printStackTrace();
@@ -172,7 +175,7 @@
      * @return a contact for this entry.
      */
     private Contact getContactFromRosterEntry(RosterEntry entry) {
-	String user = StringUtils.parseBareAddress(entry.getUser());
+	String user = entry.getUser();
 	Contact c = new Contact(user);
 	c.setStatus(mAdaptee.getPresence(user));
 	c.setGroups(entry.getGroups());
@@ -196,7 +199,7 @@
 	 * Event which is fired when an entry is deleted for a group.
 	 * @param group the group the entry was.
 	 * @param jid the jid of the entry which is deleted.
-	 * /
+	 */
 	public void onEntryDeleteFromGroup(String group, String jid) {
 	    //Log.i(TAG, "entry delete listener");
 	    final int n = mRemoteRosListeners.beginBroadcast();
@@ -210,7 +213,7 @@
 	    }
 	    mRemoteRosListeners.finishBroadcast();
 
-	} */
+	}
 
 	/**
 	 * {@inheritDoc}
@@ -291,7 +294,7 @@
 		} catch (RemoteException e) {
 		    // The RemoteCallbackList will take care of removing the
 		    // dead listeners.
-		    Log.w(TAG, "Error while updating roster entries presence", e);
+		    Log.w(TAG, "Error while updating roster entries", e);
 		}
 	    }
 	    mRemoteRosListeners.finishBroadcast();
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Thu Sep 24 14:06:24 2009 +0200
@@ -9,6 +9,7 @@
 import org.jivesoftware.smack.Roster;
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.packet.Presence;
 import org.jivesoftware.smackx.ChatStateManager;
 import org.jivesoftware.smackx.ServiceDiscoveryManager;
 import org.jivesoftware.smackx.jingle.JingleManager;
@@ -37,7 +38,8 @@
     private RosterAdapter mRoster;
     private PrivacyListManagerAdapter mPrivacyList;
     private BeemService mService;
-    private RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners = new RemoteCallbackList<IBeemConnectionListener>();
+    private RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners =
+	new RemoteCallbackList<IBeemConnectionListener>();
 
     private ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter();
 
@@ -46,9 +48,10 @@
      * @param config Configuration to use in order to connect
      * @param login login to use on connect
      * @param password password to use on connect
+     * @param service the background service associated with the connection.
      */
     public XmppConnectionAdapter(final ConnectionConfiguration config, final String login, final String password,
-	BeemService service) {
+	final BeemService service) {
 	this(new XMPPConnection(config), login, password, service);
     }
 
@@ -57,9 +60,10 @@
      * @param serviceName name of the service to connect to
      * @param login login to use on connect
      * @param password password to use on connect
+     * @param service the background service associated with the connection.
      */
     public XmppConnectionAdapter(final String serviceName, final String login, final String password,
-	BeemService service) {
+	final BeemService service) {
 	this(new XMPPConnection(serviceName), login, password, service);
     }
 
@@ -68,9 +72,10 @@
      * @param con The connection to adapt
      * @param login The login to use
      * @param password The password to use
+     * @param service the background service associated with the connection.
      */
     public XmppConnectionAdapter(final XMPPConnection con, final String login, final String password,
-	BeemService service) {
+	final BeemService service) {
 	mAdaptee = con;
 	PrivacyListManager.getInstanceFor(mAdaptee);
 	mLogin = login;
@@ -123,6 +128,10 @@
 	    ChatStateManager.getInstance(mAdaptee);
 
 	    triggerAsynchronousConnectEvent();
+	    //Priority between -128 and 128
+	    Presence p = new Presence(Presence.Type.available, "Beem : http://www.beem-project.com",
+		    128, Presence.Mode.available);
+	    mAdaptee.sendPacket(p);
 	    return true;
 	} catch (XMPPException e) {
 	    Log.e(TAG, "Error while connecting", e);
@@ -144,6 +153,10 @@
 	return true;
     }
 
+    /**
+     * Get the Smack XmppConnection.
+     * @return Smack XmppConnection
+     */
     public XMPPConnection getAdaptee() {
 	return mAdaptee;
     }
@@ -156,6 +169,10 @@
 	return mChatManager;
     }
 
+    /**
+     * Get the context of the adapter.
+     * @return The context of the adapter
+     */
     public BeemService getContext() {
 	return mService;
     }
@@ -211,13 +228,15 @@
     }
 
     /**
+     * Set the privacy list to use.
      * @param mPrivacyList the mPrivacyList to set
      */
-    public void setPrivacyList(PrivacyListManagerAdapter privacyList) {
-	this.mPrivacyList = privacyList;
+    public void setPrivacyList(PrivacyListManagerAdapter PrivacyList) {
+	this.mPrivacyList = PrivacyList;
     }
 
     /**
+     * Get the privacy list in use.
      * @return the mPrivacyList
      */
     public PrivacyListManagerAdapter getPrivacyList() {
@@ -313,7 +332,7 @@
 		} catch (RemoteException e) {
 		    // The RemoteCallbackList will take care of removing the
 		    // dead listeners.
-		    Log.w(TAG, "Eror while triggering remote connection listeners", e);
+		    Log.w(TAG, "Error while triggering remote connection listeners", e);
 		}
 	    }
 	    mRemoteConnListeners.finishBroadcast();
--- a/src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl	Thu Sep 24 14:06:24 2009 +0200
@@ -7,4 +7,5 @@
     void onEntriesUpdated(in List<String> addresses);
     void onEntriesDeleted(in List<String> addresses);
     void onPresenceChanged(in PresenceAdapter presence);
+    void onEntryDeleteFromGroup(in String group, in String jid);
 }
\ No newline at end of file
--- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl	Thu Sep 24 14:06:24 2009 +0200
@@ -52,6 +52,5 @@
      * make a jingle audio call
      * @param jid the receiver id
      */
-     
      void call(in String jid);
 }
--- a/src/com/beem/project/beem/ui/AddContact.java	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java	Thu Sep 24 14:06:24 2009 +0200
@@ -26,7 +26,7 @@
  */
 public class AddContact extends Activity {
 
-    protected static final String TAG = "AddContact";
+    private static final String TAG = "AddContact";
     private final List<String> mGroup = new ArrayList<String>();
     private IXmppFacade mXmppFacade;
     private final ServiceConnection mServConn = new BeemServiceConnection();
@@ -37,7 +37,7 @@
     public AddContact() { }
 
     /**
-     * @{InheritDoc}
+     * {@inheritDoc}
      */
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -49,7 +49,7 @@
     }
 
     /**
-     * @{InheritDoc}
+     * {@inheritDoc}
      */
     @Override
     protected void onStop() {
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Thu Sep 24 14:06:24 2009 +0200
@@ -40,6 +40,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.PresenceType;
 import com.beem.project.beem.utils.Status;
 
 /**
@@ -425,20 +426,43 @@
 	public void onEntriesUpdated(List<String> addresses) throws RemoteException {
 	    mHandler.post(new RunnableChange());
 	}
-
+	
+	@Override
+        public void onEntryDeleteFromGroup(String group, String jid)
+                throws RemoteException {
+	    // TODO Auto-generated method stub
+	    
+        }
 	/**
 	 * {@inheritDoc}
 	 */
 	@Override
 	public void onPresenceChanged(PresenceAdapter presence) throws RemoteException {
+	    //TODO gerer la presence au niveau de chaque ressources ?
+	    String from = presence.getFrom();
+	    boolean resfound = false;
 	    for (Contact curContact : mListContact) {
-		if (curContact.getJID().equals(StringUtils.parseBareAddress(presence.getFrom()))) {
+		if (curContact.getJID().equals(StringUtils.parseBareAddress(from))) {
+		    String pres = StringUtils.parseResource(from);
+		    for (String res : curContact.getMRes()) {
+	                if (res.equals(pres)) {
+	                    resfound = true;
+	                    break;
+	                }
+                    }
 		    curContact.setStatus(mRoster.getPresence(StringUtils.parseBareAddress(presence.getFrom())));
+		    int status = presence.getStatus();
+		    if (!resfound &&  (status != Status.CONTACT_STATUS_DISCONNECT && status != Status.CONTACT_STATUS_UNAVAILABLE))
+			curContact.addRes(pres);
+		    else if (resfound && (status == Status.CONTACT_STATUS_DISCONNECT && status == Status.CONTACT_STATUS_UNAVAILABLE))
+			curContact.delRes(pres);
 		    mHandler.post(new RunnableChange());
 		    return;
 		}
 	    }
 	}
+
+	
     }
 
     /**
--- a/src/com/beem/project/beem/ui/SendIM.java	Thu Sep 17 20:39:09 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java	Thu Sep 24 14:06:24 2009 +0200
@@ -207,6 +207,16 @@
 	    case R.id.sendim_smiley:
 		mSmyDialog.show();
 		return true;
+	    case R.id.sendim_call:
+		// TODO start the jingle call 
+		// Bug a besoin du jid complet (resource compris)
+		try {
+	            mXmppFacade.call(mContact.getJID());
+                } catch (RemoteException e) {
+	            // TODO Auto-generated catch block
+	            e.printStackTrace();
+                }
+		return true;
 	    default:
 		return false;
 	}
@@ -419,6 +429,12 @@
 	}
 
 	@Override
+        public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
+	    // TODO Auto-generated method stub
+
+        }
+
+	@Override
 	public void onPresenceChanged(PresenceAdapter presence) throws RemoteException {
 	    if (mContact.getJID().equals(StringUtils.parseBareAddress(presence.getFrom()))) {
 		mContact.setStatus(mRoster.getPresence(StringUtils.parseBareAddress(presence.getFrom())));
@@ -443,6 +459,8 @@
 	    }
 	}
 
+
+
     }
 
     /**