diff --git a/.classpath b/.classpath
index c6e88a7fc..3c6c7d621 100644
--- a/.classpath
+++ b/.classpath
@@ -10,5 +10,6 @@
+
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index 0f00d3424..e47295d10 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -4,6 +4,12 @@
android:versionCode="2000" android:versionName="2.0" android:installLocation="auto">
+
+
+
+
+
+
@@ -99,6 +105,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/libs/gcm.jar b/libs/gcm.jar
new file mode 100644
index 000000000..ac109a830
Binary files /dev/null and b/libs/gcm.jar differ
diff --git a/res/values/non_localizable_custom.xml b/res/values/non_localizable_custom.xml
index 1f39d0017..16a209e19 100644
--- a/res/values/non_localizable_custom.xml
+++ b/res/values/non_localizable_custom.xml
@@ -1,6 +1,9 @@
-
+
+ true
+ 175894229314
+ 175894229314
sip.linphone.org
https://www.linphone.org/wizard.php
diff --git a/src/org/linphone/GCMIntentService.java b/src/org/linphone/GCMIntentService.java
new file mode 100644
index 000000000..27f87206a
--- /dev/null
+++ b/src/org/linphone/GCMIntentService.java
@@ -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();
+ }
+}
diff --git a/src/org/linphone/LinphoneLauncherActivity.java b/src/org/linphone/LinphoneLauncherActivity.java
index e9182df67..0cebee061 100644
--- a/src/org/linphone/LinphoneLauncherActivity.java
+++ b/src/org/linphone/LinphoneLauncherActivity.java
@@ -20,6 +20,7 @@ package org.linphone;
import static android.content.Intent.ACTION_MAIN;
+import org.linphone.core.Log;
import org.linphone.mediastream.Version;
import android.app.Activity;
@@ -28,6 +29,8 @@ import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
+import com.google.android.gcm.GCMRegistrar;
+
/**
*
* Launch Linphone main activity when Service is ready.
@@ -54,6 +57,18 @@ public class LinphoneLauncherActivity extends Activity {
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()) {
onServiceReady();
} else {
diff --git a/src/org/linphone/LinphoneManager.java b/src/org/linphone/LinphoneManager.java
index 4c9586707..7b8a64e26 100644
--- a/src/org/linphone/LinphoneManager.java
+++ b/src/org/linphone/LinphoneManager.java
@@ -618,7 +618,14 @@ public final class LinphoneManager implements LinphoneCoreListener {
if (!proxy.startsWith("sip:")) {
proxy = "sip:" + proxy;
}
+
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);
//outbound proxy
diff --git a/src/org/linphone/core/LinphoneProxyConfigImpl.java b/src/org/linphone/core/LinphoneProxyConfigImpl.java
index cf5b3a304..0b7aa7f6e 100644
--- a/src/org/linphone/core/LinphoneProxyConfigImpl.java
+++ b/src/org/linphone/core/LinphoneProxyConfigImpl.java
@@ -75,7 +75,7 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
private native int setRoute(long ptr,String uri);
private native void enablePublish(long ptr,boolean enable);
private native boolean publishEnabled(long ptr);
-
+ private native void setContactParameters(long ptr, String params);
public void enableRegister(boolean value) {
enableRegister(nativePtr,value);
@@ -143,4 +143,8 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig {
public boolean publishEnabled() {
return publishEnabled(nativePtr);
}
+ @Override
+ public void setContactParameters(String params) {
+ setContactParameters(nativePtr, params);
+ }
}
diff --git a/submodules/linphone b/submodules/linphone
index cc7a70775..62ce92ff6 160000
--- a/submodules/linphone
+++ b/submodules/linphone
@@ -1 +1 @@
-Subproject commit cc7a707754f028a36dd2dfee914b93f431419622
+Subproject commit 62ce92ff69c6920bbd71c4b4276fd5b4a843b3d2