# HG changeset patch
# User marseille@KungFuh
# Date 1239128082 -7200
# Node ID 84cad8522aa65e26c1e35c18873763a322f728ec
# Parent 23a0dfdff5893394986b8bcd8a44a1f5a63b560a# Parent 29f0d6a23321a115c3881a2f1c1afd0f66717fcd
merge.
diff -r 23a0dfdff589 -r 84cad8522aa6 res/values/strings.xml
--- a/res/values/strings.xml Tue Apr 07 19:57:37 2009 +0200
+++ b/res/values/strings.xml Tue Apr 07 20:14:42 2009 +0200
@@ -17,6 +17,15 @@
host
Jabber IDloginpassword
port
+ proxy_host
+ proxy_port
+ use_proxy
+ proxy_type
+ proxy_user
+ proxy_password
+ HTTP
+ SOCKS4
+ SOCKS5
says :\n
diff -r 23a0dfdff589 -r 84cad8522aa6 src/com/beem/project/beem/BeemService.java
--- a/src/com/beem/project/beem/BeemService.java Tue Apr 07 19:57:37 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java Tue Apr 07 20:14:42 2009 +0200
@@ -1,20 +1,19 @@
package com.beem.project.beem;
+import org.jivesoftware.smack.ConnectionConfiguration;
+import org.jivesoftware.smack.proxy.ProxyInfo;
+import org.jivesoftware.smack.proxy.ProxyInfo.ProxyType;
import android.app.Notification;
import android.app.NotificationManager;
-import android.app.PendingIntent;
import android.app.Service;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.IBinder;
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.IBeemConnectionListener;
+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.
@@ -35,8 +34,9 @@
private String mLogin;
private String mPassword;
private String mHost;
-
-
+ private ConnectionConfiguration mConnectionConfiguration;
+ private ProxyInfo mProxyInfo;
+ private boolean mUseProxy;
private IXmppFacade.Stub mBind;
/**
@@ -65,12 +65,36 @@
mLogin = mSettings.getString(getString(R.string.PreferenceLoginKey), "");
mPassword = mSettings.getString(getString(R.string.PreferencePasswordKey), "");
mHost = mSettings.getString(getString(R.string.PreferenceHostKey), "");
+ mHost = "10.0.2.2";
+ initConnectionConfig();
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- mConnection = new XmppConnectionAdapter("10.0.2.2", mLogin, mPassword); // address
+ mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword);
mBind = new XmppFacade(mConnection, this);
}
/**
+ * Initialise la configuration de la connexion.
+ */
+ private void initConnectionConfig() {
+ //TODO mettre a false par defaut et remplacer les valeurs par defaut
+ mUseProxy = mSettings.getBoolean(getString(R.string.PreferenceUseProxy), false);
+ if (mUseProxy) {
+ String stype = mSettings.getString(getString(R.string.PreferenceProxyType),
+ getString(R.string.PreferenceProxyTypeHttp));
+ String phost = mSettings.getString(getString(R.string.PreferenceProxyHost), "");
+ String puser = mSettings.getString(getString(R.string.PreferenceProxyUser), "");
+ String ppass = mSettings.getString(getString(R.string.PreferenceProxyPassword), "");
+ int pport = mSettings.getInt(getString(R.string.PreferenceProxyPort), 3128);
+ ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
+ mProxyInfo = new ProxyInfo(type, phost, pport, puser, ppass);
+ mConnectionConfiguration = new ConnectionConfiguration(mHost, mProxyInfo);
+ } else {
+ mConnectionConfiguration = new ConnectionConfiguration(mHost);
+ }
+ mConnectionConfiguration.setSendPresence(true);
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
diff -r 23a0dfdff589 -r 84cad8522aa6 src/com/beem/project/beem/service/RosterAdapter.java
--- a/src/com/beem/project/beem/service/RosterAdapter.java Tue Apr 07 19:57:37 2009 +0200
+++ b/src/com/beem/project/beem/service/RosterAdapter.java Tue Apr 07 20:14:42 2009 +0200
@@ -46,16 +46,22 @@
roster.addRosterListener(mRosterListener);
for (RosterEntry entry : roster.getEntries()) {
String user = StringUtils.parseBareAddress(entry.getUser());
- if ( !mContacts.containsKey(user))
+ if (!mContacts.containsKey(user))
mContacts.put(user, new Contact(user));
}
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void createGroup(String groupname) throws RemoteException {
mAdaptee.createGroup(groupname);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Contact addContact(String user, String name, String[] groups) throws RemoteException {
try {
@@ -76,18 +82,27 @@
mContacts.remove(contact.getJID());
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void addConnectionListener(IBeemRosterListener listen) throws RemoteException {
if (listen != null)
mRemoteRosListeners.register(listen);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void removeConnectionListener(IBeemRosterListener listen) throws RemoteException {
if (listen != null)
mRemoteRosListeners.unregister(listen);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public Contact getContact(String jid) throws RemoteException {
return mContacts.get(jid);
@@ -103,8 +118,24 @@
return res;
}
+ /**
+ * Listener for the roster events.
+ * It will call the remote listeners registered.
+ * @author darisk
+ *
+ */
private class RosterListenerAdapter implements RosterListener {
+ /**
+ * Constructor.
+ */
+ public RosterListenerAdapter() {
+ // TODO Auto-generated constructor stub
+ }
+
+ /**
+ * {@inheritDoc}
+ */
@Override
public void entriesAdded(Collection addresses) {
Log.i(TAG, "Ajout de l'entry");
@@ -125,6 +156,9 @@
mRemoteRosListeners.finishBroadcast();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void entriesDeleted(Collection addresses) {
Log.i(TAG, "Suppression de l'entry");
@@ -142,9 +176,12 @@
Log.w(TAG, "Error while deleting roster entries", e);
}
}
- mRemoteRosListeners.finishBroadcast();
+ mRemoteRosListeners.finishBroadcast();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void entriesUpdated(Collection addresses) {
Log.i(TAG, "Update de l'entry");
@@ -162,15 +199,18 @@
Log.w(TAG, "Error while updating roster entries", e);
}
}
- mRemoteRosListeners.finishBroadcast();
+ mRemoteRosListeners.finishBroadcast();
}
+ /**
+ * {@inheritDoc}
+ */
@Override
public void presenceChanged(Presence presence) {
Log.i(TAG, "Changement de Presence");
/* gestion du roster coter sedirvice */
String user = StringUtils.parseBareAddress(presence.getFrom());
- Log.d(TAG, "User : "+user);
+ Log.d(TAG, "User : " + user);
Contact c = mContacts.get(StringUtils.parseBareAddress(user));
if (c == null) {
c = new Contact(user);
@@ -191,7 +231,7 @@
Log.w(TAG, "Error while updating roster entries", e);
}
}
- mRemoteRosListeners.finishBroadcast();
+ mRemoteRosListeners.finishBroadcast();
}
}
diff -r 23a0dfdff589 -r 84cad8522aa6 src/com/beem/project/beem/service/XmppConnectionAdapter.java
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Tue Apr 07 19:57:37 2009 +0200
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Tue Apr 07 20:14:42 2009 +0200
@@ -73,20 +73,21 @@
*/
@Override
public boolean connectSync() throws RemoteException {
- try {
- mAdaptee.connect();
- mAdaptee.addConnectionListener(mConListener);
- mAdaptee.login(mLogin, mPassword, "BEEM");
- mChatManager = new BeemChatManager(mAdaptee.getChatManager());
- // TODO find why this cause a null pointer exception
- // this.initFeatures(); // pour declarer les features xmpp qu'on supporte
- mLastException = null;
- triggerAsynchronousConnectEvent();
- return true;
- } catch (XMPPException e) {
- mLastException = new BeemException(e);
- }
- return false;
+ try {
+ mAdaptee.connect();
+ mAdaptee.addConnectionListener(mConListener);
+ mAdaptee.login(mLogin, mPassword, "BEEM");
+ mChatManager = new BeemChatManager(mAdaptee.getChatManager());
+ // TODO find why this cause a null pointer exception
+ // this.initFeatures(); // pour declarer les features xmpp qu'on supporte
+ mLastException = null;
+ triggerAsynchronousConnectEvent();
+ return true;
+ } catch (XMPPException e) {
+ Log.e(TAG, "Error while connecting", e);
+ mLastException = new BeemException(e);
+ }
+ return false;
}
/**
@@ -106,10 +107,10 @@
public IRoster getRoster() throws RemoteException {
if (mRoster != null)
return mRoster;
- Roster adap = mAdaptee.getRoster();
- if (adap == null)
- return null;
- mRoster = new RosterAdapter(adap);
+ Roster adap = mAdaptee.getRoster();
+ if (adap == null)
+ return null;
+ mRoster = new RosterAdapter(adap);
return mRoster;
}
@@ -264,6 +265,7 @@
} catch (RemoteException e) {
// The RemoteCallbackList will take care of removing the
// dead listeners.
+ Log.w(TAG, "Error while triggering remote connection listeners", e);
}
}
mRemoteConnListeners.finishBroadcast();
@@ -311,7 +313,11 @@
}
- public boolean isAuthentificated() throws RemoteException {
+ /**
+ * Returns true if currently authenticated by successfully calling the login method.
+ * @return true when successfully authenticated
+ */
+ public boolean isAuthentificated() {
return mAdaptee.isAuthenticated();
}
diff -r 23a0dfdff589 -r 84cad8522aa6 src/com/beem/project/beem/ui/ContactList.java
--- a/src/com/beem/project/beem/ui/ContactList.java Tue Apr 07 19:57:37 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java Tue Apr 07 20:14:42 2009 +0200
@@ -282,7 +282,7 @@
*/
v = (TextView) view.findViewById(to[2]);
if (v != null) {
- v.setText(c.getMMsgState());
+ v.setText(c.getMsgState());
}
/*