# HG changeset patch # User Nikita Kozlov # Date 1320550029 -3600 # Node ID f7cfc4a68225252085cbfba704456413eb66ab62 # Parent d697250668afc5c085e2ae6c89f5f0b9bbb93e04 Big Big Clean : Remove adapter + remove aidl + remove privacylist(sorry manu) diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/BeemService.java Sun Nov 06 04:27:09 2011 +0100 @@ -60,7 +60,6 @@ import org.jivesoftware.smackx.pubsub.provider.PubSubProvider; import android.app.Notification; -import android.app.NotificationManager; import android.app.Service; import android.content.BroadcastReceiver; import android.content.Context; @@ -79,8 +78,6 @@ import android.util.Log; import com.beem.project.beem.service.XmppConnectionAdapter; -import com.beem.project.beem.service.XmppFacade; -import com.beem.project.beem.service.aidl.IXmppFacade; import com.beem.project.beem.smack.avatar.AvatarMetadataProvider; import com.beem.project.beem.smack.avatar.AvatarProvider; import com.beem.project.beem.smack.caps.CapsProvider; @@ -107,7 +104,6 @@ private Map mConnection = new HashMap(); private Map mBeemConnection = new HashMap(); - private Map mBind = new HashMap(); private boolean mOnOffReceiverIsRegistered; private Handler mHandler; @@ -225,15 +221,6 @@ } /** - * Return a bind to an XmppFacade instance. - * @return IXmppFacade a bind to an XmppFacade instance - */ - public IXmppFacade getBind() { - //TODO: ?? Never bind to the service ?? - return null; - } - - /** * Get the preference of the service. * @return the preference */ @@ -481,7 +468,6 @@ Log.i(TAG, "Starting connection of " + accountName); if (beemcoAdapter.connectSync()) { mConnection.put(accountName, beemcoAdapter); - mBind.put(accountName, new XmppFacade(beemcoAdapter)); res.setAction(BeemIntent.ACTION_CONNECTED); Log.e(TAG, "Account configuration : " + accountName + " DONE"); } else { diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/BeemChatManager.java --- a/src/com/beem/project/beem/service/BeemChatManager.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,328 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - - */ -package com.beem.project.beem.service; - -import java.io.File; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.jivesoftware.smack.Chat; -import org.jivesoftware.smack.ChatManager; -import org.jivesoftware.smack.ChatManagerListener; - -import android.app.Notification; -import android.app.PendingIntent; -import android.content.ContentValues; -import android.content.Intent; -import android.content.SharedPreferences; -import android.os.Environment; -import android.os.RemoteCallbackList; -import android.os.RemoteException; -import android.preference.PreferenceManager; -import android.util.Log; - -import com.beem.project.beem.BeemApplication; -import com.beem.project.beem.BeemService; -import com.beem.project.beem.providers.Messages; -import com.beem.project.beem.service.aidl.IChat; -import com.beem.project.beem.service.aidl.IChatManager; -import com.beem.project.beem.service.aidl.IChatManagerListener; -import com.beem.project.beem.service.aidl.IMessageListener; -import com.beem.project.beem.service.aidl.IRoster; - -/** - * An adapter for smack's ChatManager. This class provides functionnality to handle chats. - * @author darisk - */ -public class BeemChatManager extends IChatManager.Stub { - - private static final String TAG = "BeemChatManager"; - private final ChatManager mAdaptee; - private final Map mChats = new HashMap(); - private final ChatListener mChatListener = new ChatListener(); - private final RemoteCallbackList mRemoteChatCreationListeners = new RemoteCallbackList(); - private final BeemService mService; - - /** - * Constructor. - * @param chatManager the smack ChatManager to adapt - * @param service the service which runs the chat manager - */ - public BeemChatManager(final ChatManager chatManager, final BeemService service) { - mService = service; - mAdaptee = chatManager; - //mAdaptee.addChatListener(mChatListener); - } - - @Override - public void addChatCreationListener(IChatManagerListener listener) throws RemoteException { - if (listener != null) - mRemoteChatCreationListeners.register(listener); - } - - /** - * Create a chat session. - * @param contact the contact you want to chat with - * @param listener listener to use for chat events on this chat session - * @return the chat session - */ - @Override - public IChat createChat(Contact contact, IMessageListener listener) { - String jid = contact.getJIDWithRes(); - Log.d(TAG, "Get chat key1 = "); - - return createChat(jid, listener); - } - - /** - * Create a chat session. - * @param jid the jid of the contact you want to chat with - * @param listener listener to use for chat events on this chat session - * @return the chat session - */ - public IChat createChat(String jid, IMessageListener listener) { - String key = jid; - ChatAdapter result; - Log.d(TAG, "Get chat key2 = "); - if (mChats.containsKey(key)) { - result = mChats.get(key); - result.addMessageListener(listener); - return result; - } - Chat c = mAdaptee.createChat(key, null); - // maybe a little probleme of thread synchronization - // if so use an HashTable instead of a HashMap for mChats - result = getChat(c); - result.addMessageListener(listener); - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public void destroyChat(IChat chat) throws RemoteException { - // Can't remove it. otherwise we will lose all futur message in this chat - // chat.removeMessageListener(mChatListener); - if (chat == null) - return; - deleteChatNotification(chat); - mChats.remove(chat.getParticipant().getJID()); - } - - /** - * {@inheritDoc} - */ - @Override - public void deleteChatNotification(IChat chat) { - // try { - // //TODO: BeemNotification.BindNotification(BeemChatManager.this).deleteNotification(chat.getParticipant().getJID().hashCode()); - // } catch (RemoteException e) { - // Log.v(TAG, "Remote exception ", e); - // } - } - - /** - * Get an existing ChatAdapter or create it if necessary. - * @param chat The real instance of smack chat - * @return a chat adapter register in the manager - */ - private ChatAdapter getChat(Chat chat) { - String key = chat.getParticipant(); - if (mChats.containsKey(key)) { - return mChats.get(key); - } - ChatAdapter res = new ChatAdapter(chat); - boolean history = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getBoolean( - "settings_key_history", false); - String accountUser = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getString( - BeemApplication.ACCOUNT_USERNAME_KEY, ""); - String historyPath = PreferenceManager.getDefaultSharedPreferences(mService.getBaseContext()).getString( - BeemApplication.CHAT_HISTORY_KEY, ""); - if ("".equals(historyPath)) - historyPath = "/Android/data/com.beem.project.beem/chat/"; - res.setHistory(history); - res.setAccountUser(accountUser); - res.setHistoryPath(new File(Environment.getExternalStorageDirectory(), historyPath)); - Log.d(TAG, "getChat put " + key); - mChats.put(key, res); - return res; - } - - @Override - public ChatAdapter getChat(Contact contact) { - String key = contact.getJIDWithRes(); - return mChats.get(key); - } - - /** - * This methods permits to retrieve the list of contacts who have an opened chat session with us. - * @return An List containing Contact instances. - * @throws RemoteException If a Binder remote-invocation error occurred. - */ - public List getOpenedChatList() throws RemoteException { - List openedChats = new ArrayList(); - IRoster mRoster = mService.getBind().getRoster(); - - for (ChatAdapter chat : mChats.values()) { - if (chat.getMessages().size() > 0) { - Contact t = mRoster.getContact(chat.getParticipant().getJID()); - if (t == null) - t = new Contact(chat.getParticipant().getJID()); - openedChats.add(t); - } - } - return openedChats; - } - - /** - * {@inheritDoc} - */ - @Override - public void removeChatCreationListener(IChatManagerListener listener) throws RemoteException { - if (listener != null) - mRemoteChatCreationListeners.unregister(listener); - } - - /** - * A listener for all the chat creation event that happens on the connection. - * @author darisk - */ - private class ChatListener extends IMessageListener.Stub implements ChatManagerListener { - - /** - * Constructor. - */ - public ChatListener() { - } - - /** - * {@inheritDoc} - */ - @Override - public void chatCreated(Chat chat, boolean locally) { - IChat newchat = getChat(chat); - Log.d(TAG, "Chat" + chat.toString() + " created locally " + locally + "with " + chat.getParticipant()); - try { - newchat.addMessageListener(mChatListener); - final int n = mRemoteChatCreationListeners.beginBroadcast(); - - for (int i = 0; i < n; i++) { - IChatManagerListener listener = mRemoteChatCreationListeners.getBroadcastItem(i); - listener.chatCreated(newchat, locally); - } - mRemoteChatCreationListeners.finishBroadcast(); - } catch (RemoteException e) { - // The RemoteCallbackList will take care of removing the - // dead listeners. - Log.w(TAG, " Error while triggering remote connection listeners in chat creation", e); - } - } - - /** - * Create the PendingIntent to launch our activity if the user select this chat notification. - * @param chat A ChatAdapter instance - * @return A Chat activity PendingIntent - */ - private PendingIntent makeChatIntent(IChat chat) { - Intent chatIntent = new Intent(mService, com.beem.project.beem.ui.Chat.class); - chatIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP - | Intent.FLAG_ACTIVITY_NEW_TASK); - try { - chatIntent.setData(chat.getParticipant().toUri()); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - PendingIntent contentIntent = PendingIntent.getActivity(mService, 0, chatIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - return contentIntent; - } - - /** - * Set a notification of a new chat. - * @param chat The chat to access by the notification - * @param msgBody the body of the new message - */ - private void notifyNewChat(IChat chat, String msgBody) { - SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(mService); - try { - CharSequence tickerText = mService.getBind().getRoster().getContact(chat.getParticipant().getJID()) - .getName(); - Notification notification = new Notification(android.R.drawable.stat_notify_chat, tickerText, System - .currentTimeMillis()); - notification.flags = Notification.FLAG_AUTO_CANCEL; - notification.setLatestEventInfo(mService, tickerText, msgBody, makeChatIntent(chat)); - mService.sendNotification(chat.getParticipant().getJID().hashCode(), notification); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void processMessage(final IChat chat, Message message) { - try { - String body = message.getBody(); - if (!chat.isOpen() && body != null) { - if (chat instanceof ChatAdapter) { - mChats.put(chat.getParticipant().getJID(), (ChatAdapter) chat); - } - notifyNewChat(chat, body); - } - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - } - - @Override - public void stateChanged(final IChat chat) { - } - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/ChatAdapter.java --- a/src/com/beem/project/beem/service/ChatAdapter.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,332 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - - */ -package com.beem.project.beem.service; - -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; - -import org.jivesoftware.smack.Chat; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.util.StringUtils; -import org.jivesoftware.smackx.ChatState; -import org.jivesoftware.smackx.ChatStateListener; - -import android.os.Environment; -import android.os.RemoteCallbackList; -import android.os.RemoteException; -import android.util.Log; - -import com.beem.project.beem.service.aidl.IChat; -import com.beem.project.beem.service.aidl.IMessageListener; - -/** - * An adapter for smack's Chat class. - * @author darisk - */ -public class ChatAdapter extends IChat.Stub { - private static final int HISTORY_MAX_SIZE = 50; - private static final String TAG = "ChatAdapter"; - - private final Chat mAdaptee; - private final Contact mParticipant; - private String mState; - private boolean mIsOpen; - private final List mMessages; - private final RemoteCallbackList mRemoteListeners = new RemoteCallbackList(); - private final MsgListener mMsgListener = new MsgListener(); - private boolean mIsHistory; - private File mHistoryPath; - private String mAccountUser; - - /** - * Constructor. - * @param chat The chat to adapt - */ - public ChatAdapter(final Chat chat) { - mAdaptee = chat; - mParticipant = new Contact(chat.getParticipant()); - mMessages = new LinkedList(); - mAdaptee.addMessageListener(mMsgListener); - } - - /** - * {@inheritDoc} - */ - @Override - public Contact getParticipant() throws RemoteException { - return mParticipant; - } - - /** - * {@inheritDoc} - */ - @Override - public void sendMessage(com.beem.project.beem.service.Message message) throws RemoteException { - org.jivesoftware.smack.packet.Message send = new org.jivesoftware.smack.packet.Message(); - send.setTo(message.getTo()); - send.setBody(message.getBody()); - send.setThread(message.getThread()); - send.setSubject(message.getSubject()); - send.setType(org.jivesoftware.smack.packet.Message.Type.chat); - // TODO gerer les messages contenant des XMPPError - // send.set - try { - mAdaptee.sendMessage(send); - mMessages.add(message); - } catch (XMPPException e) { - e.printStackTrace(); - } - String state = Environment.getExternalStorageState(); - if (mIsHistory && Environment.MEDIA_MOUNTED.equals(state)) - saveHistory(message, mAccountUser); - } - - /** - * {@inheritDoc} - */ - @Override - public void addMessageListener(IMessageListener listen) { - if (listen != null) - mRemoteListeners.register(listen); - } - - /** - * {@inheritDoc} - */ - @Override - public void removeMessageListener(IMessageListener listen) { - if (listen != null) { - mRemoteListeners.unregister(listen); - } - } - - /** - * {@inheritDoc} - */ - @Override - public String getState() throws RemoteException { - return mState; - } - - /** - * {@inheritDoc} - */ - @Override - public void setState(String state) throws RemoteException { - mState = state; - } - - /** - * Get the adaptee for the Chat. - * @return The real chat object - */ - public Chat getAdaptee() { - return mAdaptee; - } - - /** - * {@inheritDoc} - */ - @Override - public void setOpen(boolean isOpen) { - this.mIsOpen = isOpen; - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isOpen() { - return mIsOpen; - } - - /** - * {@inheritDoc} - */ - @Override - public List getMessages() throws RemoteException { - return Collections.unmodifiableList(mMessages); - } - - /** - * Add a message in the chat history. - * @param msg the message to add - */ - void addMessage(Message msg) { - if (mMessages.size() == HISTORY_MAX_SIZE) - mMessages.remove(0); - // note that we don't have to add an id as our table set id as autoincrement - //contentValue.put(Messages.FROM, msg.getFrom()); - mMessages.add(msg); - if (!"".equals(msg.getBody()) && msg.getBody() != null) { - String state = Environment.getExternalStorageState(); - if (mIsHistory && Environment.MEDIA_MOUNTED.equals(state)) - saveHistory(msg, msg.getFrom()); - } - } - - /** - * Save message in SDCard. - * @param msg the message receive - * @param contactName the name of the contact - */ - public void saveHistory(Message msg, String contactName) { - File path = getHistoryPath(); - File filepath; - if (contactName.equals(msg.getFrom())) - filepath = new File(path, StringUtils.parseBareAddress(contactName)); - else - filepath = new File(path, StringUtils.parseBareAddress(msg.getTo())); - path.mkdirs(); - try { - FileWriter file = new FileWriter(filepath, true); - String log = msg.getTimestamp() + " " + contactName + " " + msg.getBody() - + System.getProperty("line.separator"); - file.write(log); - file.close(); - } catch (IOException e) { - Log.e(TAG, "Error writing chat history", e); - } - } - - /** - * set History enable/disable. - * @param isHisory history state - */ - public void setHistory(boolean isHisory) { - this.mIsHistory = isHisory; - } - - /** - * get History state. - * @return mIsHistory - */ - public boolean getHistory() { - return mIsHistory; - } - - /** - * Set Account user name. - * @param accountUser user name - */ - public void setAccountUser(String accountUser) { - mAccountUser = accountUser; - } - - /** - * get Account user name. - * @return mAccountUser - */ - public String getAccountUser() { - return mAccountUser; - } - - /** - * set History path. - * @param historyPath history path - */ - public void setHistoryPath(File historyPath) { - this.mHistoryPath = historyPath; - } - - /** - * get History path. - * @return mHistoryPath; - */ - public File getHistoryPath() { - return mHistoryPath; - } - - /** - * Listener. - */ - private class MsgListener implements ChatStateListener { - /** - * Constructor. - */ - public MsgListener() { - } - - @Override - public void processMessage(Chat chat, org.jivesoftware.smack.packet.Message message) { - Message msg = new Message(message); - //TODO add que les message pas de type errors - ChatAdapter.this.addMessage(msg); - final int n = mRemoteListeners.beginBroadcast(); - for (int i = 0; i < n; i++) { - IMessageListener listener = mRemoteListeners.getBroadcastItem(i); - try { - if (listener != null) - listener.processMessage(ChatAdapter.this, msg); - } catch (RemoteException e) { - Log.w(TAG, "Error while diffusing message to listener", e); - } - } - mRemoteListeners.finishBroadcast(); - } - - /** - * {@inheritDoc} - */ - @Override - public void stateChanged(Chat chat, ChatState state) { - mState = state.name(); - final int n = mRemoteListeners.beginBroadcast(); - - for (int i = 0; i < n; i++) { - IMessageListener listener = mRemoteListeners.getBroadcastItem(i); - try { - listener.stateChanged(ChatAdapter.this); - } catch (RemoteException e) { - Log.w(TAG, e.getMessage()); - } - } - mRemoteListeners.finishBroadcast(); - } - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/Contact.aidl --- a/src/com/beem/project/beem/service/Contact.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -parcelable Contact; diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/Contact.java --- a/src/com/beem/project/beem/service/Contact.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,461 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.jivesoftware.smack.RosterGroup; -import org.jivesoftware.smack.packet.Presence; -import org.jivesoftware.smack.util.StringUtils; - -import android.net.Uri; -import android.os.Parcel; -import android.os.Parcelable; - -import com.beem.project.beem.utils.Status; - -/** - * This class contains informations on a jabber contact. - * @author darisk - */ -public class Contact implements Parcelable { - - /** Parcelable.Creator needs by Android. */ - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - - @Override - public Contact createFromParcel(Parcel source) { - return new Contact(source); - } - - @Override - public Contact[] newArray(int size) { - return new Contact[size]; - } - }; - - private int mID; - private int mStatus; - private final String mJID; - private String mSelectedRes; - private String mMsgState; - private List mRes; - private final List mGroups = new ArrayList(); - private String mName; - private String mAvatarId; - - /** - * Construct a contact from a parcel. - * @param in parcel to use for construction - */ - private Contact(final Parcel in) { - mID = in.readInt(); - mStatus = in.readInt(); - mJID = in.readString(); - mSelectedRes = in.readString(); - mName = in.readString(); - mMsgState = in.readString(); - mAvatarId = in.readString(); - mRes = new ArrayList(); - in.readStringList(mRes); - in.readStringList(mGroups); - } - - /** - * Constructor. - * @param jid JID of the contact - */ - public Contact(final String jid) { - mJID = StringUtils.parseBareAddress(jid); - mName = mJID; - mStatus = Status.CONTACT_STATUS_DISCONNECT; - mMsgState = null; - mRes = new ArrayList(); - String res = StringUtils.parseResource(jid); - mSelectedRes = res; - if (!"".equals(res)) - mRes.add(res); - } - - /** - * Create a contact from a Uri. - * @param uri an uri for the contact - * @throws IllegalArgumentException if it is not a xmpp uri - */ - public Contact(final Uri uri) { - if (!"xmpp".equals(uri.getScheme())) - throw new IllegalArgumentException(); - String enduri = uri.getEncodedSchemeSpecificPart(); - mJID = StringUtils.parseBareAddress(enduri); - mName = mJID; - mStatus = Status.CONTACT_STATUS_DISCONNECT; - mMsgState = null; - mRes = new ArrayList(); - String res = StringUtils.parseResource(enduri); - mSelectedRes = res; - mRes.add(res); - } - - /** - * Make an xmpp uri for a spcific jid. - * - * @param jid the jid to represent as an uri - * @return an uri representing this jid. - */ - public static Uri makeXmppUri(String jid) { - StringBuilder build = new StringBuilder("xmpp:"); - String name = StringUtils.parseName(jid); - build.append(name); - if (!"".equals(name)) - build.append('@'); - build.append(StringUtils.parseServer(jid)); - String resource = StringUtils.parseResource(jid); - if (!"".equals(resource)) { - build.append('/'); - build.append(resource); - } - Uri u = Uri.parse(build.toString()); - return u; - } - - /** - * {@inheritDoc} - */ - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mID); - dest.writeInt(mStatus); - dest.writeString(mJID); - dest.writeString(mSelectedRes); - dest.writeString(mName); - dest.writeString(mMsgState); - dest.writeString(mAvatarId); - dest.writeStringList(getMRes()); - dest.writeStringList(getGroups()); - } - - /** - * Add a group for the contact. - * @param group the group - */ - public void addGroup(String group) { - if (!mGroups.contains(group)) - mGroups.add(group); - } - - /** - * Remove the contact from a group. - * @param group the group to delete the contact from. - */ - public void delGroup(String group) { - mGroups.remove(group); - } - - /** - * Add a resource for this contact. - * @param res the resource to add - */ - public void addRes(String res) { - if (!mRes.contains(res)) - mRes.add(res); - } - - /** - * Delete a resource for this contact. - * @param res the resource de delete - */ - public void delRes(String res) { - mRes.remove(res); - } - - /** - * {@inheritDoc} - */ - @Override - public int describeContents() { - return 0; - } - - /** - * Get the groups the contact is in. - * @return the mGroups - */ - public List getGroups() { - return mGroups; - } - - /** - * Get the id of the contact on the phone contact list. - * @return the mID - */ - public int getID() { - return mID; - } - - /** - * Get the Jabber ID of the contact. - * @return the Jabber ID - */ - public String getJID() { - return mJID; - } - - /** - * Get selected resource. - * @return the selected resource. - */ - public String getSelectedRes() { - return mSelectedRes; - } - - /** - * Get the list of resource for the contact. - * @return the mRes - */ - public List getMRes() { - return mRes; - } - - /** - * Get the message status of the contact. - * @return the message status of the contact. - */ - public String getMsgState() { - return mMsgState; - } - - /** - * Get the name of the contact. - * @return the mName - */ - public String getName() { - return mName; - } - - /** - * Get the status of the contact. - * @return the mStatus - */ - public int getStatus() { - return mStatus; - } - - /** - * Get the avatar id of the contact. - * - * @return the avatar id or null if there is not - */ - public String getAvatarId() { - return mAvatarId; - } - - /** - * Set the groups the contact is in. - * @param groups list of groups - */ - public void setGroups(Collection groups) { - this.mGroups.clear(); - for (RosterGroup rosterGroup : groups) { - mGroups.add(rosterGroup.getName()); - } - } - - /** - * Set the groups the contact is in. - * @param groups the mGroups to set - */ - public void setGroups(List groups) { - mGroups.clear(); - mGroups.addAll(groups); - } - - /** - * set the id of te contact on the phone contact list. - * @param mid the mID to set - */ - public void setID(int mid) { - mID = mid; - } - - /** - * Set the avatar id of the contact. - * - * @param avatarId the avatar id - */ - public void setAvatarId(String avatarId) { - mAvatarId = avatarId; - } - - /** - * Set the resource of the contact. - * @param resource to set. - */ - public void setSelectedRes(String resource) { - mSelectedRes = resource; - } - - /** - * Set a list of resource for the contact. - * @param mRes the mRes to set - */ - public void setMRes(List mRes) { - this.mRes = mRes; - } - - /** - * Set the message status of the contact. - * @param msgState the message status of the contact to set - */ - public void setMsgState(String msgState) { - mMsgState = msgState; - } - - /** - * Set the name of the contact. - * @param name the mName to set - */ - public void setName(String name) { - if (name == null || "".equals(name)) { - this.mName = this.mJID; - this.mName = StringUtils.parseName(this.mName); - if (this.mName == null || "".equals(this.mName)) - this.mName = this.mJID; - } else { - this.mName = name; - } - } - - /** - * Set the status of the contact. - * @param status the mStatus to set - */ - public void setStatus(int status) { - mStatus = status; - } - - /** - * Set the status of the contact using a presence packet. - * @param presence the presence containing status - */ - public void setStatus(Presence presence) { - mStatus = Status.getStatusFromPresence(presence); - mMsgState = presence.getStatus(); - } - - /** - * Set status for the contact. - * @param presence The presence packet which contains the status - */ - public void setStatus(PresenceAdapter presence) { - mStatus = presence.getStatus(); - mMsgState = presence.getStatusText(); - } - - /** - * {@inheritDoc} - */ - @Override - public String toString() { - if (mJID != null) - return mJID + "/[" + mRes + "]"; - return super.toString(); - } - - /** - * Get a URI to access the contact. - * @return the URI - */ - public Uri toUri() { - return makeXmppUri(mJID); - } - - /** - * 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; - } - - /** - * Get a JID to access the specific contact on this resource. - * @return the JID. - */ - public String getJIDWithRes() { - StringBuilder build = new StringBuilder(mJID); - if (!"".equals(mSelectedRes)) - build.append('/').append(mSelectedRes); - return build.toString(); - } - - @Override - public boolean equals(Object other) { - if (!(other instanceof Contact)) - return false; - if (other == this) - return true; - Contact c = (Contact) other; - return c.getJID().equals(getJID()); - } - - @Override - public int hashCode() { - return mJID.hashCode(); - } - -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/LoginAsyncTask.java --- a/src/com/beem/project/beem/service/LoginAsyncTask.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,137 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -import android.content.Context; -import android.os.AsyncTask; -import android.os.RemoteException; -import android.util.Log; - -import com.beem.project.beem.service.aidl.IXmppConnection; -import com.beem.project.beem.service.aidl.IXmppFacade; - -/** - * This is an asynchronous task that will launch a connection to the XMPP server. - * @see android.os.AsyncTask - * @author Da Risk - */ -public class LoginAsyncTask extends AsyncTask { - - /** - * State of a running connection. - */ - public static final int STATE_CONNECTION_RUNNING = 0; - /** - * State of an already connected connection but authentication is running. - */ - public static final int STATE_LOGIN_RUNNING = 1; - /** - * State of a connected and authenticated succesfully. - */ - public static final int STATE_LOGIN_SUCCESS = 2; - /** - * State of a connected but failed authentication. - */ - public static final int STATE_LOGIN_FAILED = 3; - - private static final String TAG = "BeemLoginTask"; - - private IXmppConnection mConnection; - private String mErrorMessage; - - /** - * Constructor. - */ - public LoginAsyncTask() { - } - - @Override - protected Boolean doInBackground(IXmppFacade... params) { - boolean result = true; - IXmppFacade facade = params[0]; - try { - publishProgress(STATE_CONNECTION_RUNNING); - mConnection = facade.createConnection(); - if (!mConnection.connect()) { - mErrorMessage = mConnection.getErrorMessage(); - publishProgress(STATE_LOGIN_FAILED); - return false; - } - publishProgress(STATE_LOGIN_RUNNING); - - if (!mConnection.login()) { - mErrorMessage = mConnection.getErrorMessage(); - publishProgress(STATE_LOGIN_FAILED); - return false; - } - publishProgress(STATE_LOGIN_SUCCESS); - } catch (RemoteException e) { - mErrorMessage = "Exception during connection :" + e; - result = false; - } - return result; - } - - /** - * Make sur to call the parent method when overriding this method. - */ - @Override - protected void onCancelled() { - try { - if (mConnection != null && mConnection.isAuthentificated()) { - mConnection.disconnect(); - } - } catch (RemoteException e) { - Log.d(TAG, "Remote exception", e); - } - } - - /** - * Get the error Message. - * @return the error message. null if no error - */ - public String getErrorMessage() { - return mErrorMessage; - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/Message.aidl --- a/src/com/beem/project/beem/service/Message.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -parcelable Message; diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/Message.java --- a/src/com/beem/project/beem/service/Message.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,319 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -import org.jivesoftware.smack.packet.XMPPError; -import org.jivesoftware.smackx.packet.DelayInformation; -import org.jivesoftware.smack.packet.PacketExtension; - -import android.os.Parcel; -import android.os.Parcelable; -import java.util.Date; - -/** - * This class represents a instant message. - * @author darisk - */ -public class Message implements Parcelable { - - /** Normal message type. Theese messages are like an email, with subject. */ - public static final int MSG_TYPE_NORMAL = 100; - - /** Chat message type. */ - public static final int MSG_TYPE_CHAT = 200; - - /** Group chat message type. */ - public static final int MSG_TYPE_GROUP_CHAT = 300; - - /** Error message type. */ - public static final int MSG_TYPE_ERROR = 400; - - /** Parcelable.Creator needs by Android. */ - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - - @Override - public Message createFromParcel(Parcel source) { - return new Message(source); - } - - @Override - public Message[] newArray(int size) { - return new Message[size]; - } - }; - - private int mType; - private String mBody; - private String mSubject; - private String mTo; - private String mFrom; - private String mThread; - private Date mTimestamp; - - // TODO ajouter l'erreur - - /** - * Constructor. - * @param to the destinataire of the message - * @param type the message type - */ - public Message(final String to, final int type) { - mTo = to; - mType = type; - mBody = ""; - mSubject = ""; - mThread = ""; - mFrom = null; - mTimestamp = new Date(); - } - - /** - * Constructor a message of type chat. - * @param to the destinataire of the message - */ - public Message(final String to) { - this(to, MSG_TYPE_CHAT); - } - - /** - * Construct a message from a smack message packet. - * @param smackMsg Smack message packet - */ - public Message(final org.jivesoftware.smack.packet.Message smackMsg) { - this(smackMsg.getTo()); - switch (smackMsg.getType()) { - case chat: - mType = MSG_TYPE_CHAT; - break; - case groupchat: - mType = MSG_TYPE_GROUP_CHAT; - break; - case normal: - mType = MSG_TYPE_NORMAL; - break; - // TODO gerer les message de type error - // this a little work around waiting for a better handling of error - // messages - case error: - mType = MSG_TYPE_ERROR; - break; - default: - mType = MSG_TYPE_NORMAL; - break; - } - this.mFrom = smackMsg.getFrom(); - //TODO better handling of error messages - if (mType == MSG_TYPE_ERROR) { - XMPPError er = smackMsg.getError(); - String msg = er.getMessage(); - if (msg != null) - mBody = msg; - else - mBody = er.getCondition(); - } else { - mBody = smackMsg.getBody(); - mSubject = smackMsg.getSubject(); - mThread = smackMsg.getThread(); - } - PacketExtension pTime = smackMsg.getExtension("delay", "urn:xmpp:delay"); - if (pTime instanceof DelayInformation) { - mTimestamp = ((DelayInformation) pTime).getStamp(); - } else { - mTimestamp = new Date(); - } - } - - /** - * Construct a message from a parcel. - * @param in parcel to use for construction - */ - private Message(final Parcel in) { - mType = in.readInt(); - mTo = in.readString(); - mBody = in.readString(); - mSubject = in.readString(); - mThread = in.readString(); - mFrom = in.readString(); - mTimestamp = new Date(in.readLong()); - } - - /** - * {@inheritDoc} - */ - @Override - public void writeToParcel(Parcel dest, int flags) { - // TODO Auto-generated method stub - dest.writeInt(mType); - dest.writeString(mTo); - dest.writeString(mBody); - dest.writeString(mSubject); - dest.writeString(mThread); - dest.writeString(mFrom); - dest.writeLong(mTimestamp.getTime()); - } - - /** - * Get the type of the message. - * @return the type of the message. - */ - public int getType() { - return mType; - } - - /** - * Set the type of the message. - * @param type the type to set - */ - public void setType(int type) { - mType = type; - } - - /** - * Get the body of the message. - * @return the Body of the message - */ - public String getBody() { - return mBody; - } - - /** - * Set the body of the message. - * @param body the body to set - */ - public void setBody(String body) { - mBody = body; - } - - /** - * Get the subject of the message. - * @return the subject - */ - public String getSubject() { - return mSubject; - } - - /** - * Set the subject of the message. - * @param subject the subject to set - */ - public void setSubject(String subject) { - mSubject = subject; - } - - /** - * Get the destinataire of the message. - * @return the destinataire of the message - */ - public String getTo() { - return mTo; - } - - /** - * Set the destinataire of the message. - * @param to the destinataire to set - */ - public void setTo(String to) { - mTo = to; - } - - /** - * Set the from field of the message. - * @param from the mFrom to set - */ - public void setFrom(String from) { - this.mFrom = from; - } - - /** - * Get the from field of the message. - * @return the mFrom - */ - public String getFrom() { - return mFrom; - } - - /** - * Get the thread of the message. - * @return the thread - */ - public String getThread() { - return mThread; - } - - /** - * Set the thread of the message. - * @param thread the thread to set - */ - public void setThread(String thread) { - mThread = thread; - } - - /** - * Set the Date of the message. - * - * @param date date of the message. - */ - public void setTimestamp(Date date) { - mTimestamp = date; - } - - /** - * Get the Date of the message. - * - * @return if it is a delayed message get the date the message was sended. - */ - public Date getTimestamp() { - return mTimestamp; - } - - /** - * {@inheritDoc} - */ - @Override - public int describeContents() { - // TODO Auto-generated method stub - return 0; - } - -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/PresenceAdapter.aidl --- a/src/com/beem/project/beem/service/PresenceAdapter.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -parcelable PresenceAdapter; diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/PresenceAdapter.java --- a/src/com/beem/project/beem/service/PresenceAdapter.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,204 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -import org.jivesoftware.smack.packet.Presence; - -import android.os.Parcel; -import android.os.Parcelable; - -import com.beem.project.beem.utils.PresenceType; -import com.beem.project.beem.utils.Status; - -/** - * this class contain contact presence informations. - * @author nikita - */ -public class PresenceAdapter implements Parcelable { - - /** Parcelable.Creator needs by Android. */ - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - - @Override - public PresenceAdapter createFromParcel(Parcel source) { - return new PresenceAdapter(source); - } - - @Override - public PresenceAdapter[] newArray(int size) { - return new PresenceAdapter[size]; - } - }; - - private int mType; - private int mStatus; - private String mTo; - private String mFrom; - private String mStatusText; - - /** - * constructor from Parcel. - * @param source parcelable presence. - */ - public PresenceAdapter(final Parcel source) { - mType = source.readInt(); - mStatus = source.readInt(); - mTo = source.readString(); - mFrom = source.readString(); - mStatusText = source.readString(); - } - - /** - * constructor from smack Presence. - * @param presence smack presence. - */ - public PresenceAdapter(final Presence presence) { - mType = PresenceType.getPresenceType(presence); - mStatus = Status.getStatusFromPresence(presence); - mTo = presence.getTo(); - mFrom = presence.getFrom(); - mStatusText = presence.getStatus(); - } - - /* (non-Javadoc) - * @see android.os.Parcelable#describeContents() - */ - @Override - public int describeContents() { - // TODO Auto-generated method stub - return 0; - } - - /** - * mFrom getter. - * @return the mFrom - */ - public String getFrom() { - return mFrom; - } - - /** - * mStatus getter. - * @return the mStatus - */ - public int getStatus() { - return mStatus; - } - - /** - * mStatusText getter. - * @return the mStatusText - */ - public String getStatusText() { - return mStatusText; - } - - /** - * mTo getter. - * @return the mTo - */ - public String getTo() { - return mTo; - } - - /** - * mType getter. - * @return the mType - */ - public int getType() { - return mType; - } - - /** - * mFrom setter. - * @param from the mFrom to set - */ - public void setFrom(final String from) { - this.mFrom = from; - } - - /** - * mStatus setter. - * @param status the mStatus to set - */ - public void setStatus(final int status) { - this.mStatus = status; - } - - /** - * mStatusText setter. - * @param statusText the mStatusText to set - */ - public void setStatusText(final String statusText) { - this.mStatusText = statusText; - } - - /** - * mTo setter. - * @param to the mTo to set - */ - public void setTo(final String to) { - this.mTo = to; - } - - /** - * mType setter. - * @param type the type to set - */ - public void setType(int type) { - this.mType = type; - } - - /* (non-Javadoc) - * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int) - */ - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mType); - dest.writeInt(mStatus); - dest.writeString(mTo); - dest.writeString(mFrom); - dest.writeString(mStatusText); - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/PrivacyListItem.aidl --- a/src/com/beem/project/beem/service/PrivacyListItem.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -parcelable PrivacyListItem; diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/PrivacyListItem.java --- a/src/com/beem/project/beem/service/PrivacyListItem.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,153 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -import android.os.Parcel; -import android.os.Parcelable; - -/** - * A simplified version of the Smack PrivacyItem class. - * @author Jean-Manuel Da Silva - */ -public class PrivacyListItem implements Parcelable { - - /** - * Constructor. Needed to implements the Parcelable.Creator interface. Generates instances of PrivacyListItem from a - * Parcel. - */ - public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public PrivacyListItem createFromParcel(Parcel in) { - return new PrivacyListItem(in); - } - - public PrivacyListItem[] newArray(int size) { - return new PrivacyListItem[size]; - } - }; - - private int mType; - private String mValue; - - /** - * Constructor. - */ - public PrivacyListItem() { - } - - /** - * Constructor. Generates instances of PrivacyListItem from a Parcel. - * @param in The Parcel used to initialize object's attributes. - */ - public PrivacyListItem(final Parcel in) { - readFromParcel(in); - } - - /** - * Constructor. - * @param type The type of the item. - * @param value The value of the item. - */ - public PrivacyListItem(final int type, final String value) { - mType = type; - mValue = value; - } - - /** - * {@inheritDoc}. - */ - @Override - public int describeContents() { - return 0; - } - - /** - * Initialize object's attributes from a Parcel. - * @param in The Parcel used to initialize object's attributes. - */ - public void readFromParcel(Parcel in) { - mType = in.readInt(); - mValue = in.readString(); - } - - /** - * {@inheritDoc}. - */ - @Override - public void writeToParcel(Parcel dest, int flags) { - dest.writeInt(mType); - dest.writeString(mValue); - } - - /** - * PrivacyListItem type accessor. - * @return The type of the PrivacyListItem. - */ - public int getType() { - return mType; - } - - /** - * PrivacyListItem value accessor. - * @return The value of the PrivacyListItem. - */ - public String getValue() { - return mValue; - } - - /** - * PrivacyListItem type mutator. - * @param type The type of the PrivacyListItem. - */ - public void setType(final int type) { - mType = type; - } - - /** - * PrivacyListItem value mutator. - * @param value The value of the PrivacyListItem. - */ - public void setValue(final String value) { - mValue = value; - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/PrivacyListManagerAdapter.java --- a/src/com/beem/project/beem/service/PrivacyListManagerAdapter.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,358 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -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.XMPPException; -import org.jivesoftware.smack.packet.PrivacyItem; -import org.jivesoftware.smack.packet.PrivacyItem.PrivacyRule; - -import android.os.RemoteCallbackList; -import android.os.RemoteException; -import android.util.Log; - -import com.beem.project.beem.service.aidl.IPrivacyListListener; -import com.beem.project.beem.service.aidl.IPrivacyListManager; - -/** - * An adapter for the Smack's PrivacyListManager. - * @author Jean-Manuel Da Silva - */ -public class PrivacyListManagerAdapter extends IPrivacyListManager.Stub { - - /** Class's Tag. */ - public static final String TAG = "PrivacyListManagerAdapter"; - - private final PrivacyListManager mPrivacyListManager; - - private final RemoteCallbackList mPrivacyListListeners = - new RemoteCallbackList(); - private final PrivacyListListenerAdapter mPrivacyListListener = new PrivacyListListenerAdapter(); - - /** - * Constructor. - * @param privacyListManager the privacy list manager - */ - public PrivacyListManagerAdapter(final PrivacyListManager privacyListManager) { - mPrivacyListManager = privacyListManager; - mPrivacyListManager.addListener(mPrivacyListListener); - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#blockUser(java.lang.String, java.lang.String) - */ - @Override - public void blockUser(String listName, String jid) throws RemoteException { - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#createPrivacyList(java.lang.String, java.util.List) - */ - @Override - public void createPrivacyList(String listName, List items) throws RemoteException { - Log.d(TAG, "BEGIN createPrivacyList."); - try { - List privacyItems = new ArrayList(); - - PrivacyItem item = new PrivacyItem(PrivacyItem.Type.subscription.name(), true, 2); - item.setValue(PrivacyRule.SUBSCRIPTION_BOTH); - privacyItems.add(item); - - mPrivacyListManager.createPrivacyList(listName, privacyItems); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - Log.d(TAG, "END createPrivacyList."); - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#declineActivePrivacyList() - */ - @Override - public void declineActivePrivacyList() throws RemoteException { - try { - mPrivacyListManager.declineActiveList(); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#declineDefaultPrivacyList() - */ - @Override - public void declineDefaultPrivacyList() throws RemoteException { - try { - mPrivacyListManager.declineDefaultList(); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#editPrivacyList(java.lang.String, java.util.List) - */ - @Override - public void editPrivacyList(String listName, List items) throws RemoteException { - Log.d(TAG, "BEGIN editPrivacyList."); - try { - mPrivacyListManager.updatePrivacyList(listName, tranformPrivacyListItemsToPrivacyItems(items)); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - Log.d(TAG, "END editPrivacyList."); - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getActivePrivacyList() - */ - @Override - public String getActivePrivacyList() throws RemoteException { - try { - PrivacyList activePrivacyList = mPrivacyListManager.getActiveList(); - return activePrivacyList.toString(); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - return null; - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getBlockedGroupsByList(java.lang.String) - */ - @Override - public List getBlockedGroupsByList(String listName) throws RemoteException { - List blockedGroups = new ArrayList(); - try { - PrivacyList pL = mPrivacyListManager.getPrivacyList(listName); - for (PrivacyItem pI : pL.getItems()) { - if (pI.getType().equals(PrivacyItem.Type.group) && !pI.isAllow()) - blockedGroups.add(pI.getValue()); - } - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - return blockedGroups; - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getBlockedUsersByList(java.lang.String) - */ - @Override - public List getBlockedUsersByList(String listName) throws RemoteException { - List blockedUsers = new ArrayList(); - try { - PrivacyList pL = mPrivacyListManager.getPrivacyList(listName); - for (PrivacyItem pI : pL.getItems()) { - if (pI.getType().equals(PrivacyItem.Type.jid) && !pI.isAllow()) - blockedUsers.add(pI.getValue()); - } - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - return blockedUsers; - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getDefaultPrivacyList() - */ - @Override - public String getDefaultPrivacyList() throws RemoteException { - try { - PrivacyList defaultPrivacyList = mPrivacyListManager.getDefaultList(); - return defaultPrivacyList.toString(); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - return null; - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#removePrivacyList(java.lang.String) - */ - @Override - public void removePrivacyList(String listName) throws RemoteException { - try { - mPrivacyListManager.deletePrivacyList(listName); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#setActivePrivacyList(java.lang.String) - */ - @Override - public void setActivePrivacyList(String listName) throws RemoteException { - try { - mPrivacyListManager.setActiveListName(listName); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#setDefaultPrivacyList(java.lang.String) - */ - @Override - public void setDefaultPrivacyList(String listName) throws RemoteException { - try { - mPrivacyListManager.setDefaultListName(listName); - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - } - - /** - * From a List of PrivacyListItem get a List of PrivacyItem. - * @param items The List of PrivacyListItem. - * @return A list of PrivacyItem. - */ - private List tranformPrivacyListItemsToPrivacyItems(List items) { - List rItems = new ArrayList(); - PrivacyItem.Type[] itemTypes = PrivacyItem.Type.values(); - - for (int i = 0; i < items.size(); i++) { - rItems.add(new PrivacyItem(itemTypes[items.get(i).getType()].name(), false, i)); - } - - return rItems; - } - - /** - * From a List of PrivacyItem get a List of PrivacyListItem. - * @param items The List of PrivacyItem. - * @return A list of PrivacyListItem. - */ - private List tranformPrivacyItemsToPrivacyListItems(List items) { - List rItems = new ArrayList(); - - for (int i = 0; i < items.size(); i++) { - rItems.add(new PrivacyListItem(items.get(i).getType().ordinal(), items.get(i).getValue())); - } - return rItems; - } - - /** - * An adapter for the Smack's PrivacyListListener. - * @author Jean-Manuel Da Silva - */ - private class PrivacyListListenerAdapter implements PrivacyListListener { - /** - * Constructor. - */ - public PrivacyListListenerAdapter() { } - - @Override - public void setPrivacyList(final String listName, final List listItem) { - int i = mPrivacyListListeners.beginBroadcast(); - while (i > 0) { - i--; - try { - mPrivacyListListeners.getBroadcastItem(i).setPrivacyList(listName, - tranformPrivacyItemsToPrivacyListItems(listItem)); - } catch (RemoteException e) { - Log.w(TAG, e.getMessage()); - } - } - mPrivacyListListeners.finishBroadcast(); - } - - @Override - public void updatedPrivacyList(final String listName) { - Log.d(TAG, "BEGIN updatedPrivacyList."); - int i = mPrivacyListListeners.beginBroadcast(); - while (i > 0) { - i--; - try { - mPrivacyListListeners.getBroadcastItem(i).updatedPrivacyList(listName); - } catch (RemoteException e) { - Log.w(TAG, e.getMessage()); - } - } - mPrivacyListListeners.finishBroadcast(); - Log.d(TAG, "END updatedPrivacyList."); - } - } - - @Override - public void addPrivacyListListener(IPrivacyListListener listener) throws RemoteException { - if (listener != null) - mPrivacyListListeners.register(listener); - } - - @Override - public void removePrivacyListListener(IPrivacyListListener listener) throws RemoteException { - if (listener != null) - mPrivacyListListeners.unregister(listener); - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IPrivacyListManager#getPrivacyLists() - */ - @Override - public List getPrivacyLists() throws RemoteException { - Log.d(TAG, "BEGIN getPrivacyLists."); - List res = new ArrayList(); - try { - PrivacyList[] registeredPrivacyLists = mPrivacyListManager.getPrivacyLists(); - Log.d(TAG, "> registeredPrivacyLists size: " + registeredPrivacyLists.length); - if (registeredPrivacyLists.length > 0) { - for (int i = 0; i < registeredPrivacyLists.length; i++) { - res.add(registeredPrivacyLists[i].toString()); - Log.d(TAG, "> " + res.get(i) + " added."); - } - } - } catch (XMPPException e) { - Log.e(TAG, e.getMessage()); - } - Log.d(TAG, "END getPrivacyLists."); - return res; - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,417 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterEntry; -import org.jivesoftware.smack.RosterGroup; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.XMPPException; -import org.jivesoftware.smack.packet.Presence; -import org.jivesoftware.smack.util.StringUtils; - -import android.content.Context; -import android.os.RemoteCallbackList; -import android.os.RemoteException; -import android.util.Log; - -import com.beem.project.beem.R; -import com.beem.project.beem.service.aidl.IBeemRosterListener; -import com.beem.project.beem.utils.Status; -import com.beem.project.beem.smack.avatar.AvatarMetadataExtension.Info; -import com.beem.project.beem.smack.avatar.AvatarManager; -import com.beem.project.beem.smack.avatar.AvatarListener; - -/** - * This class implement a Roster adapter for BEEM. - */ -public class RosterAdapter extends com.beem.project.beem.service.aidl.IRoster.Stub { - - private static final String TAG = "RosterAdapter"; - private final Roster mAdaptee; - private final RemoteCallbackList mRemoteRosListeners = - new RemoteCallbackList(); - private final Map mDefaultStatusMessages; - private final RosterListenerAdapter mRosterListener = new RosterListenerAdapter(); - private Map mAvatarIdmap = new HashMap(); - private AvatarManager mAvatarManager; - - /** - * Constructor. - * @param roster The roster to adapt. - * @param context The context of the RosterAdapter. - */ - public RosterAdapter(final Roster roster, final Context context) { - mAdaptee = roster; - roster.addRosterListener(mRosterListener); - mDefaultStatusMessages = createDefaultStatusMessagesMap(context); - } - - /** - * Constructor. - * @param roster The roster to adapt. - * @param context The context of the RosterAdapter. - * @param avatarMgr The AvatarManager of the connection - */ - public RosterAdapter(final Roster roster, final Context context, final AvatarManager avatarMgr) { - mAdaptee = roster; - roster.addRosterListener(mRosterListener); - mDefaultStatusMessages = createDefaultStatusMessagesMap(context); - mAvatarManager = avatarMgr; - if (mAvatarManager != null) - mAvatarManager.addAvatarListener(new AvatarEventListener()); - } - - - /** - * {@inheritDoc} - */ - @Override - public void addRosterListener(IBeemRosterListener listen) throws RemoteException { - if (listen != null) - mRemoteRosListeners.register(listen); - } - - /** - * {@inheritDoc} - */ - @Override - public Contact addContact(String user, String name, String[] groups) throws RemoteException { - RosterEntry contact = mAdaptee.getEntry(user); - try { - mAdaptee.createEntry(user, name, groups); - contact = mAdaptee.getEntry(user); - } catch (XMPPException e) { - Log.e(TAG, "Error while adding new contact", e); - return null; - } - return getContactFromRosterEntry(contact); - } - - /** - * {@inheritDoc} - */ - @Override - public void deleteContact(Contact contact) throws RemoteException { - try { - RosterEntry entry = mAdaptee.getEntry(contact.getJID()); - mAdaptee.removeEntry(entry); - } catch (XMPPException e) { - e.printStackTrace(); - } - } - - /** - * {@inheritDoc} - */ - @Override - public void createGroup(String groupname) throws RemoteException { - if (mAdaptee.getGroup(groupname) == null) - mAdaptee.createGroup(groupname); - } - - /** - * {@inheritDoc} - */ - @Override - public Contact getContact(String jid) throws RemoteException { - if (mAdaptee.contains(jid)) - return getContactFromRosterEntry(mAdaptee.getEntry(jid)); - return null; - } - - /** - * {@inheritDoc} - */ - @Override - public List getContactList() throws RemoteException { - boolean add = true; - Collection list = mAdaptee.getEntries(); - List coList = new ArrayList(list.size()); - for (RosterEntry entry : list) { - coList.add(getContactFromRosterEntry(entry)); - } - return coList; - } - - /** - * {@inheritDoc} - */ - @Override - public List getGroupsNames() throws RemoteException { - Collection groups = mAdaptee.getGroups(); - List result = new ArrayList(groups.size()); - for (RosterGroup rosterGroup : groups) { - result.add(rosterGroup.getName()); - } - return result; - } - - /** - * {@inheritDoc} - */ - @Override - public void removeRosterListener(IBeemRosterListener listen) throws RemoteException { - if (listen != null) - mRemoteRosListeners.unregister(listen); - } - - /** - * {@inheritDoc} - */ - @Override - public void setContactName(String jid, String name) throws RemoteException { - mAdaptee.getEntry(jid).setName(name); - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IRoster#getPresence(java.lang.String) - */ - @Override - public PresenceAdapter getPresence(String jid) throws RemoteException { - return new PresenceAdapter(mAdaptee.getPresence(jid)); - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IRoster#addContactToGroup(java.lang.String, java.lang.String) - */ - @Override - public void addContactToGroup(String groupName, String jid) throws RemoteException { - createGroup(groupName); - RosterGroup group = mAdaptee.getGroup(groupName); - try { - group.addEntry(mAdaptee.getEntry(jid)); - } catch (XMPPException e) { - e.printStackTrace(); - } - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IRoster#removeContactFromGroup(java.lang.String, java.lang.String) - */ - @Override - public void removeContactFromGroup(String groupName, String jid) throws RemoteException { - RosterGroup group = mAdaptee.getGroup(groupName); - try { - group.removeEntry(mAdaptee.getEntry(jid)); - } catch (XMPPException e) { - e.printStackTrace(); - } - } - - /** - * Get a contact from a RosterEntry. - * @param entry a roster entry containing information for the contact. - * @return a contact for this entry. - */ - private Contact getContactFromRosterEntry(RosterEntry entry) { - String user = entry.getUser(); - Contact c = new Contact(user); - Presence p = mAdaptee.getPresence(user); - - if (p.getStatus() == null || "".equals(p.getStatus())) - p.setStatus(mDefaultStatusMessages.get(Status.getStatusFromPresence(p))); - c.setStatus(p); - try { - c.setGroups(entry.getGroups()); - } catch (NullPointerException e) { - Log.d(TAG, "Group list not ready", e); - } - Iterator iPres = mAdaptee.getPresences(user); - while (iPres.hasNext()) { - p = iPres.next(); - if (!p.getType().equals(Presence.Type.unavailable)) - c.addRes(StringUtils.parseResource(p.getFrom())); - } - c.setName(entry.getName()); - c.setAvatarId(mAvatarIdmap.get(user)); - return c; - } - - /** - * Create a map which contains default status messages. - * @param context The context of the roster adapter. - * @return A Map which assigns a status to a message. - */ - private Map createDefaultStatusMessagesMap(Context context) { - Map defaultStatusMessages = new HashMap(); - defaultStatusMessages.put(Status.CONTACT_STATUS_AVAILABLE, context - .getString(R.string.contact_status_msg_available)); - defaultStatusMessages.put(Status.CONTACT_STATUS_AVAILABLE_FOR_CHAT, context - .getString(R.string.contact_status_msg_available_chat)); - defaultStatusMessages.put(Status.CONTACT_STATUS_AWAY, context.getString(R.string.contact_status_msg_away)); - defaultStatusMessages.put(Status.CONTACT_STATUS_BUSY, context.getString(R.string.contact_status_msg_dnd)); - defaultStatusMessages.put(Status.CONTACT_STATUS_DISCONNECT, context - .getString(R.string.contact_status_msg_offline)); - defaultStatusMessages.put(Status.CONTACT_STATUS_UNAVAILABLE, context.getString(R.string.contact_status_msg_xa)); - - return defaultStatusMessages; - } - - /** - * Listener for the roster events. It will call the remote listeners registered. - * @author darisk - */ - private class RosterListenerAdapter implements RosterListener { - - /** - * Constructor. - */ - public RosterListenerAdapter() { - } - - /** - * {@inheritDoc} - */ - @Override - public void entriesAdded(Collection addresses) { - final int n = mRemoteRosListeners.beginBroadcast(); - - List tab = new ArrayList(); - tab.addAll(addresses); - for (int i = 0; i < n; i++) { - IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i); - try { - listener.onEntriesAdded(tab); - } catch (RemoteException e) { - Log.w(TAG, "Error while adding roster entries", e); - } - } - mRemoteRosListeners.finishBroadcast(); - } - - /** - * {@inheritDoc} - */ - @Override - public void entriesDeleted(Collection addresses) { - final int n = mRemoteRosListeners.beginBroadcast(); - - List tab = new ArrayList(); - tab.addAll(addresses); - for (int i = 0; i < n; i++) { - IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i); - try { - listener.onEntriesDeleted(tab); - } catch (RemoteException e) { - Log.w(TAG, "Error while deleting roster entries", e); - } - } - mRemoteRosListeners.finishBroadcast(); - } - - /** - * {@inheritDoc} - */ - @Override - public void entriesUpdated(Collection addresses) { - final int n = mRemoteRosListeners.beginBroadcast(); - - List tab = new ArrayList(); - tab.addAll(addresses); - for (int i = 0; i < n; i++) { - IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i); - try { - listener.onEntriesUpdated(tab); - } catch (RemoteException e) { - Log.w(TAG, "Error while updating roster entries", e); - } - } - mRemoteRosListeners.finishBroadcast(); - } - - /** - * {@inheritDoc} - */ - @Override - public void presenceChanged(Presence presence) { - final int n = mRemoteRosListeners.beginBroadcast(); - Log.v(TAG, ">>> Presence changed for " + presence.getFrom()); - - for (int i = 0; i < n; i++) { - IBeemRosterListener listener = mRemoteRosListeners.getBroadcastItem(i); - try { - if (!presence.isAvailable()) - mAvatarIdmap.remove(StringUtils.parseBareAddress(presence.getFrom())); - if (presence.getStatus() == null || "".equals(presence.getStatus())) { - presence.setStatus(mDefaultStatusMessages.get(Status.getStatusFromPresence(presence))); - } - listener.onPresenceChanged(new PresenceAdapter(presence)); - } catch (RemoteException e) { - Log.w(TAG, "Error while updating roster presence entries", e); - } - } - mRemoteRosListeners.finishBroadcast(); - } - } - - /** - * Listener on avatar metadata event. - * - */ - private class AvatarEventListener implements AvatarListener { - - /** - * Constructor. - */ - public AvatarEventListener() { } - - @Override - public void onAvatarChange(String from, String avatarId, List avatarInfos) { - String bare = StringUtils.parseBareAddress(from); - if (avatarId == null) - mAvatarIdmap.remove(bare); - else { - mAvatarIdmap.put(bare, avatarId); - } - } - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/XmppConnectionAdapter.java --- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Sun Nov 06 04:27:09 2011 +0100 @@ -51,7 +51,6 @@ 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; @@ -69,6 +68,7 @@ import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.net.Uri; import android.os.Bundle; import android.os.RemoteCallbackList; import android.os.RemoteException; @@ -80,8 +80,6 @@ import com.beem.project.beem.R; import com.beem.project.beem.providers.Messages; import com.beem.project.beem.service.aidl.IBeemConnectionListener; -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.smack.avatar.AvatarCache; import com.beem.project.beem.smack.avatar.AvatarManager; @@ -104,16 +102,13 @@ private static final int SMACK_PRIORITY_MAX = 128; private static final String TAG = "XMPPConnectionAdapter"; private final XMPPConnection mAdaptee; - private IChatManager mChatManager; private final String mLogin; private final String mPassword; private String mResource; private String mErrorMsg; - private RosterAdapter mRoster; private int mPreviousPriority; private int mPreviousMode; private String mPreviousStatus; - private PrivacyListManagerAdapter mPrivacyListManager; private ChatStateManager mChatStateManager; private final BeemService mService; private BeemApplication mApplication; @@ -243,14 +238,13 @@ mAdaptee.addPacketListener(mSubscribePacketListener, filter); Log.e(TAG, mLogin + mPassword + mResource); mAdaptee.login(mLogin, mPassword, mResource); - mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService); + //mChatManager = new BeemChatManager(mAdaptee.getChatManager(), mService); //nikita: I commented this line because of the logs provided in http://www.beem-project.com/issues/321 //Also, since the privacylistmanager isn't finished and used, it will be safer to not initialize it //mPrivacyListManager = new PrivacyListManagerAdapter(PrivacyListManager.getInstanceFor(mAdaptee)); mService.initJingle(mAdaptee); discoverServerFeatures(); - mRoster = new RosterAdapter(mAdaptee.getRoster(), mService, mAvatarManager); mApplication.setConnected(true); int mode = mPref.getInt(BeemApplication.STATUS_KEY, 0); String status = mPref.getString(BeemApplication.STATUS_TEXT_KEY, ""); @@ -383,27 +377,6 @@ return mAdaptee; } - /** - * {@inheritDoc} - */ - @Override - public IChatManager getChatManager() throws RemoteException { - return mChatManager; - } - - /** - * {@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, mService, mAvatarManager); - return mRoster; - } /** * Returns true if currently authenticated by successfully calling the login method. @@ -423,22 +396,6 @@ } /** - * PrivacyListManagerAdapter mutator. - * @param privacyListManager the privacy list manager - */ - public void setPrivacyListManager(PrivacyListManagerAdapter privacyListManager) { - this.mPrivacyListManager = privacyListManager; - } - - /** - * PrivacyListManagerAdapter accessor. - * @return the mPrivacyList - */ - public PrivacyListManagerAdapter getPrivacyListManager() { - return mPrivacyListManager; - } - - /** * {@inheritDoc} */ @Override @@ -448,43 +405,39 @@ public void handleMessage(android.os.Message msg) { Log.e(TAG, "HANDLEMESSAGE"); + Bundle b = (Bundle) msg.obj; - com.beem.project.beem.service.Message message = b.getParcelable(BeemIntent.EXTRA_MESSAGE); - switch (message.getType()) { - case com.beem.project.beem.service.Message.MSG_TYPE_CHAT: + String from = b.getString(BeemIntent.EXTRA_ACCOUNT); + String to = b.getString(BeemIntent.EXTRA_JID); + String body = b.getString(BeemIntent.EXTRA_MESSAGE); - org.jivesoftware.smack.packet.Message send = new org.jivesoftware.smack.packet.Message(); - send.setTo(message.getTo()); - send.setBody(message.getBody()); - send.setThread(message.getThread()); - send.setSubject(message.getSubject()); - send.setType(org.jivesoftware.smack.packet.Message.Type.chat); - // TODO gerer les messages contenant des XMPPError - // send.set - try { - mAdaptee.sendPacket(send); - } catch (IllegalStateException e) { - Log.e(TAG, "Message not send", e); - break; - } - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - ContentValues values = new ContentValues(); - values.put(Messages.FROM, "me"); //TODO: Get current account name - values.put(Messages.MESSAGE_ID, "message id"); - values.put(Messages.TO, message.getTo()); - values.put(Messages.TYPE, message.getType()); - values.put(Messages.SUBJECT, "SUBJECT"); - values.put(Messages.BODY, message.getBody()); - values.put(Messages.THREAD, "THREAD"); - values.put(Messages.EXTRAS, "EXTRAS"); - values.put(Messages.IS_RECEIVE, true); - values.put(Messages.DATE_RECEIVE, dateFormat.format(new Date())); - values.put(Messages.DATE_READ, dateFormat.format(message.getTimestamp())); - mService.getContentResolver().insert(Messages.CONTENT_URI, values); - break; - default: - Log.w(TAG, "Unknown message " + msg); + Message send = new Message(); + send.setFrom(from); + send.setThread(""); //TODO: set ThreadID + send.setTo(to); + send.setBody(body); + send.setType(Message.Type.chat); + // TODO gerer les messages contenant des XMPPError + try { + mAdaptee.sendPacket(send); + } catch (IllegalStateException e) { + Log.e(TAG, "Message not send", e); } + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ContentValues values = new ContentValues(); + values.put(Messages.FROM, "me"); //TODO: Get current account name + values.put(Messages.MESSAGE_ID, "message id"); + values.put(Messages.TO, to); + values.put(Messages.TYPE, Message.Type.chat.toString()); + values.put(Messages.SUBJECT, "SUBJECT"); + values.put(Messages.BODY, body); + values.put(Messages.THREAD, ""); + values.put(Messages.EXTRAS, ""); + values.put(Messages.IS_RECEIVE, true); + values.put(Messages.DATE_RECEIVE, dateFormat.format(new Date())); + values.put(Messages.DATE_READ, dateFormat.format(new Date())); + mService.getContentResolver().insert(Messages.CONTENT_URI, values); + } /** @@ -601,7 +554,6 @@ @Override public void connectionClosed() { Log.d(TAG, "closing connection"); - mRoster = null; Intent intent = new Intent(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED); intent.putExtra("message", mService.getString(R.string.BeemBroadcastReceiverDisconnect)); intent.putExtra("normally", true); @@ -616,7 +568,6 @@ @Override public void connectionClosedOnError(Exception exception) { Log.d(TAG, "connectionClosedOnError"); - mRoster = null; Intent intent = new Intent(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED); intent.putExtra("message", exception.getMessage()); mService.sendBroadcast(intent); @@ -722,9 +673,9 @@ notif.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK).putExtra("from", from); - notif.setLatestEventInfo(mService, from, mService - .getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0, - intent, PendingIntent.FLAG_ONE_SHOT)); + notif.setLatestEventInfo(mService, from, + mService.getString(R.string.AcceptContactRequestFrom, from), + PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); int id = packet.hashCode(); mService.sendNotification(id, notif); } @@ -771,30 +722,53 @@ R.string.AcceptContactRequest, from), System.currentTimeMillis()); notification.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(mService, Subscription.class); - intent.setData(Contact.makeXmppUri(from)); - notification.setLatestEventInfo(mService, from, mService.getString(R.string.AcceptContactRequestFrom, - from), PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); + intent.setData(makeXmppUri(from)); + notification.setLatestEventInfo(mService, from, + mService.getString(R.string.AcceptContactRequestFrom, from), + PendingIntent.getActivity(mService, 0, intent, PendingIntent.FLAG_ONE_SHOT)); int id = p.hashCode(); mService.sendNotification(id, notification); } else if (packet instanceof Message) { Message message = (Message) packet; - com.beem.project.beem.service.Message msg = new com.beem.project.beem.service.Message(message); + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // note that we don't have to add an id as our table set id as autoincrement ContentValues values = new ContentValues(); - values.put(Messages.FROM, msg.getFrom()); + values.put(Messages.FROM, message.getFrom()); values.put(Messages.MESSAGE_ID, "message id"); - values.put(Messages.TO, msg.getTo()); - values.put(Messages.TYPE, msg.getType()); + values.put(Messages.TO, message.getTo()); + values.put(Messages.TYPE, message.getType().toString()); values.put(Messages.SUBJECT, "SUBJECT"); - values.put(Messages.BODY, msg.getBody()); - values.put(Messages.THREAD, "THREAD"); - values.put(Messages.EXTRAS, "EXTRAS"); + values.put(Messages.BODY, message.getBody()); + values.put(Messages.THREAD, message.getThread()); + values.put(Messages.EXTRAS, ""); values.put(Messages.IS_RECEIVE, true); values.put(Messages.DATE_RECEIVE, dateFormat.format(new Date())); - values.put(Messages.DATE_READ, dateFormat.format(msg.getTimestamp())); + values.put(Messages.DATE_READ, dateFormat.format(new Date())); mService.getContentResolver().insert(Messages.CONTENT_URI, values); } } } + + /** + * Make an xmpp uri for a spcific jid. + * @param jid the jid to represent as an uri + * @return an uri representing this jid. + */ + public static Uri makeXmppUri(String jid) { + StringBuilder build = new StringBuilder("xmpp:"); + String name = StringUtils.parseName(jid); + build.append(name); + if (!"".equals(name)) + build.append('@'); + build.append(StringUtils.parseServer(jid)); + String resource = StringUtils.parseResource(jid); + if (!"".equals(resource)) { + build.append('/'); + build.append(resource); + } + Uri u = Uri.parse(build.toString()); + return u; + } + } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/XmppFacade.java --- a/src/com/beem/project/beem/service/XmppFacade.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,160 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service; - -import org.jivesoftware.smack.packet.Presence; - -import android.os.RemoteException; - -import com.beem.project.beem.service.aidl.IChatManager; -import com.beem.project.beem.service.aidl.IPrivacyListManager; -import com.beem.project.beem.service.aidl.IRoster; -import com.beem.project.beem.service.aidl.IXmppConnection; -import com.beem.project.beem.service.aidl.IXmppFacade; -import com.beem.project.beem.utils.PresenceType; -import com.beem.project.beem.smack.avatar.AvatarManager; - -/** - * This class is a facade for the Beem Service. - * @author darisk - */ -public class XmppFacade extends IXmppFacade.Stub { - - private final XmppConnectionAdapter mConnexion; - - /** - * Constructor for XMPPFacade. - * @param connection the connection use by the facade - */ - public XmppFacade(final XmppConnectionAdapter connection) { - this.mConnexion = connection; - } - - /** - * {@inheritDoc} - */ - @Override - public void changeStatus(int status, String msg) { - mConnexion.changeStatus(status, msg); - } - - /** - * {@inheritDoc} - */ - @Override - public void connectAsync() throws RemoteException { - mConnexion.connectAsync(); - } - - /** - * {@inheritDoc} - */ - @Override - public void connectSync() throws RemoteException { - mConnexion.connectSync(); - } - - /** - * {@inheritDoc} - */ - @Override - public IXmppConnection createConnection() throws RemoteException { - return mConnexion; - } - - /** - * {@inheritDoc} - */ - @Override - public void disconnect() throws RemoteException { - mConnexion.disconnect(); - } - - /** - * {@inheritDoc} - */ - @Override - public IChatManager getChatManager() throws RemoteException { - return mConnexion.getChatManager(); - } - - /** - * {@inheritDoc} - */ - @Override - public IRoster getRoster() throws RemoteException { - return mConnexion.getRoster(); - } - - /** - * {@inheritDoc} - */ - @Override - public IPrivacyListManager getPrivacyListManager() { - return mConnexion.getPrivacyListManager(); - } - - @Override - public void sendPresencePacket(PresenceAdapter presence) throws RemoteException { - Presence presence2 = new Presence(PresenceType.getPresenceTypeFrom(presence.getType())); - presence2.setTo(presence.getTo()); - mConnexion.getAdaptee().sendPacket(presence2); - } - - /* (non-Javadoc) - * @see com.beem.project.beem.service.aidl.IXmppFacade#call(java.lang.String) - */ - @Override - public void call(String jid) throws RemoteException { - } - - @Override - public byte[] getAvatar(String avatarId) throws RemoteException { - AvatarManager mgr = mConnexion.getAvatarManager(); - if (mgr == null) - return null; - - return mgr.getAvatar(avatarId); - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl --- a/src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/service/aidl/IBeemRosterListener.aidl Sun Nov 06 04:27:09 2011 +0100 @@ -49,5 +49,5 @@ void onEntriesAdded(in List addresses); void onEntriesUpdated(in List addresses); void onEntriesDeleted(in List addresses); - void onPresenceChanged(in PresenceAdapter presence); + //void onPresenceChanged(in PresenceAdapter presence); } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IChat.aidl --- a/src/com/beem/project/beem/service/aidl/IChat.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service.aidl; - -import com.beem.project.beem.service.Contact; -import com.beem.project.beem.service.Message; -import com.beem.project.beem.service.aidl.IMessageListener; - -/** - * An aidl interface for Chat session. - */ -interface IChat { - - /** - * Send a message. - * @param message the message to send - */ - void sendMessage(in Message message); - - /** - * Get the participant of the chat - * @return the participant - */ - Contact getParticipant(); - - /** - * Add a message listener. - * @param listener the listener to add. - */ - void addMessageListener(in IMessageListener listener); - - /** - * Remove a message listener. - * @param listener the listener to remove. - */ - void removeMessageListener(in IMessageListener listener); - - String getState(); - - void setOpen(in boolean isOpen); - - boolean isOpen(); - - void setState(in String state); - - List getMessages(); - -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IChatManager.aidl --- a/src/com/beem/project/beem/service/aidl/IChatManager.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,99 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service.aidl; - -import com.beem.project.beem.service.Contact; -import com.beem.project.beem.service.aidl.IChat; -import com.beem.project.beem.service.aidl.IMessageListener; -import com.beem.project.beem.service.aidl.IChatManagerListener; - -/** - * Aidl interface for a chat manager. - * The chat manager will manage all the chat sessions. - */ -interface IChatManager { - - /** - * Create a chat session with a contact. - * @param contact the contact to chat with - * @param listener the callback to call when a new message comes from this chat session - * @return the chat session - */ - IChat createChat(in Contact contact, in IMessageListener listener); - - /** - * Get an existing Chat session with a contact. - * @return null if the chat session does not exist. - */ - IChat getChat(in Contact contact); - - /** - * Destroy a chat session with a contact. - * @param chat the chat session - */ - void destroyChat(in IChat chat); - - /** - * @param chat the chat. - */ - void deleteChatNotification(in IChat chat); - - /** - * Register a callback to call when a new chat session is created. - * @param listener the callback to add - */ - void addChatCreationListener(in IChatManagerListener listener); - - /** - * Remove a callback for the creation of new chat session. - * @param listener the callback to remove. - */ - void removeChatCreationListener(in IChatManagerListener listener); - - /** - * Get a list of contact which we are currently chatting. - * @return list of contact. - */ - List getOpenedChatList(); -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IChatManagerListener.aidl --- a/src/com/beem/project/beem/service/aidl/IChatManagerListener.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service.aidl; - -import com.beem.project.beem.service.aidl.IChat; - -/** - * Aidl interface for ChatManager listener. - * This listener will execute on events like creation of chat session. - */ -interface IChatManagerListener { - - /** - * Call when a new chat session is created. - * @param chat the created chat session - * @param locally true if the session is create by a chat manager. - */ - void chatCreated(IChat chat, boolean locally); - -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IContact.aidl --- a/src/com/beem/project/beem/service/aidl/IContact.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,53 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service.aidl; - -interface IContact { - - String getJID(); - - void setJID(String mjid); - -} - diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IMessageListener.aidl --- a/src/com/beem/project/beem/service/aidl/IMessageListener.aidl Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/service/aidl/IMessageListener.aidl Sun Nov 06 04:27:09 2011 +0100 @@ -53,12 +53,12 @@ * @param chat the chat receiving the message. * @param msg the message received in the chat. */ - void processMessage(in IChat chat, in Message msg); + //void processMessage(in IChat chat, in Message msg); /** * This method is executed when a new ChatState is received by the chat. * You can use IChat.getState() in order to get the new state. * @param chat the chat changed. */ - void stateChanged(in IChat chat); + //void stateChanged(in IChat chat); } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IPrivacyListListener.aidl --- a/src/com/beem/project/beem/service/aidl/IPrivacyListListener.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service.aidl; - -import com.beem.project.beem.service.PrivacyListItem; - -interface IPrivacyListListener { - void updatedPrivacyList(in String listName); - void setPrivacyList(in String listName, in List listItem); -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IPrivacyListManager.aidl --- a/src/com/beem/project/beem/service/aidl/IPrivacyListManager.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,66 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service.aidl; - -import com.beem.project.beem.service.PrivacyListItem; -import com.beem.project.beem.service.aidl.IPrivacyListListener; - -interface IPrivacyListManager { - void createPrivacyList(in String listName, in List items); - void removePrivacyList(in String listName); - void editPrivacyList(in String listName, in List items); - String getActivePrivacyList(); - String getDefaultPrivacyList(); - void setActivePrivacyList(in String listName); - void setDefaultPrivacyList(in String listName); - void declineActivePrivacyList(); - void declineDefaultPrivacyList(); - List getPrivacyLists(); - void blockUser(in String listName, in String jid); - List getBlockedUsersByList(in String listName); - List getBlockedGroupsByList(in String listName); - void addPrivacyListListener(in IPrivacyListListener listener); - void removePrivacyListListener(in IPrivacyListListener listener); -} - diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IRoster.aidl --- a/src/com/beem/project/beem/service/aidl/IRoster.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,74 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service.aidl; - -import com.beem.project.beem.service.aidl.IBeemRosterListener; -import com.beem.project.beem.service.Contact; -import com.beem.project.beem.service.PresenceAdapter; - -interface IRoster { - - Contact addContact(in String user, in String name, in String[] groups); - - void deleteContact(in Contact contact); - - Contact getContact(in String jid); - void setContactName(in String jid, in String name); - - void createGroup(in String groupname); - - void addContactToGroup(in String groupName, in String jid); - - void removeContactFromGroup(in String groupName, in String jid); - - List getContactList(); - - List getGroupsNames(); - - PresenceAdapter getPresence(in String jid); - - void addRosterListener(in IBeemRosterListener listen); - void removeRosterListener(in IBeemRosterListener listen); - -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IXmppConnection.aidl --- a/src/com/beem/project/beem/service/aidl/IXmppConnection.aidl Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/service/aidl/IXmppConnection.aidl Sun Nov 06 04:27:09 2011 +0100 @@ -43,10 +43,8 @@ */ package com.beem.project.beem.service.aidl; -import com.beem.project.beem.service.aidl.IRoster; import com.beem.project.beem.service.aidl.IBeemConnectionListener; -import com.beem.project.beem.service.aidl.IChatManager; -import com.beem.project.beem.service.aidl.IPrivacyListManager; + interface IXmppConnection { @@ -60,20 +58,20 @@ boolean disconnect(); - IRoster getRoster(); + //IRoster getRoster(); void addConnectionListener(in IBeemConnectionListener listen); void removeConnectionListener(in IBeemConnectionListener listen); boolean isAuthentificated(); - IChatManager getChatManager(); + //IChatManager getChatManager(); void changeStatusAndPriority(in int status, in String msg, in int priority); void changeStatus(in int status, in String msg); - IPrivacyListManager getPrivacyListManager(); + //IPrivacyListManager getPrivacyListManager(); String getErrorMessage(); } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/service/aidl/IXmppFacade.aidl --- a/src/com/beem/project/beem/service/aidl/IXmppFacade.aidl Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,106 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.service.aidl; - -import com.beem.project.beem.service.aidl.IXmppConnection; -import com.beem.project.beem.service.aidl.IRoster; -import com.beem.project.beem.service.aidl.IChatManager; -import com.beem.project.beem.service.aidl.IPrivacyListManager; -import com.beem.project.beem.service.PresenceAdapter; - -interface IXmppFacade { - - /** - * Get the XmppConnection of the facade. - */ - IXmppConnection createConnection(); - - /** - * Get the roster of the user - */ - IRoster getRoster(); - - /** - * Connect and login synchronously on the server. - */ - void connectSync(); - - /** - * Connect and login asynchronously on the server. - */ - void connectAsync(); - - /** - * Disconnect from the server - */ - void disconnect(); - - /** - * Get the chat manager. - */ - IChatManager getChatManager(); - - /** - * Change the status of the user. - * @param status the status to set - * @param msg the message state to set - */ - void changeStatus(in int status, in String msg); - - void sendPresencePacket(in PresenceAdapter presence); - - /** - * make a jingle audio call - * @param jid the receiver id - */ - void call(in String jid); - - /** - * get the an avatar - * @param id the id of the avatar - */ - byte[] getAvatar(in String id); - - IPrivacyListManager getPrivacyListManager(); -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/AddContact.java --- a/src/com/beem/project/beem/ui/AddContact.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/AddContact.java Sun Nov 06 04:27:09 2011 +0100 @@ -40,7 +40,7 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. -*/ + */ package com.beem.project.beem.ui; import java.util.ArrayList; @@ -51,20 +51,14 @@ import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; -import android.content.ServiceConnection; import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; -import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.Toast; -import com.beem.project.beem.BeemService; import com.beem.project.beem.R; -import com.beem.project.beem.service.aidl.IXmppFacade; import com.beem.project.beem.utils.BeemBroadcastReceiver; /** @@ -76,8 +70,6 @@ private static final Intent SERVICE_INTENT = new Intent(); private static final String TAG = "AddContact"; private final List mGroup = new ArrayList(); - private IXmppFacade mXmppFacade; - private final ServiceConnection mServConn = new BeemServiceConnection(); private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); private final OkListener mOkListener = new OkListener(); @@ -103,7 +95,8 @@ this.registerReceiver(mReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see android.app.Activity#onStart() */ @Override @@ -117,7 +110,7 @@ @Override protected void onResume() { super.onResume(); - bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); +// bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); } /** @@ -126,10 +119,11 @@ @Override protected void onPause() { super.onPause(); - unbindService(mServConn); +// unbindService(mServConn); } - /* (non-Javadoc) + /* + * (non-Javadoc) * @see android.app.Activity#onDestroy() */ @Override @@ -139,28 +133,6 @@ } /** - * The ServiceConnection used to connect to the Beem service. - */ - private class BeemServiceConnection implements ServiceConnection { - - /** - * Constructor. - */ - public BeemServiceConnection() { - } - - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - mXmppFacade = IXmppFacade.Stub.asInterface(service); - } - - @Override - public void onServiceDisconnected(ComponentName name) { - mXmppFacade = null; - } - } - - /** * Get the text of a widget. * @param id the id of the widget. * @return the text of the widget. @@ -178,7 +150,8 @@ /** * Constructor. */ - public OkListener() { } + public OkListener() { + } @Override public void onClick(View v) { @@ -198,28 +171,28 @@ alias = getWidgetText(R.id.addc_alias); if (getWidgetText(R.id.addc_group).length() != 0) mGroup.add(getWidgetText(R.id.addc_group)); - try { - if (mXmppFacade != null) { - if (mXmppFacade.getRoster().getContact(login) != null) { - mGroup.addAll(mXmppFacade.getRoster().getContact(login).getGroups()); - Toast.makeText(AddContact.this, getString(R.string.AddCContactAlready), Toast.LENGTH_SHORT) - .show(); - return; - } - if (mXmppFacade.getRoster().addContact(login, alias, mGroup.toArray(new String[mGroup.size()])) == null) { - Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedError), Toast.LENGTH_SHORT) - .show(); - return; - } else { - Toast.makeText(AddContact.this, getString(R.string.AddCContactAdded), Toast.LENGTH_SHORT) - .show(); - finish(); - } - } - } catch (RemoteException e) { - Toast.makeText(AddContact.this, e.getMessage(), Toast.LENGTH_SHORT).show(); - Log.e(TAG, "Problem adding contact", e); - } + // try { + // if (mXmppFacade != null) { + // if (mXmppFacade.getRoster().getContact(login) != null) { + // mGroup.addAll(mXmppFacade.getRoster().getContact(login).getGroups()); + // Toast.makeText(AddContact.this, getString(R.string.AddCContactAlready), Toast.LENGTH_SHORT) + // .show(); + // return; + // } + // if (mXmppFacade.getRoster().addContact(login, alias, mGroup.toArray(new String[mGroup.size()])) == null) { + // Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedError), Toast.LENGTH_SHORT) + // .show(); + // return; + // } else { + // Toast.makeText(AddContact.this, getString(R.string.AddCContactAdded), Toast.LENGTH_SHORT) + // .show(); + // finish(); + // } + // } + // } catch (RemoteException e) { + // Toast.makeText(AddContact.this, e.getMessage(), Toast.LENGTH_SHORT).show(); + // Log.e(TAG, "Problem adding contact", e); + // } } }; diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/ChangeStatus.java --- a/src/com/beem/project/beem/ui/ChangeStatus.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/ChangeStatus.java Sun Nov 06 04:27:09 2011 +0100 @@ -48,12 +48,9 @@ import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; -import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; import android.preference.PreferenceManager; import android.view.View; import android.view.View.OnClickListener; @@ -63,12 +60,10 @@ import android.widget.Spinner; import android.widget.Toast; +import com.beem.project.beem.BeemApplication; import com.beem.project.beem.BeemService; -import com.beem.project.beem.BeemApplication; import com.beem.project.beem.R; -import com.beem.project.beem.service.aidl.IXmppFacade; import com.beem.project.beem.utils.BeemBroadcastReceiver; -import com.beem.project.beem.utils.BeemConnectivity; import com.beem.project.beem.utils.Status; /** @@ -98,8 +93,6 @@ private SharedPreferences mSettings; private ArrayAdapter mAdapter; - private IXmppFacade mXmppFacade; - private final ServiceConnection mServConn = new BeemServiceConnection(); private final OnClickListener mOnClickOk = new MyOnClickListener(); private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); @@ -225,35 +218,6 @@ } /** - * connection to service. - * @author nikita - */ - private class BeemServiceConnection implements ServiceConnection { - - /** - * constructor. - */ - public BeemServiceConnection() { - } - - /** - * {@inheritDoc} - */ - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - mXmppFacade = IXmppFacade.Stub.asInterface(service); - } - - /** - * {@inheritDoc} - */ - @Override - public void onServiceDisconnected(ComponentName name) { - mXmppFacade = null; - } - } - - /** * User have clicked on ok. * @author nikita */ @@ -275,12 +239,12 @@ if (status == Status.CONTACT_STATUS_DISCONNECT) { stopService(new Intent(ChangeStatus.this, BeemService.class)); } else { - try { - mXmppFacade.changeStatus(status, msg.toString()); - edit.putInt(BeemApplication.STATUS_KEY, mSpinner.getSelectedItemPosition()); - } catch (RemoteException e) { - e.printStackTrace(); - } +// try { +// mXmppFacade.changeStatus(status, msg.toString()); +// edit.putInt(BeemApplication.STATUS_KEY, mSpinner.getSelectedItemPosition()); +// } catch (RemoteException e) { +// e.printStackTrace(); +// } mToast.show(); } edit.commit(); diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/Chat.java --- a/src/com/beem/project/beem/ui/Chat.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/Chat.java Sun Nov 06 04:27:09 2011 +0100 @@ -43,6 +43,8 @@ */ package com.beem.project.beem.ui; +import org.jivesoftware.smack.packet.Message; + import android.app.Activity; import android.content.Context; import android.content.Intent; @@ -52,15 +54,15 @@ import android.net.Uri; import android.os.Bundle; import android.preference.PreferenceManager; -import android.provider.ContactsContract.Contacts; import android.provider.ContactsContract.RawContacts; +import android.telephony.gsm.SmsMessage.MessageClass; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.View; -import android.view.ViewGroup; import android.view.View.OnClickListener; import android.view.View.OnKeyListener; +import android.view.ViewGroup; import android.widget.Button; import android.widget.EditText; import android.widget.Filterable; @@ -72,7 +74,6 @@ import com.beem.project.beem.BeemIntent; import com.beem.project.beem.R; import com.beem.project.beem.providers.Messages; -import com.beem.project.beem.service.Message; /** * The chat activity for communication with 1 contact. @@ -103,10 +104,10 @@ Cursor cursorAccount = getContentResolver().query(RawContacts.CONTENT_URI, new String[] { RawContacts._ID, RawContacts.ACCOUNT_NAME }, RawContacts.SOURCE_ID + "=?", new String[] { mjid }, null); - Log.e(TAG, "Cursor :" + cursorAccount.toString()); + if (cursorAccount.getCount() == 1) { cursorAccount.moveToFirst(); - mAccount = cursorAccount.getColumnName(cursorAccount.getColumnIndex(RawContacts.ACCOUNT_NAME)); + mAccount = cursorAccount.getString(cursorAccount.getColumnIndex(RawContacts.ACCOUNT_NAME)); } else if (cursorAccount.getCount() > 1) { // TODO : get account from jid. if multi account propose select } @@ -173,13 +174,11 @@ private void sendMessage() { EditText inputField = (EditText) findViewById(R.id.chat_input); final String inputContent = inputField.getText().toString(); - - Message message = new Message(mjid, Message.MSG_TYPE_CHAT); - message.setBody(inputContent); - + Intent intent = new Intent(BeemIntent.ACTION_SEND_MESSAGE); intent.putExtra(BeemIntent.EXTRA_ACCOUNT, mAccount); - intent.putExtra(BeemIntent.EXTRA_MESSAGE, message); + intent.putExtra(BeemIntent.EXTRA_JID, mjid); + intent.putExtra(BeemIntent.EXTRA_MESSAGE, inputContent); startService(intent); inputField.setText(null); diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/ContactList.java Sun Nov 06 04:27:09 2011 +0100 @@ -28,11 +28,7 @@ */ package com.beem.project.beem.ui; -import java.util.Comparator; -import java.util.List; - import android.app.Activity; -import android.app.Dialog; import android.content.ComponentName; import android.content.Context; import android.content.Intent; @@ -42,7 +38,6 @@ import android.net.Uri; import android.os.Bundle; import android.os.Handler; -import android.os.RemoteException; import android.preference.PreferenceManager; import android.provider.ContactsContract; import android.util.Log; @@ -65,14 +60,6 @@ import com.beem.project.beem.BeemIntent; import com.beem.project.beem.R; -import com.beem.project.beem.service.Contact; -import com.beem.project.beem.service.aidl.IChatManager; -import com.beem.project.beem.service.aidl.IRoster; -import com.beem.project.beem.service.aidl.IXmppFacade; -import com.beem.project.beem.ui.dialogs.builders.Alias; -import com.beem.project.beem.ui.dialogs.builders.ChatList; -import com.beem.project.beem.ui.dialogs.builders.DeleteContact; -import com.beem.project.beem.ui.dialogs.builders.ResendSubscription; /** * The contact list activity displays the roster of the user. @@ -95,11 +82,6 @@ private final BeemContactListOnClick mOnContactClick = new BeemContactListOnClick(); - private final ComparatorContactListByStatusAndName mComparator = new ComparatorContactListByStatusAndName(); - private IRoster mRoster; - private Contact mSelectedContact; - private IXmppFacade mXmppFacade; - private IChatManager mChatManager; private SharedPreferences mSettings; private BeemBanner mAdapterBanner; private BeemContactList mAdapterContactList; @@ -175,16 +157,16 @@ startActivity(new Intent(ContactList.this, ChangeStatus.class)); return true; case R.id.contact_list_menu_chatlist: - List openedChats; - try { - openedChats = mChatManager.getOpenedChatList(); - Log.d(TAG, "opened chats = " + openedChats); - Dialog chatList = new ChatList(ContactList.this, openedChats).create(); - chatList.show(); - } catch (RemoteException e) { - e.printStackTrace(); - } - return true; + // List openedChats; + // try { + // openedChats = mChatManager.getOpenedChatList(); + // Log.d(TAG, "opened chats = " + openedChats); + // Dialog chatList = new ChatList(ContactList.this, openedChats).create(); + // chatList.show(); + // } catch (RemoteException e) { + // e.printStackTrace(); + // } + // return true; case R.id.contact_list_menu_sync: Intent intent = new Intent(BeemIntent.ACTION_SYNC); intent.putExtra(BeemIntent.EXTRA_ACCOUNT, mAccountName); @@ -217,66 +199,63 @@ public boolean onContextItemSelected(MenuItem item) { Intent in; boolean result; - if (mSelectedContact != null) { - switch (item.getItemId()) { - case R.id.contact_list_context_menu_chat_item: - List res = mSelectedContact.getMRes(); - if (res.isEmpty()) { - result = false; - break; - } - for (String resv : res) { - in = new Intent(this, Chat.class); - in.setData(mSelectedContact.toUri(resv)); - item.getSubMenu().add(resv).setIntent(in); - } - result = true; - break; - case R.id.contact_list_context_menu_call_item: - try { - mXmppFacade.call(mSelectedContact.getJID() + "/psi"); - result = true; - } catch (RemoteException e) { - e.printStackTrace(); - } - result = true; - break; - case R.id.contact_list_context_menu_user_info: - item.getSubMenu().setHeaderTitle(mSelectedContact.getJID()); - result = true; - break; - case R.id.contact_list_context_menu_userinfo_alias: - Dialog alias = new Alias(ContactList.this, mRoster, mSelectedContact).create(); - alias.show(); - result = true; - break; - case R.id.contact_list_context_menu_userinfo_group: - in = new Intent(this, GroupList.class); - in.putExtra("contact", mSelectedContact); - startActivity(in); - result = true; - break; - case R.id.contact_list_context_menu_userinfo_subscription: - Dialog subscription = new ResendSubscription(ContactList.this, mXmppFacade, mSelectedContact) - .create(); - subscription.show(); - result = true; - break; - case R.id.contact_list_context_menu_userinfo_block: - result = true; - break; - case R.id.contact_list_context_menu_userinfo_delete: - Dialog delete = new DeleteContact(ContactList.this, mRoster, mSelectedContact).create(); - delete.show(); - result = true; - break; - default: - result = super.onContextItemSelected(item); - break; - } - return result; + switch (item.getItemId()) { + case R.id.contact_list_context_menu_chat_item: + // List res = mSelectedContact.getMRes(); + // if (res.isEmpty()) { + // result = false; + // break; + // } + // for (String resv : res) { + // in = new Intent(this, Chat.class); + // in.setData(mSelectedContact.toUri(resv)); + // item.getSubMenu().add(resv).setIntent(in); + // } + result = true; + break; + case R.id.contact_list_context_menu_call_item: + // try { + // mXmppFacade.call(mSelectedContact.getJID() + "/psi"); + // result = true; + // } catch (RemoteException e) { + // e.printStackTrace(); + // } + result = true; + break; + case R.id.contact_list_context_menu_user_info: + // item.getSubMenu().setHeaderTitle(mSelectedContact.getJID()); + result = true; + break; + case R.id.contact_list_context_menu_userinfo_alias: + // Dialog alias = new Alias(ContactList.this, mRoster, mSelectedContact).create(); + // alias.show(); + result = true; + break; + case R.id.contact_list_context_menu_userinfo_group: + // in = new Intent(this, GroupList.class); + // in.putExtra("contact", mSelectedContact); + // startActivity(in); + result = true; + break; + case R.id.contact_list_context_menu_userinfo_subscription: + // Dialog subscription = new ResendSubscription(ContactList.this, mXmppFacade, mSelectedContact) + // .create(); + // subscription.show(); + result = true; + break; + case R.id.contact_list_context_menu_userinfo_block: + result = true; + break; + case R.id.contact_list_context_menu_userinfo_delete: + // Dialog delete = new DeleteContact(ContactList.this, mRoster, mSelectedContact).create(); + // delete.show(); + result = true; + break; + default: + result = super.onContextItemSelected(item); + break; } - return super.onContextItemSelected(item); + return result; } /** @@ -462,27 +441,6 @@ } /** - * Comparator Contact by status and name. - */ - private static class ComparatorContactListByStatusAndName implements Comparator { - /** - * Constructor. - */ - public ComparatorContactListByStatusAndName() { - } - - @Override - public int compare(T c1, T c2) { - if (((Contact) c1).getStatus() < ((Contact) c2).getStatus()) { - return 1; - } else if (((Contact) c1).getStatus() > ((Contact) c2).getStatus()) { - return -1; - } else - return ((Contact) c1).getName().compareToIgnoreCase(((Contact) c2).getName()); - } - } - - /** * Event simple click on item of the contact list. */ private class BeemContactListOnClick implements OnItemClickListener { diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/GroupList.java --- a/src/com/beem/project/beem/ui/GroupList.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/GroupList.java Sun Nov 06 04:27:09 2011 +0100 @@ -50,25 +50,18 @@ import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; -import android.content.ServiceConnection; import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; import android.view.KeyEvent; import android.view.View; import android.view.View.OnKeyListener; import android.widget.AdapterView; +import android.widget.AdapterView.OnItemClickListener; import android.widget.ArrayAdapter; import android.widget.CheckedTextView; import android.widget.ListView; import android.widget.TextView; -import android.widget.AdapterView.OnItemClickListener; -import com.beem.project.beem.BeemService; import com.beem.project.beem.R; -import com.beem.project.beem.service.Contact; -import com.beem.project.beem.service.aidl.IRoster; -import com.beem.project.beem.service.aidl.IXmppFacade; import com.beem.project.beem.utils.BeemBroadcastReceiver; /** @@ -79,13 +72,11 @@ private static final Intent SERVICE_INTENT = new Intent(); - private final ServiceConnection mServConn = new BeemServiceConnection(); private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); - private IXmppFacade mXmppFacade; - private IRoster mRoster; + private String mJID; private ArrayAdapter mGroups; - private Contact mContact; + private TextView mText; private final List mStrings = new ArrayList(); @@ -106,8 +97,8 @@ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.group_list); - mContact = getIntent().getParcelableExtra("contact"); - mJID = mContact.getJID(); +// mContact = getIntent().getParcelableExtra("contact"); +// mJID = mContact.getJID(); final ListView listView = getListView(); listView.setItemsCanFocus(false); @@ -125,7 +116,7 @@ @Override protected void onResume() { super.onResume(); - bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); + //bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); } /** @@ -134,7 +125,7 @@ @Override protected void onPause() { super.onPause(); - unbindService(mServConn); + //unbindService(mServConn); } /* (non-Javadoc) @@ -150,19 +141,19 @@ * init activity list adapter. */ private void setAdapter() { - try { - for (String group : mRoster.getGroupsNames()) { - mStrings.add(group); - } - mGroups = new ArrayAdapter(this, android.R.layout.simple_list_item_multiple_choice, mStrings); - setListAdapter(mGroups); - mContact = mRoster.getContact(mJID); - for (String group : mContact.getGroups()) { - getListView().setItemChecked(mGroups.getPosition(group), true); - } - } catch (RemoteException e) { - e.printStackTrace(); - } +// try { +// for (String group : mRoster.getGroupsNames()) { +// mStrings.add(group); +// } +// mGroups = new ArrayAdapter(this, android.R.layout.simple_list_item_multiple_choice, mStrings); +// setListAdapter(mGroups); +// mContact = mRoster.getContact(mJID); +// for (String group : mContact.getGroups()) { +// getListView().setItemChecked(mGroups.getPosition(group), true); +// } +// } catch (RemoteException e) { +// e.printStackTrace(); +// } } /** @@ -213,51 +204,21 @@ @Override public void onItemClick(AdapterView arg0, View v, int arg2, long arg3) { CheckedTextView textView = (CheckedTextView) v; - if (!textView.isChecked()) { - try { - mRoster.addContactToGroup(textView.getText().toString(), mJID); - } catch (RemoteException e) { - e.printStackTrace(); - } - } else { - try { - mRoster.removeContactFromGroup(textView.getText().toString(), mJID); - } catch (RemoteException e) { - e.printStackTrace(); - } - } +// if (!textView.isChecked()) { +// try { +// mRoster.addContactToGroup(textView.getText().toString(), mJID); +// } catch (RemoteException e) { +// e.printStackTrace(); +// } +// } else { +// try { +// mRoster.removeContactFromGroup(textView.getText().toString(), mJID); +// } catch (RemoteException e) { +// e.printStackTrace(); +// } +// } } } - - /** - * The ServiceConnection used to connect to the Beem service. - */ - private class BeemServiceConnection implements ServiceConnection { - - /** - * Constructor. - */ - public BeemServiceConnection() { - } - - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - mXmppFacade = IXmppFacade.Stub.asInterface(service); - try { - mRoster = mXmppFacade.getRoster(); - setAdapter(); - } catch (RemoteException e) { - e.printStackTrace(); - } - } - - @Override - public void onServiceDisconnected(ComponentName name) { - mXmppFacade = null; - mRoster = null; - } - } - } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/PrivacyList.java --- a/src/com/beem/project/beem/ui/PrivacyList.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,361 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.ui; - -import java.util.ArrayList; -import java.util.List; - -import android.app.Dialog; -import android.app.ListActivity; -import android.content.ComponentName; -import android.content.DialogInterface; -import android.content.Intent; -import android.content.IntentFilter; -import android.content.ServiceConnection; -import android.content.DialogInterface.OnDismissListener; -import android.os.Bundle; -import android.os.Handler; -import android.os.IBinder; -import android.os.RemoteException; -import android.util.Log; -import android.view.ContextMenu; -import android.view.Menu; -import android.view.MenuInflater; -import android.view.MenuItem; -import android.view.View; -import android.widget.AdapterView; -import android.widget.ArrayAdapter; - -import com.beem.project.beem.R; -import com.beem.project.beem.service.PrivacyListItem; -import com.beem.project.beem.service.aidl.IPrivacyListListener; -import com.beem.project.beem.service.aidl.IPrivacyListManager; -import com.beem.project.beem.service.aidl.IXmppFacade; -import com.beem.project.beem.ui.dialogs.builders.CreatePrivacyList; -import com.beem.project.beem.ui.dialogs.builders.DeletePrivacyList; -import com.beem.project.beem.utils.BeemBroadcastReceiver; - -/** - * This class represents an activity which allows the user to manage his privacy lists. - * @author Jean-Manuel Da Silva - */ -public class PrivacyList extends ListActivity { - - private static final String TAG = "PrivacyList"; - private static final Intent SERVICE_INTENT = new Intent(); - static { - SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); - } - - private static final int DIALOG_CREATE = 0; - private static final int DIALOG_UPDATE_BUDDIES = 1; - private static final int DIALOG_UPDATE_GROUPS = 2; - private static final int DIALOG_DELETE = 3; - - private static final String SAVED_INSTANCE_KEY_PRIVACY_LISTS = "PRIVACY_LISTS"; - - private Handler mHandler = new Handler(); - - private ArrayAdapter mAdapter; - private final List mPrivacyListNames = new ArrayList(); - private String mCurrPrivacyListName; - - private final ServiceConnection mConn = new BeemServiceConnection(); - private final BeemBroadcastReceiver mBroadcastReceiver = new BeemBroadcastReceiver(); - - private IPrivacyListManager mPrivacyListManager; - private IPrivacyListListener mPrivacyListListener; - - /** - * Constructor. - */ - public PrivacyList() { - super(); - } - - /** - * {@inheritDoc}. - */ - @Override - protected void onSaveInstanceState(Bundle savedInstanceState) { - Log.d(TAG, "BEGIN onSaveInstanceState."); - savedInstanceState.putStringArrayList(SAVED_INSTANCE_KEY_PRIVACY_LISTS, (ArrayList) mPrivacyListNames); - Log.d(TAG, "END onSaveInstanceState."); - super.onSaveInstanceState(savedInstanceState); - } - - /** - * {@inheritDoc}. - */ - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Log.d(TAG, "BEGIN onCreate."); - - setContentView(R.layout.privacy_list); - registerForContextMenu(this.getListView()); - - mHandler = new Handler(); - - if (savedInstanceState != null && !savedInstanceState.isEmpty()) { - mPrivacyListNames.addAll(savedInstanceState.getStringArrayList(SAVED_INSTANCE_KEY_PRIVACY_LISTS)); - } - - mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mPrivacyListNames); - setListAdapter(mAdapter); - - bindService(SERVICE_INTENT, mConn, BIND_AUTO_CREATE); - - mPrivacyListListener = new PrivacyListListener(); - this.registerReceiver(mBroadcastReceiver, new IntentFilter(BeemBroadcastReceiver.BEEM_CONNECTION_CLOSED)); - - Log.d(TAG, "END onCreate."); - } - - /** - * {@inheritDoc}. - */ - @Override - protected void onDestroy() { - super.onDestroy(); - - Log.v(TAG, "BEGIN onDestroy."); - - if (mPrivacyListManager != null) { - try { - mPrivacyListManager.removePrivacyListListener(mPrivacyListListener); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - } - - this.unregisterReceiver(mBroadcastReceiver); - unbindService(mConn); - - Log.v(TAG, "END onDestroy."); - } - - /** - * {@inheritDoc}. - */ - @Override - protected void onStart() { - super.onStart(); - - Log.v(TAG, "BEGIN onStart."); - Log.v(TAG, "END onStart."); - } - - /** - * {@inheritDoc}. - */ - @Override - protected void onStop() { - super.onStop(); - - Log.v(TAG, "BEGIN onStop."); - Log.v(TAG, "END onStop."); - } - - /** - * {@inheritDoc}. - */ - @Override - protected Dialog onCreateDialog(int id) { - Dialog dialog; - switch (id) { - case DIALOG_CREATE: - dialog = new CreatePrivacyList(PrivacyList.this, mPrivacyListManager).create(); - dialog.setOnDismissListener(new OnDismissListener() { - - @Override - public void onDismiss(DialogInterface dialog) { - PrivacyList.this.removeDialog(DIALOG_CREATE); - } - }); - break; - case DIALOG_DELETE: - dialog = new DeletePrivacyList(PrivacyList.this, mPrivacyListManager, mCurrPrivacyListName).create(); - dialog.setOnDismissListener(new OnDismissListener() { - - @Override - public void onDismiss(DialogInterface dialog) { - PrivacyList.this.removeDialog(DIALOG_DELETE); - } - - }); - break; - default: - dialog = null; - } - return dialog; - } - - /** - * {@inheritDoc}. - */ - @Override - public final boolean onCreateOptionsMenu(Menu menu) { - super.onCreateOptionsMenu(menu); - - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.privacy_list, menu); - return true; - } - - /** - * {@inheritDoc} - */ - @Override - public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { - super.onCreateContextMenu(menu, v, menuInfo); - MenuInflater inflater = getMenuInflater(); - inflater.inflate(R.menu.privacy_list_context, menu); - mCurrPrivacyListName = mPrivacyListNames.get(((AdapterView.AdapterContextMenuInfo) menuInfo).position); - menu.setHeaderTitle(mCurrPrivacyListName); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean onContextItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.privacy_list_context_menu_buddies_item: - return true; - case R.id.privacy_list_context_menu_groups_item: - return true; - case R.id.privacy_list_context_menu_delete_item: - showDialog(DIALOG_DELETE); - return true; - default: - return super.onContextItemSelected(item); - } - } - - /** - * {@inheritDoc}. - */ - @Override - public final boolean onOptionsItemSelected(MenuItem item) { - switch (item.getItemId()) { - case R.id.privacy_list_menu_create: - showDialog(DIALOG_CREATE); - return true; - default: - return false; - } - } - - /** - * Service connection. - * @author jamu - */ - private final class BeemServiceConnection implements ServiceConnection { - - private IXmppFacade mXmppFacade; - - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - Log.v(TAG, "BEGIN onServiceConnected."); - mXmppFacade = IXmppFacade.Stub.asInterface(service); - try { - mPrivacyListManager = mXmppFacade.getPrivacyListManager(); - mPrivacyListManager.addPrivacyListListener(mPrivacyListListener); - mPrivacyListNames.clear(); - mPrivacyListNames.addAll(mPrivacyListManager.getPrivacyLists()); - mAdapter.notifyDataSetChanged(); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - Log.v(TAG, "END onServiceConnected."); - } - - @Override - public void onServiceDisconnected(ComponentName name) { - Log.v(TAG, "BEGIN onServiceDisconnected."); - mXmppFacade = null; - try { - mPrivacyListManager.removePrivacyListListener(mPrivacyListListener); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - Log.v(TAG, "END onServiceDisconnected."); - } - } - - /** - * Listener. - * @author jamu - */ - private class PrivacyListListener extends IPrivacyListListener.Stub { - - @Override - public void setPrivacyList(String listName, List listItem) throws RemoteException { - Log.d(TAG, "BEGIN PrivacyListListener >> setPrivacyList."); - Log.d(TAG, "> " + listName + " has been setted."); - Log.d(TAG, "END PrivacyListListener >> setPrivacyList."); - } - - @Override - public void updatedPrivacyList(final String listName) throws RemoteException { - Log.d(TAG, "BEGIN PrivacyListListener >> updatedPrivacyList."); - mHandler.post(new Runnable() { - @Override - public void run() { - try { - mPrivacyListNames.clear(); - // Not that much lists and require some server queries to know if the list has been - // updated/deleted or set to default/active by this activity or another IM client. - mPrivacyListNames.addAll(mPrivacyListManager.getPrivacyLists()); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - mAdapter.notifyDataSetChanged(); - } - }); - Log.d(TAG, "END PrivacyListListener >> updatedPrivacyList."); - } - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/Settings.java --- a/src/com/beem/project/beem/ui/Settings.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/Settings.java Sun Nov 06 04:27:09 2011 +0100 @@ -110,11 +110,7 @@ case R.id.settings_menu_create_account: i = new Intent(this, CreateAccount.class); startActivity(i); - return true; - case R.id.settings_menu_privacy_lists: - i = new Intent(this, PrivacyList.class); - startActivity(i); - return true; + return true; default: return false; } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/Subscription.java --- a/src/com/beem/project/beem/ui/Subscription.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/Subscription.java Sun Nov 06 04:27:09 2011 +0100 @@ -50,21 +50,13 @@ import android.content.ComponentName; import android.content.Intent; import android.content.IntentFilter; -import android.content.ServiceConnection; import android.os.Bundle; -import android.os.IBinder; -import android.os.RemoteException; -import android.util.Log; import android.view.View; import android.view.View.OnClickListener; import android.widget.TextView; import android.widget.Toast; -import com.beem.project.beem.BeemService; import com.beem.project.beem.R; -import com.beem.project.beem.service.PresenceAdapter; -import com.beem.project.beem.service.aidl.IXmppFacade; -import com.beem.project.beem.service.Contact; import com.beem.project.beem.utils.BeemBroadcastReceiver; /** @@ -75,9 +67,7 @@ private static final Intent SERVICE_INTENT = new Intent(); private static final String TAG = Subscription.class.getSimpleName(); - private IXmppFacade mService; private String mContact; - private ServiceConnection mServConn = new BeemServiceConnection(); private final BeemBroadcastReceiver mReceiver = new BeemBroadcastReceiver(); private MyOnClickListener mClickListener = new MyOnClickListener(); @@ -100,8 +90,8 @@ setContentView(R.layout.subscription); findViewById(R.id.SubscriptionAccept).setOnClickListener(mClickListener); findViewById(R.id.SubscriptionRefuse).setOnClickListener(mClickListener); - Contact c = new Contact(getIntent().getData()); - mContact = c.getJID(); +// Contact c = new Contact(getIntent().getData()); +// mContact = c.getJID(); TextView tv = (TextView) findViewById(R.id.SubscriptionText); String str = String.format(getString(R.string.SubscriptText), mContact); tv.setText(str); @@ -114,7 +104,7 @@ @Override protected void onResume() { super.onResume(); - bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); + //bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); } /* (non-Javadoc) @@ -123,7 +113,7 @@ @Override protected void onPause() { super.onPause(); - unbindService(mServConn); + //unbindService(mServConn); } /* (non-Javadoc) @@ -141,12 +131,12 @@ * @param p presence stanza */ private void sendPresence(Presence p) { - PresenceAdapter preAdapt = new PresenceAdapter(p); - try { - mService.sendPresencePacket(preAdapt); - } catch (RemoteException e) { - Log.e(TAG, "Error while sending subscription response", e); - } +// PresenceAdapter preAdapt = new PresenceAdapter(p); +// try { +// mService.sendPresencePacket(preAdapt); +// } catch (RemoteException e) { +// Log.e(TAG, "Error while sending subscription response", e); +// } } /** @@ -184,25 +174,4 @@ } }; - /** - * The ServiceConnection used to connect to the Beem service. - */ - private class BeemServiceConnection implements ServiceConnection { - - /** - * Constructor. - */ - public BeemServiceConnection() { - } - - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - mService = IXmppFacade.Stub.asInterface(service); - } - - @Override - public void onServiceDisconnected(ComponentName name) { - mService = null; - } - } } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/dialogs/builders/Alias.java --- a/src/com/beem/project/beem/ui/dialogs/builders/Alias.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/Alias.java Sun Nov 06 04:27:09 2011 +0100 @@ -40,21 +40,17 @@ Flavien Astraud, November 26, 2009 Head of the EIP Laboratory. -*/ + */ package com.beem.project.beem.ui.dialogs.builders; import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; -import android.os.RemoteException; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; import com.beem.project.beem.R; -import com.beem.project.beem.service.Contact; -import com.beem.project.beem.service.aidl.IRoster; /** * Create dialog alias. @@ -63,8 +59,7 @@ private static final String TAG = "Dialogs.Builders > Alias"; - private IRoster mRoster; - private Contact mContact; + //private Contact mContact; private EditText mEditTextAlias; /** @@ -73,20 +68,19 @@ * @param roster Beem roster. * @param contact the contact to modify. */ - public Alias(final Context context, final IRoster roster, final Contact contact) { + //public Alias(final Context context, final IRoster roster, final Contact contact) { + public Alias(final Context context) { super(context); - mRoster = roster; - mContact = contact; + //mRoster = roster; + //mContact = contact; LayoutInflater factory = LayoutInflater.from(context); - final View textEntryView = factory.inflate( - R.layout.contactdialogaliasdialog, null); - setTitle(mContact.getJID()); + final View textEntryView = factory.inflate(R.layout.contactdialogaliasdialog, null); + //setTitle(mContact.getJID()); setView(textEntryView); - mEditTextAlias = (EditText) textEntryView.findViewById( - R.id.CDAliasDialogName); - mEditTextAlias.setText(mContact.getName()); + mEditTextAlias = (EditText) textEntryView.findViewById(R.id.CDAliasDialogName); + //mEditTextAlias.setText(mContact.getName()); setPositiveButton(R.string.OkButton, new DialogClickListener()); setNegativeButton(R.string.CancelButton, new DialogClickListener()); } @@ -102,19 +96,18 @@ public DialogClickListener() { } - @Override public void onClick(final DialogInterface dialog, final int which) { if (which == DialogInterface.BUTTON_POSITIVE) { String name = mEditTextAlias.getText().toString(); - if (name.length() == 0) { - name = mContact.getJID(); - } - try { - mRoster.setContactName(mContact.getJID(), name); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } + // if (name.length() == 0) { + // name = mContact.getJID(); + // } + // try { + // mRoster.setContactName(mContact.getJID(), name); + // } catch (RemoteException e) { + // Log.e(TAG, e.getMessage()); + // } } } } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/dialogs/builders/ChatList.java --- a/src/com/beem/project/beem/ui/dialogs/builders/ChatList.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/ChatList.java Sun Nov 06 04:27:09 2011 +0100 @@ -43,15 +43,8 @@ */ package com.beem.project.beem.ui.dialogs.builders; -import java.util.List; - import android.app.AlertDialog; import android.content.Context; -import android.content.DialogInterface; -import android.content.Intent; - -import com.beem.project.beem.R; -import com.beem.project.beem.service.Contact; /** * Create the change chat dialog. @@ -65,26 +58,27 @@ * @param context context activity. * @param openedChats A list containing the JID of participants of the opened chats. */ - public ChatList(final Context context, final List openedChats) { + //public ChatList(final Context context, final List openedChats) { + public ChatList(final Context context) { super(context); - if (openedChats.size() > 0) { - CharSequence[] items = new CharSequence[openedChats.size()]; - - int i = 0; - for (Contact c : openedChats) { - items[i++] = c.getName(); - } - setTitle(R.string.chat_dialog_change_chat_title); - setItems(items, new DialogInterface.OnClickListener() { - public void onClick(DialogInterface dialog, int item) { - Intent chatIntent = new Intent(context, com.beem.project.beem.ui.Chat.class); - chatIntent.setData((openedChats.get(item)).toUri()); - context.startActivity(chatIntent); - } - }); - } else { - setMessage(R.string.chat_no_more_chats); - } +// if (openedChats.size() > 0) { +// CharSequence[] items = new CharSequence[openedChats.size()]; +// +// int i = 0; +// for (Contact c : openedChats) { +// items[i++] = c.getName(); +// } +// setTitle(R.string.chat_dialog_change_chat_title); +// setItems(items, new DialogInterface.OnClickListener() { +// public void onClick(DialogInterface dialog, int item) { +// Intent chatIntent = new Intent(context, com.beem.project.beem.ui.Chat.class); +// chatIntent.setData((openedChats.get(item)).toUri()); +// context.startActivity(chatIntent); +// } +// }); +// } else { +// setMessage(R.string.chat_no_more_chats); +// } } } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java --- a/src/com/beem/project/beem/ui/dialogs/builders/CreatePrivacyList.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.ui.dialogs.builders; - -import java.util.ArrayList; - -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.RemoteException; -import android.util.Log; -import android.view.LayoutInflater; -import android.view.View; -import android.widget.EditText; - -import com.beem.project.beem.R; -import com.beem.project.beem.service.PrivacyListItem; -import com.beem.project.beem.service.aidl.IPrivacyListManager; - -/** - * Use this builder to build a dialog which handles a privacy list creation. - * @author Jean-Manuel Da Silva - */ -public class CreatePrivacyList extends AlertDialog.Builder { - - private static final String TAG = "Dialogs.Builders > CreatePrivacyList"; - - private final IPrivacyListManager mPrivacyListManager; - private final View mTextEntryView; - private EditText mListNameField; - - /** - * Constructor. - * @param context context activity. - * @param privacyListManager the privacy list manager that will be use to create our list. - */ - public CreatePrivacyList(final Context context, final IPrivacyListManager privacyListManager) { - super(context); - - LayoutInflater factory = LayoutInflater.from(context); - - mTextEntryView = factory.inflate(R.layout.privacy_list_create_dialog, null); - setView(mTextEntryView); - - mPrivacyListManager = privacyListManager; - mListNameField = (EditText) mTextEntryView.findViewById(R.id.privacy_list_create_dialog_list_name); - - setTitle(R.string.privacy_list_create_dialog_title); - setPositiveButton(R.string.privacy_list_create_dialog_create_button, new DialogClickListener()); - setNegativeButton(R.string.CancelButton, new DialogClickListener()); - } - - /** - * Event click listener. - */ - class DialogClickListener implements DialogInterface.OnClickListener { - - /** - * Constructor. - */ - public DialogClickListener() { - } - - @Override - public void onClick(final DialogInterface dialog, final int which) { - if (which == DialogInterface.BUTTON_POSITIVE) { - try { - Log.d(TAG, "mPrivacyListManager ## " + mPrivacyListManager); - Log.d(TAG, "listNameField ## " + mListNameField); - Log.d(TAG, "listNameField.getText().toString() ## " + mListNameField.getText().toString()); - mPrivacyListManager.createPrivacyList(mListNameField.getText().toString(), - new ArrayList()); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - } - } - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java --- a/src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/DeleteContact.java Sun Nov 06 04:27:09 2011 +0100 @@ -46,12 +46,8 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; -import android.os.RemoteException; -import android.util.Log; import com.beem.project.beem.R; -import com.beem.project.beem.service.Contact; -import com.beem.project.beem.service.aidl.IRoster; /** * Use this builder to build a dialog which allows you to delete a contact from a specific roster. @@ -61,8 +57,8 @@ private static final String TAG = "Dialogs.Builders > DeleteContact"; - private IRoster mRoster; - private Contact mContact; + //private IRoster mRoster; + //private Contact mContact; /** * Constructor. @@ -70,11 +66,12 @@ * @param roster the roster which has the contact you want to delete. * @param contact the contact to delete. */ - public DeleteContact(final Context context, final IRoster roster, final Contact contact) { + //public DeleteContact(final Context context, final IRoster roster, final Contact contact) { + public DeleteContact(final Context context) { super(context); - mContact = contact; - mRoster = roster; + //mContact = contact; + //mRoster = roster; setMessage(R.string.userinfo_sure2delete); DialogClickListener dl = new DialogClickListener(); @@ -96,11 +93,11 @@ @Override public void onClick(final DialogInterface dialog, final int which) { if (which == DialogInterface.BUTTON_POSITIVE) { - try { - mRoster.deleteContact(mContact); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } +// try { +// mRoster.deleteContact(mContact); +// } catch (RemoteException e) { +// Log.e(TAG, e.getMessage()); +// } } } } diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java --- a/src/com/beem/project/beem/ui/dialogs/builders/DeletePrivacyList.java Sun Nov 06 00:15:35 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,107 +0,0 @@ -/* - BEEM is a videoconference application on the Android Platform. - - Copyright (C) 2009 by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - This file is part of BEEM. - - BEEM is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - BEEM is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with BEEM. If not, see . - - Please send bug reports with examples or suggestions to - contact@beem-project.com or http://dev.beem-project.com/ - - Epitech, hereby disclaims all copyright interest in the program "Beem" - written by Frederic-Charles Barthelery, - Jean-Manuel Da Silva, - Nikita Kozlov, - Philippe Lago, - Jean Baptiste Vergely, - Vincent Veronis. - - Nicolas Sadirac, November 26, 2009 - President of Epitech. - - Flavien Astraud, November 26, 2009 - Head of the EIP Laboratory. - -*/ -package com.beem.project.beem.ui.dialogs.builders; - -import android.app.AlertDialog; -import android.content.Context; -import android.content.DialogInterface; -import android.os.RemoteException; -import android.util.Log; - -import com.beem.project.beem.R; -import com.beem.project.beem.service.aidl.IPrivacyListManager; - -/** - * Use this builder to build a dialog which allows you to delete a privacy list. - * @author Jean-Manuel Da Silva - */ -public class DeletePrivacyList extends AlertDialog.Builder { - - private static final String TAG = "Dialogs.Builders > DeletePrivacyList"; - - private final IPrivacyListManager mPrivacyListManager; - private final String mPrivacyListName; - - /** - * Constructor. - * @param context context activity. - * @param privacyListManager the privacy list manager managing the privacy list you want to delete. - * @param privacyListName the name of the privacy list you want to delete. - */ - public DeletePrivacyList(final Context context, final IPrivacyListManager privacyListManager, - final String privacyListName) { - super(context); - - mPrivacyListManager = privacyListManager; - mPrivacyListName = privacyListName; - - setMessage(context.getString(R.string.privacy_list_delete_dialog_msg, privacyListName)); - DialogClickListener dl = new DialogClickListener(); - setPositiveButton(R.string.privacy_list_delete_dialog_yes, dl); - setNegativeButton(R.string.privacy_list_delete_dialog_no, dl); - } - - /** - * Event click listener. - */ - private class DialogClickListener implements DialogInterface.OnClickListener { - - /** - * Constructor. - */ - public DialogClickListener() { - } - - @Override - public void onClick(final DialogInterface dialog, final int which) { - if (which == DialogInterface.BUTTON_POSITIVE) { - try { - mPrivacyListManager.removePrivacyList(mPrivacyListName); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } - } - } - } -} diff -r d697250668af -r f7cfc4a68225 src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java --- a/src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java Sun Nov 06 00:15:35 2011 +0100 +++ b/src/com/beem/project/beem/ui/dialogs/builders/ResendSubscription.java Sun Nov 06 04:27:09 2011 +0100 @@ -43,19 +43,11 @@ */ package com.beem.project.beem.ui.dialogs.builders; -import org.jivesoftware.smack.packet.Presence; - import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; -import android.os.RemoteException; -import android.util.Log; -import android.widget.Toast; 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.aidl.IXmppFacade; /** * Use this builder to build a dialog which allows you resend a subscription query to a contact. @@ -66,8 +58,8 @@ private static final String TAG = "Dialogs.Builders > ResendSubscription"; private Context mContext; - private IXmppFacade mXmppFacade; - private Contact mContact; + //private IXmppFacade mXmppFacade; + //private Contact mContact; /** * Constructor. @@ -75,12 +67,13 @@ * @param xmppFacade the XMPP Facade used to send the query. * @param contact the receiver of the query. */ - public ResendSubscription(final Context context, final IXmppFacade xmppFacade, final Contact contact) { + //public ResendSubscription(final Context context, final IXmppFacade xmppFacade, final Contact contact) { + public ResendSubscription(final Context context) { super(context); mContext = context; - mXmppFacade = xmppFacade; - mContact = contact; + //mXmppFacade = xmppFacade; + //mContact = contact; setMessage(R.string.userinfo_sureresend); DialogClickListener dl = new DialogClickListener(); @@ -102,14 +95,14 @@ @Override public void onClick(final DialogInterface dialog, final int which) { if (which == DialogInterface.BUTTON_POSITIVE) { - Presence presencePacket = new Presence(Presence.Type.subscribe); - presencePacket.setTo(mContact.getJID()); - try { - mXmppFacade.sendPresencePacket(new PresenceAdapter(presencePacket)); - Toast.makeText(mContext, mContext.getString(R.string.userinfo_resend), Toast.LENGTH_SHORT).show(); - } catch (RemoteException e) { - Log.e(TAG, e.getMessage()); - } +// Presence presencePacket = new Presence(Presence.Type.subscribe); +// presencePacket.setTo(mContact.getJID()); +// try { +// mXmppFacade.sendPresencePacket(new PresenceAdapter(presencePacket)); +// Toast.makeText(mContext, mContext.getString(R.string.userinfo_resend), Toast.LENGTH_SHORT).show(); +// } catch (RemoteException e) { +// Log.e(TAG, e.getMessage()); +// } } }