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:
Colin Walters 2004-08-29 05:40:32 +00:00
parent 5ddc7519a5
commit fbf832d9c3
6 changed files with 47 additions and 23 deletions

View file

@ -1,5 +1,22 @@
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>
* panel-applet/NMWirelessApplet.c: Include config.h.
2004-08-29 Colin Walters <walters@verbum.org>

View file

@ -45,7 +45,7 @@ struct NMAccessPoint
/* Things from user prefs */
gchar *enc_key;
time_t timestamp;
GTimeVal timestamp;
};
@ -63,7 +63,6 @@ NMAccessPoint * nm_ap_new (void)
if (!ap)
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;
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))
new_ap->enc_key = g_strdup (src_ap->enc_key);
new_ap->timestamp = 0;
return (new_ap);
}
@ -145,18 +143,18 @@ void nm_ap_unref (NMAccessPoint *ap)
* 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);
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);
ap->timestamp = timestamp;
ap->timestamp = *timestamp;
}

View file

@ -43,8 +43,8 @@ NMAccessPoint *nm_ap_new_from_ap (NMAccessPoint *ap);
void nm_ap_unref (NMAccessPoint *ap);
void nm_ap_ref (NMAccessPoint *ap);
time_t nm_ap_get_timestamp (NMAccessPoint *ap);
void nm_ap_set_timestamp (NMAccessPoint *ap, time_t timestamp);
const GTimeVal * nm_ap_get_timestamp (NMAccessPoint *ap);
void nm_ap_set_timestamp (NMAccessPoint *ap, const GTimeVal *timestamp);
gchar * nm_ap_get_essid (NMAccessPoint *ap);
void nm_ap_set_essid (NMAccessPoint *ap, gchar *essid);

View file

@ -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)))
{
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 */
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_enc_key_source (ap, key);
nm_ap_set_timestamp (ap, timestamp);
g_free (timestamp);
}
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);
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",
i, nm_ap_get_essid (ap), nm_ap_get_timestamp (ap), nm_ap_get_enc_key_source (ap), nm_ap_get_encrypted (ap),
const GTimeVal *timestamp = nm_ap_get_timestamp (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_invalid (ap));
i++;

View file

@ -678,27 +678,28 @@ char * nm_dbus_get_network_key (DBusConnection *connection, NMNetworkType type,
*
* Get a network's timestamp from NetworkManagerInfo
*
* Returns: -1 on error
* Returns: NULL on 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;
DBusError error;
DBusMessage *reply;
time_t timestamp = -1;
guint32 timestamp_secs;
GTimeVal *timestamp;
g_return_val_if_fail (connection != NULL, -1);
g_return_val_if_fail (network != NULL, -1);
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, -1);
g_return_val_if_fail (connection != NULL, NULL);
g_return_val_if_fail (network != NULL, NULL);
g_return_val_if_fail (type != NETWORK_TYPE_UNKNOWN, NULL);
message = dbus_message_new_method_call (NMI_DBUS_SERVICE, NMI_DBUS_PATH,
NMI_DBUS_INTERFACE, "getNetworkTimestamp");
if (!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,
@ -715,14 +716,20 @@ time_t nm_dbus_get_network_timestamp (DBusConnection *connection, NMNetworkType
else
{
dbus_error_init (&error);
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, &timestamp, DBUS_TYPE_INVALID))
timestamp = -1;
if (!dbus_message_get_args (reply, &error, DBUS_TYPE_INT32, &timestamp_secs, DBUS_TYPE_INVALID))
timestamp_secs = -1;
}
dbus_message_unref (message);
if (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);
}

View file

@ -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);
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);