--- a/.classpath Thu Sep 10 16:29:28 2009 +0200
+++ b/.classpath Thu Sep 17 17:28:40 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/res/menu/sendimmenu.xml Thu Sep 10 16:29:28 2009 +0200
+++ b/res/menu/sendimmenu.xml Thu Sep 17 17:28:40 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 10 16:29:28 2009 +0200
+++ b/src/com/beem/project/beem/jingle/JingleService.java Thu Sep 17 17:28:40 2009 +0200
@@ -16,13 +16,19 @@
import org.jivesoftware.smackx.jingle.media.JingleMediaManager;
import org.jivesoftware.smackx.jingle.media.PayloadType;
import org.jivesoftware.smackx.jingle.nat.BasicTransportManager;
+import org.jivesoftware.smackx.jingle.nat.ICETransportManager;
+import org.jivesoftware.smackx.jingle.nat.JingleTransportManager;
import org.jivesoftware.smackx.jingle.nat.TransportCandidate;
+import org.jivesoftware.smackx.workgroup.agent.TranscriptManager;
+
+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 +40,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 +105,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 +115,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 +156,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 10 16:29:28 2009 +0200
+++ b/src/com/beem/project/beem/service/Contact.java Thu Sep 17 17:28:40 2009 +0200
@@ -76,11 +76,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 +96,13 @@
public Contact(final Uri uri) {
if (!"xmpp".equals(uri.getScheme()))
throw new IllegalArgumentException();
- mJID = uri.getEncodedSchemeSpecificPart();
+ 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>();
}
/**
@@ -320,6 +328,27 @@
Uri u = Uri.parse(build.toString());
return u;
}
+
+ /**
+ * 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}
--- a/src/com/beem/project/beem/service/RosterAdapter.java Thu Sep 10 16:29:28 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java Thu Sep 17 17:28:40 2009 +0200
@@ -176,7 +176,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());
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Sep 10 16:29:28 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Sep 17 17:28:40 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,6 +228,7 @@
}
/**
+ * Set the privacy list to use.
* @param mPrivacyList the mPrivacyList to set
*/
public void setPrivacyList(PrivacyListManagerAdapter mPrivacyList) {
@@ -218,6 +236,7 @@
}
/**
+ * Get the privacy list in use.
* @return the mPrivacyList
*/
public PrivacyListManagerAdapter getPrivacyList() {
--- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Thu Sep 10 16:29:28 2009 +0200
+++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Thu Sep 17 17:28:40 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 10 16:29:28 2009 +0200
+++ b/src/com/beem/project/beem/ui/AddContact.java Thu Sep 17 17:28:40 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 10 16:29:28 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Thu Sep 17 17:28:40 2009 +0200
@@ -39,6 +39,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;
/**
@@ -233,9 +234,24 @@
@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 10 16:29:28 2009 +0200
+++ b/src/com/beem/project/beem/ui/SendIM.java Thu Sep 17 17:28:40 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;
}