-phone view
-settings
This commit is contained in:
parent
764383ea8e
commit
c4411985bd
17 changed files with 417 additions and 86 deletions
|
@ -3,7 +3,7 @@
|
||||||
package="org.linphone"
|
package="org.linphone"
|
||||||
android:versionCode="1"
|
android:versionCode="1"
|
||||||
android:versionName="1.0">
|
android:versionName="1.0">
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<application android:icon="@drawable/linphone2" android:label="@string/app_name">
|
||||||
<activity android:name=".Linphone"
|
<activity android:name=".Linphone"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
@ -11,7 +11,11 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<activity android:name=".LinphonePreferencesActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
|
||||||
|
|
BIN
res/drawable/green.png
Normal file
BIN
res/drawable/green.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.9 KiB |
BIN
res/drawable/linphone.png
Normal file
BIN
res/drawable/linphone.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
res/drawable/linphone2.png
Normal file
BIN
res/drawable/linphone2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
res/drawable/red.png
Normal file
BIN
res/drawable/red.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4 KiB |
|
@ -5,20 +5,34 @@
|
||||||
android:layout_height="fill_parent"
|
android:layout_height="fill_parent"
|
||||||
>
|
>
|
||||||
|
|
||||||
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content" android:hint="sip:" android:layout_marginTop="10dip" android:layout_width="fill_parent"></EditText>
|
<EditText android:id="@+id/SipUri" android:layout_height="wrap_content" android:hint="sip:" android:layout_width="fill_parent" android:singleLine="true"></EditText>
|
||||||
|
|
||||||
|
<TableLayout android:layout_width="fill_parent" android:id="@+id/Dialer" android:layout_height="300dip">
|
||||||
|
<TableRow android:layout_height="fill_parent" android:layout_weight="1" android:id="@+id/DialerRow01" android:layout_width="fill_parent">
|
||||||
|
<Button android:id="@+id/Button01" android:text="1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:id="@+id/Button02" android:text="2" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:id="@+id/Button03" android:text="3" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5"></Button>
|
||||||
|
</TableRow><TableRow android:layout_height="fill_parent" android:layout_weight="1" android:id="@+id/DialerRow02" android:layout_width="fill_parent"><Button android:id="@+id/Button04" android:text="4" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:text="5" android:id="@+id/Button05" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:id="@+id/Button06" android:text="6" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5"></Button>
|
||||||
|
</TableRow><TableRow android:layout_weight="1" android:layout_height="fill_parent" android:id="@+id/DialerRow03" android:layout_width="fill_parent"><Button android:text="7" android:id="@+id/Button07" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:id="@+id/Button08" android:text="8" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:text="9" android:id="@+id/Button09" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="0.5"></Button>
|
||||||
|
</TableRow><TableRow android:layout_weight="1" android:layout_height="fill_parent" android:id="@+id/DialerRow04" android:layout_width="fill_parent"><Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/ButtonStart" android:text="*" android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="0+" android:id="@+id/Button00" android:layout_weight="0.25"></Button>
|
||||||
|
<Button android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/ButtonHash" android:text="#" android:layout_weight="0.5"></Button>
|
||||||
|
</TableRow><TableRow android:layout_height="fill_parent" android:id="@+id/DialerRow00" android:layout_width="fill_parent" android:layout_weight="1">
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/Call" android:layout_height="fill_parent" android:src="@drawable/green" android:layout_width="fill_parent" android:layout_weight="0.25">
|
||||||
|
</ImageButton>
|
||||||
|
|
||||||
|
|
||||||
|
<ImageButton android:id="@+id/HangUp" android:src="@drawable/red" android:layout_height="fill_parent" android:layout_width="fill_parent" android:layout_weight="0.25"></ImageButton>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<TableLayout android:layout_width="fill_parent" android:layout_height="200dip" android:id="@+id/Dialer">
|
|
||||||
<TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:id="@+id/DialerRow01">
|
|
||||||
<Button android:id="@+id/Button01" android:text="1" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent"></Button>
|
|
||||||
<Button android:id="@+id/Button02" android:text="2" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent"></Button>
|
|
||||||
<Button android:id="@+id/Button03" android:text="3" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent"></Button>
|
|
||||||
</TableRow><TableRow android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_weight="1" android:id="@+id/DialerRow02"><Button android:id="@+id/Button04" android:text="4" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent"></Button>
|
|
||||||
<Button android:text="5" android:id="@+id/Button05" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent"></Button>
|
|
||||||
<Button android:id="@+id/Button06" android:text="6" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent"></Button>
|
|
||||||
</TableRow><TableRow android:layout_width="wrap_content" android:layout_weight="1" android:layout_height="fill_parent" android:id="@+id/TableRow03"><Button android:text="7" android:id="@+id/Button07" android:layout_width="fill_parent" android:layout_weight="1" android:layout_height="fill_parent"></Button>
|
|
||||||
<Button android:id="@+id/Button08" android:text="8" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent"></Button>
|
|
||||||
<Button android:text="9" android:id="@+id/Button09" android:layout_weight="1" android:layout_width="fill_parent" android:layout_height="fill_parent"></Button>
|
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
||||||
</TableLayout>
|
</TableLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
5
res/menu/linphone_activity_menu.xml
Normal file
5
res/menu/linphone_activity_menu.xml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<menu
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:title="@string/menu_settings" android:id="@+id/menu_settings"></item>
|
||||||
|
</menu>
|
7
res/values/non_localizable_strings.xml
Normal file
7
res/values/non_localizable_strings.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<string name="pref_proxy_key">pref_proxy_key</string>
|
||||||
|
<string name="pref_domain_key">pref_domain_key</string>
|
||||||
|
<string name="pref_passwd_key">pref_passwd_key</string>
|
||||||
|
<string name="pref_username_key">pref_username_key</string>
|
||||||
|
</resources>
|
|
@ -1,5 +1,14 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="menu_settings">Settings</string>
|
||||||
|
<string name="pref_proxy">Proxy</string>
|
||||||
|
<string name="pref_domain">Domain*</string>
|
||||||
|
<string name="pref_passwd">Password*</string>
|
||||||
|
<string name="pref_username">Username*</string>
|
||||||
<string name="hello">Hello World, Linphone!</string>
|
<string name="hello">Hello World, Linphone!</string>
|
||||||
<string name="app_name">Linphone</string>
|
<string name="app_name">Linphone</string>
|
||||||
|
<string name="pref_sipaccount">SIP Account</string>
|
||||||
|
<string name="enter_username">Enter a user name</string>
|
||||||
|
<string name="enter_passwd">Enter a password</string>
|
||||||
|
<string name="enter_domain">Enter a domain</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
9
res/xml/preferences.xml
Normal file
9
res/xml/preferences.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<PreferenceCategory android:title="@string/pref_sipaccount"><EditTextPreference android:title="@string/pref_username" android:key="@string/pref_username_key"></EditTextPreference>
|
||||||
|
<EditTextPreference android:title="@string/pref_passwd" android:key="@string/pref_passwd_key"></EditTextPreference>
|
||||||
|
<EditTextPreference android:title="@string/pref_domain" android:key="@string/pref_domain_key"></EditTextPreference>
|
||||||
|
<EditTextPreference android:title="@string/pref_proxy" android:key="@string/pref_proxy_key"></EditTextPreference>
|
||||||
|
</PreferenceCategory>
|
||||||
|
</PreferenceScreen>
|
|
@ -1,43 +1,75 @@
|
||||||
|
/*
|
||||||
|
Linphone.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;
|
package org.linphone;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URI;
|
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.TimerTask;
|
import java.util.TimerTask;
|
||||||
|
|
||||||
import org.linphone.core.LinphoneAuthInfo;
|
import org.linphone.core.LinphoneAuthInfo;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListener;
|
import org.linphone.core.LinphoneCoreListener;
|
||||||
import org.linphone.core.LinphoneProxyConfig;
|
import org.linphone.core.LinphoneProxyConfig;
|
||||||
import org.linphone.core.LinphoneCore.GeneralState;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
|
import android.widget.Toast;
|
||||||
|
|
||||||
public class Linphone extends Activity implements LinphoneCoreListener {
|
public class Linphone extends Activity implements LinphoneCoreListener {
|
||||||
static final String TAG="Linphone";
|
static final public String TAG="Linphone";
|
||||||
/** Called when the activity is first created. */
|
/** Called when the activity is first created. */
|
||||||
private static String LINPHONE_FACTORY_RC = "/data/data/org.linphone/files/linphonerc";
|
private static String LINPHONE_FACTORY_RC = "/data/data/org.linphone/files/linphonerc";
|
||||||
private static String LINPHONE_RC = "/data/data/org.linphone/files/.linphonerc";
|
private static String LINPHONE_RC = "/data/data/org.linphone/files/.linphonerc";
|
||||||
private static String RING_SND = "/data/data/org.linphone/files/oldphone_mono.wav";
|
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 String RINGBACK_SND = "/data/data/org.linphone/files/ringback.wav";
|
||||||
|
|
||||||
|
private static Linphone theLinphone;
|
||||||
private LinphoneCore mLinphoneCore;
|
private LinphoneCore mLinphoneCore;
|
||||||
private LinphoneProxyConfig mProxyConfig;
|
private SharedPreferences mPref;
|
||||||
private LinphoneAuthInfo mAuthInfo;
|
|
||||||
Timer mTimer = new Timer("Linphone scheduler");
|
Timer mTimer = new Timer("Linphone scheduler");
|
||||||
|
|
||||||
|
static Linphone getLinphone() {
|
||||||
|
if (theLinphone == null) {
|
||||||
|
throw new RuntimeException("LinphoneActivity not instanciated yet");
|
||||||
|
} else {
|
||||||
|
return theLinphone;
|
||||||
|
}
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.main);
|
setContentView(R.layout.main);
|
||||||
|
theLinphone = this;
|
||||||
|
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
try {
|
try {
|
||||||
copyAssetsFromPackage();
|
copyAssetsFromPackage();
|
||||||
|
|
||||||
|
@ -45,13 +77,8 @@ public class Linphone extends Activity implements LinphoneCoreListener {
|
||||||
, new File(LINPHONE_RC)
|
, new File(LINPHONE_RC)
|
||||||
, new File(LINPHONE_FACTORY_RC)
|
, new File(LINPHONE_FACTORY_RC)
|
||||||
, null);
|
, null);
|
||||||
mAuthInfo = LinphoneCoreFactory.instance().createAuthInfo("jehan", "223299");
|
|
||||||
mLinphoneCore.addAuthInfo(mAuthInfo);
|
|
||||||
|
|
||||||
mProxyConfig = mLinphoneCore.createProxyConfig("sip:jehan@sip.antisip.com", "sip:sip.antisip.com",null);
|
initFromConf();
|
||||||
mProxyConfig.enableRegister(true);
|
|
||||||
mLinphoneCore.addtProxyConfig(mProxyConfig);
|
|
||||||
mLinphoneCore.setDefaultProxyConfig(mProxyConfig);
|
|
||||||
|
|
||||||
TimerTask lTask = new TimerTask() {
|
TimerTask lTask = new TimerTask() {
|
||||||
|
|
||||||
|
@ -64,14 +91,22 @@ public class Linphone extends Activity implements LinphoneCoreListener {
|
||||||
};
|
};
|
||||||
mTimer.scheduleAtFixedRate(lTask, 0, 100);
|
mTimer.scheduleAtFixedRate(lTask, 0, 100);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.e(TAG,"Cannot start linphone",e);
|
Log.e(TAG,"Cannot start linphone",e);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public void copyAssetsFromPackage() throws IOException {
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
super.onStop();
|
||||||
|
//finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void copyAssetsFromPackage() throws IOException {
|
||||||
copyIfNotExist(R.raw.oldphone_mono,RING_SND);
|
copyIfNotExist(R.raw.oldphone_mono,RING_SND);
|
||||||
copyIfNotExist(R.raw.ringback,RINGBACK_SND);
|
copyIfNotExist(R.raw.ringback,RINGBACK_SND);
|
||||||
copyIfNotExist(R.raw.linphonerc,LINPHONE_FACTORY_RC);
|
copyIfNotExist(R.raw.linphonerc,LINPHONE_FACTORY_RC);
|
||||||
|
@ -117,7 +152,7 @@ public class Linphone extends Activity implements LinphoneCoreListener {
|
||||||
|
|
||||||
switch(state) {
|
switch(state) {
|
||||||
case GSTATE_REG_OK: {
|
case GSTATE_REG_OK: {
|
||||||
mLinphoneCore.invite("simon.morlat");
|
//mLinphoneCore.invite("simon.morlat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,4 +165,89 @@ public class Linphone extends Activity implements LinphoneCoreListener {
|
||||||
// TODO Auto-generated method stub
|
// 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;
|
||||||
|
default:
|
||||||
|
Log.e(TAG, "Unknown menu item ["+item+"]");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void initFromConf() throws LinphoneCoreException {
|
||||||
|
//1 read proxy config from preferences
|
||||||
|
String lUserName = mPref.getString(getString(R.string.pref_username_key), null);
|
||||||
|
if (lUserName == null) {
|
||||||
|
Toast toast = Toast.makeText(this, this.getString(R.string.enter_username), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
startprefActivity();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String lPasswd = mPref.getString(getString(R.string.pref_passwd_key), null);
|
||||||
|
if (lPasswd == null) {
|
||||||
|
Toast toast = Toast.makeText(this, this.getString(R.string.enter_passwd), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
startprefActivity();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String lDomain = mPref.getString(getString(R.string.pref_domain_key), null);
|
||||||
|
if (lDomain == null) {
|
||||||
|
Toast toast = Toast.makeText(this, this.getString(R.string.enter_domain), Toast.LENGTH_LONG);
|
||||||
|
toast.show();
|
||||||
|
startprefActivity();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//auth
|
||||||
|
mLinphoneCore.clearAuthInfos();
|
||||||
|
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);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
lDefaultProxyConfig.edit();
|
||||||
|
lDefaultProxyConfig.setIdentity(lIdentity);
|
||||||
|
lDefaultProxyConfig.setProxy(lProxy);
|
||||||
|
lDefaultProxyConfig.enableRegister(true);
|
||||||
|
lDefaultProxyConfig.done();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startprefActivity() {
|
||||||
|
Intent intent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
intent.setClass(Linphone.this, LinphonePreferencesActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
43
src/org/linphone/LinphoneException.java
Normal file
43
src/org/linphone/LinphoneException.java
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
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 LinphoneException extends Exception {
|
||||||
|
|
||||||
|
public LinphoneException() {
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneException(String detailMessage) {
|
||||||
|
super(detailMessage);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneException(Throwable throwable) {
|
||||||
|
super(throwable);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public LinphoneException(String detailMessage, Throwable throwable) {
|
||||||
|
super(detailMessage, throwable);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
45
src/org/linphone/LinphonePreferencesActivity.java
Normal file
45
src/org/linphone/LinphonePreferencesActivity.java
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
LinphonePreferencesActivity.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.LinphoneCoreException;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceActivity;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class LinphonePreferencesActivity extends PreferenceActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
// Load the preferences from an XML resource
|
||||||
|
addPreferencesFromResource(R.xml.preferences);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
super.onStop();
|
||||||
|
try {
|
||||||
|
Linphone.getLinphone().initFromConf();
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
Log.e(Linphone.TAG, "cannot update config",e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -61,9 +61,14 @@ public interface LinphoneCore {
|
||||||
* @param identity sip uri sip:jehan@linphone.org
|
* @param identity sip uri sip:jehan@linphone.org
|
||||||
* @param proxy sip uri (sip:linphone.org)
|
* @param proxy sip uri (sip:linphone.org)
|
||||||
* @param route optionnal sip usi (sip:linphone.org)
|
* @param route optionnal sip usi (sip:linphone.org)
|
||||||
|
* @param register should be initiated
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public LinphoneProxyConfig createProxyConfig(String identity,String proxy,String route) throws LinphoneCoreException;
|
public LinphoneProxyConfig createProxyConfig(String identity,String proxy,String route,boolean enableRegister) throws LinphoneCoreException;
|
||||||
|
/**
|
||||||
|
* clear all added proxy config
|
||||||
|
*/
|
||||||
|
public void clearProxyConfigs();
|
||||||
|
|
||||||
public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException;
|
public void addtProxyConfig(LinphoneProxyConfig proxyCfg) throws LinphoneCoreException;
|
||||||
|
|
||||||
|
@ -74,6 +79,11 @@ public interface LinphoneCore {
|
||||||
*/
|
*/
|
||||||
public LinphoneProxyConfig getDefaultProxyConfig() ;
|
public LinphoneProxyConfig getDefaultProxyConfig() ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* clear all the added auth info
|
||||||
|
*/
|
||||||
|
void clearAuthInfos();
|
||||||
|
|
||||||
void addAuthInfo(LinphoneAuthInfo info);
|
void addAuthInfo(LinphoneAuthInfo info);
|
||||||
|
|
||||||
public void invite(String uri);
|
public void invite(String uri);
|
||||||
|
|
|
@ -28,8 +28,13 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
private final long nativePtr;
|
private final long nativePtr;
|
||||||
private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata);
|
private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata);
|
||||||
private native void iterate(long nativePtr);
|
private native void iterate(long nativePtr);
|
||||||
|
private native long getDefaultProxyConfig(long nativePtr);
|
||||||
|
|
||||||
private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr);
|
private native void setDefaultProxyConfig(long nativePtr,long proxyCfgNativePtr);
|
||||||
private native int addProxyConfig(long nativePtr,long proxyCfgNativePtr);
|
private native int addProxyConfig(long nativePtr,long proxyCfgNativePtr);
|
||||||
|
private native void clearAuthInfos(long nativePtr);
|
||||||
|
|
||||||
|
private native void clearProxyConfigs(long nativePtr);
|
||||||
private native void addAuthInfo(long nativePtr,long authInfoNativePtr);
|
private native void addAuthInfo(long nativePtr,long authInfoNativePtr);
|
||||||
private native void invite(long nativePtr,String uri);
|
private native void invite(long nativePtr,String uri);
|
||||||
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
|
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
|
||||||
|
@ -41,12 +46,17 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr);
|
addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route) throws LinphoneCoreException {
|
public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException {
|
||||||
return new LinphoneProxyConfigImpl(identity, proxy, route);
|
return new LinphoneProxyConfigImpl(identity, proxy, route,enableRegister);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinphoneProxyConfig getDefaultProxyConfig() {
|
public LinphoneProxyConfig getDefaultProxyConfig() {
|
||||||
throw new RuntimeException("not implemenetd yet");
|
long lNativePtr = getDefaultProxyConfig(nativePtr);
|
||||||
|
if (lNativePtr!=0) {
|
||||||
|
return new LinphoneProxyConfigImpl(lNativePtr);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void invite(String uri) {
|
public void invite(String uri) {
|
||||||
|
@ -65,6 +75,13 @@ class LinphoneCoreImpl implements LinphoneCore {
|
||||||
throw new LinphoneCoreException("bad proxy config");
|
throw new LinphoneCoreException("bad proxy config");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void clearAuthInfos() {
|
||||||
|
clearAuthInfos(nativePtr);
|
||||||
|
|
||||||
|
}
|
||||||
|
public void clearProxyConfigs() {
|
||||||
|
clearProxyConfigs(nativePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,31 @@ package org.linphone.core;
|
||||||
|
|
||||||
public interface LinphoneProxyConfig {
|
public interface LinphoneProxyConfig {
|
||||||
|
|
||||||
void enableRegister(boolean value);
|
/**
|
||||||
|
* Unregister proxy config a enable edition
|
||||||
|
*/
|
||||||
|
public void edit();
|
||||||
|
/**
|
||||||
|
* Validate proxy config changes. Start registration in case
|
||||||
|
*/
|
||||||
|
public void done();
|
||||||
|
/**
|
||||||
|
* sip user made by sip:username@domain
|
||||||
|
*/
|
||||||
|
public void setIdentity(String identity) throws LinphoneCoreException;
|
||||||
|
/**
|
||||||
|
* Set proxy uri, like sip:linphone.org:5060
|
||||||
|
* @param proxyUri
|
||||||
|
* @throws LinphoneCoreException
|
||||||
|
*/
|
||||||
|
public void setProxy(String proxyUri) throws LinphoneCoreException;
|
||||||
|
/**
|
||||||
|
* Enable register for this proxy config.
|
||||||
|
* Register message is issued after call to {@link #done()}
|
||||||
|
* @param value
|
||||||
|
* @throws LinphoneCoreException
|
||||||
|
*/
|
||||||
|
public void enableRegister(boolean value) throws LinphoneCoreException;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,28 +18,37 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
package org.linphone.core;
|
package org.linphone.core;
|
||||||
|
|
||||||
|
import org.linphone.Linphone;
|
||||||
|
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
||||||
|
|
||||||
protected final long nativePtr;
|
protected final long nativePtr;
|
||||||
protected LinphoneProxyConfigImpl(String identity,String proxy,String route) throws LinphoneCoreException {
|
boolean ownPtr = false;
|
||||||
|
protected LinphoneProxyConfigImpl(String identity,String proxy,String route, boolean enableRegister) throws LinphoneCoreException {
|
||||||
nativePtr = newLinphoneProxyConfig();
|
nativePtr = newLinphoneProxyConfig();
|
||||||
setIdentity(nativePtr,identity);
|
setIdentity(identity);
|
||||||
if (setProxy(nativePtr,proxy)!=0) {
|
setProxy(proxy);
|
||||||
throw new LinphoneCoreException("Bad proxy address ["+proxy+"]");
|
enableRegister(enableRegister);
|
||||||
|
ownPtr=true;
|
||||||
|
Log.w(Linphone.TAG, "route ["+route+"] not used yet");
|
||||||
}
|
}
|
||||||
|
protected LinphoneProxyConfigImpl(long aNativePtr) {
|
||||||
|
nativePtr = aNativePtr;
|
||||||
|
ownPtr=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void finalize() throws Throwable {
|
protected void finalize() throws Throwable {
|
||||||
delete(nativePtr);
|
if (ownPtr) delete(nativePtr);
|
||||||
}
|
}
|
||||||
private native long newLinphoneProxyConfig();
|
private native long newLinphoneProxyConfig();
|
||||||
private native void delete(long ptr);
|
private native void delete(long ptr);
|
||||||
|
|
||||||
//private native void edit(long ptr);
|
private native void edit(long ptr);
|
||||||
//private native void done(long ptr);
|
private native void done(long ptr);
|
||||||
|
|
||||||
private native void setIdentity(long ptr,String identity);
|
private native void setIdentity(long ptr,String identity);
|
||||||
private native int setProxy(long ptr,String proxy);
|
private native int setProxy(long ptr,String proxy);
|
||||||
|
@ -47,9 +56,24 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
||||||
private native void enableRegister(long ptr,boolean value);
|
private native void enableRegister(long ptr,boolean value);
|
||||||
|
|
||||||
public void enableRegister(boolean value) {
|
public void enableRegister(boolean value) {
|
||||||
//edit(nativePtr);
|
|
||||||
enableRegister(nativePtr,value);
|
enableRegister(nativePtr,value);
|
||||||
//done(nativePtr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void done() {
|
||||||
|
done(nativePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void edit() {
|
||||||
|
edit(nativePtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIdentity(String identity) throws LinphoneCoreException {
|
||||||
|
setIdentity(nativePtr,identity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProxy(String proxyUri) throws LinphoneCoreException {
|
||||||
|
if (setProxy(nativePtr,proxyUri)!=0) {
|
||||||
|
throw new LinphoneCoreException("Bad proxy address ["+proxyUri+"]");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue