changed debian/source/format to native

This commit is contained in:
openKylinBot 2022-05-14 02:28:45 +08:00
parent 4429d98ddf
commit 966b595a16
9 changed files with 1 additions and 988 deletions

View File

@ -1,332 +0,0 @@
From: Michael Biebl <biebl@debian.org>
Date: Tue, 18 Mar 2014 10:49:13 +0100
Subject: Allow creation of connections without admin privileges
Set passwords as agent-owned when they need to, to allow users without
root permissions to easily configure their connections.
The logic is:
- Bluetooth, CDMA and GSM connections: always user-owned
- WEP/WPA connections: system-owned if user has the permissions
(with NM's config, that is netdev or sudo membership), user-owned
otherwise. The password is stored in the keyring for WPA, not for
WEP.
- WiMax / Wired connections: always system-owned (with 802.1x
passwords in the keyring).
Closes: #696256
---
src/applet-device-wifi.c | 28 ++++++++++++++++++++++++++--
src/connection-editor/page-mobile.c | 10 ++++++++++
src/connection-editor/page-vpn.c | 8 ++++++++
src/connection-editor/page-wifi.c | 13 +++++++++++++
src/libnm-gtk/nm-wifi-dialog.c | 4 ++++
src/mobile-helpers.c | 3 +++
src/utils/utils.c | 8 ++++++++
src/utils/utils.h | 4 ++++
src/wireless-security/ws-wep-key.c | 7 +++++++
src/wireless-security/ws-wpa-psk.c | 5 +++++
10 files changed, 88 insertions(+), 2 deletions(-)
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 0f1043c..8ce4bd1 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -444,9 +444,10 @@ wifi_new_auto_connection (NMDevice *device,
NMConnection *connection;
NMSettingConnection *s_con;
NMSettingWireless *s_wifi = NULL;
- NMSettingWirelessSecurity *s_wsec;
+ NMSettingWirelessSecurity *s_wsec = NULL;
NMSetting8021x *s_8021x = NULL;
GBytes *ssid;
+ NM80211ApFlags flags;
NM80211ApSecurityFlags wpa_flags, rsn_flags;
GtkWidget *dialog;
MoreInfo *more_info;
@@ -464,7 +465,6 @@ wifi_new_auto_connection (NMDevice *device,
/* Make the new connection available only for the current user */
s_con = (NMSettingConnection *) nm_setting_connection_new ();
- nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
nm_connection_add_setting (connection, NM_SETTING (s_con));
ssid = nm_access_point_get_ssid (ap);
@@ -482,6 +482,7 @@ wifi_new_auto_connection (NMDevice *device,
/* If the AP is WPA[2]-Enterprise then we need to set up a minimal 802.1x
* setting and ask the user for more information.
*/
+ flags = nm_access_point_get_flags (ap);
rsn_flags = nm_access_point_get_rsn_flags (ap);
wpa_flags = nm_access_point_get_wpa_flags (ap);
if ( (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
@@ -510,6 +511,29 @@ wifi_new_auto_connection (NMDevice *device,
nm_connection_add_setting (connection, NM_SETTING (s_8021x));
}
+ if (utils_default_to_private_connection (applet->nm_client)) {
+ if (!s_con) {
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_con));
+ }
+ nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+
+ if ((rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK) ||
+ (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)) {
+ if (!s_wsec) {
+ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_wsec));
+ }
+ g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);
+ } else if (flags & NM_802_11_AP_FLAGS_PRIVACY) {
+ if (!s_wsec) {
+ s_wsec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_wsec));
+ }
+ g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);
+ }
+ }
+
/* If it's an 802.1x connection, we need more information, so pop up the
* Dialog Of Doom.
*/
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
index 16621cb..5a8f79e 100644
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -425,6 +425,7 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
WizardInfo *info = user_data;
if (!canceled && method) {
+ NMSettingConnection *s_con;
NMSetting *type_setting;
const char *ctype = NULL;
char *detail = NULL;
@@ -438,6 +439,7 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
NM_SETTING_GSM_NUMBER, "*99#",
NM_SETTING_GSM_USERNAME, method->username,
NM_SETTING_GSM_PASSWORD, method->password,
+ NM_SETTING_GSM_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
NM_SETTING_GSM_APN, method->gsm_apn,
NULL);
break;
@@ -449,6 +451,7 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
NM_SETTING_CDMA_NUMBER, "#777",
NM_SETTING_GSM_USERNAME, method->username,
NM_SETTING_GSM_PASSWORD, method->password,
+ NM_SETTING_GSM_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
NULL);
break;
default:
@@ -469,6 +472,13 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
info->client);
g_free (detail);
+ s_con = nm_connection_get_setting_connection (info->connection);
+ if (!s_con) {
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ nm_connection_add_setting (info->connection, NM_SETTING (s_con));
+ }
+ nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+
nm_connection_add_setting (info->connection, type_setting);
nm_connection_add_setting (info->connection, nm_setting_ppp_new ());
}
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 5b35172..32d49bb 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -221,6 +221,7 @@ vpn_connection_new (FUNC_TAG_PAGE_NEW_CONNECTION_IMPL,
gpointer user_data)
{
NMSetting *s_vpn;
+ NMSettingConnection *s_con;
const char *service_type;
gs_free char *service_type_free = NULL;
gs_free char *add_detail_key_free = NULL;
@@ -294,6 +295,13 @@ vpn_connection_new (FUNC_TAG_PAGE_NEW_CONNECTION_IMPL,
if (!service_type)
service_type = detail;
+ s_con = nm_connection_get_setting_connection (connection);
+ if (!s_con) {
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_con));
+ }
+ nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+
s_vpn = nm_setting_vpn_new ();
g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, service_type, NULL);
diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c
index 2ff80d4..0fbfa97 100644
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -12,6 +12,8 @@
#include <math.h>
#include "nm-connection-editor.h"
+#include "utils.h"
+
#include "page-wifi.h"
G_DEFINE_TYPE (CEPageWifi, ce_page_wifi, CE_TYPE_PAGE)
@@ -601,6 +603,17 @@ wifi_connection_new (FUNC_TAG_PAGE_NEW_CONNECTION_IMPL,
NM_SETTING_WIRELESS_SETTING_NAME,
TRUE,
client);
+
+ if (utils_default_to_private_connection (client)) {
+ NMSettingConnection *s_con;
+ s_con = nm_connection_get_setting_connection (connection);
+ if (!s_con) {
+ s_con = (NMSettingConnection *) nm_setting_connection_new ();
+ nm_connection_add_setting (connection, NM_SETTING (s_con));
+ }
+ nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+ }
+
s_wifi = nm_setting_wireless_new ();
g_object_set (s_wifi, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
nm_connection_add_setting (connection, s_wifi);
diff --git a/src/libnm-gtk/nm-wifi-dialog.c b/src/libnm-gtk/nm-wifi-dialog.c
index 145742f..68ac06f 100644
--- a/src/libnm-gtk/nm-wifi-dialog.c
+++ b/src/libnm-gtk/nm-wifi-dialog.c
@@ -22,6 +22,7 @@
#include "wireless-security.h"
#include "nm-ui-utils.h"
#include "eap-method.h"
+#include "utils.h"
G_DEFINE_TYPE (NMAWifiDialog, nma_wifi_dialog, GTK_TYPE_DIALOG)
@@ -1204,6 +1205,9 @@ nma_wifi_dialog_get_connection (NMAWifiDialog *self,
NM_SETTING_CONNECTION_UUID, uuid,
NULL);
g_free (uuid);
+ if (utils_default_to_private_connection (priv->client)) {
+ nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
+ }
nm_connection_add_setting (connection, (NMSetting *) s_con);
s_wireless = (NMSettingWireless *) nm_setting_wireless_new ();
diff --git a/src/mobile-helpers.c b/src/mobile-helpers.c
index 54f250b..0d0554f 100644
--- a/src/mobile-helpers.c
+++ b/src/mobile-helpers.c
@@ -168,6 +168,7 @@ mobile_wizard_done (NMAMobileWizard *wizard,
NM_SETTING_CDMA_NUMBER, "#777",
NM_SETTING_CDMA_USERNAME, method->username,
NM_SETTING_CDMA_PASSWORD, method->password,
+ NM_SETTING_CDMA_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
NULL);
nm_connection_add_setting (connection, setting);
} else if (method->devtype == NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) {
@@ -178,6 +179,7 @@ mobile_wizard_done (NMAMobileWizard *wizard,
NM_SETTING_GSM_USERNAME, method->username,
NM_SETTING_GSM_PASSWORD, method->password,
NM_SETTING_GSM_APN, method->gsm_apn,
+ NM_SETTING_GSM_PASSWORD_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED,
NULL);
nm_connection_add_setting (connection, setting);
} else
@@ -208,6 +210,7 @@ mobile_wizard_done (NMAMobileWizard *wizard,
"user", g_get_user_name (), NULL);
g_free (uuid);
g_free (id);
+ nm_setting_connection_add_permission ((NMSettingConnection *) setting, "user", g_get_user_name (), NULL);
nm_connection_add_setting (connection, setting);
}
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 3a6f07e..1d8b4af 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -557,3 +557,11 @@ utils_key_filter (void)
return filter;
}
+
+gboolean
+utils_default_to_private_connection (NMClient *client)
+{
+ NMClientPermissionResult perms;
+ perms = nm_client_get_permission_result (client, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
+ return (perms != NM_CLIENT_PERMISSION_RESULT_YES);
+}
diff --git a/src/utils/utils.h b/src/utils/utils.h
index d57f3a1..9db3202 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -11,6 +11,8 @@
#include <net/ethernet.h>
+#include <nm-client.h>
+
gboolean utils_ether_addr_valid (const struct ether_addr *test_addr);
#if LIBNM_BUILD
@@ -38,6 +40,8 @@ void utils_show_error_dialog (const char *title,
gboolean modal,
GtkWindow *parent);
+gboolean utils_default_to_private_connection (NMClient *client);
+
#define NMA_ERROR (g_quark_from_static_string ("nma-error-quark"))
typedef enum {
diff --git a/src/wireless-security/ws-wep-key.c b/src/wireless-security/ws-wep-key.c
index fc5a4b7..610bdf2 100644
--- a/src/wireless-security/ws-wep-key.c
+++ b/src/wireless-security/ws-wep-key.c
@@ -155,6 +155,7 @@ static void
fill_connection (WirelessSecurity *parent, NMConnection *connection)
{
WirelessSecurityWEPKey *sec = (WirelessSecurityWEPKey *) parent;
+ NMSettingConnection *s_con;
NMSettingWirelessSecurity *s_wsec;
NMSettingSecretFlags secret_flags;
GtkWidget *widget, *passwd_entry;
@@ -181,6 +182,12 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
NM_SETTING_WIRELESS_SECURITY_WEP_KEY_TYPE, sec->type,
NULL);
+ s_con = nm_connection_get_setting_connection (connection);
+
+ /* If the connection is user-owned, mark the secrets as agent-owned */
+ if (s_con && nm_setting_connection_get_num_permissions (s_con))
+ g_object_set (s_wsec, NM_SETTING_WIRELESS_SECURITY_WEP_KEY_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);
+
for (i = 0; i < 4; i++) {
if (strlen (sec->keys[i]))
nm_setting_wireless_security_set_wep_key (s_wsec, i, sec->keys[i]);
diff --git a/src/wireless-security/ws-wpa-psk.c b/src/wireless-security/ws-wpa-psk.c
index 5f0df4d..eb8f4c1 100644
--- a/src/wireless-security/ws-wpa-psk.c
+++ b/src/wireless-security/ws-wpa-psk.c
@@ -97,12 +97,14 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
WirelessSecurityWPAPSK *wpa_psk = (WirelessSecurityWPAPSK *) parent;
GtkWidget *widget, *passwd_entry;
const char *key;
+ NMSettingConnection *s_con;
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
NMSettingSecretFlags secret_flags;
const char *mode;
gboolean is_adhoc = FALSE;
+ s_con = nm_connection_get_setting_connection (connection);
s_wireless = nm_connection_get_setting_wireless (connection);
g_assert (s_wireless);
@@ -118,6 +120,9 @@ fill_connection (WirelessSecurity *parent, NMConnection *connection)
passwd_entry = widget;
key = gtk_editable_get_text (GTK_EDITABLE (widget));
g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, key, NULL);
+ /* If the connection is user-owned, mark the secrets as agent-owned */
+ if (s_con && nm_setting_connection_get_num_permissions (s_con))
+ g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK_FLAGS, NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);
/* Save PSK_FLAGS to the connection */
secret_flags = nma_utils_menu_to_secret_flags (passwd_entry);

View File

@ -1,30 +0,0 @@
From: Michael Biebl <biebl@debian.org>
Date: Tue, 18 Mar 2014 10:49:13 +0100
Subject: Force online state with unmanaged devices
If NM has an active unmanaged device it will forcefully set the online
state to CONNECTED_GLOBAL. In that case show a wired connection icon
instead of an offline icon.
Closes: #471191
---
src/applet.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/applet.c b/src/applet.c
index 42d4478..ac4f03d 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2679,6 +2679,12 @@ applet_update_icon (gpointer user_data)
applet_get_device_icon_for_state (applet, &pixbuf, &icon_name_free, &dev_tip_free);
icon_name = icon_name_free;
dev_tip = dev_tip_free;
+ if (!pixbuf && ( state == NM_STATE_CONNECTED_LOCAL
+ || state == NM_STATE_CONNECTED_SITE
+ || state == NM_STATE_CONNECTED_GLOBAL)) {
+ icon_name = g_strdup ("nm-device-wired");
+ pixbuf = g_object_ref (nma_icon_check_and_load (icon_name, applet));
+ }
break;
}

