-phone view
-settings
This commit is contained in:
parent
764383ea8e
commit
c4411985bd
17 changed files with 417 additions and 86 deletions
|
@ -3,15 +3,19 @@
|
|||
package="org.linphone"
|
||||
android:versionCode="1"
|
||||
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"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
</activity>
|
||||
<activity android:name=".LinphonePreferencesActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<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"
|
||||
>
|
||||
|
||||
<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>
|
||||
|
||||
</TableLayout>
|
||||
|
||||
</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"?>
|
||||
<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="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>
|
||||
|
|
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,83 +1,118 @@
|
|||
/*
|
||||
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;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URI;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
import org.linphone.core.LinphoneAuthInfo;
|
||||
import org.linphone.core.LinphoneCore;
|
||||
import org.linphone.core.LinphoneCoreException;
|
||||
import org.linphone.core.LinphoneCoreFactory;
|
||||
import org.linphone.core.LinphoneCoreListener;
|
||||
import org.linphone.core.LinphoneProxyConfig;
|
||||
import org.linphone.core.LinphoneCore.GeneralState;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
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 {
|
||||
static final String TAG="Linphone";
|
||||
/** Called when the activity is first created. */
|
||||
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";
|
||||
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 RINGBACK_SND = "/data/data/org.linphone/files/ringback.wav";
|
||||
|
||||
private static Linphone theLinphone;
|
||||
private LinphoneCore mLinphoneCore;
|
||||
private LinphoneProxyConfig mProxyConfig;
|
||||
private LinphoneAuthInfo mAuthInfo;
|
||||
private SharedPreferences mPref;
|
||||
Timer mTimer = new Timer("Linphone scheduler");
|
||||
|
||||
|
||||
static Linphone getLinphone() {
|
||||
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);
|
||||
try {
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
theLinphone = this;
|
||||
mPref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||
try {
|
||||
copyAssetsFromPackage();
|
||||
|
||||
mLinphoneCore = LinphoneCoreFactory.instance().createLinphoneCore( this
|
||||
, new File(LINPHONE_RC)
|
||||
, new File(LINPHONE_FACTORY_RC)
|
||||
, null);
|
||||
mAuthInfo = LinphoneCoreFactory.instance().createAuthInfo("jehan", "223299");
|
||||
mLinphoneCore.addAuthInfo(mAuthInfo);
|
||||
|
||||
mProxyConfig = mLinphoneCore.createProxyConfig("sip:jehan@sip.antisip.com", "sip:sip.antisip.com",null);
|
||||
mProxyConfig.enableRegister(true);
|
||||
mLinphoneCore.addtProxyConfig(mProxyConfig);
|
||||
mLinphoneCore.setDefaultProxyConfig(mProxyConfig);
|
||||
|
||||
TimerTask lTask = new TimerTask() {
|
||||
mLinphoneCore = LinphoneCoreFactory.instance().createLinphoneCore( this
|
||||
, new File(LINPHONE_RC)
|
||||
, new File(LINPHONE_FACTORY_RC)
|
||||
, null);
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mLinphoneCore.iterate();
|
||||
|
||||
}
|
||||
initFromConf();
|
||||
|
||||
};
|
||||
mTimer.scheduleAtFixedRate(lTask, 0, 100);
|
||||
|
||||
|
||||
|
||||
TimerTask lTask = new TimerTask() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mLinphoneCore.iterate();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
mTimer.scheduleAtFixedRate(lTask, 0, 100);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG,"Cannot start linphone",e);
|
||||
}
|
||||
|
||||
}
|
||||
public void copyAssetsFromPackage() throws IOException {
|
||||
copyIfNotExist(R.raw.oldphone_mono,RING_SND);
|
||||
copyIfNotExist(R.raw.ringback,RINGBACK_SND);
|
||||
copyIfNotExist(R.raw.linphonerc,LINPHONE_FACTORY_RC);
|
||||
}
|
||||
private void copyIfNotExist(int ressourceId,String target) throws IOException {
|
||||
File lFileToCopy = new File(target);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@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.ringback,RINGBACK_SND);
|
||||
copyIfNotExist(R.raw.linphonerc,LINPHONE_FACTORY_RC);
|
||||
}
|
||||
private void copyIfNotExist(int ressourceId,String target) throws IOException {
|
||||
File lFileToCopy = new File(target);
|
||||
if (!lFileToCopy.exists()) {
|
||||
FileOutputStream lOutputStream = openFileOutput (lFileToCopy.getName(), 0);
|
||||
InputStream lInputStream = getResources().openRawResource(ressourceId);
|
||||
|
@ -90,44 +125,129 @@ public class Linphone extends Activity implements LinphoneCoreListener {
|
|||
lOutputStream.close();
|
||||
lInputStream.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public void authInfoRequested(LinphoneCore lc, String realm, String username) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
public void byeReceived(LinphoneCore lc, String from) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
public void displayMessage(LinphoneCore lc, String message) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
public void displayStatus(LinphoneCore lc, String message) {
|
||||
Log.i(TAG, message);
|
||||
|
||||
|
||||
}
|
||||
public void displayWarning(LinphoneCore lc, String message) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
public void generalState(LinphoneCore lc, LinphoneCore.GeneralState state) {
|
||||
Log.i(TAG, "new state ["+state+"]");
|
||||
|
||||
switch(state) {
|
||||
case GSTATE_REG_OK: {
|
||||
mLinphoneCore.invite("simon.morlat");
|
||||
//mLinphoneCore.invite("simon.morlat");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void inviteReceived(LinphoneCore lc, String from) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
|
||||
}
|
||||
public void show(LinphoneCore lc) {
|
||||
// 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,18 +61,28 @@ public interface LinphoneCore {
|
|||
* @param identity sip uri sip:jehan@linphone.org
|
||||
* @param proxy sip uri (sip:linphone.org)
|
||||
* @param route optionnal sip usi (sip:linphone.org)
|
||||
* @param register should be initiated
|
||||
* @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 setDefaultProxyConfig(LinphoneProxyConfig proxyCfg);
|
||||
|
||||
/**
|
||||
* @return null if no default proxyconfig
|
||||
* @return null if no default proxy config
|
||||
*/
|
||||
public LinphoneProxyConfig getDefaultProxyConfig();
|
||||
public LinphoneProxyConfig getDefaultProxyConfig() ;
|
||||
|
||||
/**
|
||||
* clear all the added auth info
|
||||
*/
|
||||
void clearAuthInfos();
|
||||
|
||||
void addAuthInfo(LinphoneAuthInfo info);
|
||||
|
||||
|
|
|
@ -28,8 +28,13 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
private final long nativePtr;
|
||||
private native long newLinphoneCore(LinphoneCoreListener listener,String userConfig,String factoryConfig,Object userdata);
|
||||
private native void iterate(long nativePtr);
|
||||
private native long getDefaultProxyConfig(long nativePtr);
|
||||
|
||||
private native void setDefaultProxyConfig(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 invite(long nativePtr,String uri);
|
||||
LinphoneCoreImpl(LinphoneCoreListener listener, File userConfig,File factoryConfig,Object userdata) throws IOException {
|
||||
|
@ -41,12 +46,17 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
addAuthInfo(nativePtr,((LinphoneAuthInfoImpl)info).nativePtr);
|
||||
}
|
||||
|
||||
public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route) throws LinphoneCoreException {
|
||||
return new LinphoneProxyConfigImpl(identity, proxy, route);
|
||||
public LinphoneProxyConfig createProxyConfig(String identity, String proxy,String route,boolean enableRegister) throws LinphoneCoreException {
|
||||
return new LinphoneProxyConfigImpl(identity, proxy, route,enableRegister);
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -65,6 +75,13 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
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 {
|
||||
|
||||
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;
|
||||
|
||||
import org.linphone.Linphone;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
|
||||
|
||||
class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
||||
|
||||
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();
|
||||
setIdentity(nativePtr,identity);
|
||||
if (setProxy(nativePtr,proxy)!=0) {
|
||||
throw new LinphoneCoreException("Bad proxy address ["+proxy+"]");
|
||||
}
|
||||
setIdentity(identity);
|
||||
setProxy(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 {
|
||||
delete(nativePtr);
|
||||
if (ownPtr) delete(nativePtr);
|
||||
}
|
||||
private native long newLinphoneProxyConfig();
|
||||
private native void delete(long ptr);
|
||||
|
||||
//private native void edit(long ptr);
|
||||
//private native void done(long ptr);
|
||||
private native void edit(long ptr);
|
||||
private native void done(long ptr);
|
||||
|
||||
private native void setIdentity(long ptr,String identity);
|
||||
private native int setProxy(long ptr,String proxy);
|
||||
|
@ -47,9 +56,24 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
|||
private native void enableRegister(long ptr,boolean value);
|
||||
|
||||
public void enableRegister(boolean value) {
|
||||
//edit(nativePtr);
|
||||
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