Creation de l'interface à distance pour la classe PrivacyListManager.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/PrivacyListItem.aidl Sun Nov 15 02:28:42 2009 +0100
@@ -0,0 +1,3 @@
+package com.beem.project.beem.service;
+
+parcelable PrivacyListItem;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/service/PrivacyListItem.java Sun Nov 15 02:28:42 2009 +0100
@@ -0,0 +1,64 @@
+package com.beem.project.beem.service;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+public class PrivacyListItem implements Parcelable {
+
+ private int mType;
+ private String mValue;
+
+ public static final Parcelable.Creator<PrivacyListItem> CREATOR = new Parcelable.Creator<PrivacyListItem>() {
+ public PrivacyListItem createFromParcel(Parcel in) {
+ return new PrivacyListItem(in);
+ }
+
+ public PrivacyListItem[] newArray(int size) {
+ return new PrivacyListItem[size];
+ }
+ };
+
+ public PrivacyListItem() {
+ }
+
+ public PrivacyListItem(Parcel in) {
+ readFromParcel(in);
+ }
+
+ public PrivacyListItem(int type, String value) {
+ mType = type;
+ mValue = value;
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ public void readFromParcel(Parcel in) {
+ mType = in.readInt();
+ mValue = in.readString();
+ }
+
+ @Override
+ public void writeToParcel(Parcel dest, int flags) {
+ dest.writeInt(mType);
+ dest.writeString(mValue);
+ }
+
+ public int getType() {
+ return mType;
+ }
+
+ public String getValue() {
+ return mValue;
+ }
+
+ public void setType(final int type) {
+ mType = type;
+ }
+
+ public void setValue(final String value) {
+ mValue = value;
+ }
+}
--- a/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java Sat Nov 14 23:53:18 2009 +0100
+++ b/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java Sun Nov 15 02:28:42 2009 +0100
@@ -1,169 +1,112 @@
package com.beem.project.beem.service;
-import java.util.ArrayList;
import java.util.List;
-import org.jivesoftware.smack.PrivacyList;
-import org.jivesoftware.smack.PrivacyListListener;
import org.jivesoftware.smack.PrivacyListManager;
import org.jivesoftware.smack.XMPPConnection;
-import org.jivesoftware.smack.XMPPException;
-import org.jivesoftware.smack.packet.PrivacyItem;
-import org.jivesoftware.smack.packet.PrivacyItem.PrivacyRule;
import android.os.RemoteException;
-import android.util.Log;
import com.beem.project.beem.service.aidl.IPrivacyListManager;
/**
- * Privacy list manager in beem.
- * @author nikita
+ * An adapter for the Smack's PrivacyListManager.
+ * @author Jean-Manuel Da Silva <dasilvj at beem-project dot com>
*/
public class PrivacyListManagerAdapter extends IPrivacyListManager.Stub {
/**
- * Tag.
+ * Class's Tag.
*/
public static final String TAG = "PrivacyListManagerAdapter";
- /**
- * default privacy list name.
- */
- public static final String DEFAULT_PRIVACYLIST = "BEEM_DEFAULT_PRIVACY_LIST";
- private PrivacyListManager mAdaptee;
- private List<String> mBlockedUsers = new ArrayList<String>();
+ private final PrivacyListManager mAdaptee;
private final XMPPConnection mConnection;
- private final MyPrivacyListListener mPrivacyPacketListener = new MyPrivacyListListener();
/**
- * Privacy list constructor.
- * @param connection xmppconnection used.
+ * Constructor.
+ * @param The XMPP connection that will be used by the PrivacyListManagerAdapter.
*/
public PrivacyListManagerAdapter(final XMPPConnection connection) {
mConnection = connection;
mAdaptee = PrivacyListManager.getInstanceFor(mConnection);
- mAdaptee.addListener(mPrivacyPacketListener);
}
- /**
- * Return the blocked user list.
- * @return blocked user list
- * @throws RemoteException
- */
- public List<String> getBlockedUsers() {
- return mBlockedUsers;
+ @Override
+ public void addPrivacyList(String listName) throws RemoteException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void blockUser(String listName, String jid) throws RemoteException {
+ // TODO Auto-generated method stub
+
}
- /**
- * Add a user to the blocked user list.
- * @param jid blocked user jid TODO: Ne bloque pas uniquement un utilisateur, fonction a d�couper/revoir
- */
- public synchronized void addBlockedUser(final String jid) {
- Log.d(TAG, "BEGIN addBlockedUser.");
- if (mAdaptee == null) {
- mAdaptee = PrivacyListManager.getInstanceFor(mConnection);
- mAdaptee.addListener(mPrivacyPacketListener);
- }
- List<PrivacyItem> pItemList = new ArrayList<PrivacyItem>();
- PrivacyItem pItem = new PrivacyItem(PrivacyItem.Type.jid.name(), true, 1);
- pItem.setFilterMessage(true);
- pItem.setValue(jid);
- pItemList.add(pItem);
+ @Override
+ public void createPrivacyList(String listName, List<PrivacyListItem> items) throws RemoteException {
+ // TODO Auto-generated method stub
- pItem = new PrivacyItem(PrivacyItem.Type.subscription.name(), true, 2);
- pItem.setValue(PrivacyRule.SUBSCRIPTION_BOTH);
- pItemList.add(pItem);
+ }
+
+ @Override
+ public void declineActivePrivacyList() throws RemoteException {
+ // TODO Auto-generated method stub
- try {
- if (mAdaptee.getPrivacyList(DEFAULT_PRIVACYLIST) == null) {
- mAdaptee.createPrivacyList(DEFAULT_PRIVACYLIST, pItemList);
- }
- } catch (XMPPException e) {
- Log.e(TAG, e.getMessage());
- } catch (ClassCastException e) {
- Log.e(TAG, e.getMessage());
- try {
- mAdaptee.createPrivacyList(DEFAULT_PRIVACYLIST, pItemList);
- } catch (XMPPException e1) {
- Log.e(TAG, e1.getMessage());
- }
- }
- try {
- mAdaptee.setActiveListName(DEFAULT_PRIVACYLIST);
- mAdaptee.setDefaultListName(DEFAULT_PRIVACYLIST);
- } catch (XMPPException e) {
- Log.e(TAG, e.getMessage());
- }
- Log.d(TAG, "END addBlockedUser.");
+ }
+
+ @Override
+ public void declineDefaultPrivacyList() throws RemoteException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void editPrivacyList(String listName, List<PrivacyListItem> items) throws RemoteException {
+ // TODO Auto-generated method stub
+
}
- /**
- * Return a list of users blocked for a specified list.
- * @param listName The list name that will be checked for blocked users.
- * @return A list of String which contains a user JID who is blocked by the user.
- * @throws RemoteException If a Binder remote-invocation error occurred.
- */
@Override
- public List<String> getBlockedUsersByList(String listName) throws RemoteException {
- List<String> blockedUsersList = new ArrayList<String>();
- try {
- PrivacyList pList = mAdaptee.getPrivacyList(listName);
- for (PrivacyItem p : pList.getItems()) {
- if (p.getType().equals(PrivacyItem.Type.jid) && !p.isAllow()) {
- blockedUsersList.add(p.getValue());
- }
- }
- } catch (XMPPException e) {
- Log.e(TAG, e.getMessage());
- }
- return blockedUsersList;
+ public String getActivePrivacyList() throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
}
- /**
- * Return the user's PrivacyListManager.
- * @return the current PrivacyListManager instance
- */
- public PrivacyListManager getManager() {
- return mAdaptee;
+ @Override
+ public void getBlockedGroupsByList(String listName, List<String> blockedGroupsByList) throws RemoteException {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void getBlockedUsersByList(String listName, List<String> blockedUsersByList) throws RemoteException {
+ // TODO Auto-generated method stub
+
}
- /**
- * A class which allows listening on a PrivacyList TODO: Besoin d'en discuter. Va t-on g�rer plusieurs listes ? Une
- * seule ?
- */
- class MyPrivacyListListener implements PrivacyListListener {
- /**
- * constructor.
- */
- public MyPrivacyListListener() {
- }
+ @Override
+ public String getDefaultPrivacyList() throws RemoteException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void removePrivacyList(String listName) throws RemoteException {
+ // TODO Auto-generated method stub
- @Override
- public void setPrivacyList(String listName, List<PrivacyItem> listItem) {
- Log.d(TAG, "BEGIN setPrivacyList.");
- try {
- if (mAdaptee.getPrivacyList(listName) == null)
- mAdaptee.createPrivacyList(listName, listItem);
- else
- mAdaptee.updatePrivacyList(listName, listItem);
- } catch (XMPPException e) {
- Log.e(TAG, e.getMessage());
- }
- Log.d(TAG, "END setPrivacyList.");
- }
+ }
+
+ @Override
+ public void setActivePrivacyList(String listName) throws RemoteException {
+ // TODO Auto-generated method stub
- @Override
- public void updatedPrivacyList(String listName) {
- Log.d(TAG, "BEGIN updatedPrivacyList.");
- if (listName.equals(DEFAULT_PRIVACYLIST)) {
- try {
- mBlockedUsers = getBlockedUsersByList(DEFAULT_PRIVACYLIST);
- } catch (RemoteException e) {
- Log.e(TAG, e.getMessage());
- }
- }
- Log.d(TAG, "END updatedPrivacyList.");
- }
+ }
+
+ @Override
+ public void setDefaultPrivacyList(String listName) throws RemoteException {
+ // TODO Auto-generated method stub
+
}
}
--- a/src/com/beem/project/beem/service/XmppFacade.java Sat Nov 14 23:53:18 2009 +0100
+++ b/src/com/beem/project/beem/service/XmppFacade.java Sun Nov 15 02:28:42 2009 +0100
@@ -25,9 +25,9 @@
*/
public class XmppFacade extends IXmppFacade.Stub {
- private XmppConnectionAdapter mConnexion;
- private BeemService mBeemService;
- private JingleService mJingle;
+ private final XmppConnectionAdapter mConnexion;
+ private final BeemService mBeemService;
+ private final JingleService mJingle;
/**
* Constructor for XMPPFacade.
@@ -124,11 +124,6 @@
}
@Override
- public void blockUser(String jid) throws RemoteException {
- mConnexion.getPrivacyList().addBlockedUser(jid);
- }
-
- @Override
public void call(String jid) throws RemoteException {
mJingle.call(jid);
}
--- a/src/com/beem/project/beem/service/aidl/IPrivacyListManager.aidl Sat Nov 14 23:53:18 2009 +0100
+++ b/src/com/beem/project/beem/service/aidl/IPrivacyListManager.aidl Sun Nov 15 02:28:42 2009 +0100
@@ -1,25 +1,33 @@
package com.beem.project.beem.service.aidl;
-
+import com.beem.project.beem.service.PrivacyListItem;
-/**
- * An aidl interface for Privacy List Manager.
- */
interface IPrivacyListManager {
- /**
- * @return: return a list of blocked users
- */
- List<String> getBlockedUsers();
+ void createPrivacyList(in String listName, in List<PrivacyListItem> items);
+
+ void addPrivacyList(in String listName);
+
+ void removePrivacyList(in String listName);
+
+ void editPrivacyList(in String listName, in List<PrivacyListItem> items);
+
+ String getActivePrivacyList();
+
+ String getDefaultPrivacyList();
+
+ void setActivePrivacyList(in String listName);
- /**
- * @return: return a list of blocked users
- */
- List<String> getBlockedUsersByList(in String listName);
+ void setDefaultPrivacyList(in String listName);
+
+ void declineActivePrivacyList();
- /**
- * @param: block an user
- */
- void addBlockedUser(in String jid);
-
+ void declineDefaultPrivacyList();
+
+ void blockUser(in String listName, in String jid);
+
+ void getBlockedUsersByList(in String listName, out List<String> blockedUsersByList);
+
+ void getBlockedGroupsByList(in String listName, out List<String> blockedGroupsByList);
+
}
\ No newline at end of file
--- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Sat Nov 14 23:53:18 2009 +0100
+++ b/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Sun Nov 15 02:28:42 2009 +0100
@@ -45,9 +45,7 @@
void changeStatus(in int status, in String msg);
void sendPresencePacket(in PresenceAdapter presence);
-
- void blockUser(in String jid);
-
+
/**
* make a jingle audio call
* @param jid the receiver id