device: renew dhcp leases on awake for software devices
[NetworkManager.git] / libnm-util / nm-setting-gsm.c
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2
3 /*
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301 USA.
18  *
19  * Copyright 2007 - 2013 Red Hat, Inc.
20  * Copyright 2007 - 2008 Novell, Inc.
21  */
22
23 #include "nm-default.h"
24
25 #include <string.h>
26
27 #include "nm-setting-gsm.h"
28 #include "nm-utils.h"
29 #include "nm-setting-private.h"
30
31 /**
32  * SECTION:nm-setting-gsm
33  * @short_description: Describes GSM/3GPP-based mobile broadband properties
34  * @include: nm-setting-gsm.h
35  *
36  * The #NMSettingGsm object is a #NMSetting subclass that describes
37  * properties that allow connections to 3GPP-based mobile broadband
38  * networks, including those using GPRS/EDGE and UMTS/HSPA technology.
39  */
40
41 /**
42  * nm_setting_gsm_error_quark:
43  *
44  * Registers an error quark for #NMSettingGsm if necessary.
45  *
46  * Returns: the error quark used for #NMSettingGsm errors.
47  **/
48 GQuark
49 nm_setting_gsm_error_quark (void)
50 {
51         static GQuark quark;
52
53         if (G_UNLIKELY (!quark))
54                 quark = g_quark_from_static_string ("nm-setting-gsm-error-quark");
55         return quark;
56 }
57
58
59 G_DEFINE_TYPE_WITH_CODE (NMSettingGsm, nm_setting_gsm, NM_TYPE_SETTING,
60                          _nm_register_setting (NM_SETTING_GSM_SETTING_NAME,
61                                                g_define_type_id,
62                                                1,
63                                                NM_SETTING_GSM_ERROR))
64 NM_SETTING_REGISTER_TYPE (NM_TYPE_SETTING_GSM)
65
66 #define NM_SETTING_GSM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_GSM, NMSettingGsmPrivate))
67
68 typedef struct {
69         char *number; /* For dialing, duh */
70         char *username;
71         char *password;
72         NMSettingSecretFlags password_flags;
73
74         char *apn; /* NULL for dynamic */
75         char *network_id; /* for manual registration or NULL for automatic */
76         int network_type; /* One of the NM_SETTING_GSM_NETWORK_TYPE_* */
77         guint32 allowed_bands;     /* A bitfield of NM_SETTING_GSM_BAND_* */
78
79         char *pin;
80         NMSettingSecretFlags pin_flags;
81
82         gboolean home_only;
83 } NMSettingGsmPrivate;
84
85 enum {
86         PROP_0,
87         PROP_NUMBER,
88         PROP_USERNAME,
89         PROP_PASSWORD,
90         PROP_PASSWORD_FLAGS,
91         PROP_APN,
92         PROP_NETWORK_ID,
93         PROP_NETWORK_TYPE,
94         PROP_PIN,
95         PROP_PIN_FLAGS,
96         PROP_ALLOWED_BANDS,
97         PROP_HOME_ONLY,
98
99         LAST_PROP
100 };
101
102 /**
103  * nm_setting_gsm_new:
104  *
105  * Creates a new #NMSettingGsm object with default values.
106  *
107  * Returns: the new empty #NMSettingGsm object
108  **/
109 NMSetting *
110 nm_setting_gsm_new (void)
111 {
112         return (NMSetting *) g_object_new (NM_TYPE_SETTING_GSM, NULL);
113 }
114
115 /**
116  * nm_setting_gsm_get_number:
117  * @setting: the #NMSettingGsm
118  *
119  * Returns: the #NMSettingGsm:number property of the setting
120  **/
121 const char *
122 nm_setting_gsm_get_number (NMSettingGsm *setting)
123 {
124         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
125
126         return NM_SETTING_GSM_GET_PRIVATE (setting)->number;
127 }
128
129 /**
130  * nm_setting_gsm_get_username:
131  * @setting: the #NMSettingGsm
132  *
133  * Returns: the #NMSettingGsm:username property of the setting
134  **/
135 const char *
136 nm_setting_gsm_get_username (NMSettingGsm *setting)
137 {
138         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
139
140         return NM_SETTING_GSM_GET_PRIVATE (setting)->username;
141 }
142
143 /**
144  * nm_setting_gsm_get_password:
145  * @setting: the #NMSettingGsm
146  *
147  * Returns: the #NMSettingGsm:password property of the setting
148  **/
149 const char *
150 nm_setting_gsm_get_password (NMSettingGsm *setting)
151 {
152         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
153
154         return NM_SETTING_GSM_GET_PRIVATE (setting)->password;
155 }
156
157 /**
158  * nm_setting_gsm_get_password_flags:
159  * @setting: the #NMSettingGsm
160  *
161  * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingGsm:password
162  **/
163 NMSettingSecretFlags
164 nm_setting_gsm_get_password_flags (NMSettingGsm *setting)
165 {
166         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_SECRET_FLAG_NONE);
167
168         return NM_SETTING_GSM_GET_PRIVATE (setting)->password_flags;
169 }
170
171 /**
172  * nm_setting_gsm_get_apn:
173  * @setting: the #NMSettingGsm
174  *
175  * Returns: the #NMSettingGsm:apn property of the setting
176  **/
177 const char *
178 nm_setting_gsm_get_apn (NMSettingGsm *setting)
179 {
180         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
181
182         return NM_SETTING_GSM_GET_PRIVATE (setting)->apn;
183 }
184
185 /**
186  * nm_setting_gsm_get_network_id:
187  * @setting: the #NMSettingGsm
188  *
189  * Returns: the #NMSettingGsm:network-id property of the setting
190  **/
191 const char *
192 nm_setting_gsm_get_network_id (NMSettingGsm *setting)
193 {
194         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
195
196         return NM_SETTING_GSM_GET_PRIVATE (setting)->network_id;
197 }
198
199 /**
200  * nm_setting_gsm_get_network_type:
201  * @setting: the #NMSettingGsm
202  *
203  * Returns: the #NMSettingGsm:network-type property of the setting
204  *
205  * Deprecated: 0.9.10: No longer used. Network type setting should be done talking to ModemManager directly.
206  **/
207 int
208 nm_setting_gsm_get_network_type (NMSettingGsm *setting)
209 {
210         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), -1);
211
212         return NM_SETTING_GSM_GET_PRIVATE (setting)->network_type;
213 }
214
215 /**
216  * nm_setting_gsm_get_allowed_bands:
217  * @setting: the #NMSettingGsm
218  *
219  * Returns: the #NMSettingGsm:allowed-bands property of the setting
220  *
221  * Deprecated: 0.9.10: No longer used. Bands setting should be done talking to ModemManager directly.
222  **/
223 guint32
224 nm_setting_gsm_get_allowed_bands (NMSettingGsm *setting)
225 {
226         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_GSM_BAND_UNKNOWN);
227
228         return NM_SETTING_GSM_GET_PRIVATE (setting)->allowed_bands;
229 }
230
231 /**
232  * nm_setting_gsm_get_pin:
233  * @setting: the #NMSettingGsm
234  *
235  * Returns: the #NMSettingGsm:pin property of the setting
236  **/
237 const char *
238 nm_setting_gsm_get_pin (NMSettingGsm *setting)
239 {
240         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NULL);
241
242         return NM_SETTING_GSM_GET_PRIVATE (setting)->pin;
243 }
244
245 /**
246  * nm_setting_gsm_get_pin_flags:
247  * @setting: the #NMSettingGsm
248  *
249  * Returns: the #NMSettingSecretFlags pertaining to the #NMSettingGsm:pin
250  **/
251 NMSettingSecretFlags
252 nm_setting_gsm_get_pin_flags (NMSettingGsm *setting)
253 {
254         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), NM_SETTING_SECRET_FLAG_NONE);
255
256         return NM_SETTING_GSM_GET_PRIVATE (setting)->pin_flags;
257 }
258
259 /**
260  * nm_setting_gsm_get_home_only:
261  * @setting: the #NMSettingGsm
262  *
263  * Returns: the #NMSettingGsm:home-only property of the setting
264  **/
265 gboolean
266 nm_setting_gsm_get_home_only (NMSettingGsm *setting)
267 {
268         g_return_val_if_fail (NM_IS_SETTING_GSM (setting), FALSE);
269
270         return NM_SETTING_GSM_GET_PRIVATE (setting)->home_only;
271 }
272
273 static gboolean
274 verify (NMSetting *setting, GSList *all_settings, GError **error)
275 {
276         NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
277
278         if (priv->number && !priv->number[0]) {
279                 g_set_error_literal (error,
280                                      NM_SETTING_GSM_ERROR,
281                                      NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
282                                      _("property is empty"));
283                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NUMBER);
284                 return FALSE;
285         }
286
287         if (priv->apn) {
288                 guint32 apn_len = strlen (priv->apn);
289                 guint32 i;
290
291                 if (apn_len < 1 || apn_len > 64) {
292                         g_set_error (error,
293                                      NM_SETTING_GSM_ERROR,
294                                      NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
295                                      _("property value '%s' is empty or too long (>64)"),
296                                      priv->apn);
297                         g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_APN);
298                         return FALSE;
299                 }
300
301                 /* APNs roughly follow the same rules as DNS domain names.  Allowed
302                  * characters are a-z, 0-9, . and -.  GSM 03.03 Section 9.1 states:
303                  *
304                  *   The syntax of the APN shall follow the Name Syntax defined in
305                  *   RFC 2181 [14] and RFC 1035 [15]. The APN consists of one or
306                  *   more labels. Each label is coded as one octet length field
307                  *   followed by that number of octets coded as 8 bit ASCII characters.
308                  *   Following RFC 1035 [15] the labels should consist only of the
309                  *   alphabetic characters (A-Z and a-z), digits (0-9) and the
310                  *   dash (-). The case of alphabetic characters is not significant.
311                  *
312                  * A dot (.) is commonly used to separate parts of the APN, and
313                  * apparently the underscore (_) is used as well.  RFC 2181 indicates
314                  * that no restrictions of any kind are placed on DNS labels, and thus
315                  * it would appear that none are placed on APNs either, but many modems
316                  * and networks will fail to accept APNs that include odd characters
317                  * like space ( ) and such.
318                  */
319                 for (i = 0; i < apn_len; i++) {
320                         if (   !g_ascii_isalnum (priv->apn[i])
321                             && (priv->apn[i] != '.')
322                             && (priv->apn[i] != '_')
323                             && (priv->apn[i] != '-')) {
324                                 g_set_error (error,
325                                              NM_SETTING_GSM_ERROR,
326                                              NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
327                                              _("'%s' contains invalid char(s) (use [A-Za-z._-])"),
328                                              priv->apn);
329                                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_APN);
330                                 return FALSE;
331                         }
332                 }
333         }
334
335         if (priv->username && !strlen (priv->username)) {
336                 g_set_error_literal (error,
337                                      NM_SETTING_GSM_ERROR,
338                                      NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
339                                      _("property is empty"));
340                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_USERNAME);
341                 return FALSE;
342         }
343
344         if (priv->network_id) {
345                 guint32 nid_len = strlen (priv->network_id);
346                 guint32 i;
347
348                 /* Accept both 5 and 6 digit MCC/MNC codes */
349                 if ((nid_len < 5) || (nid_len > 6)) {
350                         g_set_error (error,
351                                      NM_SETTING_GSM_ERROR,
352                                      NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
353                                      _("'%s' length is invalid (should be 5 or 6 digits)"),
354                                      priv->network_id);
355                         g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NETWORK_ID);
356                         return FALSE;
357                 }
358
359                 for (i = 0; i < nid_len; i++) {
360                         if (!g_ascii_isdigit (priv->network_id[i])) {
361                                 g_set_error (error,
362                                              NM_SETTING_GSM_ERROR,
363                                              NM_SETTING_GSM_ERROR_INVALID_PROPERTY,
364                                              _("'%s' is not a number"),
365                                              priv->network_id);
366                                 g_prefix_error (error, "%s.%s: ", NM_SETTING_GSM_SETTING_NAME, NM_SETTING_GSM_NETWORK_ID);
367                                 return FALSE;
368                         }
369                 }
370         }
371
372         return TRUE;
373 }
374
375 static GPtrArray *
376 need_secrets (NMSetting *setting)
377 {
378         NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (setting);
379         GPtrArray *secrets = NULL;
380
381         if (priv->password && *priv->password)
382                 return NULL;
383
384         if (priv->username) {
385                 if (!(priv->password_flags & NM_SETTING_SECRET_FLAG_NOT_REQUIRED)) {
386                         secrets = g_ptr_array_sized_new (1);
387                         g_ptr_array_add (secrets, NM_SETTING_GSM_PASSWORD);
388                 }
389         }
390
391         return secrets;
392 }
393
394 static void
395 nm_setting_gsm_init (NMSettingGsm *setting)
396 {
397 }
398
399 static void
400 finalize (GObject *object)
401 {
402         NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
403
404         g_free (priv->number);
405         g_free (priv->username);
406         g_free (priv->password);
407         g_free (priv->apn);
408         g_free (priv->network_id);
409         g_free (priv->pin);
410
411         G_OBJECT_CLASS (nm_setting_gsm_parent_class)->finalize (object);
412 }
413
414 static void
415 set_property (GObject *object, guint prop_id,
416               const GValue *value, GParamSpec *pspec)
417 {
418         NMSettingGsmPrivate *priv = NM_SETTING_GSM_GET_PRIVATE (object);
419         char *tmp;
420
421         switch (prop_id) {
422         case PROP_NUMBER:
423                 g_free (priv->number);
424                 priv->number = g_value_dup_string (value);
425                 break;
426         case PROP_USERNAME:
427                 g_free (priv->username);
428                 priv->username = g_value_dup_string (value);
429                 break;
430         case PROP_PASSWORD:
431                 g_free (priv->password);
432                 priv->password = g_value_dup_string (value);
433                 break;
434         case PROP_PASSWORD_FLAGS:
435                 priv->password_flags = g_value_get_uint (value);
436                 break;
437         case PROP_APN:
438                 g_free (priv->apn);
439                 priv->apn = NULL;
440                 tmp = g_value_dup_string (value);
441                 if (tmp)
442                         priv->apn = g_strstrip (tmp);
443                 break;
444         case PROP_NETWORK_ID:
445                 g_free (priv->network_id);
446                 priv->network_id = NULL;
447                 tmp = g_value_dup_string (value);
448                 if (tmp)
449                         priv->network_id = g_strstrip (tmp);
450                 break;
451         case PROP_NETWORK_TYPE:
452                 priv->network_type = g_value_get_int (value);
453                 break;
454         case PROP_ALLOWED_BANDS:
455                 priv->allowed_bands = g_value_get_uint (value);
456                 break;
457         case PROP_PIN:
458                 g_free (priv->pin);
459                 priv->pin = g_value_dup_string (value);
460                 break;
461         case PROP_PIN_FLAGS:
462                 priv->pin_flags = g_value_get_uint (value);
463                 break;
464         case PROP_HOME_ONLY:
465                 priv->home_only = g_value_get_boolean (value);
466                 break;
467         default:
468                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
469                 break;
470         }
471 }
472
473 static void
474 get_property (GObject *object, guint prop_id,
475               GValue *value, GParamSpec *pspec)
476 {
477         NMSettingGsm *setting = NM_SETTING_GSM (object);
478
479         switch (prop_id) {
480         case PROP_NUMBER:
481                 g_value_set_string (value, nm_setting_gsm_get_number (setting));
482                 break;
483         case PROP_USERNAME:
484                 g_value_set_string (value, nm_setting_gsm_get_username (setting));
485                 break;
486         case PROP_PASSWORD:
487                 g_value_set_string (value, nm_setting_gsm_get_password (setting));
488                 break;
489         case PROP_PASSWORD_FLAGS:
490                 g_value_set_uint (value, nm_setting_gsm_get_password_flags (setting));
491                 break;
492         case PROP_APN:
493                 g_value_set_string (value, nm_setting_gsm_get_apn (setting));
494                 break;
495         case PROP_NETWORK_ID:
496                 g_value_set_string (value, nm_setting_gsm_get_network_id (setting));
497                 break;
498         case PROP_NETWORK_TYPE:
499                 g_value_set_int (value, NM_SETTING_GSM_GET_PRIVATE (setting)->network_type);
500                 break;
501         case PROP_ALLOWED_BANDS:
502                 g_value_set_uint (value, NM_SETTING_GSM_GET_PRIVATE (setting)->allowed_bands);
503                 break;
504         case PROP_PIN:
505                 g_value_set_string (value, nm_setting_gsm_get_pin (setting));
506                 break;
507         case PROP_PIN_FLAGS:
508                 g_value_set_uint (value, nm_setting_gsm_get_pin_flags (setting));
509                 break;
510         case PROP_HOME_ONLY:
511                 g_value_set_boolean (value, nm_setting_gsm_get_home_only (setting));
512                 break;
513         default:
514                 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
515                 break;
516         }
517 }
518
519 static void
520 nm_setting_gsm_class_init (NMSettingGsmClass *setting_class)
521 {
522         GObjectClass *object_class = G_OBJECT_CLASS (setting_class);
523         NMSettingClass *parent_class = NM_SETTING_CLASS (setting_class);
524
525         g_type_class_add_private (setting_class, sizeof (NMSettingGsmPrivate));
526
527         /* virtual methods */
528         object_class->set_property = set_property;
529         object_class->get_property = get_property;
530         object_class->finalize     = finalize;
531         parent_class->verify       = verify;
532         parent_class->need_secrets = need_secrets;
533
534         /* Properties */
535
536         /**
537          * NMSettingGsm:number:
538          *
539          * Number to dial when establishing a PPP data session with the GSM-based
540          * mobile broadband network.  Many modems do not require PPP for connections
541          * to the mobile network and thus this property should be left blank, which
542          * allows NetworkManager to select the appropriate settings automatically.
543          **/
544         g_object_class_install_property
545                 (object_class, PROP_NUMBER,
546                  g_param_spec_string (NM_SETTING_GSM_NUMBER, "", "",
547                                       NULL,
548                                       G_PARAM_READWRITE |
549                                       G_PARAM_STATIC_STRINGS));
550
551         /**
552          * NMSettingGsm:username:
553          *
554          * The username used to authenticate with the network, if required.  Many
555          * providers do not require a username, or accept any username.  But if a
556          * username is required, it is specified here.
557          **/
558         g_object_class_install_property
559                 (object_class, PROP_USERNAME,
560                  g_param_spec_string (NM_SETTING_GSM_USERNAME, "", "",
561                                       NULL,
562                                       G_PARAM_READWRITE |
563                                       G_PARAM_STATIC_STRINGS));
564
565         /**
566          * NMSettingGsm:password:
567          *
568          * The password used to authenticate with the network, if required.  Many
569          * providers do not require a password, or accept any password.  But if a
570          * password is required, it is specified here.
571          **/
572         g_object_class_install_property
573                 (object_class, PROP_PASSWORD,
574                  g_param_spec_string (NM_SETTING_GSM_PASSWORD, "", "",
575                                       NULL,
576                                       G_PARAM_READWRITE |
577                                       NM_SETTING_PARAM_SECRET |
578                                       G_PARAM_STATIC_STRINGS));
579
580         /**
581          * NMSettingGsm:password-flags:
582          *
583          * Flags indicating how to handle the #NMSettingGsm:password property.
584          **/
585         g_object_class_install_property
586                 (object_class, PROP_PASSWORD_FLAGS,
587                  g_param_spec_uint (NM_SETTING_GSM_PASSWORD_FLAGS, "", "",
588                                     NM_SETTING_SECRET_FLAG_NONE,
589                                     NM_SETTING_SECRET_FLAGS_ALL,
590                                     NM_SETTING_SECRET_FLAG_NONE,
591                                     G_PARAM_READWRITE |
592                                     G_PARAM_STATIC_STRINGS));
593
594         /**
595          * NMSettingGsm:apn:
596          *
597          * The GPRS Access Point Name specifying the APN used when establishing a
598          * data session with the GSM-based network.  The APN often determines how
599          * the user will be billed for their network usage and whether the user has
600          * access to the Internet or just a provider-specific walled-garden, so it
601          * is important to use the correct APN for the user's mobile broadband plan.
602          * The APN may only be composed of the characters a-z, 0-9, ., and - per GSM
603          * 03.60 Section 14.9.
604          **/
605         g_object_class_install_property
606                 (object_class, PROP_APN,
607                  g_param_spec_string (NM_SETTING_GSM_APN, "", "",
608                                       NULL,
609                                       G_PARAM_READWRITE |
610                                       G_PARAM_STATIC_STRINGS));
611
612         /**
613          * NMSettingGsm:network-id:
614          *
615          * The Network ID (GSM LAI format, ie MCC-MNC) to force specific network
616          * registration.  If the Network ID is specified, NetworkManager will
617          * attempt to force the device to register only on the specified network.
618          * This can be used to ensure that the device does not roam when direct
619          * roaming control of the device is not otherwise possible.
620          **/
621         g_object_class_install_property
622                 (object_class, PROP_NETWORK_ID,
623                  g_param_spec_string (NM_SETTING_GSM_NETWORK_ID, "", "",
624                                       NULL,
625                                       G_PARAM_READWRITE |
626                                       G_PARAM_STATIC_STRINGS));
627
628         /**
629          * NMSettingGsm:network-type:
630          *
631          * Network preference to force the device to only use specific network
632          * technologies. The permitted values are %NM_SETTING_GSM_NETWORK_TYPE_ANY,
633          * %NM_SETTING_GSM_NETWORK_TYPE_UMTS_HSPA,
634          * %NM_SETTING_GSM_NETWORK_TYPE_GPRS_EDGE,
635          * %NM_SETTING_GSM_NETWORK_TYPE_PREFER_UMTS_HSPA,
636          * %NM_SETTING_GSM_NETWORK_TYPE_PREFER_GPRS_EDGE,
637          * %NM_SETTING_GSM_NETWORK_TYPE_PREFER_4G, and
638          * %NM_SETTING_GSM_NETWORK_TYPE_4G.  Note that not all devices allow network
639          * preference control.
640          *
641          * Deprecated: 0.9.10: No longer used. Network type setting should be done
642          * by talking to ModemManager directly.
643          **/
644         g_object_class_install_property
645                 (object_class, PROP_NETWORK_TYPE,
646                  g_param_spec_int (NM_SETTING_GSM_NETWORK_TYPE, "", "",
647                                    NM_SETTING_GSM_NETWORK_TYPE_ANY,
648                                    NM_SETTING_GSM_NETWORK_TYPE_4G,
649                                    NM_SETTING_GSM_NETWORK_TYPE_ANY,
650                                    G_PARAM_READWRITE |
651                                    G_PARAM_CONSTRUCT |
652                                    G_PARAM_STATIC_STRINGS));
653
654         /**
655          * NMSettingGsm:allowed-bands:
656          *
657          * Bitfield of allowed frequency bands.  Note that not all devices allow
658          * frequency band control.  Permitted values are those specified by
659          * #NMSettingGsmNetworkBand.
660          *
661          * Deprecated: 0.9.10: No longer used. Band setting should be done by
662          * talking to ModemManager directly.
663          **/
664         g_object_class_install_property
665                 (object_class, PROP_ALLOWED_BANDS,
666                  g_param_spec_uint (NM_SETTING_GSM_ALLOWED_BANDS, "", "",
667                                     NM_SETTING_GSM_BAND_UNKNOWN,
668                                     NM_SETTING_GSM_BANDS_MAX,
669                                     NM_SETTING_GSM_BAND_ANY,
670                                     G_PARAM_READWRITE |
671                                     G_PARAM_CONSTRUCT |
672                                     G_PARAM_STATIC_STRINGS));
673
674         /**
675          * NMSettingGsm:pin:
676          *
677          * If the SIM is locked with a PIN it must be unlocked before any other
678          * operations are requested.  Specify the PIN here to allow operation of the
679          * device.
680          **/
681         g_object_class_install_property
682                 (object_class, PROP_PIN,
683                  g_param_spec_string (NM_SETTING_GSM_PIN, "", "",
684                                       NULL,
685                                       G_PARAM_READWRITE |
686                                       NM_SETTING_PARAM_SECRET |
687                                       G_PARAM_STATIC_STRINGS));
688
689         /**
690          * NMSettingGsm:pin-flags:
691          *
692          * Flags indicating how to handle the #NMSettingGsm:pin property.
693          **/
694         g_object_class_install_property
695                 (object_class, PROP_PIN_FLAGS,
696                  g_param_spec_uint (NM_SETTING_GSM_PIN_FLAGS, "", "",
697                                     NM_SETTING_SECRET_FLAG_NONE,
698                                     NM_SETTING_SECRET_FLAGS_ALL,
699                                     NM_SETTING_SECRET_FLAG_NONE,
700                                     G_PARAM_READWRITE |
701                                     G_PARAM_STATIC_STRINGS));
702
703         /**
704          * NMSettingGsm:home-only:
705          *
706          * When %TRUE, only connections to the home network will be allowed.
707          * Connections to roaming networks will not be made.
708          **/
709         g_object_class_install_property
710                 (object_class, PROP_HOME_ONLY,
711                  g_param_spec_boolean (NM_SETTING_GSM_HOME_ONLY, "", "",
712                                        FALSE,
713                                        G_PARAM_READWRITE |
714                                        G_PARAM_STATIC_STRINGS));
715 }