src/com/beem/project/beem/BeemService.java
changeset 148 c169121bd07e
parent 145 70b67bdac4fc
parent 147 472d56ba57c6
child 163 52e96a8a743d
--- a/src/com/beem/project/beem/BeemService.java	Thu Apr 23 16:59:45 2009 +0200
+++ b/src/com/beem/project/beem/BeemService.java	Thu Apr 23 17:03:53 2009 +0200
@@ -14,6 +14,7 @@
 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;
@@ -26,6 +27,8 @@
 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.ui.SendIM;
+import com.beem.project.beem.ui.Subscription;
 
 /**
  * This class is for the Beem service.
@@ -72,7 +75,7 @@
      */
     @Override
     public void onCreate() {
-	
+
 	super.onCreate();
 	mSettings = getSharedPreferences(getString(R.string.PreferenceFileName), MODE_PRIVATE);
 	mLogin = mSettings.getString(getString(R.string.PreferenceLoginKey), "");
@@ -117,7 +120,7 @@
     public void sendNotification(int id, Notification notif) {
 	mNotificationManager.notify(id, notif);
     }
-    
+
     /**
      * Initialise la configuration de la connexion.
      */
@@ -168,7 +171,7 @@
 			@Override
 			public void processPacket(Packet packet) {
 			    // TODO Auto-generated method stub
-			    Log.i("TEST", "Une demande recue");
+			    Log.d("TEST", "Une demande recue");
 			}
 		    }, filter);
 		}
@@ -185,7 +188,7 @@
 
 		}
 
-		
+
 		@Override
 		public void onConnect() throws RemoteException {
 		    // TODO Auto-generated method stub
@@ -205,8 +208,17 @@
 
 			@Override
 			public void processPacket(Packet packet) {
-			    // TODO Auto-generated method stub
-			    Log.i("TEST", "Une demande recue");
+			    String from = packet.getFrom();
+			    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));
+			    int id = packet.hashCode();
+			    sendNotification(id, notif);
 			}
 		    }, filter);
 
@@ -228,7 +240,7 @@
 		@Override
 		public void connectionFailed(String errorMsg) throws RemoteException {
 		    // TODO Auto-generated method stub
-		    
+
 		}
 	    });
 	} catch (RemoteException e) {
@@ -245,5 +257,5 @@
 	    mConnection.disconnect();
     }
 
-    
+
 }