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 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2011 Google, Inc.
*/
#include <string.h>
#include "mm-enums-types.h"
#include "mm-errors-types.h"
#include "mm-common-helpers.h"
#include "mm-simple-status.h"
#include "mm-modem-cdma.h"
/**
* SECTION: mm-simple-status
* @title: MMSimpleStatus
* @short_description: Helper object to handle overall modem status.
*
* The #MMSimpleStatus is an object handling the general modem status properties,
* available in the Simple interface.
*
* This object is retrieved with either mm_modem_simple_get_status() or
* mm_modem_simple_get_status_sync().
*/
G_DEFINE_TYPE (MMSimpleStatus, mm_simple_status, G_TYPE_OBJECT);
enum {
PROP_0,
PROP_STATE,
PROP_SIGNAL_QUALITY,
PROP_CURRENT_BANDS,
PROP_ACCESS_TECHNOLOGIES,
PROP_3GPP_REGISTRATION_STATE,
PROP_3GPP_OPERATOR_CODE,
PROP_3GPP_OPERATOR_NAME,
PROP_3GPP_SUBSCRIPTION_STATE,
PROP_CDMA_CDMA1X_REGISTRATION_STATE,
PROP_CDMA_EVDO_REGISTRATION_STATE,
PROP_CDMA_SID,
PROP_CDMA_NID,
PROP_LAST
};
static GParamSpec *properties[PROP_LAST];
struct _MMSimpleStatusPrivate {
/* <--- From the Modem interface ---> */
/* Overall modem state, signature 'u' */
MMModemState state;
/* Signal quality, given only when registered, signature '(ub)' */
GVariant *signal_quality;
/* List of bands, given only when registered, signature: au */
GVariant *current_bands;
GArray *current_bands_array;
/* Access technologies, given only when registered, signature: u */
MMModemAccessTechnology access_technologies;
/* <--- From the Modem 3GPP interface ---> */
/* 3GPP registration state, signature 'u' */
MMModem3gppRegistrationState modem_3gpp_registration_state;
/* 3GPP operator code, given only when registered, signature 's' */
gchar *modem_3gpp_operator_code;
/* 3GPP operator name, given only when registered, signature 's' */
gchar *modem_3gpp_operator_name;
/* 3GPP subsctiption state, signature 'u' */
MMModem3gppSubscriptionState modem_3gpp_subscription_state;
/* <--- From the Modem CDMA interface ---> */
/* CDMA/CDMA1x registration state, signature 'u' */
MMModemCdmaRegistrationState modem_cdma_cdma1x_registration_state;
/* CDMA/EV-DO registration state, signature 'u' */
MMModemCdmaRegistrationState modem_cdma_evdo_registration_state;
/* SID, signature 'u' */
guint modem_cdma_sid;
/* NID, signature 'u' */
guint modem_cdma_nid;
};
/*****************************************************************************/
/**
* mm_simple_status_get_state:
* @self: a #MMSimpleStatus.
*
* Gets the state of the modem.
*
* Returns: a #MMModemState.
*/
MMModemState
mm_simple_status_get_state (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_STATE_UNKNOWN);
return self->priv->state;
}
/*****************************************************************************/
/**
* mm_simple_status_get_signal_quality:
* @self: a #MMSimpleStatus.
* @recent: (out) (allow-none): indication of whether the given signal quality is considered recent.
*
* Gets the signal quality.
*
* Returns: the signal quality.
*/
guint32
mm_simple_status_get_signal_quality (MMSimpleStatus *self,
gboolean *recent)
{
guint32 signal_quality = 0;
gboolean signal_quality_recent = FALSE;
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), 0);
if (self->priv->signal_quality) {
g_variant_get (self->priv->signal_quality,
"(ub)",
&signal_quality,
&signal_quality_recent);
}
if (recent)
*recent = signal_quality_recent;
return signal_quality;
}
/*****************************************************************************/
/**
* mm_simple_status_get_current_bands:
* @self: a #MMSimpleStatus.
* @bands: (out): location for an array of #MMModemBand values. Do not free the returned value, it is owned by @self.
* @n_bands: (out): number of elements in @bands.
*
* Gets the currently used frequency bands.
*/
void
mm_simple_status_get_current_bands (MMSimpleStatus *self,
const MMModemBand **bands,
guint *n_bands)
{
g_return_if_fail (MM_IS_SIMPLE_STATUS (self));
if (!self->priv->current_bands_array)
self->priv->current_bands_array = mm_common_bands_variant_to_garray (self->priv->current_bands);
*n_bands = self->priv->current_bands_array->len;
*bands = (const MMModemBand *)self->priv->current_bands_array->data;
}
/*****************************************************************************/
/**
* mm_simple_status_get_access_technologies:
* @self: a #MMSimpleStatus.
*
* Gets the currently used access technologies.
*
* Returns: a bitmask of #MMModemAccessTechnology values.
*/
MMModemAccessTechnology
mm_simple_status_get_access_technologies (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN);
return self->priv->access_technologies;
}
/*****************************************************************************/
/**
* mm_simple_status_get_3gpp_registration_state:
* @self: a #MMSimpleStatus.
*
* Gets the current state of the registration in the 3GPP network.
*
* Returns: a #MMModem3gppRegistrationState.
*/
MMModem3gppRegistrationState
mm_simple_status_get_3gpp_registration_state (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN);
return self->priv->modem_3gpp_registration_state;
}
/*****************************************************************************/
/**
* mm_simple_status_get_3gpp_operator_code:
* @self: a #MMSimpleStatus.
*
* Gets the MCC/MNC of the operator of the 3GPP network where the modem is registered.
*
* Returns: the operator code, or %NULL if unknown. Do not free the returned value, it is owned by @self.
*/
const gchar *
mm_simple_status_get_3gpp_operator_code (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), NULL);
return self->priv->modem_3gpp_operator_code;
}
/*****************************************************************************/
/**
* mm_simple_status_get_3gpp_operator_name:
* @self: a #MMSimpleStatus.
*
* Gets the name of the operator of the 3GPP network where the modem is registered.
*
* Returns: the operator name, or %NULL if unknown. Do not free the returned value, it is owned by @self.
*/
const gchar *
mm_simple_status_get_3gpp_operator_name (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), NULL);
return self->priv->modem_3gpp_operator_name;
}
/*****************************************************************************/
/**
* mm_simple_status_get_3gpp_subscription_state:
* @self: a #MMSimpleStatus.
*
* Gets the current subscription status of the account.
*
* Returns: a #MMModem3gppSubscriptionState.
*/
MMModem3gppSubscriptionState
mm_simple_status_get_3gpp_subscription_state (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_3GPP_SUBSCRIPTION_STATE_UNKNOWN);
return self->priv->modem_3gpp_subscription_state;
}
/*****************************************************************************/
/**
* mm_simple_status_get_cdma_cdma1x_registration_state:
* @self: a #MMSimpleStatus.
*
* Gets the current state of the registration in the CDMA-1x network.
*
* Returns: a #MMModemCdmaRegistrationState.
*/
MMModemCdmaRegistrationState
mm_simple_status_get_cdma_cdma1x_registration_state (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN);
return self->priv->modem_cdma_cdma1x_registration_state;
}
/*****************************************************************************/
/**
* mm_simple_status_get_cdma_evdo_registration_state:
* @self: a #MMSimpleStatus.
*
* Gets the current state of the registration in the EV-DO network.
*
* Returns: a #MMModemCdmaRegistrationState.
*/
MMModemCdmaRegistrationState
mm_simple_status_get_cdma_evdo_registration_state (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN);
return self->priv->modem_cdma_evdo_registration_state;
}
/*****************************************************************************/
/**
* mm_simple_status_get_cdma_sid:
* @self: a #MMSimpleStatus.
*
* Gets the System Identification number of the CDMA network.
*
* Returns: the SID, or %MM_MODEM_CDMA_SID_UNKNOWN if unknown.
*/
guint
mm_simple_status_get_cdma_sid (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_CDMA_SID_UNKNOWN);
return self->priv->modem_cdma_sid;
}
/*****************************************************************************/
/**
* mm_simple_status_get_cdma_nid:
* @self: a #MMSimpleStatus.
*
* Gets the Network Identification number of the CDMA network.
*
* Returns: the NID, or %MM_MODEM_CDMA_NID_UNKNOWN if unknown.
*/
guint
mm_simple_status_get_cdma_nid (MMSimpleStatus *self)
{
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), MM_MODEM_CDMA_NID_UNKNOWN);
return self->priv->modem_cdma_nid;
}
/*****************************************************************************/
GVariant *
mm_simple_status_get_dictionary (MMSimpleStatus *self)
{
GVariantBuilder builder;
/* Allow NULL */
if (!self)
return NULL;
g_return_val_if_fail (MM_IS_SIMPLE_STATUS (self), NULL);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{sv}"));
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_STATE,
g_variant_new_uint32 (self->priv->state));
/* Next ones, only when registered */
if (self->priv->state >= MM_MODEM_STATE_REGISTERED) {
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_SIGNAL_QUALITY,
self->priv->signal_quality);
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_CURRENT_BANDS,
self->priv->current_bands);
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_ACCESS_TECHNOLOGIES,
g_variant_new_uint32 (self->priv->access_technologies));
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE,
g_variant_new_uint32 (self->priv->modem_3gpp_registration_state));
if (self->priv->modem_3gpp_operator_code)
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE,
g_variant_new_string (self->priv->modem_3gpp_operator_code));
if (self->priv->modem_3gpp_operator_name)
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME,
g_variant_new_string (self->priv->modem_3gpp_operator_name));
if (self->priv->modem_cdma_cdma1x_registration_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) {
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE,
g_variant_new_uint32 (self->priv->modem_cdma_cdma1x_registration_state));
if (self->priv->modem_cdma_sid != MM_MODEM_CDMA_SID_UNKNOWN)
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_CDMA_SID,
g_variant_new_uint32 (self->priv->modem_cdma_sid));
if (self->priv->modem_cdma_nid != MM_MODEM_CDMA_NID_UNKNOWN)
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_CDMA_NID,
g_variant_new_uint32 (self->priv->modem_cdma_nid));
}
if (self->priv->modem_cdma_evdo_registration_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN)
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_CDMA_EVDO_REGISTRATION_STATE,
g_variant_new_uint32 (self->priv->modem_cdma_evdo_registration_state));
}
if (self->priv->modem_3gpp_subscription_state)
g_variant_builder_add (&builder,
"{sv}",
MM_SIMPLE_PROPERTY_3GPP_SUBSCRIPTION_STATE,
g_variant_new_uint32 (self->priv->modem_3gpp_subscription_state));
return g_variant_ref_sink (g_variant_builder_end (&builder));
}
/*****************************************************************************/
MMSimpleStatus *
mm_simple_status_new_from_dictionary (GVariant *dictionary,
GError **error)
{
GError *inner_error = NULL;
GVariantIter iter;
gchar *key;
GVariant *value;
MMSimpleStatus *properties;
properties = mm_simple_status_new ();
if (!dictionary)
return properties;
if (!g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{sv}"))) {
g_set_error (error,
MM_CORE_ERROR,
MM_CORE_ERROR_INVALID_ARGS,
"Cannot create Simple status from dictionary: "
"invalid variant type received");
g_object_unref (properties);
return NULL;
}
g_variant_iter_init (&iter, dictionary);
while (!inner_error &&
g_variant_iter_next (&iter, "{sv}", &key, &value)) {
/* Note: we could do a more efficient matching by checking the variant type
* and just g_object_set()-ing they specific 'key' and value, but we do want
* to check which input keys we receive, in order to propagate the error.
*/
if (g_str_equal (key, MM_SIMPLE_PROPERTY_STATE) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_ACCESS_TECHNOLOGIES) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_SUBSCRIPTION_STATE) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_EVDO_REGISTRATION_STATE) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_SID) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_CDMA_NID)) {
/* uint properties */
g_object_set (properties,
key, g_variant_get_uint32 (value),
NULL);
} else if (g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME)) {
/* string properties */
g_object_set (properties,
key, g_variant_get_string (value, NULL),
NULL);
} else if (g_str_equal (key, MM_SIMPLE_PROPERTY_CURRENT_BANDS) ||
g_str_equal (key, MM_SIMPLE_PROPERTY_SIGNAL_QUALITY)) {
/* remaining complex types, as variant */
g_object_set (properties,
key, value,
NULL);
} else {
/* Set inner error, will stop the loop */
inner_error = g_error_new (MM_CORE_ERROR,
MM_CORE_ERROR_INVALID_ARGS,
"Invalid status dictionary, unexpected key '%s'",
key);
}
g_free (key);
g_variant_unref (value);
}
/* If error, destroy the object */
if (inner_error) {
g_propagate_error (error, inner_error);
g_object_unref (properties);
properties = NULL;
}
return properties;
}
/*****************************************************************************/
MMSimpleStatus *
mm_simple_status_new (void)
{
return (MM_SIMPLE_STATUS (
g_object_new (MM_TYPE_SIMPLE_STATUS, NULL)));
}
static void
set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
MMSimpleStatus *self = MM_SIMPLE_STATUS (object);
switch (prop_id) {
case PROP_STATE:
self->priv->state = g_value_get_enum (value);
break;
case PROP_SIGNAL_QUALITY:
if (self->priv->signal_quality)
g_variant_unref (self->priv->signal_quality);
self->priv->signal_quality = g_value_dup_variant (value);
break;
case PROP_CURRENT_BANDS:
if (self->priv->current_bands)
g_variant_unref (self->priv->current_bands);
if (self->priv->current_bands_array) {
g_array_unref (self->priv->current_bands_array);
self->priv->current_bands_array = NULL;
}
self->priv->current_bands = g_value_dup_variant (value);
break;
case PROP_ACCESS_TECHNOLOGIES:
self->priv->access_technologies = g_value_get_flags (value);
break;
case PROP_3GPP_REGISTRATION_STATE:
self->priv->modem_3gpp_registration_state = g_value_get_enum (value);
break;
case PROP_3GPP_OPERATOR_CODE:
g_free (self->priv->modem_3gpp_operator_code);
self->priv->modem_3gpp_operator_code = g_value_dup_string (value);
break;
case PROP_3GPP_OPERATOR_NAME:
g_free (self->priv->modem_3gpp_operator_name);
self->priv->modem_3gpp_operator_name = g_value_dup_string (value);
break;
case PROP_3GPP_SUBSCRIPTION_STATE:
self->priv->modem_3gpp_subscription_state = g_value_get_enum (value);
break;
case PROP_CDMA_CDMA1X_REGISTRATION_STATE:
self->priv->modem_cdma_cdma1x_registration_state = g_value_get_enum (value);
break;
case PROP_CDMA_EVDO_REGISTRATION_STATE:
self->priv->modem_cdma_evdo_registration_state = g_value_get_enum (value);
break;
case PROP_CDMA_SID:
self->priv->modem_cdma_sid = g_value_get_uint (value);
break;
case PROP_CDMA_NID:
self->priv->modem_cdma_nid = g_value_get_uint (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MMSimpleStatus *self = MM_SIMPLE_STATUS (object);
switch (prop_id) {
case PROP_STATE:
g_value_set_enum (value, self->priv->state);
break;
case PROP_SIGNAL_QUALITY:
g_value_set_variant (value, self->priv->signal_quality);
break;
case PROP_CURRENT_BANDS:
g_value_set_variant (value, self->priv->current_bands);
break;
case PROP_ACCESS_TECHNOLOGIES:
g_value_set_flags (value, self->priv->access_technologies);
break;
case PROP_3GPP_REGISTRATION_STATE:
g_value_set_enum (value, self->priv->modem_3gpp_registration_state);
break;
case PROP_3GPP_OPERATOR_CODE:
g_value_set_string (value, self->priv->modem_3gpp_operator_code);
break;
case PROP_3GPP_OPERATOR_NAME:
g_value_set_string (value, self->priv->modem_3gpp_operator_name);
break;
case PROP_3GPP_SUBSCRIPTION_STATE:
g_value_set_enum (value, self->priv->modem_3gpp_subscription_state);
break;
case PROP_CDMA_CDMA1X_REGISTRATION_STATE:
g_value_set_enum (value, self->priv->modem_cdma_cdma1x_registration_state);
break;
case PROP_CDMA_EVDO_REGISTRATION_STATE:
g_value_set_enum (value, self->priv->modem_cdma_evdo_registration_state);
break;
case PROP_CDMA_SID:
g_value_set_uint (value, self->priv->modem_cdma_sid);
break;
case PROP_CDMA_NID:
g_value_set_uint (value, self->priv->modem_cdma_nid);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
mm_simple_status_init (MMSimpleStatus *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self),
MM_TYPE_SIMPLE_STATUS,
MMSimpleStatusPrivate);
/* Some defaults */
self->priv->state = MM_MODEM_STATE_UNKNOWN;
self->priv->access_technologies = MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN;
self->priv->modem_3gpp_registration_state = MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN;
self->priv->modem_3gpp_subscription_state = MM_MODEM_3GPP_SUBSCRIPTION_STATE_UNKNOWN;
self->priv->current_bands = g_variant_ref_sink (mm_common_build_bands_unknown ());
self->priv->signal_quality = g_variant_ref_sink (g_variant_new ("(ub)", 0, 0));
self->priv->modem_cdma_cdma1x_registration_state = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN;
self->priv->modem_cdma_evdo_registration_state = MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN;
self->priv->modem_cdma_sid = MM_MODEM_CDMA_SID_UNKNOWN;
self->priv->modem_cdma_nid = MM_MODEM_CDMA_NID_UNKNOWN;
}
static void
finalize (GObject *object)
{
MMSimpleStatus *self = MM_SIMPLE_STATUS (object);
g_variant_unref (self->priv->signal_quality);
g_variant_unref (self->priv->current_bands);
if (self->priv->current_bands_array)
g_array_unref (self->priv->current_bands_array);
g_free (self->priv->modem_3gpp_operator_code);
g_free (self->priv->modem_3gpp_operator_name);
G_OBJECT_CLASS (mm_simple_status_parent_class)->finalize (object);
}
static void
mm_simple_status_class_init (MMSimpleStatusClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMSimpleStatusPrivate));
/* Virtual methods */
object_class->set_property = set_property;
object_class->get_property = get_property;
object_class->finalize = finalize;
properties[PROP_STATE] =
g_param_spec_enum (MM_SIMPLE_PROPERTY_STATE,
"State",
"State of the modem",
MM_TYPE_MODEM_STATE,
MM_MODEM_STATE_UNKNOWN,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_STATE, properties[PROP_STATE]);
properties[PROP_SIGNAL_QUALITY] =
g_param_spec_variant (MM_SIMPLE_PROPERTY_SIGNAL_QUALITY,
"Signal quality",
"Signal quality reported by the modem",
G_VARIANT_TYPE ("(ub)"),
NULL,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_SIGNAL_QUALITY, properties[PROP_SIGNAL_QUALITY]);
properties[PROP_CURRENT_BANDS] =
g_param_spec_variant (MM_SIMPLE_PROPERTY_CURRENT_BANDS,
"Current Bands",
"Frequency bands used by the modem",
G_VARIANT_TYPE ("au"),
NULL,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CURRENT_BANDS, properties[PROP_CURRENT_BANDS]);
properties[PROP_ACCESS_TECHNOLOGIES] =
g_param_spec_flags (MM_SIMPLE_PROPERTY_ACCESS_TECHNOLOGIES,
"Access Technologies",
"Access technologies used by the modem",
MM_TYPE_MODEM_ACCESS_TECHNOLOGY,
MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_ACCESS_TECHNOLOGIES, properties[PROP_ACCESS_TECHNOLOGIES]);
properties[PROP_3GPP_REGISTRATION_STATE] =
g_param_spec_enum (MM_SIMPLE_PROPERTY_3GPP_REGISTRATION_STATE,
"3GPP registration state",
"Registration state in the 3GPP network",
MM_TYPE_MODEM_3GPP_REGISTRATION_STATE,
MM_MODEM_3GPP_REGISTRATION_STATE_UNKNOWN,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_3GPP_REGISTRATION_STATE, properties[PROP_3GPP_REGISTRATION_STATE]);
properties[PROP_3GPP_OPERATOR_CODE] =
g_param_spec_string (MM_SIMPLE_PROPERTY_3GPP_OPERATOR_CODE,
"3GPP operator code",
"Code of the current operator in the 3GPP network",
NULL,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_3GPP_OPERATOR_CODE, properties[PROP_3GPP_OPERATOR_CODE]);
properties[PROP_3GPP_OPERATOR_NAME] =
g_param_spec_string (MM_SIMPLE_PROPERTY_3GPP_OPERATOR_NAME,
"3GPP operator name",
"Name of the current operator in the 3GPP network",
NULL,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_3GPP_OPERATOR_NAME, properties[PROP_3GPP_OPERATOR_NAME]);
properties[PROP_3GPP_SUBSCRIPTION_STATE] =
g_param_spec_enum (MM_SIMPLE_PROPERTY_3GPP_SUBSCRIPTION_STATE,
"3GPP subscription state",
"Subscription state of the account",
MM_TYPE_MODEM_3GPP_SUBSCRIPTION_STATE,
MM_MODEM_3GPP_SUBSCRIPTION_STATE_UNKNOWN,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_3GPP_SUBSCRIPTION_STATE, properties[PROP_3GPP_SUBSCRIPTION_STATE]);
properties[PROP_CDMA_CDMA1X_REGISTRATION_STATE] =
g_param_spec_enum (MM_SIMPLE_PROPERTY_CDMA_CDMA1X_REGISTRATION_STATE,
"CDMA1x registration state",
"Registration state in the CDMA1x network",
MM_TYPE_MODEM_CDMA_REGISTRATION_STATE,
MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CDMA_CDMA1X_REGISTRATION_STATE, properties[PROP_CDMA_CDMA1X_REGISTRATION_STATE]);
properties[PROP_CDMA_EVDO_REGISTRATION_STATE] =
g_param_spec_enum (MM_SIMPLE_PROPERTY_CDMA_EVDO_REGISTRATION_STATE,
"EV-DO registration state",
"Registration state in the EV-DO network",
MM_TYPE_MODEM_CDMA_REGISTRATION_STATE,
MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CDMA_EVDO_REGISTRATION_STATE, properties[PROP_CDMA_EVDO_REGISTRATION_STATE]);
properties[PROP_CDMA_SID] =
g_param_spec_uint (MM_SIMPLE_PROPERTY_CDMA_SID,
"CDMA1x SID",
"System Identifier of the serving CDMA1x network",
0,
MM_MODEM_CDMA_SID_UNKNOWN,
MM_MODEM_CDMA_SID_UNKNOWN,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CDMA_SID, properties[PROP_CDMA_SID]);
properties[PROP_CDMA_NID] =
g_param_spec_uint (MM_SIMPLE_PROPERTY_CDMA_NID,
"CDMA1x NID",
"Network Identifier of the serving CDMA1x network",
0,
MM_MODEM_CDMA_NID_UNKNOWN,
MM_MODEM_CDMA_NID_UNKNOWN,
G_PARAM_READWRITE);
g_object_class_install_property (object_class, PROP_CDMA_NID, properties[PROP_CDMA_NID]);
}
|