# HG changeset patch # User Philippe Lago # Date 1239141729 -7200 # Node ID 9a4dbd7fe5460ce8f23d78a92969a23d42e9f0c6 # Parent fb3e3ed4bafca4667c24a177f185d20934b960d7# Parent 29f0d6a23321a115c3881a2f1c1afd0f66717fcd Super mercurial le retour du commit oubliƩ apres le merge du pull -f -r19 diff -r 29f0d6a23321 -r 9a4dbd7fe546 AndroidManifest.xml --- a/AndroidManifest.xml Tue Apr 07 10:25:40 2009 +0200 +++ b/AndroidManifest.xml Wed Apr 08 00:02:09 2009 +0200 @@ -2,7 +2,7 @@ - + diff -r 29f0d6a23321 -r 9a4dbd7fe546 res/drawable/background.png Binary file res/drawable/background.png has changed diff -r 29f0d6a23321 -r 9a4dbd7fe546 res/drawable/xmpp.jpg Binary file res/drawable/xmpp.jpg has changed diff -r 29f0d6a23321 -r 9a4dbd7fe546 res/layout/messagelist.xml --- a/res/layout/messagelist.xml Tue Apr 07 10:25:40 2009 +0200 +++ b/res/layout/messagelist.xml Wed Apr 08 00:02:09 2009 +0200 @@ -1,7 +1,6 @@ \ No newline at end of file diff -r 29f0d6a23321 -r 9a4dbd7fe546 res/layout/sendim.xml --- a/res/layout/sendim.xml Tue Apr 07 10:25:40 2009 +0200 +++ b/res/layout/sendim.xml Wed Apr 08 00:02:09 2009 +0200 @@ -2,8 +2,7 @@ + android:layout_height="fill_parent"> SOCKS5 - says :\n + says :\n Tip text here Is : and is speaking from : diff -r 29f0d6a23321 -r 9a4dbd7fe546 res/values/style.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/res/values/style.xml Wed Apr 08 00:02:09 2009 +0200 @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff -r 29f0d6a23321 -r 9a4dbd7fe546 src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Tue Apr 07 10:25:40 2009 +0200 +++ b/src/com/beem/project/beem/BeemService.java Wed Apr 08 00:02:09 2009 +0200 @@ -91,7 +91,7 @@ } else { mConnectionConfiguration = new ConnectionConfiguration(mHost); } - mConnectionConfiguration.setSendPresence(false); + mConnectionConfiguration.setSendPresence(true); } /** diff -r 29f0d6a23321 -r 9a4dbd7fe546 src/com/beem/project/beem/ui/SendIM.java --- a/src/com/beem/project/beem/ui/SendIM.java Tue Apr 07 10:25:40 2009 +0200 +++ b/src/com/beem/project/beem/ui/SendIM.java Wed Apr 08 00:02:09 2009 +0200 @@ -4,7 +4,10 @@ import android.app.ListActivity; import android.content.SharedPreferences; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; import android.os.Bundle; +import android.os.Handler; +import android.os.RemoteException; import android.util.Log; import android.view.KeyEvent; import android.view.Menu; @@ -16,8 +19,15 @@ import android.widget.ArrayAdapter; import android.widget.EditText; +import com.beem.project.beem.BeemApplication; import com.beem.project.beem.R; import com.beem.project.beem.service.Contact; +import com.beem.project.beem.service.Message; +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.IXmppFacade; /** * @author barbu This activity class provide the view for instant messaging @@ -31,7 +41,15 @@ private ArrayAdapter mAdapter; private SendIMDialogSmiley mSmyDialog; private SharedPreferences mSet; + private SharedPreferences mGlobalSettings; + private BeemApplication mBeemApplication; + private Handler mHandler; + private IXmppFacade mService = null; private Contact mContact; + private IChatManager mChatManager; + private IChatManagerListener mChatManagerListener; + private IMessageListener mMessageListener; + private IChat mChat; /** * Constructor. @@ -46,11 +64,15 @@ @Override public void onCreate(Bundle saveBundle) { super.onCreate(saveBundle); - + mHandler = new Handler(); + mChatManagerListener = new OnChatListener(); + mMessageListener = new OnMessageListener(); + mBeemApplication = BeemApplication.getApplication(this); setContentView(R.layout.sendim); mToSend = (EditText) findViewById(R.id.userText); mSet = getSharedPreferences("lol", MODE_PRIVATE); mSmyDialog = new SendIMDialogSmiley(this, mSet); + mGlobalSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE); mAdapter = new ArrayAdapter(this, R.layout.messagelist, mMessages); @@ -65,7 +87,16 @@ @Override public void onStart() { super.onStart(); - + mBeemApplication.startBeemService(); + mService = mBeemApplication.getXmppFacade(); + try { + mChatManager = mService.getChatManager(); + mChatManager.addChatCreationListener(mChatManagerListener); + mChat = mChatManager.createChat(mContact, mMessageListener); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } } /** @@ -82,19 +113,17 @@ */ private void sendText() { String text = mToSend.getText().toString(); + String from = mGlobalSettings.getString(getString(R.string.PreferenceJID), "You"); if (!text.equals("")) { - /* - * Prepare the message to be send - */ - /* Message msg = new Message("barbu", Message.Type.chat); */ - /* msg.setBody(text); */ - /* - * Rien a voir il faut changer le mContact.getJID() et remplacer - * avec son pseudo cetait juste un test pour savoir qu'on recupere - * bien le contact a qui envoyer les infos - */ - mAdapter.add(mContact.getJID() + " " - + getString(R.string.SendIMSays) + text); + Message msg = new Message(mContact.getJID(), Message.MSG_TYPE_CHAT); + msg.setBody(text); + try { + mChat.sendMessage(msg); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + mAdapter.add(from + getString(R.string.SendIMSays) + text); mToSend.setText(null); } } @@ -139,4 +168,27 @@ return false; } } + + private class OnChatListener extends IChatManagerListener.Stub { + + @Override + public void chatCreated(IChat chat, boolean locally) + throws RemoteException { + Log.i("LOG", "chatCreated"); + + } + + } + + private class OnMessageListener extends IMessageListener.Stub { + + @Override + public void processMessage(IChat chat, Message msg) + throws RemoteException { + Log.i("LOG", "processMessage"); + mAdapter.add(mContact.getJID() + " " + + getString(R.string.SendIMSays) + msg.getBody()); + } + + } }