Use the NetworkManager modem capabilities API.
A recent change to the NetworkManager API combined the NM_DEVICE_TYPE_GSM and NM_DEVICE_TYPE_CDMA types as NM_DEVICE_TYPE_MODEM and provided an alternative API for accessing the modem device's capabilities (including GSM_UMTS and CDMA_EVDO). https://bugzilla.gnome.org/show_bug.cgi?id=643390 Signed-off-by: Richard Hughes <richard@hughsie.com>
This commit is contained in:
parent
4906b8cde8
commit
f658c8db0f
3 changed files with 75 additions and 53 deletions
|
@ -28,6 +28,7 @@
|
|||
#include "nm-client.h"
|
||||
#include "nm-device.h"
|
||||
#include "nm-device-ethernet.h"
|
||||
#include "nm-device-modem.h"
|
||||
#include "nm-device-wifi.h"
|
||||
#include "nm-utils.h"
|
||||
#include "nm-active-connection.h"
|
||||
|
@ -376,8 +377,7 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
|
|||
|
||||
/* do we have to get additonal data from ModemManager */
|
||||
type = nm_device_get_device_type (device);
|
||||
if (type == NM_DEVICE_TYPE_GSM ||
|
||||
type == NM_DEVICE_TYPE_CDMA) {
|
||||
if (type == NM_DEVICE_TYPE_MODEM) {
|
||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
|
||||
G_DBUS_PROXY_FLAGS_NONE,
|
||||
NULL,
|
||||
|
@ -400,15 +400,15 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
|
|||
|
||||
/* make title a bit bigger */
|
||||
title = g_strdup_printf ("<span size=\"large\">%s</span>",
|
||||
panel_device_type_to_localized_string (nm_device_get_device_type (device)));
|
||||
panel_device_to_localized_string (device));
|
||||
|
||||
liststore_devices = GTK_LIST_STORE (gtk_builder_get_object (priv->builder,
|
||||
"liststore_devices"));
|
||||
gtk_list_store_append (liststore_devices, &iter);
|
||||
gtk_list_store_set (liststore_devices,
|
||||
&iter,
|
||||
PANEL_DEVICES_COLUMN_ICON, panel_device_type_to_icon_name (nm_device_get_device_type (device)),
|
||||
PANEL_DEVICES_COLUMN_SORT, panel_device_type_to_sortable_string (nm_device_get_device_type (device)),
|
||||
PANEL_DEVICES_COLUMN_ICON, panel_device_to_icon_name (device),
|
||||
PANEL_DEVICES_COLUMN_SORT, panel_device_to_sortable_string (device),
|
||||
PANEL_DEVICES_COLUMN_TITLE, title,
|
||||
PANEL_DEVICES_COLUMN_ID, nm_device_get_udi (device),
|
||||
PANEL_DEVICES_COLUMN_TOOLTIP, NULL,
|
||||
|
@ -729,14 +729,14 @@ nm_device_refresh_item_ui (CcNetworkPanel *panel, NMDevice *device)
|
|||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
||||
"image_device"));
|
||||
gtk_image_set_from_icon_name (GTK_IMAGE (widget),
|
||||
panel_device_type_to_icon_name (type),
|
||||
panel_device_to_icon_name (device),
|
||||
GTK_ICON_SIZE_DIALOG);
|
||||
|
||||
/* set device kind */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
||||
"label_device"));
|
||||
gtk_label_set_label (GTK_LABEL (widget),
|
||||
panel_device_type_to_localized_string (type));
|
||||
panel_device_to_localized_string (device));
|
||||
|
||||
|
||||
/* set device state */
|
||||
|
@ -754,10 +754,13 @@ nm_device_refresh_item_ui (CcNetworkPanel *panel, NMDevice *device)
|
|||
} else if (type == NM_DEVICE_TYPE_WIFI) {
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 1);
|
||||
sub_pane = "wireless";
|
||||
} else if (type == NM_DEVICE_TYPE_GSM ||
|
||||
type == NM_DEVICE_TYPE_CDMA) {
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 4);
|
||||
sub_pane = "mobilebb";
|
||||
} else if (type == NM_DEVICE_TYPE_MODEM) {
|
||||
NMDeviceModemCapabilities caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 4);
|
||||
sub_pane = "mobilebb";
|
||||
}
|
||||
}
|
||||
if (sub_pane == NULL)
|
||||
goto out;
|
||||
|
@ -824,30 +827,33 @@ nm_device_refresh_item_ui (CcNetworkPanel *panel, NMDevice *device)
|
|||
active_ap);
|
||||
}
|
||||
|
||||
} else if (type == NM_DEVICE_TYPE_GSM ||
|
||||
type == NM_DEVICE_TYPE_CDMA) {
|
||||
} else if (type == NM_DEVICE_TYPE_MODEM) {
|
||||
NMDeviceModemCapabilities caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||
|
||||
/* IMEI */
|
||||
str = g_object_get_data (G_OBJECT (device),
|
||||
"ControlCenter::EquipmentIdentifier");
|
||||
panel_set_widget_data (panel,
|
||||
sub_pane,
|
||||
"imei",
|
||||
str);
|
||||
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||
/* IMEI */
|
||||
str = g_object_get_data (G_OBJECT (device),
|
||||
"ControlCenter::EquipmentIdentifier");
|
||||
panel_set_widget_data (panel,
|
||||
sub_pane,
|
||||
"imei",
|
||||
str);
|
||||
|
||||
/* operator name */
|
||||
str = g_object_get_data (G_OBJECT (device),
|
||||
"ControlCenter::OperatorName");
|
||||
panel_set_widget_data (panel,
|
||||
sub_pane,
|
||||
"provider",
|
||||
str);
|
||||
/* operator name */
|
||||
str = g_object_get_data (G_OBJECT (device),
|
||||
"ControlCenter::OperatorName");
|
||||
panel_set_widget_data (panel,
|
||||
sub_pane,
|
||||
"provider",
|
||||
str);
|
||||
|
||||
/* device speed */
|
||||
panel_set_widget_data (panel,
|
||||
sub_pane,
|
||||
"speed",
|
||||
NULL);
|
||||
/* device speed */
|
||||
panel_set_widget_data (panel,
|
||||
sub_pane,
|
||||
"speed",
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* get IP4 parameters */
|
||||
|
|
|
@ -26,25 +26,32 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include "panel-common.h"
|
||||
#include "nm-device-modem.h"
|
||||
|
||||
/**
|
||||
* panel_device_type_to_icon_name:
|
||||
* panel_device_to_icon_name:
|
||||
**/
|
||||
const gchar *
|
||||
panel_device_type_to_icon_name (NMDeviceType type)
|
||||
panel_device_to_icon_name (NMDevice *device)
|
||||
{
|
||||
const gchar *value = NULL;
|
||||
switch (type) {
|
||||
NMDeviceModemCapabilities caps;
|
||||
switch (nm_device_get_device_type (device)) {
|
||||
case NM_DEVICE_TYPE_ETHERNET:
|
||||
value = "network-wired";
|
||||
break;
|
||||
case NM_DEVICE_TYPE_WIFI:
|
||||
case NM_DEVICE_TYPE_GSM:
|
||||
case NM_DEVICE_TYPE_CDMA:
|
||||
case NM_DEVICE_TYPE_BT:
|
||||
case NM_DEVICE_TYPE_OLPC_MESH:
|
||||
value = "network-wireless";
|
||||
break;
|
||||
case NM_DEVICE_TYPE_MODEM:
|
||||
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||
value = "network-wireless";
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -52,13 +59,14 @@ panel_device_type_to_icon_name (NMDeviceType type)
|
|||
}
|
||||
|
||||
/**
|
||||
* panel_device_type_to_localized_string:
|
||||
* panel_device_to_localized_string:
|
||||
**/
|
||||
const gchar *
|
||||
panel_device_type_to_localized_string (NMDeviceType type)
|
||||
panel_device_to_localized_string (NMDevice *device)
|
||||
{
|
||||
const gchar *value = NULL;
|
||||
switch (type) {
|
||||
NMDeviceModemCapabilities caps;
|
||||
switch (nm_device_get_device_type (device)) {
|
||||
case NM_DEVICE_TYPE_UNKNOWN:
|
||||
/* TRANSLATORS: device type */
|
||||
value = _("Unknown");
|
||||
|
@ -71,10 +79,13 @@ panel_device_type_to_localized_string (NMDeviceType type)
|
|||
/* TRANSLATORS: device type */
|
||||
value = _("Wireless");
|
||||
break;
|
||||
case NM_DEVICE_TYPE_GSM:
|
||||
case NM_DEVICE_TYPE_CDMA:
|
||||
/* TRANSLATORS: device type */
|
||||
value = _("Mobile broadband");
|
||||
case NM_DEVICE_TYPE_MODEM:
|
||||
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||
/* TRANSLATORS: device type */
|
||||
value = _("Mobile broadband");
|
||||
}
|
||||
break;
|
||||
case NM_DEVICE_TYPE_BT:
|
||||
/* TRANSLATORS: device type */
|
||||
|
@ -91,24 +102,28 @@ panel_device_type_to_localized_string (NMDeviceType type)
|
|||
}
|
||||
|
||||
/**
|
||||
* panel_device_type_to_sortable_string:
|
||||
* panel_device_to_sortable_string:
|
||||
*
|
||||
* Try to return order of approximate connection speed.
|
||||
**/
|
||||
const gchar *
|
||||
panel_device_type_to_sortable_string (NMDeviceType type)
|
||||
panel_device_to_sortable_string (NMDevice *device)
|
||||
{
|
||||
const gchar *value = NULL;
|
||||
switch (type) {
|
||||
NMDeviceModemCapabilities caps;
|
||||
switch (nm_device_get_device_type (device)) {
|
||||
case NM_DEVICE_TYPE_ETHERNET:
|
||||
value = "1";
|
||||
break;
|
||||
case NM_DEVICE_TYPE_WIFI:
|
||||
value = "2";
|
||||
break;
|
||||
case NM_DEVICE_TYPE_GSM:
|
||||
case NM_DEVICE_TYPE_CDMA:
|
||||
value = "3";
|
||||
case NM_DEVICE_TYPE_MODEM:
|
||||
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||
value = "3";
|
||||
}
|
||||
break;
|
||||
case NM_DEVICE_TYPE_BT:
|
||||
value = "4";
|
||||
|
|
|
@ -24,12 +24,13 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
#include <NetworkManager.h>
|
||||
#include <nm-device.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
const gchar *panel_device_type_to_icon_name (NMDeviceType type);
|
||||
const gchar *panel_device_type_to_localized_string (NMDeviceType type);
|
||||
const gchar *panel_device_type_to_sortable_string (NMDeviceType type);
|
||||
const gchar *panel_device_to_icon_name (NMDevice *device);
|
||||
const gchar *panel_device_to_localized_string (NMDevice *device);
|
||||
const gchar *panel_device_to_sortable_string (NMDevice *device);
|
||||
const gchar *panel_ap_mode_to_localized_string (NM80211Mode mode);
|
||||
const gchar *panel_device_state_to_localized_string (NMDeviceState type);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue