commit c02fefb4ba1076af15de90f0ed1db38d748e4a32
Author: Danny Kukawka <danny.kukawka@web.de>
Date:   Wed Jun 16 16:44:15 2010 +0200

    initial port of nma-finer-policy-fate#305657.patch

diff --git a/src/Makefile.am b/src/Makefile.am
index 33d2c49..ff13af9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -17,6 +17,7 @@ nm_applet_CPPFLAGS = \
 	-DDBUS_API_SUBJECT_TO_CHANGE							\
 	-DNMALOCALEDIR=\"$(datadir)/locale\"					\
 	$(DBUS_CFLAGS)										\
+	$(POLKIT_CFLAGS) \
 	$(DISABLE_DEPRECATED)	\
 	-I${top_builddir}/src/marshallers \
 	-I${top_srcdir}/src/utils \
@@ -52,10 +53,15 @@ nm_applet_SOURCES =			\
 	mm-types.h \
 	nma-gsm-modem.c \
 	nma-gsm-modem.h \
+	applet-polkit-manager.c \
+        applet-polkit-manager.h \
+        applet-menu-item.c \
+        applet-menu-item.h  \
 	$(NULL)
 
 nm_applet_LDADD = \
 	$(NMA_LIBS) \
+	$(POLKIT_LIBS) \
 	$(NOTIFY_LIBS) \
 	${top_builddir}/src/marshallers/libmarshallers.la \
 	${top_builddir}/src/utils/libutils.la \
diff --git a/src/ap-menu-item.c b/src/ap-menu-item.c
index 6131549..68b82e1 100644
--- a/src/ap-menu-item.c
+++ b/src/ap-menu-item.c
@@ -35,7 +35,7 @@
 #include "utils.h"
 
 
-G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, GTK_TYPE_CHECK_MENU_ITEM);
+G_DEFINE_TYPE (NMNetworkMenuItem, nm_network_menu_item, APPLET_TYPE_MENU_ITEM);
 
 static void
 nm_network_menu_item_init (NMNetworkMenuItem * item)
@@ -44,18 +44,17 @@ nm_network_menu_item_init (NMNetworkMenuItem * item)
 	PangoFontMetrics * metrics;
 	PangoContext * context;
 	PangoLanguage * lang;
+	AppletMenuItem *applet_item;
+	GtkWidget * hbox;
 	int ascent;
 
 	gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
-	item->hbox = gtk_hbox_new (FALSE, 6);
+	applet_item = APPLET_MENU_ITEM (item);
+	hbox = applet_menu_item_get_hbox (applet_item);
 	item->ssid = gtk_label_new (NULL);
 	gtk_misc_set_alignment (GTK_MISC (item->ssid), 0.0, 0.5);
 
-	item->detail = gtk_image_new ();
-
-	gtk_container_add (GTK_CONTAINER (item), item->hbox);
-	gtk_box_pack_start (GTK_BOX (item->hbox), item->ssid, TRUE, TRUE, 0);
-	gtk_box_pack_start (GTK_BOX (item->hbox), item->detail, FALSE, FALSE, 0);
+	applet_menu_item_set_label (APPLET_MENU_ITEM (item), item->ssid);
 
 	item->strength = gtk_progress_bar_new ();
 	
@@ -68,14 +67,15 @@ nm_network_menu_item_init (NMNetworkMenuItem * item)
 	pango_font_metrics_unref (metrics);
 
 	/* size our progress bar to be five ascents long */
-	gtk_widget_set_size_request (item->strength, ascent * 5, -1);
+	gtk_widget_set_size_request (item->strength, ascent * 5, -1);
 
-	gtk_box_pack_end (GTK_BOX (item->hbox), item->strength, FALSE, TRUE, 0);
+	gtk_box_pack_end (GTK_BOX (hbox), item->strength, FALSE, TRUE, 0);
+
+	item->detail = gtk_image_new ();
+	gtk_box_pack_end (GTK_BOX (hbox), item->detail, FALSE, TRUE, 0);
 
-	gtk_widget_show (item->ssid);
 	gtk_widget_show (item->strength);
 	gtk_widget_show (item->detail);
-	gtk_widget_show (item->hbox);
 }
 
 GtkWidget*
@@ -112,10 +112,8 @@ nm_network_menu_item_class_dispose (GObject *object)
 		return;
 	}
 
-	gtk_widget_destroy (item->ssid);
 	gtk_widget_destroy (item->strength);
 	gtk_widget_destroy (item->detail);
-	gtk_widget_destroy (item->hbox);
 
 	item->destroyed = TRUE;
 	g_free (item->hash);
diff --git a/src/ap-menu-item.h b/src/ap-menu-item.h
index 1d7fdfe..1e722fb 100644
--- a/src/ap-menu-item.h
+++ b/src/ap-menu-item.h
@@ -27,6 +27,7 @@
 #include <gtk/gtk.h>
 #include "applet.h"
 #include "nm-access-point.h"
+#include "applet-menu-item.h"
 
 #define NM_TYPE_NETWORK_MENU_ITEM            (nm_network_menu_item_get_type ())
 #define NM_NETWORK_MENU_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_NETWORK_MENU_ITEM, NMNetworkMenuItem))
@@ -48,7 +49,6 @@ struct _NMNetworkMenuItem
 	GtkWidget * strength;
 	guint32     int_strength;
 	GtkWidget * detail;
-	GtkWidget * hbox;
 	guchar *    hash;
 	guint32     hash_len;
 	gboolean    destroyed;
@@ -57,7 +57,7 @@ struct _NMNetworkMenuItem
 
 struct _NMNetworkMenuItemClass
 {
-	GtkCheckMenuItemClass parent_class;
+	AppletMenuItemClass parent_class;
 };
 
 
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 58742fe..bcb560b 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -30,24 +30,48 @@
 #include <nm-device.h>
 #include <nm-setting-connection.h>
 #include <nm-setting-cdma.h>
+#include <nm-setting-ip4-config.h>
 #include <nm-setting-serial.h>
 #include <nm-setting-ppp.h>
 #include <nm-cdma-device.h>
 #include <nm-utils.h>
 
+#ifdef NO_POLKIT_GNOME
+#include "polkit-gnome.h"
+#else
+#include <polkit-gnome/polkit-gnome.h>
+#endif
+
 #include "applet.h"
 #include "applet-device-cdma.h"
 #include "utils.h"
+#include "applet-polkit-manager.h"
+#include "applet-menu-item.h"
 
 typedef struct {
 	NMApplet *applet;
 	NMDevice *device;
 	NMConnection *connection;
+	PolKitGnomeAction *pk_gnome_action;
 } CdmaMenuItemInfo;
 
 static void
 cdma_menu_item_info_destroy (gpointer data)
 {
+	CdmaMenuItemInfo *info = (CdmaMenuItemInfo *) data;
+	if (info->device) {
+	    g_object_unref (G_OBJECT (info->device));
+	    info->device = NULL;
+	}
+	if (info->connection) {
+	    g_object_unref (G_OBJECT (info->connection));
+	    info->connection = NULL;
+	}
+	if (info->pk_gnome_action) {
+	    g_object_unref (G_OBJECT (info->pk_gnome_action));
+	    info->pk_gnome_action = NULL;
+	}
+
 	g_slice_free (CdmaMenuItemInfo, data);
 }
 
