Bundle pour debug avec nikita.
--- a/AndroidManifest.xml Thu Sep 24 21:41:20 2009 +0200
+++ b/AndroidManifest.xml Thu Sep 24 23:54:11 2009 +0200
@@ -2,7 +2,8 @@
<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" android:debuggable="true">
+ <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>
@@ -18,7 +19,11 @@
<activity android:name=".ui.EditSettings" android:label="@string/edit_settings_name" />
<activity android:name=".ui.CreateAccount" android:label="@string/create_account_name" />
<activity android:name=".ui.ContactList" android:label="@string/contact_list_name"
- android:launchMode="singleTask" />
+ android:launchMode="singleTask">
+ <intent-filter android:label="Beem Connection">
+ <action android:name="com.beem.project.beem.service.XmppConnectionAdapter.CONNECTION_CLOSED" />
+ </intent-filter>
+ </activity>
<service android:name="BeemService" android:enabled="true"
android:label="Beem Service" android:permission="com.beem.project.beem.BEEM_SERVICE">
<intent-filter>
--- a/src/com/beem/project/beem/BeemService.java Thu Sep 24 21:41:20 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java Thu Sep 24 23:54:11 2009 +0200
@@ -1,21 +1,16 @@
package com.beem.project.beem;
import org.jivesoftware.smack.ConnectionConfiguration;
-import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration.SecurityMode;
import org.jivesoftware.smack.Roster.SubscriptionMode;
-import org.jivesoftware.smack.filter.PacketFilter;
-import org.jivesoftware.smack.packet.Packet;
-import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.proxy.ProxyInfo;
import org.jivesoftware.smack.proxy.ProxyInfo.ProxyType;
import org.jivesoftware.smack.util.StringUtils;
import android.app.Notification;
import android.app.NotificationManager;
-import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
@@ -28,9 +23,7 @@
import com.beem.project.beem.jingle.JingleService;
import com.beem.project.beem.service.XmppConnectionAdapter;
import com.beem.project.beem.service.XmppFacade;
-import com.beem.project.beem.service.aidl.IBeemConnectionListener;
import com.beem.project.beem.service.aidl.IXmppFacade;
-import com.beem.project.beem.ui.Subscription;
/**
* This class is for the Beem service. The connection to the xmpp server will be made asynchronously when the service
@@ -76,7 +69,6 @@
* Initialise la configuration de la connexion.
*/
private void initConnectionConfig() {
- // TODO mettre a false par defaut et remplacer les valeurs par defaut
java.security.Security.addProvider(new com.sun.security.sasl.Provider());
mUseProxy = mSettings.getBoolean(getString(R.string.settings_key_proxy_use), false);
if (mUseProxy) {
@@ -108,116 +100,6 @@
}
/**
- * Initialize the listener for Roster request.
- */
- private void initRosterRequestListener() {
- Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
- final XMPPConnection con = mConnection.getAdaptee();
- try {
- // l'ajout d'un packet listener ne peut etre effectuer que lorsqu'on est connecte au
- // serveur
- mConnection.addConnectionListener(new IBeemConnectionListener.Stub() {
-
- @Override
- public void connectionClosed() throws RemoteException {
- Log.i("BeemService", "connectionClosed()");
- }
-
- @Override
- public void connectionClosedOnError() throws RemoteException {
- Log.i("BeemService", "connectionClosedOnError()");
-
- }
-
- @Override
- public void connectionFailed(String errorMsg) throws RemoteException {
- Log.i("BeemService", "connectionFailed()");
-
- }
-
- @Override
- public void onConnect() throws RemoteException {
- mJingle.initWhenConntected(mConnection.getAdaptee());
- PacketFilter filter = new PacketFilter() {
-
- @Override
- public boolean accept(Packet packet) {
- if (packet instanceof Presence) {
- Presence pres = (Presence) packet;
- if (pres.getType() == Presence.Type.subscribe)
- return true;
- }
- return false;
- }
- };
- con.addPacketListener(new PacketListener() {
-
- @Override
- public void processPacket(Packet packet) {
- String from = packet.getFrom();
- Notification notif = new Notification(com.beem.project.beem.R.drawable.signal,
- "Demande d'ajout", System.currentTimeMillis());
- notif.defaults = Notification.DEFAULT_ALL;
- notif.flags = Notification.FLAG_AUTO_CANCEL;
- Intent intent = new Intent(BeemService.this, Subscription.class);
- intent.putExtra("from", from);
- notif.setLatestEventInfo(BeemService.this, from, "demande d'ajout de " + from,
- PendingIntent.getActivity(BeemService.this, 0, intent, PendingIntent.FLAG_ONE_SHOT));
- int id = packet.hashCode();
- sendNotification(id, notif);
- }
- }, filter);
- // set status connect in the preferences
- // private static final int AVAILABLE_IDX = 5;
- Editor edit = mSettings.edit();
- edit.putInt(getString(R.string.PreferenceStatus), 1);
- edit.commit();
- }
-
- @Override
- public void reconnectingIn(int seconds) throws RemoteException {
- Log.i("BeemService", "reconnectingIn()");
-
- }
-
- @Override
- public void reconnectionFailed() throws RemoteException {
- Log.i("BeemService", "reconnectionFailed()");
-
- }
-
- @Override
- public void reconnectionSuccessful() throws RemoteException {
- Log.i("BeemService", "reconnectionSuccessful()");
- PacketFilter filter = new PacketFilter() {
-
- @Override
- public boolean accept(Packet packet) {
- if (packet instanceof Presence) {
- Presence pres = (Presence) packet;
- if (pres.getType() == Presence.Type.subscribe)
- return true;
- }
- return false;
- }
- };
- con.addPacketListener(new PacketListener() {
-
- @Override
- public void processPacket(Packet packet) {
- // TODO Auto-generated method stub
- Log.d("TEST", "Une demande recue");
- }
- }, filter);
- }
- });
- } catch (RemoteException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /**
* {@inheritDoc}
*/
@Override
@@ -239,7 +121,6 @@
mHost = mSettings.getString(getString(R.string.settings_key_xmpp_server), "");
mPort = Integer.parseInt(mSettings.getString(getString(R.string.settings_key_xmpp_port), "5222"));
- Log.i("BEEEMSERVICE", mLogin);
/*
* Gestion pour gmail.
*/
@@ -252,9 +133,10 @@
initConnectionConfig();
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword, this);
+
+ Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
+ mBind = new XmppFacade(mConnection, this, mJingle);
mJingle = new JingleService(mConnection.getAdaptee());
- initRosterRequestListener();
- mBind = new XmppFacade(mConnection, this, mJingle);
}
/**
@@ -277,7 +159,6 @@
try {
mConnection.connectAsync();
} catch (RemoteException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
@@ -291,4 +172,18 @@
mNotificationManager.notify(id, notif);
}
+ /**
+ * Reset the status to online after a deconnection.
+ */
+ public void resetStatus() {
+ Editor edit = mSettings.edit();
+ edit.putInt(getString(R.string.PreferenceStatus), 1);
+ edit.commit();
+ }
+
+ public void initJingle(XMPPConnection adaptee) {
+ mJingle.initWhenConntected(adaptee);
+
+ }
+
}
--- a/src/com/beem/project/beem/jingle/JingleService.java Thu Sep 24 21:41:20 2009 +0200
+++ b/src/com/beem/project/beem/jingle/JingleService.java Thu Sep 24 23:54:11 2009 +0200
@@ -40,6 +40,9 @@
mMediaManagers = new ArrayList<JingleMediaManager>();
mMediaManagers.add(new MicrophoneRTPManager(bt));
+ //mJingleManager = new JingleManager(xmppConnection, mMediaManagers);
+ //mJingleManager.addJingleSessionRequestListener(new BeemJingleSessionRequestListener());
+
}
/**
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Sep 24 21:41:20 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Thu Sep 24 23:54:11 2009 +0200
@@ -1,19 +1,22 @@
-/**
- *
- */
package com.beem.project.beem.service;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionListener;
+import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.PrivacyListManager;
import org.jivesoftware.smack.Roster;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
+import org.jivesoftware.smack.filter.PacketFilter;
+import org.jivesoftware.smack.packet.Packet;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smackx.ChatStateManager;
import org.jivesoftware.smackx.ServiceDiscoveryManager;
import org.jivesoftware.smackx.jingle.JingleManager;
+import android.app.Notification;
+import android.app.PendingIntent;
+import android.content.Intent;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.util.Log;
@@ -23,6 +26,7 @@
import com.beem.project.beem.service.aidl.IChatManager;
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppConnection;
+import com.beem.project.beem.ui.Subscription;
/**
* This class implements an adapter for XMPPConnection.
@@ -31,6 +35,7 @@
public class XmppConnectionAdapter extends IXmppConnection.Stub {
private static final String TAG = "XMPPConnectionAdapter";
+ public static final String BEEM_CONNECTION_CLOSED = "BeemConnectionClosed";
private XMPPConnection mAdaptee;
private IChatManager mChatManager;
private String mLogin;
@@ -249,6 +254,8 @@
*/
private class ConnexionListenerAdapter implements ConnectionListener {
+
+
/**
* Defaut constructor.
*/
@@ -276,6 +283,8 @@
}
}
mRemoteConnListeners.finishBroadcast();
+ Intent closedIntent = new Intent(BEEM_CONNECTION_CLOSED);
+ mService.sendBroadcast(closedIntent);
}
/**
@@ -322,6 +331,40 @@
* Method to execute when a connection event occurs.
*/
public void onConnect() {
+ PacketFilter filter = new PacketFilter() {
+
+ @Override
+ public boolean accept(Packet packet) {
+ if (packet instanceof Presence) {
+ Presence pres = (Presence) packet;
+ if (pres.getType() == Presence.Type.subscribe)
+ return true;
+ }
+ return false;
+ }
+ };
+
+ mAdaptee.addPacketListener(new PacketListener() {
+
+ @Override
+ public void processPacket(Packet packet) {
+ String from = packet.getFrom();
+ Notification notif = new Notification(com.beem.project.beem.R.drawable.signal,
+ "Demande d'ajout", System.currentTimeMillis());
+ notif.defaults = Notification.DEFAULT_ALL;
+ notif.flags = Notification.FLAG_AUTO_CANCEL;
+ Intent intent = new Intent(mService, Subscription.class);
+ intent.putExtra("from", from);
+ notif.setLatestEventInfo(mService, from, "demande d'ajout de " + from,
+ PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT));
+ int id = packet.hashCode();
+ mService.sendNotification(id, notif);
+ }
+ }, filter);
+
+ mService.resetStatus();
+ mService.initJingle(mAdaptee);
+
final int n = mRemoteConnListeners.beginBroadcast();
for (int i = 0; i < n; i++) {
@@ -385,6 +428,38 @@
*/
@Override
public void reconnectionSuccessful() {
+ PacketFilter filter = new PacketFilter() {
+
+ @Override
+ public boolean accept(Packet packet) {
+ if (packet instanceof Presence) {
+ Presence pres = (Presence) packet;
+ if (pres.getType() == Presence.Type.subscribe)
+ return true;
+ }
+ return false;
+ }
+ };
+
+ mAdaptee.addPacketListener(new PacketListener() {
+
+ @Override
+ public void processPacket(Packet packet) {
+ String from = packet.getFrom();
+ Notification notif = new Notification(com.beem.project.beem.R.drawable.signal,
+ "Demande d'ajout", System.currentTimeMillis());
+ notif.defaults = Notification.DEFAULT_ALL;
+ notif.flags = Notification.FLAG_AUTO_CANCEL;
+ Intent intent = new Intent(mService, Subscription.class);
+ intent.putExtra("from", from);
+ notif.setLatestEventInfo(mService, from, "demande d'ajout de " + from,
+ PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT));
+ int id = packet.hashCode();
+ mService.sendNotification(id, notif);
+ }
+ }, filter);
+
+
final int n = mRemoteConnListeners.beginBroadcast();
for (int i = 0; i < n; i++) {
--- a/src/com/beem/project/beem/ui/ContactList.java Thu Sep 24 21:41:20 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Thu Sep 24 23:54:11 2009 +0200
@@ -8,9 +8,11 @@
import org.jivesoftware.smack.util.StringUtils;
import android.app.Activity;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.IntentFilter;
import android.content.ServiceConnection;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
@@ -37,6 +39,7 @@
import com.beem.project.beem.R;
import com.beem.project.beem.service.Contact;
import com.beem.project.beem.service.PresenceAdapter;
+import com.beem.project.beem.service.XmppConnectionAdapter;
import com.beem.project.beem.service.aidl.IBeemRosterListener;
import com.beem.project.beem.service.aidl.IRoster;
import com.beem.project.beem.service.aidl.IXmppFacade;
@@ -71,6 +74,7 @@
setContentView(R.layout.contactlist);
mAdapter = new BeemContactList(this);
mHandler = new Handler();
+ this.registerReceiver(new BeemBroadcastReceiver(), new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED));
}
@@ -343,10 +347,22 @@
}
@Override
+<<<<<<< local
public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException {
+=======
+ public void onEntryDeleteFromGroup(String group, String jid)
+ throws RemoteException {
+>>>>>>> other
// TODO Auto-generated method stub
+<<<<<<< local
+=======
+
+>>>>>>> other
}
+<<<<<<< local
+=======
+>>>>>>> other
/**
* {@inheritDoc}
*/
@@ -377,6 +393,11 @@
}
}
}
+<<<<<<< local
+=======
+
+
+>>>>>>> other
}
/**
@@ -566,6 +587,7 @@
} catch (RemoteException e) {
e.printStackTrace();
}
+
}
@Override
@@ -579,4 +601,14 @@
mRoster = null;
}
}
+
+ private class BeemBroadcastReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(TAG, "broadcast received");
+
+ }
+
+ }
}
--- a/src/com/beem/project/beem/ui/Subscription.java Thu Sep 24 21:41:20 2009 +0200
+++ b/src/com/beem/project/beem/ui/Subscription.java Thu Sep 24 23:54:11 2009 +0200
@@ -29,72 +29,72 @@
*/
public class Subscription extends Activity {
- public static final String TAG = "Subscription";
- private IXmppFacade mService;
- private String mContact;
- private ServiceConnection mServConn = new BeemServiceConnection();
+ public static final String TAG = "Subscription";
+ private IXmppFacade mService;
+ private String mContact;
+ private ServiceConnection mServConn = new BeemServiceConnection();
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.subscription);
+ bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
+ findViewById(R.id.SubscriptionAccept).setOnClickListener(mClickListener);
+ findViewById(R.id.SubscriptionRefuse).setOnClickListener(mClickListener);
+ mContact = getIntent().getStringExtra("from");
+ TextView tv = (TextView) findViewById(R.id.SubscriptionText);
+ String str = String.format(getString(R.string.SubscriptText), mContact);
+ tv.setText(str);
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ unbindService(mServConn);
+ }
+
+ private OnClickListener mClickListener = new OnClickListener() {
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.subscription);
- bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE);
- findViewById(R.id.SubscriptionAccept).setOnClickListener(mClickListener);
- findViewById(R.id.SubscriptionRefuse).setOnClickListener(mClickListener);
- mContact = getIntent().getStringExtra("from");
- TextView tv = (TextView) findViewById(R.id.SubscriptionText);
- String str = String.format(getString(R.string.SubscriptText), mContact);
- tv.setText(str);
+ public void onClick(View v) {
+ switch (v.getId()) {
+ case R.id.SubscriptionAccept:
+ Presence presence = new Presence(Type.subscribed);
+ presence.setTo(mContact);
+ PresenceAdapter preAdapt = new PresenceAdapter(presence);
+ try {
+ mService.sendPresencePacket(preAdapt);
+ Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept),
+ Toast.LENGTH_SHORT).show();
+ finish();
+ } catch (RemoteException e) {
+ Toast.makeText(Subscription.this, getString(R.string.SubscriptError),
+ Toast.LENGTH_SHORT).show();
+ e.printStackTrace();
+ }
+ break ;
+ case R.id.SubscriptionRefuse:
+ Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused),
+ Toast.LENGTH_SHORT).show();
+
+ break ;
+ default:
+ Toast.makeText(Subscription.this, getString(R.string.SubscriptError),
+ Toast.LENGTH_SHORT).show();
+ };
+ }
+ };
+
+ private class BeemServiceConnection implements ServiceConnection {
+
+ @Override
+ public void onServiceConnected(ComponentName name, IBinder service) {
+ mService = IXmppFacade.Stub.asInterface(service);
}
@Override
- protected void onDestroy() {
- super.onDestroy();
- unbindService(mServConn);
+ public void onServiceDisconnected(ComponentName name) {
+ mService = null;
}
-
- private OnClickListener mClickListener = new OnClickListener() {
-
- @Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.SubscriptionAccept:
- Presence presence = new Presence(Type.subscribed);
- presence.setTo(mContact);
- PresenceAdapter preAdapt = new PresenceAdapter(presence);
- try {
- mService.sendPresencePacket(preAdapt);
- Toast.makeText(Subscription.this, getString(R.string.SubscriptAccept),
- Toast.LENGTH_SHORT).show();
- finish();
- } catch (RemoteException e) {
- Toast.makeText(Subscription.this, getString(R.string.SubscriptError),
- Toast.LENGTH_SHORT).show();
- e.printStackTrace();
- }
- break ;
- case R.id.SubscriptionRefuse:
- Toast.makeText(Subscription.this, getString(R.string.SubscriptRefused),
- Toast.LENGTH_SHORT).show();
-
- break ;
- default:
- Toast.makeText(Subscription.this, getString(R.string.SubscriptError),
- Toast.LENGTH_SHORT).show();
- };
- }
- };
-
- private class BeemServiceConnection implements ServiceConnection {
-
- @Override
- public void onServiceConnected(ComponentName name, IBinder service) {
- mService = IXmppFacade.Stub.asInterface(service);
- }
-
- @Override
- public void onServiceDisconnected(ComponentName name) {
- mService = null;
- }
- }
+ }
}