From 982b383ffdfa9c6792560dc0b977bfe65b9b5bb3 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 14 Nov 2011 15:37:03 +0100 Subject: [PATCH] Improve ZRTP GUI + setAuthenticationVerified --- README | 2 + res/drawable/conf_maybe_secured.png | Bin 0 -> 871 bytes res/layout/conf_callee.xml | 1 + res/layout/conf_callee_older_devices.xml | 4 +- res/layout/conf_choices_dialog.xml | 43 ++++++++++-------- res/values/strings.xml | 4 +- src/org/linphone/IncallActivity.java | 28 +++++++++--- src/org/linphone/LinphoneActivity.java | 9 ++++ src/org/linphone/core/LinphoneCallImpl.java | 11 +++-- submodules/linphone | 2 +- test/org/linphone/TestConferenceActivity.java | 7 ++- 11 files changed, 79 insertions(+), 32 deletions(-) create mode 100644 res/drawable/conf_maybe_secured.png diff --git a/README b/README index 9ac244430..5a133c2c7 100644 --- a/README +++ b/README @@ -20,6 +20,8 @@ BUILD_AMR 0 (don't build amr codec), light (try to use amr codec fro BUILD_GPLV3_ZRTP 0 (don't support ZRTP), 1 (support ZRTP and make the whole program GPLv3) BUILD_SILK 0 (don't build silk plugin), 1 (build silk) [silk is Skype nonfree patented audio codec] +In order to use ZRTP you also need to define the media_encryption property to +"zrtp" in the sip section of linphonerc file. diff --git a/res/drawable/conf_maybe_secured.png b/res/drawable/conf_maybe_secured.png new file mode 100644 index 0000000000000000000000000000000000000000..106cf427dcc94a6d125b3fb31cfed3af9ed3c3cc GIT binary patch literal 871 zcmV-t1DO1YP)P000*V1^@s6{^R5m00001b5ch_0Itp) z=>Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01ejw01ejxLMWSf00007bV*G`2ipq{ z4gnM@eaKh<00QSpL_t(Y$F)^WPZL2HerC4a#kP?|F)g%6&{lyp>JK1r;BLH_m|i`= z$;6WqDcOLD(IdAWxHi#)H{*#ztG__fQbQ31s#Y6KK!ld=jEDW4cDp4ePO{0)yfg3f zem*bopVkL$$o>zU=0PQ$?kY>>a`yl3g9HvD9Gnoem~)5tDKD?yLSQY@(}{660)Z=rT5gsd2MmDBu&aRVb>Qcj z1*&RQu`4*Rk+}$J=~HN*X@CfzXH{l`Z~$D-s?0p&rkor5x&gGbE2v&qle6_5-FI>skVhWT7RJR$IM( zeldq&Y#efQ403E7?9VS8|JXq6#@(J15`aMWI;FU-?RYmu_1!A^;#VO@$8l0CqggBC z_sW`k+;S7pv!NQP0;Hp3j6JWnJLIhR7BT*X!}O#qN&F2~yS`~^%Z6+js5{A~aL002ovPDHLkV1hzVeN_Me literal 0 HcmV?d00001 diff --git a/res/layout/conf_callee.xml b/res/layout/conf_callee.xml index 0bd5317a1..a63fea3a4 100644 --- a/res/layout/conf_callee.xml +++ b/res/layout/conf_callee.xml @@ -34,6 +34,7 @@ + diff --git a/res/layout/conf_callee_older_devices.xml b/res/layout/conf_callee_older_devices.xml index 6b5461026..3b21cd493 100644 --- a/res/layout/conf_callee_older_devices.xml +++ b/res/layout/conf_callee_older_devices.xml @@ -41,7 +41,9 @@ android:src="@drawable/conf_status_inconf" /> + android:src="@drawable/conf_secured" android:visibility="gone"/> + diff --git a/res/layout/conf_choices_dialog.xml b/res/layout/conf_choices_dialog.xml index 64892c0b8..0fa51dc93 100644 --- a/res/layout/conf_choices_dialog.xml +++ b/res/layout/conf_choices_dialog.xml @@ -7,9 +7,27 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> + + + + + + + + + + + + - @@ -17,7 +35,7 @@ - @@ -25,7 +43,7 @@ - @@ -34,7 +52,7 @@ - @@ -42,7 +60,7 @@ - @@ -50,7 +68,7 @@ - @@ -58,22 +76,11 @@ - - - - - - - - - - \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 3d965d768..f8b12ca23 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -3,8 +3,8 @@ Not ready for a new call Bad contact : %s - Authentication token is %s - Communication not encrypted + Encrypted %s + Not encrypted Starting up... An error occurred while accepting call diff --git a/src/org/linphone/IncallActivity.java b/src/org/linphone/IncallActivity.java index 5a573aa87..921a3469e 100644 --- a/src/org/linphone/IncallActivity.java +++ b/src/org/linphone/IncallActivity.java @@ -508,6 +508,15 @@ public class IncallActivity extends ListActivity implements LinphoneActivity.instance().startVideoActivity(call, 0); } break; + case R.id.set_auth_token_verified: + call.setAuthenticationTokenVerified(true); + break; + case R.id.set_auth_token_not_verified: + call.setAuthenticationTokenVerified(false); + break; + case R.id.encrypted: + call.setAuthenticationTokenVerified(!call.isAuthenticationTokenVerified()); + break; default: throw new RuntimeException("unknown id " + v.getId()); } @@ -673,9 +682,12 @@ public class IncallActivity extends ListActivity implements if ("none".equals(mediaEncryption)) { boolean showUnencrypted = Version.hasZrtp(); setVisibility(v, R.id.callee_status_secured, false); + setVisibility(v, R.id.callee_status_maybe_secured, false); setVisibility(v, R.id.callee_status_not_secured, showUnencrypted); } else { - setVisibility(v, R.id.callee_status_secured, true); + boolean reallySecured = !Version.hasZrtp() || call.isAuthenticationTokenVerified(); + setVisibility(v, R.id.callee_status_secured, reallySecured); + setVisibility(v, R.id.callee_status_maybe_secured, !reallySecured); setVisibility(v, R.id.callee_status_not_secured, false); } @@ -698,15 +710,19 @@ public class IncallActivity extends ListActivity implements String mediaEncryption = call.getCurrentParamsCopy().getMediaEncryption(); if ("none".equals(mediaEncryption)) { boolean showUnencrypted = Version.hasZrtp(); - setVisibility(content, R.id.encrypted, false); setVisibility(content, R.id.unencrypted, showUnencrypted); } else { - setVisibility(content, R.id.encrypted, true); - setVisibility(content, R.id.unencrypted, false); + TextView token = (TextView) content.findViewById(R.id.authentication_token); + String fmt = getString(R.string.authenticationTokenFormat); if ("zrtp".equals(mediaEncryption)) { - TextView token = (TextView) content.findViewById(R.id.authentication_token); - String fmt = getString(R.string.authenticationTokenFormat); token.setText(String.format(fmt, call.getAuthenticationToken())); + boolean authVerified = call.isAuthenticationTokenVerified(); + enableView(content, R.id.set_auth_token_not_verified, l, authVerified); + enableView(content, R.id.set_auth_token_verified, l, !authVerified); + enableView(content, R.id.encrypted, l, true); + } else { + setVisibility(content, R.id.encrypted, true); + token.setText(String.format(fmt, "")); } } diff --git a/src/org/linphone/LinphoneActivity.java b/src/org/linphone/LinphoneActivity.java index 83a90aa1a..54495e3d8 100644 --- a/src/org/linphone/LinphoneActivity.java +++ b/src/org/linphone/LinphoneActivity.java @@ -36,6 +36,7 @@ import org.linphone.mediastream.Version; import org.linphone.mediastream.video.AndroidVideoWindowImpl; import android.app.AlertDialog; +import android.app.Dialog; import android.app.TabActivity; import android.content.Context; import android.content.DialogInterface; @@ -103,6 +104,14 @@ public class LinphoneActivity extends TabActivity implements throw new RuntimeException("LinphoneActivity not instantiated yet"); } + @Override + protected Dialog onCreateDialog(final int id) { + if (id == LinphoneManagerWaitHelper.DIALOG_ID) { + return waitHelper.createWaitDialog(); + } + return super.onCreateDialog(id); + } + public void onCreate(Bundle savedInstanceState) { instance = this; super.onCreate(savedInstanceState); diff --git a/src/org/linphone/core/LinphoneCallImpl.java b/src/org/linphone/core/LinphoneCallImpl.java index 2550367cb..802801155 100644 --- a/src/org/linphone/core/LinphoneCallImpl.java +++ b/src/org/linphone/core/LinphoneCallImpl.java @@ -39,9 +39,6 @@ class LinphoneCallImpl implements LinphoneCall { private native int getDuration(long nativePtr); private native float getCurrentQuality(long nativePtr); private native float getAverageQuality(long nativePtr); - private native String getAuthenticationToken(long nativePtr); - private native boolean isAuthenticationTokenVerified(long nativePtr); - private native boolean areStreamsEncrypted(long nativePtr); /* * This method must always be called from JNI, nothing else. @@ -126,13 +123,21 @@ class LinphoneCallImpl implements LinphoneCall { return getCurrentQuality(nativePtr); } + private native String getAuthenticationToken(long nativePtr); public String getAuthenticationToken(){ return getAuthenticationToken(nativePtr); } + + private native boolean isAuthenticationTokenVerified(long nativePtr); public boolean isAuthenticationTokenVerified(){ return isAuthenticationTokenVerified(nativePtr); } + private native boolean setAuthenticationTokenVerified(long nativePtr, boolean verified); + public void setAuthenticationTokenVerified(boolean verified){ + setAuthenticationTokenVerified(nativePtr, verified); + } + public boolean isInConference() { LinphoneCallParamsImpl params = new LinphoneCallParamsImpl(getCurrentParamsCopy(nativePtr)); return params.localConferenceMode(); diff --git a/submodules/linphone b/submodules/linphone index 91b606875..ce510f9d1 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 91b606875d8ccbbf80191e189e2714a4e11a4763 +Subproject commit ce510f9d1fa8d66aabcca308f0d2a9174f68acd4 diff --git a/test/org/linphone/TestConferenceActivity.java b/test/org/linphone/TestConferenceActivity.java index b308049df..a8bd25759 100644 --- a/test/org/linphone/TestConferenceActivity.java +++ b/test/org/linphone/TestConferenceActivity.java @@ -402,7 +402,6 @@ public class TestConferenceActivity extends IncallActivity { remoteAddress = new LinphoneAddressTest(name, number); } - public boolean areStreamsEncrypted() {return false;} public void enableCamera(boolean enabled) {} public void enableEchoCancellation(boolean enable) {} public void enableEchoLimiter(boolean enable) {} @@ -421,6 +420,12 @@ public class TestConferenceActivity extends IncallActivity { public boolean isEchoLimiterEnabled() {return false;} public boolean isInConference() { return inConf;} public boolean cameraEnabled() {return false;} + + @Override + public void setAuthenticationTokenVerified(boolean verified) { + // TODO Auto-generated method stub + + } }