builder.setContentTitle(getString(s));
if (!publicVersion)
{
- Intent intent = new Intent(getApplicationContext(), CharonVpnService.class);
- intent.setAction(CharonVpnService.DISCONNECT_ACTION);
- PendingIntent pending = PendingIntent.getService(getApplicationContext(), 0, intent,
- PendingIntent.FLAG_ONE_SHOT);
+ Intent intent = new Intent(getApplicationContext(), MainActivity.class);
+ intent.setAction(MainActivity.DISCONNECT);
+ PendingIntent pending = PendingIntent.getActivity(getApplicationContext(), 0, intent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
builder.addAction(R.drawable.ic_notification_disconnect, getString(R.string.disconnect), pending);
builder.setContentText(name);
builder.setPublicVersion(buildNotification(true));
* Copyright (C) 2012-2017 Tobias Brunner
* Copyright (C) 2012 Giuliano Grassi
* Copyright (C) 2012 Ralf Sager
- * Hochschule fuer Technik Rapperswil
+ * HSR Hochschule fuer Technik Rapperswil
*
* 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
{
public static final String CONTACT_EMAIL = "android@strongswan.org";
public static final String START_PROFILE = "org.strongswan.android.action.START_PROFILE";
+ public static final String DISCONNECT = "org.strongswan.android.action.DISCONNECT";
public static final String EXTRA_VPN_PROFILE_ID = "org.strongswan.android.VPN_PROFILE_ID";
/**
* Use "bring your own device" (BYOD) features
private static final String PROFILE_NAME = "org.strongswan.android.MainActivity.PROFILE_NAME";
private static final String PROFILE_REQUIRES_PASSWORD = "org.strongswan.android.MainActivity.REQUIRES_PASSWORD";
private static final String PROFILE_RECONNECT = "org.strongswan.android.MainActivity.RECONNECT";
+ private static final String PROFILE_DISCONNECT = "org.strongswan.android.MainActivity.DISCONNECT";
private static final String DIALOG_TAG = "Dialog";
private Bundle mProfileInfo;
{
startVpnProfile(getIntent());
}
+ else if (DISCONNECT.equals(getIntent().getAction()))
+ {
+ disconnect();
+ }
}
};
{
startVpnProfile(intent);
}
+ else if (DISCONNECT.equals(intent.getAction()))
+ {
+ disconnect();
+ }
}
@Override
}
}
+ /**
+ * Disconnect the current connection, if any (silently ignored if there is no connection).
+ */
+ private void disconnect()
+ {
+ removeFragmentByTag(DIALOG_TAG);
+
+ if (mService != null && (mService.getState() == State.CONNECTED || mService.getState() == State.CONNECTING))
+ {
+ Bundle args = new Bundle();
+ args.putBoolean(PROFILE_DISCONNECT, true);
+
+ ConfirmationDialog dialog = new ConfirmationDialog();
+ dialog.setArguments(args);
+ dialog.show(this.getSupportFragmentManager(), DIALOG_TAG);
+ return;
+ }
+ }
+
/**
* Class that loads the cached CA certificates.
*/
message = R.string.vpn_profile_connected;
button = R.string.reconnect;
}
+ else if (profileInfo.getBoolean(PROFILE_DISCONNECT))
+ {
+ title = R.string.disconnect_question;
+ message = R.string.disconnect_active_connection;
+ button = R.string.disconnect;
+ }
return new AlertDialog.Builder(getActivity())
.setIcon(icon)
public void onClick(DialogInterface dialog, int whichButton)
{
MainActivity activity = (MainActivity)getActivity();
- activity.startVpnProfile(profileInfo);
+ if (profileInfo.getBoolean(PROFILE_DISCONNECT))
+ {
+ if (activity.mService != null)
+ {
+ activity.mService.disconnect();
+ }
+ }
+ else
+ {
+ activity.startVpnProfile(profileInfo);
+ }
}
})
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener()
<string name="reconnect">Neu verbinden</string>
<string name="connect_profile_question">Verbinde %1$s?</string>
<string name="replaces_active_connection">Dies ersetzt die aktuelle VPN Verbindung!</string>
+ <string name="disconnect_question">VPN Verbindung trennen?</string>
+ <string name="disconnect_active_connection">Dies trennt die aktuelle VPN Verbindung!</string>
<string name="connect">Verbinden</string>
</resources>
<string name="reconnect">Połączyć ponownie</string>
<string name="connect_profile_question">Połącz %1$s?</string>
<string name="replaces_active_connection">To zastąpi aktywne połączenie VPN!</string>
+ <string name="disconnect_question">Disconnect VPN?</string>
+ <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
<string name="connect">Połącz</string>
</resources>
<string name="reconnect">Переподключить</string>
<string name="connect_profile_question">Подключить %1$s?</string>
<string name="replaces_active_connection">Это заменит ваше текущее VPN соединение!</string>
+ <string name="disconnect_question">Disconnect VPN?</string>
+ <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
<string name="connect">Соединить</string>
</resources>
<string name="reconnect">Перепідключитися</string>
<string name="connect_profile_question">Підключити %1$s?</string>
<string name="replaces_active_connection">Ця дія замінить ваше поточне VPN з\'єднання!</string>
+ <string name="disconnect_question">Disconnect VPN?</string>
+ <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
<string name="connect">Підключити</string>
</resources>
<string name="reconnect">重连</string>
<string name="connect_profile_question">是否连接%1$s?</string>
<string name="replaces_active_connection">这将覆盖您当前活跃的VPN连接!</string>
+ <string name="disconnect_question">Disconnect VPN?</string>
+ <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
<string name="connect">连接</string>
</resources>
<string name="reconnect">重新連線</string>
<string name="connect_profile_question">是否連線%1$s?</string>
<string name="replaces_active_connection">這將會覆蓋您當前運作的VPN連線!</string>
+ <string name="disconnect_question">Disconnect VPN?</string>
+ <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
<string name="connect">連線</string>
</resources>
<string name="reconnect">Reconnect</string>
<string name="connect_profile_question">Connect %1$s?</string>
<string name="replaces_active_connection">This will replace your active VPN connection!</string>
+ <string name="disconnect_question">Disconnect VPN?</string>
+ <string name="disconnect_active_connection">This will disconnect the active VPN connection!</string>
<string name="connect">Connect</string>
</resources>