2004-08-29 Colin Walters <walters@verbum.org>
* src/NetworkManagerDbus.c (nm_dbus_get_network_timestamp): Return a GTimeVal instead of time_t. This is easier to work with, since time_t may be a long or double, we don't know. * src/NetworkManagerDbus.h: Update prototype. * src/NetworkManagerAP.c (struct NMAccessPoint): Store a GTimeVal instead of time_t. (nm_ap_get_timestamp): Update to return GTimeVal. (nm_ap_set_timestamp): Update to take GTimeVal. * src/NetworkManagerAPList.c (nm_ap_list_update_network): Handle GTimeVal change. (nm_ap_list_print_members): Fix warnings in printf format. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@103 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
17
ChangeLog
17
ChangeLog
@@ -1,3 +1,20 @@
|
|||||||
|
2004-08-29 Colin Walters <walters@verbum.org>
|
||||||
|
|
||||||
|
* src/NetworkManagerDbus.c (nm_dbus_get_network_timestamp): Return
|
||||||
|
a GTimeVal instead of time_t. This is easier to work with,
|
||||||
|
since time_t may be a long or double, we don't know.
|
||||||
|
|
||||||
|
* src/NetworkManagerDbus.h: Update prototype.
|
||||||
|
|
||||||
|
* src/NetworkManagerAP.c (struct NMAccessPoint): Store a GTimeVal
|
||||||
|
instead of time_t.
|
||||||
|
(nm_ap_get_timestamp): Update to return GTimeVal.
|
||||||
|
(nm_ap_set_timestamp): Update to take GTimeVal.
|
||||||
|
|
||||||
|
* src/NetworkManagerAPList.c (nm_ap_list_update_network): Handle
|
||||||
|
GTimeVal change.
|
||||||
|
(nm_ap_list_print_members): Fix warnings in printf format.
|
||||||
|
|
||||||
2004-08-29 Colin Walters <walters@verbum.org>
|
2004-08-29 Colin Walters <walters@verbum.org>
|
||||||
|
|
||||||
* panel-applet/NMWirelessApplet.c: Include config.h.
|
* panel-applet/NMWirelessApplet.c: Include config.h.
|
||||||
|
@@ -45,7 +45,7 @@ struct NMAccessPoint
|
|||||||
|
|
||||||
/* Things from user prefs */
|
/* Things from user prefs */
|
||||||
gchar *enc_key;
|
gchar *enc_key;
|
||||||
time_t timestamp;
|
GTimeVal timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -63,7 +63,6 @@ NMAccessPoint * nm_ap_new (void)
|
|||||||
if (!ap)
|
if (!ap)
|
||||||
syslog( LOG_ERR, "nm_ap_new() could not allocate a new user access point info structure. Not enough memory?" );
|
syslog( LOG_ERR, "nm_ap_new() could not allocate a new user access point info structure. Not enough memory?" );
|
||||||
|
|
||||||
ap->timestamp = 0;
|
|
||||||
ap->refcount = 1;
|
ap->refcount = 1;
|
||||||
|
|
||||||
return (ap);
|
return (ap);
|
||||||
@@ -106,7 +105,6 @@ NMAccessPoint * nm_ap_new_from_ap (NMAccessPoint *src_ap)
|
|||||||
|
|
||||||
if (src_ap->enc_key && (strlen (src_ap->enc_key) > 0))
|
if (src_ap->enc_key && (strlen (src_ap->enc_key) > 0))
|
||||||
new_ap->enc_key = g_strdup (src_ap->enc_key);
|
new_ap->enc_key = g_strdup (src_ap->enc_key);
|
||||||
new_ap->timestamp = 0;
|
|
||||||
|
|
||||||
return (new_ap);
|
return (new_ap);
|
||||||
}
|
}
|
||||||
@@ -145,18 +143,18 @@ void nm_ap_unref (NMAccessPoint *ap)
|
|||||||
* Get/set functions for timestamp
|
* Get/set functions for timestamp
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
time_t nm_ap_get_timestamp (NMAccessPoint *ap)
|
const GTimeVal *nm_ap_get_timestamp (NMAccessPoint *ap)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (ap != NULL, 0);
|
g_return_val_if_fail (ap != NULL, 0);
|
||||||
|
|
||||||
return (ap->timestamp);
|
return (&ap->timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void nm_ap_set_timestamp (NMAccessPoint *ap, time_t timestamp)
|
void nm_ap_set_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp)
|
||||||
{
|
{
|
||||||
g_return_if_fail (ap != NULL);
|
g_return_if_fail (ap != NULL);
|
||||||
|
|
||||||
ap->timestamp = timestamp;
|
ap->timestamp = *timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -43,8 +43,8 @@ NMAccessPoint *nm_ap_new_from_ap (NMAccessPoint *ap);
|
|||||||
void nm_ap_unref (NMAccessPoint *ap);
|
void nm_ap_unref (NMAccessPoint *ap);
|
||||||
void nm_ap_ref (NMAccessPoint *ap);
|
void nm_ap_ref (NMAccessPoint *ap);
|
||||||
|
|
||||||
time_t nm_ap_get_timestamp (NMAccessPoint *ap);
|
const GTimeVal * nm_ap_get_timestamp (NMAccessPoint *ap);
|
||||||
void nm_ap_set_timestamp (NMAccessPoint *ap, time_t timestamp);
|
void nm_ap_set_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
|
||||||
|
|
||||||
gchar * nm_ap_get_essid (NMAccessPoint *ap);
|
gchar * nm_ap_get_essid (NMAccessPoint *ap);
|
||||||
void nm_ap_set_essid (NMAccessPoint *ap, gchar *essid);
|
void nm_ap_set_essid (NMAccessPoint *ap, gchar *essid);
|
||||||
|
@@ -233,9 +233,9 @@ void nm_ap_list_update_network (NMAccessPointList *list, const char *network, NM
|
|||||||
if ((essid = nm_dbus_get_network_essid (data->dbus_connection, list->type, network)))
|
if ((essid = nm_dbus_get_network_essid (data->dbus_connection, list->type, network)))
|
||||||
{
|
{
|
||||||
char *key = nm_dbus_get_network_key (data->dbus_connection, list->type, network);
|
char *key = nm_dbus_get_network_key (data->dbus_connection, list->type, network);
|
||||||
time_t timestamp = nm_dbus_get_network_timestamp (data->dbus_connection, list->type, network);
|
GTimeVal *timestamp = nm_dbus_get_network_timestamp (data->dbus_connection, list->type, network);
|
||||||
|
|
||||||
if (timestamp >= 0)
|
if (timestamp != NULL)
|
||||||
{
|
{
|
||||||
/* Find access point in list, if not found create a new AP and add it to the list */
|
/* Find access point in list, if not found create a new AP and add it to the list */
|
||||||
if (!(ap = nm_ap_list_get_ap_by_essid (list, network)))
|
if (!(ap = nm_ap_list_get_ap_by_essid (list, network)))
|
||||||
@@ -244,6 +244,7 @@ void nm_ap_list_update_network (NMAccessPointList *list, const char *network, NM
|
|||||||
nm_ap_set_essid (ap, essid);
|
nm_ap_set_essid (ap, essid);
|
||||||
nm_ap_set_enc_key_source (ap, key);
|
nm_ap_set_enc_key_source (ap, key);
|
||||||
nm_ap_set_timestamp (ap, timestamp);
|
nm_ap_set_timestamp (ap, timestamp);
|
||||||
|
g_free (timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (essid);
|
g_free (essid);
|
||||||
@@ -466,8 +467,9 @@ void nm_ap_list_print_members (NMAccessPointList *list, const char *name)
|
|||||||
syslog (LOG_DEBUG, "AP_LIST_PRINT: printing members of '%s'", name);
|
syslog (LOG_DEBUG, "AP_LIST_PRINT: printing members of '%s'", name);
|
||||||
while ((ap = nm_ap_list_iter_next (iter)))
|
while ((ap = nm_ap_list_iter_next (iter)))
|
||||||
{
|
{
|
||||||
syslog (LOG_DEBUG, "\t%d)\tessid='%s', timestamp=%d, key='%s', enc=%d, addr=0x%X, qual=%d, freq=%f, rate=%d, inval=%d",
|
const GTimeVal *timestamp = nm_ap_get_timestamp (ap);
|
||||||
i, nm_ap_get_essid (ap), nm_ap_get_timestamp (ap), nm_ap_get_enc_key_source (ap), nm_ap_get_encrypted (ap),
|
syslog (LOG_DEBUG, "\t%d)\tessid='%s', timestamp=%ld, key='%s', enc=%d, addr=%p, qual=%d, freq=%f, rate=%d, inval=%d",
|
||||||
|
i, nm_ap_get_essid (ap), timestamp->tv_sec, nm_ap_get_enc_key_source (ap), nm_ap_get_encrypted (ap),
|
||||||
nm_ap_get_address (ap), nm_ap_get_quality (ap), nm_ap_get_freq (ap), nm_ap_get_rate (ap),
|
nm_ap_get_address (ap), nm_ap_get_quality (ap), nm_ap_get_freq (ap), nm_ap_get_rate (ap),
|
||||||
nm_ap_get_invalid (ap));
|
nm_ap_get_invalid (ap));
|
||||||
i++;
|
i++;
|
||||||
|
@@ -678,27 +678,28 @@ char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type,
|
|||||||
*
|
*
|
||||||
* Get a network's timestamp from NetworkManagerInfo
|
* Get a network's timestamp from NetworkManagerInfo
|
||||||
*
|
*
|
||||||
* Returns: -1 on error
|
* Returns: NULL on error
|
||||||
* timestamp if no error
|
* timestamp if no error
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
time_t nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network)
|
GTimeVal *nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network)
|
||||||
{
|
{
|
||||||
DBusMessage *message;
|
DBusMessage *message;
|
||||||
DBusError error;
|
DBusError error;
|
||||||
DBusMessage *reply;
|
DBusMessage *reply;
|
||||||
time_t timestamp = -1;
|
guint32 timestamp_secs;
|
||||||
|
GTimeVal *timestamp;
|
||||||
|
|
||||||
g_return_val_if_fail (connection != NULL, -1);
|
g_return_val_if_fail (connection != NULL, NULL);
|
||||||
g_return_val_if_fail (network != NULL, -1);
|
g_return_val_if_fail (network != NULL, NULL);
|
||||||
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, -1);
|
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, NULL);
|
||||||
|
|
||||||
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
|
||||||
NMI_DBUS_INTERFACE, "getNetworkTimestamp");
|
NMI_DBUS_INTERFACE, "getNetworkTimestamp");
|
||||||
if (!message)
|
if (!message)
|
||||||
{
|
{
|
||||||
syslog (LOG_ERR, "nm_dbus_get_network_timestamp(): Couldn't allocate the dbus message");
|
syslog (LOG_ERR, "nm_dbus_get_network_timestamp(): Couldn't allocate the dbus message");
|
||||||
return (-1);
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
dbus_message_append_args (message, DBUS_TYPE_STRING, network,
|
||||||
@@ -715,14 +716,20 @@ time_t nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
dbus_error_init (&error);
|
dbus_error_init (&error);
|
||||||
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, ×tamp, DBUS_TYPE_INVALID))
|
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, ×tamp_secs, DBUS_TYPE_INVALID))
|
||||||
timestamp = -1;
|
timestamp_secs = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
dbus_message_unref (message);
|
dbus_message_unref (message);
|
||||||
if (reply)
|
if (reply)
|
||||||
dbus_message_unref (reply);
|
dbus_message_unref (reply);
|
||||||
|
|
||||||
|
if (timestamp_secs < 0)
|
||||||
|
return NULL;
|
||||||
|
timestamp = g_new0 (GTimeVal, 1);
|
||||||
|
timestamp->tv_sec = timestamp_secs;
|
||||||
|
timestamp->tv_usec = 0;
|
||||||
|
|
||||||
return (timestamp);
|
return (timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -68,7 +68,7 @@ char * nm_dbus_get_network_essid (DBusConnection *connection, NMNetworkType t
|
|||||||
|
|
||||||
char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network);
|
char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type, const char *network);
|
||||||
|
|
||||||
time_t nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network);
|
GTimeVal * nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType type, const char *network);
|
||||||
|
|
||||||
char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, int *num_networks);
|
char ** nm_dbus_get_networks (DBusConnection *connection, NMNetworkType type, int *num_networks);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user