modif
authormarseille@marseille-desktop
Thu, 21 May 2009 16:33:11 +0200
changeset 193 54e1e3f0bd4b
parent 192 b74384311dee
child 194 4f1b3af03671
child 196 052599f4e646
modif
res/layout/contactlistgroup.xml
src/com/beem/project/beem/BeemService.java
src/com/beem/project/beem/ui/ContactList.java
--- a/res/layout/contactlistgroup.xml	Thu May 21 15:41:11 2009 +0200
+++ b/res/layout/contactlistgroup.xml	Thu May 21 16:33:11 2009 +0200
@@ -9,6 +9,7 @@
         <TextView android:id="@+id/textgroup"
         	android:layout_width="fill_parent"
             android:layout_height="wrap_content"
+            android:minHeight="30sp"
             android:paddingLeft="40sp" />
 
 </LinearLayout> 
\ No newline at end of file
--- a/src/com/beem/project/beem/BeemService.java	Thu May 21 15:41:11 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Thu May 21 16:33:11 2009 +0200
@@ -27,8 +27,7 @@
 import com.beem.project.beem.ui.Subscription;
 
 /**
- * This class is for the Beem service.
- * The connection to the xmpp server will be made asynchronously when the service
+ * This class is for the Beem service. The connection to the xmpp server will be made asynchronously when the service
  * will start.
  * @author darisk
  */
@@ -80,10 +79,10 @@
 	mPassword = mSettings.getString(getString(R.string.PreferencePasswordKey), "");
 	mHost = mSettings.getString(getString(R.string.PreferenceHostKey), "");
 	mPort = mSettings.getInt(getString(R.string.PreferencePortKey), 5222);
-	mService = mSettings.getString(getString(R.string.PreferenceService), "");
-	
-	// TODO penser a commenter
-	// mHost = "10.0.2.2";
+	if (mHost.equals("talk.google.com"))
+	    mService = "gmail.com";
+	else
+	    mService = null;
 	initConnectionConfig();
 	mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
 	mConnection = new XmppConnectionAdapter(mConnectionConfiguration, mLogin, mPassword, this);
@@ -115,8 +114,8 @@
 
     /**
      * Show a notification.
-     * @param id 	the id of the notification.
-     * @param notif	the notification to show
+     * @param id the id of the notification.
+     * @param notif the notification to show
      */
     public void sendNotification(int id, Notification notif) {
 	mNotificationManager.notify(id, notif);
@@ -126,7 +125,7 @@
      * Initialise la configuration de la connexion.
      */
     private void initConnectionConfig() {
-	//TODO mettre a false par defaut et remplacer les valeurs par defaut
+	// 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),
@@ -134,12 +133,18 @@
 	    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), 1080);
+	    int pport = mSettings.getInt(getString(R.string.PreferenceProxyPort), 1080);
 	    ProxyInfo.ProxyType type = ProxyType.valueOf(stype);
 	    mProxyInfo = new ProxyInfo(type, phost, pport, puser, ppass);
-	    mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mService, mProxyInfo);
+	    if (mService != null)
+		mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mService, mProxyInfo);
+	    else
+		mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mProxyInfo);
 	} else {
-	    mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort);
+	    if (mService != null)
+		mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort, mService);
+	    else
+		mConnectionConfiguration = new ConnectionConfiguration(mHost, mPort);
 	}
 	mConnectionConfiguration.setDebuggerEnabled(false);
 	mConnectionConfiguration.setSendPresence(true);
@@ -147,7 +152,7 @@
 
     private void initRosterRequestListener() {
 	Roster.setDefaultSubscriptionMode(SubscriptionMode.manual);
-	final XMPPConnection con =  mConnection.getAdaptee();
+	final XMPPConnection con = mConnection.getAdaptee();
 	try {
 	    // l'ajout d'un packet listener ne peut etre effectuer que lorsqu'on est connecte au serveur
 	    mConnection.addConnectionListener(new IBeemConnectionListener.Stub() {
@@ -189,10 +194,9 @@
 
 		}
 
-
 		@Override
 		public void onConnect() throws RemoteException {
-		    
+
 		    PacketFilter filter = new PacketFilter() {
 
 			@Override
@@ -210,14 +214,14 @@
 			@Override
 			public void processPacket(Packet packet) {
 			    String from = packet.getFrom();
-			    Notification notif = new Notification(com.beem.project.beem.R.drawable.signal, "Demande d'ajout", System
-				.currentTimeMillis());
+			    Notification notif = new Notification(com.beem.project.beem.R.drawable.signal,
+				"Demande d'ajout", System.currentTimeMillis());
 			    notif.defaults = Notification.DEFAULT_ALL;
 			    notif.flags = Notification.FLAG_AUTO_CANCEL;
 			    Intent intent = new Intent(BeemService.this, Subscription.class);
 			    intent.putExtra("from", from);
-			    notif.setLatestEventInfo(BeemService.this, from, "demande d'ajout de " + from, PendingIntent.getActivity(BeemService.this, 0,
-				intent, PendingIntent.FLAG_ONE_SHOT));
+			    notif.setLatestEventInfo(BeemService.this, from, "demande d'ajout de " + from,
+				PendingIntent.getActivity(BeemService.this, 0, intent, PendingIntent.FLAG_ONE_SHOT));
 			    int id = packet.hashCode();
 			    sendNotification(id, notif);
 			}
@@ -237,7 +241,6 @@
 
 		}
 
-
 		@Override
 		public void connectionFailed(String errorMsg) throws RemoteException {
 		    // TODO Auto-generated method stub
@@ -258,5 +261,4 @@
 	    mConnection.disconnect();
     }
 
-
 }
--- a/src/com/beem/project/beem/ui/ContactList.java	Thu May 21 15:41:11 2009 +0200
+++ b/src/com/beem/project/beem/ui/ContactList.java	Thu May 21 16:33:11 2009 +0200
@@ -88,10 +88,6 @@
 		    callbackShowContactList();
 	    }
 	});
-	if (!mBeemApplication.isConnected()) {
-	    mBeemApplication = BeemApplication.getApplication(this);
-	    mBeemApplication.startBeemService();
-	}
     }
 
     @Override
@@ -165,7 +161,6 @@
     }
 
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-	//TODO:marche pas
 	if (requestCode == PREFERENCECHANGED) {
 	    if (resultCode == RESULT_OK) {
 		mAdapter = null;