View File

@ -1,35 +0,0 @@
From: Mathieu Trudel-Lapierre <mathieu@canonical.com>
Date: Fri, 20 May 2016 14:32:07 +0800
Subject: Have the appindicator enabled by default.
---
src/main.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/main.c b/src/main.c
index 2308e61..b31c65f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -17,7 +17,7 @@
gboolean shell_debug = FALSE;
gboolean with_agent = TRUE;
-gboolean with_appindicator = FALSE;
+gboolean with_appindicator = TRUE;
static void
usage (const char *progname)
@@ -47,11 +47,9 @@ int main (int argc, char *argv[])
shell_debug = TRUE;
else if (!strcmp (argv[i], "--no-agent"))
with_agent = FALSE;
- else if (!strcmp (argv[i], "--indicator")) {
+ else if (!strcmp (argv[i], "--no-indicator")) {
#ifdef WITH_APPINDICATOR
- with_appindicator = TRUE;
-#else
- g_error ("Error: --indicator requested but indicator support not available");
+ with_appindicator = FALSE;
#endif
}
}

View File

@ -1,127 +0,0 @@
From: =?utf-8?q?Antti_Kaijanm=C3=A4ki?= <antti.kaijanmaki@canonical.com>
Date: Tue, 24 May 2016 13:37:12 +0800
Subject: Make policykit-restricted actions insensitive
Make sure the behavior for policykit-restricted actions is
consistently to make the items insensitive
---
src/applet-device-wifi.c | 29 +++++++++++++++++++++++++++++
src/applet.c | 30 ++++++++++++++++++++++++++++--
2 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 37b2121..407f7e0 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -203,6 +203,8 @@ nma_menu_add_hidden_network_item (GtkWidget *menu, NMApplet *applet)
{
GtkWidget *menu_item;
GtkWidget *label;
+ gboolean allowed;
+ NMClientPermissionResult perm;
menu_item = gtk_menu_item_new ();
label = gtk_label_new_with_mnemonic (_("_Connect to Hidden Wi-Fi Network…"));
@@ -213,6 +215,33 @@ nma_menu_add_hidden_network_item (GtkWidget *menu, NMApplet *applet)
g_signal_connect_swapped (menu_item, "activate",
G_CALLBACK (applet_wifi_connect_to_hidden_network),
applet);
+
+ allowed = FALSE;
+ perm = nm_client_get_permission_result (applet->nm_client,
+ NM_CLIENT_PERMISSION_NETWORK_CONTROL);
+ if ( perm == NM_CLIENT_PERMISSION_RESULT_YES
+ || perm == NM_CLIENT_PERMISSION_RESULT_AUTH) {
+ /* First, the user has to be able to control networks
+ * to connect to a new hidden access point.
+ */
+ perm = nm_client_get_permission_result (applet->nm_client,
+ NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN);
+ if ( perm == NM_CLIENT_PERMISSION_RESULT_YES
+ || perm == NM_CLIENT_PERMISSION_RESULT_AUTH) {
+ /* The user can modify (and add!) a new configuration for herself. */
+ allowed = TRUE;
+ } else {
+ perm = nm_client_get_permission_result (applet->nm_client,
+ NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM);
+ if ( perm == NM_CLIENT_PERMISSION_RESULT_YES
+ || perm == NM_CLIENT_PERMISSION_RESULT_AUTH) {
+ /* The user can modify (and add!) a new system wide configuration. */
+ allowed = TRUE;
+ }
+ }
+ }
+
+ gtk_widget_set_sensitive (GTK_WIDGET (menu_item), allowed);
}
gboolean
diff --git a/src/applet.c b/src/applet.c
index a13808c..7a0f041 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -50,6 +50,8 @@ extern gboolean with_appindicator;
G_DEFINE_TYPE (NMApplet, nma, G_TYPE_APPLICATION)
+static gboolean is_permission_yes (NMApplet *applet, NMClientPermission perm);
+
/********************************************************************/
static gboolean
@@ -1323,7 +1325,10 @@ nma_menu_device_get_menu_item (NMDevice *device,
G_CALLBACK (applet_device_disconnect_db),
info,
applet_device_info_destroy, 0);
- gtk_widget_set_sensitive (item, TRUE);
+ if (is_permission_yes (applet, NM_CLIENT_PERMISSION_NETWORK_CONTROL))
+ gtk_widget_set_sensitive (item, TRUE);
+ else
+ gtk_widget_set_sensitive (item, FALSE);
break;
}
default:
@@ -1482,7 +1487,8 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
state = nm_client_get_state (applet->nm_client);
if ( state != NM_STATE_CONNECTED_LOCAL
&& state != NM_STATE_CONNECTED_SITE
- && state != NM_STATE_CONNECTED_GLOBAL)
+ && state != NM_STATE_CONNECTED_GLOBAL
+ && !is_permission_yes (applet, NM_CLIENT_PERMISSION_NETWORK_CONTROL))
gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
else
gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
@@ -1508,6 +1514,12 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
g_signal_connect (item, "activate", G_CALLBACK (nma_menu_add_vpn_item_activate), applet);
}
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
+ if ( is_permission_yes (applet, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM)
+ || is_permission_yes (applet, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN)) {
+ gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
+ } else {
+ gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
+ }
gtk_widget_show (GTK_WIDGET (item));
g_ptr_array_unref (list);
@@ -1766,6 +1778,20 @@ nma_context_menu_update (NMApplet *applet)
gtk_widget_show_all (applet->wwan_enabled_item);
else
gtk_widget_hide (applet->wwan_enabled_item);
+
+ if (is_permission_yes (applet, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM)
+ || is_permission_yes (applet, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN)
+ || is_permission_yes (applet, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_HOSTNAME)) {
+
+ /* User has permissions to modify some of the settings. */
+ gtk_widget_set_sensitive (applet->connections_menu_item, TRUE);
+
+ } else {
+ /* the user is not allowed to edit any of the settings,
+ * so set the "Edit Connections..." menu item insensitive.
+ */
+ gtk_widget_set_sensitive (applet->connections_menu_item, FALSE);
+ }
}
static void

