# HG changeset patch # User marseille@marseille-desktop # Date 1245258191 -7200 # Node ID 23647e075321b9532b5e8198a1b47706e9e03cd8 # Parent d8fa7f751a0f747beb1ed38ec6c187e3860275b0 Re arrangemetn de certains fichiers !! Remise en place de la notification qui avait saute a cause de la suppression de beemapplication. diff -r d8fa7f751a0f -r 23647e075321 src/com/beem/project/beem/BeemService.java --- a/src/com/beem/project/beem/BeemService.java Wed Jun 17 18:33:14 2009 +0200 +++ b/src/com/beem/project/beem/BeemService.java Wed Jun 17 19:03:11 2009 +0200 @@ -227,10 +227,6 @@ mHost = mSettings.getString(getString(R.string.settings_key_xmpp_server), ""); mPort = Integer.parseInt(mSettings.getString(getString(R.string.settings_key_xmpp_port), "5222")); - Log.i("BEEMSERVICE", mLogin); - Log.i("BEEMSERVICE", mPassword); - Log.i("BEEMSERVICE", mHost); - Log.i("BEEMSERVICE", "" + mPort + ""); if (mHost.equals("talk.google.com")) mService = "gmail.com"; else diff -r d8fa7f751a0f -r 23647e075321 src/com/beem/project/beem/service/XmppFacade.java --- a/src/com/beem/project/beem/service/XmppFacade.java Wed Jun 17 18:33:14 2009 +0200 +++ b/src/com/beem/project/beem/service/XmppFacade.java Wed Jun 17 19:03:11 2009 +0200 @@ -58,7 +58,6 @@ mStatusNotification.defaults = Notification.DEFAULT_ALL; mStatusNotification.flags = Notification.FLAG_NO_CLEAR; - // mStatusNotification.contentView = ; mStatusNotification.setLatestEventInfo(mBeemService, "Beem Status", text, PendingIntent.getActivity( mBeemService, 0, new Intent(mBeemService, ChangeStatus.class), 0)); mBeemService.sendNotification(BeemService.NOTIFICATION_STATUS_ID, mStatusNotification); diff -r d8fa7f751a0f -r 23647e075321 src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Wed Jun 17 18:33:14 2009 +0200 +++ b/src/com/beem/project/beem/ui/Login.java Wed Jun 17 19:03:11 2009 +0200 @@ -20,140 +20,26 @@ import com.beem.project.beem.service.aidl.IBeemConnectionListener; import com.beem.project.beem.service.aidl.IXmppConnection; import com.beem.project.beem.service.aidl.IXmppFacade; +import com.beem.project.beem.utils.Status; /** - * This class represents an activity which allows the user to connect to an XMPP server with his - * username/password - * + * This class represents an activity which allows the user to connect to an XMPP server with his username/password * @author dasilvj */ public class Login extends Activity { - private class BeemConnectionListener extends IBeemConnectionListener.Stub { - - private class ErrorRunnable implements Runnable { - - private final String mErrorMsg; - - public ErrorRunnable(String errorMsg) { - mErrorMsg = errorMsg; - } - - @Override - public void run() { - progressDialog.setMessage(mErrorMsg); - } - - } - - @Override - public void connectionClosed() throws RemoteException { - mIsConnected = false; - Login.this.unbindService(mServConn); - Login.this.stopService(SERVICE_INTENT); - } - - @Override - public void connectionClosedOnError() throws RemoteException { - mIsConnected = false; - Login.this.unbindService(mServConn); - Login.this.stopService(SERVICE_INTENT); - } - - @Override - public void connectionFailed(String errorMsg) throws RemoteException { - connectionHandler.post(new ErrorRunnable(errorMsg)); - mIsConnected = false; - Login.this.unbindService(mServConn); - Login.this.stopService(SERVICE_INTENT); - dismissProgressDialog(); - } - - private void dismissProgressDialog() { - connectionHandler.post(new Runnable() { - - @Override - public void run() { - progressDialog.dismiss(); - } - }); - } - - @Override - public void onConnect() throws RemoteException { - mIsConnected = true; - dismissProgressDialog(); - Log.i(getString(R.string.login_tag), "Connected."); - startActivity(new Intent(Login.this, ContactList.class)); - finish(); - } - - @Override - public void reconnectingIn(int seconds) throws RemoteException { - - } - - @Override - public void reconnectionFailed() throws RemoteException { - mIsConnected = false; - } - - @Override - public void reconnectionSuccessful() throws RemoteException { - mIsConnected = true; - } - } - - private class BeemServiceConnection implements ServiceConnection { - - @Override - public void onServiceConnected(ComponentName name, IBinder service) { - xmppFacade = IXmppFacade.Stub.asInterface(service); - try { - xmppConnection = xmppFacade.createConnection(); - xmppConnection.addConnectionListener(new BeemConnectionListener()); - if (!xmppConnection.isAuthentificated()) { - connectionHandler.post(new Runnable() { - - @Override - public void run() { - progressDialog.setMessage("Loading. Please wait..."); - progressDialog.show(); - } - }); - Login.this.startService(Login.SERVICE_INTENT); - } else { - mIsConnected = true; - startActivity(new Intent(Login.this, ContactList.class)); - finish(); - } - } catch (RemoteException e) { - Log.e(getString(R.string.login_tag), "REMOTE EXCEPTION $" + e.getMessage()); - } - } - - @Override - public void onServiceDisconnected(ComponentName name) { - xmppFacade = null; - mIsConnected = false; - - } - - } - - protected static final String TAG = "LOG_AS"; - private static final Intent SERVICE_INTENT = new Intent(); + protected static final String TAG = "LOG_AS"; + private static final Intent SERVICE_INTENT = new Intent(); static { SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); } - private IXmppConnection xmppConnection = null; - private IXmppFacade xmppFacade = null; - private final Handler connectionHandler = new Handler(); + + private final Handler connectionHandler = new Handler(); + private ProgressDialog progressDialog = null; - private ProgressDialog progressDialog = null; - - private boolean mIsConnected = false; - private final ServiceConnection mServConn = new BeemServiceConnection(); + private boolean mIsConnected = false; + private final ServiceConnection mServConn = new BeemServiceConnection(); + private IXmppFacade xmppFacade = null; /** * Create an about "BEEM" dialog @@ -215,4 +101,117 @@ if (!mIsConnected) bindService(Login.SERVICE_INTENT, mServConn, BIND_AUTO_CREATE); } + + private class BeemConnectionListener extends IBeemConnectionListener.Stub { + + private class ErrorRunnable implements Runnable { + + private final String mErrorMsg; + + public ErrorRunnable(String errorMsg) { + mErrorMsg = errorMsg; + } + + @Override + public void run() { + progressDialog.setMessage(mErrorMsg); + } + + } + + @Override + public void connectionClosed() throws RemoteException { + mIsConnected = false; + Login.this.unbindService(mServConn); + Login.this.stopService(SERVICE_INTENT); + } + + @Override + public void connectionClosedOnError() throws RemoteException { + mIsConnected = false; + Login.this.unbindService(mServConn); + Login.this.stopService(SERVICE_INTENT); + } + + @Override + public void connectionFailed(String errorMsg) throws RemoteException { + connectionHandler.post(new ErrorRunnable(errorMsg)); + mIsConnected = false; + Login.this.unbindService(mServConn); + Login.this.stopService(SERVICE_INTENT); + dismissProgressDialog(); + } + + private void dismissProgressDialog() { + connectionHandler.post(new Runnable() { + + @Override + public void run() { + progressDialog.dismiss(); + } + }); + } + + @Override + public void onConnect() throws RemoteException { + mIsConnected = true; + dismissProgressDialog(); + Log.i(getString(R.string.login_tag), "Connected."); + xmppFacade.changeStatus(Status.CONTACT_STATUS_AVAILABLE, null); + startActivity(new Intent(Login.this, ContactList.class)); + finish(); + } + + @Override + public void reconnectingIn(int seconds) throws RemoteException { + + } + + @Override + public void reconnectionFailed() throws RemoteException { + mIsConnected = false; + } + + @Override + public void reconnectionSuccessful() throws RemoteException { + mIsConnected = true; + } + } + + private class BeemServiceConnection implements ServiceConnection { + private IXmppConnection xmppConnection = null; + + @Override + public void onServiceConnected(ComponentName name, IBinder service) { + xmppFacade = IXmppFacade.Stub.asInterface(service); + try { + xmppConnection = xmppFacade.createConnection(); + xmppConnection.addConnectionListener(new BeemConnectionListener()); + if (!xmppConnection.isAuthentificated()) { + connectionHandler.post(new Runnable() { + + @Override + public void run() { + progressDialog.setMessage("Loading. Please wait..."); + progressDialog.show(); + } + }); + Login.this.startService(Login.SERVICE_INTENT); + } else { + mIsConnected = true; + startActivity(new Intent(Login.this, ContactList.class)); + finish(); + } + } catch (RemoteException e) { + Log.e(getString(R.string.login_tag), "REMOTE EXCEPTION $" + e.getMessage()); + } + } + + @Override + public void onServiceDisconnected(ComponentName name) { + xmppFacade = null; + mIsConnected = false; + } + } + } diff -r d8fa7f751a0f -r 23647e075321 src/com/beem/project/beem/ui/SendIM.java --- a/src/com/beem/project/beem/ui/SendIM.java Wed Jun 17 18:33:14 2009 +0200 +++ b/src/com/beem/project/beem/ui/SendIM.java Wed Jun 17 19:03:11 2009 +0200 @@ -40,69 +40,6 @@ public class SendIM extends Activity implements OnClickListener, OnKeyListener { - /** - * Listener for chat creation. (maybe not necessary) - * - * @author darisk - */ - private class OnChatListener extends IChatManagerListener.Stub { - - /** - * {@inheritDoc} - */ - @Override - public void chatCreated(IChat chat, boolean locally) throws RemoteException { - Log.i("LOG", "chatCreated"); - } - - } - - /** - * Listener for new chat messages. - * - * @author darisk - */ - private class OnMessageListener extends IMessageListener.Stub { - - /** - * {@inheritDoc} - */ - @Override - public void processMessage(IChat chat, Message msg) throws RemoteException { - - if (chat != mChat) - return; - final Message m = msg; - mHandler.post(new Runnable() { - - @Override - public void run() { - if (m.getBody() != null) { - if (mSpeak == 2) - mText.append(m.getBody() + "\n"); - else { - String str = String.format(getString(R.string.SendIMSays), m.getFrom()); - mText.append(str); - mText.append(m.getBody() + "\n"); - } - mScrolling.fullScroll(ScrollView.FOCUS_DOWN); - mToSend.requestFocus(); - mSpeak = 2; - } - } - }); - } - - /** - * {@inheritDoc} - */ - @Override - public void stateChanged(IChat chat) throws RemoteException { - // TODO: a integrer dans l'ui - // Log.d(TAG, "state changed"); - } - } - private static final String TAG = "SEND_IM"; private EditText mToSend; private SendIMDialogSmiley mSmyDialog; @@ -388,4 +325,69 @@ mContact = newContact; mToSend.requestFocus(); } + + + /** + * Listener for chat creation. (maybe not necessary) + * + * @author darisk + */ + private class OnChatListener extends IChatManagerListener.Stub { + + /** + * {@inheritDoc} + */ + @Override + public void chatCreated(IChat chat, boolean locally) throws RemoteException { + Log.i("LOG", "chatCreated"); + } + + } + + /** + * Listener for new chat messages. + * + * @author darisk + */ + private class OnMessageListener extends IMessageListener.Stub { + + /** + * {@inheritDoc} + */ + @Override + public void processMessage(IChat chat, Message msg) throws RemoteException { + + if (chat != mChat) + return; + final Message m = msg; + mHandler.post(new Runnable() { + + @Override + public void run() { + if (m.getBody() != null) { + if (mSpeak == 2) + mText.append(m.getBody() + "\n"); + else { + String str = String.format(getString(R.string.SendIMSays), m.getFrom()); + mText.append(str); + mText.append(m.getBody() + "\n"); + } + mScrolling.fullScroll(ScrollView.FOCUS_DOWN); + mToSend.requestFocus(); + mSpeak = 2; + } + } + }); + } + + /** + * {@inheritDoc} + */ + @Override + public void stateChanged(IChat chat) throws RemoteException { + // TODO: a integrer dans l'ui + // Log.d(TAG, "state changed"); + } + } + }