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-client.h"
|
||||||
#include "nm-device.h"
|
#include "nm-device.h"
|
||||||
#include "nm-device-ethernet.h"
|
#include "nm-device-ethernet.h"
|
||||||
|
#include "nm-device-modem.h"
|
||||||
#include "nm-device-wifi.h"
|
#include "nm-device-wifi.h"
|
||||||
#include "nm-utils.h"
|
#include "nm-utils.h"
|
||||||
#include "nm-active-connection.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 */
|
/* do we have to get additonal data from ModemManager */
|
||||||
type = nm_device_get_device_type (device);
|
type = nm_device_get_device_type (device);
|
||||||
if (type == NM_DEVICE_TYPE_GSM ||
|
if (type == NM_DEVICE_TYPE_MODEM) {
|
||||||
type == NM_DEVICE_TYPE_CDMA) {
|
|
||||||
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
|
g_dbus_proxy_new_for_bus (G_BUS_TYPE_SYSTEM,
|
||||||
G_DBUS_PROXY_FLAGS_NONE,
|
G_DBUS_PROXY_FLAGS_NONE,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -400,15 +400,15 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
|
||||||
|
|
||||||
/* make title a bit bigger */
|
/* make title a bit bigger */
|
||||||
title = g_strdup_printf ("<span size=\"large\">%s</span>",
|
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 (gtk_builder_get_object (priv->builder,
|
||||||
"liststore_devices"));
|
"liststore_devices"));
|
||||||
gtk_list_store_append (liststore_devices, &iter);
|
gtk_list_store_append (liststore_devices, &iter);
|
||||||
gtk_list_store_set (liststore_devices,
|
gtk_list_store_set (liststore_devices,
|
||||||
&iter,
|
&iter,
|
||||||
PANEL_DEVICES_COLUMN_ICON, panel_device_type_to_icon_name (nm_device_get_device_type (device)),
|
PANEL_DEVICES_COLUMN_ICON, panel_device_to_icon_name (device),
|
||||||
PANEL_DEVICES_COLUMN_SORT, panel_device_type_to_sortable_string (nm_device_get_device_type (device)),
|
PANEL_DEVICES_COLUMN_SORT, panel_device_to_sortable_string (device),
|
||||||
PANEL_DEVICES_COLUMN_TITLE, title,
|
PANEL_DEVICES_COLUMN_TITLE, title,
|
||||||
PANEL_DEVICES_COLUMN_ID, nm_device_get_udi (device),
|
PANEL_DEVICES_COLUMN_ID, nm_device_get_udi (device),
|
||||||
PANEL_DEVICES_COLUMN_TOOLTIP, NULL,
|
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,
|
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
||||||
"image_device"));
|
"image_device"));
|
||||||
gtk_image_set_from_icon_name (GTK_IMAGE (widget),
|
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);
|
GTK_ICON_SIZE_DIALOG);
|
||||||
|
|
||||||
/* set device kind */
|
/* set device kind */
|
||||||
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
widget = GTK_WIDGET (gtk_builder_get_object (priv->builder,
|
||||||
"label_device"));
|
"label_device"));
|
||||||
gtk_label_set_label (GTK_LABEL (widget),
|
gtk_label_set_label (GTK_LABEL (widget),
|
||||||
panel_device_type_to_localized_string (type));
|
panel_device_to_localized_string (device));
|
||||||
|
|
||||||
|
|
||||||
/* set device state */
|
/* set device state */
|
||||||
|
@ -754,10 +754,13 @@ nm_device_refresh_item_ui (CcNetworkPanel *panel, NMDevice *device)
|
||||||
} else if (type == NM_DEVICE_TYPE_WIFI) {
|
} else if (type == NM_DEVICE_TYPE_WIFI) {
|
||||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 1);
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 1);
|
||||||
sub_pane = "wireless";
|
sub_pane = "wireless";
|
||||||
} else if (type == NM_DEVICE_TYPE_GSM ||
|
} else if (type == NM_DEVICE_TYPE_MODEM) {
|
||||||
type == NM_DEVICE_TYPE_CDMA) {
|
NMDeviceModemCapabilities caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||||
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 4);
|
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||||
sub_pane = "mobilebb";
|
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||||
|
gtk_notebook_set_current_page (GTK_NOTEBOOK (widget), 4);
|
||||||
|
sub_pane = "mobilebb";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (sub_pane == NULL)
|
if (sub_pane == NULL)
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -824,30 +827,33 @@ nm_device_refresh_item_ui (CcNetworkPanel *panel, NMDevice *device)
|
||||||
active_ap);
|
active_ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (type == NM_DEVICE_TYPE_GSM ||
|
} else if (type == NM_DEVICE_TYPE_MODEM) {
|
||||||
type == NM_DEVICE_TYPE_CDMA) {
|
NMDeviceModemCapabilities caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||||
|
|
||||||
/* IMEI */
|
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||||
str = g_object_get_data (G_OBJECT (device),
|
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||||
"ControlCenter::EquipmentIdentifier");
|
/* IMEI */
|
||||||
panel_set_widget_data (panel,
|
str = g_object_get_data (G_OBJECT (device),
|
||||||
sub_pane,
|
"ControlCenter::EquipmentIdentifier");
|
||||||
"imei",
|
panel_set_widget_data (panel,
|
||||||
str);
|
sub_pane,
|
||||||
|
"imei",
|
||||||
|
str);
|
||||||
|
|
||||||
/* operator name */
|
/* operator name */
|
||||||
str = g_object_get_data (G_OBJECT (device),
|
str = g_object_get_data (G_OBJECT (device),
|
||||||
"ControlCenter::OperatorName");
|
"ControlCenter::OperatorName");
|
||||||
panel_set_widget_data (panel,
|
panel_set_widget_data (panel,
|
||||||
sub_pane,
|
sub_pane,
|
||||||
"provider",
|
"provider",
|
||||||
str);
|
str);
|
||||||
|
|
||||||
/* device speed */
|
/* device speed */
|
||||||
panel_set_widget_data (panel,
|
panel_set_widget_data (panel,
|
||||||
sub_pane,
|
sub_pane,
|
||||||
"speed",
|
"speed",
|
||||||
NULL);
|
NULL);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get IP4 parameters */
|
/* get IP4 parameters */
|
||||||
|
|
|
@ -26,25 +26,32 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
#include "panel-common.h"
|
#include "panel-common.h"
|
||||||
|
#include "nm-device-modem.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* panel_device_type_to_icon_name:
|
* panel_device_to_icon_name:
|
||||||
**/
|
**/
|
||||||
const gchar *
|
const gchar *
|
||||||
panel_device_type_to_icon_name (NMDeviceType type)
|
panel_device_to_icon_name (NMDevice *device)
|
||||||
{
|
{
|
||||||
const gchar *value = NULL;
|
const gchar *value = NULL;
|
||||||
switch (type) {
|
NMDeviceModemCapabilities caps;
|
||||||
|
switch (nm_device_get_device_type (device)) {
|
||||||
case NM_DEVICE_TYPE_ETHERNET:
|
case NM_DEVICE_TYPE_ETHERNET:
|
||||||
value = "network-wired";
|
value = "network-wired";
|
||||||
break;
|
break;
|
||||||
case NM_DEVICE_TYPE_WIFI:
|
case NM_DEVICE_TYPE_WIFI:
|
||||||
case NM_DEVICE_TYPE_GSM:
|
|
||||||
case NM_DEVICE_TYPE_CDMA:
|
|
||||||
case NM_DEVICE_TYPE_BT:
|
case NM_DEVICE_TYPE_BT:
|
||||||
case NM_DEVICE_TYPE_OLPC_MESH:
|
case NM_DEVICE_TYPE_OLPC_MESH:
|
||||||
value = "network-wireless";
|
value = "network-wireless";
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
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 *
|
const gchar *
|
||||||
panel_device_type_to_localized_string (NMDeviceType type)
|
panel_device_to_localized_string (NMDevice *device)
|
||||||
{
|
{
|
||||||
const gchar *value = NULL;
|
const gchar *value = NULL;
|
||||||
switch (type) {
|
NMDeviceModemCapabilities caps;
|
||||||
|
switch (nm_device_get_device_type (device)) {
|
||||||
case NM_DEVICE_TYPE_UNKNOWN:
|
case NM_DEVICE_TYPE_UNKNOWN:
|
||||||
/* TRANSLATORS: device type */
|
/* TRANSLATORS: device type */
|
||||||
value = _("Unknown");
|
value = _("Unknown");
|
||||||
|
@ -71,10 +79,13 @@ panel_device_type_to_localized_string (NMDeviceType type)
|
||||||
/* TRANSLATORS: device type */
|
/* TRANSLATORS: device type */
|
||||||
value = _("Wireless");
|
value = _("Wireless");
|
||||||
break;
|
break;
|
||||||
case NM_DEVICE_TYPE_GSM:
|
case NM_DEVICE_TYPE_MODEM:
|
||||||
case NM_DEVICE_TYPE_CDMA:
|
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||||
/* TRANSLATORS: device type */
|
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||||
value = _("Mobile broadband");
|
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||||
|
/* TRANSLATORS: device type */
|
||||||
|
value = _("Mobile broadband");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NM_DEVICE_TYPE_BT:
|
case NM_DEVICE_TYPE_BT:
|
||||||
/* TRANSLATORS: device type */
|
/* 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.
|
* Try to return order of approximate connection speed.
|
||||||
**/
|
**/
|
||||||
const gchar *
|
const gchar *
|
||||||
panel_device_type_to_sortable_string (NMDeviceType type)
|
panel_device_to_sortable_string (NMDevice *device)
|
||||||
{
|
{
|
||||||
const gchar *value = NULL;
|
const gchar *value = NULL;
|
||||||
switch (type) {
|
NMDeviceModemCapabilities caps;
|
||||||
|
switch (nm_device_get_device_type (device)) {
|
||||||
case NM_DEVICE_TYPE_ETHERNET:
|
case NM_DEVICE_TYPE_ETHERNET:
|
||||||
value = "1";
|
value = "1";
|
||||||
break;
|
break;
|
||||||
case NM_DEVICE_TYPE_WIFI:
|
case NM_DEVICE_TYPE_WIFI:
|
||||||
value = "2";
|
value = "2";
|
||||||
break;
|
break;
|
||||||
case NM_DEVICE_TYPE_GSM:
|
case NM_DEVICE_TYPE_MODEM:
|
||||||
case NM_DEVICE_TYPE_CDMA:
|
caps = nm_device_modem_get_current_capabilities (NM_DEVICE_MODEM (device));
|
||||||
value = "3";
|
if ((caps & NM_DEVICE_MODEM_CAPABILITY_GSM_UMTS) ||
|
||||||
|
(caps & NM_DEVICE_MODEM_CAPABILITY_CDMA_EVDO)) {
|
||||||
|
value = "3";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case NM_DEVICE_TYPE_BT:
|
case NM_DEVICE_TYPE_BT:
|
||||||
value = "4";
|
value = "4";
|
||||||
|
|
|
@ -24,12 +24,13 @@
|
||||||
|
|
||||||
#include <glib-object.h>
|
#include <glib-object.h>
|
||||||
#include <NetworkManager.h>
|
#include <NetworkManager.h>
|
||||||
|
#include <nm-device.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
const gchar *panel_device_type_to_icon_name (NMDeviceType type);
|
const gchar *panel_device_to_icon_name (NMDevice *device);
|
||||||
const gchar *panel_device_type_to_localized_string (NMDeviceType type);
|
const gchar *panel_device_to_localized_string (NMDevice *device);
|
||||||
const gchar *panel_device_type_to_sortable_string (NMDeviceType type);
|
const gchar *panel_device_to_sortable_string (NMDevice *device);
|
||||||
const gchar *panel_ap_mode_to_localized_string (NM80211Mode mode);
|
const gchar *panel_ap_mode_to_localized_string (NM80211Mode mode);
|
||||||
const gchar *panel_device_state_to_localized_string (NMDeviceState type);
|
const gchar *panel_device_state_to_localized_string (NMDeviceState type);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue