From 6a68d79c0839c928e513b82035dc2953354aa94f Mon Sep 17 00:00:00 2001 From: Tambet Ingo Date: Thu, 9 Aug 2007 09:19:57 +0000 Subject: [PATCH] 2007-08-09 Tambet Ingo [Based on patch by Helmut Schaa ] * libnm-glib/nm-client.h: * libnm-glib/nm-object.h: * libnm-glib/nm-vpn-connection.h: * libnm-glib/nm-settings.h: * libnm-glib/nm-device.h: * libnm-glib/nm-ip4-config.h: * libnm-glib/nm-access-point.h: * libnm-glib/nm-device-802-3-ethernet.h: * libnm-util/nm-setting.h: * libnm-util/nm-connection.h: Add G_BEGIN_DECLS / G_END_DECLS to * support C++. * libnm-glib/nm-object.c (nm_object_get_byte_property): * Implement. * libnm-glib/nm-access-point.c: Strength has type char. * gnome/vpn-properties/Makefile.am: Remove * GNOME_DISABLE_DEPRECTATED for now to fix build. GnomeDruid is deprecated in recent libgnomeui. * introspection/nm-access-point.xml: Strength property is char, * not int. * src/NetworkManagerAP.c (set_property): Set strength from char. (get_property): Handle hidden APs (with empty SSID). Get strength value from char. (nm_ap_class_init): Strength property has char type. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2659 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 29 ++++++++++++++++++++++++++ gnome/vpn-properties/Makefile.am | 1 - introspection/nm-access-point.xml | 2 +- libnm-glib/nm-access-point.c | 6 +++--- libnm-glib/nm-access-point.h | 14 ++++++++----- libnm-glib/nm-client.h | 4 ++++ libnm-glib/nm-device-802-11-wireless.h | 4 ++++ libnm-glib/nm-device-802-3-ethernet.h | 4 ++++ libnm-glib/nm-device.h | 4 ++++ libnm-glib/nm-ip4-config.h | 3 +++ libnm-glib/nm-object.c | 14 +++++++++++++ libnm-glib/nm-object.h | 8 +++++++ libnm-glib/nm-settings.h | 4 ++++ libnm-glib/nm-vpn-connection.h | 4 ++++ libnm-util/nm-connection.h | 4 ++++ libnm-util/nm-setting.h | 3 +++ src/NetworkManagerAP.c | 20 ++++++++++-------- 17 files changed, 109 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index a067ab8d5f..02dd65f71a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,32 @@ +2007-08-09 Tambet Ingo + + [Based on patch by Helmut Schaa ] + + * libnm-glib/nm-client.h: + * libnm-glib/nm-object.h: + * libnm-glib/nm-vpn-connection.h: + * libnm-glib/nm-settings.h: + * libnm-glib/nm-device.h: + * libnm-glib/nm-ip4-config.h: + * libnm-glib/nm-access-point.h: + * libnm-glib/nm-device-802-3-ethernet.h: + * libnm-util/nm-setting.h: + * libnm-util/nm-connection.h: Add G_BEGIN_DECLS / G_END_DECLS to support C++. + + * libnm-glib/nm-object.c (nm_object_get_byte_property): Implement. + + * libnm-glib/nm-access-point.c: Strength has type char. + + * gnome/vpn-properties/Makefile.am: Remove GNOME_DISABLE_DEPRECTATED for now + to fix build. GnomeDruid is deprecated in recent libgnomeui. + + * introspection/nm-access-point.xml: Strength property is char, not int. + + * src/NetworkManagerAP.c (set_property): Set strength from char. + (get_property): Handle hidden APs (with empty SSID). + Get strength value from char. + (nm_ap_class_init): Strength property has char type. + 2007-08-03 Rodrigo Moya * introspection/Makefile.am: diff --git a/gnome/vpn-properties/Makefile.am b/gnome/vpn-properties/Makefile.am index e35bc263a9..cf55205249 100644 --- a/gnome/vpn-properties/Makefile.am +++ b/gnome/vpn-properties/Makefile.am @@ -26,7 +26,6 @@ nm_vpn_properties_CFLAGS = \ -DGLADEDIR=\""$(gladedir)"\" \ -DG_DISABLE_DEPRECATED \ -DGDK_DISABLE_DEPRECATED \ - -DGNOME_DISABLE_DEPRECATED \ -DGNOMELOCALEDIR=\"$(datadir)/locale\" \ -DVERSION=\"$(VERSION)\" \ $(NULL) diff --git a/introspection/nm-access-point.xml b/introspection/nm-access-point.xml index a01f77d64b..9608a457fc 100644 --- a/introspection/nm-access-point.xml +++ b/introspection/nm-access-point.xml @@ -9,7 +9,7 @@ - + diff --git a/libnm-glib/nm-access-point.c b/libnm-glib/nm-access-point.c index 926641b03e..2465cc5c8f 100644 --- a/libnm-glib/nm-access-point.c +++ b/libnm-glib/nm-access-point.c @@ -9,7 +9,7 @@ G_DEFINE_TYPE (NMAccessPoint, nm_access_point, NM_TYPE_OBJECT) typedef struct { DBusGProxy *ap_proxy; - int strength; + gint8 strength; } NMAccessPointPrivate; enum { @@ -157,7 +157,7 @@ nm_access_point_get_rate (NMAccessPoint *ap) return nm_object_get_uint_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Rate"); } -int +gint8 nm_access_point_get_strength (NMAccessPoint *ap) { NMAccessPointPrivate *priv; @@ -167,7 +167,7 @@ nm_access_point_get_strength (NMAccessPoint *ap) priv = NM_ACCESS_POINT_GET_PRIVATE (ap); if (priv->strength == 0) - priv->strength = nm_object_get_int_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Strength"); + priv->strength = nm_object_get_byte_property (NM_OBJECT (ap), NM_DBUS_INTERFACE_ACCESS_POINT, "Strength"); return priv->strength; } diff --git a/libnm-glib/nm-access-point.h b/libnm-glib/nm-access-point.h index 0ce4a040e8..0d4bf7dfee 100644 --- a/libnm-glib/nm-access-point.h +++ b/libnm-glib/nm-access-point.h @@ -1,6 +1,12 @@ #ifndef NM_ACCESS_POINT_H #define NM_ACCESS_POINT_H +#include +#include +#include "nm-object.h" + +G_BEGIN_DECLS + #define NM_TYPE_ACCESS_POINT (nm_access_point_get_type ()) #define NM_ACCESS_POINT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_ACCESS_POINT, NMAccessPoint)) #define NM_ACCESS_POINT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_ACCESS_POINT, NMAccessPointClass)) @@ -8,10 +14,6 @@ #define NM_IS_ACCESS_POINT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((obj), NM_TYPE_ACCESS_POINT)) #define NM_ACCESS_POINT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), NM_TYPE_ACCESS_POINT, NMAccessPointClass)) -#include -#include -#include "nm-object.h" - typedef struct { NMObject parent; } NMAccessPoint; @@ -34,6 +36,8 @@ gdouble nm_access_point_get_frequency (NMAccessPoint *ap); char * nm_access_point_get_hw_address (NMAccessPoint *ap); int nm_access_point_get_mode (NMAccessPoint *ap); guint32 nm_access_point_get_rate (NMAccessPoint *ap); -int nm_access_point_get_strength (NMAccessPoint *ap); +gint8 nm_access_point_get_strength (NMAccessPoint *ap); + +G_END_DECLS #endif /* NM_ACCESS_POINT_H */ diff --git a/libnm-glib/nm-client.h b/libnm-glib/nm-client.h index 0126d84cf6..3c78352798 100644 --- a/libnm-glib/nm-client.h +++ b/libnm-glib/nm-client.h @@ -11,6 +11,8 @@ #include "nm-device.h" #include "nm-vpn-connection.h" +G_BEGIN_DECLS + #define NM_TYPE_CLIENT (nm_client_get_type ()) #define NM_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CLIENT, NMClient)) #define NM_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CLIENT, NMClientClass)) @@ -62,4 +64,6 @@ void nm_client_remove_vpn_connection (NMClient *client, NMVPNActStage nm_client_get_vpn_state (NMClient *client); +G_END_DECLS + #endif /* NM_CLIENT_H */ diff --git a/libnm-glib/nm-device-802-11-wireless.h b/libnm-glib/nm-device-802-11-wireless.h index 66fc152618..b807c69ad8 100644 --- a/libnm-glib/nm-device-802-11-wireless.h +++ b/libnm-glib/nm-device-802-11-wireless.h @@ -4,6 +4,8 @@ #include "nm-device.h" #include "nm-access-point.h" +G_BEGIN_DECLS + #define NM_TYPE_DEVICE_802_11_WIRELESS (nm_device_802_11_wireless_get_type ()) #define NM_DEVICE_802_11_WIRELESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_802_11_WIRELESS, NMDevice80211Wireless)) #define NM_DEVICE_802_11_WIRELESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_802_11_WIRELESS, NMDevice80211WirelessClass)) @@ -39,4 +41,6 @@ NMAccessPoint *nm_device_802_11_wireless_get_network_by_path (NMDevice802 GSList *nm_device_802_11_wireless_get_networks (NMDevice80211Wireless *device); +G_END_DECLS + #endif /* NM_DEVICE_802_11_WIRELESS_H */ diff --git a/libnm-glib/nm-device-802-3-ethernet.h b/libnm-glib/nm-device-802-3-ethernet.h index 1c8094abad..8b83605fc3 100644 --- a/libnm-glib/nm-device-802-3-ethernet.h +++ b/libnm-glib/nm-device-802-3-ethernet.h @@ -3,6 +3,8 @@ #include "nm-device.h" +G_BEGIN_DECLS + #define NM_TYPE_DEVICE_802_3_ETHERNET (nm_device_802_3_ethernet_get_type ()) #define NM_DEVICE_802_3_ETHERNET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE_802_3_ETHERNET, NMDevice8023Ethernet)) #define NM_DEVICE_802_3_ETHERNET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE_802_3_ETHERNET, NMDevice8023EthernetClass)) @@ -25,4 +27,6 @@ NMDevice8023Ethernet *nm_device_802_3_ethernet_new (DBusGConnection *con int nm_device_802_3_ethernet_get_speed (NMDevice8023Ethernet *device); char *nm_device_802_3_ethernet_get_hw_address (NMDevice8023Ethernet *device); +G_END_DECLS + #endif /* NM_DEVICE_802_3_ETHERNET_H */ diff --git a/libnm-glib/nm-device.h b/libnm-glib/nm-device.h index 560df46256..06b739d644 100644 --- a/libnm-glib/nm-device.h +++ b/libnm-glib/nm-device.h @@ -9,6 +9,8 @@ #include "nm-ip4-config.h" #include "nm-connection.h" +G_BEGIN_DECLS + #define NM_TYPE_DEVICE (nm_device_get_type ()) #define NM_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_DEVICE, NMDevice)) #define NM_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_DEVICE, NMDeviceClass)) @@ -49,4 +51,6 @@ char *nm_device_get_description (NMDevice *device); NMDeviceType nm_device_type_for_path (DBusGConnection *connection, const char *path); +G_END_DECLS + #endif /* NM_DEVICE_H */ diff --git a/libnm-glib/nm-ip4-config.h b/libnm-glib/nm-ip4-config.h index 87c0d3a45a..4d354b7e3b 100644 --- a/libnm-glib/nm-ip4-config.h +++ b/libnm-glib/nm-ip4-config.h @@ -6,6 +6,8 @@ #include #include "nm-object.h" +G_BEGIN_DECLS + #define NM_TYPE_IP4_CONFIG (nm_ip4_config_get_type ()) #define NM_IP4_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_IP4_CONFIG, NMIP4Config)) #define NM_IP4_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_IP4_CONFIG, NMIP4ConfigClass)) @@ -36,5 +38,6 @@ char **nm_ip4_config_get_domains (NMIP4Config *config); char *nm_ip4_config_get_nis_domain (NMIP4Config *config); GArray *nm_ip4_config_get_nis_servers (NMIP4Config *config); +G_END_DECLS #endif /* NM_IP4_CONFIG_H */ diff --git a/libnm-glib/nm-object.c b/libnm-glib/nm-object.c index 03b77bd242..0d3b04b5bf 100644 --- a/libnm-glib/nm-object.c +++ b/libnm-glib/nm-object.c @@ -288,6 +288,20 @@ nm_object_get_boolean_property (NMObject *object, return b; } +gint8 +nm_object_get_byte_property (NMObject *object, + const char *interface, + const char *prop_name) +{ + gint8 b; + GValue value = {0,}; + + if (nm_object_get_property (object, interface, prop_name, &value)) + b = g_value_get_uchar (&value); + + return b; +} + gdouble nm_object_get_double_property (NMObject *object, const char *interface, diff --git a/libnm-glib/nm-object.h b/libnm-glib/nm-object.h index 8369538265..1a41b9c71b 100644 --- a/libnm-glib/nm-object.h +++ b/libnm-glib/nm-object.h @@ -5,6 +5,8 @@ #include #include +G_BEGIN_DECLS + #define NM_TYPE_OBJECT (nm_object_get_type ()) #define NM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_OBJECT, NMObject)) #define NM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_OBJECT, NMObjectClass)) @@ -60,6 +62,10 @@ gboolean nm_object_get_boolean_property (NMObject *object, const char *interface, const char *prop_name); +gint8 nm_object_get_byte_property (NMObject *object, + const char *interface, + const char *prop_name); + gdouble nm_object_get_double_property (NMObject *object, const char *interface, const char *prop_name); @@ -69,4 +75,6 @@ GByteArray *nm_object_get_byte_array_property (NMObject *object, const char *prop_name); +G_END_DECLS + #endif /* NM_OBJECT_H */ diff --git a/libnm-glib/nm-settings.h b/libnm-glib/nm-settings.h index 8a63d1f469..2516e2a427 100644 --- a/libnm-glib/nm-settings.h +++ b/libnm-glib/nm-settings.h @@ -4,6 +4,8 @@ #include +G_BEGIN_DECLS + #define NM_TYPE_CONNECTION_SETTINGS (nm_connection_settings_get_type ()) #define NM_CONNECTION_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettings)) #define NM_CONNECTION_SETTINGS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_CONNECTION_SETTINGS, NMConnectionSettingsClass)) @@ -53,4 +55,6 @@ typedef struct { GType nm_settings_get_type (void); +G_END_DECLS + #endif diff --git a/libnm-glib/nm-vpn-connection.h b/libnm-glib/nm-vpn-connection.h index ff7d0e32a4..0a02253da1 100644 --- a/libnm-glib/nm-vpn-connection.h +++ b/libnm-glib/nm-vpn-connection.h @@ -27,6 +27,8 @@ #include #include "NetworkManagerVPN.h" +G_BEGIN_DECLS + #define NM_TYPE_VPN_CONNECTION (nm_vpn_connection_get_type ()) #define NM_VPN_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NM_TYPE_VPN_CONNECTION, NMVPNConnection)) #define NM_VPN_CONNECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NM_TYPE_VPN_CONNECTION, NMVPNConnectionClass)) @@ -65,4 +67,6 @@ gboolean nm_vpn_connection_deactivate (NMVPNConnection *vpn); void nm_vpn_connection_set_state (NMVPNConnection *vpn, NMVPNActStage state); +G_END_DECLS + #endif /* NM_VPN_CONNECTION_H */ diff --git a/libnm-util/nm-connection.h b/libnm-util/nm-connection.h index 71e3b69592..58335f6156 100644 --- a/libnm-util/nm-connection.h +++ b/libnm-util/nm-connection.h @@ -4,6 +4,8 @@ #include #include "nm-setting.h" +G_BEGIN_DECLS + typedef struct { GHashTable *settings; } NMConnection; @@ -29,4 +31,6 @@ void nm_setting_parser_register (const char *name, void nm_setting_parser_unregister (const char *name); +G_END_DECLS + #endif /* NM_CONNECTION_H */ diff --git a/libnm-util/nm-setting.h b/libnm-util/nm-setting.h index 645be8c451..7f16d41f30 100644 --- a/libnm-util/nm-setting.h +++ b/libnm-util/nm-setting.h @@ -3,6 +3,8 @@ #include +G_BEGIN_DECLS + typedef struct _NMSetting NMSetting; typedef NMSetting *(*NMSettingCreateFn) (GHashTable *settings); @@ -134,5 +136,6 @@ typedef struct { NMSetting *nm_setting_wireless_security_new (void); NMSetting *nm_setting_wireless_security_new_from_hash (GHashTable *settings); +G_END_DECLS #endif /* NM_SETTING_H */ diff --git a/src/NetworkManagerAP.c b/src/NetworkManagerAP.c index 403ddae88c..5b2674fefc 100644 --- a/src/NetworkManagerAP.c +++ b/src/NetworkManagerAP.c @@ -173,7 +173,7 @@ set_property (GObject *object, guint prop_id, priv->rate = g_value_get_uint (value); break; case PROP_STRENGTH: - nm_ap_set_strength (NM_AP (object), g_value_get_int (value)); + nm_ap_set_strength (NM_AP (object), g_value_get_char (value)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -188,6 +188,7 @@ get_property (GObject *object, guint prop_id, NMAccessPointPrivate *priv = NM_AP_GET_PRIVATE (object); char hw_addr_buf[20]; GArray * ssid; + int len; int i; switch (prop_id) { @@ -198,8 +199,9 @@ get_property (GObject *object, guint prop_id, g_value_set_boolean (value, !(priv->capabilities & NM_802_11_CAP_PROTO_NONE)); break; case PROP_SSID: - ssid = g_array_sized_new (FALSE, TRUE, sizeof (unsigned char), priv->ssid->len); - for (i = 0; i < priv->ssid->len; i++) + len = priv->ssid ? priv->ssid->len : 0; + ssid = g_array_sized_new (FALSE, TRUE, sizeof (unsigned char), len); + for (i = 0; i < len; i++) g_array_append_val (ssid, priv->ssid->data[i]); g_value_set_boxed (value, ssid); g_array_free (ssid, TRUE); @@ -219,7 +221,7 @@ get_property (GObject *object, guint prop_id, g_value_set_uint (value, priv->rate); break; case PROP_STRENGTH: - g_value_set_int (value, priv->strength); + g_value_set_char (value, priv->strength); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -318,11 +320,11 @@ nm_ap_class_init (NMAccessPointClass *ap_class) g_object_class_install_property (object_class, PROP_STRENGTH, - g_param_spec_int (NM_AP_STRENGTH, - "Strength", - "Strength", - G_MININT8, G_MAXINT8, 0, - G_PARAM_READWRITE)); + g_param_spec_char (NM_AP_STRENGTH, + "Strength", + "Strength", + G_MININT8, G_MAXINT8, 0, + G_PARAM_READWRITE)); /* Signals */ signals[STRENGTH_CHANGED] =