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
|
/* -*- 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) 2008 - 2009 Novell, Inc.
* Copyright (C) 2009 Red Hat, Inc.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "mm-modem-base.h"
#include "mm-modem.h"
#include "mm-at-serial-port.h"
#include "mm-qcdm-serial-port.h"
#include "mm-errors.h"
#include "mm-options.h"
#include "mm-properties-changed-signal.h"
#include "mm-callback-info.h"
#include "mm-modem-helpers.h"
static void modem_init (MMModem *modem_class);
G_DEFINE_TYPE_EXTENDED (MMModemBase, mm_modem_base,
G_TYPE_OBJECT,
G_TYPE_FLAG_VALUE_ABSTRACT,
G_IMPLEMENT_INTERFACE (MM_TYPE_MODEM, modem_init))
#define MM_MODEM_BASE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), MM_TYPE_MODEM_BASE, MMModemBasePrivate))
typedef struct {
char *driver;
char *plugin;
char *device;
char *equipment_ident;
char *unlock_required;
guint32 unlock_retries;
guint32 ip_method;
gboolean valid;
MMModemState state;
char *manf;
char *model;
char *revision;
MMAuthProvider *authp;
GHashTable *ports;
} MMModemBasePrivate;
static char *
get_hash_key (const char *subsys, const char *name)
{
return g_strdup_printf ("%s%s", subsys, name);
}
MMPort *
mm_modem_base_get_port (MMModemBase *self,
const char *subsys,
const char *name)
{
MMPort *port;
char *key;
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (subsys != NULL, NULL);
g_return_val_if_fail (!strcmp (subsys, "net") || !strcmp (subsys, "tty"), NULL);
key = get_hash_key (subsys, name);
port = g_hash_table_lookup (MM_MODEM_BASE_GET_PRIVATE (self)->ports, key);
g_free (key);
return port;
}
static void
find_primary (gpointer key, gpointer data, gpointer user_data)
{
MMPort **found = user_data;
MMPort *port = MM_PORT (data);
if (!*found && (mm_port_get_port_type (port) == MM_PORT_TYPE_PRIMARY))
*found = port;
}
MMPort *
mm_modem_base_add_port (MMModemBase *self,
const char *subsys,
const char *name,
MMPortType ptype)
{
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self);
MMPort *port = NULL;
char *key, *device;
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
g_return_val_if_fail (subsys != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
g_return_val_if_fail (ptype != MM_PORT_TYPE_UNKNOWN, NULL);
g_return_val_if_fail (!strcmp (subsys, "net") || !strcmp (subsys, "tty"), NULL);
key = get_hash_key (subsys, name);
port = g_hash_table_lookup (priv->ports, key);
g_free (key);
g_return_val_if_fail (port == NULL, NULL);
if (ptype == MM_PORT_TYPE_PRIMARY) {
g_hash_table_foreach (priv->ports, find_primary, &port);
g_return_val_if_fail (port == NULL, FALSE);
}
if (!strcmp (subsys, "tty")) {
if (ptype == MM_PORT_TYPE_QCDM)
port = MM_PORT (mm_qcdm_serial_port_new (name, ptype));
else
port = MM_PORT (mm_at_serial_port_new (name, ptype));
} else if (!strcmp (subsys, "net")) {
port = MM_PORT (g_object_new (MM_TYPE_PORT,
MM_PORT_DEVICE, name,
MM_PORT_SUBSYS, MM_PORT_SUBSYS_NET,
MM_PORT_TYPE, ptype,
NULL));
}
if (!port)
return NULL;
if (mm_options_debug ()) {
device = mm_modem_get_device (MM_MODEM (self));
g_message ("(%s) type %s claimed by %s",
name,
mm_port_type_to_name (ptype),
device);
g_free (device);
}
key = get_hash_key (subsys, name);
g_hash_table_insert (priv->ports, key, port);
return port;
}
gboolean
mm_modem_base_remove_port (MMModemBase *self, MMPort *port)
{
g_return_val_if_fail (MM_IS_MODEM_BASE (self), FALSE);
g_return_val_if_fail (port != NULL, FALSE);
return g_hash_table_remove (MM_MODEM_BASE_GET_PRIVATE (self)->ports, port);
}
void
mm_modem_base_set_valid (MMModemBase *self, gboolean new_valid)
{
MMModemBasePrivate *priv;
g_return_if_fail (MM_IS_MODEM_BASE (self));
priv = MM_MODEM_BASE_GET_PRIVATE (self);
if (priv->valid != new_valid) {
priv->valid = new_valid;
/* Modem starts off in disabled state, and jumps to disabled when
* it's no longer valid.
*/
mm_modem_set_state (MM_MODEM (self),
MM_MODEM_STATE_DISABLED,
MM_MODEM_STATE_REASON_NONE);
g_object_notify (G_OBJECT (self), MM_MODEM_VALID);
}
}
gboolean
mm_modem_base_get_valid (MMModemBase *self)
{
g_return_val_if_fail (MM_IS_MODEM_BASE (self), FALSE);
return MM_MODEM_BASE_GET_PRIVATE (self)->valid;
}
const char *
mm_modem_base_get_equipment_identifier (MMModemBase *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
return MM_MODEM_BASE_GET_PRIVATE (self)->equipment_ident;
}
void
mm_modem_base_set_equipment_identifier (MMModemBase *self, const char *ident)
{
MMModemBasePrivate *priv;
const char *dbus_path;
g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_MODEM_BASE (self));
priv = MM_MODEM_BASE_GET_PRIVATE (self);
/* Only do something if the value changes */
if ( (priv->equipment_ident == ident)
|| (priv->equipment_ident && ident && !strcmp (priv->equipment_ident, ident)))
return;
g_free (priv->equipment_ident);
priv->equipment_ident = g_strdup (ident);
dbus_path = (const char *) g_object_get_data (G_OBJECT (self), DBUS_PATH_TAG);
if (dbus_path) {
if (priv->equipment_ident)
g_message ("Modem %s: Equipment identifier set (%s)", dbus_path, priv->equipment_ident);
else
g_message ("Modem %s: Equipment identifier not set", dbus_path);
}
g_object_notify (G_OBJECT (self), MM_MODEM_EQUIPMENT_IDENTIFIER);
}
const char *
mm_modem_base_get_unlock_required (MMModemBase *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
return MM_MODEM_BASE_GET_PRIVATE (self)->unlock_required;
}
void
mm_modem_base_set_unlock_required (MMModemBase *self, const char *unlock_required)
{
MMModemBasePrivate *priv;
const char *dbus_path;
g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_MODEM_BASE (self));
priv = MM_MODEM_BASE_GET_PRIVATE (self);
/* Only do something if the value changes */
if ( (priv->unlock_required == unlock_required)
|| ( priv->unlock_required
&& unlock_required
&& !strcmp (priv->unlock_required, unlock_required)))
return;
g_free (priv->unlock_required);
priv->unlock_required = g_strdup (unlock_required);
dbus_path = (const char *) g_object_get_data (G_OBJECT (self), DBUS_PATH_TAG);
if (dbus_path) {
if (priv->unlock_required)
g_message ("Modem %s: unlock required (%s)", dbus_path, priv->unlock_required);
else
g_message ("Modem %s: unlock no longer required", dbus_path);
}
g_object_notify (G_OBJECT (self), MM_MODEM_UNLOCK_REQUIRED);
}
guint32
mm_modem_base_get_unlock_retries (MMModemBase *self)
{
g_return_val_if_fail (self != NULL, 0);
g_return_val_if_fail (MM_IS_MODEM_BASE (self), 0);
return MM_MODEM_BASE_GET_PRIVATE (self)->unlock_retries;
}
void
mm_modem_base_set_unlock_retries (MMModemBase *self, guint unlock_retries)
{
MMModemBasePrivate *priv;
const char *dbus_path;
g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_MODEM_BASE (self));
priv = MM_MODEM_BASE_GET_PRIVATE (self);
/* Only do something if the value changes */
if (priv->unlock_retries == unlock_retries)
return;
priv->unlock_retries = unlock_retries;
dbus_path = (const char *) g_object_get_data (G_OBJECT (self), DBUS_PATH_TAG);
if (dbus_path) {
g_message ("Modem %s: # unlock retries for %s is %d",
dbus_path, priv->unlock_required, priv->unlock_retries);
}
g_object_notify (G_OBJECT (self), MM_MODEM_UNLOCK_RETRIES);
}
const char *
mm_modem_base_get_manf (MMModemBase *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
return MM_MODEM_BASE_GET_PRIVATE (self)->manf;
}
void
mm_modem_base_set_manf (MMModemBase *self, const char *manf)
{
MMModemBasePrivate *priv;
g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_MODEM_BASE (self));
priv = MM_MODEM_BASE_GET_PRIVATE (self);
g_free (priv->manf);
priv->manf = g_strdup (manf);
}
const char *
mm_modem_base_get_model (MMModemBase *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
return MM_MODEM_BASE_GET_PRIVATE (self)->model;
}
void
mm_modem_base_set_model (MMModemBase *self, const char *model)
{
MMModemBasePrivate *priv;
g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_MODEM_BASE (self));
priv = MM_MODEM_BASE_GET_PRIVATE (self);
g_free (priv->model);
priv->model = g_strdup (model);
}
const char *
mm_modem_base_get_revision (MMModemBase *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
return MM_MODEM_BASE_GET_PRIVATE (self)->revision;
}
void
mm_modem_base_set_revision (MMModemBase *self, const char *revision)
{
MMModemBasePrivate *priv;
g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_MODEM_BASE (self));
priv = MM_MODEM_BASE_GET_PRIVATE (self);
g_free (priv->revision);
priv->revision = g_strdup (revision);
}
/*************************************************************************/
static void
card_info_simple_invoke (MMCallbackInfo *info)
{
MMModemBase *self = MM_MODEM_BASE (info->modem);
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self);
MMModemInfoFn callback = (MMModemInfoFn) info->callback;
callback (info->modem, priv->manf, priv->model, priv->revision, info->error, info->user_data);
}
static void
card_info_cache_invoke (MMCallbackInfo *info)
{
MMModemBase *self = MM_MODEM_BASE (info->modem);
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self);
MMModemInfoFn callback = (MMModemInfoFn) info->callback;
const char *manf, *cmanf, *model, *cmodel, *rev, *crev;
manf = mm_callback_info_get_data (info, "card-info-manf");
cmanf = mm_callback_info_get_data (info, "card-info-c-manf");
model = mm_callback_info_get_data (info, "card-info-model");
cmodel = mm_callback_info_get_data (info, "card-info-c-model");
rev = mm_callback_info_get_data (info, "card-info-revision");
crev = mm_callback_info_get_data (info, "card-info-c-revision");
/* Prefer the 'C' responses over the plain responses */
g_free (priv->manf);
priv->manf = g_strdup (cmanf ? cmanf : manf);
g_free (priv->model);
priv->model = g_strdup (cmodel ? cmodel : model);
g_free (priv->revision);
priv->revision = g_strdup (crev ? crev : rev);
callback (info->modem, priv->manf, priv->model, priv->revision, info->error, info->user_data);
}
static void
info_item_done (MMCallbackInfo *info,
GString *response,
GError *error,
const char *tag,
const char *desc)
{
const char *p;
if (!error) {
p = mm_strip_tag (response->str, tag);
mm_callback_info_set_data (info, desc, strlen (p) ? g_strdup (p) : NULL, g_free);
}
mm_callback_info_chain_complete_one (info);
}
#define GET_INFO_RESP_FN(func_name, tag, desc) \
static void \
func_name (MMAtSerialPort *port, \
GString *response, \
GError *error, \
gpointer user_data) \
{ \
info_item_done ((MMCallbackInfo *) user_data, response, error, tag , desc ); \
}
GET_INFO_RESP_FN(get_revision_done, "+GMR:", "card-info-revision")
GET_INFO_RESP_FN(get_model_done, "+GMM:", "card-info-model")
GET_INFO_RESP_FN(get_manf_done, "+GMI:", "card-info-manf")
GET_INFO_RESP_FN(get_c_revision_done, "+CGMR:", "card-info-c-revision")
GET_INFO_RESP_FN(get_c_model_done, "+CGMM:", "card-info-c-model")
GET_INFO_RESP_FN(get_c_manf_done, "+CGMI:", "card-info-c-manf")
void
mm_modem_base_get_card_info (MMModemBase *self,
MMAtSerialPort *port,
GError *port_error,
MMModemInfoFn callback,
gpointer user_data)
{
MMModemBasePrivate *priv;
MMCallbackInfo *info;
MMModemState state;
gboolean cached = FALSE;
GError *error = port_error;
g_return_if_fail (self != NULL);
g_return_if_fail (MM_IS_MODEM_BASE (self));
g_return_if_fail (port != NULL);
g_return_if_fail (MM_IS_AT_SERIAL_PORT (port));
g_return_if_fail (callback != NULL);
priv = MM_MODEM_BASE_GET_PRIVATE (self);
/* Cached info and errors schedule the callback immediately and do
* not hit up the card for it's model information.
*/
if (priv->manf || priv->model || priv->revision)
cached = TRUE;
else {
state = mm_modem_get_state (MM_MODEM (self));
if (port_error)
error = g_error_copy (port_error);
else if (state < MM_MODEM_STATE_ENABLING) {
error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL,
"The modem is not enabled.");
}
}
/* If we have cached info or an error, don't hit up the card */
if (cached || error) {
info = mm_callback_info_new_full (MM_MODEM (self),
card_info_simple_invoke,
G_CALLBACK (callback),
user_data);
info->error = error;
mm_callback_info_schedule (info);
return;
}
/* Otherwise, ask the card */
info = mm_callback_info_new_full (MM_MODEM (self),
card_info_cache_invoke,
G_CALLBACK (callback),
user_data);
mm_callback_info_chain_start (info, 6);
mm_at_serial_port_queue_command_cached (port, "+GMI", 3, get_manf_done, info);
mm_at_serial_port_queue_command_cached (port, "+GMM", 3, get_model_done, info);
mm_at_serial_port_queue_command_cached (port, "+GMR", 3, get_revision_done, info);
mm_at_serial_port_queue_command_cached (port, "+CGMI", 3, get_c_manf_done, info);
mm_at_serial_port_queue_command_cached (port, "+CGMM", 3, get_c_model_done, info);
mm_at_serial_port_queue_command_cached (port, "+CGMR", 3, get_c_revision_done, info);
}
/*****************************************************************************/
static gboolean
modem_auth_request (MMModem *modem,
const char *authorization,
DBusGMethodInvocation *context,
MMAuthRequestCb callback,
gpointer callback_data,
GDestroyNotify notify,
GError **error)
{
MMModemBase *self = MM_MODEM_BASE (modem);
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self);
g_assert (priv->authp);
return !!mm_auth_provider_request_auth (priv->authp,
authorization,
G_OBJECT (self),
context,
callback,
callback_data,
notify,
error);
}
static gboolean
modem_auth_finish (MMModem *modem, MMAuthRequest *req, GError **error)
{
if (mm_auth_request_get_result (req) != MM_AUTH_RESULT_AUTHORIZED) {
g_set_error (error, MM_MODEM_ERROR, MM_MODEM_ERROR_AUTHORIZATION_REQUIRED,
"This request requires the '%s' authorization",
mm_auth_request_get_authorization (req));
return FALSE;
}
return TRUE;
}
/*****************************************************************************/
static void
mm_modem_base_init (MMModemBase *self)
{
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self);
priv->authp = mm_auth_provider_get ();
priv->ports = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
mm_properties_changed_signal_register_property (G_OBJECT (self),
MM_MODEM_ENABLED,
MM_MODEM_DBUS_INTERFACE);
mm_properties_changed_signal_register_property (G_OBJECT (self),
MM_MODEM_EQUIPMENT_IDENTIFIER,
MM_MODEM_DBUS_INTERFACE);
mm_properties_changed_signal_register_property (G_OBJECT (self),
MM_MODEM_UNLOCK_REQUIRED,
MM_MODEM_DBUS_INTERFACE);
mm_properties_changed_signal_register_property (G_OBJECT (self),
MM_MODEM_UNLOCK_RETRIES,
MM_MODEM_DBUS_INTERFACE);
}
static void
modem_init (MMModem *modem_class)
{
modem_class->auth_request = modem_auth_request;
modem_class->auth_finish = modem_auth_finish;
}
static gboolean
is_enabled (MMModemState state)
{
return (state >= MM_MODEM_STATE_ENABLED);
}
static void
set_property (GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec)
{
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (object);
gboolean old_enabled;
switch (prop_id) {
case MM_MODEM_PROP_STATE:
/* Ensure we update the 'enabled' property when the state changes */
old_enabled = is_enabled (priv->state);
priv->state = g_value_get_uint (value);
if (old_enabled != is_enabled (priv->state))
g_object_notify (object, MM_MODEM_ENABLED);
break;
case MM_MODEM_PROP_DRIVER:
/* Construct only */
priv->driver = g_value_dup_string (value);
break;
case MM_MODEM_PROP_PLUGIN:
/* Construct only */
priv->plugin = g_value_dup_string (value);
break;
case MM_MODEM_PROP_MASTER_DEVICE:
/* Construct only */
priv->device = g_value_dup_string (value);
break;
case MM_MODEM_PROP_IP_METHOD:
priv->ip_method = g_value_get_uint (value);
break;
case MM_MODEM_PROP_VALID:
case MM_MODEM_PROP_TYPE:
case MM_MODEM_PROP_ENABLED:
case MM_MODEM_PROP_EQUIPMENT_IDENTIFIER:
case MM_MODEM_PROP_UNLOCK_REQUIRED:
case MM_MODEM_PROP_UNLOCK_RETRIES:
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)
{
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (object);
switch (prop_id) {
case MM_MODEM_PROP_STATE:
g_value_set_uint (value, priv->state);
break;
case MM_MODEM_PROP_MASTER_DEVICE:
g_value_set_string (value, priv->device);
break;
case MM_MODEM_PROP_DATA_DEVICE:
g_value_set_string (value, NULL);
break;
case MM_MODEM_PROP_DRIVER:
g_value_set_string (value, priv->driver);
break;
case MM_MODEM_PROP_PLUGIN:
g_value_set_string (value, priv->plugin);
break;
case MM_MODEM_PROP_TYPE:
g_value_set_uint (value, MM_MODEM_TYPE_UNKNOWN);
break;
case MM_MODEM_PROP_IP_METHOD:
g_value_set_uint (value, priv->ip_method);
break;
case MM_MODEM_PROP_VALID:
g_value_set_boolean (value, priv->valid);
break;
case MM_MODEM_PROP_ENABLED:
g_value_set_boolean (value, is_enabled (priv->state));
break;
case MM_MODEM_PROP_EQUIPMENT_IDENTIFIER:
g_value_set_string (value, priv->equipment_ident);
break;
case MM_MODEM_PROP_UNLOCK_REQUIRED:
g_value_set_string (value, priv->unlock_required);
break;
case MM_MODEM_PROP_UNLOCK_RETRIES:
g_value_set_uint (value, priv->unlock_retries);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
finalize (GObject *object)
{
MMModemBase *self = MM_MODEM_BASE (object);
MMModemBasePrivate *priv = MM_MODEM_BASE_GET_PRIVATE (self);
mm_auth_provider_cancel_for_owner (priv->authp, object);
g_hash_table_destroy (priv->ports);
g_free (priv->driver);
g_free (priv->plugin);
g_free (priv->device);
g_free (priv->equipment_ident);
g_free (priv->unlock_required);
G_OBJECT_CLASS (mm_modem_base_parent_class)->finalize (object);
}
static void
mm_modem_base_class_init (MMModemBaseClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (object_class, sizeof (MMModemBasePrivate));
/* Virtual methods */
object_class->get_property = get_property;
object_class->set_property = set_property;
object_class->finalize = finalize;
g_object_class_override_property (object_class,
MM_MODEM_PROP_STATE,
MM_MODEM_STATE);
g_object_class_override_property (object_class,
MM_MODEM_PROP_MASTER_DEVICE,
MM_MODEM_MASTER_DEVICE);
g_object_class_override_property (object_class,
MM_MODEM_PROP_DATA_DEVICE,
MM_MODEM_DATA_DEVICE);
g_object_class_override_property (object_class,
MM_MODEM_PROP_DRIVER,
MM_MODEM_DRIVER);
g_object_class_override_property (object_class,
MM_MODEM_PROP_PLUGIN,
MM_MODEM_PLUGIN);
g_object_class_override_property (object_class,
MM_MODEM_PROP_TYPE,
MM_MODEM_TYPE);
g_object_class_override_property (object_class,
MM_MODEM_PROP_IP_METHOD,
MM_MODEM_IP_METHOD);
g_object_class_override_property (object_class,
MM_MODEM_PROP_VALID,
MM_MODEM_VALID);
g_object_class_override_property (object_class,
MM_MODEM_PROP_ENABLED,
MM_MODEM_ENABLED);
g_object_class_override_property (object_class,
MM_MODEM_PROP_EQUIPMENT_IDENTIFIER,
MM_MODEM_EQUIPMENT_IDENTIFIER);
g_object_class_override_property (object_class,
MM_MODEM_PROP_UNLOCK_REQUIRED,
MM_MODEM_UNLOCK_REQUIRED);
g_object_class_override_property (object_class,
MM_MODEM_PROP_UNLOCK_RETRIES,
MM_MODEM_UNLOCK_RETRIES);
mm_properties_changed_signal_new (object_class);
}
|