[network-manager-applet/cc-bt: 3/3] mobile: consolidate creation of mobile broadband connection IDs
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/cc-bt: 3/3] mobile: consolidate creation of mobile broadband connection IDs
- Date: Wed, 8 Aug 2012 16:50:35 +0000 (UTC)
commit e534378d1138c214e84268351ef2cb04376e27f7
Author: Dan Williams <dcbw redhat com>
Date: Wed Aug 8 11:47:05 2012 -0500
mobile: consolidate creation of mobile broadband connection IDs
Instead of doing the same thing in three places, lets do it in one.
po/POTFILES.in | 1 +
src/applet-device-cdma.c | 5 +----
src/applet-device-gsm.c | 5 +----
src/gnome-bluetooth/nma-bt-device.c | 17 +++--------------
src/utils/utils.c | 13 +++++++++++++
src/utils/utils.h | 3 +++
6 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ab32404..6bd6bdd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -57,6 +57,7 @@ src/libnm-gtk/nm-wireless-dialog.c
src/main.c
src/mb-menu-item.c
src/utils/nmn-mobile-providers.c
+src/utils/utils.c
[type: gettext/glade]src/wired-8021x.ui
src/wired-dialog.c
src/wireless-security/eap-method.c
diff --git a/src/applet-device-cdma.c b/src/applet-device-cdma.c
index 4c18131..1a5ecb7 100644
--- a/src/applet-device-cdma.c
+++ b/src/applet-device-cdma.c
@@ -135,10 +135,7 @@ mobile_wizard_done (NMAMobileWizard *wizard,
nm_connection_add_setting (connection, nm_setting_ppp_new ());
setting = nm_setting_connection_new ();
- if (method->plan_name)
- id = g_strdup_printf ("%s %s", method->provider_name, method->plan_name);
- else
- id = g_strdup_printf ("%s connection", method->provider_name);
+ id = utils_create_mobile_connection_id (method->provider_name, method->plan_name);
uuid = nm_utils_uuid_generate ();
g_object_set (setting,
NM_SETTING_CONNECTION_ID, id,
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
index e9cd1c1..0497ce4 100644
--- a/src/applet-device-gsm.c
+++ b/src/applet-device-gsm.c
@@ -165,10 +165,7 @@ mobile_wizard_done (NMAMobileWizard *wizard,
nm_connection_add_setting (connection, nm_setting_ppp_new ());
setting = nm_setting_connection_new ();
- if (method->plan_name)
- id = g_strdup_printf ("%s %s", method->provider_name, method->plan_name);
- else
- id = g_strdup_printf ("%s connection", method->provider_name);
+ id = utils_create_mobile_connection_id (method->provider_name, method->plan_name);
uuid = nm_utils_uuid_generate ();
g_object_set (setting,
NM_SETTING_CONNECTION_ID, id,
diff --git a/src/gnome-bluetooth/nma-bt-device.c b/src/gnome-bluetooth/nma-bt-device.c
index a81918f..e1b9f38 100644
--- a/src/gnome-bluetooth/nma-bt-device.c
+++ b/src/gnome-bluetooth/nma-bt-device.c
@@ -41,6 +41,7 @@
#include "nma-marshal.h"
#include "nm-mobile-wizard.h"
#include "nm-utils.h"
+#include "utils.h"
#if !GLIB_CHECK_VERSION(2,28,0)
#define g_clear_object(object_ptr) \
@@ -321,18 +322,6 @@ dun_error (NmaBtDevice *self, const char *func, GError *error, const char *fallb
recheck_services_enabled (self);
}
-static char *
-get_connection_name (NMAMobileWizardAccessMethod *method)
-{
- if (method->plan_name) {
- /* Results in something like "T-Mobile ToGo (prepaid)" */
- return g_strdup_printf (_("%s %s"), method->provider_name, method->plan_name);
- }
-
- /* Results in something like "T-Mobile connection" */
- return g_strdup_printf (_("%s connection"), method->provider_name);
-}
-
static NMConnection *
dun_new_cdma (NMAMobileWizardAccessMethod *method)
{
@@ -363,7 +352,7 @@ dun_new_cdma (NMAMobileWizardAccessMethod *method)
nm_connection_add_setting (connection, nm_setting_ppp_new ());
setting = nm_setting_connection_new ();
- id = get_connection_name (method);
+ id = utils_create_mobile_connection_id (method->provider_name, method->plan_name);
uuid = nm_utils_uuid_generate ();
g_object_set (setting,
NM_SETTING_CONNECTION_ID, id,
@@ -409,7 +398,7 @@ dun_new_gsm (NMAMobileWizardAccessMethod *method)
nm_connection_add_setting (connection, nm_setting_ppp_new ());
setting = nm_setting_connection_new ();
- id = get_connection_name (method);
+ id = utils_create_mobile_connection_id (method->provider_name, method->plan_name);
uuid = nm_utils_uuid_generate ();
g_object_set (setting,
NM_SETTING_CONNECTION_ID, id,
diff --git a/src/utils/utils.c b/src/utils/utils.c
index 2560b2e..fac2b4f 100644
--- a/src/utils/utils.c
+++ b/src/utils/utils.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <netinet/ether.h>
#include <glib.h>
+#include <glib/gi18n.h>
#include <gtk/gtk.h>
#include <nm-setting-connection.h>
@@ -312,6 +313,18 @@ utils_escape_notify_message (const char *src)
return g_string_free (escaped, FALSE);
}
+char *
+utils_create_mobile_connection_id (const char *provider, const char *plan_name)
+{
+ g_return_val_if_fail (provider != NULL, NULL);
+
+ if (plan_name)
+ return g_strdup_printf ("%s %s", provider, plan_name);
+
+ /* The %s is a mobile provider name, eg "T-Mobile" */
+ return g_strdup_printf (_("%s connection"), provider);
+}
+
void
utils_show_error_dialog (const char *title,
const char *text1,
diff --git a/src/utils/utils.h b/src/utils/utils.h
index 8d56293..e3d231a 100644
--- a/src/utils/utils.h
+++ b/src/utils/utils.h
@@ -46,6 +46,9 @@ char *utils_hash_ap (const GByteArray *ssid,
char *utils_escape_notify_message (const char *src);
+char *utils_create_mobile_connection_id (const char *provider,
+ const char *plan_name);
+
void utils_show_error_dialog (const char *title,
const char *text1,
const char *text2,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]