'Refactoring, and added ISipClient.aidl'
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java b/src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java
deleted file mode 100644
index d58aa7c..0000000
--- a/src/com/savoirfairelinux/sflphone/account/AccountManagementUI.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2004-2012 Savoir-Faire Linux Inc.
- *
- * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
- *
- * This program 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.
- *
- * This program 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 this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Additional permission under GNU GPL version 3 section 7:
- *
- * If you modify this program, or any covered work, by linking or
- * combining it with the OpenSSL project's OpenSSL library (or a
- * modified version of that library), containing parts covered by the
- * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
- * grants you additional permission to convey the resulting work.
- * Corresponding Source for a non-source form of such a combination
- * shall include the source code for the parts of OpenSSL used as well
- * as that of the covered work.
- */
-package com.savoirfairelinux.sflphone.account;
-
-import java.util.ArrayList;
-
-import com.savoirfairelinux.sflphone.client.receiver.AccountListReceiver;
-
-public interface AccountManagementUI
-{
- public void setAccountList(AccountListReceiver accountList);
-
- public void accountSelectedNotifyAccountList(String accountID);
-
- public void setSelectedAccount(String accountID);
-
- public void accountAdded(ArrayList<String> newList);
-
- public void accountRemoved();
-
- public void accountUpdated();
-}
diff --git a/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java b/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java
index f0f63cc..efc6178 100644
--- a/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java
+++ b/src/com/savoirfairelinux/sflphone/account/AccountSelectionSpinner.java
@@ -45,7 +45,7 @@
import com.savoirfairelinux.sflphone.client.receiver.AccountListReceiver;
import com.savoirfairelinux.sflphone.service.ISipService;
-public class AccountSelectionSpinner extends Spinner implements AccountManagementUI {
+public class AccountSelectionSpinner extends Spinner {
private static final String TAG = AccountSelectionSpinner.class.getSimpleName();
public static final String DEFAULT_ACCOUNT_ID = "IP2IP";
private Context mContext;
@@ -82,7 +82,7 @@
((RadioButton) view.findViewById(R.id.account_checked)).toggle();
}
mAdapter.setSelectedAccount(pos);
- accountSelectedNotifyAccountList(mAdapter.getItem(pos));
+// accountSelectedNotifyAccountList(mAdapter.getItem(pos));
// setSelection(cursor.getPosition(),true);
}
@@ -107,48 +107,48 @@
* AccountManagementUI Interface
****************************************/
- @Override
- public void setAccountList(AccountListReceiver accountList) {
- Log.i(TAG, "setAccountList");
- mAccountList = accountList;
-
- }
-
- @Override
- public void accountSelectedNotifyAccountList(String accountID) {
- Log.i(TAG, "->accountSelectedNotifyAccountList");
- if (mAccountList != null) {
- mAccountList.accountSelected(accountID, this);
- }
- }
-
- @Override
- public void setSelectedAccount(String accountID) {
- Log.i(TAG, "Account Selected");
- // setText(accountID);
- }
-
- @Override
- public void accountAdded(ArrayList<String> newList) {
- mAdapter = new AccountSelectionAdapter(mContext, serviceRef, newList);
- setOnItemSelectedListener(onClick);
- setAdapter(mAdapter);
- // Log.i(TAG, "Account added");
- // mList = newList;
- //
- // if(newList.size() == 1) {
- // setText(newList.get(0));
- // }
- }
-
- @Override
- public void accountRemoved() {
- Log.i(TAG, "Account Removed");
- }
-
- @Override
- public void accountUpdated() {
- Log.i(TAG, "Account Updated");
- }
+// @Override
+// public void setAccountList(AccountListReceiver accountList) {
+// Log.i(TAG, "setAccountList");
+// mAccountList = accountList;
+//
+// }
+//
+// @Override
+// public void accountSelectedNotifyAccountList(String accountID) {
+// Log.i(TAG, "->accountSelectedNotifyAccountList");
+// if (mAccountList != null) {
+// mAccountList.accountSelected(accountID, this);
+// }
+// }
+//
+// @Override
+// public void setSelectedAccount(String accountID) {
+// Log.i(TAG, "Account Selected");
+// // setText(accountID);
+// }
+//
+// @Override
+// public void accountAdded(ArrayList<String> newList) {
+// mAdapter = new AccountSelectionAdapter(mContext, serviceRef, newList);
+// setOnItemSelectedListener(onClick);
+// setAdapter(mAdapter);
+// // Log.i(TAG, "Account added");
+// // mList = newList;
+// //
+// // if(newList.size() == 1) {
+// // setText(newList.get(0));
+// // }
+// }
+//
+// @Override
+// public void accountRemoved() {
+// Log.i(TAG, "Account Removed");
+// }
+//
+// @Override
+// public void accountUpdated() {
+// Log.i(TAG, "Account Updated");
+// }
}
diff --git a/src/com/savoirfairelinux/sflphone/adapters/CallElementAdapter.java b/src/com/savoirfairelinux/sflphone/adapters/CallElementAdapter.java
index 35b694f..dc66ecd 100644
--- a/src/com/savoirfairelinux/sflphone/adapters/CallElementAdapter.java
+++ b/src/com/savoirfairelinux/sflphone/adapters/CallElementAdapter.java
@@ -8,7 +8,7 @@
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import android.widget.ArrayAdapter;
+import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
@@ -19,14 +19,14 @@
* A CursorAdapter that creates and update call elements using corresponding contact infos. TODO: handle contact list separatly to allow showing
* synchronized contacts on Call cards with multiple contacts etc.
*/
-public class CallElementAdapter extends ArrayAdapter {
+public class CallElementAdapter extends BaseAdapter {
private ExecutorService infos_fetcher = Executors.newCachedThreadPool();
private Context mContext;
- private final List mCallList;
+ private final List<SipCall> mCallList;
private static final String CURRENT_STATE_LABEL = " CURRENT STATE: ";
- public CallElementAdapter(Context context, List callList) {
- super(context, R.layout.item_contact, callList);
+ public CallElementAdapter(Context context, List<SipCall> callList) {
+ super();
mContext = context;
mCallList = callList;
}
@@ -76,6 +76,31 @@
protected TextView phones;
public TextView state;
}
-
-
+
+ @Override
+ public int getCount() {
+ return mCallList.size();
+ }
+
+ @Override
+ public Object getItem(int pos) {
+ return mCallList.get(pos);
+ }
+
+ @Override
+ public long getItemId(int arg0) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void add(SipCall c) {
+ mCallList.add(c);
+
+ }
+
+ public void remove(SipCall c) {
+ mCallList.remove(c);
+
+ }
+
}
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
index 226a4a3..0ae022e 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLPhoneHomeActivity.java
@@ -44,487 +44,473 @@
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
+import android.os.RemoteException;
import android.support.v13.app.FragmentStatePagerAdapter;
-import android.support.v4.content.LocalBroadcastManager;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.Animation;
-import android.view.animation.LinearInterpolator;
import android.widget.EditText;
import android.widget.ImageButton;
import com.savoirfairelinux.sflphone.R;
-import com.savoirfairelinux.sflphone.client.receiver.AccountListReceiver;
import com.savoirfairelinux.sflphone.client.receiver.CallListReceiver;
-import com.savoirfairelinux.sflphone.fragments.ButtonSectionFragment;
import com.savoirfairelinux.sflphone.fragments.CallElementListFragment;
import com.savoirfairelinux.sflphone.fragments.ContactListFragment;
import com.savoirfairelinux.sflphone.fragments.HistoryFragment;
import com.savoirfairelinux.sflphone.model.SipCall;
-import com.savoirfairelinux.sflphone.service.CallManagerCallBack;
import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
+import com.savoirfairelinux.sflphone.service.ISipClient;
import com.savoirfairelinux.sflphone.service.ISipService;
import com.savoirfairelinux.sflphone.service.SipService;
-public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener, OnClickListener {
- SectionsPagerAdapter mSectionsPagerAdapter = null;
- static final String TAG = "SFLPhoneHome";
- private static final int REQUEST_CODE_PREFERENCES = 1;
- ImageButton buttonCall, buttonHangup;
- static Animation animation;
- private ContactListFragment mContactListFragment = null;
- private CallElementListFragment mCallElementList = null;
- private HistoryFragment mHistorySectionFragment = null;
- private ButtonSectionFragment mButtonSectionFragment = null;
- private boolean mBound = false;
- private ISipService service;
- public AccountListReceiver mAccountList;
- public CallListReceiver mCallList = new CallListReceiver(this);
- private SFLphoneApplication mApplication;
+public class SFLPhoneHomeActivity extends Activity implements ActionBar.TabListener {
+ SectionsPagerAdapter mSectionsPagerAdapter = null;
+ static final String TAG = "SFLPhoneHome";
+ private static final int REQUEST_CODE_PREFERENCES = 1;
+ ImageButton buttonCall, buttonHangup;
+ private ContactListFragment mContactListFragment = null;
+ private CallElementListFragment mCallElementList = null;
+ private HistoryFragment mHistorySectionFragment = null;
+ private boolean mBound = false;
+ private ISipService service;
+// public AccountListReceiver mAccountList;
+// public CallListReceiver mCallList = new CallListReceiver(this);
+ private SFLphoneApplication mApplication;
- private static final int ACTION_BAR_TAB_CONTACT = 0;
- private static final int ACTION_BAR_TAB_CALL = 1;
- private static final int ACTION_BAR_TAB_HISTORY = 2;
- private static final int ACTION_BAR_TAB_TEST = 3;
+ private static final int ACTION_BAR_TAB_CONTACT = 0;
+ private static final int ACTION_BAR_TAB_CALL = 1;
+ private static final int ACTION_BAR_TAB_HISTORY = 2;
- /**
- * The {@link ViewPager} that will host the section contents.
- */
- ViewPager mViewPager;
+ /**
+ * The {@link ViewPager} that will host the section contents.
+ */
+ ViewPager mViewPager;
- final private int[] icon_res_id = { R.drawable.ic_tab_call, R.drawable.ic_tab_call, R.drawable.ic_tab_history, R.drawable.ic_tab_play_selected };
+ final private int[] icon_res_id = { R.drawable.ic_tab_call, R.drawable.ic_tab_call, R.drawable.ic_tab_history };
- // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
+ // public SFLPhoneHome extends Activity implements ActionBar.TabListener, OnClickListener
- /* called before activity is killed, e.g. rotation */
- @Override
- protected void onSaveInstanceState(Bundle bundle) {
- super.onSaveInstanceState(bundle);
- for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
- try {
- /* putFragment (Bundle bundle, String key, Fragment fragment) */
- getFragmentManager().putFragment(bundle, mSectionsPagerAdapter.getClassName(i), mSectionsPagerAdapter.getFragment(i));
- } catch (IllegalStateException e) {
- Log.e(TAG, "IllegalStateException: fragment=" + mSectionsPagerAdapter.getFragment(i));
- }
- }
- Log.w(TAG, "onSaveInstanceState()");
- }
+ /* called before activity is killed, e.g. rotation */
+ @Override
+ protected void onSaveInstanceState(Bundle bundle) {
+ super.onSaveInstanceState(bundle);
+ for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
+ try {
+ /* putFragment (Bundle bundle, String key, Fragment fragment) */
+ getFragmentManager().putFragment(bundle, mSectionsPagerAdapter.getClassName(i), mSectionsPagerAdapter.getFragment(i));
+ } catch (IllegalStateException e) {
+ Log.e(TAG, "IllegalStateException: fragment=" + mSectionsPagerAdapter.getFragment(i));
+ }
+ }
+ Log.w(TAG, "onSaveInstanceState()");
+ }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
- mApplication = (SFLphoneApplication) getApplication();
+ mApplication = (SFLphoneApplication) getApplication();
- // Bind to LocalService
- if (!mBound) {
- Log.i(TAG, "onStart: Binding service...");
- Intent intent = new Intent(this, SipService.class);
- bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
- }
+ // Bind to LocalService
+ if (!mBound) {
+ Log.i(TAG, "onStart: Binding service...");
+ Intent intent = new Intent(this, SipService.class);
+ bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
+ }
- setContentView(R.layout.activity_sflphone_home);
+ setContentView(R.layout.activity_sflphone_home);
- if (mSectionsPagerAdapter == null) {
- mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
- }
+ if (mSectionsPagerAdapter == null) {
+ mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());
+ }
- /* getFragment(Bundle, String) */
- if (savedInstanceState != null) {
- Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
- /* getFragment (Bundle bundle, String key) */
- mContactListFragment = (ContactListFragment) getFragmentManager().getFragment(savedInstanceState,
- mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CONTACT));
- mCallElementList = (CallElementListFragment) getFragmentManager().getFragment(savedInstanceState,
- mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
- mHistorySectionFragment = (HistoryFragment) getFragmentManager().getFragment(savedInstanceState,
- mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
- mButtonSectionFragment = (ButtonSectionFragment) getFragmentManager().getFragment(savedInstanceState,
- mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_TEST));
- }
+ /* getFragment(Bundle, String) */
+ if (savedInstanceState != null) {
+ Log.w(TAG, "Activity restarted, recreating PagerAdapter...");
+ /* getFragment (Bundle bundle, String key) */
+ mContactListFragment = (ContactListFragment) getFragmentManager().getFragment(savedInstanceState,
+ mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CONTACT));
+ mCallElementList = (CallElementListFragment) getFragmentManager().getFragment(savedInstanceState,
+ mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_CALL));
+ mHistorySectionFragment = (HistoryFragment) getFragmentManager().getFragment(savedInstanceState,
+ mSectionsPagerAdapter.getClassName(ACTION_BAR_TAB_HISTORY));
+ }
- if (mContactListFragment == null) {
- mContactListFragment = new ContactListFragment();
- Log.w(TAG, "Recreated mContactListFragment=" + mContactListFragment);
- }
- if (mCallElementList == null) {
- mCallElementList = new CallElementListFragment();
- Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
- }
- if (mHistorySectionFragment == null) {
- mHistorySectionFragment = new HistoryFragment();
- Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
- }
- if (mButtonSectionFragment == null) {
- mButtonSectionFragment = new ButtonSectionFragment();
- Log.w(TAG, "Recreated mButtonSectionFragment=" + mButtonSectionFragment);
- }
+ if (mContactListFragment == null) {
+ mContactListFragment = new ContactListFragment();
+ Log.w(TAG, "Recreated mContactListFragment=" + mContactListFragment);
+ }
+ if (mCallElementList == null) {
+ mCallElementList = new CallElementListFragment();
+ Log.w(TAG, "Recreated mCallElementList=" + mCallElementList);
+ }
+ if (mHistorySectionFragment == null) {
+ mHistorySectionFragment = new HistoryFragment();
+ Log.w(TAG, "Recreated mHistorySectionFragment=" + mHistorySectionFragment);
+ }
- final ActionBar actionBar = getActionBar();
- actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
- // final ActionBar actionBar = getActionBar();
+ final ActionBar actionBar = getActionBar();
+ actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
+ // final ActionBar actionBar = getActionBar();
- // Set up the ViewPager with the sections adapter.
- mViewPager = (ViewPager) findViewById(R.id.pager);
- mViewPager.setAdapter(mSectionsPagerAdapter);
+ // Set up the ViewPager with the sections adapter.
+ mViewPager = (ViewPager) findViewById(R.id.pager);
+ mViewPager.setAdapter(mSectionsPagerAdapter);
- // When swiping between different sections, select the corresponding tab.
- // We can also use ActionBar.Tab#select() to do this if we have a reference to the
- // Tab.
- mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
- @Override
- public void onPageSelected(int position) {
- actionBar.setSelectedNavigationItem(position);
- }
- });
+ // When swiping between different sections, select the corresponding tab.
+ // We can also use ActionBar.Tab#select() to do this if we have a reference to the
+ // Tab.
+ mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
+ @Override
+ public void onPageSelected(int position) {
+ actionBar.setSelectedNavigationItem(position);
+ }
+ });
- // For each of the sections in the app, add a tab to the action bar.
- for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
- // Create a tab with text corresponding to the page title defined by the adapter.
- // Also specify this Activity object, which implements the TabListener interface, as the
- // listener for when this tab is selected.
- actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
- }
+ // For each of the sections in the app, add a tab to the action bar.
+ for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
+ // Create a tab with text corresponding to the page title defined by the adapter.
+ // Also specify this Activity object, which implements the TabListener interface, as the
+ // listener for when this tab is selected.
+ actionBar.addTab(actionBar.newTab().setIcon(icon_res_id[i]).setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
+ }
- actionBar.setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
+ actionBar.setSelectedNavigationItem(ACTION_BAR_TAB_CALL);
- buttonCall = (ImageButton) findViewById(R.id.buttonCall);
- buttonHangup = (ImageButton) findViewById(R.id.buttonHangUp);
+ buttonCall = (ImageButton) findViewById(R.id.buttonCall);
+ buttonHangup = (ImageButton) findViewById(R.id.buttonHangUp);
- // Change alpha from fully visible to invisible
- animation = new AlphaAnimation(1, 0);
- // duration - half a second
- animation.setDuration(500);
- // do not alter animation rate
- animation.setInterpolator(new LinearInterpolator());
- // Repeat animation infinitely
- animation.setRepeatCount(Animation.INFINITE);
- // Reverse
- animation.setRepeatMode(Animation.REVERSE);
+ buttonCall.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ processingNewCallAction();
+ }
+ });
+
+ buttonHangup.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ processingHangUpAction();
+
+ }
+ });
- IntentFilter callFilter = new IntentFilter(CallManagerCallBack.NEW_CALL_CREATED);
- callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
- callFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED);
- LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, callFilter);
+// IntentFilter callFilter = new IntentFilter(CallManagerCallBack.NEW_CALL_CREATED);
+// callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
+// callFilter.addAction(CallManagerCallBack.CALL_STATE_CHANGED);
+// LocalBroadcastManager.getInstance(this).registerReceiver(mCallList, callFilter);
+//
+// mAccountList = mApplication.getAccountList();
+// Log.w(TAG, "mAccountList=" + mAccountList + ", mCallElementList=" + mCallElementList);
- mAccountList = mApplication.getAccountList();
- Log.w(TAG, "mAccountList=" + mAccountList + ", mCallElementList=" + mCallElementList);
-
- IntentFilter accountFilter = new IntentFilter(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
+ IntentFilter accountFilter = new IntentFilter(ConfigurationManagerCallback.ACCOUNTS_CHANGED);
accountFilter.addAction(ConfigurationManagerCallback.ACCOUNT_STATE_CHANGED);
- LocalBroadcastManager.getInstance(this).registerReceiver(mAccountList, accountFilter);
+// LocalBroadcastManager.getInstance(this).registerReceiver(mAccountList, accountFilter);
- SipCall.setSFLPhoneHomeContext(this);
- }
+ SipCall.setSFLPhoneHomeContext(this);
+ }
- @Override
- protected void onStart() {
- Log.i(TAG, "onStart");
- super.onStart();
- }
+ @Override
+ protected void onStart() {
+ Log.i(TAG, "onStart");
+ super.onStart();
+ }
- /* user gets back to the activity, e.g. through task manager */
- @Override
- protected void onRestart() {
- super.onRestart();
- }
+ /* user gets back to the activity, e.g. through task manager */
+ @Override
+ protected void onRestart() {
+ super.onRestart();
+ }
- /* activity gets back to the foreground and user input */
- @Override
- protected void onResume() {
- Log.i(TAG, "onResume");
- super.onResume();
- }
+ /* activity gets back to the foreground and user input */
+ @Override
+ protected void onResume() {
+ Log.i(TAG, "onResume");
+ super.onResume();
+ }
- /* activity no more in foreground */
- @Override
- protected void onPause() {
- super.onPause();
- }
+ /* activity no more in foreground */
+ @Override
+ protected void onPause() {
+ super.onPause();
+ }
- /* activity is no longer visible */
- @Override
- protected void onStop() {
- super.onStop();
- }
+ /* activity is no longer visible */
+ @Override
+ protected void onStop() {
+ super.onStop();
+ }
- /* activity finishes itself or is being killed by the system */
- @Override
- protected void onDestroy() {
- /* stop the service, if no other bound user, no need to check if it is running */
- if (mBound) {
- Log.i(TAG, "onStop: Unbinding service...");
- unbindService(mConnection);
- mBound = false;
- }
+ /* activity finishes itself or is being killed by the system */
+ @Override
+ protected void onDestroy() {
+ /* stop the service, if no other bound user, no need to check if it is running */
+ if (mBound) {
+ Log.i(TAG, "onStop: Unbinding service...");
+ unbindService(mConnection);
+ mBound = false;
+ }
- /* unregister broadcast receiver */
- LocalBroadcastManager.getInstance(this).unregisterReceiver(mCallList);
- LocalBroadcastManager.getInstance(this).unregisterReceiver(mAccountList);
+ /* unregister broadcast receiver */
+// LocalBroadcastManager.getInstance(this).unregisterReceiver(mCallList);
+// LocalBroadcastManager.getInstance(this).unregisterReceiver(mAccountList);
- super.onDestroy();
- }
-
-
+ super.onDestroy();
+ }
- /** Defines callbacks for service binding, passed to bindService() */
- private ServiceConnection mConnection = new ServiceConnection() {
+ /** Defines callbacks for service binding, passed to bindService() */
+ private ServiceConnection mConnection = new ServiceConnection() {
- @Override
- public void onServiceConnected(ComponentName className, IBinder binder) {
- service = ISipService.Stub.asInterface(binder);
- mApplication.setSipService(service);
- mBound = true;
- mAccountList.setSipService(service);
- mCallElementList.onServiceSipBinded(service);
- Log.d(TAG, "Service connected service=" + service);
- }
+ private ISipClient callback = new ISipClient.Stub() {
+
+ @Override
+ public void incomingCall() throws RemoteException {
+ Log.i(TAG,"Incoming call transfered from Service");
+
+ }
+ };
- @Override
- public void onServiceDisconnected(ComponentName arg0) {
- mApplication.setSipService(null);
- mBound = false;
- Log.d(TAG, "Service disconnected service=" + service);
- }
- };
+ @Override
+ public void onServiceConnected(ComponentName className, IBinder binder) {
+ service = ISipService.Stub.asInterface(binder);
+
+ try {
+ service.registerClient(callback );
+ } catch (RemoteException e) {
+ Log.e(TAG,e.toString());
+ }
+ mApplication.setSipService(service);
+ mBound = true;
+// mAccountList.setSipService(service);
+ mCallElementList.onServiceSipBinded(service);
+ Log.d(TAG, "Service connected service=" + service);
+ }
+
+ @Override
+ public void onServiceDisconnected(ComponentName arg0) {
+ mApplication.setSipService(null);
+ mBound = false;
+ Log.d(TAG, "Service disconnected service=" + service);
+ }
+ };
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ Log.i("SFLphone", "onOptionsItemSelected " + item.getItemId());
+ if (item.getItemId() != 0) {
+ // When the button is clicked, launch an activity through this intent
+ Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class);
+
+ // Make it a subactivity so we know when it returns
+ startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
+ }
+
+ return super.onOptionsItemSelected(item);
+ }
+
+ @Override
+ public void onActivityResult(int requestCode,int resultCode,Intent data){
+ super.onActivityResult(requestCode, resultCode, data);
+ if(service != null){
+ // Refresh Spinner with accounts
+ mCallElementList.onServiceSipBinded(service);
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.activity_sflphone_home, menu);
+ return true;
+ }
+
+ @Override
+ public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ }
+
+ @Override
+ public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ // When the given tab is selected, switch to the corresponding page in the ViewPager.
+ mViewPager.setCurrentItem(tab.getPosition());
+ }
+
+ @Override
+ public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
+ // Log.d(TAG, "onTabReselected");
+ }
+
+ public void onSelectedCallAction(SipCall call) {
+ int callState = call.getCallStateInt();
+
+ if ((callState == SipCall.CALL_STATE_NONE) || (callState == SipCall.CALL_STATE_CURRENT)) {
+ buttonCall.setEnabled(false);
+ buttonHangup.setEnabled(true);
+ } else {
+ buttonCall.setEnabled(true);
+ buttonHangup.setEnabled(false);
+ }
+
+ buttonCall.setTag(call);
+ buttonHangup.setTag(call);
+ }
+
+ public void onUnselectedCallAction() {
+ buttonCall.setTag(null);
+ buttonCall.setTag(null);
+
+ buttonCall.setEnabled(true);
+ buttonHangup.setEnabled(false);
+ }
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- Log.i("SFLphone", "onOptionsItemSelected " + item.getItemId());
- if (item.getItemId() != 0) {
- // When the button is clicked, launch an activity through this intent
- Intent launchPreferencesIntent = new Intent().setClass(this, SFLPhonePreferenceActivity.class);
- // Make it a subactivity so we know when it returns
- startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES);
- }
+ public void processingNewCallAction() {
+ // String accountID = mAccountList.currentAccountID;
+ Log.w(TAG, "processingNewCallAction() mCallElementList=" + mCallElementList);
+ String accountID = mCallElementList.getSelectedAccount();
+ EditText editText = (EditText) findViewById(R.id.phoneNumberTextEntry);
+ String to = editText.getText().toString();
- return super.onOptionsItemSelected(item);
- }
+ Random random = new Random();
+ String callID = Integer.toString(random.nextInt());
+ SipCall.CallInfo info = new SipCall.CallInfo();
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.activity_sflphone_home, menu);
- return true;
- }
+ info.mCallID = callID;
+ info.mAccountID = accountID;
+ info.mDisplayName = "Cool Guy!";
+ info.mPhone = to;
+ info.mEmail = "coolGuy@coolGuy.com";
+ info.mCallType = SipCall.CALL_TYPE_OUTGOING;
- @Override
- public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
- }
+ SipCall call = CallListReceiver.getCallInstance(info);
+ call.launchCallActivity(this);
+ call.placeCallUpdateUi();
+ try {
+ service.placeCall(info.mAccountID, info.mCallID, info.mPhone);
+ } catch (RemoteException e) {
+ Log.e(TAG, "Cannot call service method", e);
+ }
- @Override
- public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
- // When the given tab is selected, switch to the corresponding page in the ViewPager.
- mViewPager.setCurrentItem(tab.getPosition());
- }
+ onSelectedCallAction(call);
+ }
- @Override
- public void onTabReselected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
- // Log.d(TAG, "onTabReselected");
- }
+ public void processingHangUpAction() {
+ SipCall call = (SipCall) buttonHangup.getTag();
+ if (call != null)
+ call.notifyServiceHangup(service);
+ }
- public void onSelectedCallAction(SipCall call) {
- int callState = call.getCallStateInt();
+ /**
+ * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to one of the primary sections of the app.
+ */
+ public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
- if ((callState == SipCall.CALL_STATE_NONE) || (callState == SipCall.CALL_STATE_CURRENT)) {
- buttonCall.setEnabled(false);
- buttonHangup.setEnabled(true);
- } else {
- buttonCall.setEnabled(true);
- buttonHangup.setEnabled(false);
- }
+ public SectionsPagerAdapter(FragmentManager fm) {
+ super(fm);
+ }
- buttonCall.setTag(call);
- buttonHangup.setTag(call);
- }
+ @Override
+ public Fragment getItem(int i) {
+ Fragment fragment;
- public void onUnselectedCallAction() {
- buttonCall.setTag(null);
- buttonCall.setTag(null);
+ switch (i) {
+ case 0:
+ mContactListFragment = new ContactListFragment();
+ fragment = mContactListFragment;
+ Log.w(TAG, "getItem() ContactListFragment=" + fragment);
+ break;
+ case 1:
+ mCallElementList = new CallElementListFragment();
+ SipCall.setCallElementList(mCallElementList);
+// mCallElementList.setAccountList(mAccountList);
+ fragment = mCallElementList;
+ Log.w(TAG, "getItem() CallElementList=" + fragment);
+ break;
+ case 2:
+ fragment = new HistoryFragment();
+ Log.w(TAG, "getItem() HistoryFragment=" + fragment);
+ break;
+ default:
+ Log.e(TAG, "getItem() unknown tab position " + i);
+ return null;
+ }
- buttonCall.setEnabled(true);
- buttonHangup.setEnabled(false);
- }
+ // Log.i(TAG, "getItem() fragment is " + fragment);
+ Bundle args = new Bundle();
+ args.putInt(HistoryFragment.ARG_SECTION_NUMBER, i + 1);
+ fragment.setArguments(args);
+ return fragment;
+ }
- public void setIncomingCallID(String accountID, String callID, String from) {
- Log.i(TAG, "incomingCall(" + accountID + ", " + callID + ", " + from + ")");
- buttonCall.startAnimation(animation);
- buttonCall.setImageResource(R.drawable.ic_incomingcall);
- }
+ public Fragment getFragment(int i) {
+ Fragment fragment;
- /**
- * A {@link FragmentStatePagerAdapter} that returns a fragment corresponding to one of the primary sections of the app.
- */
- public class SectionsPagerAdapter extends FragmentStatePagerAdapter {
+ switch (i) {
+ case 0:
+ fragment = mContactListFragment;
+ break;
+ case 1:
+ fragment = mCallElementList;
+ break;
+ case 2:
+ fragment = mHistorySectionFragment;
+ break;
+ default:
+ Log.e(TAG, "getClassName: unknown fragment position " + i);
+ fragment = null;
+ }
- public SectionsPagerAdapter(FragmentManager fm) {
- super(fm);
- }
+ // Log.w(TAG, "getFragment: fragment=" + fragment);
+ return fragment;
+ }
- @Override
- public Fragment getItem(int i) {
- Fragment fragment;
+ public String getClassName(int i) {
+ String name;
- switch (i) {
- case 0:
- mContactListFragment = new ContactListFragment();
- fragment = mContactListFragment;
- Log.w(TAG, "getItem() ContactListFragment=" + fragment);
- break;
- case 1:
- mCallElementList = new CallElementListFragment();
- SipCall.setCallElementList(mCallElementList);
- mCallElementList.setAccountList(mAccountList);
- fragment = mCallElementList;
- Log.w(TAG, "getItem() CallElementList=" + fragment);
- break;
- case 2:
- fragment = new HistoryFragment();
- Log.w(TAG, "getItem() HistoryFragment=" + fragment);
- break;
- case 3:
- fragment = new ButtonSectionFragment();
- Log.w(TAG, "getItem() ButtonSectionFragment=" + fragment);
- break;
- default:
- Log.e(TAG, "getItem() unknown tab position " + i);
- return null;
- }
+ switch (i) {
+ case 0:
+ name = ContactListFragment.class.getName();
+ break;
+ case 1:
+ name = CallElementListFragment.class.getName();
+ break;
+ case 2:
+ name = HistoryFragment.class.getName();
+ break;
- // Log.i(TAG, "getItem() fragment is " + fragment);
- Bundle args = new Bundle();
- args.putInt(HistoryFragment.ARG_SECTION_NUMBER, i + 1);
- fragment.setArguments(args);
- return fragment;
- }
+ default:
+ Log.e(TAG, "getClassName: unknown fragment position " + i);
+ return null;
+ }
- public Fragment getFragment(int i) {
- Fragment fragment;
+ // Log.w(TAG, "getClassName: name=" + name);
+ return name;
+ }
- switch (i) {
- case 0:
- fragment = mContactListFragment;
- break;
- case 1:
- fragment = mCallElementList;
- break;
- case 2:
- fragment = mHistorySectionFragment;
- break;
- case 3:
- fragment = mButtonSectionFragment;
- break;
- default:
- Log.e(TAG, "getClassName: unknown fragment position " + i);
- fragment = null;
- }
+ @Override
+ public int getCount() {
+ return 3;
+ }
- // Log.w(TAG, "getFragment: fragment=" + fragment);
- return fragment;
- }
+ @Override
+ public CharSequence getPageTitle(int position) {
+ switch (position) {
+ case 0:
+ return getString(R.string.title_section0).toUpperCase();
+ case 1:
+ return getString(R.string.title_section1).toUpperCase();
+ case 2:
+ return getString(R.string.title_section2).toUpperCase();
+ case 3:
+ return getString(R.string.title_section3).toUpperCase();
+ default:
+ Log.e(TAG, "getPageTitle: unknown tab position " + position);
+ break;
+ }
+ return null;
+ }
+ }
- public String getClassName(int i) {
- String name;
-
- switch (i) {
- case 0:
- name = ContactListFragment.class.getName();
- break;
- case 1:
- name = CallElementListFragment.class.getName();
- break;
- case 2:
- name = HistoryFragment.class.getName();
- break;
- case 3:
- name = ButtonSectionFragment.class.getName();
- break;
- default:
- Log.e(TAG, "getClassName: unknown fragment position " + i);
- return null;
- }
-
- // Log.w(TAG, "getClassName: name=" + name);
- return name;
- }
-
- @Override
- public int getCount() {
- return 4;
- }
-
- @Override
- public CharSequence getPageTitle(int position) {
- switch (position) {
- case 0:
- return getString(R.string.title_section0).toUpperCase();
- case 1:
- return getString(R.string.title_section1).toUpperCase();
- case 2:
- return getString(R.string.title_section2).toUpperCase();
- case 3:
- return getString(R.string.title_section3).toUpperCase();
- default:
- Log.e(TAG, "getPageTitle: unknown tab position " + position);
- break;
- }
- return null;
- }
- }
-
-
- @Override
- public void onClick(View view) {
- Log.i(TAG, "onClic from SFLPhoneHome");
- switch (view.getId()) {
- case R.id.buttonCall:
- processingNewCallAction();
- break;
- case R.id.buttonHangUp:
- processingHangUpAction();
- break;
- default:
- Log.w(TAG, "unknown button " + view.getId());
- break;
- }
- }
-
- public void processingNewCallAction() {
- // String accountID = mAccountList.currentAccountID;
- Log.w(TAG, "processingNewCallAction() mCallElementList=" + mCallElementList);
- String accountID = mCallElementList.getSelectedAccount();
- EditText editText = (EditText) findViewById(R.id.phoneNumberTextEntry);
- String to = editText.getText().toString();
-
- Random random = new Random();
- String callID = Integer.toString(random.nextInt());
- SipCall.CallInfo info = new SipCall.CallInfo();
-
- info.mCallID = callID;
- info.mAccountID = accountID;
- info.mDisplayName = "Cool Guy!";
- info.mPhone = to;
- info.mEmail = "coolGuy@coolGuy.com";
- info.mCallType = SipCall.CALL_TYPE_OUTGOING;
-
- SipCall call = CallListReceiver.getCallInstance(info);
- call.launchCallActivity(this);
- call.placeCallUpdateUi();
- call.notifyServicePlaceCall(service);
-
- onSelectedCallAction(call);
- }
-
- public void processingHangUpAction() {
- SipCall call = (SipCall) buttonHangup.getTag();
- if (call != null)
- call.notifyServiceHangup(service);
- }
}
diff --git a/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java b/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
index 4fc4427..1a33306 100644
--- a/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
+++ b/src/com/savoirfairelinux/sflphone/client/SFLphoneApplication.java
@@ -17,7 +17,6 @@
static final String TAG = "SFLphoneApplication";
private boolean serviceRunning = false;
private ISipService sipService;
- private AccountListReceiver accountList = new AccountListReceiver();
private void startSipService() {
Thread thread = new Thread("StartSFLphoneService") {
@@ -79,10 +78,6 @@
sipService = service;
}
- public AccountListReceiver getAccountList() {
- return accountList;
- }
-
public String getAppPath() {
PackageManager pkgMng = getPackageManager();
String pkgName = getPackageName();
diff --git a/src/com/savoirfairelinux/sflphone/client/receiver/AccountListReceiver.java b/src/com/savoirfairelinux/sflphone/client/receiver/AccountListReceiver.java
index efd6c5b..fa17868 100644
--- a/src/com/savoirfairelinux/sflphone/client/receiver/AccountListReceiver.java
+++ b/src/com/savoirfairelinux/sflphone/client/receiver/AccountListReceiver.java
@@ -31,15 +31,14 @@
package com.savoirfairelinux.sflphone.client.receiver;
+import java.util.ArrayList;
+
import android.content.BroadcastReceiver;
-import android.content.Intent;
import android.content.Context;
+import android.content.Intent;
import android.os.RemoteException;
import android.util.Log;
-import java.util.ArrayList;
-
-import com.savoirfairelinux.sflphone.account.AccountManagementUI;
import com.savoirfairelinux.sflphone.service.ConfigurationManagerCallback;
import com.savoirfairelinux.sflphone.service.ISipService;
@@ -49,7 +48,7 @@
static final String TAG = "AccountList";
private String currentAccountID = "";
private ArrayList<String> mList = new ArrayList<String>();
- private ArrayList<AccountManagementUI> mUserInterfaceList = new ArrayList<AccountManagementUI>();
+// private ArrayList<AccountManagementUI> mUserInterfaceList = new ArrayList<AccountManagementUI>();
private static ISipService mService = null;
// private HashMap<String, AccountPreferenceScreen> mAccountList = new HashMap<String, AccountPreferenceScreen>();
@@ -64,17 +63,17 @@
}
- public void addManagementUI(AccountManagementUI ui) {
- mUserInterfaceList.add(ui);
- }
-
- public void accountSelected(String accountID, AccountManagementUI userInterface) {
- if(!mUserInterfaceList.isEmpty()) {
- for(AccountManagementUI ui : mUserInterfaceList) {
- ui.setSelectedAccount(accountID);
- }
- }
- }
+// public void addManagementUI(AccountManagementUI ui) {
+// mUserInterfaceList.add(ui);
+// }
+//
+// public void accountSelected(String accountID, AccountManagementUI userInterface) {
+// if(!mUserInterfaceList.isEmpty()) {
+// for(AccountManagementUI ui : mUserInterfaceList) {
+// ui.setSelectedAccount(accountID);
+// }
+// }
+// }
@Override
public void onReceive(Context context, Intent intent)
@@ -112,20 +111,20 @@
newList.remove(DEFAULT_ACCOUNT_ID);
- if(!mUserInterfaceList.isEmpty()) {
-
- if(newList.size() > mList.size()) {
- for(AccountManagementUI ui : mUserInterfaceList) {
- ui.accountAdded(newList);
- }
- }
- }
+// if(!mUserInterfaceList.isEmpty()) {
+//
+// if(newList.size() > mList.size()) {
+// for(AccountManagementUI ui : mUserInterfaceList) {
+// ui.accountAdded(newList);
+// }
+// }
+// }
mList = newList;
}
private void processAccountStateChanged(Intent intent) {
- if(!mUserInterfaceList.isEmpty()) {
- }
+// if(!mUserInterfaceList.isEmpty()) {
+// }
}
}
diff --git a/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java b/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
index fb9f83b..9ed7c72 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/CallElementListFragment.java
@@ -99,7 +99,6 @@
super.onAttach(activity);
sflphoneHome = (SFLPhoneHomeActivity) activity;
service = ((SFLphoneApplication) sflphoneHome.getApplication()).getSipService();
- mAccountList = ((SFLphoneApplication) sflphoneHome.getApplication()).getAccountList();
Log.w(TAG, "onAttach() service=" + service + ", accountList=" + mAccountList);
}
@@ -197,7 +196,7 @@
setHasOptionsMenu(true);
// Create an empty adapter we will use to display the loaded data.
- ArrayList calls = new ArrayList();
+ ArrayList<SipCall> calls = new ArrayList<SipCall>();
mAdapter = new CallElementAdapter(getActivity(), calls);
setListAdapter(mAdapter);
@@ -256,8 +255,8 @@
View inflatedView = inflater.inflate(R.layout.frag_call_element, container, false);
mAccountSelectionSpinner = (AccountSelectionSpinner) inflatedView.findViewById(R.id.account_selection_button);
- mAccountList.addManagementUI(mAccountSelectionSpinner);
- mAccountSelectionSpinner.setAccountList(mAccountList);
+// mAccountList.addManagementUI(mAccountSelectionSpinner);
+// mAccountSelectionSpinner.setAccountList(mAccountList);
isReady = true;
if (service != null) {
@@ -272,7 +271,6 @@
Log.i(TAG, "Call Clicked: " + call.getCallId());
call.launchCallActivity(getActivity());
-
sflphoneHome.onSelectedCallAction(call);
}
@@ -331,6 +329,7 @@
*/
public void onServiceSipBinded(ISipService isip) {
+
if (isReady) {
service = isip;
ArrayList<String> accountList;
diff --git a/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java b/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
index 2cdca05..888af04 100644
--- a/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
+++ b/src/com/savoirfairelinux/sflphone/fragments/ContactListFragment.java
@@ -91,7 +91,6 @@
private SFLPhoneHomeActivity sflphoneHome;
private SFLphoneApplication sflphoneApplication;
private ISipService service;
- private AccountListReceiver mAccountList;
// These are the Contacts rows that we will retrieve.
static final String[] CONTACTS_SUMMARY_PROJECTION = new String[] { Contacts._ID, Contacts.DISPLAY_NAME, Contacts.PHOTO_ID, Contacts.LOOKUP_KEY };
@@ -104,9 +103,6 @@
sflphoneHome = (SFLPhoneHomeActivity) activity;
sflphoneApplication = (SFLphoneApplication) sflphoneHome.getApplication();
service = sflphoneApplication.getSipService();
- mAccountList = sflphoneApplication.getAccountList();
-
- Log.w(TAG, "onAttach() service=" + service + ", mAccountList=" + mAccountList);
}
public static class InfosLoader implements Runnable {
diff --git a/src/com/savoirfairelinux/sflphone/model/SipCall.java b/src/com/savoirfairelinux/sflphone/model/SipCall.java
index 679d2df..ad3f49c 100644
--- a/src/com/savoirfairelinux/sflphone/model/SipCall.java
+++ b/src/com/savoirfairelinux/sflphone/model/SipCall.java
@@ -292,14 +292,6 @@
mHome.onSelectedCallAction(this);
}
- public void notifyServicePlaceCall(ISipService service)
- {
- try {
- service.placeCall(mCallInfo.mAccountID, mCallInfo.mCallID, mCallInfo.mPhone);
- } catch (RemoteException e) {
- Log.e(TAG, "Cannot call service method", e);
- }
- }
public void receiveCallUpdateUi()
{
@@ -449,4 +441,16 @@
intent.putExtras(bundle);
context.startActivity(intent);
}
+
+ /**
+ * Compare sip calls based on call ID
+ */
+ @Override
+ public boolean equals(Object c){
+ if(c instanceof SipCall && ((SipCall) c).mCallInfo.mCallID == mCallInfo.mCallID){
+ return true;
+ }
+ return false;
+
+ }
}
diff --git a/src/com/savoirfairelinux/sflphone/service/ISipClient.aidl b/src/com/savoirfairelinux/sflphone/service/ISipClient.aidl
new file mode 100644
index 0000000..2da24cc
--- /dev/null
+++ b/src/com/savoirfairelinux/sflphone/service/ISipClient.aidl
@@ -0,0 +1,5 @@
+package com.savoirfairelinux.sflphone.service;
+
+interface ISipClient {
+ void incomingCall();
+}
\ No newline at end of file
diff --git a/src/com/savoirfairelinux/sflphone/service/ISipService.aidl b/src/com/savoirfairelinux/sflphone/service/ISipService.aidl
index 1bcf4b5..cb7bf46 100644
--- a/src/com/savoirfairelinux/sflphone/service/ISipService.aidl
+++ b/src/com/savoirfairelinux/sflphone/service/ISipService.aidl
@@ -1,5 +1,7 @@
package com.savoirfairelinux.sflphone.service;
+import com.savoirfairelinux.sflphone.service.ISipClient;
+
interface ISipService {
void placeCall(String accountID, in String callID, in String to);
void refuse(in String callID);
@@ -14,4 +16,5 @@
void setAccountDetails(in String accountId, in Map accountDetails);
void setAudioPlugin(in String callID);
String getCurrentAudioOutputPlugin();
+ void registerClient(in ISipClient callback);
}
diff --git a/src/com/savoirfairelinux/sflphone/service/SipService.java b/src/com/savoirfairelinux/sflphone/service/SipService.java
index ec1f0b6..e84562d 100644
--- a/src/com/savoirfairelinux/sflphone/service/SipService.java
+++ b/src/com/savoirfairelinux/sflphone/service/SipService.java
@@ -39,14 +39,13 @@
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
-import android.os.Vibrator;
+import android.os.RemoteException;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.widget.Toast;
import com.savoirfairelinux.sflphone.account.AccountDetailsHandler;
import com.savoirfairelinux.sflphone.client.SFLphoneApplication;
-import com.savoirfairelinux.sflphone.client.receiver.CallListReceiver;
public class SipService extends Service {
@@ -63,7 +62,7 @@
private ConfigurationManagerCallback configurationManagerCallback;
private ManagerImpl managerImpl;
private boolean isPjSipStackStarted = false;
- public CallListReceiver mCallList;
+ ISipClient client;
/* Implement public interface for the service */
@@ -253,6 +252,11 @@
}
});
}
+
+ @Override
+ public void registerClient(ISipClient callback) throws RemoteException {
+ client = callback;
+ }
};
private BroadcastReceiver IncomingReceiver = new BroadcastReceiver() {
@@ -260,8 +264,15 @@
public void onReceive(Context context, Intent intent) {
Log.i(TAG, "Received"+ intent.getAction());
// Get instance of Vibrator from current Context
- Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
- mVibrator.vibrate(300);
+// Vibrator mVibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
+// mVibrator.vibrate(300);
+ if(intent.getAction().contentEquals(CallManagerCallBack.INCOMING_CALL)){
+ try {
+ client.incomingCall();
+ } catch (RemoteException e) {
+ Log.e(TAG,e.toString());
+ }
+ }
}
};
@@ -283,9 +294,8 @@
super.onCreate();
sflphoneApp = (SFLphoneApplication) getApplication();
sipServiceThread = new SipServiceThread();
- mCallList = new CallListReceiver();
- IntentFilter callFilter = new IntentFilter(CallManagerCallBack.NEW_CALL_CREATED);
+ IntentFilter callFilter = new IntentFilter();
callFilter.addAction(CallManagerCallBack.INCOMING_CALL);
LocalBroadcastManager.getInstance(this).registerReceiver(IncomingReceiver , callFilter);
getExecutor().execute(new StartRunnable());