1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
|
Upstream-Status: Pending
commit 15852e826b0b47f577718ada4b68b63515387f4d
Author: dongxiao <dongxiao@dongxiao-osel.(none)>
Date: Wed Jun 1 14:56:16 2011 +0800
connman-gnome: Add cellular network config option.
Add cellular network config option in connman-gnome.
Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
diff --git a/common/connman-client.c b/common/connman-client.c
index e907cc2..d6be363 100644
--- a/common/connman-client.c
+++ b/common/connman-client.c
@@ -112,9 +112,10 @@ static void connman_client_init(ConnmanClient *client)
G_TYPE_STRING, /* address */
G_TYPE_STRING, /* netmask */
G_TYPE_STRING, /* gateway */
- G_TYPE_BOOLEAN, /* gateway */
- G_TYPE_BOOLEAN, /* gateway */
- G_TYPE_BOOLEAN);/* gateway */
+ G_TYPE_BOOLEAN, /* ethernet enabled */
+ G_TYPE_BOOLEAN, /* wifi enabled */
+ G_TYPE_BOOLEAN, /* cellular enabled */
+ G_TYPE_BOOLEAN);/* offline */
g_object_set_data(G_OBJECT(priv->store),
"State", g_strdup("unavailable"));
@@ -218,6 +219,7 @@ static gboolean device_filter(GtkTreeModel *model,
switch (type) {
case CONNMAN_TYPE_LABEL_ETHERNET:
case CONNMAN_TYPE_LABEL_WIFI:
+ case CONNMAN_TYPE_LABEL_CELLULAR:
case CONNMAN_TYPE_SYSCONFIG:
return TRUE;
}
diff --git a/common/connman-client.h b/common/connman-client.h
index 37e86d0..15fa098 100644
--- a/common/connman-client.h
+++ b/common/connman-client.h
@@ -117,6 +117,7 @@ enum {
CONNMAN_COLUMN_ETHERNET_ENABLED,/* G_TYPE_STRING */
CONNMAN_COLUMN_WIFI_ENABLED, /* G_TYPE_STRING */
+ CONNMAN_COLUMN_CELLULAR_ENABLED,/* G_TYPE_STRING */
CONNMAN_COLUMN_OFFLINEMODE, /* G_TYPE_STRING */
_CONNMAN_NUM_COLUMNS
@@ -132,6 +133,7 @@ enum {
CONNMAN_TYPE_LABEL_ETHERNET,
CONNMAN_TYPE_LABEL_WIFI,
+ CONNMAN_TYPE_LABEL_CELLULAR,
CONNMAN_TYPE_SYSCONFIG,
_CONNMAN_NUM_TYPE,
diff --git a/common/connman-dbus.c b/common/connman-dbus.c
index b5a635c..0f4e1db 100644
--- a/common/connman-dbus.c
+++ b/common/connman-dbus.c
@@ -208,6 +208,8 @@ static const gchar *type2icon(guint type)
case CONNMAN_TYPE_WIFI:
case CONNMAN_TYPE_WIMAX:
return "network-wireless";
+ case CONNMAN_TYPE_CELLULAR:
+ return "network-cellular";
case CONNMAN_TYPE_BLUETOOTH:
return "bluetooth";
}
@@ -220,6 +222,7 @@ static void enabled_technologies_changed(GtkTreeStore *store, GValue *value)
GtkTreeIter iter;
gboolean ethernet_enabled_prev, ethernet_enabled = FALSE;
gboolean wifi_enabled_prev, wifi_enabled = FALSE;
+ gboolean cellular_enabled_prev, cellular_enabled = FALSE;
gchar **tech = g_value_get_boxed (value);
guint i;
@@ -227,10 +230,13 @@ static void enabled_technologies_changed(GtkTreeStore *store, GValue *value)
return;
for (i = 0; i < g_strv_length(tech); i++) {
+ DBG("technology: %s", *(tech+i));
if (g_str_equal("ethernet", *(tech + i)))
ethernet_enabled = TRUE;
else if (g_str_equal ("wifi", *(tech + i)))
wifi_enabled = TRUE;
+ else if (g_str_equal ("cellular", *(tech + i)))
+ cellular_enabled = TRUE;
}
get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET);
@@ -246,6 +252,13 @@ static void enabled_technologies_changed(GtkTreeStore *store, GValue *value)
if (wifi_enabled_prev != wifi_enabled)
gtk_tree_store_set(store, &iter,
CONNMAN_COLUMN_WIFI_ENABLED, wifi_enabled, -1);
+
+ get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_CELLULAR);
+ gtk_tree_model_get(GTK_TREE_MODEL(store), &iter,
+ CONNMAN_COLUMN_CELLULAR_ENABLED, &cellular_enabled_prev, -1);
+ if (cellular_enabled_prev != cellular_enabled)
+ gtk_tree_store_set(store, &iter,
+ CONNMAN_COLUMN_CELLULAR_ENABLED, cellular_enabled, -1);
}
static void enabled_technologies_properties(GtkTreeStore *store, DBusGProxy *proxy, GValue *value)
@@ -253,14 +266,18 @@ static void enabled_technologies_properties(GtkTreeStore *store, DBusGProxy *pro
GtkTreeIter iter;
gboolean ethernet_enabled = FALSE;
gboolean wifi_enabled = FALSE;
+ gboolean cellular_enabled = FALSE;
gchar **tech = g_value_get_boxed (value);
guint i;
for (i = 0; i < g_strv_length (tech); i++) {
+ DBG("technology: %s", *(tech+i));
if (g_str_equal("ethernet", *(tech + i)))
ethernet_enabled = TRUE;
else if (g_str_equal ("wifi", *(tech + i)))
wifi_enabled = TRUE;
+ else if (g_str_equal ("cellular", *(tech + i)))
+ cellular_enabled = TRUE;
}
if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_ETHERNET) == FALSE)
@@ -280,6 +297,15 @@ static void enabled_technologies_properties(GtkTreeStore *store, DBusGProxy *pro
CONNMAN_COLUMN_WIFI_ENABLED, wifi_enabled,
CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_WIFI,
-1);
+
+ if (get_iter_from_type(store, &iter, CONNMAN_TYPE_LABEL_CELLULAR) == FALSE)
+ gtk_tree_store_append(store, &iter, NULL);
+
+ gtk_tree_store_set(store, &iter,
+ CONNMAN_COLUMN_PROXY, proxy,
+ CONNMAN_COLUMN_CELLULAR_ENABLED, cellular_enabled,
+ CONNMAN_COLUMN_TYPE, CONNMAN_TYPE_LABEL_CELLULAR,
+ -1);
}
static void offline_mode_changed(GtkTreeStore *store, GValue *value)
@@ -497,6 +523,9 @@ static void service_properties(DBusGProxy *proxy, GHashTable *hash,
case CONNMAN_TYPE_WIFI:
label_type = CONNMAN_TYPE_LABEL_WIFI;
break;
+ case CONNMAN_TYPE_CELLULAR:
+ label_type = CONNMAN_TYPE_LABEL_CELLULAR;
+ break;
default:
label_type = CONNMAN_TYPE_UNKNOWN;
break;
diff --git a/icons/connman-type-cellular.png b/icons/connman-type-cellular.png
new file mode 100644
index 0000000..386abd5
Binary files /dev/null and b/icons/connman-type-cellular.png differ
diff --git a/properties/Makefile.am b/properties/Makefile.am
index fc1b8c6..30ae442 100644
--- a/properties/Makefile.am
+++ b/properties/Makefile.am
@@ -1,7 +1,7 @@
bin_PROGRAMS = connman-properties
-connman_properties_SOURCES = main.c advanced.h ethernet.c wifi.c
+connman_properties_SOURCES = main.c advanced.h ethernet.c wifi.c cellular.c
connman_properties_LDADD = $(top_builddir)/common/libcommon.a \
@GTK_LIBS@ @DBUS_LIBS@
diff --git a/properties/advanced.h b/properties/advanced.h
index 79a1c3c..d8f4117 100644
--- a/properties/advanced.h
+++ b/properties/advanced.h
@@ -59,10 +59,18 @@ struct config_data {
GtkWidget *disconnect;
} wifi;
+ struct {
+ GtkWidget *name;
+ GtkWidget *strength;
+ GtkWidget *connect_info;
+ GtkWidget *connect;
+ GtkWidget *disconnect;
+ } cellular;
+
GtkWidget *ethernet_button;
GtkWidget *wifi_button;
-
GtkWidget *scan_button;
+ GtkWidget *cellular_button;
GtkWidget *offline_button;
};
@@ -88,8 +96,11 @@ void update_ethernet_ipv4(struct config_data *data, guint policy);
void add_wifi_service(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data);
void update_wifi_policy(struct config_data *data, guint policy);
+void add_cellular_service(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data);
void add_ethernet_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
struct config_data *data);
void add_wifi_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
struct config_data *data);
+void add_cellular_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
+ struct config_data *data);
diff --git a/properties/cellular.c b/properties/cellular.c
new file mode 100644
index 0000000..7bbfb89
--- /dev/null
+++ b/properties/cellular.c
@@ -0,0 +1,175 @@
+/*
+ *
+ * Connection Manager
+ *
+ * Copyright (C) 2011 Intel Corporation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * 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 St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <dbus/dbus-glib.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include "connman-client.h"
+
+#include "advanced.h"
+
+static void connect_reply_cb(DBusGProxy *proxy, GError *error,
+ gpointer user_data)
+{
+ if (error)
+ g_error_free(error);
+}
+
+static void connect_callback(GtkWidget *editable, gpointer user_data)
+{
+ struct config_data *data = user_data;
+
+ connman_client_connect_async(data->client, data->device, connect_reply_cb, data);
+}
+
+
+static void disconnect_callback(GtkWidget *editable, gpointer user_data)
+{
+ struct config_data *data = user_data;
+
+ connman_client_disconnect(data->client, data->device);
+}
+
+static void switch_callback(GtkWidget *editable, gpointer user_data)
+{
+ struct config_data *data = user_data;
+ const gchar *label = gtk_button_get_label(GTK_BUTTON(data->cellular_button));
+
+ if (g_str_equal(label, "Disable"))
+ connman_client_disable_technology(data->client, data->device, "cellular");
+ else
+ connman_client_enable_technology(data->client, data->device, "cellular");
+}
+
+void add_cellular_switch_button(GtkWidget *mainbox, GtkTreeIter *iter,
+ struct config_data *data)
+{
+ GtkWidget *vbox;
+ GtkWidget *table;
+ GtkWidget *label;
+ GtkWidget *buttonbox;
+ GtkWidget *button;
+ gboolean cellular_enabled;
+
+ gtk_tree_model_get(data->model, iter,
+ CONNMAN_COLUMN_CELLULAR_ENABLED, &cellular_enabled,
+ -1);
+
+ vbox = gtk_vbox_new(TRUE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 24);
+ gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0);
+
+ table = gtk_table_new(1, 1, TRUE);
+ gtk_table_set_row_spacings(GTK_TABLE(table), 10);
+ gtk_table_set_col_spacings(GTK_TABLE(table), 10);
+ gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
+
+ label = gtk_label_new(_("Configure Cellular Networks."));
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1);
+
+ buttonbox = gtk_hbutton_box_new();
+ gtk_button_box_set_layout(GTK_BUTTON_BOX(buttonbox), GTK_BUTTONBOX_CENTER);
+ gtk_box_pack_start(GTK_BOX(mainbox), buttonbox, FALSE, FALSE, 0);
+
+ button = gtk_button_new();
+ data->cellular_button = button;
+
+ if (cellular_enabled)
+ gtk_button_set_label(GTK_BUTTON(button), _("Disable"));
+ else
+ gtk_button_set_label(GTK_BUTTON(button), _("Enable"));
+
+ gtk_container_add(GTK_CONTAINER(buttonbox), button);
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(switch_callback), data);
+}
+
+void add_cellular_service(GtkWidget *mainbox, GtkTreeIter *iter, struct config_data *data)
+{
+ GtkWidget *vbox;
+ GtkWidget *table;
+ GtkWidget *label;
+ GtkWidget *button;
+
+ const char *name, *icon, *state;
+ guint strength;
+
+ gtk_tree_model_get(data->model, iter,
+ CONNMAN_COLUMN_NAME, &name,
+ CONNMAN_COLUMN_ICON, &icon,
+ CONNMAN_COLUMN_STATE, &state,
+ CONNMAN_COLUMN_STRENGTH, &strength,
+ -1);
+
+ if (g_str_equal(state, "failure") == TRUE)
+ connman_client_remove(data->client, data->device);
+
+ vbox = gtk_vbox_new(TRUE, 0);
+ gtk_container_set_border_width(GTK_CONTAINER(vbox), 24);
+ gtk_box_pack_start(GTK_BOX(mainbox), vbox, FALSE, FALSE, 0);
+
+ table = gtk_table_new(4, 8, TRUE);
+ gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0);
+ data->table = table;
+
+ label = gtk_label_new(_("Access Point:"));
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 3, 4, 0, 1);
+
+ label = gtk_label_new(_(name));
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 4, 5, 0, 1);
+ gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
+ data->cellular.name = label;
+
+ label = gtk_label_new(_(""));
+ gtk_table_attach_defaults(GTK_TABLE(table), label, 3, 5, 2, 3);
+ gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.0);
+ gtk_widget_hide(label);
+ data->cellular.connect_info = label;
+
+ button = gtk_button_new_with_label(_("Connect"));
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 5, 3, 4);
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(connect_callback), data);
+ gtk_widget_set_no_show_all(button, TRUE);
+ data->cellular.connect = button;
+
+ button = gtk_button_new_with_label(_("Disconnect"));
+ gtk_table_attach_defaults(GTK_TABLE(table), button, 3, 5, 3, 4);
+ g_signal_connect(G_OBJECT(button), "clicked",
+ G_CALLBACK(disconnect_callback), data);
+ data->cellular.disconnect = button;
+ gtk_widget_set_no_show_all(button, TRUE);
+
+ if (g_str_equal(state, "failure") == TRUE
+ || g_str_equal(state, "idle") == TRUE) {
+ gtk_widget_show(data->cellular.connect);
+ gtk_widget_hide(data->cellular.disconnect);
+ } else {
+ gtk_widget_hide(data->cellular.connect);
+ gtk_widget_show(data->cellular.disconnect);
+ }
+}
diff --git a/properties/main.c b/properties/main.c
index a09c721..ec36aef 100644
--- a/properties/main.c
+++ b/properties/main.c
@@ -42,6 +42,7 @@ static void status_update(GtkTreeModel *model, GtkTreePath *path,
const char *name = NULL, *_name = NULL, *state = NULL;
gboolean ethernet_enabled;
gboolean wifi_enabled;
+ gboolean cellular_enabled;
gboolean offline_mode;
gtk_tree_model_get(model, iter,
@@ -50,6 +51,7 @@ static void status_update(GtkTreeModel *model, GtkTreePath *path,
CONNMAN_COLUMN_TYPE, &type,
CONNMAN_COLUMN_ETHERNET_ENABLED, ðernet_enabled,
CONNMAN_COLUMN_WIFI_ENABLED, &wifi_enabled,
+ CONNMAN_COLUMN_CELLULAR_ENABLED, &cellular_enabled,
CONNMAN_COLUMN_OFFLINEMODE, &offline_mode,
-1);
@@ -75,6 +77,29 @@ static void status_update(GtkTreeModel *model, GtkTreePath *path,
gtk_widget_hide(data->wifi.connect);
gtk_widget_show(data->wifi.disconnect);
}
+ } else if (type == CONNMAN_TYPE_CELLULAR) {
+ if (data->cellular.name)
+ _name = gtk_label_get_text(GTK_LABEL(data->cellular.name));
+
+ if (!(name && _name && g_str_equal(name, _name)))
+ return;
+
+ if (g_str_equal(state, "failure") == TRUE) {
+ gtk_label_set_text(GTK_LABEL(data->cellular.connect_info),
+ _("connection failed"));
+ gtk_widget_show(data->cellular.connect_info);
+ gtk_widget_show(data->cellular.connect);
+ gtk_widget_hide(data->cellular.disconnect);
+ } else if (g_str_equal(state, "idle") == TRUE) {
+ gtk_widget_hide(data->cellular.connect_info);
+ gtk_widget_show(data->cellular.connect);
+ gtk_widget_hide(data->cellular.disconnect);
+ } else {
+ gtk_widget_hide(data->cellular.connect_info);
+ gtk_widget_hide(data->cellular.connect);
+ gtk_widget_show(data->cellular.disconnect);
+ }
+
} else if (type == CONNMAN_TYPE_LABEL_ETHERNET) {
if (!data->ethernet_button)
return;
@@ -92,6 +117,13 @@ static void status_update(GtkTreeModel *model, GtkTreePath *path,
gtk_button_set_label(GTK_BUTTON(data->wifi_button), _("Enable"));
gtk_widget_set_sensitive(data->scan_button, 0);
}
+ } else if (type == CONNMAN_TYPE_LABEL_CELLULAR) {
+ if (!data->cellular_button)
+ return;
+ if (cellular_enabled)
+ gtk_button_set_label(GTK_BUTTON(data->cellular_button), _("Disable"));
+ else
+ gtk_button_set_label(GTK_BUTTON(data->cellular_button), _("Enable"));
} else if (type == CONNMAN_TYPE_SYSCONFIG) {
if (!data->offline_button)
return;
@@ -100,7 +132,6 @@ static void status_update(GtkTreeModel *model, GtkTreePath *path,
else
gtk_button_set_label(GTK_BUTTON(data->offline_button), _("OfflineMode"));
}
-
}
static void set_offline_callback(GtkWidget *button, gpointer user_data)
@@ -207,12 +238,18 @@ static struct config_data *create_config(GtkTreeModel *model,
case CONNMAN_TYPE_WIFI:
add_wifi_service(mainbox, iter, data);
break;
+ case CONNMAN_TYPE_CELLULAR:
+ add_cellular_service(mainbox, iter, data);
+ break;
case CONNMAN_TYPE_LABEL_ETHERNET:
add_ethernet_switch_button(mainbox, iter, data);
break;
case CONNMAN_TYPE_LABEL_WIFI:
add_wifi_switch_button(mainbox, iter, data);
break;
+ case CONNMAN_TYPE_LABEL_CELLULAR:
+ add_cellular_switch_button(mainbox, iter, data);
+ break;
case CONNMAN_TYPE_SYSCONFIG:
add_system_config(mainbox, iter, data);
break;
@@ -295,6 +332,7 @@ static void device_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell,
markup = g_strdup_printf(" %s\n", title);
break;
case CONNMAN_TYPE_WIFI:
+ case CONNMAN_TYPE_CELLULAR:
/* Show the AP name */
title = N_(name);
if (g_str_equal(state, "association") == TRUE)
@@ -324,6 +362,10 @@ static void device_to_text(GtkTreeViewColumn *column, GtkCellRenderer *cell,
title = N_("Wireless Networks");
markup = g_strdup_printf("<b>\n%s\n</b>", title);
break;
+ case CONNMAN_TYPE_LABEL_CELLULAR:
+ title = N_("Cellular Networks");
+ markup = g_strdup_printf("<b>\n%s\n</b>", title);
+ break;
case CONNMAN_TYPE_SYSCONFIG:
title = N_("System Configuration");
markup = g_strdup_printf("<b>\n%s\n</b>", title);
@@ -362,6 +404,10 @@ static void type_to_icon(GtkTreeViewColumn *column, GtkCellRenderer *cell,
g_object_set(cell, "icon-name", "network-wireless",
"stock-size", 4, NULL);
break;
+ case CONNMAN_TYPE_LABEL_CELLULAR:
+ g_object_set(cell, "icon-name", "network-cellular",
+ "stock-size", 4, NULL);
+ break;
default:
g_object_set(cell, "icon-name", NULL, NULL);
break;
|