debut de la gestion de la PrivacyList
authornikita@localhost
Mon, 22 Jun 2009 18:07:29 +0200
changeset 262 0548b407992a
parent 261 e082fd525147 (diff)
parent 260 0ce1e306fdd3 (current diff)
child 263 ff0b4790a5ed
child 264 454a83b47bcd
child 269 d78115a6b45b
debut de la gestion de la PrivacyList
src/com/beem/project/beem/service/XmppConnectionAdapter.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/PrivacyListAdapter.java	Mon Jun 22 18:07:29 2009 +0200
@@ -0,0 +1,39 @@
+/**
+ * 
+ */
+package com.beem.project.beem.service;
+
+import java.util.List;
+
+import org.jivesoftware.smack.PrivacyListListener;
+import org.jivesoftware.smack.PrivacyListManager;
+import org.jivesoftware.smack.packet.PrivacyItem;
+
+/**
+ * @author nikita
+ *
+ */
+public class PrivacyListAdapter {
+    private PrivacyListManager mAdaptee = null;
+   
+    
+    public PrivacyListAdapter(PrivacyListManager manager) {
+	mAdaptee = manager;
+    }
+    
+    class MyPrivacyListListener implements PrivacyListListener {
+
+	@Override
+	public void setPrivacyList(String listName, List<PrivacyItem> listItem) {
+	    // TODO Auto-generated method stub
+	    
+	}
+
+	@Override
+	public void updatedPrivacyList(String listName) {
+	    // TODO Auto-generated method stub
+	    
+	}
+	
+    }    
+}
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Mon Jun 22 15:48:56 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java	Mon Jun 22 18:07:29 2009 +0200
@@ -5,6 +5,7 @@
 
 import org.jivesoftware.smack.ConnectionConfiguration;
 import org.jivesoftware.smack.ConnectionListener;
+import org.jivesoftware.smack.PrivacyListManager;
 import org.jivesoftware.smack.Roster;
 import org.jivesoftware.smack.XMPPConnection;
 import org.jivesoftware.smack.XMPPException;