View File

@ -1,157 +0,0 @@
From: =?utf-8?q?Antti_Kaijanm=C3=A4ki?= <antti.kaijanmaki@canonical.com>
Date: Tue, 24 May 2016 14:14:37 +0800
Subject: Support hiding rather than desensitizing disallowed items
This is done using a new environment variable that can be set
when nm-applet is started: NM_APPLET_HIDE_POLICY_ITEMS.
---
src/applet-device-wifi.c | 20 +++++++++++++++++---
src/applet.c | 33 ++++++++++++++++++++++++++++-----
src/applet.h | 1 +
3 files changed, 46 insertions(+), 8 deletions(-)
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 407f7e0..162b1ff 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -211,7 +211,6 @@ nma_menu_add_hidden_network_item (GtkWidget *menu, NMApplet *applet)
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_container_add (GTK_CONTAINER (menu_item), label);
gtk_widget_show_all (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
g_signal_connect_swapped (menu_item, "activate",
G_CALLBACK (applet_wifi_connect_to_hidden_network),
applet);
@@ -242,6 +241,13 @@ nma_menu_add_hidden_network_item (GtkWidget *menu, NMApplet *applet)
}
gtk_widget_set_sensitive (GTK_WIDGET (menu_item), allowed);
+ if (!allowed && applet->hide_policy_items) {
+ /* don't add the item if it should be hidden */
+ /* TODO: is this the final solution? */
+ g_object_ref_sink (menu_item);
+ g_object_unref (menu_item);
+ } else
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
}
gboolean
@@ -289,13 +295,21 @@ nma_menu_add_create_network_item (GtkWidget *menu, NMApplet *applet)
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_container_add (GTK_CONTAINER (menu_item), label);
gtk_widget_show_all (menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
g_signal_connect_swapped (menu_item, "activate",
G_CALLBACK (applet_wifi_create_wifi_network),
applet);
- if (!applet_wifi_can_create_wifi_network (applet))
+ if (!applet_wifi_can_create_wifi_network (applet)) {
gtk_widget_set_sensitive (GTK_WIDGET (menu_item), FALSE);
+ if (applet->hide_policy_items) {
+ /* don't add the item if it should be hidden */
+ /* TODO: is this the final solution? */
+ g_object_ref_sink (menu_item);
+ g_object_unref (menu_item);
+ return;
+ }
+ }
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item);
}
typedef struct {
diff --git a/src/applet.c b/src/applet.c
index 7a0f041..9e41d47 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -1459,6 +1459,8 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
GtkMenuItem *item;
GPtrArray *list;
int i;
+ gboolean configure_allowed;
+ gboolean disconnect_allowed;
vpn_menu = GTK_MENU (gtk_menu_new ());
@@ -1488,9 +1490,16 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
if ( state != NM_STATE_CONNECTED_LOCAL
&& state != NM_STATE_CONNECTED_SITE
&& state != NM_STATE_CONNECTED_GLOBAL
- && !is_permission_yes (applet, NM_CLIENT_PERMISSION_NETWORK_CONTROL))
+ && !disconnect_allowed){
gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
- else
+ if (!applet->hide_policy_items)
+ gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
+ else {
+ /* TODO: is this the final solution? */
+ g_object_ref_sink (item);
+ g_object_unref (item);
+ }
+ } else
gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), !!active);
@@ -1506,7 +1515,10 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
/* Draw a separator, but only if we have VPN connections above it */
if (list->len) {
- nma_menu_add_separator_item (GTK_WIDGET (vpn_menu));
+ if ( !applet->hide_policy_items
+ || configure_allowed
+ || disconnect_allowed)
+ nma_menu_add_separator_item (GTK_WIDGET (vpn_menu)); /* separator is added if there will be items under it */
item = GTK_MENU_ITEM (gtk_menu_item_new_with_mnemonic (_("_Configure VPN…")));
g_signal_connect (item, "activate", G_CALLBACK (nma_menu_configure_vpn_item_activate), applet);
} else {
@@ -1514,11 +1526,17 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
g_signal_connect (item, "activate", G_CALLBACK (nma_menu_add_vpn_item_activate), applet);
}
gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
- if ( is_permission_yes (applet, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_SYSTEM)
- || is_permission_yes (applet, NM_CLIENT_PERMISSION_SETTINGS_MODIFY_OWN)) {
+ if (configure_allowed) {
gtk_widget_set_sensitive (GTK_WIDGET (item), TRUE);
} else {
gtk_widget_set_sensitive (GTK_WIDGET (item), FALSE);
+ if (!applet->hide_policy_items) {
+ gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
+ } else {
+ /* TODO: is this the final solution? */
+ g_object_ref_sink (item);
+ g_object_unref (item);
+ }
}
gtk_widget_show (GTK_WIDGET (item));
@@ -1791,6 +1809,7 @@ nma_context_menu_update (NMApplet *applet)
* so set the "Edit Connections..." menu item insensitive.
*/
gtk_widget_set_sensitive (applet->connections_menu_item, FALSE);
+ gtk_widget_set_visible (applet->connections_menu_item, !applet->hide_policy_items);
}
}
@@ -3562,6 +3581,10 @@ static void nma_init (NMApplet *applet)
g_signal_connect (applet, "startup", G_CALLBACK (applet_startup), NULL);
g_signal_connect (applet, "activate", G_CALLBACK (applet_activate), NULL);
+
+ applet->hide_policy_items = FALSE;
+ if (getenv ("NM_APPLET_HIDE_POLICY_ITEMS"))
+ applet->hide_policy_items = TRUE;
}
static void nma_class_init (NMAppletClass *klass)
diff --git a/src/applet.h b/src/applet.h
index 958ba56..706a2e7 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -76,6 +76,7 @@ typedef struct {
#endif
gboolean visible;
+ gboolean hide_policy_items;
/* Permissions */
NMClientPermissionResult permissions[NM_CLIENT_PERMISSION_LAST + 1];

View File

@ -1,216 +0,0 @@
From: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Date: Fri, 20 May 2016 14:27:57 +0800
Subject: lp341684_device_sensitive_disconnect_notify
---
src/applet-device-wifi.c | 2 +
src/applet.c | 142 +++++++++++++++++++++++++++++++++++++++++++++--
src/applet.h | 5 +-
3 files changed, 143 insertions(+), 6 deletions(-)
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index 8ce4bd1..37b2121 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -1305,6 +1305,8 @@ wifi_notify_connected (NMDevice *device,
ap = _active_ap_get (applet, device);
+ g_object_set_data_full (G_OBJECT(device), "canonical-last-essid", g_strdup (esc_ssid), (GDestroyNotify) g_free);
+
esc_ssid = get_ssid_utf8 (ap);
if (!ap)
diff --git a/src/applet.c b/src/applet.c
index ac4f03d..e43c1e4 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -141,6 +141,19 @@ get_device_class_from_connection (NMConnection *connection, NMApplet *applet)
return NULL;
}
+struct _OfflineNotificationContextInfo {
+ NMState state;
+ NMDeviceState device_state;
+ NMDeviceStateReason device_state_reason;
+ NMDeviceType device_type;
+ gchar* title;
+ gchar* text;
+ const gchar* icon;
+ NotifyUrgency urgency;
+};
+
+typedef struct _OfflineNotificationContextInfo OfflineNotificationContextInfo;
+
static NMActiveConnection *
applet_get_best_activating_connection (NMApplet *applet, NMDevice **device)
{
@@ -2127,6 +2140,64 @@ applet_get_exported_connection_for_device (NMDevice *device, NMApplet *applet)
return NULL;
}
+static gboolean
+select_merged_notification_text (OfflineNotificationContextInfo *info)
+{
+ info->urgency = NOTIFY_URGENCY_LOW;
+ /* only do something if this is about full offline state */
+ if(info->state != NM_STATE_UNKNOWN || info->device_state != NM_DEVICE_STATE_UNKNOWN) {
+ info->urgency = NOTIFY_URGENCY_NORMAL;
+ if (!info->text)
+ info->text = g_strdup (_("Network"));
+ if (info->state == NM_STATE_DISCONNECTED || info->state == NM_STATE_ASLEEP) {
+ info->title = _("Disconnected - you are now offline");
+ } else
+ info->title = _("Disconnected");
+
+ switch (info->device_type) {
+ case NM_DEVICE_TYPE_ETHERNET:
+ info->icon = "notification-network-ethernet-disconnected";
+ break;
+ case NM_DEVICE_TYPE_WIFI:
+ info->icon = "notification-network-wireless-disconnected";
+ break;
+ case NM_DEVICE_TYPE_MODEM:
+ info->icon = "notification-gsm-disconnected";
+ break;
+ default:
+ info->icon = "nm-no-connection";
+ break;
+ }
+ g_debug("going for offline with icon: %s", info->icon);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
+foo_online_offline_deferred_notify (gpointer user_data)
+{
+ NMApplet *applet = NM_APPLET (user_data);
+ OfflineNotificationContextInfo *info = applet->notification_queue_data;
+ if(select_merged_notification_text (info))
+ if (!g_settings_get_boolean (applet->gsettings, PREF_DISABLE_DISCONNECTED_NOTIFICATIONS))
+ applet_do_notify (applet, info->urgency, info->title,
+ info->text, info->icon,
+ PREF_DISABLE_DISCONNECTED_NOTIFICATIONS,
+ _("Don't show this message again"),
+ notify_dont_show_cb,
+ applet);
+ else
+ g_debug("no notification because merged found that we have nothing to say (e.g. not offline)");
+ if (info->text)
+ g_free (info->text);
+ info->text = NULL;
+ g_free (applet->notification_queue_data);
+ applet->notification_queue_data = NULL;
+ applet->deferred_id = 0;
+ return FALSE;
+}
+
static void
applet_common_device_state_changed (NMDevice *device,
NMDeviceState new_state,
@@ -2141,6 +2212,54 @@ applet_common_device_state_changed (NMDevice *device,
switch (new_state) {
+ case NM_DEVICE_STATE_FAILED:
+ case NM_DEVICE_STATE_DISCONNECTED:
+ case NM_DEVICE_STATE_UNMANAGED:
+ case NM_DEVICE_STATE_UNAVAILABLE:
+ {
+ if (old_state != NM_DEVICE_STATE_FAILED &&
+ old_state != NM_DEVICE_STATE_UNKNOWN &&
+ old_state != NM_DEVICE_STATE_DISCONNECTED &&
+ old_state != NM_DEVICE_STATE_UNMANAGED &&
+ old_state != NM_DEVICE_STATE_UNAVAILABLE) {
+ OfflineNotificationContextInfo *info = applet->notification_queue_data;
+ if (!info) {
+ info = g_new0(OfflineNotificationContextInfo, 1);
+ applet->notification_queue_data = info;
+ }
+
+ info->device_state = new_state;
+ info->device_state_reason = reason;
+ if (info->text) {
+ g_free(info->text);
+ info->text = NULL;
+ }
+ if (NM_IS_DEVICE_WIFI (device)) {
+ info->device_type = NM_DEVICE_TYPE_WIFI;
+ info->text = g_strdup(g_object_get_data (G_OBJECT(device), "canonical-last-essid"));
+ if (!info->text)
+ info->text = g_strdup (_("Wireless network"));
+ } else if (NM_IS_DEVICE_ETHERNET (device)) {
+ info->device_type = NM_DEVICE_TYPE_ETHERNET;
+ info->text = g_strdup(_("Ethernet network"));
+ } else if (NM_IS_DEVICE_MODEM (device)) {
+ info->device_type = NM_DEVICE_TYPE_MODEM;
+ info->text = g_strdup (_("Modem network"));
+ } else {
+ info->device_type = NM_DEVICE_TYPE_UNKNOWN;
+ info->text = g_strdup (_("Network"));
+ }
+
+ if (applet->deferred_id)
+ g_source_remove (applet->deferred_id);
+ applet->deferred_id = g_timeout_add (1000, foo_online_offline_deferred_notify, applet);
+
+ clear_animation_timeout (applet);
+ } else {
+ g_debug ("old state indicates that this was not a disconnect %d", old_state);
+ }
+ break;
+ }
case NM_DEVICE_STATE_PREPARE:
case NM_DEVICE_STATE_CONFIG:
case NM_DEVICE_STATE_NEED_AUTH:
@@ -2227,13 +2346,26 @@ foo_client_state_changed_cb (NMClient *client, GParamSpec *pspec, gpointer user_
{
NMApplet *applet = NM_APPLET (user_data);
+ g_debug("foo_client_state_changed_cb");
switch (nm_client_get_state (client)) {
case NM_STATE_DISCONNECTED:
- applet_do_notify_with_pref (applet, _("Disconnected"),
- _("The network connection has been disconnected."),
- "nm-no-connection",
- PREF_DISABLE_DISCONNECTED_NOTIFICATIONS);
- break;
+ case NM_STATE_ASLEEP:
+ {
+ OfflineNotificationContextInfo *info = applet->notification_queue_data;
+ if (!info) {
+ info = g_new0(OfflineNotificationContextInfo, 1);
+ applet->notification_queue_data = info;
+ }
+
+ info->state = nm_client_get_state (client);
+ select_merged_notification_text (info);
+
+ if (applet->deferred_id)
+ g_source_remove (applet->deferred_id);
+ applet->deferred_id = g_timeout_add (1000, foo_online_offline_deferred_notify, applet);
+
+ /* Fall through */
+ }
default:
break;
}
diff --git a/src/applet.h b/src/applet.h
index 7a0cb8f..958ba56 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -135,8 +135,11 @@ typedef struct {
/* Tracker objects for secrets requests */
GSList * secrets_reqs;
-
guint wifi_scan_id;
+
+ gpointer notification_queue_data;
+ guint deferred_id;
+
} NMApplet;
typedef void (*AppletNewAutoConnectionCallback) (NMConnection *connection,

View File

@ -1,83 +0,0 @@
From: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Date: Fri, 20 May 2016 14:28:34 +0800
Subject: lp460144_correctly_update_notification
---
src/applet.c | 38 +++++++++++++++++---------------------
1 file changed, 17 insertions(+), 21 deletions(-)
diff --git a/src/applet.c b/src/applet.c
index e43c1e4..a13808c 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -673,17 +673,6 @@ applet_menu_item_create_device_item_helper (NMDevice *device,
return item;
}
-static void
-applet_clear_notify (NMApplet *applet)
-{
- if (applet->notification == NULL)
- return;
-
- notify_notification_close (applet->notification, NULL);
- g_object_unref (applet->notification);
- applet->notification = NULL;
-}
-
static gboolean
applet_notify_server_has_actions (void)
{
@@ -740,19 +729,28 @@ applet_do_notify (NMApplet *applet,
if (!applet->agent)
return;
- applet_clear_notify (applet);
-
escaped = utils_escape_notify_message (message);
- notify = notify_notification_new (summary,
- escaped,
- icon ? icon : "network-workgroup"
+
+ if (applet->notification == NULL) {
+ notify = notify_notification_new (summary,
+ escaped,
+ icon ? icon : "network-workgroup"
#if HAVE_LIBNOTIFY_07
- );
+ );
#else
- , NULL);
+ , NULL);
#endif
+
+ applet->notification = notify;
+ } else {
+ notify = applet->notification;
+ notify_notification_update (notify,
+ summary,
+ escaped,
+ icon ? icon : "network-workgroup");
+ }
+
g_free (escaped);
- applet->notification = notify;
#if HAVE_LIBNOTIFY_07
notify_notification_set_hint (notify, "transient", g_variant_new_boolean (TRUE));
@@ -3265,7 +3263,6 @@ status_icon_activate_cb (GtkStatusIcon *icon, NMApplet *applet)
/* Have clicking on the applet act also as acknowledgement
* of the notification.
*/
- applet_clear_notify (applet);
applet_start_wifi_scan (applet, NULL);
@@ -3297,7 +3294,6 @@ status_icon_popup_menu_cb (GtkStatusIcon *icon,
/* Have clicking on the applet act also as acknowledgement
* of the notification.
*/
- applet_clear_notify (applet);
nma_context_menu_update (applet);
gtk_menu_popup (GTK_MENU (applet->context_menu), NULL, NULL,

View File

@ -1,7 +0,0 @@
Allow-creation-of-connections-without-admin-privileges.patch
Force-online-state-with-unmanaged-devices.patch
lp341684_device_sensitive_disconnect_notify.patch
lp460144_correctly_update_notification.patch
Have-the-appindicator-enabled-by-default.patch
Make-policykit-restricted-actions-insensitive.patch
Support-hiding-rather-than-desensitizing-disallowed-items.patch

View File

@ -1 +1 @@
3.0 (quilt)
3.0 (native)