diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 08131987c..b8c492420 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -4,7 +4,7 @@
android:versionCode="1"
android:versionName="1.0">
-
@@ -27,6 +27,13 @@
+
+
+
+
+
+
+
diff --git a/res/drawable/in_call.png b/res/drawable/in_call.png
new file mode 100644
index 000000000..d48369e6a
Binary files /dev/null and b/res/drawable/in_call.png differ
diff --git a/res/drawable/out_call.png b/res/drawable/out_call.png
new file mode 100644
index 000000000..7fef2b4ae
Binary files /dev/null and b/res/drawable/out_call.png differ
diff --git a/res/layout-land/dialer.xml b/res/layout-land/dialer.xml
new file mode 100644
index 000000000..c820fd542
--- /dev/null
+++ b/res/layout-land/dialer.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/layout/dialer.xml b/res/layout/dialer.xml
index 7d4023aa5..b2af87cec 100644
--- a/res/layout/dialer.xml
+++ b/res/layout/dialer.xml
@@ -1,39 +1,89 @@
+ android:orientation="vertical" android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
+
+
+
-
+
+
-
+
diff --git a/res/layout/history_cell.xml b/res/layout/history_cell.xml
new file mode 100644
index 000000000..8e2240b0d
--- /dev/null
+++ b/res/layout/history_cell.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/res/layout/main.xml b/res/layout/main.xml
index 1d0e21b7d..17d3f10a9 100644
--- a/res/layout/main.xml
+++ b/res/layout/main.xml
@@ -7,7 +7,7 @@
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
- android:padding="5dp">
+ >
+ android:layout_height="fill_parent"/>
+
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index a5a776896..f5abae018 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -21,4 +21,5 @@
No
%s, do you want to return to the settings page ?
Cannot initiate a new call because a call is already engaged
+History
diff --git a/src/org/linphone/ContactPickerActivity.java b/src/org/linphone/ContactPickerActivity.java
index a20342c84..397c8486d 100644
--- a/src/org/linphone/ContactPickerActivity.java
+++ b/src/org/linphone/ContactPickerActivity.java
@@ -1,3 +1,21 @@
+/*
+ContactPickerActivity.java
+Copyright (C) 2010 Belledonne Communications, Grenoble, France
+
+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 2
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
package org.linphone;
import android.app.Activity;
@@ -51,7 +69,7 @@ public class ContactPickerActivity extends Activity {
}
}
- Linphone.getLinphone().getTabHost().setCurrentTabByTag(Linphone.DIALER_TAB);
+ LinphoneActivity.instance().getTabHost().setCurrentTabByTag(LinphoneActivity.DIALER_TAB);
}
}
}
diff --git a/src/org/linphone/DialerActivity.java b/src/org/linphone/DialerActivity.java
index 9acbed01b..26371a4a6 100644
--- a/src/org/linphone/DialerActivity.java
+++ b/src/org/linphone/DialerActivity.java
@@ -1,3 +1,21 @@
+/*
+DialerActivity.java
+Copyright (C) 2010 Belledonne Communications, Grenoble, France
+
+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 2
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
package org.linphone;
import org.linphone.core.LinphoneAddress;
@@ -9,6 +27,7 @@ import org.linphone.core.LinphoneCore.GeneralState;
import android.app.Activity;
import android.content.Context;
+import android.content.res.Configuration;
import android.media.AudioManager;
import android.os.Bundle;
import android.util.Log;
@@ -20,7 +39,7 @@ import android.widget.TextView;
import android.widget.Toast;
public class DialerActivity extends Activity implements LinphoneCoreListener {
- private LinphoneCore mLinphoneCore;
+
private TextView mAddress;
private TextView mStatus;
private ImageButton mCall;
@@ -62,18 +81,19 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
setContentView(R.layout.dialer);
mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
try {
- theDialer = this;
- mLinphoneCore = Linphone.getLinphone().getLinphoneCore();
+
+
mAddress = (TextView) findViewById(R.id.SipUri);
mCall = (ImageButton) findViewById(R.id.Call);
mCall.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
- if (mLinphoneCore.isInComingInvitePending()) {
- mLinphoneCore.acceptCall();
+ LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
+ if (lLinphoneCore.isInComingInvitePending()) {
+ lLinphoneCore.acceptCall();
return;
}
- if (mLinphoneCore.isIncall()) {
+ if (lLinphoneCore.isIncall()) {
Toast toast = Toast.makeText(DialerActivity.this, getString(R.string.warning_already_incall), Toast.LENGTH_LONG);
toast.show();
return;
@@ -83,7 +103,7 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
if (lRawAddress.startsWith("sip:")) {
lCallingUri=lRawAddress;
} else {
- LinphoneProxyConfig lProxy = mLinphoneCore.getDefaultProxyConfig();
+ LinphoneProxyConfig lProxy = lLinphoneCore.getDefaultProxyConfig();
String lDomain=null;
String lNormalizedNumber=lRawAddress;
if (lProxy!=null) {
@@ -95,15 +115,17 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
, mDisplayName);
lCallingUri = lAddress.toUri();
}
- mLinphoneCore.invite(lCallingUri);
+ lLinphoneCore.invite(lCallingUri);
}
});
mHangup = (ImageButton) findViewById(R.id.HangUp);
mHangup.setEnabled(false);
mHangup.setOnClickListener(new OnClickListener() {
+
public void onClick(View v) {
- mLinphoneCore.terminateCall();
+ LinphoneCore lLinphoneCore = LinphoneService.instance().getLinphoneCore();
+ lLinphoneCore.terminateCall();
}
});
@@ -116,40 +138,44 @@ public class DialerActivity extends Activity implements LinphoneCoreListener {
mAddressView = anAddress;
}
public void onClick(View v) {
- mAddressView.append(mKeyCode);
+ mAddressView.append(mKeyCode);
}
};
+
mZero = (Button) findViewById(R.id.Button00) ;
- mZero.setOnClickListener(new DialKeyListener(mAddress,'0'));
- mOne = (Button) findViewById(R.id.Button01) ;
- mOne.setOnClickListener(new DialKeyListener(mAddress,'1'));
- mTwo = (Button) findViewById(R.id.Button02);
- mTwo.setOnClickListener(new DialKeyListener(mAddress,'2'));
- mThree = (Button) findViewById(R.id.Button03);
- mThree.setOnClickListener(new DialKeyListener(mAddress,'3'));
- mFour = (Button) findViewById(R.id.Button04);
- mFour.setOnClickListener(new DialKeyListener(mAddress,'4'));
- mFive = (Button) findViewById(R.id.Button05);
- mFive.setOnClickListener(new DialKeyListener(mAddress,'5'));
- mSix = (Button) findViewById(R.id.Button06);
- mSix.setOnClickListener(new DialKeyListener(mAddress,'6'));
- mSeven = (Button) findViewById(R.id.Button07);
- mSeven.setOnClickListener(new DialKeyListener(mAddress,'7'));
- mEight = (Button) findViewById(R.id.Button08);
- mEight.setOnClickListener(new DialKeyListener(mAddress,'8'));
- mNine = (Button) findViewById(R.id.Button09);
- mNine.setOnClickListener(new DialKeyListener(mAddress,'9'));
- mStar = (Button) findViewById(R.id.ButtonStar);
- mStar.setOnClickListener(new DialKeyListener(mAddress,'*'));
- mHash = (Button) findViewById(R.id.ButtonHash);
- mHash.setOnClickListener(new DialKeyListener(mAddress,'#'));
-
+ if (mZero != null) {
+
+ mZero.setOnClickListener(new DialKeyListener(mAddress,'0'));
+ mOne = (Button) findViewById(R.id.Button01) ;
+ mOne.setOnClickListener(new DialKeyListener(mAddress,'1'));
+ mTwo = (Button) findViewById(R.id.Button02);
+ mTwo.setOnClickListener(new DialKeyListener(mAddress,'2'));
+ mThree = (Button) findViewById(R.id.Button03);
+ mThree.setOnClickListener(new DialKeyListener(mAddress,'3'));
+ mFour = (Button) findViewById(R.id.Button04);
+ mFour.setOnClickListener(new DialKeyListener(mAddress,'4'));
+ mFive = (Button) findViewById(R.id.Button05);
+ mFive.setOnClickListener(new DialKeyListener(mAddress,'5'));
+ mSix = (Button) findViewById(R.id.Button06);
+ mSix.setOnClickListener(new DialKeyListener(mAddress,'6'));
+ mSeven = (Button) findViewById(R.id.Button07);
+ mSeven.setOnClickListener(new DialKeyListener(mAddress,'7'));
+ mEight = (Button) findViewById(R.id.Button08);
+ mEight.setOnClickListener(new DialKeyListener(mAddress,'8'));
+ mNine = (Button) findViewById(R.id.Button09);
+ mNine.setOnClickListener(new DialKeyListener(mAddress,'9'));
+ mStar = (Button) findViewById(R.id.ButtonStar);
+ mStar.setOnClickListener(new DialKeyListener(mAddress,'*'));
+ mHash = (Button) findViewById(R.id.ButtonHash);
+ mHash.setOnClickListener(new DialKeyListener(mAddress,'#'));
+ }
mStatus = (TextView) findViewById(R.id.status_label);
+ theDialer = this;
} catch (Exception e) {
- Log.e(Linphone.TAG,"Cannot start linphone",e);
+ Log.e(LinphoneService.TAG,"Cannot start linphone",e);
}
}
diff --git a/src/org/linphone/HistoryActivity.java b/src/org/linphone/HistoryActivity.java
new file mode 100644
index 000000000..f4858343c
--- /dev/null
+++ b/src/org/linphone/HistoryActivity.java
@@ -0,0 +1,106 @@
+/*
+DialerActivity.java
+Copyright (C) 2010 Belledonne Communications, Grenoble, France
+
+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 2
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+package org.linphone;
+
+
+
+import java.util.List;
+
+import org.linphone.core.LinphoneAddress;
+import org.linphone.core.LinphoneCallLog;
+import org.linphone.core.LinphoneCallLog.CallDirection;
+
+import android.app.ListActivity;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+public class HistoryActivity extends ListActivity {
+ LayoutInflater mInflater;
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ mInflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ }
+
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ setListAdapter(new CallHistoryAdapter(this));
+ }
+
+
+ class CallHistoryAdapter extends BaseAdapter {
+ private final Context mContext;
+ final List mLogs;
+ CallHistoryAdapter(Context aContext) {
+ mContext = aContext;
+ mLogs = LinphoneService.instance().getLinphoneCore().getCallLogs();
+ }
+ public int getCount() {
+ return mLogs.size();
+ }
+
+ public Object getItem(int position) {
+ return position;
+ }
+
+ public long getItemId(int position) {
+
+ return position;
+ }
+
+ public View getView(int position, View convertView, ViewGroup parent) {
+ LinphoneCallLog lLog = mLogs.get(position);
+ View lView=null;
+ LinphoneAddress lAddress;
+ lView = mInflater.inflate(R.layout.history_cell, null);
+ TextView lFirstLineView = (TextView) lView.findViewById(R.id.history_cell_first_line);
+ TextView lSecondLineView = (TextView) lView.findViewById(R.id.history_cell_second_line);
+ ImageView lDirectionImage = (ImageView) lView.findViewById(R.id.history_cell_icon);
+
+ if (lLog.getDirection() == CallDirection.Callincoming) {
+ lAddress = lLog.getFrom();
+ lDirectionImage.setImageResource(R.drawable.in_call);
+
+ } else {
+ lAddress = lLog.getTo();
+ lDirectionImage.setImageResource(R.drawable.out_call);
+ }
+
+ if (lAddress.getDisplayName() == null) {
+ lFirstLineView.setText(lAddress.getUserName());
+ lSecondLineView.setVisibility(View.GONE);
+ } else {
+ lFirstLineView.setText(lAddress.getDisplayName());
+ lSecondLineView.setText(lAddress.getUserName());
+ }
+
+ return lView;
+
+ }
+
+ }
+}
diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java
new file mode 100644
index 000000000..f5c49ca6b
--- /dev/null
+++ b/src/org/linphone/LinphoneActivity.java
@@ -0,0 +1,166 @@
+/*
+LinphoneActivity.java
+Copyright (C) 2010 Belledonne Communications, Grenoble, France
+
+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 2
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+package org.linphone;
+
+
+import android.app.AlertDialog;
+import android.app.TabActivity;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.media.AudioManager;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.Menu;
+import android.view.MenuInflater;
+import android.view.MenuItem;
+import android.widget.TabHost;
+
+public class LinphoneActivity extends TabActivity {
+ public static String DIALER_TAB = "dialer";
+ private AudioManager mAudioManager;
+ private static LinphoneActivity theLinphoneActivity;
+
+ protected static LinphoneActivity instance()
+ {
+ if (theLinphoneActivity == null) {
+ throw new RuntimeException("LinphoneActivity not instanciated yet");
+ } else {
+ return theLinphoneActivity;
+ }
+ }
+
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+ theLinphoneActivity = this;
+
+
+ mAudioManager = ((AudioManager)getSystemService(Context.AUDIO_SERVICE));
+
+ TabHost lTabHost = getTabHost(); // The activity TabHost
+ TabHost.TabSpec spec; // Reusable TabSpec for each tab
+
+
+ //Call History
+ Intent lHistoryItent = new Intent().setClass(this, HistoryActivity.class);
+
+ spec = lTabHost.newTabSpec("history").setIndicator(getString(R.string.tab_history),
+ null)
+ .setContent(lHistoryItent);
+ lTabHost.addTab(spec);
+
+ // dialer
+ Intent lDialerIntent = new Intent().setClass(this, DialerActivity.class);
+
+ // Initialize a TabSpec for each tab and add it to the TabHost
+ spec = lTabHost.newTabSpec("dialer").setIndicator(getString(R.string.tab_dialer),
+ getResources().getDrawable(android.R.drawable.ic_menu_call))
+ .setContent(lDialerIntent);
+ lTabHost.addTab(spec);
+
+ // contact pick
+ Intent lContactItent = new Intent().setClass(this, ContactPickerActivity.class);
+
+ spec = lTabHost.newTabSpec("contact").setIndicator(getString(R.string.tab_contact),
+ null)
+ .setContent(lContactItent);
+ lTabHost.addTab(spec);
+
+ lTabHost.setCurrentTabByTag("dialer");
+ // start linphone as background
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setClass(this, LinphoneService.class);
+ startService(intent);
+
+ }
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ if (isFinishing()) {
+ //restaure audio settings
+ mAudioManager.setSpeakerphoneOn(true);
+ mAudioManager.setMode(AudioManager.MODE_NORMAL);
+ mAudioManager.setRouting(AudioManager.MODE_NORMAL,
+ AudioManager.ROUTE_SPEAKER, AudioManager.ROUTE_ALL);
+
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setClass(this, LinphoneService.class);
+ stopService(intent);
+ }
+ theLinphoneActivity = null;
+ }
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the currently selected menu XML resource.
+ MenuInflater inflater = getMenuInflater();
+ inflater.inflate(R.menu.linphone_activity_menu, menu);
+
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case R.id.menu_settings:
+ startprefActivity();
+ return true;
+ case R.id.menu_exit:
+ finish();
+ break;
+ default:
+ Log.e(LinphoneService.TAG, "Unknown menu item ["+item+"]");
+ break;
+ }
+
+ return false;
+ }
+ private void startprefActivity() {
+ Intent intent = new Intent(Intent.ACTION_MAIN);
+ intent.setClass(this, LinphonePreferencesActivity.class);
+ startActivity(intent);
+ }
+ public void initFromConf() throws LinphoneException {
+
+ try {
+ LinphoneService.instance().initFromConf();
+ } catch (LinphoneConfigException e) {
+ handleBadConfig(e.getMessage());
+ }
+
+ }
+ private void handleBadConfig(String message) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setMessage(String.format(getString(R.string.config_error),message))
+ .setCancelable(false)
+ .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ startprefActivity();
+ }
+ })
+ .setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ dialog.cancel();
+ }
+ });
+ builder.create().show();
+ }
+
+}
diff --git a/src/org/linphone/LinphoneConfigException.java b/src/org/linphone/LinphoneConfigException.java
new file mode 100644
index 000000000..998e0d8f3
--- /dev/null
+++ b/src/org/linphone/LinphoneConfigException.java
@@ -0,0 +1,40 @@
+/*
+LinphoneCoreException.java
+Copyright (C) 2010 Belledonne Communications, Grenoble, France
+
+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 2
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+package org.linphone;
+
+@SuppressWarnings("serial")
+public class LinphoneConfigException extends LinphoneException {
+
+ public LinphoneConfigException() {
+ super();
+ }
+
+ public LinphoneConfigException(String detailMessage, Throwable throwable) {
+ super(detailMessage, throwable);
+ }
+
+ public LinphoneConfigException(String detailMessage) {
+ super(detailMessage);
+ }
+
+ public LinphoneConfigException(Throwable throwable) {
+ super(throwable);
+ }
+
+}
diff --git a/src/org/linphone/LinphonePreferencesActivity.java b/src/org/linphone/LinphonePreferencesActivity.java
index 31c70191b..0bccb4b21 100644
--- a/src/org/linphone/LinphonePreferencesActivity.java
+++ b/src/org/linphone/LinphonePreferencesActivity.java
@@ -36,9 +36,9 @@ public class LinphonePreferencesActivity extends PreferenceActivity {
protected void onStop() {
super.onStop();
try {
- Linphone.getLinphone().initFromConf();
- } catch (LinphoneCoreException e) {
- Log.e(Linphone.TAG, "cannot update config",e);
+ LinphoneActivity.instance().initFromConf();
+ } catch (LinphoneException e) {
+ Log.e(LinphoneService.TAG, "cannot update config",e);
}
}
diff --git a/src/org/linphone/Linphone.java b/src/org/linphone/LinphoneService.java
similarity index 61%
rename from src/org/linphone/Linphone.java
rename to src/org/linphone/LinphoneService.java
index 680ddc36f..759ad7f11 100644
--- a/src/org/linphone/Linphone.java
+++ b/src/org/linphone/LinphoneService.java
@@ -35,12 +35,16 @@ import org.linphone.core.LinphoneProxyConfig;
import android.app.AlertDialog;
+import android.app.Service;
import android.app.TabActivity;
+import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
+import android.media.AudioManager;
import android.os.Bundle;
import android.os.Handler;
+import android.os.IBinder;
import android.os.Message;
import android.preference.PreferenceManager;
import android.util.Log;
@@ -50,7 +54,7 @@ import android.view.MenuItem;
import android.widget.TabHost;
import android.widget.Toast;
-public class Linphone extends TabActivity implements LinphoneCoreListener {
+public class LinphoneService extends Service implements LinphoneCoreListener {
static final public String TAG="Linphone";
/** Called when the activity is first created. */
private static String LINPHONE_FACTORY_RC = "/data/data/org.linphone/files/linphonerc";
@@ -58,26 +62,26 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
private static String RING_SND = "/data/data/org.linphone/files/oldphone_mono.wav";
private static String RINGBACK_SND = "/data/data/org.linphone/files/ringback.wav";
- private static Linphone theLinphone;
+ private static LinphoneService theLinphone;
private LinphoneCore mLinphoneCore;
private SharedPreferences mPref;
Timer mTimer = new Timer("Linphone scheduler");
- public static String DIALER_TAB = "dialer";
private Handler mIteratehandler;
- static Linphone getLinphone() {
+ static LinphoneService instance() {
if (theLinphone == null) {
throw new RuntimeException("LinphoneActivity not instanciated yet");
} else {
return theLinphone;
}
}
+
@Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
+ public void onCreate() {
+ super.onCreate();
theLinphone = this;
+
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
try {
copyAssetsFromPackage();
@@ -106,31 +110,6 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
mTimer.scheduleAtFixedRate(lTask, 0, 100);
- TabHost lTabHost = getTabHost(); // The activity TabHost
- TabHost.TabSpec spec; // Reusable TabSpec for each tab
-
-
- // Create an Intent to launch an Activity for the tab (to be reused)
- Intent lDialerIntent = new Intent().setClass(this, DialerActivity.class);
-
- // Initialize a TabSpec for each tab and add it to the TabHost
- spec = lTabHost.newTabSpec("dialer").setIndicator(getString(R.string.tab_dialer),
- getResources().getDrawable(android.R.drawable.ic_menu_call))
- .setContent(lDialerIntent);
- lTabHost.addTab(spec);
-
-
-
- // Do the same for the other tabs
- Intent lContactItent = new Intent().setClass(this, ContactPickerActivity.class);
-
- spec = lTabHost.newTabSpec("contact").setIndicator(getString(R.string.tab_contact),
- null)
- .setContent(lContactItent);
- lTabHost.addTab(spec);
-
- lTabHost.setCurrentTabByTag("dialer");
-
@@ -141,11 +120,7 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
}
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if (isFinishing()) System.exit(0); // FIXME to destroy liblinphone
- }
+
private void copyAssetsFromPackage() throws IOException {
@@ -204,53 +179,24 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
// TODO Auto-generated method stub
}
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- // Inflate the currently selected menu XML resource.
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.linphone_activity_menu, menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.menu_settings:
- startprefActivity();
- return true;
- case R.id.menu_exit:
- finish();
- break;
- default:
- Log.e(TAG, "Unknown menu item ["+item+"]");
- break;
- }
-
- return false;
- }
-
- public void initFromConf() throws LinphoneCoreException {
+ public void initFromConf() throws LinphoneConfigException, LinphoneException {
//1 read proxy config from preferences
String lUserName = mPref.getString(getString(R.string.pref_username_key), null);
if (lUserName == null) {
- handleBadConfig(getString(R.string.wrong_username));
- return;
+ throw new LinphoneConfigException(getString(R.string.wrong_username));
}
String lPasswd = mPref.getString(getString(R.string.pref_passwd_key), null);
if (lPasswd == null) {
- handleBadConfig(getString(R.string.wrong_passwd));
- return;
-
+ throw new LinphoneConfigException(getString(R.string.wrong_passwd));
}
-
+
String lDomain = mPref.getString(getString(R.string.pref_domain_key), null);
if (lDomain == null) {
- handleBadConfig(getString(R.string.wrong_domain));
- return;
+ throw new LinphoneConfigException(getString(R.string.wrong_domain));
}
@@ -259,62 +205,58 @@ public class Linphone extends TabActivity implements LinphoneCoreListener {
LinphoneAuthInfo lAuthInfo = LinphoneCoreFactory.instance().createAuthInfo(lUserName, lPasswd);
mLinphoneCore.addAuthInfo(lAuthInfo);
-
+
//proxy
String lProxy = mPref.getString(getString(R.string.pref_proxy_key), "sip:"+lDomain);
-
+
//get Default proxy if any
LinphoneProxyConfig lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig();
String lIdentity = "sip:"+lUserName+"@"+lDomain;
- if (lDefaultProxyConfig == null) {
- lDefaultProxyConfig = mLinphoneCore.createProxyConfig(lIdentity, lProxy, null,true);
- mLinphoneCore.addtProxyConfig(lDefaultProxyConfig);
- mLinphoneCore.setDefaultProxyConfig(lDefaultProxyConfig);
+ try {
+ if (lDefaultProxyConfig == null) {
+ lDefaultProxyConfig = mLinphoneCore.createProxyConfig(lIdentity, lProxy, null,true);
+ mLinphoneCore.addtProxyConfig(lDefaultProxyConfig);
+ mLinphoneCore.setDefaultProxyConfig(lDefaultProxyConfig);
- } else {
- lDefaultProxyConfig.edit();
- lDefaultProxyConfig.setIdentity(lIdentity);
- lDefaultProxyConfig.setProxy(lProxy);
- lDefaultProxyConfig.enableRegister(true);
- lDefaultProxyConfig.done();
- }
- lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig();
-
- if (lDefaultProxyConfig !=null) {
- //prefix
- String lPrefix = mPref.getString(getString(R.string.pref_prefix_key), null);
- if (lPrefix != null ) {
- lDefaultProxyConfig.setDialPrefix(lPrefix);
+ } else {
+ lDefaultProxyConfig.edit();
+ lDefaultProxyConfig.setIdentity(lIdentity);
+ lDefaultProxyConfig.setProxy(lProxy);
+ lDefaultProxyConfig.enableRegister(true);
+ lDefaultProxyConfig.done();
}
- //escape +
- lDefaultProxyConfig.setDialEscapePlus(true);
+ lDefaultProxyConfig = mLinphoneCore.getDefaultProxyConfig();
+
+ if (lDefaultProxyConfig !=null) {
+ //prefix
+ String lPrefix = mPref.getString(getString(R.string.pref_prefix_key), null);
+ if (lPrefix != null ) {
+ lDefaultProxyConfig.setDialPrefix(lPrefix);
+ }
+ //escape +
+ lDefaultProxyConfig.setDialEscapePlus(true);
+ }
+ }catch (LinphoneCoreException e) {
+ throw new LinphoneException(e);
}
-
+
}
- private void handleBadConfig(String message) {
- AlertDialog.Builder builder = new AlertDialog.Builder(this);
- builder.setMessage(String.format(getString(R.string.config_error),message))
- .setCancelable(false)
- .setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- startprefActivity();
- }
- })
- .setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- dialog.cancel();
- }
- });
- builder.create().show();
- }
- private void startprefActivity() {
- Intent intent = new Intent(Intent.ACTION_MAIN);
- intent.setClass(Linphone.this, LinphonePreferencesActivity.class);
- startActivity(intent);
- }
+
+
protected LinphoneCore getLinphoneCore() {
return mLinphoneCore;
}
+ @Override
+ public IBinder onBind(Intent intent) {
+ return null;
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+ System.exit(0); // FIXME to destroy liblinphone
+ }
+
}
\ No newline at end of file
diff --git a/src/org/linphone/core/LinphoneCallLog.java b/src/org/linphone/core/LinphoneCallLog.java
new file mode 100644
index 000000000..19d851a43
--- /dev/null
+++ b/src/org/linphone/core/LinphoneCallLog.java
@@ -0,0 +1,31 @@
+/*
+LinPhoneCallLog.java
+Copyright (C) 2010 Belledonne Communications, Grenoble, France
+
+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 2
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+package org.linphone.core;
+
+public interface LinphoneCallLog {
+ public enum CallDirection {
+ CallOutgoing,Callincoming
+ }
+
+ public LinphoneAddress getFrom();
+
+ public LinphoneAddress getTo ();
+
+ public LinphoneCallLog.CallDirection getDirection();
+}
diff --git a/src/org/linphone/core/LinphoneCallLogImpl.java b/src/org/linphone/core/LinphoneCallLogImpl.java
new file mode 100644
index 000000000..c35eea2c7
--- /dev/null
+++ b/src/org/linphone/core/LinphoneCallLogImpl.java
@@ -0,0 +1,46 @@
+/*
+LinPhoneCallLogImpl.java
+Copyright (C) 2010 Belledonne Communications, Grenoble, France
+
+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 2
+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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+package org.linphone.core;
+
+
+class LinphoneCallLogImpl implements LinphoneCallLog {
+
+ protected final long nativePtr;
+
+ private native long getFrom(long nativePtr);
+ private native long getTo(long nativePtr);
+ private native boolean isIncoming(long nativePtr);
+ LinphoneCallLogImpl(long aNativePtr) {
+ nativePtr = aNativePtr;
+ }
+
+
+ public CallDirection getDirection() {
+ return isIncoming(nativePtr)?CallDirection.Callincoming:CallDirection.CallOutgoing;
+ }
+
+ public LinphoneAddress getFrom() {
+ return new LinphoneAddressImpl(getFrom(nativePtr));
+ }
+
+ public LinphoneAddress getTo() {
+ return new LinphoneAddressImpl(getTo(nativePtr));
+ }
+
+}
diff --git a/src/org/linphone/core/LinphoneCore.java b/src/org/linphone/core/LinphoneCore.java
index 59747220c..c39ef36f2 100644
--- a/src/org/linphone/core/LinphoneCore.java
+++ b/src/org/linphone/core/LinphoneCore.java
@@ -18,6 +18,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
+import java.util.List;
+
public interface LinphoneCore {
@@ -116,4 +118,9 @@ public interface LinphoneCore {
public void acceptCall();
+ /**
+ * @return a list of LinphoneCallLog
+ */
+ public List getCallLogs();
+
}
diff --git a/src/org/linphone/core/LinphoneCoreImpl.java b/src/org/linphone/core/LinphoneCoreImpl.java
index 2997033e5..80d24bd67 100644
--- a/src/org/linphone/core/LinphoneCoreImpl.java
+++ b/src/org/linphone/core/LinphoneCoreImpl.java
@@ -20,6 +20,8 @@ package org.linphone.core;
import java.io.File;
import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
class LinphoneCoreImpl implements LinphoneCore {
@@ -42,6 +44,9 @@ class LinphoneCoreImpl implements LinphoneCore {
private native boolean isInCall(long nativePtr);
private native boolean isInComingInvitePending(long nativePtr);
private native void acceptCall(long nativePtr);
+ private native long getCallLog(long nativePtr,int position);
+ private native int getNumberOfCallLogs(long nativePtr);
+
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
mListener=listener;
@@ -109,4 +114,11 @@ class LinphoneCoreImpl implements LinphoneCore {
acceptCall(nativePtr);
}
+ public List getCallLogs() {
+ List logs = new ArrayList();
+ for (int i=0;i < getNumberOfCallLogs(nativePtr);i++) {
+ logs.add(new LinphoneCallLogImpl(getCallLog(nativePtr, i)));
+ }
+ return logs;
+ }
}
diff --git a/src/org/linphone/core/LinphoneProxyConfigImpl.java b/src/org/linphone/core/LinphoneProxyConfigImpl.java
index af2722dd2..3794c58bf 100644
--- a/src/org/linphone/core/LinphoneProxyConfigImpl.java
+++ b/src/org/linphone/core/LinphoneProxyConfigImpl.java
@@ -18,7 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
-import org.linphone.Linphone;
+import org.linphone.LinphoneService;
import android.util.Log;
@@ -35,14 +35,14 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
setProxy(proxy);
enableRegister(enableRegister);
ownPtr=true;
- Log.w(Linphone.TAG, "route ["+route+"] not used yet");
+ Log.w(LinphoneService.TAG, "route ["+route+"] not used yet");
}
protected LinphoneProxyConfigImpl(long aNativePtr) {
nativePtr = aNativePtr;
ownPtr=false;
}
protected void finalize() throws Throwable {
- Log.e(Linphone.TAG,"fixme, should release underlying proxy config");
+ Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config");
// FIXME if (ownPtr) delete(nativePtr);
}
private native long newLinphoneProxyConfig();