1
commit 48892f9ff93f48fc560e706f47afcaadd002f41e
2
Author: Tambet Ingo <tambet@gmail.com>
3
Date: Tue Jan 13 13:36:29 2009 +0200
7
diff --git a/configure.ac b/configure.ac
8
index 7524739..db7597a 100644
11
@@ -222,6 +222,7 @@ src/gconf-helpers/Makefile
12
src/wireless-security/Makefile
13
src/polkit-helpers/Makefile
14
src/connection-editor/Makefile
19
diff --git a/src/Makefile.am b/src/Makefile.am
20
index 3486186..33d2c49 100644
24
-SUBDIRS = marshallers utils gconf-helpers wireless-security polkit-helpers connection-editor
25
+SUBDIRS = marshallers utils gconf-helpers wireless-security polkit-helpers connection-editor modems
29
@@ -49,6 +49,9 @@ nm_applet_SOURCES = \
31
applet-device-cdma.h \
32
applet-device-cdma.c \
39
diff --git a/src/applet-device-gsm.c b/src/applet-device-gsm.c
40
index eaacf48..2a3d8bc 100644
41
--- a/src/applet-device-gsm.c
42
+++ b/src/applet-device-gsm.c
47
+#include <sys/types.h>
50
#include <glib/gi18n.h>
51
#include <gtk/gtkwidget.h>
52
#include <gtk/gtkmenuitem.h>
56
#include "applet-device-gsm.h"
57
+#include "nma-gsm-modem.h"
58
+#include "mm-types.h"
62
@@ -174,6 +179,50 @@ add_default_connection_item (NMDevice *device,
66
+child_setup (gpointer user_data G_GNUC_UNUSED)
68
+ /* We are in the child process at this point */
69
+ pid_t pid = getpid ();
74
+gsm_properties_cb (GtkMenuItem *mi, gpointer user_data)
76
+ NMDevice *device = NM_DEVICE (user_data);
78
+ GError *error = NULL;
81
+ argv[0] = BINDIR "/nm-modem-properties";
82
+ argv[1] = (char *) nm_device_get_udi (device);
85
+ success = g_spawn_async ("/", argv, NULL, 0, &child_setup, NULL, NULL, &error);
87
+ g_warning ("Error launching modem properties dialog: %s", error->message);
88
+ g_error_free (error);
93
+add_properties_item (NMDevice *device,
98
+ if (nm_device_get_state (device) != NM_DEVICE_STATE_DISCONNECTED)
101
+ item = gtk_menu_item_new_with_label (_("Properties"));
102
+ g_signal_connect (item, "activate",
103
+ G_CALLBACK (gsm_properties_cb),
106
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
110
gsm_menu_item_deactivate (GtkMenuItem *item, gpointer user_data)
112
GSMMenuItemInfo *info = (GSMMenuItemInfo *) user_data;
113
@@ -273,41 +322,67 @@ gsm_add_menu_item (NMDevice *device,
114
add_connection_items (device, connections, active, menu, applet);
116
add_default_connection_item (device, menu, applet);
118
add_disconnect_item (device, menu, applet);
119
+ add_properties_item (device, menu);
122
g_slist_free (connections);
126
+signal_quality_changed (NMAGsmModem *modem, guint32 quality, gpointer user_data)
128
+ applet_schedule_update_icon (NM_APPLET (user_data));
132
gsm_device_state_changed (NMDevice *device,
133
NMDeviceState new_state,
134
NMDeviceState old_state,
135
NMDeviceStateReason reason,
138
- if (new_state == NM_DEVICE_STATE_ACTIVATED) {
139
- NMConnection *connection;
140
- NMSettingConnection *s_con = NULL;
143
- connection = applet_find_active_connection_for_device (device, applet, NULL);
147
- s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
148
- id = s_con ? nm_setting_connection_get_id (s_con) : NULL;
150
- str = g_strdup_printf (_("You are now connected to '%s'."), id);
152
+ NMAGsmModem *modem;
156
+ guint32 reg_status;
158
+ if (new_state != NM_DEVICE_STATE_ACTIVATED)
161
- applet_do_notify_with_pref (applet,
162
- _("Connection Established"),
163
- str ? str : _("You are now connected to the GSM network."),
165
- PREF_DISABLE_CONNECTED_NOTIFICATIONS);
167
+ modem = (NMAGsmModem *) g_object_get_data (G_OBJECT (device), "gsm-modem");
169
+ DBusGConnection *bus;
171
+ bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, NULL);
175
+ modem = nma_gsm_modem_new (bus, nm_device_get_udi (device));
176
+ dbus_g_connection_unref (bus);
178
+ g_object_set_data_full (G_OBJECT (device), "gsm-modem", modem, g_object_unref);
180
+ g_signal_connect (modem, "signal-quality",
181
+ G_CALLBACK (signal_quality_changed),
187
+ reg_status = nma_gsm_modem_get_registration_info (modem, &oper_code, &oper_name);
188
+ msg = g_strdup_printf (_("You are now connected to the %s GSM network '%s'."),
189
+ reg_status == MM_GSM_MODEM_REG_STATUS_ROAMING ? _("roaming") : _("home"),
192
+ applet_do_notify_with_pref (applet, _("Connection Established"), msg,
193
+ "nm-device-wwan", PREF_DISABLE_CONNECTED_NOTIFICATIONS);
195
+ g_free (oper_code);
196
+ g_free (oper_name);
201
@@ -318,6 +393,7 @@ gsm_get_icon (NMDevice *device,
204
NMSettingConnection *s_con;
205
+ NMAGsmModem *modem;
206
GdkPixbuf *pixbuf = NULL;
209
@@ -341,8 +417,40 @@ gsm_get_icon (NMDevice *device,
210
*tip = g_strdup_printf (_("Requesting a network address for '%s'..."), id);
212
case NM_DEVICE_STATE_ACTIVATED:
213
- pixbuf = applet->wwan_icon;
214
- *tip = g_strdup_printf (_("Mobile broadband connection '%s' active"), id);
215
+ modem = (NMAGsmModem *) g_object_get_data (G_OBJECT (device), "gsm-modem");
219
+ guint32 reg_status;
222
+ quality = nma_gsm_modem_get_signal_quality (modem);
223
+ quality = CLAMP (quality, 0, 100);
226
+ pixbuf = applet->wireless_100_icon;
227
+ else if (quality > 55)
228
+ pixbuf = applet->wireless_75_icon;
229
+ else if (quality > 30)
230
+ pixbuf = applet->wireless_50_icon;
231
+ else if (quality > 5)
232
+ pixbuf = applet->wireless_25_icon;
234
+ pixbuf = applet->wireless_00_icon;
236
+ reg_status = nma_gsm_modem_get_registration_info (modem, &oper_code, &oper_name);
237
+ *tip = g_strdup_printf (_("%s GSM connection '%s' (%d%%)"),
238
+ reg_status == MM_GSM_MODEM_REG_STATUS_ROAMING ? _("Roaming") : _("Home"),
239
+ oper_name, quality);
241
+ g_free (oper_name);
242
+ g_free (oper_code);
245
+ pixbuf = applet->wireless_00_icon;
246
+ *tip = g_strdup_printf (_("GSM connection"));
252
@@ -514,6 +622,7 @@ ask_for_pin_puk (NMDevice *device,
254
w = gtk_entry_new ();
255
*out_secret_entry = GTK_ENTRY (w);
256
+ gtk_entry_set_visibility (GTK_ENTRY (w), FALSE);
257
gtk_entry_set_max_length (GTK_ENTRY (w), 4);
258
gtk_entry_set_width_chars (GTK_ENTRY (w), 4);
259
gtk_entry_set_activates_default (GTK_ENTRY (w), TRUE);
260
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
261
index 2522ff1..40f2d44 100644
262
--- a/src/connection-editor/page-mobile.c
263
+++ b/src/connection-editor/page-mobile.c
264
@@ -107,7 +107,6 @@ populate_gsm_ui (CEPageMobile *self, NMConnection *connection)
271
s = nm_setting_gsm_get_number (setting);
272
@@ -146,17 +145,6 @@ populate_gsm_ui (CEPageMobile *self, NMConnection *connection)
274
gtk_combo_box_set_active (priv->network_type, type_idx);
276
- /* Hide network type widgets; not supported yet */
277
- gtk_widget_hide (GTK_WIDGET (priv->network_type));
278
- widget = glade_xml_get_widget (CE_PAGE (self)->xml, "type_label");
279
- gtk_widget_hide (widget);
281
- /* Hide Band widgets; not supported yet */
282
- widget = glade_xml_get_widget (CE_PAGE (self)->xml, "mobile_band");
283
- gtk_widget_hide (widget);
284
- widget = glade_xml_get_widget (CE_PAGE (self)->xml, "band_label");
285
- gtk_widget_hide (widget);
287
secrets = get_secrets (connection, nm_setting_get_name (priv->setting));
289
s = nm_setting_gsm_get_password (setting);
290
diff --git a/src/mm-types.h b/src/mm-types.h
292
index 0000000..a1f9979
296
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
301
+#define MM_DBUS_SERVICE "org.freedesktop.ModemManager"
302
+#define MM_DBUS_INTERFACE_MODEM_GSM "org.freedesktop.ModemManager.Modem.Gsm.Network"
305
+ MM_GSM_MODEM_REG_STATUS_IDLE = 0,
306
+ MM_GSM_MODEM_REG_STATUS_HOME = 1,
307
+ MM_GSM_MODEM_REG_STATUS_SEARCHING = 2,
308
+ MM_GSM_MODEM_REG_STATUS_DENIED = 3,
309
+ MM_GSM_MODEM_REG_STATUS_UNKNOWN = 4,
310
+ MM_GSM_MODEM_REG_STATUS_ROAMING = 5
313
+#endif /* MM_TYPES_H */
314
diff --git a/src/modems/Makefile.am b/src/modems/Makefile.am
316
index 0000000..206ee52
318
+++ b/src/modems/Makefile.am
320
+bin_PROGRAMS = nm-modem-properties
322
+nm_modem_properties_CPPFLAGS = \
324
+ -DICONDIR=\""$(datadir)/icons"\" \
325
+ -DGLADEDIR=\""$(gladedir)"\" \
326
+ -DBINDIR=\""$(bindir)"\" \
327
+ -DSYSCONFDIR=\""$(sysconfdir)"\" \
328
+ -DLIBDIR=\""$(libdir)"\" \
329
+ -DNMALOCALEDIR=\"$(datadir)/locale\" \
331
+ -I${top_srcdir}/src/gconf-helpers
333
+nm_modem_properties_SOURCES = \
336
+nm_modem_properties_LDADD = \
337
+ $(top_builddir)/src/gconf-helpers/libgconf-helpers.la \
340
+gladedir = $(datadir)/nm-applet
341
+glade_DATA = nm-modem-properties.glade
343
+CLEANFILES = *.bak *.gladep
344
+EXTRA_DIST = $(glade_DATA)
345
diff --git a/src/modems/main.c b/src/modems/main.c
347
index 0000000..3243a6c
349
+++ b/src/modems/main.c
351
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
354
+#include <gtk/gtk.h>
355
+#include <glade/glade.h>
356
+#include <dbus/dbus-glib.h>
357
+#include <gconf/gconf-client.h>
358
+#include <nm-connection.h>
359
+#include <nm-setting-connection.h>
360
+#include <nm-setting-gsm.h>
361
+#include <nm-setting-serial.h>
362
+#include <nm-setting-ppp.h>
363
+#include <nm-utils.h>
364
+#include "gconf-helpers.h"
366
+#define MM_DBUS_SERVICE "org.freedesktop.ModemManager"
367
+#define MM_DBUS_PATH "/org/freedesktop/ModemManager"
368
+#define MM_DBUS_INTERFACE "org.freedesktop.ModemManager"
369
+#define MM_DBUS_INTERFACE_MODEM "org.freedesktop.ModemManager.Modem"
371
+#define MM_DBUS_INTERFACE_MODEM_GSM_CARD "org.freedesktop.ModemManager.Modem.Gsm.Card"
372
+#define MM_DBUS_INTERFACE_MODEM_GSM_NETWORK "org.freedesktop.ModemManager.Modem.Gsm.Network"
374
+#define MM_MODEM_TYPE_UNKNOWN 0
375
+#define MM_MODEM_TYPE_GSM 1
376
+#define MM_MODEM_TYPE_CDMA 2
378
+#define SCAN_COL_NAME 0
379
+#define SCAN_COL_STATUS 1
380
+#define SCAN_COL_OPER_ID 2
384
+ GladeXML *glade_xml;
385
+ GtkDialog *main_dialog;
386
+ GtkTreeView *network_list;
387
+ GtkListStore *network_store;
388
+ GtkWidget *scan_button;
389
+ GtkWidget *create_net_button;
391
+ GtkWidget *scan_dialog;
392
+ GtkProgressBar *scan_progress_bar;
394
+ GtkDialog *create_network_dialog;
395
+ GtkEntry *create_network_name;
398
+ DBusGConnection *bus;
400
+ DBusGProxy *gsm_net_proxy;
402
+ GMainLoop *main_loop;
406
+get_str_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
408
+ char *result = NULL;
409
+ GError *error = NULL;
411
+ if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_STRING, &result, G_TYPE_INVALID)) {
412
+ g_warning ("%s", error->message);
413
+ g_error_free (error);
415
+ gtk_label_set_text (GTK_LABEL (user_data), result);
421
+get_card_info_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
423
+ GladeXML *glade_xml = GLADE_XML (user_data);
424
+ char *manufacturer = NULL;
425
+ char *model = NULL;
426
+ char *version = NULL;
427
+ GError *error = NULL;
429
+ if (!dbus_g_proxy_end_call (proxy, call_id, &error,
430
+ G_TYPE_STRING, &manufacturer,
431
+ G_TYPE_STRING, &model,
432
+ G_TYPE_STRING, &version,
434
+ g_warning ("Couldn't get modem information: %s", error->message);
435
+ g_error_free (error);
437
+ gtk_label_set_text (GTK_LABEL (glade_xml_get_widget (glade_xml, "vendor_label")), manufacturer);
438
+ gtk_label_set_text (GTK_LABEL (glade_xml_get_widget (glade_xml, "model_label")), model);
439
+ gtk_label_set_text (GTK_LABEL (glade_xml_get_widget (glade_xml, "version_label")), version);
441
+ g_free (manufacturer);
448
+get_property_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
450
+ GValue value = { 0, };
451
+ GError *error = NULL;
453
+ if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) {
454
+ g_warning ("%s", error->message);
455
+ g_error_free (error);
457
+ gtk_label_set_text (GTK_LABEL (user_data), g_value_get_string (&value));
458
+ g_value_unset (&value);
463
+get_info (gpointer data)
465
+ AppData *app_data = (AppData *) data;
467
+ dbus_g_proxy_set_interface (app_data->proxy, MM_DBUS_INTERFACE_MODEM_GSM_CARD);
468
+ dbus_g_proxy_begin_call (app_data->proxy, "GetImsi", get_str_done,
469
+ glade_xml_get_widget (app_data->glade_xml, "imsi_label"), NULL,
472
+ dbus_g_proxy_begin_call (app_data->proxy, "GetImei", get_str_done,
473
+ glade_xml_get_widget (app_data->glade_xml, "imei_label"), NULL,
476
+ dbus_g_proxy_begin_call (app_data->proxy, "GetInfo", get_card_info_done,
477
+ app_data->glade_xml, NULL,
480
+ dbus_g_proxy_set_interface (app_data->proxy, "org.freedesktop.DBus.Properties");
482
+ dbus_g_proxy_begin_call (app_data->proxy, "Get", get_property_done,
483
+ glade_xml_get_widget (app_data->glade_xml, "driver_label"), NULL,
484
+ G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM,
485
+ G_TYPE_STRING, "Driver",
488
+ dbus_g_proxy_begin_call (app_data->proxy, "Get", get_property_done,
489
+ glade_xml_get_widget (app_data->glade_xml, "device_label"), NULL,
490
+ G_TYPE_STRING, MM_DBUS_INTERFACE_MODEM,
491
+ G_TYPE_STRING, "DataDevice",
498
+got_signal_quality (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
500
+ guint32 quality = 0;
501
+ GError *error = NULL;
503
+ if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_UINT, &quality, G_TYPE_INVALID)) {
504
+ g_warning ("%s", error->message);
505
+ g_error_free (error);
509
+ tmp = g_strdup_printf ("%d%%", quality);
510
+ gtk_label_set_text (GTK_LABEL (user_data), tmp);
516
+signal_quality_changed (DBusGProxy *proxy,
517
+ guint32 signal_quality,
518
+ gpointer user_data)
522
+ tmp = g_strdup_printf ("%d%%", signal_quality);
523
+ gtk_label_set_text (GTK_LABEL (user_data), tmp);
528
+monitor_signal_quality (gpointer data)
530
+ AppData *app_data = (AppData *) data;
533
+ label = glade_xml_get_widget (app_data->glade_xml, "signal_quality_label");
535
+ dbus_g_proxy_add_signal (app_data->gsm_net_proxy, "SignalQuality", G_TYPE_UINT, G_TYPE_INVALID);
536
+ dbus_g_proxy_connect_signal (app_data->gsm_net_proxy, "SignalQuality",
537
+ G_CALLBACK (signal_quality_changed),
540
+ dbus_g_proxy_begin_call (app_data->gsm_net_proxy, "GetSignalQuality",
541
+ got_signal_quality, label, NULL, G_TYPE_INVALID);
547
+got_scan_results (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
549
+ AppData *app_data = (AppData *) user_data;
550
+ GPtrArray *array = NULL;
551
+ GError *error = NULL;
554
+ type = dbus_g_type_get_collection ("GPtrArray", DBUS_TYPE_G_STRING_STRING_HASHTABLE);
556
+ if (!dbus_g_proxy_end_call (proxy, call_id, &error, type, &array, G_TYPE_INVALID)) {
557
+ g_warning ("Couldn't scan: %s", error->message);
558
+ g_error_free (error);
563
+ for (i = 0; i < array->len; i++) {
564
+ GHashTable *hash = (GHashTable *) g_ptr_array_index (array, i);
566
+ const char *status_str;
568
+ status = g_hash_table_lookup (hash, "status");
569
+ if (!strcmp (status, "1"))
570
+ status_str = "Available";
571
+ else if (!strcmp (status, "2"))
572
+ status_str = "Current";
573
+ else if (!strcmp (status, "3"))
574
+ status_str = "Forbidden";
576
+ status_str = "Unknown";
578
+ gtk_list_store_append (app_data->network_store, &iter);
579
+ gtk_list_store_set (app_data->network_store, &iter,
580
+ SCAN_COL_NAME, g_hash_table_lookup (hash, "operator-long"),
581
+ SCAN_COL_STATUS, status_str,
582
+ SCAN_COL_OPER_ID, g_hash_table_lookup (hash, "operator-num"),
585
+ g_hash_table_destroy (hash);
588
+ g_ptr_array_free (array, TRUE);
591
+ gtk_widget_hide (app_data->scan_dialog);
592
+ gtk_widget_set_sensitive (app_data->scan_button, TRUE);
596
+scan_pulse (gpointer data)
598
+ GtkProgressBar *bar = GTK_PROGRESS_BAR (data);
600
+ gtk_progress_bar_pulse (bar);
601
+ return gdk_window_is_visible (gtk_widget_get_parent_window (GTK_WIDGET (bar)));
605
+scan (GtkButton *button, gpointer user_data)
607
+ AppData *app_data = (AppData *) user_data;
609
+ dbus_g_proxy_begin_call_with_timeout (app_data->gsm_net_proxy, "Scan", got_scan_results,
610
+ app_data, NULL, 120000, G_TYPE_INVALID);
612
+ gtk_widget_set_sensitive (app_data->scan_button, FALSE);
613
+ gtk_list_store_clear (app_data->network_store);
615
+ g_timeout_add (200, scan_pulse, app_data->scan_progress_bar);
616
+ gtk_widget_show (app_data->scan_dialog);
620
+modem_enabled (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
622
+ AppData *app_data = (AppData *) user_data;
623
+ GError *error = NULL;
625
+ if (!dbus_g_proxy_end_call (proxy, call_id, &error, G_TYPE_INVALID)) {
626
+ g_warning ("Couldn't enable modem: %s", error->message);
627
+ g_error_free (error);
628
+ g_main_loop_quit (app_data->main_loop);
632
+ g_idle_add (get_info, app_data);
633
+ g_idle_add (monitor_signal_quality, app_data);
637
+modem_enable (AppData *app_data)
639
+ dbus_g_proxy_begin_call (app_data->proxy, "Enable", modem_enabled,
641
+ G_TYPE_BOOLEAN, TRUE, G_TYPE_INVALID);
645
+create_network (const char *name, const char *oper_code)
647
+ NMConnection *connection;
648
+ NMSettingGsm *s_gsm;
649
+ NMSettingSerial *s_serial;
650
+ NMSettingPPP *s_ppp;
651
+ NMSettingConnection *s_con;
652
+ GConfClient *gconf_client;
655
+ connection = nm_connection_new ();
657
+ s_gsm = NM_SETTING_GSM (nm_setting_gsm_new ());
658
+ g_object_set (s_gsm,
659
+ NM_SETTING_GSM_NUMBER, "*99#",
660
+ NM_SETTING_GSM_NETWORK_ID, oper_code,
663
+ nm_connection_add_setting (connection, NM_SETTING (s_gsm));
665
+ /* Serial setting */
666
+ s_serial = (NMSettingSerial *) nm_setting_serial_new ();
667
+ g_object_set (s_serial,
668
+ NM_SETTING_SERIAL_BAUD, 115200,
669
+ NM_SETTING_SERIAL_BITS, 8,
670
+ NM_SETTING_SERIAL_PARITY, 'n',
671
+ NM_SETTING_SERIAL_STOPBITS, 1,
674
+ nm_connection_add_setting (connection, NM_SETTING (s_serial));
676
+ s_ppp = (NMSettingPPP *) nm_setting_ppp_new ();
677
+ nm_connection_add_setting (connection, NM_SETTING (s_ppp));
679
+ s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
680
+ uuid = nm_utils_uuid_generate ();
681
+ g_object_set (s_con,
682
+ NM_SETTING_CONNECTION_ID, name,
683
+ NM_SETTING_CONNECTION_TYPE, nm_setting_get_name (NM_SETTING (s_gsm)),
684
+ NM_SETTING_CONNECTION_AUTOCONNECT, FALSE,
685
+ NM_SETTING_CONNECTION_UUID, uuid,
689
+ nm_connection_add_setting (connection, NM_SETTING (s_con));
691
+ gconf_client = gconf_client_get_default ();
692
+ if (gconf_client) {
696
+ /* Find free GConf directory */
697
+ for (i = 0; i < G_MAXUINT32; i++) {
700
+ snprintf (&buf[0], 255, GCONF_PATH_CONNECTIONS"/%d", i);
701
+ if (!gconf_client_dir_exists (gconf_client, buf, NULL)) {
702
+ dir = g_strdup (buf);
707
+ nm_gconf_write_connection (connection, gconf_client, dir);
708
+ gconf_client_notify (gconf_client, dir);
709
+ gconf_client_suggest_sync (gconf_client, NULL);
711
+ g_object_unref (gconf_client);
713
+ g_warning ("Writing conneciton failed");
715
+ g_object_unref (connection);
719
+create_network_clicked (GtkButton *button, gpointer user_data)
721
+ AppData *app_data = (AppData *) user_data;
722
+ GtkTreeSelection *selection;
723
+ GList *selected_rows;
724
+ GtkTreeModel *model = NULL;
727
+ selection = gtk_tree_view_get_selection (app_data->network_list);
728
+ selected_rows = gtk_tree_selection_get_selected_rows (selection, &model);
729
+ if (!selected_rows)
732
+ if (gtk_tree_model_get_iter (model, &iter, (GtkTreePath *) selected_rows->data)) {
733
+ char *oper_name = NULL;
734
+ char *oper_id = NULL;
737
+ gtk_tree_model_get (model, &iter, SCAN_COL_NAME, &oper_name, -1);
738
+ gtk_tree_model_get (model, &iter, SCAN_COL_OPER_ID, &oper_id, -1);
740
+ gtk_entry_set_text (app_data->create_network_name, oper_name);
741
+ gtk_editable_select_region (GTK_EDITABLE (app_data->create_network_name), 0, -1);
742
+ gtk_widget_grab_focus (GTK_WIDGET (app_data->create_network_name));
744
+ result = gtk_dialog_run (app_data->create_network_dialog);
745
+ gtk_widget_hide (GTK_WIDGET (app_data->create_network_dialog));
747
+ if (result == GTK_RESPONSE_OK)
748
+ create_network (gtk_entry_get_text (app_data->create_network_name), oper_id);
750
+ g_free (oper_name);
755
+ g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
756
+ g_list_free (selected_rows);
760
+network_list_selection_changed (GtkTreeSelection *selection, gpointer user_data)
762
+ AppData *app_data = (AppData *) user_data;
764
+ GtkTreeModel *model;
766
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
767
+ gtk_widget_set_sensitive (app_data->create_net_button, TRUE);
769
+ gtk_widget_set_sensitive (app_data->create_net_button, FALSE);
774
+app_data_destroy (AppData *app_data)
777
+ dbus_g_connection_unref (app_data->bus);
779
+ if (app_data->proxy)
780
+ g_object_unref (app_data->proxy);
782
+ if (app_data->gsm_net_proxy)
783
+ g_object_unref (app_data->gsm_net_proxy);
785
+ if (app_data->glade_xml)
786
+ g_object_unref (app_data->glade_xml);
788
+ if (app_data->main_loop)
789
+ g_main_loop_unref (app_data->main_loop);
791
+ g_slice_free (AppData, app_data);
795
+close_cb (GtkDialog *dialog,
797
+ gpointer user_data)
799
+ AppData *app_data = (AppData *) user_data;
801
+ dbus_g_proxy_set_interface (app_data->proxy, MM_DBUS_INTERFACE_MODEM);
802
+ dbus_g_proxy_call_no_reply (app_data->proxy, "Enable", G_TYPE_BOOLEAN, FALSE, G_TYPE_INVALID);
804
+ g_main_loop_quit (app_data->main_loop);
805
+ app_data_destroy (app_data);
809
+static GtkListStore *
810
+prepare_network_list (GtkTreeView *treeview)
812
+ GtkListStore *store;
814
+ store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
815
+ gtk_tree_view_set_model (treeview, GTK_TREE_MODEL (store));
816
+ g_object_unref (store);
818
+ gtk_tree_view_insert_column_with_attributes (treeview,
819
+ -1, "Name", gtk_cell_renderer_text_new (),
820
+ "text", SCAN_COL_NAME,
823
+ gtk_tree_view_insert_column_with_attributes (treeview,
824
+ -1, "Status", gtk_cell_renderer_text_new (),
825
+ "text", SCAN_COL_STATUS,
832
+app_data_create (const char *udi)
835
+ GtkTreeSelection *selection;
836
+ GError *error = NULL;
838
+ app_data = g_slice_new0 (AppData);
841
+ app_data->bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error);
842
+ if (!app_data->bus) {
843
+ g_error ("Couldn't connect to DBus: %s", error->message);
844
+ g_error_free (error);
845
+ g_slice_free (AppData, app_data);
850
+ app_data->proxy = dbus_g_proxy_new_for_name (app_data->bus, MM_DBUS_SERVICE, udi, MM_DBUS_INTERFACE_MODEM);
851
+ app_data->gsm_net_proxy = dbus_g_proxy_new_from_proxy (app_data->proxy, MM_DBUS_INTERFACE_MODEM_GSM_NETWORK, NULL);
854
+ app_data->glade_xml = glade_xml_new (GLADEDIR "/nm-modem-properties.glade", NULL, NULL);
855
+ if (!app_data->glade_xml) {
856
+ g_error ("Could not load Glade file");
857
+ g_slice_free (AppData, app_data);
862
+ app_data->main_dialog = GTK_DIALOG (glade_xml_get_widget (app_data->glade_xml, "main_dialog"));
863
+ g_signal_connect (app_data->main_dialog, "response", G_CALLBACK (close_cb), app_data);
865
+ app_data->network_list = GTK_TREE_VIEW (glade_xml_get_widget (app_data->glade_xml, "network_list"));
866
+ app_data->network_store = prepare_network_list (app_data->network_list);
867
+ app_data->scan_button = glade_xml_get_widget (app_data->glade_xml, "scan_button");
868
+ g_signal_connect (app_data->scan_button, "clicked", G_CALLBACK (scan), app_data);
870
+ app_data->scan_dialog = glade_xml_get_widget (app_data->glade_xml, "scan_dialog");
871
+ gtk_window_set_transient_for (GTK_WINDOW (app_data->scan_dialog), GTK_WINDOW (app_data->main_dialog));
873
+ app_data->scan_progress_bar = GTK_PROGRESS_BAR (glade_xml_get_widget (app_data->glade_xml, "scan_progress_bar"));
875
+ app_data->create_net_button = glade_xml_get_widget (app_data->glade_xml, "create_connection_button");
876
+ gtk_widget_set_sensitive (app_data->create_net_button, FALSE);
877
+ g_signal_connect (app_data->create_net_button, "clicked", G_CALLBACK (create_network_clicked), app_data);
878
+ selection = gtk_tree_view_get_selection (app_data->network_list);
879
+ g_signal_connect (selection, "changed", G_CALLBACK (network_list_selection_changed), app_data);
881
+ app_data->create_network_dialog = GTK_DIALOG (glade_xml_get_widget (app_data->glade_xml, "create_network_dialog"));
882
+ app_data->create_network_name = GTK_ENTRY (glade_xml_get_widget (app_data->glade_xml, "create_network_name"));
884
+ app_data->main_loop = g_main_loop_new (NULL, FALSE);
890
+main (int argc, char *argv[])
892
+ //const char *udi = "/org/freedesktop/Hal/devices/usb_device_12d1_1003_noserial_if0_serial_usb_0";
896
+ g_print ("Usage: %s <udi>\n", argv[0]);
900
+ gtk_init (&argc, &argv);
902
+ app_data = app_data_create (argv[1]);
904
+ modem_enable (app_data);
905
+ g_main_loop_run (app_data->main_loop);
910
diff --git a/src/modems/nm-modem-properties.glade b/src/modems/nm-modem-properties.glade
912
index 0000000..5c1285c
914
+++ b/src/modems/nm-modem-properties.glade
916
+<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
917
+<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
921
+<widget class="GtkDialog" id="main_dialog">
922
+ <property name="visible">True</property>
923
+ <property name="title" translatable="yes">GSM modem properties</property>
924
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
925
+ <property name="window_position">GTK_WIN_POS_NONE</property>
926
+ <property name="modal">False</property>
927
+ <property name="resizable">True</property>
928
+ <property name="destroy_with_parent">False</property>
929
+ <property name="decorated">True</property>
930
+ <property name="skip_taskbar_hint">False</property>
931
+ <property name="skip_pager_hint">False</property>
932
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
933
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
934
+ <property name="focus_on_map">True</property>
935
+ <property name="urgency_hint">False</property>
936
+ <property name="has_separator">True</property>
938
+ <child internal-child="vbox">
939
+ <widget class="GtkVBox" id="dialog-vbox1">
940
+ <property name="visible">True</property>
941
+ <property name="homogeneous">False</property>
942
+ <property name="spacing">0</property>
944
+ <child internal-child="action_area">
945
+ <widget class="GtkHButtonBox" id="dialog-action_area1">
946
+ <property name="visible">True</property>
947
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
950
+ <widget class="GtkButton" id="closebutton1">
951
+ <property name="visible">True</property>
952
+ <property name="can_default">True</property>
953
+ <property name="can_focus">True</property>
954
+ <property name="label">gtk-close</property>
955
+ <property name="use_stock">True</property>
956
+ <property name="relief">GTK_RELIEF_NORMAL</property>
957
+ <property name="focus_on_click">True</property>
958
+ <property name="response_id">-7</property>
963
+ <property name="padding">0</property>
964
+ <property name="expand">False</property>
965
+ <property name="fill">True</property>
966
+ <property name="pack_type">GTK_PACK_END</property>
971
+ <widget class="GtkVBox" id="vbox1">
972
+ <property name="visible">True</property>
973
+ <property name="homogeneous">False</property>
974
+ <property name="spacing">6</property>
977
+ <widget class="GtkHBox" id="hbox2">
978
+ <property name="visible">True</property>
979
+ <property name="homogeneous">False</property>
980
+ <property name="spacing">6</property>
983
+ <widget class="GtkFrame" id="frame1">
984
+ <property name="visible">True</property>
985
+ <property name="label_xalign">0</property>
986
+ <property name="label_yalign">0.5</property>
987
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
990
+ <widget class="GtkAlignment" id="alignment1">
991
+ <property name="visible">True</property>
992
+ <property name="xalign">0.5</property>
993
+ <property name="yalign">0.5</property>
994
+ <property name="xscale">1</property>
995
+ <property name="yscale">1</property>
996
+ <property name="top_padding">0</property>
997
+ <property name="bottom_padding">0</property>
998
+ <property name="left_padding">12</property>
999
+ <property name="right_padding">0</property>
1002
+ <widget class="GtkTable" id="info_table">
1003
+ <property name="visible">True</property>
1004
+ <property name="n_rows">8</property>
1005
+ <property name="n_columns">2</property>
1006
+ <property name="homogeneous">False</property>
1007
+ <property name="row_spacing">0</property>
1008
+ <property name="column_spacing">6</property>
1011
+ <widget class="GtkLabel" id="label6">
1012
+ <property name="visible">True</property>
1013
+ <property name="label" translatable="yes">Vendor</property>
1014
+ <property name="use_underline">False</property>
1015
+ <property name="use_markup">False</property>
1016
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1017
+ <property name="wrap">False</property>
1018
+ <property name="selectable">False</property>
1019
+ <property name="xalign">0</property>
1020
+ <property name="yalign">0</property>
1021
+ <property name="xpad">0</property>
1022
+ <property name="ypad">0</property>
1023
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1024
+ <property name="width_chars">-1</property>
1025
+ <property name="single_line_mode">False</property>
1026
+ <property name="angle">0</property>
1029
+ <property name="left_attach">0</property>
1030
+ <property name="right_attach">1</property>
1031
+ <property name="top_attach">0</property>
1032
+ <property name="bottom_attach">1</property>
1033
+ <property name="x_options">fill</property>
1034
+ <property name="y_options"></property>
1039
+ <widget class="GtkLabel" id="label7">
1040
+ <property name="visible">True</property>
1041
+ <property name="label" translatable="yes">Model</property>
1042
+ <property name="use_underline">False</property>
1043
+ <property name="use_markup">False</property>
1044
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1045
+ <property name="wrap">False</property>
1046
+ <property name="selectable">False</property>
1047
+ <property name="xalign">0</property>
1048
+ <property name="yalign">0</property>
1049
+ <property name="xpad">0</property>
1050
+ <property name="ypad">0</property>
1051
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1052
+ <property name="width_chars">-1</property>
1053
+ <property name="single_line_mode">False</property>
1054
+ <property name="angle">0</property>
1057
+ <property name="left_attach">0</property>
1058
+ <property name="right_attach">1</property>
1059
+ <property name="top_attach">1</property>
1060
+ <property name="bottom_attach">2</property>
1061
+ <property name="x_options">fill</property>
1062
+ <property name="y_options"></property>
1067
+ <widget class="GtkLabel" id="label8">
1068
+ <property name="visible">True</property>
1069
+ <property name="label" translatable="yes">Version</property>
1070
+ <property name="use_underline">False</property>
1071
+ <property name="use_markup">False</property>
1072
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1073
+ <property name="wrap">False</property>
1074
+ <property name="selectable">False</property>
1075
+ <property name="xalign">0</property>
1076
+ <property name="yalign">0</property>
1077
+ <property name="xpad">0</property>
1078
+ <property name="ypad">0</property>
1079
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1080
+ <property name="width_chars">-1</property>
1081
+ <property name="single_line_mode">False</property>
1082
+ <property name="angle">0</property>
1085
+ <property name="left_attach">0</property>
1086
+ <property name="right_attach">1</property>
1087
+ <property name="top_attach">2</property>
1088
+ <property name="bottom_attach">3</property>
1089
+ <property name="x_options">fill</property>
1090
+ <property name="y_options"></property>
1095
+ <widget class="GtkLabel" id="label9">
1096
+ <property name="visible">True</property>
1097
+ <property name="label" translatable="yes">Driver</property>
1098
+ <property name="use_underline">False</property>
1099
+ <property name="use_markup">False</property>
1100
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1101
+ <property name="wrap">False</property>
1102
+ <property name="selectable">False</property>
1103
+ <property name="xalign">0</property>
1104
+ <property name="yalign">0</property>
1105
+ <property name="xpad">0</property>
1106
+ <property name="ypad">0</property>
1107
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1108
+ <property name="width_chars">-1</property>
1109
+ <property name="single_line_mode">False</property>
1110
+ <property name="angle">0</property>
1113
+ <property name="left_attach">0</property>
1114
+ <property name="right_attach">1</property>
1115
+ <property name="top_attach">3</property>
1116
+ <property name="bottom_attach">4</property>
1117
+ <property name="x_options">fill</property>
1118
+ <property name="y_options"></property>
1123
+ <widget class="GtkLabel" id="label10">
1124
+ <property name="visible">True</property>
1125
+ <property name="label" translatable="yes">Data device</property>
1126
+ <property name="use_underline">False</property>
1127
+ <property name="use_markup">False</property>
1128
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1129
+ <property name="wrap">False</property>
1130
+ <property name="selectable">False</property>
1131
+ <property name="xalign">0</property>
1132
+ <property name="yalign">0</property>
1133
+ <property name="xpad">0</property>
1134
+ <property name="ypad">0</property>
1135
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1136
+ <property name="width_chars">-1</property>
1137
+ <property name="single_line_mode">False</property>
1138
+ <property name="angle">0</property>
1141
+ <property name="left_attach">0</property>
1142
+ <property name="right_attach">1</property>
1143
+ <property name="top_attach">4</property>
1144
+ <property name="bottom_attach">5</property>
1145
+ <property name="x_options">fill</property>
1146
+ <property name="y_options"></property>
1151
+ <widget class="GtkLabel" id="label11">
1152
+ <property name="visible">True</property>
1153
+ <property name="label" translatable="yes">IMSI</property>
1154
+ <property name="use_underline">False</property>
1155
+ <property name="use_markup">False</property>
1156
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1157
+ <property name="wrap">False</property>
1158
+ <property name="selectable">False</property>
1159
+ <property name="xalign">0</property>
1160
+ <property name="yalign">0</property>
1161
+ <property name="xpad">0</property>
1162
+ <property name="ypad">0</property>
1163
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1164
+ <property name="width_chars">-1</property>
1165
+ <property name="single_line_mode">False</property>
1166
+ <property name="angle">0</property>
1169
+ <property name="left_attach">0</property>
1170
+ <property name="right_attach">1</property>
1171
+ <property name="top_attach">5</property>
1172
+ <property name="bottom_attach">6</property>
1173
+ <property name="x_options">fill</property>
1174
+ <property name="y_options"></property>
1179
+ <widget class="GtkLabel" id="label12">
1180
+ <property name="visible">True</property>
1181
+ <property name="label" translatable="yes">IMEI</property>
1182
+ <property name="use_underline">False</property>
1183
+ <property name="use_markup">False</property>
1184
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1185
+ <property name="wrap">False</property>
1186
+ <property name="selectable">False</property>
1187
+ <property name="xalign">0</property>
1188
+ <property name="yalign">0</property>
1189
+ <property name="xpad">0</property>
1190
+ <property name="ypad">0</property>
1191
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1192
+ <property name="width_chars">-1</property>
1193
+ <property name="single_line_mode">False</property>
1194
+ <property name="angle">0</property>
1197
+ <property name="left_attach">0</property>
1198
+ <property name="right_attach">1</property>
1199
+ <property name="top_attach">6</property>
1200
+ <property name="bottom_attach">7</property>
1201
+ <property name="x_options">fill</property>
1202
+ <property name="y_options"></property>
1207
+ <widget class="GtkLabel" id="label13">
1208
+ <property name="visible">True</property>
1209
+ <property name="label" translatable="yes">Signal quality</property>
1210
+ <property name="use_underline">False</property>
1211
+ <property name="use_markup">False</property>
1212
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1213
+ <property name="wrap">False</property>
1214
+ <property name="selectable">False</property>
1215
+ <property name="xalign">0</property>
1216
+ <property name="yalign">0</property>
1217
+ <property name="xpad">0</property>
1218
+ <property name="ypad">0</property>
1219
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1220
+ <property name="width_chars">-1</property>
1221
+ <property name="single_line_mode">False</property>
1222
+ <property name="angle">0</property>
1225
+ <property name="left_attach">0</property>
1226
+ <property name="right_attach">1</property>
1227
+ <property name="top_attach">7</property>
1228
+ <property name="bottom_attach">8</property>
1229
+ <property name="x_options">fill</property>
1230
+ <property name="y_options"></property>
1235
+ <widget class="GtkLabel" id="vendor_label">
1236
+ <property name="visible">True</property>
1237
+ <property name="label" translatable="yes"></property>
1238
+ <property name="use_underline">False</property>
1239
+ <property name="use_markup">False</property>
1240
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1241
+ <property name="wrap">False</property>
1242
+ <property name="selectable">False</property>
1243
+ <property name="xalign">0</property>
1244
+ <property name="yalign">0</property>
1245
+ <property name="xpad">0</property>
1246
+ <property name="ypad">0</property>
1247
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1248
+ <property name="width_chars">-1</property>
1249
+ <property name="single_line_mode">False</property>
1250
+ <property name="angle">0</property>
1253
+ <property name="left_attach">1</property>
1254
+ <property name="right_attach">2</property>
1255
+ <property name="top_attach">0</property>
1256
+ <property name="bottom_attach">1</property>
1257
+ <property name="x_options">fill</property>
1258
+ <property name="y_options"></property>
1263
+ <widget class="GtkLabel" id="model_label">
1264
+ <property name="visible">True</property>
1265
+ <property name="label" translatable="yes"></property>
1266
+ <property name="use_underline">False</property>
1267
+ <property name="use_markup">False</property>
1268
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1269
+ <property name="wrap">False</property>
1270
+ <property name="selectable">False</property>
1271
+ <property name="xalign">0</property>
1272
+ <property name="yalign">0</property>
1273
+ <property name="xpad">0</property>
1274
+ <property name="ypad">0</property>
1275
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1276
+ <property name="width_chars">-1</property>
1277
+ <property name="single_line_mode">False</property>
1278
+ <property name="angle">0</property>
1281
+ <property name="left_attach">1</property>
1282
+ <property name="right_attach">2</property>
1283
+ <property name="top_attach">1</property>
1284
+ <property name="bottom_attach">2</property>
1285
+ <property name="x_options">fill</property>
1286
+ <property name="y_options"></property>
1291
+ <widget class="GtkLabel" id="version_label">
1292
+ <property name="visible">True</property>
1293
+ <property name="label" translatable="yes"></property>
1294
+ <property name="use_underline">False</property>
1295
+ <property name="use_markup">False</property>
1296
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1297
+ <property name="wrap">False</property>
1298
+ <property name="selectable">False</property>
1299
+ <property name="xalign">0</property>
1300
+ <property name="yalign">0</property>
1301
+ <property name="xpad">0</property>
1302
+ <property name="ypad">0</property>
1303
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1304
+ <property name="width_chars">-1</property>
1305
+ <property name="single_line_mode">False</property>
1306
+ <property name="angle">0</property>
1309
+ <property name="left_attach">1</property>
1310
+ <property name="right_attach">2</property>
1311
+ <property name="top_attach">2</property>
1312
+ <property name="bottom_attach">3</property>
1313
+ <property name="x_options">fill</property>
1314
+ <property name="y_options"></property>
1319
+ <widget class="GtkLabel" id="driver_label">
1320
+ <property name="visible">True</property>
1321
+ <property name="label" translatable="yes"></property>
1322
+ <property name="use_underline">False</property>
1323
+ <property name="use_markup">False</property>
1324
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1325
+ <property name="wrap">False</property>
1326
+ <property name="selectable">False</property>
1327
+ <property name="xalign">0</property>
1328
+ <property name="yalign">0</property>
1329
+ <property name="xpad">0</property>
1330
+ <property name="ypad">0</property>
1331
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1332
+ <property name="width_chars">-1</property>
1333
+ <property name="single_line_mode">False</property>
1334
+ <property name="angle">0</property>
1337
+ <property name="left_attach">1</property>
1338
+ <property name="right_attach">2</property>
1339
+ <property name="top_attach">3</property>
1340
+ <property name="bottom_attach">4</property>
1341
+ <property name="x_options">fill</property>
1342
+ <property name="y_options"></property>
1347
+ <widget class="GtkLabel" id="device_label">
1348
+ <property name="visible">True</property>
1349
+ <property name="label" translatable="yes"></property>
1350
+ <property name="use_underline">False</property>
1351
+ <property name="use_markup">False</property>
1352
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1353
+ <property name="wrap">False</property>
1354
+ <property name="selectable">False</property>
1355
+ <property name="xalign">0</property>
1356
+ <property name="yalign">0</property>
1357
+ <property name="xpad">0</property>
1358
+ <property name="ypad">0</property>
1359
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1360
+ <property name="width_chars">-1</property>
1361
+ <property name="single_line_mode">False</property>
1362
+ <property name="angle">0</property>
1365
+ <property name="left_attach">1</property>
1366
+ <property name="right_attach">2</property>
1367
+ <property name="top_attach">4</property>
1368
+ <property name="bottom_attach">5</property>
1369
+ <property name="x_options">fill</property>
1370
+ <property name="y_options"></property>
1375
+ <widget class="GtkLabel" id="imsi_label">
1376
+ <property name="visible">True</property>
1377
+ <property name="label" translatable="yes"></property>
1378
+ <property name="use_underline">False</property>
1379
+ <property name="use_markup">False</property>
1380
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1381
+ <property name="wrap">False</property>
1382
+ <property name="selectable">False</property>
1383
+ <property name="xalign">0</property>
1384
+ <property name="yalign">0</property>
1385
+ <property name="xpad">0</property>
1386
+ <property name="ypad">0</property>
1387
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1388
+ <property name="width_chars">-1</property>
1389
+ <property name="single_line_mode">False</property>
1390
+ <property name="angle">0</property>
1393
+ <property name="left_attach">1</property>
1394
+ <property name="right_attach">2</property>
1395
+ <property name="top_attach">5</property>
1396
+ <property name="bottom_attach">6</property>
1397
+ <property name="x_options">fill</property>
1398
+ <property name="y_options"></property>
1403
+ <widget class="GtkLabel" id="imei_label">
1404
+ <property name="visible">True</property>
1405
+ <property name="label" translatable="yes"></property>
1406
+ <property name="use_underline">False</property>
1407
+ <property name="use_markup">False</property>
1408
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1409
+ <property name="wrap">False</property>
1410
+ <property name="selectable">False</property>
1411
+ <property name="xalign">0</property>
1412
+ <property name="yalign">0</property>
1413
+ <property name="xpad">0</property>
1414
+ <property name="ypad">0</property>
1415
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1416
+ <property name="width_chars">-1</property>
1417
+ <property name="single_line_mode">False</property>
1418
+ <property name="angle">0</property>
1421
+ <property name="left_attach">1</property>
1422
+ <property name="right_attach">2</property>
1423
+ <property name="top_attach">6</property>
1424
+ <property name="bottom_attach">7</property>
1425
+ <property name="x_options">fill</property>
1426
+ <property name="y_options"></property>
1431
+ <widget class="GtkLabel" id="signal_quality_label">
1432
+ <property name="visible">True</property>
1433
+ <property name="label" translatable="yes"></property>
1434
+ <property name="use_underline">False</property>
1435
+ <property name="use_markup">False</property>
1436
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1437
+ <property name="wrap">False</property>
1438
+ <property name="selectable">False</property>
1439
+ <property name="xalign">0</property>
1440
+ <property name="yalign">0</property>
1441
+ <property name="xpad">0</property>
1442
+ <property name="ypad">0</property>
1443
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1444
+ <property name="width_chars">-1</property>
1445
+ <property name="single_line_mode">False</property>
1446
+ <property name="angle">0</property>
1449
+ <property name="left_attach">1</property>
1450
+ <property name="right_attach">2</property>
1451
+ <property name="top_attach">7</property>
1452
+ <property name="bottom_attach">8</property>
1453
+ <property name="x_options">fill</property>
1454
+ <property name="y_options"></property>
1463
+ <widget class="GtkLabel" id="label1">
1464
+ <property name="visible">True</property>
1465
+ <property name="label" translatable="yes"><b>Information</b></property>
1466
+ <property name="use_underline">False</property>
1467
+ <property name="use_markup">True</property>
1468
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1469
+ <property name="wrap">False</property>
1470
+ <property name="selectable">False</property>
1471
+ <property name="xalign">0.5</property>
1472
+ <property name="yalign">0.5</property>
1473
+ <property name="xpad">0</property>
1474
+ <property name="ypad">0</property>
1475
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1476
+ <property name="width_chars">-1</property>
1477
+ <property name="single_line_mode">False</property>
1478
+ <property name="angle">0</property>
1481
+ <property name="type">label_item</property>
1486
+ <property name="padding">0</property>
1487
+ <property name="expand">True</property>
1488
+ <property name="fill">True</property>
1493
+ <widget class="GtkFrame" id="frame3">
1494
+ <property name="label_xalign">0</property>
1495
+ <property name="label_yalign">0.5</property>
1496
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
1499
+ <widget class="GtkAlignment" id="alignment3">
1500
+ <property name="visible">True</property>
1501
+ <property name="xalign">0.5</property>
1502
+ <property name="yalign">0.5</property>
1503
+ <property name="xscale">1</property>
1504
+ <property name="yscale">1</property>
1505
+ <property name="top_padding">0</property>
1506
+ <property name="bottom_padding">0</property>
1507
+ <property name="left_padding">12</property>
1508
+ <property name="right_padding">0</property>
1517
+ <widget class="GtkLabel" id="label4">
1518
+ <property name="visible">True</property>
1519
+ <property name="label" translatable="yes"><b>PIN operations</b></property>
1520
+ <property name="use_underline">False</property>
1521
+ <property name="use_markup">True</property>
1522
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1523
+ <property name="wrap">False</property>
1524
+ <property name="selectable">False</property>
1525
+ <property name="xalign">0.5</property>
1526
+ <property name="yalign">0.5</property>
1527
+ <property name="xpad">0</property>
1528
+ <property name="ypad">0</property>
1529
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1530
+ <property name="width_chars">-1</property>
1531
+ <property name="single_line_mode">False</property>
1532
+ <property name="angle">0</property>
1535
+ <property name="type">label_item</property>
1540
+ <property name="padding">0</property>
1541
+ <property name="expand">True</property>
1542
+ <property name="fill">True</property>
1547
+ <property name="padding">0</property>
1548
+ <property name="expand">True</property>
1549
+ <property name="fill">True</property>
1554
+ <widget class="GtkFrame" id="frame2">
1555
+ <property name="visible">True</property>
1556
+ <property name="label_xalign">0</property>
1557
+ <property name="label_yalign">0.5</property>
1558
+ <property name="shadow_type">GTK_SHADOW_NONE</property>
1561
+ <widget class="GtkAlignment" id="alignment2">
1562
+ <property name="visible">True</property>
1563
+ <property name="xalign">0.5</property>
1564
+ <property name="yalign">0.5</property>
1565
+ <property name="xscale">1</property>
1566
+ <property name="yscale">1</property>
1567
+ <property name="top_padding">0</property>
1568
+ <property name="bottom_padding">0</property>
1569
+ <property name="left_padding">12</property>
1570
+ <property name="right_padding">0</property>
1573
+ <widget class="GtkHBox" id="hbox1">
1574
+ <property name="visible">True</property>
1575
+ <property name="homogeneous">False</property>
1576
+ <property name="spacing">6</property>
1579
+ <widget class="GtkScrolledWindow" id="scrolledwindow1">
1580
+ <property name="visible">True</property>
1581
+ <property name="can_focus">True</property>
1582
+ <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
1583
+ <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
1584
+ <property name="shadow_type">GTK_SHADOW_IN</property>
1585
+ <property name="window_placement">GTK_CORNER_TOP_LEFT</property>
1588
+ <widget class="GtkTreeView" id="network_list">
1589
+ <property name="visible">True</property>
1590
+ <property name="can_focus">True</property>
1591
+ <property name="headers_visible">False</property>
1592
+ <property name="rules_hint">False</property>
1593
+ <property name="reorderable">False</property>
1594
+ <property name="enable_search">True</property>
1595
+ <property name="fixed_height_mode">False</property>
1596
+ <property name="hover_selection">False</property>
1597
+ <property name="hover_expand">False</property>
1602
+ <property name="padding">0</property>
1603
+ <property name="expand">True</property>
1604
+ <property name="fill">True</property>
1609
+ <widget class="GtkVButtonBox" id="vbuttonbox1">
1610
+ <property name="visible">True</property>
1611
+ <property name="layout_style">GTK_BUTTONBOX_START</property>
1612
+ <property name="spacing">0</property>
1615
+ <widget class="GtkButton" id="scan_button">
1616
+ <property name="visible">True</property>
1617
+ <property name="can_default">True</property>
1618
+ <property name="can_focus">True</property>
1619
+ <property name="label" translatable="yes">Scan</property>
1620
+ <property name="use_underline">True</property>
1621
+ <property name="relief">GTK_RELIEF_NORMAL</property>
1622
+ <property name="focus_on_click">True</property>
1627
+ <widget class="GtkButton" id="create_connection_button">
1628
+ <property name="visible">True</property>
1629
+ <property name="can_default">True</property>
1630
+ <property name="can_focus">True</property>
1631
+ <property name="label" translatable="yes">Create connection</property>
1632
+ <property name="use_underline">True</property>
1633
+ <property name="relief">GTK_RELIEF_NORMAL</property>
1634
+ <property name="focus_on_click">True</property>
1639
+ <property name="padding">0</property>
1640
+ <property name="expand">False</property>
1641
+ <property name="fill">False</property>
1650
+ <widget class="GtkLabel" id="label2">
1651
+ <property name="visible">True</property>
1652
+ <property name="label" translatable="yes"><b>Networks</b></property>
1653
+ <property name="use_underline">False</property>
1654
+ <property name="use_markup">True</property>
1655
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1656
+ <property name="wrap">False</property>
1657
+ <property name="selectable">False</property>
1658
+ <property name="xalign">0.5</property>
1659
+ <property name="yalign">0.5</property>
1660
+ <property name="xpad">0</property>
1661
+ <property name="ypad">0</property>
1662
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1663
+ <property name="width_chars">-1</property>
1664
+ <property name="single_line_mode">False</property>
1665
+ <property name="angle">0</property>
1668
+ <property name="type">label_item</property>
1673
+ <property name="padding">0</property>
1674
+ <property name="expand">True</property>
1675
+ <property name="fill">True</property>
1680
+ <property name="padding">0</property>
1681
+ <property name="expand">True</property>
1682
+ <property name="fill">True</property>
1689
+<widget class="GtkDialog" id="create_network_dialog">
1690
+ <property name="title" translatable="yes">Create new connection</property>
1691
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
1692
+ <property name="window_position">GTK_WIN_POS_NONE</property>
1693
+ <property name="modal">False</property>
1694
+ <property name="resizable">False</property>
1695
+ <property name="destroy_with_parent">False</property>
1696
+ <property name="decorated">True</property>
1697
+ <property name="skip_taskbar_hint">False</property>
1698
+ <property name="skip_pager_hint">False</property>
1699
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
1700
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
1701
+ <property name="focus_on_map">True</property>
1702
+ <property name="urgency_hint">False</property>
1703
+ <property name="has_separator">True</property>
1705
+ <child internal-child="vbox">
1706
+ <widget class="GtkVBox" id="dialog-vbox2">
1707
+ <property name="visible">True</property>
1708
+ <property name="homogeneous">False</property>
1709
+ <property name="spacing">0</property>
1711
+ <child internal-child="action_area">
1712
+ <widget class="GtkHButtonBox" id="dialog-action_area2">
1713
+ <property name="visible">True</property>
1714
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
1717
+ <widget class="GtkButton" id="cancelbutton1">
1718
+ <property name="visible">True</property>
1719
+ <property name="can_default">True</property>
1720
+ <property name="can_focus">True</property>
1721
+ <property name="label">gtk-cancel</property>
1722
+ <property name="use_stock">True</property>
1723
+ <property name="relief">GTK_RELIEF_NORMAL</property>
1724
+ <property name="focus_on_click">True</property>
1725
+ <property name="response_id">-6</property>
1730
+ <widget class="GtkButton" id="okbutton1">
1731
+ <property name="visible">True</property>
1732
+ <property name="can_default">True</property>
1733
+ <property name="can_focus">True</property>
1734
+ <property name="label">gtk-ok</property>
1735
+ <property name="use_stock">True</property>
1736
+ <property name="relief">GTK_RELIEF_NORMAL</property>
1737
+ <property name="focus_on_click">True</property>
1738
+ <property name="response_id">-5</property>
1743
+ <property name="padding">0</property>
1744
+ <property name="expand">False</property>
1745
+ <property name="fill">True</property>
1746
+ <property name="pack_type">GTK_PACK_END</property>
1751
+ <widget class="GtkVBox" id="vbox2">
1752
+ <property name="border_width">6</property>
1753
+ <property name="visible">True</property>
1754
+ <property name="homogeneous">False</property>
1755
+ <property name="spacing">6</property>
1758
+ <widget class="GtkLabel" id="label3">
1759
+ <property name="visible">True</property>
1760
+ <property name="label" translatable="yes">Please choose a name for the connection</property>
1761
+ <property name="use_underline">False</property>
1762
+ <property name="use_markup">False</property>
1763
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1764
+ <property name="wrap">False</property>
1765
+ <property name="selectable">False</property>
1766
+ <property name="xalign">0.5</property>
1767
+ <property name="yalign">0.5</property>
1768
+ <property name="xpad">0</property>
1769
+ <property name="ypad">0</property>
1770
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1771
+ <property name="width_chars">-1</property>
1772
+ <property name="single_line_mode">False</property>
1773
+ <property name="angle">0</property>
1776
+ <property name="padding">0</property>
1777
+ <property name="expand">False</property>
1778
+ <property name="fill">False</property>
1783
+ <widget class="GtkEntry" id="create_network_name">
1784
+ <property name="visible">True</property>
1785
+ <property name="can_focus">True</property>
1786
+ <property name="editable">True</property>
1787
+ <property name="visibility">True</property>
1788
+ <property name="max_length">0</property>
1789
+ <property name="text" translatable="yes"></property>
1790
+ <property name="has_frame">True</property>
1791
+ <property name="invisible_char">●</property>
1792
+ <property name="activates_default">True</property>
1795
+ <property name="padding">0</property>
1796
+ <property name="expand">False</property>
1797
+ <property name="fill">False</property>
1802
+ <property name="padding">0</property>
1803
+ <property name="expand">True</property>
1804
+ <property name="fill">True</property>
1811
+<widget class="GtkWindow" id="scan_dialog">
1812
+ <property name="title" translatable="yes"></property>
1813
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
1814
+ <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
1815
+ <property name="modal">True</property>
1816
+ <property name="resizable">False</property>
1817
+ <property name="destroy_with_parent">False</property>
1818
+ <property name="decorated">False</property>
1819
+ <property name="skip_taskbar_hint">True</property>
1820
+ <property name="skip_pager_hint">True</property>
1821
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
1822
+ <property name="gravity">GDK_GRAVITY_CENTER</property>
1823
+ <property name="focus_on_map">True</property>
1824
+ <property name="urgency_hint">False</property>
1827
+ <widget class="GtkVBox" id="vbox3">
1828
+ <property name="border_width">6</property>
1829
+ <property name="visible">True</property>
1830
+ <property name="homogeneous">False</property>
1831
+ <property name="spacing">6</property>
1834
+ <widget class="GtkLabel" id="label5">
1835
+ <property name="visible">True</property>
1836
+ <property name="label" translatable="yes">Scanning... Please wait.</property>
1837
+ <property name="use_underline">False</property>
1838
+ <property name="use_markup">False</property>
1839
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1840
+ <property name="wrap">False</property>
1841
+ <property name="selectable">False</property>
1842
+ <property name="xalign">0.5</property>
1843
+ <property name="yalign">0.5</property>
1844
+ <property name="xpad">0</property>
1845
+ <property name="ypad">0</property>
1846
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1847
+ <property name="width_chars">-1</property>
1848
+ <property name="single_line_mode">False</property>
1849
+ <property name="angle">0</property>
1852
+ <property name="padding">0</property>
1853
+ <property name="expand">False</property>
1854
+ <property name="fill">False</property>
1859
+ <widget class="GtkProgressBar" id="scan_progress_bar">
1860
+ <property name="visible">True</property>
1861
+ <property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
1862
+ <property name="fraction">0</property>
1863
+ <property name="pulse_step">0.10000000149</property>
1864
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1867
+ <property name="padding">0</property>
1868
+ <property name="expand">False</property>
1869
+ <property name="fill">False</property>
1876
+<widget class="GtkDialog" id="pin_dialog">
1877
+ <property name="visible">False</property>
1878
+ <property name="title" translatable="yes">PIN code required</property>
1879
+ <property name="type">GTK_WINDOW_TOPLEVEL</property>
1880
+ <property name="window_position">GTK_WIN_POS_NONE</property>
1881
+ <property name="modal">False</property>
1882
+ <property name="resizable">False</property>
1883
+ <property name="destroy_with_parent">False</property>
1884
+ <property name="decorated">True</property>
1885
+ <property name="skip_taskbar_hint">False</property>
1886
+ <property name="skip_pager_hint">False</property>
1887
+ <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
1888
+ <property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
1889
+ <property name="focus_on_map">True</property>
1890
+ <property name="urgency_hint">False</property>
1891
+ <property name="has_separator">True</property>
1893
+ <child internal-child="vbox">
1894
+ <widget class="GtkVBox" id="dialog-vbox3">
1895
+ <property name="homogeneous">False</property>
1896
+ <property name="spacing">0</property>
1898
+ <child internal-child="action_area">
1899
+ <widget class="GtkHButtonBox" id="dialog-action_area3">
1900
+ <property name="visible">True</property>
1901
+ <property name="layout_style">GTK_BUTTONBOX_END</property>
1904
+ <widget class="GtkButton" id="cancelbutton2">
1905
+ <property name="visible">True</property>
1906
+ <property name="can_default">True</property>
1907
+ <property name="can_focus">True</property>
1908
+ <property name="label">gtk-cancel</property>
1909
+ <property name="use_stock">True</property>
1910
+ <property name="relief">GTK_RELIEF_NORMAL</property>
1911
+ <property name="focus_on_click">True</property>
1912
+ <property name="response_id">-6</property>
1917
+ <widget class="GtkButton" id="okbutton2">
1918
+ <property name="visible">True</property>
1919
+ <property name="can_default">True</property>
1920
+ <property name="can_focus">True</property>
1921
+ <property name="label">gtk-ok</property>
1922
+ <property name="use_stock">True</property>
1923
+ <property name="relief">GTK_RELIEF_NORMAL</property>
1924
+ <property name="focus_on_click">True</property>
1925
+ <property name="response_id">-5</property>
1930
+ <property name="padding">0</property>
1931
+ <property name="expand">False</property>
1932
+ <property name="fill">True</property>
1933
+ <property name="pack_type">GTK_PACK_END</property>
1938
+ <widget class="GtkVBox" id="vbox4">
1939
+ <property name="border_width">6</property>
1940
+ <property name="visible">True</property>
1941
+ <property name="homogeneous">False</property>
1942
+ <property name="spacing">6</property>
1945
+ <widget class="GtkLabel" id="pin_dialog_label">
1946
+ <property name="visible">True</property>
1947
+ <property name="label" translatable="yes">Please enter SIM PIN code</property>
1948
+ <property name="use_underline">False</property>
1949
+ <property name="use_markup">False</property>
1950
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
1951
+ <property name="wrap">False</property>
1952
+ <property name="selectable">False</property>
1953
+ <property name="xalign">0.5</property>
1954
+ <property name="yalign">0.5</property>
1955
+ <property name="xpad">0</property>
1956
+ <property name="ypad">0</property>
1957
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
1958
+ <property name="width_chars">-1</property>
1959
+ <property name="single_line_mode">False</property>
1960
+ <property name="angle">0</property>
1963
+ <property name="padding">0</property>
1964
+ <property name="expand">False</property>
1965
+ <property name="fill">False</property>
1970
+ <widget class="GtkEntry" id="pin_dialog_entry">
1971
+ <property name="visible">True</property>
1972
+ <property name="can_focus">True</property>
1973
+ <property name="editable">True</property>
1974
+ <property name="visibility">True</property>
1975
+ <property name="max_length">0</property>
1976
+ <property name="text" translatable="yes"></property>
1977
+ <property name="has_frame">True</property>
1978
+ <property name="invisible_char">●</property>
1979
+ <property name="activates_default">False</property>
1982
+ <property name="padding">0</property>
1983
+ <property name="expand">False</property>
1984
+ <property name="fill">False</property>
1989
+ <property name="padding">0</property>
1990
+ <property name="expand">True</property>
1991
+ <property name="fill">True</property>
1999
diff --git a/src/nma-gsm-modem.c b/src/nma-gsm-modem.c
2000
new file mode 100644
2001
index 0000000..0dba9cd
2003
+++ b/src/nma-gsm-modem.c
2005
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
2007
+#include "nma-gsm-modem.h"
2008
+#include "mm-types.h"
2010
+G_DEFINE_TYPE (NMAGsmModem, nma_gsm_modem, G_TYPE_OBJECT)
2012
+#define NMA_GSM_MODEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMA_TYPE_GSM_MODEM, NMAGsmModemPrivate))
2015
+ DBusGProxy *proxy;
2016
+ int signal_quality;
2018
+ gboolean disposed;
2019
+} NMAGsmModemPrivate;
2028
+static guint signals[LAST_SIGNAL] = { 0 };
2031
+signal_quality_proxy (DBusGProxy *proxy,
2032
+ guint32 signal_quality,
2033
+ gpointer user_data)
2035
+ NMAGsmModem *modem = NMA_GSM_MODEM (user_data);
2037
+ NMA_GSM_MODEM_GET_PRIVATE (modem)->signal_quality = signal_quality;
2039
+ g_signal_emit (modem, signals[SIGNAL_QUALITY], 0, signal_quality);
2043
+network_mode_proxy (DBusGProxy *proxy,
2044
+ guint32 network_mode,
2045
+ gpointer user_data)
2047
+ NMAGsmModem *modem = NMA_GSM_MODEM (user_data);
2049
+ g_signal_emit (modem, signals[NETWORK_MODE], 0, network_mode);
2053
+nma_gsm_modem_new (DBusGConnection *bus, const char *object_path)
2055
+ NMAGsmModem *modem;
2056
+ NMAGsmModemPrivate *priv;
2058
+ g_return_val_if_fail (bus != NULL, NULL);
2059
+ g_return_val_if_fail (object_path != NULL, NULL);
2061
+ modem = (NMAGsmModem *) g_object_new (NMA_TYPE_GSM_MODEM, NULL);
2065
+ priv = NMA_GSM_MODEM_GET_PRIVATE (modem);
2066
+ priv->proxy = dbus_g_proxy_new_for_name (bus, MM_DBUS_SERVICE, object_path, MM_DBUS_INTERFACE_MODEM_GSM);
2068
+ dbus_g_proxy_add_signal (priv->proxy, "SignalQuality", G_TYPE_UINT, G_TYPE_INVALID);
2069
+ dbus_g_proxy_connect_signal (priv->proxy, "SignalQuality",
2070
+ G_CALLBACK (signal_quality_proxy),
2074
+ dbus_g_proxy_add_signal (priv->proxy, "NetworkMode", G_TYPE_UINT, G_TYPE_INVALID);
2075
+ dbus_g_proxy_connect_signal (priv->proxy, "NetworkMode",
2076
+ G_CALLBACK (network_mode_proxy),
2084
+nma_gsm_modem_get_signal_quality (NMAGsmModem *modem)
2086
+ NMAGsmModemPrivate *priv = NMA_GSM_MODEM_GET_PRIVATE (modem);
2087
+ GError *err = NULL;
2089
+ g_return_val_if_fail (NMA_IS_GSM_MODEM (modem), 0);
2091
+ if (priv->signal_quality == -1) {
2092
+ if (!dbus_g_proxy_call (priv->proxy, "GetSignalQuality", &err,
2094
+ G_TYPE_UINT, &priv->signal_quality,
2095
+ G_TYPE_INVALID)) {
2096
+ g_warning ("Error in getting signal quality: %s", err->message);
2097
+ g_error_free (err);
2101
+ return priv->signal_quality;
2105
+nma_gsm_modem_get_registration_info (NMAGsmModem *modem,
2106
+ char **operator_code,
2107
+ char **operator_name)
2109
+ NMAGsmModemPrivate *priv = NMA_GSM_MODEM_GET_PRIVATE (modem);
2110
+ GError *err = NULL;
2111
+ guint32 status = MM_GSM_MODEM_REG_STATUS_UNKNOWN;
2113
+ g_return_val_if_fail (NMA_IS_GSM_MODEM (modem), 0);
2115
+ if (!dbus_g_proxy_call (priv->proxy, "GetRegistrationInfo", &err,
2117
+ G_TYPE_UINT, &status,
2118
+ G_TYPE_STRING, operator_code,
2119
+ G_TYPE_STRING, operator_name,
2120
+ G_TYPE_INVALID)) {
2121
+ g_warning ("Error in getting network mode: %s", err->message);
2122
+ g_error_free (err);
2129
+nma_gsm_modem_get_network_mode (NMAGsmModem *modem)
2131
+ NMAGsmModemPrivate *priv = NMA_GSM_MODEM_GET_PRIVATE (modem);
2132
+ GError *err = NULL;
2133
+ guint32 network_mode = 0;
2135
+ g_return_val_if_fail (NMA_IS_GSM_MODEM (modem), 0);
2137
+ if (!dbus_g_proxy_call (priv->proxy, "GetNetworkMode", &err,
2139
+ G_TYPE_UINT, &network_mode,
2140
+ G_TYPE_INVALID)) {
2141
+ g_warning ("Error in getting network mode: %s", err->message);
2142
+ g_error_free (err);
2145
+ return network_mode;
2149
+nma_gsm_modem_init (NMAGsmModem *modem)
2151
+ NMAGsmModemPrivate *priv = NMA_GSM_MODEM_GET_PRIVATE (modem);
2153
+ priv->signal_quality = -1;
2157
+dispose (GObject *object)
2159
+ NMAGsmModemPrivate *priv = NMA_GSM_MODEM_GET_PRIVATE (object);
2161
+ if (priv->disposed)
2164
+ priv->disposed = TRUE;
2167
+ g_object_unref (priv->proxy);
2169
+ G_OBJECT_CLASS (nma_gsm_modem_parent_class)->dispose (object);
2173
+nma_gsm_modem_class_init (NMAGsmModemClass *modem_class)
2175
+ GObjectClass *object_class = G_OBJECT_CLASS (modem_class);
2177
+ g_type_class_add_private (modem_class, sizeof (NMAGsmModemPrivate));
2179
+ /* virtual methods */
2180
+ object_class->dispose = dispose;
2183
+ signals[SIGNAL_QUALITY] =
2184
+ g_signal_new ("signal-quality",
2185
+ G_OBJECT_CLASS_TYPE (object_class),
2186
+ G_SIGNAL_RUN_FIRST,
2187
+ G_STRUCT_OFFSET (NMAGsmModemClass, signal_quality),
2189
+ g_cclosure_marshal_VOID__UINT,
2193
+ signals[NETWORK_MODE] =
2194
+ g_signal_new ("network-mode",
2195
+ G_OBJECT_CLASS_TYPE (object_class),
2196
+ G_SIGNAL_RUN_FIRST,
2197
+ G_STRUCT_OFFSET (NMAGsmModemClass, network_mode),
2199
+ g_cclosure_marshal_VOID__UINT,
2203
diff --git a/src/nma-gsm-modem.h b/src/nma-gsm-modem.h
2204
new file mode 100644
2205
index 0000000..90e7ae0
2207
+++ b/src/nma-gsm-modem.h
2209
+/* -*- Mode: C; tab-width: 5; indent-tabs-mode: t; c-basic-offset: 5 -*- */
2211
+#ifndef NMA_GSM_MODEM_H
2212
+#define NMA_GSM_MODEM_H
2214
+#include <glib/gtypes.h>
2215
+#include <glib-object.h>
2216
+#include <dbus/dbus-glib.h>
2220
+#define NMA_TYPE_GSM_MODEM (nma_gsm_modem_get_type ())
2221
+#define NMA_GSM_MODEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMA_TYPE_GSM_MODEM, NMAGsmModem))
2222
+#define NMA_GSM_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMA_TYPE_GSM_MODEM, NMAGsmModemClass))
2223
+#define NMA_IS_GSM_MODEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NMA_TYPE_GSM_MODEM))
2224
+#define NMA_IS_GSM_MODEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NMA_TYPE_GSM_MODEM))
2225
+#define NMA_GSM_MODEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NMA_TYPE_GSM_MODEM, NMAGsmModemClass))
2232
+ GObjectClass parent;
2235
+ void (*signal_quality) (NMAGsmModem *modem, guint32 signal_quality);
2236
+ void (*network_mode) (NMAGsmModem *modem, guint32 network_mode);
2237
+} NMAGsmModemClass;
2239
+GType nma_gsm_modem_get_type (void);
2241
+NMAGsmModem *nma_gsm_modem_new (DBusGConnection *bus,
2242
+ const char *object_path);
2244
+guint32 nma_gsm_modem_get_signal_quality (NMAGsmModem *modem);
2245
+guint32 nma_gsm_modem_get_registration_info (NMAGsmModem *modem,
2246
+ char **operator_code,
2247
+ char **operator_name);
2249
+guint32 nma_gsm_modem_get_network_mode (NMAGsmModem *modem);
2253
+#endif /* NMA_GSM_MODEM_H */