# HG changeset patch # User Vincent Veronis # Date 1253793984 -7200 # Node ID 295cc30ae84a38af02925a69153e0fe6a0b0d6b4 # Parent da35534975cd14c79fe3ac67110c8d7b21f41ea5# Parent f2c9564a3cc7429fde769bcc9dd1edf6546cb12b Merge. diff -r da35534975cd -r 295cc30ae84a .classpath --- a/.classpath Thu Sep 17 20:39:09 2009 +0200 +++ b/.classpath Thu Sep 24 14:06:24 2009 +0200 @@ -2,7 +2,7 @@ - + diff -r da35534975cd -r 295cc30ae84a AndroidManifest.xml --- 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 @@ - + diff -r da35534975cd -r 295cc30ae84a INSTALL --- 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 - - diff -r da35534975cd -r 295cc30ae84a res/menu/sendimmenu.xml --- 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 @@ + diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/jingle/JingleService.java --- 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 mMediaManagers; private JingleSession mIn; @@ -34,6 +36,7 @@ */ public JingleService(final XMPPConnection xmppConnection) { BasicTransportManager bt = new BasicTransportManager(); + //JingleTransportManager tm = new ICETransportManager(); mMediaManagers = new ArrayList(); 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(); diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/service/Contact.java --- 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(); - mRes.add("none"); + String res = StringUtils.parseResource(jid); + if (!"".equals(res)) + mRes.add(res); mGroups = new ArrayList(); } @@ -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(); + mRes.add(StringUtils.parseResource(enduri)); + mGroups = new ArrayList(); } /** @@ -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 diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/service/RosterAdapter.java --- 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(); diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/service/XmppConnectionAdapter.java --- 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 mRemoteConnListeners = new RemoteCallbackList(); + private RemoteCallbackList mRemoteConnListeners = + new RemoteCallbackList(); 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(); diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl --- 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 addresses); void onEntriesDeleted(in List addresses); void onPresenceChanged(in PresenceAdapter presence); + void onEntryDeleteFromGroup(in String group, in String jid); } \ No newline at end of file diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/service/aidl/IXmppFacade.aidl --- 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); } diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/ui/AddContact.java --- 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 mGroup = new ArrayList(); 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() { diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/ui/ContactList.java --- 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 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; } } } + + } /** diff -r da35534975cd -r 295cc30ae84a src/com/beem/project/beem/ui/SendIM.java --- 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 @@ } } + + } /**