Sending regId to flexisip using proxyconfig contact params
This commit is contained in:
parent
f6ea7e5158
commit
df071cf987
9 changed files with 126 additions and 3 deletions
|
@ -10,5 +10,6 @@
|
||||||
<classpathentry exported="true" kind="lib" path="libs/aXMLRPC.jar"/>
|
<classpathentry exported="true" kind="lib" path="libs/aXMLRPC.jar"/>
|
||||||
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
|
||||||
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
|
<classpathentry kind="lib" path="libs/android-support-v4.jar"/>
|
||||||
|
<classpathentry kind="lib" path="libs/gcm.jar"/>
|
||||||
<classpathentry kind="output" path="bin/classes"/>
|
<classpathentry kind="output" path="bin/classes"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
android:versionCode="2000" android:versionName="2.0" android:installLocation="auto">
|
android:versionCode="2000" android:versionName="2.0" android:installLocation="auto">
|
||||||
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="16"/>
|
<uses-sdk android:minSdkVersion="5" android:targetSdkVersion="16"/>
|
||||||
|
|
||||||
|
<!-- Permissions for Push Notification -->
|
||||||
|
<permission android:name="org.linphone.permission.C2D_MESSAGE" android:protectionLevel="signature" />
|
||||||
|
<uses-permission android:name="org.linphone.permission.C2D_MESSAGE" />
|
||||||
|
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
|
||||||
|
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
|
||||||
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
<uses-permission android:name="android.permission.READ_CONTACTS"/>
|
||||||
|
@ -100,6 +106,17 @@
|
||||||
<intent-filter><action android:name="android.intent.action.PHONE_STATE" /></intent-filter>
|
<intent-filter><action android:name="android.intent.action.PHONE_STATE" /></intent-filter>
|
||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
|
<!-- Needed for push notification -->
|
||||||
|
<receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" >
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
|
||||||
|
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
|
||||||
|
<category android:name="org.linphone" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
|
||||||
|
<service android:name=".GCMIntentService" />
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
|
BIN
libs/gcm.jar
Normal file
BIN
libs/gcm.jar
Normal file
Binary file not shown.
|
@ -1,6 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<!-- Push notification settings -->
|
||||||
|
<bool name="enable_push_id">true</bool>
|
||||||
|
<string name="push_reg_id_key">175894229314</string>
|
||||||
|
<string name="push_sender_id">175894229314</string>
|
||||||
|
|
||||||
<string name="default_domain">sip.linphone.org</string>
|
<string name="default_domain">sip.linphone.org</string>
|
||||||
<string name="wizard_url">https://www.linphone.org/wizard.php</string>
|
<string name="wizard_url">https://www.linphone.org/wizard.php</string>
|
||||||
|
|
76
src/org/linphone/GCMIntentService.java
Normal file
76
src/org/linphone/GCMIntentService.java
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
package org.linphone;
|
||||||
|
/*
|
||||||
|
GCMIntentService.java
|
||||||
|
Copyright (C) 2012 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.linphone.core.LinphoneCoreException;
|
||||||
|
import org.linphone.core.Log;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
|
||||||
|
import com.google.android.gcm.GCMBaseIntentService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Sylvain Berfini
|
||||||
|
*/
|
||||||
|
// Warning ! Do not rename the service !
|
||||||
|
public class GCMIntentService extends GCMBaseIntentService {
|
||||||
|
|
||||||
|
public GCMIntentService() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onError(Context context, String errorId) {
|
||||||
|
Log.e("Error while registering push notification : " + errorId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onMessage(Context context, Intent intent) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onRegistered(Context context, String regId) {
|
||||||
|
Log.d("Registered push notification : " + regId);
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
editor.putString(context.getString(R.string.push_reg_id_key), regId);
|
||||||
|
editor.commit();
|
||||||
|
|
||||||
|
if (LinphoneManager.isInstanciated()) {
|
||||||
|
try {
|
||||||
|
LinphoneManager.getInstance().initAccounts();
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onUnregistered(Context context, String regId) {
|
||||||
|
Log.w("Unregistered push notification : " + regId);
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
editor.putString(context.getString(R.string.push_reg_id_key), null);
|
||||||
|
editor.commit();
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@ package org.linphone;
|
||||||
|
|
||||||
import static android.content.Intent.ACTION_MAIN;
|
import static android.content.Intent.ACTION_MAIN;
|
||||||
|
|
||||||
|
import org.linphone.core.Log;
|
||||||
import org.linphone.mediastream.Version;
|
import org.linphone.mediastream.Version;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -28,6 +29,8 @@ import android.content.pm.ActivityInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
|
||||||
|
import com.google.android.gcm.GCMRegistrar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Launch Linphone main activity when Service is ready.
|
* Launch Linphone main activity when Service is ready.
|
||||||
|
@ -54,6 +57,18 @@ public class LinphoneLauncherActivity extends Activity {
|
||||||
|
|
||||||
mHandler = new Handler();
|
mHandler = new Handler();
|
||||||
|
|
||||||
|
// Starting the push notification service
|
||||||
|
if (getResources().getBoolean(R.bool.enable_push_id)) {
|
||||||
|
GCMRegistrar.checkDevice(this);
|
||||||
|
GCMRegistrar.checkManifest(this);
|
||||||
|
final String regId = GCMRegistrar.getRegistrationId(this);
|
||||||
|
if (regId.equals("")) {
|
||||||
|
GCMRegistrar.register(this, getString(R.string.push_sender_id));
|
||||||
|
} else {
|
||||||
|
Log.e("Already registered");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (LinphoneService.isReady()) {
|
if (LinphoneService.isReady()) {
|
||||||
onServiceReady();
|
onServiceReady();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -618,7 +618,14 @@ public final class LinphoneManager implements LinphoneCoreListener {
|
||||||
if (!proxy.startsWith("sip:")) {
|
if (!proxy.startsWith("sip:")) {
|
||||||
proxy = "sip:" + proxy;
|
proxy = "sip:" + proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneProxyConfig proxycon = LinphoneCoreFactory.instance().createProxyConfig(identity, proxy, null, true);
|
LinphoneProxyConfig proxycon = LinphoneCoreFactory.instance().createProxyConfig(identity, proxy, null, true);
|
||||||
|
|
||||||
|
String regId = getPrefString(R.string.push_reg_id_key, null);
|
||||||
|
if (regId != null) {
|
||||||
|
String contactInfos = "app-id=org.linphone.phone.dev;pn-type=android;pn-tok=" + regId + ";pn-msg-str=IM_MSG;pn-call-str=IC_MSG;pn-call-snd=ring.caf;pn-msg-snd=msg.caf;";
|
||||||
|
proxycon.setContactParameters(contactInfos);
|
||||||
|
}
|
||||||
mLc.addProxyConfig(proxycon);
|
mLc.addProxyConfig(proxycon);
|
||||||
|
|
||||||
//outbound proxy
|
//outbound proxy
|
||||||
|
|
|
@ -75,7 +75,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
||||||
private native int setRoute(long ptr,String uri);
|
private native int setRoute(long ptr,String uri);
|
||||||
private native void enablePublish(long ptr,boolean enable);
|
private native void enablePublish(long ptr,boolean enable);
|
||||||
private native boolean publishEnabled(long ptr);
|
private native boolean publishEnabled(long ptr);
|
||||||
|
private native void setContactParameters(long ptr, String params);
|
||||||
|
|
||||||
public void enableRegister(boolean value) {
|
public void enableRegister(boolean value) {
|
||||||
enableRegister(nativePtr,value);
|
enableRegister(nativePtr,value);
|
||||||
|
@ -143,4 +143,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
|
||||||
public boolean publishEnabled() {
|
public boolean publishEnabled() {
|
||||||
return publishEnabled(nativePtr);
|
return publishEnabled(nativePtr);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void setContactParameters(String params) {
|
||||||
|
setContactParameters(nativePtr, params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit cc7a707754f028a36dd2dfee914b93f431419622
|
Subproject commit 62ce92ff69c6920bbd71c4b4276fd5b4a843b3d2
|
Loading…
Reference in a new issue