--- a/AndroidManifest.xml Fri Feb 19 00:49:37 2010 +0100
+++ b/AndroidManifest.xml Fri Feb 19 02:26:21 2010 +0100
@@ -4,7 +4,7 @@
android:versionName="0.1.2">
<application android:label="@string/app_name"
android:icon="@drawable/beem_launcher_icon_silver" android:theme="@style/Theme.BEEM.Default"
- android:debuggable="true" android:name="@string/app_name">
+ android:debuggable="true" android:name=".BeemApplication">
<activity android:name=".ui.Login" android:label="@string/app_name"
android:screenOrientation="portrait" android:launchMode="singleTask">
<intent-filter>
@@ -13,7 +13,7 @@
</intent-filter>
</activity>
<activity android:name=".ui.LoginAnim" android:label="@string/login_login_progress"
- android:launchMode="singleTop" />
+ android:launchMode="singleTop" android:screenOrientation="portrait" />
<activity android:name=".ui.Settings" android:label="@string/edit_settings_name">
<intent-filter android:label="Beem Connection">
<action
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/com/beem/project/beem/BeemApplication.java Fri Feb 19 02:26:21 2010 +0100
@@ -0,0 +1,79 @@
+/*
+ BEEM is a videoconference application on the Android Platform.
+
+ Copyright (C) 2009 by Frederic-Charles Barthelery,
+ Jean-Manuel Da Silva,
+ Nikita Kozlov,
+ Philippe Lago,
+ Jean Baptiste Vergely,
+ Vincent Veronis.
+
+ This file is part of BEEM.
+
+ BEEM is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ BEEM is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with BEEM. If not, see <http://www.gnu.org/licenses/>.
+
+ Please send bug reports with examples or suggestions to
+ contact@beem-project.com or http://dev.beem-project.com/
+
+ Epitech, hereby disclaims all copyright interest in the program "Beem"
+ written by Frederic-Charles Barthelery,
+ Jean-Manuel Da Silva,
+ Nikita Kozlov,
+ Philippe Lago,
+ Jean Baptiste Vergely,
+ Vincent Veronis.
+
+ Nicolas Sadirac, November 26, 2009
+ President of Epitech.
+
+ Flavien Astraud, November 26, 2009
+ Head of the EIP Laboratory.
+
+*/
+
+package com.beem.project.beem;
+
+import android.app.Application;
+
+/**
+ * This class contains informations that needs to be global in the application.
+ * Theses informations must be necessary for the activities and the service.
+ * @author Da Risk <darisk972@gmail.com>
+ */
+public class BeemApplication extends Application {
+
+ private boolean mIsConnected;
+
+ @Override
+ public void onCreate() {
+ super.onCreate();
+ }
+
+ /**
+ * Tell if Beem is connected to a XMPP server.
+ * @return false if not connected.
+ */
+ public boolean isConnected() {
+ return mIsConnected;
+ }
+
+ /**
+ * Set the status of the connection to a XMPP server of BEEM.
+ * @param isConnected
+ */
+ public void setConnected(boolean isConnected) {
+ mIsConnected = isConnected;
+ }
+
+}
--- a/src/com/beem/project/beem/service/BeemChatManager.java Fri Feb 19 00:49:37 2010 +0100
+++ b/src/com/beem/project/beem/service/BeemChatManager.java Fri Feb 19 02:26:21 2010 +0100
@@ -92,6 +92,7 @@
@Override
public void chatCreated(Chat chat, boolean locally) {
IChat newchat = getChat(chat);
+ Log.d(TAG, "Chat" + chat.toString() + " created locally " + locally + "with " + chat.getParticipant());
try {
newchat.addMessageListener(mChatListener);
final int n = mRemoteChatCreationListeners.beginBroadcast();
--- a/src/com/beem/project/beem/service/XmppConnectionAdapter.java Fri Feb 19 00:49:37 2010 +0100
+++ b/src/com/beem/project/beem/service/XmppConnectionAdapter.java Fri Feb 19 02:26:21 2010 +0100
@@ -59,6 +59,7 @@
import android.app.Notification;
import android.app.PendingIntent;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.RemoteCallbackList;
@@ -67,6 +68,7 @@
import com.beem.project.beem.BeemService;
import com.beem.project.beem.R;
+import com.beem.project.beem.BeemApplication;
import com.beem.project.beem.service.aidl.IBeemConnectionListener;
import com.beem.project.beem.service.aidl.IChatManager;
import com.beem.project.beem.service.aidl.IRoster;
@@ -101,6 +103,7 @@
private String mPreviousStatus;
private PrivacyListManagerAdapter mPrivacyListManager;
private final BeemService mService;
+ private BeemApplication mApplication;
private final RemoteCallbackList<IBeemConnectionListener> mRemoteConnListeners = new RemoteCallbackList<IBeemConnectionListener>();
private final SubscribePacketListener mSubscribePacketListener = new SubscribePacketListener();
@@ -144,6 +147,10 @@
mLogin = login;
mPassword = password;
mService = service;
+ Context ctx = mService.getApplicationContext();
+ if (ctx instanceof BeemApplication) {
+ mApplication = (BeemApplication) ctx;
+ }
SharedPreferences pref = mService.getServicePreference();
try {
mPreviousPriority = Integer.parseInt(pref.getString("settings_key_priority", "0"));
@@ -221,7 +228,7 @@
mService.resetStatus();
mService.initJingle(mAdaptee);
- // triggerAsynchronousConnectEvent();
+ mApplication.setConnected(true);
changeStatus(Status.CONTACT_STATUS_AVAILABLE, mService.getServicePreference().getString("status_text", ""));
return true;
} catch (XMPPException e) {
@@ -369,7 +376,7 @@
Roster adap = mAdaptee.getRoster();
if (adap == null)
return null;
- mRoster = new RosterAdapter(adap, mService.getApplicationContext());
+ mRoster = new RosterAdapter(adap, mService);
return mRoster;
}
@@ -403,13 +410,6 @@
}
/**
- * Trigger Connection event.
- */
- private void triggerAsynchronousConnectEvent() {
- mConListener.onConnect();
- }
-
- /**
* PrivacyListManagerAdapter mutator.
* @param privacyListManager the privacy list manager
*/
@@ -457,6 +457,7 @@
intent.putExtra("normally", true);
mService.sendBroadcast(intent);
mService.stopSelf();
+ mApplication.setConnected(false);
}
/**
@@ -470,6 +471,7 @@
intent.putExtra("message", exception.getMessage());
mService.sendBroadcast(intent);
mService.stopSelf();
+ mApplication.setConnected(false);
}
/**
@@ -493,61 +495,7 @@
}
mRemoteConnListeners.finishBroadcast();
mService.stopSelf();
- }
-
- /**
- * Method to execute when a connection event occurs.
- */
- public void onConnect() {
- PacketFilter filter = new PacketFilter() {
-
- @Override
- public boolean accept(Packet packet) {
- if (packet instanceof Presence) {
- Presence pres = (Presence) packet;
- if (pres.getType() == Presence.Type.subscribe)
- return true;
- }
- return false;
- }
- };
-
- mAdaptee.addPacketListener(new PacketListener() {
-
- @Override
- public void processPacket(Packet packet) {
- String from = packet.getFrom();
- Notification notif = new Notification(android.R.drawable.stat_notify_more, mService.getString(
- R.string.AcceptContactRequest, from), System.currentTimeMillis());
- notif.defaults = Notification.DEFAULT_ALL;
- notif.flags = Notification.FLAG_AUTO_CANCEL;
- Intent intent = new Intent(mService, Subscription.class);
- intent.putExtra("from", from);
- notif.setLatestEventInfo(mService, from, mService
- .getString(R.string.AcceptContactRequestFrom, from), PendingIntent.getActivity(mService, 0,
- intent, PendingIntent.FLAG_ONE_SHOT));
- int id = packet.hashCode();
- mService.sendNotification(id, notif);
- }
- }, filter);
-
- mService.resetStatus();
- mService.initJingle(mAdaptee);
-
- final int n = mRemoteConnListeners.beginBroadcast();
-
- for (int i = 0; i < n; i++) {
- IBeemConnectionListener listener = mRemoteConnListeners.getBroadcastItem(i);
- try {
- if (listener != null)
- listener.onConnect();
- } 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();
+ mApplication.setConnected(false);
}
/**
@@ -600,6 +548,7 @@
@Override
public void reconnectionSuccessful() {
Log.d(TAG, "reconnectionSuccessful");
+ mApplication.setConnected(true);
PacketFilter filter = new PacketFilter() {
@Override
--- a/src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl Fri Feb 19 00:49:37 2010 +0100
+++ b/src/com/beem/project/beem/service/aidl/IBeemConnectionListener.aidl Fri Feb 19 02:26:21 2010 +0100
@@ -56,8 +56,9 @@
/**
* Callback to call when the connection occurs
+ * @Deprecated
*/
- void onConnect();
+ //void onConnect();
//void connectionClosedOnError(in Exception e);
/**
--- a/src/com/beem/project/beem/ui/Login.java Fri Feb 19 00:49:37 2010 +0100
+++ b/src/com/beem/project/beem/ui/Login.java Fri Feb 19 02:26:21 2010 +0100
@@ -45,6 +45,7 @@
import android.app.Activity;
import android.app.AlertDialog;
+import android.app.Application;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -60,6 +61,7 @@
import com.beem.project.beem.R;
import com.beem.project.beem.utils.BeemConnectivity;
+import com.beem.project.beem.BeemApplication;
/**
* This class is the main Activity for the Beem project.
@@ -72,6 +74,7 @@
private TextView mTextView;
private boolean mIsConfigured;
private boolean mIsResult;
+ private BeemApplication mBeemApplication;
/**
* Constructor.
@@ -82,6 +85,14 @@
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ Application app = getApplication();
+ if (app instanceof BeemApplication) {
+ BeemApplication mBeemApplication = (BeemApplication) app;
+ if (mBeemApplication.isConnected()) {
+ startActivity(new Intent(this, ContactList.class));
+ finish();
+ }
+ }
setContentView(R.layout.login);
mTextView = (TextView) findViewById(R.id.log_as_msg);
mSettings = PreferenceManager.getDefaultSharedPreferences(this);