@@ -28,6 +29,182 @@
  */
 public class XmppConnectionAdapter extends IXmppConnection.Stub {
 
+    private static final String TAG = "XMPPConnectionAdapter";
+    private XMPPConnection mAdaptee;
+    private IChatManager mChatManager;
+    private String mLogin;
+    private String mPassword;
+    private RosterAdapter mRoster;
+    private PrivacyListAdapter mPrivacyList;
+    private BeemService mService;
+    private RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners = new RemoteCallbackList<IBeemConnectionListener>();
+
+    private ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter();
+
+    /**
+     * Constructor.
+     * @param config Configuration to use in order to connect
+     * @param login login to use on connect
+     * @param password password to use on connect
+     */
+    public XmppConnectionAdapter(final ConnectionConfiguration config, final String login, final String password,
+	BeemService service) {
+	this(new XMPPConnection(config), login, password, service);
+    }
+
+    /**
+     * Constructor.
+     * @param serviceName name of the service to connect to
+     * @param login login to use on connect
+     * @param password password to use on connect
+     */
+    public XmppConnectionAdapter(final String serviceName, final String login, final String password,
+	BeemService service) {
+	this(new XMPPConnection(serviceName), login, password, service);
+    }
+
+    /**
+     * Constructor.
+     * @param con The connection to adapt
+     * @param login The login to use
+     * @param password The password to use
+     */
+    public XmppConnectionAdapter(final XMPPConnection con, final String login, final String password,
+	BeemService service) {
+	mAdaptee = con;
+	mLogin = login;
+	mPassword = password;
+	mService = service;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void addConnectionListener(IBeemConnectionListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteConnListeners.register(listen);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public final void connectAsync() throws RemoteException {
+	Thread t = new Thread(new Runnable() {
+
+	    @Override
+	    public void run() {
+		try {
+		    connectSync();
+		} catch (RemoteException e) {
+		    Log.e(TAG, "Error while connecting", e);
+		}
+	    }
+	});
+	t.start();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean connectSync() throws RemoteException {
+	try {
+	    mAdaptee.connect();
+	    mAdaptee.addConnectionListener(mConListener);
+	    mAdaptee.login(mLogin, mPassword, "BEEM");
+
+	    mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService);
+	    // TODO find why this cause a null pointer exception
+	    this.initFeatures(); // pour declarer les features xmpp qu'on supporte
+	    mPrivacyList = new PrivacyListAdapter(PrivacyListManager.getInstanceFor(mAdaptee));
+	    ChatStateManager.getInstance(mAdaptee);
+	    triggerAsynchronousConnectEvent();
+	    return true;
+	} catch (XMPPException e) {
+	    Log.e(TAG, "Error while connecting", e);
+	    mConListener.connectionFailed("Error On Connection");
+	}
+	return false;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean disconnect() {
+	if (mAdaptee != null && mAdaptee.isConnected())
+	    mAdaptee.disconnect();
+	return true;
+    }
+
+    public XMPPConnection getAdaptee() {
+	return mAdaptee;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IChatManager getChatManager() throws RemoteException {
+	return mChatManager;
+    }
+
+    public BeemService getContext() {
+	return mService;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public IRoster getRoster() throws RemoteException {
+	if (mRoster != null)
+	    return mRoster;
+	Roster adap = mAdaptee.getRoster();
+	if (adap == null)
+	    return null;
+	mRoster = new RosterAdapter(adap);
+	return mRoster;
+    }
+
+    /**
+     * enregistre les features dispo dans notre version Liste de features que Telepathy supporte.
+     */
+    private void initFeatures() {
+	ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mAdaptee);
+	if (sdm == null)
+	    sdm = new ServiceDiscoveryManager(mAdaptee);
+	sdm.addFeature("http://jabber.org/protocol/disco#info");
+	JingleManager.setJingleServiceEnabled();
+	// sdm.addFeature("http://jabber.org/protocol/nick");
+
+    }
+
+    /**
+     * Returns true if currently authenticated by successfully calling the login method.
+     * @return true when successfully authenticated
+     */
+    public boolean isAuthentificated() {
+	return mAdaptee.isAuthenticated();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void removeConnectionListener(IBeemConnectionListener listen) throws RemoteException {
+	if (listen != null)
+	    mRemoteConnListeners.unregister(listen);
+    }
+
+    /**
+     * Trigger Connection event.
+     */
+    private void triggerAsynchronousConnectEvent() {
+	mConListener.onConnect();
+    }
     /**
      * Listener for XMPP connection events. It will calls the remote listeners for connexion events.
      * @author darisk
@@ -38,7 +215,6 @@
 	 * Defaut constructor.
 	 */
 	public ConnexionListenerAdapter() {
-	    // TODO Auto-generated constructor stub
 	}
 
 	/**
@@ -180,180 +356,4 @@
 	}
     }
 
-    private static final String TAG = "XMPPConnectionAdapter";
-    private XMPPConnection mAdaptee;
-    private IChatManager mChatManager;
-    private String mLogin;
-    private String mPassword;
-    private RosterAdapter mRoster;
-
-    private BeemService mService;
-    private RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners = new RemoteCallbackList<IBeemConnectionListener>();
-
-    private ConnexionListenerAdapter mConListener = new ConnexionListenerAdapter();
-
-    /**
-     * Constructor.
-     * @param config Configuration to use in order to connect
-     * @param login login to use on connect
-     * @param password password to use on connect
-     */
-    public XmppConnectionAdapter(final ConnectionConfiguration config, final String login, final String password,
-	BeemService service) {
-	this(new XMPPConnection(config), login, password, service);
-    }
-
-    /**
-     * Constructor.
-     * @param serviceName name of the service to connect to
-     * @param login login to use on connect
-     * @param password password to use on connect
-     */
-    public XmppConnectionAdapter(final String serviceName, final String login, final String password,
-	BeemService service) {
-	this(new XMPPConnection(serviceName), login, password, service);
-    }
-
-    /**
-     * Constructor.
-     * @param con The connection to adapt
-     * @param login The login to use
-     * @param password The password to use
-     */
-    public XmppConnectionAdapter(final XMPPConnection con, final String login, final String password,
-	BeemService service) {
-	mAdaptee = con;
-	mLogin = login;
-	mPassword = password;
-	mService = service;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void addConnectionListener(IBeemConnectionListener listen) throws RemoteException {
-	if (listen != null)
-	    mRemoteConnListeners.register(listen);
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public final void connectAsync() throws RemoteException {
-	Thread t = new Thread(new Runnable() {
-
-	    @Override
-	    public void run() {
-		try {
-		    connectSync();
-		} catch (RemoteException e) {
-		    Log.e(TAG, "Error while connecting", e);
-		}
-	    }
-	});
-	t.start();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean connectSync() throws RemoteException {
-	try {
-	    mAdaptee.connect();
-	    mAdaptee.addConnectionListener(mConListener);
-	    mAdaptee.login(mLogin, mPassword, "BEEM");
-
-	    mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService);
-	    // TODO find why this cause a null pointer exception
-	    this.initFeatures(); // pour declarer les features xmpp qu'on supporte
-	    ChatStateManager.getInstance(mAdaptee);
-	    triggerAsynchronousConnectEvent();
-	    return true;
-	} catch (XMPPException e) {
-	    Log.e(TAG, "Error while connecting", e);
-	    mConListener.connectionFailed("Error On Connection");
-	}
-	return false;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public boolean disconnect() {
-	if (mAdaptee != null && mAdaptee.isConnected())
-	    mAdaptee.disconnect();
-	return true;
-    }
-
-    public XMPPConnection getAdaptee() {
-	return mAdaptee;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IChatManager getChatManager() throws RemoteException {
-	return mChatManager;
-    }
-
-    public BeemService getContext() {
-	return mService;
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public IRoster getRoster() throws RemoteException {
-	if (mRoster != null)
-	    return mRoster;
-	Roster adap = mAdaptee.getRoster();
-	if (adap == null)
-	    return null;
-	mRoster = new RosterAdapter(adap);
-	return mRoster;
-    }
-
-    /**
-     * enregistre les features dispo dans notre version Liste de features que Telepathy supporte.
-     */
-    private void initFeatures() {
-	ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mAdaptee);
-	if (sdm == null)
-	    sdm = new ServiceDiscoveryManager(mAdaptee);
-	sdm.addFeature("http://jabber.org/protocol/disco#info");
-	JingleManager.setJingleServiceEnabled();
-	// sdm.addFeature("http://jabber.org/protocol/nick");
-
-    }
-
-    /**
-     * Returns true if currently authenticated by successfully calling the login method.
-     * @return true when successfully authenticated
-     */
-    public boolean isAuthentificated() {
-	return mAdaptee.isAuthenticated();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
-    @Override
-    public void removeConnectionListener(IBeemConnectionListener listen) throws RemoteException {
-	if (listen != null)
-	    mRemoteConnListeners.unregister(listen);
-    }
-
-    /**
-     * Trigger Connection event.
-     */
-    private void triggerAsynchronousConnectEvent() {
-	mConListener.onConnect();
-    }
-
 }