First commit of jingle demo
authorDa Risk <darisk972@gmail.com>
Fri, 25 Sep 2009 15:14:49 +0200
changeset 387 055bfaf224ce
parent 383 228b20eb8b44
child 388 21f8a872962f
First commit of jingle demo
AndroidManifest.xml
res/layout/jingle_call_activity.xml
src/com/beem/project/beem/jingle/JingleService.java
src/com/beem/project/beem/jingle/demo/JingleCallActivity.java
--- a/AndroidManifest.xml	Fri Sep 25 00:05:26 2009 +0200
+++ b/AndroidManifest.xml	Fri Sep 25 15:14:49 2009 +0200
@@ -24,6 +24,12 @@
 				<action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
 			</intent-filter>
 		</activity>
+		<activity android:name=".jingle.demo.JingleCallActivity" android:label="JingleDemoCall">
+			<intent-filter>
+				<action android:name="android.intent.action.MAIN" />
+				<category android:name="android.intent.category.LAUNCHER" />
+			</intent-filter>
+		</activity>
 		<service android:name="BeemService" android:enabled="true"
 			android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
 			<intent-filter>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/res/layout/jingle_call_activity.xml	Fri Sep 25 15:14:49 2009 +0200
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+	android:layout_width="wrap_content" android:layout_height="wrap_content"
+	android:orientation="vertical">
+	<TextView android:text="Jid:" android:id="@+id/jingledemocalljidlabel"
+		android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+	<EditText android:id="@+id/jingledemocalljid"
+		android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
+	<TextView android:text="Password:" android:id="@+id/jingledemocallpasswordlabel"
+		android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+	<EditText android:id="@+id/jingledemocallpassword"
+		android:layout_width="fill_parent" android:layout_height="wrap_content" android:inputType="textPassword" ></EditText>
+
+	<Button android:text="Connexion" android:id="@+id/jingledemocallconnectbutton"
+		android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
+	<TextView android:text="Call who :" android:id="@+id/jingledemocallreceiverlabel"
+		android:layout_width="wrap_content" android:layout_height="wrap_content"></TextView>
+
+<EditText android:text="" android:id="@+id/jingledemocallreceiver" android:layout_width="fill_parent" android:layout_height="wrap_content"></EditText>
+
+<Button android:text="Call" android:id="@+id/jingledemocallbutton" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
+</LinearLayout>
--- a/src/com/beem/project/beem/jingle/JingleService.java	Fri Sep 25 00:05:26 2009 +0200
+++ b/src/com/beem/project/beem/jingle/JingleService.java	Fri Sep 25 15:14:49 2009 +0200
@@ -40,8 +40,8 @@
 
 	mMediaManagers = new ArrayList<JingleMediaManager>();
 	mMediaManagers.add(new MicrophoneRTPManager(bt));
-	//mJingleManager = new JingleManager(xmppConnection, mMediaManagers);
-	//mJingleManager.addJingleSessionRequestListener(new BeemJingleSessionRequestListener());
+	mJingleManager = new JingleManager(xmppConnection, mMediaManagers);
+	mJingleManager.addJingleSessionRequestListener(new BeemJingleSessionRequestListener());
 
     }
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/jingle/demo/JingleCallActivity.java	Fri Sep 25 15:14:49 2009 +0200
@@ -0,0 +1,86 @@
+/**
+ * 
+ */
+package com.beem.project.beem.jingle.demo;
+
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.XMPPConnection;
+import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.util.StringUtils;
+
+import com.beem.project.beem.R;
+import com.beem.project.beem.jingle.JingleService;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.view.View.OnClickListener;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+/**
+ * @author darisk
+ * 
+ */
+public class JingleCallActivity extends Activity {
+
+    private XMPPConnection con;
+    private ConnectionConfiguration conf;
+    private JingleService jingle;
+
+    private Button btconnect;
+    private Button btcall;
+    private EditText mEdJID;
+    private EditText mEdPassword;
+    private EditText mEdReceiver;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+	// TODO Auto-generated method stub
+	super.onCreate(savedInstanceState);
+	setContentView(R.layout.jingle_call_activity);
+	// localhost
+	conf = new ConnectionConfiguration("10.0.2.2", 5222);
+	
+	mEdJID = (EditText) findViewById(R.id.jingledemocalljid);
+	mEdPassword = (EditText) findViewById(R.id.jingledemocallpassword);
+	mEdReceiver = (EditText) findViewById(R.id.jingledemocallreceiver);
+	btconnect = (Button) findViewById(R.id.jingledemocallconnectbutton);
+	btconnect.setOnClickListener(new OnClickListener() {
+
+	    @Override
+	    public void onClick(View arg0) {
+		String jid = mEdJID.getText().toString();
+		String login = StringUtils.parseName(jid);
+		con = new XMPPConnection(conf);
+		String password = mEdPassword.getText().toString();
+		try {
+		    con.connect();
+	            con.login(login, password);
+	            jingle = new JingleService(con);
+	            btcall.setEnabled(true);
+                } catch (XMPPException e) {
+	            // TODO Auto-generated catch block
+	            e.printStackTrace();
+                }
+	    }
+
+	});
+	btcall = (Button) findViewById(R.id.jingledemocallbutton);
+	btcall.setOnClickListener(new OnClickListener() {
+	
+	    @Override
+	    public void onClick(View arg0) {
+		String jid = mEdReceiver.getText().toString();
+		if (!"".equals(jid)){
+		    jingle.call(jid);
+		    Toast.makeText(JingleCallActivity.this, "Appel en cours", Toast.LENGTH_SHORT);
+		}else
+		    Toast.makeText(JingleCallActivity.this, "Remplir le champ (JID complet en  toto@tutu.com/truc)", Toast.LENGTH_SHORT);
+	    }
+	});
+
+    }
+
+}