@@ -121,23 +145,61 @@ add_connection_items (NMDevice *device,
 {
 	GSList *iter;
 	CdmaMenuItemInfo *info;
+	AppletPolKitManager * pk_manager;
+	pk_manager = applet_polkit_manager_get ();
 
 	for (iter = connections; iter; iter = g_slist_next (iter)) {
 		NMConnection *connection = NM_CONNECTION (iter->data);
 		NMSettingConnection *s_con;
 		GtkWidget *item;
+		PolKitGnomeAction * pk_gnome_action;
+		const char * connection_type;
+
+		pk_gnome_action = NULL;
 
 		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
-		item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+		connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+		if (connection_type == NULL) {
+			g_warning ("connection_type is NULL");
+			continue;
+		}
+
+		item = applet_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
 		gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
 		if (connection == active)
 			gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
 
+		if (!is_system_connection (connection)) {
+		    NMSettingIP4Config *s_ip4;
+		    AppletPolKitManagerActionDetails action_details;
+
+		    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
+		    s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
+		    if (s_ip4) {
+			const char *ip4_method;
+			ip4_method = nm_setting_ip4_config_get_method (s_ip4);
+			if (!strcmp (ip4_method, "shared")) {
+			    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE;
+			}
+		    }
+		    pk_gnome_action = applet_polkit_manager_connect_menu_item_action (pk_manager, APPLET_MENU_ITEM (item), connection_type, action_details);
+		    if (pk_gnome_action == NULL) {
+			g_object_ref (item);
+			gtk_object_sink (GTK_OBJECT (item));
+			gtk_widget_destroy (GTK_WIDGET (item));
+			g_object_unref (item);
+			continue;
+		    }
+		    /* set the applet for item auth end callback in AppletPolKitManager */
+		    g_object_set_data (G_OBJECT (item), "applet", applet);
+		}
+
 		info = g_slice_new0 (CdmaMenuItemInfo);
 		info->applet = applet;
 		info->device = g_object_ref (G_OBJECT (device));
 		info->connection = g_object_ref (connection);
+		info->pk_gnome_action = pk_gnome_action;
 
 		g_signal_connect_data (item, "activate",
 		                       G_CALLBACK (cdma_menu_item_activate),
@@ -155,13 +217,24 @@ add_default_connection_item (NMDevice *device,
 {
 	CdmaMenuItemInfo *info;
 	GtkWidget *item;
+	PolKitGnomeAction * pk_gnome_action = NULL;
+	const char * connection_type;
+	AppletPolKitManagerActionDetails action_details;
+
+	connection_type = NM_SETTING_CDMA_SETTING_NAME;
+	action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;	
 	
-	item = gtk_check_menu_item_new_with_label (DEFAULT_CDMA_NAME);
+	item = applet_menu_item_new_with_label (DEFAULT_CDMA_NAME);
 	gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
+	pk_gnome_action = applet_polkit_manager_connect_menu_item_action (applet_polkit_manager_get(), APPLET_MENU_ITEM (item), connection_type, action_details);
+	/* set the applet for item auth end callback in AppletPolKitManager */
+	g_object_set_data (G_OBJECT (item), "applet", applet);
+
 	info = g_slice_new0 (CdmaMenuItemInfo);
 	info->applet = applet;
 	info->device = g_object_ref (G_OBJECT (device));
+	info->pk_gnome_action = pk_gnome_action;
 
 	g_signal_connect_data (item, "activate",
 	                       G_CALLBACK (cdma_menu_item_activate),
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index e34dc47..5f9f635 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -34,26 +34,50 @@
 #include <nm-device.h>
 #include <nm-setting-connection.h>
 #include <nm-setting-gsm.h>
+#include <nm-setting-ip4-config.h>
 #include <nm-setting-serial.h>
 #include <nm-setting-ppp.h>
 #include <nm-gsm-device.h>
 #include <nm-utils.h>
 
+#ifdef NO_POLKIT_GNOME
+#include "polkit-gnome.h"
+#else
+#include <polkit-gnome/polkit-gnome.h>
+#endif
+
 #include "applet.h"
 #include "applet-device-gsm.h"
 #include "nma-gsm-modem.h"
 #include "mm-types.h"
 #include "utils.h"
+#include "applet-polkit-manager.h"
+#include "applet-menu-item.h"
 
 typedef struct {
 	NMApplet *applet;
 	NMDevice *device;
 	NMConnection *connection;
+	PolKitGnomeAction * pk_gnome_action;
 } GSMMenuItemInfo;
 
 static void
 gsm_menu_item_info_destroy (gpointer data)
 {
+	GSMMenuItemInfo * info = (GSMMenuItemInfo *) data;
+	if (info->device) {
+	    g_object_unref (G_OBJECT (info->device));
+	    info->device = NULL;
+	}
+	if (info->connection) {
+	    g_object_unref (G_OBJECT (info->connection));
+	    info->device = NULL;
+	}
+	if (info->pk_gnome_action) {
+	    g_object_unref (G_OBJECT (info->pk_gnome_action));
+	    info->pk_gnome_action = NULL;
+	}
+
 	g_slice_free (GSMMenuItemInfo, data);
 }
 
@@ -127,23 +151,64 @@ add_connection_items (NMDevice *device,
 {
 	GSList *iter;
 	GSMMenuItemInfo *info;
+	AppletPolKitManager * pk_manager;
+
+	pk_manager = applet_polkit_manager_get ();
 
 	for (iter = connections; iter; iter = g_slist_next (iter)) {
 		NMConnection *connection = NM_CONNECTION (iter->data);
 		NMSettingConnection *s_con;
 		GtkWidget *item;
+		PolKitGnomeAction * pk_gnome_action;
+		const char * connection_type;
+
+		pk_gnome_action = NULL;
 
 		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
-		item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+
+		connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+
+		if (connection_type == NULL) {
+		    g_warning ("connection_type is NULL");
+		    continue;
+		}
+
+                item = applet_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
 		gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
 		if (connection == active)
 			gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
 
+		if (!is_system_connection (connection)) {
+		    NMSettingIP4Config *s_ip4;
+		    AppletPolKitManagerActionDetails action_details;
+
+		    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
+		    s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
+		    if (s_ip4) {
+			const char *ip4_method;
+			ip4_method = nm_setting_ip4_config_get_method (s_ip4);
+			if (!strcmp (ip4_method, "shared")) {
+			    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE;
+			}
+		    }
+		    pk_gnome_action = applet_polkit_manager_connect_menu_item_action (pk_manager, APPLET_MENU_ITEM (item), connection_type, action_details);
+		    if (pk_gnome_action == NULL) {
+			g_object_ref (item);
+			gtk_object_sink (GTK_OBJECT (item));
+			gtk_widget_destroy (GTK_WIDGET (item));
+			g_object_unref (item);
+			continue;
+		    }
+		    /* set the applet for item auth end callback in AppletPolKitManager */
+		    g_object_set_data (G_OBJECT (item), "applet", applet);
+		}
+
 		info = g_slice_new0 (GSMMenuItemInfo);
 		info->applet = applet;
 		info->device = g_object_ref (G_OBJECT (device));
 		info->connection = g_object_ref (connection);
+		info->pk_gnome_action = pk_gnome_action;
 
 		g_signal_connect_data (item, "activate",
 		                       G_CALLBACK (gsm_menu_item_activate),
@@ -161,10 +226,20 @@ add_default_connection_item (NMDevice *device,
 {
 	GSMMenuItemInfo *info;
 	GtkWidget *item;
+	PolKitGnomeAction * pk_gnome_action = NULL;
+	const char * connection_type = NULL;
+	AppletPolKitManagerActionDetails action_datails;
+
+	connection_type = NM_SETTING_GSM_SETTING_NAME;
+	action_datails = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
 	
 	item = gtk_check_menu_item_new_with_label (DEFAULT_GSM_NAME);
 	gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
+	pk_gnome_action = applet_polkit_manager_connect_menu_item_action (applet_polkit_manager_get(), APPLET_MENU_ITEM (item), connection_type, action_datails);
+	/* set the applet for item auth end callback in AppletPolKitManager */
+	g_object_set_data (G_OBJECT (item), "applet", applet);
+
 	info = g_slice_new0 (GSMMenuItemInfo);
 	info->applet = applet;
 	info->device = g_object_ref (G_OBJECT (device));
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index a4cc157..d1045ce 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -39,14 +39,23 @@
 #include <nm-setting-wireless.h>
 #include <nm-device-wifi.h>
 #include <nm-setting-8021x.h>
+#include <nm-setting-ip4-config.h>
 #include <nm-utils.h>
 
+#ifdef NO_POLKIT_GNOME
+#include "polkit-gnome.h"
+#else
+#include <polkit-gnome/polkit-gnome.h>
+#endif
+
 #include "applet.h"
 #include "applet-device-wifi.h"
 #include "ap-menu-item.h"
 #include "utils.h"
 #include "gnome-keyring-md5.h"
 #include "wireless-dialog.h"
+#include "applet-polkit-manager.h"
+#include "applet-menu-item.h"
 
 #define PREF_SUPPRESS_WIRELESS_NEWORKS_AVAILABLE    APPLET_PREFS_PATH "/suppress-wireless-networks-available"
 
@@ -134,6 +143,7 @@ typedef struct {
 	NMDeviceWifi *device;
 	NMAccessPoint *ap;
 	NMConnection *connection;
+	PolKitGnomeAction * pk_gnome_action;
 } WirelessMenuItemInfo;
 
 static void
@@ -142,11 +152,18 @@ wireless_menu_item_info_destroy (gpointer data)
 	WirelessMenuItemInfo *info = (WirelessMenuItemInfo *) data;
 
 	g_object_unref (G_OBJECT (info->device));
-	g_object_unref (G_OBJECT (info->ap));
+
+	if (info->ap) {
+		g_object_unref (info->ap);
+	}
 
 	if (info->connection)
 		g_object_unref (G_OBJECT (info->connection));
 
+	if (info->pk_gnome_action) {
+		g_object_unref (info->pk_gnome_action);
+	}
+
 	g_slice_free (WirelessMenuItemInfo, data);
 }
 
@@ -472,8 +489,11 @@ add_new_ap_item (NMDeviceWifi *device,
 	GSList *ap_connections = NULL;
 	const GByteArray *ssid;
 	guint8 strength;
+	AppletPolKitManager *pk_manager;
 	guint32 dev_caps;
 
+	pk_manager = applet_polkit_manager_get();
+
 	ap_connections = filter_connections_for_access_point (connections, device, ap);
 
 	foo = nm_network_menu_item_new (applet->encryption_size_group,
@@ -492,8 +512,6 @@ add_new_ap_item (NMDeviceWifi *device,
 
 	g_object_set_data (G_OBJECT (item), "device", NM_DEVICE (device));
 
-	gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
-
 	/* If there's only one connection, don't show the submenu */
 	if (g_slist_length (ap_connections) > 1) {
 		GtkWidget *submenu;
@@ -504,15 +522,51 @@ add_new_ap_item (NMDeviceWifi *device,
 			NMConnection *connection = NM_CONNECTION (iter->data);
 			NMSettingConnection *s_con;
 			GtkWidget *subitem;
+			PolKitGnomeAction * pk_gnome_action;
+			const char * connection_type;
+
+			pk_gnome_action = NULL;
 
 			s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
-			subitem = gtk_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+			connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+			if (connection_type == NULL) {
+			    g_warning ("connection_type is NULL");
+			    continue;
+			}
+				   subitem = applet_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+
+
+			if (!is_system_connection (connection)) {
+			    NMSettingIP4Config *s_ip4;
+			    AppletPolKitManagerActionDetails action_details;
+
+			    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
+			    s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
+			    if (s_ip4) {
+				const char * ip4_method;
+				ip4_method = nm_setting_ip4_config_get_method (s_ip4);
+				if (!strcmp (ip4_method, "shared")) {
+				    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE;
+				}
+			    }
+			    pk_gnome_action = applet_polkit_manager_connect_menu_item_action (pk_manager, APPLET_MENU_ITEM (subitem), connection_type, action_details);
+			    if (pk_gnome_action == NULL) {
+				g_object_ref (subitem);
+				gtk_object_sink (GTK_OBJECT (subitem));
+				gtk_widget_destroy (GTK_WIDGET (subitem));
+				g_object_unref (subitem);
+				continue;
+			    }
+			    /* set the applet for item auth end callback in AppletPolKitManager */
+			    g_object_set_data (G_OBJECT (subitem), "applet", applet);
+			}
 
 			info = g_slice_new0 (WirelessMenuItemInfo);
 			info->applet = applet;
 			info->device = g_object_ref (G_OBJECT (device));
 			info->ap = g_object_ref (G_OBJECT (ap));
 			info->connection = g_object_ref (G_OBJECT (connection));
+			info->pk_gnome_action = pk_gnome_action;
 
 			g_signal_connect_data (subitem, "activate",
 			                       G_CALLBACK (wireless_menu_item_activate),
@@ -523,26 +577,99 @@ add_new_ap_item (NMDeviceWifi *device,
 		}
 
 		gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), submenu);
+       } else if (g_slist_length (ap_connections) == 1) {
+        do {
+            NMConnection *connection;
+            NMSettingConnection *s_con;
+            PolKitGnomeAction * pk_gnome_action;
+            const char * connection_type;
+
+            pk_gnome_action = NULL;
+
+            connection = NM_CONNECTION (g_slist_nth_data (ap_connections, 0));
+            s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
+            connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
+
+            if (connection_type == NULL) {
+                g_warning ("connection_type is NULL");
+                continue;
+            }
+
+            if (!is_system_connection (connection)) {
+                NMSettingIP4Config *s_ip4;
+                AppletPolKitManagerActionDetails action_details;
+
+                action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
+                s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
+                if (s_ip4) {
+                    const char * ip4_method;
+                    ip4_method = nm_setting_ip4_config_get_method (s_ip4);
+                    if (!strcmp (ip4_method, "shared")) {
+                        action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE;
+                    }
+                }
+                pk_gnome_action = applet_polkit_manager_connect_menu_item_action (pk_manager, APPLET_MENU_ITEM (item), connection_type, action_details);
+                if (pk_gnome_action == NULL) {
+                    g_object_ref (item);
+                    gtk_object_sink (GTK_OBJECT (item));
+                    gtk_widget_destroy (GTK_WIDGET (item));
+                    g_object_unref (item);
+                    continue;
+                }
+
+                /* set the applet for item auth end callback in AppletPolKitManager */
+                g_object_set_data (G_OBJECT (item), "applet", applet);
+            }
+
+            info = g_slice_new0 (WirelessMenuItemInfo);
+            info->applet = applet;
+            info->device = g_object_ref (G_OBJECT (device));
+            info->ap = g_object_ref (G_OBJECT (ap));
+            info->connection = g_object_ref (G_OBJECT (connection));
+            info->pk_gnome_action = pk_gnome_action;
+
+            g_signal_connect_data (GTK_WIDGET (item),
+                    "activate",
+                    G_CALLBACK (wireless_menu_item_activate),
+                    info,
+                    (GClosureNotify) wireless_menu_item_info_destroy,
+                    0);
+        } while (0);
 	} else {
-		NMConnection *connection;
-
-		info = g_slice_new0 (WirelessMenuItemInfo);
-		info->applet = applet;
-		info->device = g_object_ref (G_OBJECT (device));
-		info->ap = g_object_ref (G_OBJECT (ap));
+        do {
+            PolKitGnomeAction * pk_gnome_action;
+            const char * connection_type = NM_SETTING_WIRELESS_SETTING_NAME;
+            AppletPolKitManagerActionDetails action_details;
+
+            action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
+
+            pk_gnome_action = applet_polkit_manager_connect_menu_item_action (pk_manager, APPLET_MENU_ITEM (item), connection_type, action_details);
+            if (pk_gnome_action == NULL) {
+                g_object_ref (item);
+                gtk_object_sink (GTK_OBJECT (item));
+                gtk_widget_destroy (GTK_WIDGET (item));
+                g_object_unref (item);
+                continue;
+            }
+            /* set the applet for item auth end callback in AppletPolKitManager */
+            g_object_set_data (G_OBJECT (item), "applet", applet);
+
+            info = g_slice_new0 (WirelessMenuItemInfo);
+            info->applet = applet;
+            info->device = g_object_ref (G_OBJECT (device));
+            info->ap = g_object_ref (G_OBJECT (ap));
+            info->pk_gnome_action = pk_gnome_action;
+
+            g_signal_connect_data (GTK_WIDGET (item),
+                    "activate",
+                    G_CALLBACK (wireless_menu_item_activate),
+                    info,
+                    (GClosureNotify) wireless_menu_item_info_destroy,
+                    0);
+        } while (0);
+    }
 
-		if (g_slist_length (ap_connections) == 1) {
-			connection = NM_CONNECTION (g_slist_nth_data (ap_connections, 0));
-			info->connection = g_object_ref (G_OBJECT (connection));
-		}
-
-		g_signal_connect_data (GTK_WIDGET (item),
-		                       "activate",
-		                       G_CALLBACK (wireless_menu_item_activate),
-		                       info,
-		                       (GClosureNotify) wireless_menu_item_info_destroy,
-		                       0);
-	}
+	gtk_menu_shell_append (GTK_MENU_SHELL (menu), GTK_WIDGET (item));
 
 	gtk_widget_show_all (GTK_WIDGET (item));
 
@@ -596,12 +723,17 @@ add_one_ap_menu_item (NMDeviceWifi *device,
 
 	g_signal_handlers_block_matched (item, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
 	                                 G_CALLBACK (wireless_menu_item_activate), NULL);
+	g_signal_handlers_block_matched (item, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
+                                         G_CALLBACK (gtk_action_activate), NULL);
 
 	if (nm_network_menu_item_find_dupe (item, active_ap))
-		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
+		gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE && GTK_WIDGET_SENSITIVE(item));
 
 	g_signal_handlers_unblock_matched (item, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
 	                                   G_CALLBACK (wireless_menu_item_activate), NULL);
+	g_signal_handlers_unblock_matched (item, G_SIGNAL_MATCH_FUNC, 0, 0, NULL,
+	                                   G_CALLBACK (gtk_action_activate), NULL);
+
 }
 
 static gint
@@ -1296,6 +1428,37 @@ nag_dialog_response_cb (GtkDialog *nag_dialog,
 }
 
 static void
+wireless_dialog_auth_end_cb (PolKitGnomeAction *action, gboolean gained_privilege, gpointer user_data)
+{
+    WirelessMenuItemInfo *info = (WirelessMenuItemInfo *) user_data;
+    if (gained_privilege) {
+        const char *specific_object = NULL;
+
+        if (info->ap)
+            specific_object = nm_object_get_path (NM_OBJECT (info->ap));
+        applet_menu_item_activate_helper (NM_DEVICE (info->device),
+                info->connection,
+                specific_object ? specific_object : "/",
+                info->applet,
+                user_data);
+    } else {
+        NMSettingConnection *s_con;
+        const char * connection_id;
+        gchar * message;
+
+        s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (info->connection, NM_TYPE_SETTING_CONNECTION));
+        connection_id = nm_setting_connection_get_id (s_con);
+        message = g_strdup_printf("%s %s", _("You do not have the privilege to activate connection"), connection_id);
+
+        applet_do_notify (info->applet, NOTIFY_URGENCY_LOW, _("Activate Connection Failed"), message, NULL, NULL, NULL, NULL, NULL);
+
+        g_free (message);
+    }
+
+    wireless_menu_item_info_destroy (user_data);
+}
+
+static void
 wireless_dialog_response_cb (GtkDialog *foo,
                              gint response,
                              gpointer user_data)
@@ -1306,6 +1469,7 @@ wireless_dialog_response_cb (GtkDialog *foo,
 	NMDevice *device = NULL;
 	NMAccessPoint *ap = NULL;
 	NMAGConfConnection *gconf_connection;
+	WirelessMenuItemInfo * info;
 
 	if (response != GTK_RESPONSE_OK)
 		goto done;
@@ -1409,13 +1573,65 @@ wireless_dialog_response_cb (GtkDialog *foo,
 		}
 	}
 
-	nm_client_activate_connection (applet->nm_client,
-	                               NM_DBUS_SERVICE_USER_SETTINGS,
-	                               nm_connection_get_path (connection),
-	                               device,
-	                               ap ? nm_object_get_path (NM_OBJECT (ap)) : NULL,
-	                               activate_device_cb,
-	                               applet);
+       if (!is_system_connection (connection)) {
+               PolKitGnomeAction *pk_gnome_action;
+               const char * action_id = NM_SETTING_WIRELESS_SETTING_NAME;
+               NMSettingIP4Config *s_ip4;
+               AppletPolKitManagerActionDetails action_details;
+               PolKitResult pk_result;
+
+               action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
+               s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
+               if (s_ip4) {
+                       const char * ip4_method;
+                       ip4_method = nm_setting_ip4_config_get_method (s_ip4);
+                       if (!strcmp (ip4_method, "shared")) {
+                               action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE;
+                       }
+               }
+               pk_gnome_action = applet_polkit_manager_create_action (applet_polkit_manager_get (), action_id, action_details);
+               if (pk_gnome_action == NULL) {
+                       nm_warning ("Couldn't create action for other network");
+                       goto done;
+               }
+               info = g_slice_new0 (WirelessMenuItemInfo);
+               info->applet = applet;
+               info->device = g_object_ref (device);
+               info->ap = ap ? g_object_ref (ap) : NULL;
+               info->connection = g_object_ref (connection);
+               info->pk_gnome_action = pk_gnome_action;
+
+               pk_result = polkit_gnome_action_get_polkit_result (pk_gnome_action);
+               switch (pk_result) {
+                       case POLKIT_RESULT_YES:
+                               // When the result is yes, we gained privilege for active connection.
+                               wireless_dialog_auth_end_cb (pk_gnome_action, TRUE, info);
+                               break;
+
+                       case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
+                       case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
+                       case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
+                       case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
+                       case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
+                       case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
+                               // Trigger the auth action, after success it'll call wireless_dialog_auth_end_cb.
+                               applet_polkit_manager_activate_action (applet_polkit_manager_get (),
+                                               pk_gnome_action, G_CALLBACK (wireless_dialog_auth_end_cb), info);
+                               break;
+                       case POLKIT_RESULT_NO:
+                       default:
+                               // nothing to do
+                               break;
+               }
+    } else {
+        nm_client_activate_connection (applet->nm_client,
+                NM_DBUS_SERVICE_SYSTEM_SETTINGS,
+                nm_connection_get_path (connection),
+                device,
+                ap ? nm_object_get_path (NM_OBJECT (ap)) : NULL,
+                activate_device_cb,
+                applet);
+    }
 
 done:
 	/* Balance the caller of wireless_dialog_new () */
diff --git a/src/applet-device-wired.c b/src/applet-device-wired.c
index 8027e39..4252072 100644
--- a/src/applet-device-wired.c
+++ b/src/applet-device-wired.c
@@ -31,21 +31,33 @@
 #include <nm-device.h>
 #include <nm-setting-connection.h>
 #include <nm-setting-wired.h>
+#include <nm-setting-ip4-config.h>
 #include <nm-setting-8021x.h>
 #include <nm-setting-pppoe.h>
 #include <nm-device-ethernet.h>
 #include <nm-utils.h>
 
+#ifdef NO_POLKIT_GNOME
+#include "polkit-gnome.h"
+#else
+#include <polkit-gnome/polkit-gnome.h>
+#endif
+
 #include "applet.h"
 #include "applet-device-wired.h"
 #include "wired-dialog.h"
 #include "utils.h"
 #include "gconf-helpers.h"
+#include "applet-polkit-manager.h"
+#include "applet-menu-item.h"
+
+#define PK_ACTION_ID_USER_APPLY "org.freedesktop.network-manager-settings.user.wired.apply"
 
 typedef struct {
 	NMApplet *applet;
 	NMDevice *device;
 	NMConnection *connection;
+	PolKitGnomeAction * pk_gnome_action;
 } WiredMenuItemInfo;
 
 static void
@@ -53,9 +65,18 @@ wired_menu_item_info_destroy (gpointer data)
 {
 	WiredMenuItemInfo *info = (WiredMenuItemInfo *) data;
 
-	g_object_unref (G_OBJECT (info->device));
-	if (info->connection)
-		g_object_unref (G_OBJECT (info->connection));
+	if (info->device) {
+	    g_object_unref (G_OBJECT (info->device));
+	    info->device = NULL;
+	}
+	if (info->connection) {
+	    g_object_unref (G_OBJECT (info->connection));
+	    info->connection = NULL;
+	}
+	if (info->pk_gnome_action) {
+	    g_object_unref (G_OBJECT (info->pk_gnome_action));
+	    info->pk_gnome_action = NULL;
+	}
 
 	g_slice_free (WiredMenuItemInfo, data);
 }
@@ -114,24 +135,65 @@ add_connection_items (NMDevice *device,
 {
 	GSList *iter;
 	WiredMenuItemInfo *info;
+	AppletPolKitManager * pk_manager;
+	pk_manager = applet_polkit_manager_get ();
 
 	for (iter = connections; iter; iter = g_slist_next (iter)) {
 		NMConnection *connection = NM_CONNECTION (iter->data);
 		NMSettingConnection *s_con;
 		GtkWidget *item;
+		PolKitGnomeAction *pk_gnome_action;
+		const char * connection_type;
+
+		pk_gnome_action = NULL;
 
 		s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
-		item = gtk_check_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
- 		gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
+		connection_type = s_con ? nm_setting_connection_get_connection_type(s_con) : NULL;
+
+		if (connection_type == NULL) {
+		    g_warning ("conection_type is NULL");
+		    continue;
+		}
+
+		item = applet_menu_item_new_with_label (nm_setting_connection_get_id (s_con));
+
+		gtk_widget_set_sensitive (GTK_WIDGET (item), GTK_WIDGET_SENSITIVE (item) && carrier);
 		gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
 		if (connection == active)
 			gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE);
 
+		/*  connection is user scope */
+		if (!is_system_connection (connection)) {
+		    NMSettingIP4Config *s_ip4;
+		    AppletPolKitManagerActionDetails action_details;
+
+		    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
+		    s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
+		    if (s_ip4) {
+			const char * ip4_method;
+			ip4_method = nm_setting_ip4_config_get_method (s_ip4);
+			if (!strcmp (ip4_method, "shared")) {
+			    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE;
+			}
+		    }
+		    pk_gnome_action = applet_polkit_manager_connect_menu_item_action (pk_manager, APPLET_MENU_ITEM (item), connection_type, action_details);
+		    if (pk_gnome_action == NULL) {
+			g_object_ref (item);
+			gtk_object_sink (GTK_OBJECT (item));
+			gtk_widget_destroy (GTK_WIDGET (item));
+			g_object_unref (item);
+			continue;
+		    }
+		    /* set the applet for item auth end callback in AppletPolKitManager */
+		    g_object_set_data (G_OBJECT (item), "applet", applet);
+		}
+
 		info = g_slice_new0 (WiredMenuItemInfo);
 		info->applet = applet;
 		info->device = g_object_ref (G_OBJECT (device));
 		info->connection = g_object_ref (connection);
+		info->pk_gnome_action = pk_gnome_action;
 
 		g_signal_connect_data (item, "activate",
 		                       G_CALLBACK (wired_menu_item_activate),
@@ -150,14 +212,24 @@ add_default_connection_item (NMDevice *device,
 {
 	WiredMenuItemInfo *info;
 	GtkWidget *item;
+	PolKitGnomeAction *pk_gnome_action;
+	const char * connection_type;
+	AppletPolKitManagerActionDetails action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
 	
-	item = gtk_check_menu_item_new_with_label (DEFAULT_WIRED_NAME);
+	connection_type = NM_SETTING_WIRED_SETTING_NAME;
+        item = applet_menu_item_new_with_label (DEFAULT_WIRED_NAME);
 	gtk_widget_set_sensitive (GTK_WIDGET (item), carrier);
 	gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
+	pk_gnome_action = applet_polkit_manager_connect_menu_item_action (applet_polkit_manager_get(), APPLET_MENU_ITEM (item), connection_type, action_details);
+
+	/* set the applet for item auth end callback in AppletPolKitManager */
+	g_object_set_data (G_OBJECT (item), "applet", applet);
+
 	info = g_slice_new0 (WiredMenuItemInfo);
 	info->applet = applet;
 	info->device = g_object_ref (G_OBJECT (device));
+	info->pk_gnome_action = pk_gnome_action;
 
 	g_signal_connect_data (item, "activate",
 	                       G_CALLBACK (wired_menu_item_activate),
diff --git a/src/applet-menu-item.c b/src/applet-menu-item.c
new file mode 100644
index 0000000..47259d4
--- /dev/null
+++ b/src/applet-menu-item.c
@@ -0,0 +1,184 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* applet-menu-item.c - Class to represent a menu item for a connection setting
+ *
+ * Lance Wang <lzwang@novell.com>
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2009 Novell, Inc.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "applet-menu-item.h"
+
+G_DEFINE_TYPE (AppletMenuItem, applet_menu_item, GTK_TYPE_CHECK_MENU_ITEM)
+
+typedef struct AppletMenuItemPriv
+{
+    GtkWidget *main_hbox;
+    GtkWidget *label_p;
+    GtkWidget *label;
+    GtkWidget *scope_icon_p;
+    GtkWidget *scope_icon;
+} AppletMenuItemPriv;
+
+#define APPLET_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APPLET_TYPE_MENU_ITEM, AppletMenuItemPriv))
+
+static void
+applet_menu_item_init (AppletMenuItem * item)
+{
+    AppletMenuItemPriv * priv = APPLET_MENU_ITEM_GET_PRIVATE (item);
+
+    GtkCheckMenuItem *ck_item = GTK_CHECK_MENU_ITEM(item);
+
+    priv->scope_icon_p = gtk_hbox_new (TRUE, 0);
+    priv->label_p = gtk_hbox_new (TRUE, 0);
+    priv->main_hbox = gtk_hbox_new(FALSE, 6);
+    gtk_container_add (GTK_CONTAINER(item), priv->main_hbox);
+    gtk_box_pack_start (GTK_BOX (priv->main_hbox), priv->scope_icon_p, FALSE, TRUE, 0);
+    gtk_box_pack_start (GTK_BOX (priv->main_hbox), priv->label_p, FALSE, TRUE, 0);
+    gtk_check_menu_item_set_draw_as_radio(ck_item, TRUE);
+}
+
+static void
+dispose (GObject *object)
+{
+    AppletMenuItem * item;
+    AppletMenuItemPriv * priv;
+    GtkWidget *wdtmp;
+
+       item = APPLET_MENU_ITEM (object);
+    priv = APPLET_MENU_ITEM_GET_PRIVATE (item);
+
+    if (priv->scope_icon_p) {
+        wdtmp = priv->scope_icon_p;
+        priv->scope_icon_p = NULL;
+        gtk_widget_destroy (wdtmp);
+    }
+
+    if (priv->label_p) {
+        wdtmp = priv->label_p;
+        priv->label_p = NULL;
+        gtk_widget_destroy (wdtmp);
+    }
+
+    if (priv->main_hbox) {
+        wdtmp = priv->main_hbox;
+        priv->main_hbox = NULL;
+        gtk_widget_destroy (wdtmp);
+    }
+
+       G_OBJECT_CLASS (applet_menu_item_parent_class)->dispose (object);
+}
+
+static void
+applet_menu_item_class_init (AppletMenuItemClass * klass)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+       /* virtual methods */
+       object_class->dispose = dispose;
+
+    g_type_class_add_private (klass, sizeof (AppletMenuItemPriv));
+}
+
+GtkWidget *applet_menu_item_get_hbox (AppletMenuItem * item)
+{
+    AppletMenuItemPriv * priv;
+
+    g_return_val_if_fail (APPLET_IS_MENU_ITEM(item), NULL);
+
+    priv = APPLET_MENU_ITEM_GET_PRIVATE (item);
+
+    return priv->main_hbox;
+}
+
+void applet_menu_item_set_scope_icon (AppletMenuItem *item, GtkWidget * icon)
+{
+    AppletMenuItemPriv * priv;
+
+    g_return_if_fail (APPLET_IS_MENU_ITEM (item));
+
+    priv = APPLET_MENU_ITEM_GET_PRIVATE (item);
+
+    if (priv->scope_icon) {
+        gtk_widget_destroy (priv->scope_icon);
+    }
+    priv->scope_icon = icon;
+    if (priv->scope_icon) {
+        gtk_box_pack_start (GTK_BOX (priv->scope_icon_p), priv->scope_icon, TRUE, TRUE, 0);
+    }
+}
+
+void applet_menu_item_set_label (AppletMenuItem * item, GtkWidget * label)
+{
+    AppletMenuItemPriv * priv;
+
+    g_return_if_fail (APPLET_IS_MENU_ITEM (item));
+
+    priv = APPLET_MENU_ITEM_GET_PRIVATE (item);
+
+    if (priv->label) {
+        gtk_widget_destroy (priv->label);
+    }
+    priv->label = label;
+    if (label) {
+        gtk_box_pack_start (GTK_BOX (priv->label_p), priv->label, TRUE, TRUE, 0);
+    }
+}
+
+const char *
+applet_menu_item_get_label_name (AppletMenuItem * item)
+{
+    AppletMenuItemPriv * priv;
+
+    g_return_val_if_fail (APPLET_IS_MENU_ITEM (item), NULL);
+
+    priv = APPLET_MENU_ITEM_GET_PRIVATE (item);
+
+    if (priv->label) {
+        return gtk_label_get_text (GTK_LABEL (priv->label));
+    }
+    return NULL;
+}
+
+GtkWidget*
+applet_menu_item_new (void)
+{
+       AppletMenuItem * item;
+
+       item = g_object_new (APPLET_TYPE_MENU_ITEM, NULL);
+
+       return GTK_WIDGET (item);
+}
+
+GtkWidget * applet_menu_item_new_with_label(const char * string)
+{
+    AppletMenuItem * item;
+    GtkWidget * label;
+
+    item = g_object_new (APPLET_TYPE_MENU_ITEM, NULL);
+
+    label = gtk_label_new(string);
+    applet_menu_item_set_label (item, label);
+
+    return GTK_WIDGET(item);
+}
+
+
+
diff --git a/src/applet-menu-item.h b/src/applet-menu-item.h
new file mode 100644
index 0000000..e0efb76
--- /dev/null
+++ b/src/applet-menu-item.h
@@ -0,0 +1,63 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* applet-menu-item.h - Class to represent a menu item for a connection setting
+ *
+ * Lance Wang <lzwang@novell.com>
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Copyright (C) 2009 Novell, Inc.
+ */
+
+#ifndef __APPLET_MENU_ITEM_H__
+#define __APPLET_MENU_ITEM_H__
+
+#include <gtk/gtk.h>
+#include <gtk/gtkcheckmenuitem.h>
+#include <nm-connection.h>
+
+#include "applet.h"
+
+#define APPLET_TYPE_MENU_ITEM            (applet_menu_item_get_type ())
+#define APPLET_MENU_ITEM(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLET_TYPE_MENU_ITEM, AppletMenuItem))
+#define APPLET_MENU_ITEM_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), APPLET_TYPE_MENU_ITEM, AppletMenuItemClass))
+#define APPLET_IS_MENU_ITEM(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLET_TYPE_MENU_ITEM))
+#define APPLET_IS_MENU_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLET_TYPE_MENU_ITEM))
+#define APPLET_MENU_ITEM_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLET_TYPE_MENU_ITEM, AppletMenuItemClass))
+
+
+typedef struct _AppletMenuItem     AppletMenuItem;
+typedef struct _AppletMenuItemClass   AppletMenuItemClass;
+
+struct _AppletMenuItem
+{
+       GtkCheckMenuItem check_item;
+};
+
+struct _AppletMenuItemClass
+{
+       GtkCheckMenuItemClass parent_class;
+};
+
+
+GType     applet_menu_item_get_type (void);
+GtkWidget *applet_menu_item_new (void);
+GtkWidget *applet_menu_item_new_with_label (const char * string);
+void applet_menu_item_set_label (AppletMenuItem * item, GtkWidget * label);
+const char * applet_menu_item_get_label_name (AppletMenuItem * item);
+GtkWidget *applet_menu_item_get_hbox (AppletMenuItem * item);
+void applet_menu_item_set_scope_icon (AppletMenuItem * item, GtkWidget * icon);
+
+#endif /* __APPLET_MENU_ITEM_H__ */
+
diff --git a/src/applet-polkit-manager.c b/src/applet-polkit-manager.c
new file mode 100644
index 0000000..425d898
--- /dev/null
+++ b/src/applet-polkit-manager.c
@@ -0,0 +1,339 @@
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+
+#include <gtk/gtk.h>
+#include <polkit/polkit.h>
+
+#include <nm-setting-connection.h>
+#include <nm-setting-ip4-config.h>
+#include <nm-setting-wired.h>
+#include <nm-setting-8021x.h>
+#include <nm-setting-wireless.h>
+#include <nm-setting-wireless-security.h>
+#include <nm-setting-vpn.h>
+#include <nm-setting-pppoe.h>
+#include <nm-setting-ppp.h>
+#include <nm-setting-gsm.h>
+#include <nm-setting-cdma.h>
+
+#include "applet.h"
+#include "applet-polkit-manager.h"
+#include "applet-menu-item.h"
+
+#define NM_POLICY_ACTION_USER_WIRED_APPLY "org.freedesktop.network-manager-settings.user.wired.apply"
+#define NM_POLICY_ACTION_USER_WIRELESS_APPLY "org.freedesktop.network-manager-settings.user.wireless.apply"
+#define NM_POLICY_ACTION_USER_MOBILE_APPLY "org.freedesktop.network-manager-settings.user.mobile.apply"
+#define NM_POLICY_ACTION_USER_VPN_APPLY "org.freedesktop.network-manager-settings.user.vpn.apply"
+#define NM_POLICY_ACTION_USER_DSL_APPLY "org.freedesktop.network-manager-settings.user.dsl.apply"
+
+#define NM_POLICY_ACTION_USER_WIRED_APPLY_WITH_SHARE "org.freedesktop.network-manager-settings.user.wired.apply-with-share"
+#define NM_POLICY_ACTION_USER_WIRELESS_APPLY_WITH_SHARE "org.freedesktop.network-manager-settings.user.wireless.apply-with-share"
+#define NM_POLICY_ACTION_USER_MOBILE_APPLY_WITH_SHARE "org.freedesktop.network-manager-settings.user.mobile.apply-with-share"
+#define NM_POLICY_ACTION_USER_VPN_APPLY_WITH_SHARE "org.freedesktop.network-manager-settings.user.vpn.apply-with-share"
+#define NM_POLICY_ACTION_USER_DSL_APPLY_WITH_SHARE "org.freedesktop.network-manager-settings.user.dsl.apply-with-share"
+
+static AppletPolKitManager *singleton = NULL;
+
+typedef struct _AppletPolKitManagerPriv AppletPolKitManagerPriv;
+
+struct _AppletPolKitManagerPriv {
+    PolKitAction *user_wired_apply;
+    PolKitAction *user_wireless_apply;
+    PolKitAction *user_mobile_apply;
+    PolKitAction *user_vpn_apply;
+    PolKitAction *user_dsl_apply;
+
+    PolKitAction *user_wired_apply_with_share;
+    PolKitAction *user_wireless_apply_with_share;
+    PolKitAction *user_mobile_apply_with_share;
+    PolKitAction *user_vpn_apply_with_share;
+    PolKitAction *user_dsl_apply_with_share;
+};
+
+#define APPLET_POLKIT_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APPLET_TYPE_POLKIT_MANAGER, AppletPolKitManagerPriv))
+
+G_DEFINE_TYPE (AppletPolKitManager, applet_polkit_manager, G_TYPE_OBJECT)
+
+static void
+menu_item_polkit_action_result_change_cb (PolKitGnomeAction * action, PolKitResult pk_result, AppletMenuItem * item)
+{
+    gboolean deny = FALSE;
+    switch (polkit_gnome_action_get_polkit_result(action)) {
+        case POLKIT_RESULT_YES:
+            break;
+
+        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
+        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
+        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
+        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
+        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
+        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
+            applet_menu_item_set_scope_icon (item, gtk_action_create_icon (GTK_ACTION (action), GTK_ICON_SIZE_BUTTON));
+            break;
+        case POLKIT_RESULT_NO:
+        default:
+            deny = TRUE;
+            break;
+    }
+
+    gtk_widget_set_sensitive (GTK_WIDGET (item), GTK_WIDGET_SENSITIVE (item) && !deny);
+}
+
+static void
+menu_item_polkit_action_activate_cb (GtkMenuItem * item,  PolKitGnomeAction * action)
+{
+        switch (polkit_gnome_action_get_polkit_result(action)) {
+        case POLKIT_RESULT_YES:
+                break;
+
+        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH:
+        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_SESSION:
+        case POLKIT_RESULT_ONLY_VIA_ADMIN_AUTH_KEEP_ALWAYS:
+        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH:
+        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_SESSION:
+        case POLKIT_RESULT_ONLY_VIA_SELF_AUTH_KEEP_ALWAYS:
+                g_signal_stop_emission_by_name (item, "activate");
+                break;
+
+        default:
+        case POLKIT_RESULT_NO:
+                break;
+        }
+}
+
+static void
+menu_item_polkit_action_auth_end_cb (PolKitGnomeAction *action, gboolean gained_privilege, GtkWidget *item)
+{
+
+    if (gained_privilege) {
+        gtk_action_block_activate_from (GTK_ACTION (action), item);
+        g_signal_emit_by_name (item, "activate");
+        gtk_action_unblock_activate_from (GTK_ACTION (action), item);
+    } else {
+        gpointer data;
+        data = g_object_get_data (G_OBJECT (item), "applet");
+        if (data) {
+            const char * connection_id;
+            gchar * message;
+            NMApplet * applet;
+
+            applet = NM_APPLET (data);
+            connection_id = applet_menu_item_get_label_name (APPLET_MENU_ITEM (item));
+            message = g_strdup_printf ("%s, %s", _("You do not have the privilege to activate connection"), connection_id);
+
+            applet_do_notify (applet, NOTIFY_URGENCY_LOW, _("Activate Connection Failed"), message, NULL, NULL, NULL, NULL, NULL);
+            g_free (message);
+        }
+    }
+}
+
+PolKitGnomeAction *
+applet_polkit_manager_create_action (AppletPolKitManager * manager, const char * action_id, AppletPolKitManagerActionDetails action_details)
+{
+    const char *action_name;
+    PolKitAction *pk_action;
+    PolKitGnomeAction *action;
+    AppletPolKitManagerPriv * priv;
+
+    g_return_val_if_fail (APPLET_IS_POLKIT_MANAGER (manager), NULL);
+
+    priv = APPLET_POLKIT_MANAGER_GET_PRIVATE (manager);
+
+    switch (action_details)
+    {
+        case APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE:
+            if (!strcmp(action_id, NM_SETTING_WIRED_SETTING_NAME)) {
+                action_name = "user_wired_apply";
+                pk_action = priv->user_wired_apply;
+            } else if (!strcmp(action_id, NM_SETTING_WIRELESS_SETTING_NAME)) {
+                action_name = "user_wireless_apply";
+                pk_action = priv->user_wireless_apply;
+            } else if (!strcmp(action_id, NM_SETTING_VPN_SETTING_NAME)) {
+                action_name = "user_vpn_apply";
+                pk_action = priv->user_vpn_apply;
+            } else if (!strcmp(action_id, NM_SETTING_PPP_SETTING_NAME)
+                                       || !strcmp(action_id, NM_SETTING_PPPOE_SETTING_NAME)) {
+                action_name = "user_dsl_apply";
+                pk_action = priv->user_dsl_apply;
+            } else if (!strcmp(action_id, NM_SETTING_CDMA_SETTING_NAME)
+                    || !strcmp(action_id, NM_SETTING_GSM_SETTING_NAME)) {
+                action_name = "user_mobile_apply";
+                pk_action = priv->user_mobile_apply;
+            } else {
+                g_warning ("Can not create the action(%s). Maybe there is a new policy to be add",
+                                               action_id);
+                return NULL;
+            }
+            break;
+        case APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE:
+            if (!strcmp(action_id, NM_SETTING_WIRED_SETTING_NAME)) {
+                action_name = "user_wired_apply_with_share";
+                pk_action = priv->user_wired_apply_with_share;
+            } else if (!strcmp(action_id, NM_SETTING_WIRELESS_SETTING_NAME)) {
+                action_name = "user_wireless_apply_with_share";
+                pk_action = priv->user_wireless_apply_with_share;
+            } else if (!strcmp(action_id, NM_SETTING_VPN_SETTING_NAME)) {
+                action_name = "user_vpn_apply_with_share";
+                pk_action = priv->user_vpn_apply_with_share;
+            } else if (!strcmp(action_id, NM_SETTING_PPP_SETTING_NAME)
+                                       || !strcmp(action_id, NM_SETTING_PPPOE_SETTING_NAME)) {
+                action_name = "user_dsl_apply_with_share";
+                pk_action = priv->user_dsl_apply_with_share;
+            } else if (!strcmp(action_id, NM_SETTING_CDMA_SETTING_NAME)
+                    || !strcmp(action_id, NM_SETTING_GSM_SETTING_NAME)) {
+                action_name = "user_mobile_apply_with_share";
+                pk_action = priv->user_mobile_apply_with_share;
+            } else {
+                g_warning ("Can not create the action(%s). Maybe there is a new policy to be add",
+                                               action_id);
+                return NULL;
+            }
+            break;
+        default:
+            g_assert_not_reached();
+    }
+
+    action = polkit_gnome_action_new_default (action_name, pk_action, "", "");
+    return action;
+}
+
+PolKitGnomeAction *
+applet_polkit_manager_connect_menu_item_action (AppletPolKitManager * manager, AppletMenuItem * item, const char *connection_type, AppletPolKitManagerActionDetails action_details)
+{
+    PolKitResult pk_result;
+    PolKitGnomeAction *action;
+
+    g_return_val_if_fail (APPLET_IS_POLKIT_MANAGER (manager), NULL);
+    g_return_val_if_fail (APPLET_IS_MENU_ITEM (item), NULL);
+
+    action = applet_polkit_manager_create_action (manager, connection_type, action_details);
+       // When the action is NULL return, or else it'll crash
+       if (action == NULL)
+               return NULL;
+
+    pk_result = polkit_gnome_action_get_polkit_result (action);
+    /* update item sensitive */
+    menu_item_polkit_action_result_change_cb (action, pk_result, item);
+
+       g_signal_connect_object (item, "activate", G_CALLBACK (gtk_action_activate), action, G_CONNECT_SWAPPED);
+    g_signal_connect (item, "activate", G_CALLBACK (menu_item_polkit_action_activate_cb), action);
+    g_signal_connect (action, "auth_end", G_CALLBACK (menu_item_polkit_action_auth_end_cb), item);
+    g_signal_connect (action, "polkit-result-changed", G_CALLBACK (menu_item_polkit_action_result_change_cb), item);
+
+    return action;
+}
+
+void
+applet_polkit_manager_activate_action (AppletPolKitManager * manager, PolKitGnomeAction * action, GCallback callback, gpointer data)
+{
+    g_return_if_fail (APPLET_IS_POLKIT_MANAGER (manager));
+
+    g_signal_connect (action, "auth_end", callback, data);
+    gtk_action_activate (GTK_ACTION (action));
+}
+
+static void
+applet_polkit_manager_init (AppletPolKitManager * manager)
+{
+
+    AppletPolKitManagerPriv * priv;
+
+    g_return_if_fail (APPLET_IS_POLKIT_MANAGER (manager));
+
+    priv = APPLET_POLKIT_MANAGER_GET_PRIVATE (manager);
+
+    priv->user_wired_apply = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_wired_apply, NM_POLICY_ACTION_USER_WIRED_APPLY);
+    priv->user_wireless_apply = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_wireless_apply, NM_POLICY_ACTION_USER_WIRELESS_APPLY);
+    priv->user_mobile_apply = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_mobile_apply, NM_POLICY_ACTION_USER_MOBILE_APPLY);
+    priv->user_vpn_apply = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_vpn_apply, NM_POLICY_ACTION_USER_VPN_APPLY);
+    priv->user_dsl_apply = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_dsl_apply, NM_POLICY_ACTION_USER_DSL_APPLY);
+
+    /* shared connection */
+    priv->user_wired_apply_with_share = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_wired_apply_with_share, NM_POLICY_ACTION_USER_WIRED_APPLY_WITH_SHARE);
+    priv->user_wireless_apply_with_share = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_wireless_apply_with_share, NM_POLICY_ACTION_USER_WIRELESS_APPLY_WITH_SHARE);
+    priv->user_mobile_apply_with_share = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_mobile_apply_with_share, NM_POLICY_ACTION_USER_MOBILE_APPLY_WITH_SHARE);
+    priv->user_vpn_apply_with_share = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_vpn_apply_with_share, NM_POLICY_ACTION_USER_VPN_APPLY_WITH_SHARE);
+    priv->user_dsl_apply_with_share = polkit_action_new ();
+    polkit_action_set_action_id (priv->user_dsl_apply_with_share, NM_POLICY_ACTION_USER_DSL_APPLY_WITH_SHARE);
+
+}
+
+static void
+finalize (GObject *gobject)
+{
+    AppletPolKitManager * manager;
+    AppletPolKitManagerPriv * priv;
+
+    manager = APPLET_POLKIT_MANAGER (gobject);
+
+    priv = APPLET_POLKIT_MANAGER_GET_PRIVATE (manager);
+
+    if (priv->user_wired_apply) {
+        polkit_action_unref (priv->user_wired_apply);
+    }
+    if (priv->user_wireless_apply) {
+        polkit_action_unref (priv->user_wireless_apply);
+    }
+    if (priv->user_mobile_apply) {
+        polkit_action_unref (priv->user_mobile_apply);
+    }
+    if (priv->user_vpn_apply) {
+        polkit_action_unref (priv->user_vpn_apply);
+    }
+    if (priv->user_dsl_apply) {
+        polkit_action_unref (priv->user_dsl_apply);
+    }
+    /* shared connectin */
+    if (priv->user_wired_apply_with_share) {
+        polkit_action_unref (priv->user_wired_apply_with_share);
+    }
+    if (priv->user_wireless_apply_with_share) {
+        polkit_action_unref (priv->user_wireless_apply_with_share);
+    }
+    if (priv->user_mobile_apply_with_share) {
+        polkit_action_unref (priv->user_mobile_apply_with_share);
+    }
+    if (priv->user_vpn_apply_with_share) {
+        polkit_action_unref (priv->user_vpn_apply_with_share);
+    }
+    if (priv->user_dsl_apply_with_share) {
+        polkit_action_unref (priv->user_dsl_apply_with_share);
+    }
+
+    G_OBJECT_CLASS (applet_polkit_manager_parent_class)->finalize (gobject);
+}
+
+static void
+applet_polkit_manager_class_init (AppletPolKitManagerClass * klass)
+{
+    GObjectClass * gobject_class;
+
+    g_return_if_fail (APPLET_IS_POLKIT_MANAGER_CLASS (klass));
+
+    gobject_class = G_OBJECT_CLASS (klass);
+
+    gobject_class->finalize = finalize;
+
+    g_type_class_add_private (klass, sizeof (AppletPolKitManagerPriv));
+}
+
+AppletPolKitManager *
+applet_polkit_manager_get (void)
+{
+    if (singleton == NULL) {
+        singleton = g_object_new (APPLET_TYPE_POLKIT_MANAGER, NULL);
+    }
+    return singleton;
+}
+
diff --git a/src/applet-polkit-manager.h b/src/applet-polkit-manager.h
new file mode 100644
index 0000000..e4a01bd
--- /dev/null
+++ b/src/applet-polkit-manager.h
@@ -0,0 +1,49 @@
+#ifndef __APPLET_POLKIT_MANAGER__
+#define __APPLET_POLKIT_MANAGER__
+
+#include <polkit/polkit.h>
+
+#ifdef NO_POLKIT_GNOME
+#include "polkit-gnome.h"
+#else
+#include <polkit-gnome/polkit-gnome.h>
+#endif
+
+#include "applet-menu-item.h"
+
+#define APPLET_TYPE_POLKIT_MANAGER   (applet_polkit_manager_get_type())
+#define APPLET_POLKIT_MANAGER(obj)   (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLET_TYPE_POLKIT_MANAGER, AppletPolKitManager))
+#define APPLET_POLKIT_MANAGER_CLASS(klass)   (G_TYPE_CHECK_CLASS_CAST ((klass), APPLET_TYPE_POLKIT_MANAGER, AppletPolKitManagerClass))
+#define APPLET_IS_POLKIT_MANAGER(obj)  (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLET_TYPE_POLKIT_MANAGER))
+#define APPLET_IS_POLKIT_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLET_TYPE_POLKIT_MANAGER))
+#define APPLET_POLKIT_MANAGER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLET_TYPE_POLKIT_MANAGER, AppletPolKitManagerClass))
+
+
+typedef struct _AppletPolKitManager AppletPolKitManager;
+typedef struct _AppletPolKitManagerClass AppletPolKitManagerClass;
+
+struct _AppletPolKitManager {
+    GObject parent;
+};
+
+struct _AppletPolKitManagerClass {
+    GObjectClass parent;
+};
+
+typedef enum AppletPolKitManagerActionDetails
+{
+    APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE,
+    APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE,
+    APPLET_POLKIT_MANAGER_ACTION_LAST,
+} AppletPolKitManagerActionDetails;
+
+GType applet_polkit_manager_get_type (void);
+
+AppletPolKitManager * applet_polkit_manager_get (void);
+
+
+PolKitGnomeAction * applet_polkit_manager_create_action (AppletPolKitManager * manager, const char * action_id, AppletPolKitManagerActionDetails action_details);
+void applet_polkit_manager_activate_action (AppletPolKitManager * manager, PolKitGnomeAction * action, GCallback callback, gpointer data);
+PolKitGnomeAction *applet_polkit_manager_connect_menu_item_action (AppletPolKitManager * manager, AppletMenuItem * item, const char * connection_type, AppletPolKitManagerActionDetails action_details);
+#endif
+
diff --git a/src/applet.c b/src/applet.c
index 82472c1..ed26b73 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -53,6 +53,7 @@
 #include <nm-active-connection.h>
 #include <nm-dbus-settings-system.h>
 #include <nm-setting-wireless.h>
+#include <nm-setting-ip4-config.h>
 
 #include <glade/glade.h>
 #include <gconf/gconf-client.h>
@@ -69,6 +70,7 @@
 #include "applet-dbus-manager.h"
 #include "utils.h"
 #include "gconf-helpers.h"
+#include "applet-polkit-manager.h"
 
 #define NOTIFY_CAPS_ACTIONS_KEY "actions"
 
@@ -281,7 +283,7 @@ get_device_class (NMDevice *device, NMApplet *applet)
 	return NULL;
 }
 
-static gboolean
+gboolean
 is_system_connection (NMConnection *connection)
 {
 	return (nm_connection_get_scope (connection) == NM_CONNECTION_SCOPE_SYSTEM) ? TRUE : FALSE;
@@ -1170,7 +1172,7 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
 
 		name = get_connection_id (connection);
 
-		item = GTK_MENU_ITEM (gtk_check_menu_item_new_with_label (name));
+		item = GTK_MENU_ITEM (applet_menu_item_new_with_label (name));
 		gtk_check_menu_item_set_draw_as_radio (GTK_CHECK_MENU_ITEM (item), TRUE);
 
 		/* If no VPN connections are active, draw all menu items enabled. If
@@ -1193,6 +1195,25 @@ nma_menu_add_vpn_submenu (GtkWidget *menu, NMApplet *applet)
 						    g_object_ref (connection),
 						    (GDestroyNotify) g_object_unref);
 
+		if (!is_system_connection (connection)) {
+		    PolKitGnomeAction *pk_gnome_action;
+		    const char * connection_type = NM_SETTING_VPN_SETTING_NAME;
+		    NMSettingIP4Config *s_ip4;
+		    AppletPolKitManagerActionDetails action_details;
+
+		    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE;
+		    s_ip4 = NM_SETTING_IP4_CONFIG (nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG));
+		    if (s_ip4) {
+			const char * ip4_method;
+			ip4_method = nm_setting_ip4_config_get_method (s_ip4);
+			if (!strcmp (ip4_method, "shared")) {
+			    action_details = APPLET_POLKIT_MANAGER_ACTION_CONNECTION_TYPE_WITH_SHARE;
+			}
+		    }
+		    pk_gnome_action = applet_polkit_manager_connect_menu_item_action (applet_polkit_manager_get (), APPLET_MENU_ITEM (item), connection_type, action_details);
+		    g_object_set_data_full (G_OBJECT (item), "polkit_gnome_action", pk_gnome_action, (GDestroyNotify) g_object_unref);
+		}
+
 		g_signal_connect (item, "activate", G_CALLBACK (nma_menu_vpn_item_clicked), applet);
 		gtk_menu_shell_append (GTK_MENU_SHELL (vpn_menu), GTK_WIDGET (item));
 	}
@@ -1292,7 +1313,16 @@ nma_menu_deactivate_cb (GtkWidget *widget, NMApplet *applet)
 	 * the menu items don't get destroyed before any 'activate' signal
 	 * fires for an item.
 	 */
-	g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc) nma_menu_clear, applet, NULL);
+
+	/*
+	 * Authentication of polkit need the menu to be alive. It is OK
+	 * not to set the source for calling nma_menu_clear, as the menu will be
+	 * cleared every time before it will appear in status_icon_activate_cb
+	 * which is the callback of signal activate of status icon.
+	 *
+	 * g_idle_add_full (G_PRIORITY_LOW, (GSourceFunc) nma_menu_clear, applet, NULL);
+	 *
+	 */
 
 	/* Re-set the tooltip */
 #if GTK_CHECK_VERSION(2, 15, 0)
diff --git a/src/applet.h b/src/applet.h
index f333447..d75c781 100644
--- a/src/applet.h
+++ b/src/applet.h
@@ -228,4 +228,6 @@ NMConnection * applet_find_active_connection_for_device (NMDevice *device,
                                                          NMApplet *applet,
                                                          NMActiveConnection **out_active);
 
+gboolean is_system_connection (NMConnection * connection);
+
 #endif
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 1f9e41c..f4513f1 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -318,7 +318,6 @@ nm_connection_editor_init (NMConnectionEditor *editor)
 	editor->system_checkbutton = glade_xml_get_widget (editor->xml, "system_checkbutton");
 
 	editor->system_action = polkit_action_new ();
-	polkit_action_set_action_id (editor->system_action, "org.freedesktop.network-manager-settings.system.modify");
 
 	editor->system_gnome_action = polkit_gnome_action_new ("system");
 
@@ -570,6 +569,7 @@ nm_connection_editor_set_connection (NMConnectionEditor *editor,
 	NMSettingConnection *s_con;
 	const char *connection_type;
 	gboolean success = FALSE;
+	PolKitAction * system_action = editor->system_action;
 
 	g_return_val_if_fail (NM_IS_CONNECTION_EDITOR (editor), FALSE);
 	g_return_val_if_fail (NM_IS_CONNECTION (connection), FALSE);
@@ -593,6 +593,7 @@ nm_connection_editor_set_connection (NMConnectionEditor *editor,
 			goto out;
 		if (!add_page (editor, ce_page_ip4_new, connection, error))
 			goto out;
+		polkit_action_set_action_id(system_action, NM_SYSCONFIG_POLICY_ACTION_SYSTEM_WIRED_MODIFY);
 	} else if (!strcmp (connection_type, NM_SETTING_WIRELESS_SETTING_NAME)) {
 		if (!add_page (editor, ce_page_wireless_new, connection, error))
 			goto out;
@@ -600,11 +601,13 @@ nm_connection_editor_set_connection (NMConnectionEditor *editor,
 			goto out;
 		if (!add_page (editor, ce_page_ip4_new, connection, error))
 			goto out;
+		polkit_action_set_action_id(system_action, NM_SYSCONFIG_POLICY_ACTION_SYSTEM_WIRELESS_MODIFY);
 	} else if (!strcmp (connection_type, NM_SETTING_VPN_SETTING_NAME)) {
 		if (!add_page (editor, ce_page_vpn_new, connection, error))
 			goto out;
 		if (!add_page (editor, ce_page_ip4_new, connection, error))
 			goto out;
+		polkit_action_set_action_id(system_action, NM_SYSCONFIG_POLICY_ACTION_SYSTEM_VPN_MODIFY);
 	} else if (!strcmp (connection_type, NM_SETTING_PPPOE_SETTING_NAME)) {
 		if (!add_page (editor, ce_page_dsl_new, connection, error))
 			goto out;
@@ -614,6 +617,7 @@ nm_connection_editor_set_connection (NMConnectionEditor *editor,
 			goto out;
 		if (!add_page (editor, ce_page_ip4_new, connection, error))
 			goto out;
+		polkit_action_set_action_id(system_action, NM_SYSCONFIG_POLICY_ACTION_SYSTEM_DSL_MODIFY);
 	} else if (!strcmp (connection_type, NM_SETTING_GSM_SETTING_NAME) || 
 	           !strcmp (connection_type, NM_SETTING_CDMA_SETTING_NAME)) {
 		if (!add_page (editor, ce_page_mobile_new, connection, error))
@@ -622,6 +626,7 @@ nm_connection_editor_set_connection (NMConnectionEditor *editor,
 			goto out;
 		if (!add_page (editor, ce_page_ip4_new, connection, error))
 			goto out;
+		polkit_action_set_action_id(system_action, NM_SYSCONFIG_POLICY_ACTION_SYSTEM_MOBILE_MODIFY);
 	} else {
 		g_warning ("Unhandled setting type '%s'", connection_type);
 	}
diff --git a/src/connection-editor/nm-connection-editor.h b/src/connection-editor/nm-connection-editor.h
index 2e6c122..f3daf72 100644
--- a/src/connection-editor/nm-connection-editor.h
+++ b/src/connection-editor/nm-connection-editor.h
@@ -34,6 +34,12 @@
 #include <polkit-gnome/polkit-gnome.h>
 #endif
 
+#define NM_SYSCONFIG_POLICY_ACTION_SYSTEM_WIRED_MODIFY "org.freedesktop.network-manager-settings.system.wired.modify"
+#define NM_SYSCONFIG_POLICY_ACTION_SYSTEM_WIRELESS_MODIFY "org.freedesktop.network-manager-settings.system.wireless.modify"
+#define NM_SYSCONFIG_POLICY_ACTION_SYSTEM_MOBILE_MODIFY "org.freedesktop.network-manager-settings.system.mobile.modify"
+#define NM_SYSCONFIG_POLICY_ACTION_SYSTEM_VPN_MODIFY "org.freedesktop.network-manager-settings.system.vpn.modify"
+#define NM_SYSCONFIG_POLICY_ACTION_SYSTEM_DSL_MODIFY "org.freedesktop.network-manager-settings.system.dsl.modify"
+
 #define NM_TYPE_CONNECTION_EDITOR    (nm_connection_editor_get_type ())
 #define NM_IS_CONNECTION_EDITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NM_TYPE_CONNECTION_EDITOR))
 #define NM_CONNECTION_EDITOR(obj)    (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_EDITOR, NMConnectionEditor))
