# HG changeset patch # User Vincent Veronis # Date 1253891714 -7200 # Node ID 172ed4d2b2c7ec80510e43d266138930c5b52f52 # Parent 1bc22fb59ff09201ce9d67b3fca5d90e48c4fb09# Parent 571b95fa452c8049689874aab06e6d748b248a7e Merge. diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 AndroidManifest.xml --- a/AndroidManifest.xml Fri Sep 25 19:10:48 2009 +0200 +++ b/AndroidManifest.xml Fri Sep 25 17:15:14 2009 +0200 @@ -10,18 +10,50 @@ + + + - - + android:launchMode="singleTop"> + + + + + + + + + + + + + + - + + + + + - + + + + + + + + + + + + + + + + + + + + diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 src/com/beem/project/beem/jingle/JingleService.java --- a/src/com/beem/project/beem/jingle/JingleService.java Fri Sep 25 19:10:48 2009 +0200 +++ b/src/com/beem/project/beem/jingle/JingleService.java Fri Sep 25 17:15:14 2009 +0200 @@ -40,9 +40,6 @@ mMediaManagers = new ArrayList(); mMediaManagers.add(new MicrophoneRTPManager(bt)); - //mJingleManager = new JingleManager(xmppConnection, mMediaManagers); - //mJingleManager.addJingleSessionRequestListener(new BeemJingleSessionRequestListener()); - } /** diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 src/com/beem/project/beem/jingle/demo/JingleCallActivity.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/com/beem/project/beem/jingle/demo/JingleCallActivity.java Fri Sep 25 17:15:14 2009 +0200 @@ -0,0 +1,88 @@ +package com.beem.project.beem.jingle.demo; + +import org.jivesoftware.smack.ConnectionConfiguration; +import org.jivesoftware.smack.XMPPConnection; +import org.jivesoftware.smack.XMPPException; +import org.jivesoftware.smack.util.StringUtils; + +import android.app.Activity; +import android.os.Bundle; +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.Button; +import android.widget.EditText; +import android.widget.Toast; + +import com.beem.project.beem.R; +import com.beem.project.beem.jingle.JingleService; + +/** + * Activity used to test Jingle call. + * @author darisk + */ +public class JingleCallActivity extends Activity { + + private XMPPConnection mConnection; + private ConnectionConfiguration mConf; + private JingleService mJingle; + + private Button mBtconnect; + private Button mBtcall; + private EditText mEdJID; + private EditText mEdPassword; + private EditText mEdReceiver; + + /** + * Constructor. + */ + public JingleCallActivity() { + } + + @Override + protected void onCreate(Bundle savedInstanceState) { + // TODO Auto-generated method stub + super.onCreate(savedInstanceState); + setContentView(R.layout.jingle_call_activity); + // localhost + mConf = new ConnectionConfiguration("10.0.2.2", 5222); + mEdJID = (EditText) findViewById(R.id.jingledemocalljid); + mEdPassword = (EditText) findViewById(R.id.jingledemocallpassword); + mEdReceiver = (EditText) findViewById(R.id.jingledemocallreceiver); + mBtconnect = (Button) findViewById(R.id.jingledemocallconnectbutton); + mBtconnect.setOnClickListener(new OnClickListener() { + + @Override + public void onClick(View arg0) { + String jid = mEdJID.getText().toString(); + String login = StringUtils.parseName(jid); + mConnection = new XMPPConnection(mConf); + String password = mEdPassword.getText().toString(); + try { + mConnection.connect(); + mConnection.login(login, password); + mJingle = new JingleService(mConnection); + mBtcall.setEnabled(true); + } catch (XMPPException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + }); + mBtcall = (Button) findViewById(R.id.jingledemocallbutton); + mBtcall.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View arg0) { + String jid = mEdReceiver.getText().toString(); + if (!"".equals(jid)) { + mJingle.call(jid); + Toast.makeText(JingleCallActivity.this, "Appel en cours", Toast.LENGTH_SHORT); + } else + Toast.makeText(JingleCallActivity.this, "Remplir le champ (JID complet en toto@tutu.com/truc)", + Toast.LENGTH_SHORT); + } + }); + + } + +} diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 src/com/beem/project/beem/ui/AddContact.java --- a/src/com/beem/project/beem/ui/AddContact.java Fri Sep 25 19:10:48 2009 +0200 +++ b/src/com/beem/project/beem/ui/AddContact.java Fri Sep 25 17:15:14 2009 +0200 @@ -4,8 +4,11 @@ import java.util.List; import java.util.regex.Pattern; import android.app.Activity; +import android.content.BroadcastReceiver; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; @@ -18,8 +21,8 @@ import android.widget.Toast; import com.beem.project.beem.BeemService; import com.beem.project.beem.R; +import com.beem.project.beem.service.XmppConnectionAdapter; import com.beem.project.beem.service.aidl.IXmppFacade; - /** * This activity is used to add a contact. * @author nikita @@ -30,6 +33,12 @@ private final List mGroup = new ArrayList(); private IXmppFacade mXmppFacade; private final ServiceConnection mServConn = new BeemServiceConnection(); + private BroadcastReceiver mReceiver; + + private static final Intent SERVICE_INTENT = new Intent(); + static { + SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); + } /** * Constructor. @@ -45,7 +54,7 @@ setContentView(R.layout.addcontact); Button ok = (Button) findViewById(R.id.addc_ok); ok.setOnClickListener(mOkListener); - bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); + mReceiver = new BeemBroadcastReceiver(); } /** @@ -56,6 +65,25 @@ super.onStop(); unbindService(mServConn); } + + /** + * {@inheritDoc} + */ + @Override + protected void onResume() { + super.onResume(); + this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED)); + bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); + } + + /** + * {@inheritDoc} + */ + @Override + protected void onPause() { + super.onPause(); + this.unregisterReceiver(mReceiver); + } /** * The ServiceConnection used to connect to the Beem service. @@ -101,7 +129,7 @@ boolean isEmail = Pattern.matches("[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+.)+[a-zA-Z]{2,4}", login); if (!isEmail) { Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedLoginError), Toast.LENGTH_SHORT) - .show(); + .show(); return; } String alias; @@ -113,13 +141,13 @@ if (mXmppFacade.getRoster().getContact(login) != null) mGroup.addAll(mXmppFacade.getRoster().getContact(login).getGroups()); if (mXmppFacade.getRoster().addContact(login, alias, - mGroup.toArray(new String[mGroup.size()])) == null) { + mGroup.toArray(new String[mGroup.size()])) == null) { Toast.makeText(AddContact.this, getString(R.string.AddCContactAddedError), Toast.LENGTH_SHORT) - .show(); + .show(); return; } else { Toast.makeText(AddContact.this, getString(R.string.AddCContactAdded), Toast.LENGTH_SHORT) - .show(); + .show(); finish(); } } @@ -130,4 +158,14 @@ } }; + + private class BeemBroadcastReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + Log.d(TAG, "broadcast received"); + stopService(SERVICE_INTENT); + startActivity(new Intent(AddContact.this, Login.class)); + finish(); + } + } } diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 src/com/beem/project/beem/ui/ChangeStatus.java --- a/src/com/beem/project/beem/ui/ChangeStatus.java Fri Sep 25 19:10:48 2009 +0200 +++ b/src/com/beem/project/beem/ui/ChangeStatus.java Fri Sep 25 17:15:14 2009 +0200 @@ -1,8 +1,11 @@ package com.beem.project.beem.ui; import android.app.Activity; +import android.content.BroadcastReceiver; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; @@ -19,6 +22,7 @@ import com.beem.project.beem.BeemService; import com.beem.project.beem.R; +import com.beem.project.beem.service.XmppConnectionAdapter; import com.beem.project.beem.service.aidl.IXmppFacade; import com.beem.project.beem.utils.Status; @@ -43,7 +47,13 @@ private ArrayAdapter mAdapter; private IXmppFacade mXmppFacade = null; private final ServiceConnection mServConn = new BeemServiceConnection(); - private final OnClickListener mOnClickOk = new MyOnClickListener(); + private final OnClickListener mOnClickOk = new MyOnClickListener(); + private BroadcastReceiver mReceiver; + + private static final Intent SERVICE_INTENT = new Intent(); + static { + SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); + } private int getPreferenceStatusIndex() { return mSettings.getInt(getString(R.string.PreferenceStatus), 0); @@ -80,6 +90,9 @@ return res; } + /** + * {@inheritDoc} + */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -97,19 +110,36 @@ mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mSpinner.setAdapter(mAdapter); mToast = Toast.makeText(this, R.string.ChangeStatusOk, Toast.LENGTH_LONG); + mReceiver = new BeemBroadcastReceiver(); showSettings(); } + /** + * {@inheritDoc} + */ @Override protected void onDestroy() { super.onDestroy(); unbindService(mServConn); } + /** + * {@inheritDoc} + */ @Override protected void onResume() { super.onResume(); bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); + this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED)); + } + + /** + * {@inheritDoc} + */ + @Override + protected void onPause() { + super.onPause(); + this.unregisterReceiver(mReceiver); } private void showSettings() { @@ -170,4 +200,12 @@ } } + private class BeemBroadcastReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + stopService(SERVICE_INTENT); + finish(); + } + } + } diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 src/com/beem/project/beem/ui/ContactList.java --- a/src/com/beem/project/beem/ui/ContactList.java Fri Sep 25 19:10:48 2009 +0200 +++ b/src/com/beem/project/beem/ui/ContactList.java Fri Sep 25 17:15:14 2009 +0200 @@ -66,6 +66,11 @@ private final ServiceConnection mServConn = new BeemServiceConnection(); private BroadcastReceiver mReceiver; + private static final Intent SERVICE_INTENT = new Intent(); + static { + SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); + } + /** * Constructor. */ @@ -73,6 +78,9 @@ } + /** + * {@inheritDoc} + */ @Override protected void onCreate(Bundle saveBundle) { super.onCreate(saveBundle); @@ -83,12 +91,18 @@ mReceiver = new BeemBroadcastReceiver(); } + /** + * {@inheritDoc} + */ @Override protected void onResume() { super.onResume(); this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED)); } + /** + * {@inheritDoc} + */ @Override protected void onPause() { super.onPause(); @@ -153,7 +167,6 @@ */ @Override protected void onStop() { - Log.e(TAG, "UNBINSERVICE"); super.onStop(); unbindService(mServConn); } @@ -500,7 +513,7 @@ break; default: imageDrawable = getResources().getDrawable(R.drawable.error); - break; + break; } imgV.setImageDrawable(imageDrawable); @@ -644,12 +657,12 @@ } private class BeemBroadcastReceiver extends BroadcastReceiver { - @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "broadcast received"); - + stopService(SERVICE_INTENT); + startActivity(new Intent(ContactList.this, Login.class)); + finish(); } - } } diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 src/com/beem/project/beem/ui/EditSettings.java --- a/src/com/beem/project/beem/ui/EditSettings.java Fri Sep 25 19:10:48 2009 +0200 +++ b/src/com/beem/project/beem/ui/EditSettings.java Fri Sep 25 17:15:14 2009 +0200 @@ -3,7 +3,11 @@ import java.util.ArrayList; import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.ComponentName; +import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.SharedPreferences; import android.os.Bundle; import android.util.Log; @@ -21,6 +25,7 @@ import android.widget.Toast; import com.beem.project.beem.R; +import com.beem.project.beem.service.XmppConnectionAdapter; /** * This class represents an activity which allows the user to change his account or proxy parameters. @@ -56,6 +61,12 @@ private EditText mProxyPortField; private EditText mProxyUsernameField; private EditText mProxyPasswordField; + private BroadcastReceiver mReceiver; + + private static final Intent SERVICE_INTENT = new Intent(); + static { + SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); + } /** * Constructor. @@ -356,6 +367,7 @@ initTabbedWindow(); initFields(); mSettings = getSharedPreferences(getString(R.string.settings_filename), MODE_PRIVATE); + mReceiver = new BeemBroadcastReceiver(); } /** @@ -380,6 +392,7 @@ startActivity(i); return true; case R.id.settings_menu_login: + setResult(69); finish(); return true; default: @@ -393,6 +406,7 @@ @Override public void onResume() { super.onResume(); + this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED)); refreshAccountTabFields(); refreshXMPPTabFields(); refreshProxyTabFields(); @@ -400,6 +414,14 @@ if (!mProxyUseCheckBox.isChecked()) disableProxyParameters(); } + /** + * {@inheritDoc} + */ + @Override + protected void onPause() { + super.onPause(); + this.unregisterReceiver(mReceiver); + } /** * {@inheritDoc} @@ -525,4 +547,12 @@ Log.i(getString(R.string.edit_settings_tag), LOG_MSG_SETTINGS_SAVED); } } + + private class BeemBroadcastReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + stopService(SERVICE_INTENT); + EditSettings.this.setResult(69); + } + } } diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 src/com/beem/project/beem/ui/Login.java --- a/src/com/beem/project/beem/ui/Login.java Fri Sep 25 19:10:48 2009 +0200 +++ b/src/com/beem/project/beem/ui/Login.java Fri Sep 25 17:15:14 2009 +0200 @@ -83,7 +83,7 @@ @Override protected void onDestroy() { super.onDestroy(); - if (mIsConfigured && (mIsConnected || mXmppFacade == null)) { + if (mIsConfigured && (mIsConnected || mXmppFacade != null)) { unbindService(mServConn); } } @@ -174,8 +174,6 @@ public void connectionClosed() throws RemoteException { mIsConnected = false; if (mXmppFacade != null) { - Login.this.unbindService(mServConn); - Login.this.stopService(SERVICE_INTENT); mXmppFacade = null; } } @@ -302,6 +300,5 @@ mIsConnected = false; mXmppFacade = null; } - } - + } } diff -r 1bc22fb59ff0 -r 172ed4d2b2c7 src/com/beem/project/beem/ui/SendIM.java --- a/src/com/beem/project/beem/ui/SendIM.java Fri Sep 25 19:10:48 2009 +0200 +++ b/src/com/beem/project/beem/ui/SendIM.java Fri Sep 25 17:15:14 2009 +0200 @@ -5,8 +5,11 @@ import org.jivesoftware.smack.util.StringUtils; import android.app.Activity; +import android.content.BroadcastReceiver; import android.content.ComponentName; +import android.content.Context; import android.content.Intent; +import android.content.IntentFilter; import android.content.ServiceConnection; import android.content.SharedPreferences; import android.graphics.drawable.Drawable; @@ -33,6 +36,7 @@ import com.beem.project.beem.service.Contact; import com.beem.project.beem.service.Message; import com.beem.project.beem.service.PresenceAdapter; +import com.beem.project.beem.service.XmppConnectionAdapter; import com.beem.project.beem.service.aidl.IBeemRosterListener; import com.beem.project.beem.service.aidl.IChat; import com.beem.project.beem.service.aidl.IChatManager; @@ -69,6 +73,12 @@ private final ServiceConnection mServConn = new BeemServiceConnection(); private IXmppFacade mXmppFacade; private TextView mStatusText; + private BroadcastReceiver mReceiver; + + private static final Intent SERVICE_INTENT = new Intent(); + static { + SERVICE_INTENT.setComponent(new ComponentName("com.beem.project.beem", "com.beem.project.beem.BeemService")); + } /** * Constructor. @@ -115,6 +125,7 @@ mScrolling = (ScrollView) findViewById(R.id.sendimscroll); mStatusText = (TextView) findViewById(R.id.sendimstatus); setViewHeader(); + mReceiver = new BeemBroadcastReceiver(); } /** @@ -211,11 +222,11 @@ // TODO start the jingle call // Bug a besoin du jid complet (resource compris) try { - mXmppFacade.call(mContact.getJID()); - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } + mXmppFacade.call(mContact.getJID()); + } catch (RemoteException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } return true; default: return false; @@ -228,6 +239,7 @@ @Override protected void onPause() { super.onPause(); + this.unregisterReceiver(mReceiver); try { if (mChat != null) mChat.setOpen(false); @@ -243,6 +255,7 @@ @Override protected void onResume() { super.onResume(); + this.registerReceiver(mReceiver, new IntentFilter(XmppConnectionAdapter.BEEM_CONNECTION_CLOSED)); bindService(new Intent(this, BeemService.class), mServConn, BIND_AUTO_CREATE); mScrolling.fullScroll(ScrollView.FOCUS_DOWN); } @@ -262,7 +275,6 @@ e.printStackTrace(); } setViewHeader(); - } /** @@ -429,10 +441,10 @@ } @Override - public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException { + public void onEntryDeleteFromGroup(String group, String jid) throws RemoteException { // TODO Auto-generated method stub - } + } @Override public void onPresenceChanged(PresenceAdapter presence) throws RemoteException { @@ -523,4 +535,13 @@ } } + private class BeemBroadcastReceiver extends BroadcastReceiver { + @Override + public void onReceive(Context context, Intent intent) { + Log.d(TAG, "broadcast received"); + stopService(SERVICE_INTENT); + startActivity(new Intent(SendIM.this, Login.class)); + finish(); + } + } }