# HG changeset patch # User Da Risk # Date 1238691788 -7200 # Node ID d1a5bb00aaebe0b230cbc200e600f3793bf70816 # Parent ef115770432d3c1d3b8994fda9039b73f48d5e85# Parent 66732dd2cb77bf58bec6a69ef38108b7ee74a328 Merge with nikita diff -r ef115770432d -r d1a5bb00aaeb .hgignore --- a/.hgignore Thu Apr 02 15:56:12 2009 +0200 +++ b/.hgignore Thu Apr 02 19:03:08 2009 +0200 @@ -1,2 +1,5 @@ +syntax: glob bin/* R.java +doc/javadoc +src/com/beem/project/beem/service/aidl/*.java diff -r ef115770432d -r d1a5bb00aaeb build.xml --- a/build.xml Thu Apr 02 15:56:12 2009 +0200 +++ b/build.xml Thu Apr 02 19:03:08 2009 +0200 @@ -114,6 +114,8 @@ + + @@ -121,6 +123,7 @@ Creating output directories if needed... + @@ -145,11 +148,13 @@ Compiling aidl files into Java classes... + + @@ -244,7 +249,9 @@ - + Packaging ${out-unsigned-package} for release... @@ -264,7 +271,8 @@ - + Installing ${out-debug-package} onto default emulator... @@ -281,8 +289,9 @@ - - + + Uninstalling ${application-package} from the default emulator... @@ -295,6 +304,13 @@ - + + + + + + + diff -r ef115770432d -r d1a5bb00aaeb project.aidl --- a/project.aidl Thu Apr 02 15:56:12 2009 +0200 +++ b/project.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -4,3 +4,4 @@ parcelable com.beem.project.beem.BeemException parcelable com.beem.project.beem.service.Contact +parcelable com.beem.project.beem.service.Message diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/BeemApplication.java --- a/src/com/beem/project/beem/BeemApplication.java Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/BeemApplication.java Thu Apr 02 19:03:08 2009 +0200 @@ -21,63 +21,18 @@ import com.beem.project.beem.service.aidl.IXMPPFacade; /** + * The Beem application. + * This class has some methods utiliy needs by the activities. * @author darisk */ public class BeemApplication extends Application { + private static BeemApplication mBeemApp; private IXMPPFacade mFacade; - private Context mApplicationContext; private Resources mPrivateResources; - private static BeemApplication mBeemApp; private List mQueue = new LinkedList(); private boolean mIsConnected; - - public static BeemApplication getApplication(Activity activity) { - if (mBeemApp == null) { - mBeemApp = new BeemApplication(); - mBeemApp.mApplicationContext = activity.getApplication(); - mBeemApp.mPrivateResources = activity.getResources(); - mBeemApp.onCreate(); - } - return mBeemApp; - } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - // TODO Auto-generated method stub - super.onConfigurationChanged(newConfig); - } - - @Override - public void onCreate() { - // TODO Auto-generated method stub - super.onCreate(); - mFacade = null; - } - - @Override - public void onLowMemory() { - // TODO Auto-generated method stub - super.onLowMemory(); - } - - @Override - public void onTerminate() { - // TODO Auto-generated method stub - super.onTerminate(); - } - - public synchronized void startBeemService() { - if (!mIsConnected) { - // Intent intent = new Intent(this, BeemService.class); - Intent intent = new Intent(); - intent.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); - mApplicationContext.startService(intent); - mApplicationContext.bindService(intent, mServConn, BIND_AUTO_CREATE); - mIsConnected = true; - } - } private ServiceConnection mServConn = new ServiceConnection() { @@ -100,16 +55,101 @@ } }; + /** + * Constructor. + */ + public BeemApplication() { + // TODO Auto-generated constructor stub + } + + /** + * Get the Beem application for an activity. + * @param activity the activity which want the Beem application + * @return the Beem application + */ + public static BeemApplication getApplication(Activity activity) { + if (mBeemApp == null) { + mBeemApp = new BeemApplication(); + mBeemApp.mApplicationContext = activity.getApplication(); + mBeemApp.mPrivateResources = activity.getResources(); + mBeemApp.onCreate(); + } + return mBeemApp; + } + + /** + * {@inheritDoc} + */ + @Override + public void onConfigurationChanged(Configuration newConfig) { + // TODO Auto-generated method stub + super.onConfigurationChanged(newConfig); + } + + /** + * {@inheritDoc} + */ + @Override + public void onCreate() { + // TODO Auto-generated method stub + super.onCreate(); + mFacade = null; + } + + /** + * {@inheritDoc} + */ + @Override + public void onLowMemory() { + // TODO Auto-generated method stub + super.onLowMemory(); + } + + /** + * {@inheritDoc} + */ + @Override + public void onTerminate() { + // TODO Auto-generated method stub + super.onTerminate(); + } + + /** + * Start the beem service. + */ + public synchronized void startBeemService() { + if (!mIsConnected) { + // Intent intent = new Intent(this, BeemService.class); + Intent intent = new Intent(); + intent.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); + mApplicationContext.startService(intent); + mApplicationContext.bindService(intent, mServConn, BIND_AUTO_CREATE); + mIsConnected = true; + } + } + + /** + * Stop the Beem service. + */ public synchronized void stopBeemService() { Intent intent = new Intent(this, BeemService.class); mApplicationContext.unbindService(mServConn); mApplicationContext.stopService(intent); } + /** + * Get the facade to use to access the Beem service. + * @return the facade or null if the application is not connected to the beem service. + */ public IXMPPFacade getXmppFacade() { return mFacade; } - + + /** + * Add a methode to execute when the application is connected to the Beem service. + * @param target the handler which will execute the callback + * @param callback the callback to execute + */ public void callWhenServiceConnected(Handler target, Runnable callback) { Message msg = Message.obtain(target, callback); if (!mIsConnected) { diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/BeemService.java Thu Apr 02 19:03:08 2009 +0200 @@ -1,19 +1,5 @@ - -/** - * - */ package com.beem.project.beem; -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -import org.jivesoftware.smack.Roster; -import org.jivesoftware.smack.RosterListener; -import org.jivesoftware.smack.packet.Presence; -import org.jivesoftware.smack.XMPPConnection; -import org.jivesoftware.smack.XMPPException; - import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -21,15 +7,13 @@ import android.content.Intent; import android.content.SharedPreferences; import android.os.IBinder; -import android.os.Looper; import android.os.RemoteException; import android.widget.Toast; import com.beem.project.beem.service.XMPPConnectionAdapter; import com.beem.project.beem.service.XMPPFacade; -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.service.aidl.IXmppConnection; /** * This class is for the Beem service. * @author darisk @@ -37,20 +21,18 @@ */ public class BeemService extends Service { - private NotificationManager notificationManager; + private NotificationManager mNotificationManager; - private IXMPPConnection connection; - private SharedPreferences settings; + private IXmppConnection mConnection; + private SharedPreferences mSettings; private String mLogin; private String mPassword; private String mHost; private IXMPPFacade.Stub mBind; - /* - * (non-Javadoc) - * - * @see android.app.Service#onBind(android.content.Intent) + /** + * {@inheritDoc} */ @Override public IBinder onBind(Intent intent) { @@ -60,20 +42,62 @@ // return null; } + /** + * {@inheritDoc} + */ @Override public void onCreate() { super.onCreate(); - settings = getSharedPreferences(getString(R.string.PreferenceFileName), + mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE); - mLogin = settings.getString(getString(R.string.PreferenceLoginKey), ""); - mPassword = settings.getString( + mLogin = mSettings.getString(getString(R.string.PreferenceLoginKey), ""); + mPassword = mSettings.getString( getString(R.string.PreferencePasswordKey), ""); - mHost = settings.getString(getString(R.string.PreferenceHostKey), ""); - notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - connection = new XMPPConnectionAdapter("10.0.2.2", mLogin, mPassword); // address - mBind = new XMPPFacade((XMPPConnectionAdapter) connection); + mHost = mSettings.getString(getString(R.string.PreferenceHostKey), ""); + mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + mConnection = new XMPPConnectionAdapter("10.0.2.2", mLogin, mPassword); // address + mBind = new XMPPFacade((XMPPConnectionAdapter) mConnection); + } + + /** + * {@inheritDoc} + */ + @Override + public void onStart(Intent intent, int startId) { + try { + mConnection.connectSync(); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } + /** + * {@inheritDoc} + */ + @Override + public void onDestroy() { + closeConnection(); + showBasicNotification(R.string.BeemServiceDestroyed); + } + + /** + * Close the connection to the xmpp server. + */ + private void closeConnection() { + if (mConnection != null) + try { + mConnection.disconnect(); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * Add a notification in the notification status bar. + * @param stringResource the ressource of the text to show + */ private void showBasicNotification(int stringResource) { String text = (String) getText(stringResource); Notification notif = new Notification(R.drawable.logo, text, System @@ -81,36 +105,11 @@ notif.defaults = Notification.DEFAULT_ALL; notif.setLatestEventInfo(this, text, text, PendingIntent.getActivity( this, 0, new Intent(), 0)); - notificationManager.notify(stringResource, notif); + mNotificationManager.notify(stringResource, notif); Toast toast = Toast.makeText(this, R.string.BeemServiceCreated, Toast.LENGTH_LONG); toast.show(); } - @Override - public void onStart(Intent intent, int startId) { - try { - connection.connectSync(); - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Override - public void onDestroy() { - closeConnection(); - showBasicNotification(R.string.BeemServiceDestroyed); - } - - private void closeConnection() { - if (connection != null) - try { - connection.disconnect(); - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } } diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/BeemChatManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/BeemChatManager.java Thu Apr 02 19:03:08 2009 +0200 @@ -0,0 +1,135 @@ +/** + * + */ +package com.beem.project.beem.service; + +import java.util.HashMap; +import java.util.Map; + +import org.jivesoftware.smack.Chat; +import org.jivesoftware.smack.ChatManager; +import org.jivesoftware.smack.ChatManagerListener; +import org.jivesoftware.smack.MessageListener; + +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.IChatManager; +import com.beem.project.beem.service.aidl.IChatManagerListener; +import com.beem.project.beem.service.aidl.IMessageListener; + +/** + * An adapter for smack's ChatManager. This class provides functionnality to handle chats. + * @author darisk + */ +public class BeemChatManager extends IChatManager.Stub { + + /** + * Tag to use with log methods. + */ + public static final String TAG = "BeemChatManager"; + private ChatManager mAdaptee; + private Map mChats = new HashMap(); + private ChatListener mChatListener = new ChatListener(); + private RemoteCallbackList mRemoteChatCreationListeners = + new RemoteCallbackList(); + + /** + * Constructor. + * @param chatManager the smack ChatManager to adapt + */ + public BeemChatManager(final ChatManager chatManager) { + // TODO Auto-generated constructor stub + mAdaptee = chatManager; + mAdaptee.addChatListener(mChatListener); + } + + /** + * 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 Chat createChat(String jid, MessageListener listener) { + return mAdaptee.createChat(jid, 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 + */ + public Chat createChat(Contact contact, MessageListener listener) { + String jid = contact.getJID(); + return createChat(jid, listener); + } + + /** + * {@inheritDoc} + */ + @Override + public void addChatCreationListener(IChatManagerListener listener) throws RemoteException { + // TODO Auto-generated method stub + mRemoteChatCreationListeners.register(listener); + } + + /** + * {@inheritDoc} + */ + @Override + public IChat createChat(Contact contact, IMessageListener listener) throws RemoteException { + // TODO Auto-generated method stub + return null; + } + + /** + * {@inheritDoc} + */ + @Override + public void removeChatCreationListener(IChatManagerListener listener) throws RemoteException { + // TODO Auto-generated method stub + mRemoteChatCreationListeners.unregister(listener); + } + + /** + * A listener for all the chat creation event that happens on the connection. + * @author darisk + */ + private class ChatListener implements ChatManagerListener { + + /** + * Constructor. + */ + public ChatListener() { + // TODO Auto-generated constructor stub + } + + /** + * {@inheritDoc} + */ + @Override + public void chatCreated(Chat chat, boolean locally) { + if (!locally) { + mChats.put(chat.getParticipant(), chat); + } + final int n = mRemoteChatCreationListeners.beginBroadcast(); + + for (int i = 0; i < n; i++) { + IChatManagerListener listener = mRemoteChatCreationListeners.getBroadcastItem(i); + try { + IChat newchat = new ChatAdapter(chat); + listener.chatCreated(newchat, locally); + } catch (RemoteException e) { + // The RemoteCallbackList will take care of removing the + // dead listeners. + Log.w(TAG, "Error while triggering remote connection listeners", e); + } + } + mRemoteChatCreationListeners.finishBroadcast(); + } + } + +} diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/ChatAdapter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/ChatAdapter.java Thu Apr 02 19:03:08 2009 +0200 @@ -0,0 +1,57 @@ +/** + * + */ +package com.beem.project.beem.service; + +import org.jivesoftware.smack.Chat; +import org.jivesoftware.smack.XMPPException; + +import android.os.RemoteException; + +import com.beem.project.beem.service.aidl.IChat; + +/** + * An adapter for smack's Chat class. + * @author darisk + */ +public class ChatAdapter extends IChat.Stub { + private Chat mAdaptee; + private Contact mParticipant; + + /** + * Constructor. + * @param chat The chat to adapt + */ + public ChatAdapter(final Chat chat) { + mAdaptee = chat; + mParticipant = new Contact(chat.getParticipant()); + } + + /** + * {@inheritDoc} + */ + @Override + public Contact getParticipant() throws RemoteException { + return mParticipant; + } + + /** + * {@inheritDoc} + */ + @Override + public void sendMessage(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); + try { + mAdaptee.sendMessage(send); + } catch (XMPPException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/Contact.java --- a/src/com/beem/project/beem/service/Contact.java Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/service/Contact.java Thu Apr 02 19:03:08 2009 +0200 @@ -53,7 +53,22 @@ * @param in parcel to use for construction */ private Contact(final Parcel in) { + mID = in.readInt(); + mStatus = in.readInt(); + mJID = in.readString(); + mMsgState = in.readString(); + } + /** + * {@inheritDoc} + */ + @Override + public void writeToParcel(Parcel dest, int flags) { + // TODO Auto-generated method stub + dest.writeInt(mID); + dest.writeInt(mStatus); + dest.writeString(mJID); + dest.writeString(mMsgState); } /** @@ -81,13 +96,5 @@ return 0; } - /** - * {@inheritDoc} - */ - @Override - public void writeToParcel(Parcel dest, int flags) { - // TODO Auto-generated method stub - } - } diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/Message.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/Message.java Thu Apr 02 19:03:08 2009 +0200 @@ -0,0 +1,196 @@ +/** + * + */ +package com.beem.project.beem.service; + +import android.os.Parcel; +import android.os.Parcelable; + +/** + * 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; + + private int mType; + private String mBody; + private String mSubject; + private String mTo; + private String mThread; + + /** + * 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]; + } + }; + + /** + * 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 = ""; + } + + /** + * 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 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(); + } + + /** + * {@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); + } + + /** + * 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; + } + + + /** + * 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; + } + + /** + * {@inheritDoc} + */ + @Override + public int describeContents() { + // TODO Auto-generated method stub + return 0; + } + +} diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/RosterAdapter.java --- a/src/com/beem/project/beem/service/RosterAdapter.java Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/service/RosterAdapter.java Thu Apr 02 19:03:08 2009 +0200 @@ -1,15 +1,17 @@ /** - * + * */ package com.beem.project.beem.service; import java.util.ArrayList; +import java.util.Collection; import java.util.HashMap; 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.XMPPException; import android.os.RemoteException; @@ -86,4 +88,17 @@ return res; } + /** + * {@inheritDoc} + */ + @Override + public List getGroupsNames() throws RemoteException { + Collection groups = mAdaptee.getGroups(); + ArrayList result = new ArrayList(groups.size()); + for (RosterGroup rosterGroup : groups) { + result.add(rosterGroup.getName()); + } + return result; + } + } diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/XMPPConnectionAdapter.java --- a/src/com/beem/project/beem/service/XMPPConnectionAdapter.java Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/service/XMPPConnectionAdapter.java Thu Apr 02 19:03:08 2009 +0200 @@ -10,21 +10,19 @@ import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smackx.ServiceDiscoveryManager; import org.jivesoftware.smackx.jingle.JingleManager; - import android.os.RemoteCallbackList; import android.os.RemoteException; import android.util.Log; - import com.beem.project.beem.BeemException; import com.beem.project.beem.service.aidl.IBeemConnectionListener; import com.beem.project.beem.service.aidl.IRoster; -import com.beem.project.beem.service.aidl.IXMPPConnection; +import com.beem.project.beem.service.aidl.IXmppConnection; /** * This class implements an adapter for XMPPConnection. * @author darisk */ -public class XMPPConnectionAdapter extends IXMPPConnection.Stub { +public class XMPPConnectionAdapter extends IXmppConnection.Stub { private static final String TAG = "XMPPConnectionAdapter"; private XMPPConnection mAdaptee; diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/XMPPFacade.java --- a/src/com/beem/project/beem/service/XMPPFacade.java Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/service/XMPPFacade.java Thu Apr 02 19:03:08 2009 +0200 @@ -1,15 +1,13 @@ -/** - * - */ package com.beem.project.beem.service; import android.os.RemoteException; import com.beem.project.beem.service.aidl.IRoster; -import com.beem.project.beem.service.aidl.IXMPPConnection; +import com.beem.project.beem.service.aidl.IXmppConnection; import com.beem.project.beem.service.aidl.IXMPPFacade; + /** + * This class is a facade for the Beem Service. * @author darisk - * */ public class XMPPFacade extends IXMPPFacade.Stub { @@ -19,34 +17,49 @@ * Constructor for XMPPFacade. * @param connection the connection use by the facade */ - public XMPPFacade(XMPPConnectionAdapter connection) { + public XMPPFacade(final XMPPConnectionAdapter connection) { this.mConnexion = connection; } + /** + * {@inheritDoc} + */ @Override public void connectAsync() throws RemoteException { // TODO Auto-generated method stub mConnexion.connectAsync(); } + /** + * {@inheritDoc} + */ @Override public void connectSync() throws RemoteException { // TODO Auto-generated method stub mConnexion.connectSync(); } + /** + * {@inheritDoc} + */ @Override - public IXMPPConnection createConnection() throws RemoteException { + public IXmppConnection createConnection() throws RemoteException { // TODO Auto-generated method stub return mConnexion; } + /** + * {@inheritDoc} + */ @Override public void disconnect() throws RemoteException { // TODO Auto-generated method stub mConnexion.disconnect(); } + /** + * {@inheritDoc} + */ @Override public IRoster getRoster() throws RemoteException { return mConnexion.getRoster(); diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl --- a/src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -1,17 +1,39 @@ package com.beem.project.beem.service.aidl; +/** + * Interface to listen for connection events + * @author Da Risk + */ interface IBeemConnectionListener { + /** + * Callback to call when the connection is closed + */ void connectionClosed(); + /** + * Callback to call when the connection occurs + */ void onConnect(); //void connectionClosedOnError(in Exception e); + /** + * Callback to call when the connection is closed on error + */ void connectionClosedOnError(); + /** + * Callback to call when trying to reconnecting + */ void reconnectingIn(in int seconds); + /** + * Callback to call when the reconnection has failed + */ void reconnectionFailed(); + /** + * Callback to call when the reconnection is successfull + */ void reconnectionSuccessful(); } diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IChat.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/aidl/IChat.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -0,0 +1,22 @@ +package com.beem.project.beem.service.aidl; + +import com.beem.project.beem.service.Contact; +import com.beem.project.beem.service.Message; + +/** + * 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(); +} \ No newline at end of file diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IChatManager.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/aidl/IChatManager.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -0,0 +1,35 @@ +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 { + + //IChat createChat(in String jid, in IMessageListener listener); + + /** + * 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); + + /** + * 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); +} \ No newline at end of file diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IChatManagerListener.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/aidl/IChatManagerListener.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -0,0 +1,18 @@ +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); + +} \ No newline at end of file diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IMessageListener.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/aidl/IMessageListener.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -0,0 +1,9 @@ +package com.beem.project.beem.service.aidl; + +import com.beem.project.beem.service.Message; +import com.beem.project.beem.service.aidl.IChat; + +interface IMessageListener { + + void processMessage(in IChat chat, in Message msg); +} diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IRoster.aidl --- a/src/com/beem/project/beem/service/aidl/IRoster.aidl Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/service/aidl/IRoster.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -13,5 +13,7 @@ void createGroup(in String groupname); List getContactList(); + + List getGroupsNames(); } \ No newline at end of file diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IXMPPConnection.aidl --- a/src/com/beem/project/beem/service/aidl/IXMPPConnection.aidl Thu Apr 02 15:56:12 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ -package com.beem.project.beem.service.aidl; - -import com.beem.project.beem.service.aidl.IRoster; -import com.beem.project.beem.service.aidl.IBeemConnectionListener; - -interface IXMPPConnection { - - boolean connectSync(); - - void connectAsync(); - - boolean disconnect(); - - IRoster getRoster(); - - void addConnectionListener(in IBeemConnectionListener listen); - void removeConnectionListener(in IBeemConnectionListener listen); -} \ No newline at end of file diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IXMPPFacade.aidl --- a/src/com/beem/project/beem/service/aidl/IXMPPFacade.aidl Thu Apr 02 15:56:12 2009 +0200 +++ b/src/com/beem/project/beem/service/aidl/IXMPPFacade.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -1,11 +1,11 @@ package com.beem.project.beem.service.aidl; -import com.beem.project.beem.service.aidl.IXMPPConnection; +import com.beem.project.beem.service.aidl.IXmppConnection; import com.beem.project.beem.service.aidl.IRoster; interface IXMPPFacade { - IXMPPConnection createConnection(); + IXmppConnection createConnection(); IRoster getRoster(); diff -r ef115770432d -r d1a5bb00aaeb src/com/beem/project/beem/service/aidl/IXmppConnection.aidl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/service/aidl/IXmppConnection.aidl Thu Apr 02 19:03:08 2009 +0200 @@ -0,0 +1,20 @@ +package com.beem.project.beem.service.aidl; + +import com.beem.project.beem.service.aidl.IRoster; +import com.beem.project.beem.service.aidl.IBeemConnectionListener; + +interface IXmppConnection { + + boolean connectSync(); + + void connectAsync(); + + boolean disconnect(); + + IRoster getRoster(); + + void addConnectionListener(in IBeemConnectionListener listen); + void removeConnectionListener(in IBeemConnectionListener listen); + + // IChatManager getChatManager(); +} \ No newline at end of file