Merge branch '1931-bookmark-file-y2038' into 'master'

Resolve "GBookmarkFile API involves time_t"

Closes #1931

See merge request GNOME/glib!1511
This commit is contained in:
Emmanuele Bassi 2020-05-28 15:41:04 +00:00
commit 3d0e1f5c85
4 changed files with 615 additions and 179 deletions

View File

@ -2369,11 +2369,15 @@ g_bookmark_file_get_mime_type
g_bookmark_file_get_is_private
g_bookmark_file_get_icon
g_bookmark_file_get_added
g_bookmark_file_get_added_date_time
g_bookmark_file_get_modified
g_bookmark_file_get_modified_date_time
g_bookmark_file_get_visited
g_bookmark_file_get_visited_date_time
g_bookmark_file_get_groups
g_bookmark_file_get_applications
g_bookmark_file_get_app_info
g_bookmark_file_get_application_info
<SUBSECTION>
g_bookmark_file_set_title
@ -2382,10 +2386,14 @@ g_bookmark_file_set_mime_type
g_bookmark_file_set_is_private
g_bookmark_file_set_icon
g_bookmark_file_set_added
g_bookmark_file_set_added_date_time
g_bookmark_file_set_groups
g_bookmark_file_set_modified
g_bookmark_file_set_modified_date_time
g_bookmark_file_set_visited
g_bookmark_file_set_visited_date_time
g_bookmark_file_set_app_info
g_bookmark_file_set_application_info
g_bookmark_file_add_group
g_bookmark_file_add_application
g_bookmark_file_remove_group

View File

@ -31,6 +31,7 @@
#include "gconvert.h"
#include "gdataset.h"
#include "gdatetime.h"
#include "gerror.h"
#include "gfileutils.h"
#include "ghash.h"
@ -86,7 +87,7 @@
*
* The important caveat of bookmark files is that when you add a new
* bookmark you must also add the application that is registering it, using
* g_bookmark_file_add_application() or g_bookmark_file_set_app_info().
* g_bookmark_file_add_application() or g_bookmark_file_set_application_info().
* If a bookmark has no applications then it won't be dumped when creating
* the on disk representation, using g_bookmark_file_to_data() or
* g_bookmark_file_to_file().
@ -165,7 +166,7 @@ struct _BookmarkAppInfo
guint count;
time_t stamp;
GDateTime *stamp; /* (owned) */
};
struct _BookmarkMetadata
@ -190,9 +191,9 @@ struct _BookmarkItem
gchar *title;
gchar *description;
time_t added;
time_t modified;
time_t visited;
GDateTime *added; /* (owned) */
GDateTime *modified; /* (owned) */
GDateTime *visited; /* (owned) */
BookmarkMetadata *metadata;
};
@ -245,10 +246,9 @@ static void g_bookmark_file_add_item (GBookmarkFile *bookmark,
BookmarkItem *item,
GError **error);
static gboolean timestamp_from_iso8601 (const gchar *iso_date,
time_t *out_timestamp,
GError **error);
static gchar *timestamp_to_iso8601 (time_t timestamp);
static gboolean timestamp_from_iso8601 (const gchar *iso_date,
GDateTime **out_date_time,
GError **error);
/********************************
* BookmarkAppInfo *
@ -267,7 +267,7 @@ bookmark_app_info_new (const gchar *name)
retval->name = g_strdup (name);
retval->exec = NULL;
retval->count = 0;
retval->stamp = 0;
retval->stamp = NULL;
return retval;
}
@ -280,6 +280,7 @@ bookmark_app_info_free (BookmarkAppInfo *app_info)
g_free (app_info->name);
g_free (app_info->exec);
g_clear_pointer (&app_info->stamp, g_date_time_unref);
g_slice_free (BookmarkAppInfo, app_info);
}
@ -297,7 +298,7 @@ bookmark_app_info_dump (BookmarkAppInfo *app_info)
name = g_markup_escape_text (app_info->name, -1);
exec = g_markup_escape_text (app_info->exec, -1);
modified = timestamp_to_iso8601 (app_info->stamp);
modified = g_date_time_format_iso8601 (app_info->stamp);
count = g_strdup_printf ("%u", app_info->count);
retval = g_strconcat (" "
@ -511,9 +512,9 @@ bookmark_item_new (const gchar *uri)
item->title = NULL;
item->description = NULL;
item->added = (time_t) -1;
item->modified = (time_t) -1;
item->visited = (time_t) -1;
item->added = NULL;
item->modified = NULL;
item->visited = NULL;
item->metadata = NULL;
@ -533,9 +534,20 @@ bookmark_item_free (BookmarkItem *item)
if (item->metadata)
bookmark_metadata_free (item->metadata);
g_clear_pointer (&item->added, g_date_time_unref);
g_clear_pointer (&item->modified, g_date_time_unref);
g_clear_pointer (&item->visited, g_date_time_unref);
g_slice_free (BookmarkItem, item);
}
static void
bookmark_item_touch_modified (BookmarkItem *item)
{
g_clear_pointer (&item->modified, g_date_time_unref);
item->modified = g_date_time_new_now_utc ();
}
static gchar *
bookmark_item_dump (BookmarkItem *item)
{
@ -555,9 +567,9 @@ bookmark_item_dump (BookmarkItem *item)
retval = g_string_sized_new (4096);
added = timestamp_to_iso8601 (item->added);
modified = timestamp_to_iso8601 (item->modified);
visited = timestamp_to_iso8601 (item->visited);
added = g_date_time_format_iso8601 (item->added);
modified = g_date_time_format_iso8601 (item->modified);
visited = g_date_time_format_iso8601 (item->visited);
escaped_uri = g_markup_escape_text (item->uri, -1);
@ -883,6 +895,7 @@ parse_application_element (GMarkupParseContext *context,
else
ai->count = 1;
g_clear_pointer (&ai->stamp, g_date_time_unref);
if (modified != NULL)
{
if (!timestamp_from_iso8601 (modified, &ai->stamp, error))
@ -894,9 +907,9 @@ parse_application_element (GMarkupParseContext *context,
* it for backward compatibility
*/
if (stamp)
ai->stamp = (time_t) atol (stamp);
ai->stamp = g_date_time_new_from_unix_utc (atol (stamp));
else
ai->stamp = time (NULL);
ai->stamp = g_date_time_new_now_utc ();
}
}
@ -1599,25 +1612,11 @@ out:
* Misc *
**************/
/* converts a Unix timestamp in a ISO 8601 compliant string; you
* should free the returned string.
*/
static gchar *
timestamp_to_iso8601 (time_t timestamp)
{
GDateTime *dt = g_date_time_new_from_unix_utc (timestamp);
gchar *iso8601_string = g_date_time_format_iso8601 (dt);
g_date_time_unref (dt);
return g_steal_pointer (&iso8601_string);
}
static gboolean
timestamp_from_iso8601 (const gchar *iso_date,
time_t *out_timestamp,
GDateTime **out_date_time,
GError **error)
{
gint64 time_val;
GDateTime *dt = g_date_time_new_from_iso8601 (iso_date, NULL);
if (dt == NULL)
{
@ -1626,10 +1625,7 @@ timestamp_from_iso8601 (const gchar *iso_date,
return FALSE;
}
time_val = g_date_time_to_unix (dt);
g_date_time_unref (dt);
*out_timestamp = time_val;
*out_date_time = g_steal_pointer (&dt);
return TRUE;
}
@ -2040,11 +2036,11 @@ g_bookmark_file_add_item (GBookmarkFile *bookmark,
item->uri,
item);
if (item->added == (time_t) -1)
item->added = time (NULL);
if (item->added == NULL)
item->added = g_date_time_new_now_utc ();
if (item->modified == (time_t) -1)
item->modified = time (NULL);
if (item->modified == NULL)
item->modified = g_date_time_new_now_utc ();
}
/**
@ -2194,7 +2190,7 @@ g_bookmark_file_set_title (GBookmarkFile *bookmark,
g_free (item->title);
item->title = g_strdup (title);
item->modified = time (NULL);
bookmark_item_touch_modified (item);
}
}
@ -2281,7 +2277,7 @@ g_bookmark_file_set_description (GBookmarkFile *bookmark,
g_free (item->description);
item->description = g_strdup (description);
item->modified = time (NULL);
bookmark_item_touch_modified (item);
}
}
@ -2362,7 +2358,7 @@ g_bookmark_file_set_mime_type (GBookmarkFile *bookmark,
g_free (item->metadata->mime_type);
item->metadata->mime_type = g_strdup (mime_type);
item->modified = time (NULL);
bookmark_item_touch_modified (item);
}
/**
@ -2448,7 +2444,7 @@ g_bookmark_file_set_is_private (GBookmarkFile *bookmark,
item->metadata = bookmark_metadata_new ();
item->metadata->is_private = (is_private == TRUE);
item->modified = time (NULL);
bookmark_item_touch_modified (item);
}
/**
@ -2511,16 +2507,41 @@ g_bookmark_file_get_is_private (GBookmarkFile *bookmark,
* If no bookmark for @uri is found then it is created.
*
* Since: 2.12
* Deprecated: 2.66: Use g_bookmark_file_set_added_date_time() instead, as
* `time_t` is deprecated due to the year 2038 problem.
*/
void
g_bookmark_file_set_added (GBookmarkFile *bookmark,
const gchar *uri,
time_t added)
{
GDateTime *added_dt = (added != (time_t) -1) ? g_date_time_new_from_unix_utc (added) : g_date_time_new_now_utc ();
g_bookmark_file_set_added_date_time (bookmark, uri, added_dt);
g_date_time_unref (added_dt);
}
/**
* g_bookmark_file_set_added_date_time:
* @bookmark: a #GBookmarkFile
* @uri: a valid URI
* @added: a #GDateTime
*
* Sets the time the bookmark for @uri was added into @bookmark.
*
* If no bookmark for @uri is found then it is created.
*
* Since: 2.66
*/
void
g_bookmark_file_set_added_date_time (GBookmarkFile *bookmark,
const char *uri,
GDateTime *added)
{
BookmarkItem *item;
g_return_if_fail (bookmark != NULL);
g_return_if_fail (uri != NULL);
g_return_if_fail (added != NULL);
item = g_bookmark_file_lookup_item (bookmark, uri);
if (!item)
@ -2529,11 +2550,10 @@ g_bookmark_file_set_added (GBookmarkFile *bookmark,
g_bookmark_file_add_item (bookmark, item, NULL);
}
if (added == (time_t) -1)
time (&added);
item->added = added;
item->modified = added;
g_clear_pointer (&item->added, g_date_time_unref);
item->added = g_date_time_ref (added);
g_clear_pointer (&item->modified, g_date_time_unref);
item->modified = g_date_time_ref (added);
}
/**
@ -2550,25 +2570,52 @@ g_bookmark_file_set_added (GBookmarkFile *bookmark,
* Returns: a timestamp
*
* Since: 2.12
* Deprecated: 2.66: Use g_bookmark_file_get_added_date_time() instead, as
* `time_t` is deprecated due to the year 2038 problem.
*/
time_t
g_bookmark_file_get_added (GBookmarkFile *bookmark,
const gchar *uri,
GError **error)
{
GDateTime *added = g_bookmark_file_get_added_date_time (bookmark, uri, error);
return (added != NULL) ? g_date_time_to_unix (added) : (time_t) -1;
}
/**
* g_bookmark_file_get_added_date_time:
* @bookmark: a #GBookmarkFile
* @uri: a valid URI
* @error: return location for a #GError, or %NULL
*
* Gets the time the bookmark for @uri was added to @bookmark
*
* In the event the URI cannot be found, %NULL is returned and
* @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
*
* Returns: (transfer none): a #GDateTime
*
* Since: 2.66
*/
GDateTime *
g_bookmark_file_get_added_date_time (GBookmarkFile *bookmark,
const char *uri,
GError **error)
{
BookmarkItem *item;
g_return_val_if_fail (bookmark != NULL, (time_t) -1);
g_return_val_if_fail (uri != NULL, (time_t) -1);
g_return_val_if_fail (bookmark != NULL, NULL);
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
item = g_bookmark_file_lookup_item (bookmark, uri);
if (!item)
{
g_set_error (error, G_BOOKMARK_FILE_ERROR,
G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
_("No bookmark found for URI “%s”"),
uri);
return (time_t) -1;
G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
_("No bookmark found for URI “%s”"),
uri);
return NULL;
}
return item->added;
@ -2587,19 +2634,49 @@ g_bookmark_file_get_added (GBookmarkFile *bookmark,
* The "modified" time should only be set when the bookmark's meta-data
* was actually changed. Every function of #GBookmarkFile that
* modifies a bookmark also changes the modification time, except for
* g_bookmark_file_set_visited().
* g_bookmark_file_set_visited_date_time().
*
* Since: 2.12
* Deprecated: 2.66: Use g_bookmark_file_set_modified_date_time() instead, as
* `time_t` is deprecated due to the year 2038 problem.
*/
void
g_bookmark_file_set_modified (GBookmarkFile *bookmark,
const gchar *uri,
time_t modified)
{
GDateTime *modified_dt = (modified != (time_t) -1) ? g_date_time_new_from_unix_utc (modified) : g_date_time_new_now_utc ();
g_bookmark_file_set_modified_date_time (bookmark, uri, modified_dt);
g_date_time_unref (modified_dt);
}
/**
* g_bookmark_file_set_modified_date_time:
* @bookmark: a #GBookmarkFile
* @uri: a valid URI
* @modified: a #GDateTime
*
* Sets the last time the bookmark for @uri was last modified.
*
* If no bookmark for @uri is found then it is created.
*
* The "modified" time should only be set when the bookmark's meta-data
* was actually changed. Every function of #GBookmarkFile that
* modifies a bookmark also changes the modification time, except for
* g_bookmark_file_set_visited_date_time().
*
* Since: 2.66
*/
void
g_bookmark_file_set_modified_date_time (GBookmarkFile *bookmark,
const char *uri,
GDateTime *modified)
{
BookmarkItem *item;
g_return_if_fail (bookmark != NULL);
g_return_if_fail (uri != NULL);
g_return_if_fail (modified != NULL);
item = g_bookmark_file_lookup_item (bookmark, uri);
if (!item)
@ -2608,10 +2685,8 @@ g_bookmark_file_set_modified (GBookmarkFile *bookmark,
g_bookmark_file_add_item (bookmark, item, NULL);
}
if (modified == (time_t) -1)
time (&modified);
item->modified = modified;
g_clear_pointer (&item->modified, g_date_time_unref);
item->modified = g_date_time_ref (modified);
}
/**
@ -2628,25 +2703,52 @@ g_bookmark_file_set_modified (GBookmarkFile *bookmark,
* Returns: a timestamp
*
* Since: 2.12
* Deprecated: 2.66: Use g_bookmark_file_get_modified_date_time() instead, as
* `time_t` is deprecated due to the year 2038 problem.
*/
time_t
g_bookmark_file_get_modified (GBookmarkFile *bookmark,
const gchar *uri,
GError **error)
{
GDateTime *modified = g_bookmark_file_get_modified_date_time (bookmark, uri, error);
return (modified != NULL) ? g_date_time_to_unix (modified) : (time_t) -1;
}
/**
* g_bookmark_file_get_modified_date_time:
* @bookmark: a #GBookmarkFile
* @uri: a valid URI
* @error: return location for a #GError, or %NULL
*
* Gets the time when the bookmark for @uri was last modified.
*
* In the event the URI cannot be found, %NULL is returned and
* @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
*
* Returns: (transfer none): a #GDateTime
*
* Since: 2.66
*/
GDateTime *
g_bookmark_file_get_modified_date_time (GBookmarkFile *bookmark,
const char *uri,
GError **error)
{
BookmarkItem *item;
g_return_val_if_fail (bookmark != NULL, (time_t) -1);
g_return_val_if_fail (uri != NULL, (time_t) -1);
g_return_val_if_fail (bookmark != NULL, NULL);
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
item = g_bookmark_file_lookup_item (bookmark, uri);
if (!item)
{
g_set_error (error, G_BOOKMARK_FILE_ERROR,
G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
_("No bookmark found for URI “%s”"),
uri);
return (time_t) -1;
G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
_("No bookmark found for URI “%s”"),
uri);
return NULL;
}
return item->modified;
@ -2663,22 +2765,53 @@ g_bookmark_file_get_modified (GBookmarkFile *bookmark,
* If no bookmark for @uri is found then it is created.
*
* The "visited" time should only be set if the bookmark was launched,
* either using the command line retrieved by g_bookmark_file_get_app_info()
* either using the command line retrieved by g_bookmark_file_get_application_info()
* or by the default application for the bookmark's MIME type, retrieved
* using g_bookmark_file_get_mime_type(). Changing the "visited" time
* does not affect the "modified" time.
*
* Since: 2.12
* Deprecated: 2.66: Use g_bookmark_file_set_visited_date_time() instead, as
* `time_t` is deprecated due to the year 2038 problem.
*/
void
g_bookmark_file_set_visited (GBookmarkFile *bookmark,
const gchar *uri,
time_t visited)
{
GDateTime *visited_dt = (visited != (time_t) -1) ? g_date_time_new_from_unix_utc (visited) : g_date_time_new_now_utc ();
g_bookmark_file_set_visited_date_time (bookmark, uri, visited_dt);
g_date_time_unref (visited_dt);
}
/**
* g_bookmark_file_set_visited_date_time:
* @bookmark: a #GBookmarkFile
* @uri: a valid URI
* @visited: a #GDateTime
*
* Sets the time the bookmark for @uri was last visited.
*
* If no bookmark for @uri is found then it is created.
*
* The "visited" time should only be set if the bookmark was launched,
* either using the command line retrieved by g_bookmark_file_get_application_info()
* or by the default application for the bookmark's MIME type, retrieved
* using g_bookmark_file_get_mime_type(). Changing the "visited" time
* does not affect the "modified" time.
*
* Since: 2.66
*/
void
g_bookmark_file_set_visited_date_time (GBookmarkFile *bookmark,
const char *uri,
GDateTime *visited)
{
BookmarkItem *item;
g_return_if_fail (bookmark != NULL);
g_return_if_fail (uri != NULL);
g_return_if_fail (visited != NULL);
item = g_bookmark_file_lookup_item (bookmark, uri);
if (!item)
@ -2687,10 +2820,8 @@ g_bookmark_file_set_visited (GBookmarkFile *bookmark,
g_bookmark_file_add_item (bookmark, item, NULL);
}
if (visited == (time_t) -1)
time (&visited);
item->visited = visited;
g_clear_pointer (&item->visited, g_date_time_unref);
item->visited = g_date_time_ref (visited);
}
/**
@ -2707,25 +2838,52 @@ g_bookmark_file_set_visited (GBookmarkFile *bookmark,
* Returns: a timestamp.
*
* Since: 2.12
* Deprecated: 2.66: Use g_bookmark_file_get_visited_date_time() instead, as
* `time_t` is deprecated due to the year 2038 problem.
*/
time_t
g_bookmark_file_get_visited (GBookmarkFile *bookmark,
const gchar *uri,
GError **error)
{
GDateTime *visited = g_bookmark_file_get_visited_date_time (bookmark, uri, error);
return (visited != NULL) ? g_date_time_to_unix (visited) : (time_t) -1;
}
/**
* g_bookmark_file_get_visited_date_time:
* @bookmark: a #GBookmarkFile
* @uri: a valid URI
* @error: return location for a #GError, or %NULL
*
* Gets the time the bookmark for @uri was last visited.
*
* In the event the URI cannot be found, %NULL is returned and
* @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND.
*
* Returns: (transfer none): a #GDateTime
*
* Since: 2.66
*/
GDateTime *
g_bookmark_file_get_visited_date_time (GBookmarkFile *bookmark,
const char *uri,
GError **error)
{
BookmarkItem *item;
g_return_val_if_fail (bookmark != NULL, (time_t) -1);
g_return_val_if_fail (uri != NULL, (time_t) -1);
g_return_val_if_fail (bookmark != NULL, NULL);
g_return_val_if_fail (uri != NULL, NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
item = g_bookmark_file_lookup_item (bookmark, uri);
if (!item)
{
g_set_error (error, G_BOOKMARK_FILE_ERROR,
G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
_("No bookmark found for URI “%s”"),
uri);
return (time_t) -1;
G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND,
_("No bookmark found for URI “%s”"),
uri);
return NULL;
}
return item->visited;
@ -2822,7 +2980,7 @@ g_bookmark_file_add_group (GBookmarkFile *bookmark,
item->metadata->groups = g_list_prepend (item->metadata->groups,
g_strdup (group));
item->modified = time (NULL);
bookmark_item_touch_modified (item);
}
}
@ -2884,7 +3042,7 @@ g_bookmark_file_remove_group (GBookmarkFile *bookmark,
g_free (l->data);
g_list_free_1 (l);
item->modified = time (NULL);
bookmark_item_touch_modified (item);
return TRUE;
}
@ -2941,7 +3099,7 @@ g_bookmark_file_set_groups (GBookmarkFile *bookmark,
g_strdup (groups[i]));
}
item->modified = time (NULL);
bookmark_item_touch_modified (item);
}
/**
@ -3057,6 +3215,7 @@ g_bookmark_file_add_application (GBookmarkFile *bookmark,
{
BookmarkItem *item;
gchar *app_name, *app_exec;
GDateTime *stamp;
g_return_if_fail (bookmark != NULL);
g_return_if_fail (uri != NULL);
@ -3078,13 +3237,16 @@ g_bookmark_file_add_application (GBookmarkFile *bookmark,
else
app_exec = g_strjoin (" ", g_get_prgname(), "%u", NULL);
g_bookmark_file_set_app_info (bookmark, uri,
app_name,
app_exec,
-1,
(time_t) -1,
NULL);
stamp = g_date_time_new_now_utc ();
g_bookmark_file_set_application_info (bookmark, uri,
app_name,
app_exec,
-1,
stamp,
NULL);
g_date_time_unref (stamp);
g_free (app_exec);
g_free (app_name);
}
@ -3123,12 +3285,12 @@ g_bookmark_file_remove_application (GBookmarkFile *bookmark,
g_return_val_if_fail (name != NULL, FALSE);
set_error = NULL;
retval = g_bookmark_file_set_app_info (bookmark, uri,
name,
"",
0,
(time_t) -1,
&set_error);
retval = g_bookmark_file_set_application_info (bookmark, uri,
name,
"",
0,
NULL,
&set_error);
if (set_error)
{
g_propagate_error (error, set_error);
@ -3204,7 +3366,7 @@ g_bookmark_file_has_application (GBookmarkFile *bookmark,
* be expanded as the local file name retrieved from the bookmark's
* URI; "\%u", which will be expanded as the bookmark's URI.
* The expansion is done automatically when retrieving the stored
* command line using the g_bookmark_file_get_app_info() function.
* command line using the g_bookmark_file_get_application_info() function.
* @count is the number of times the application has registered the
* bookmark; if is < 0, the current registration count will be increased
* by one, if is 0, the application with @name will be removed from
@ -3224,6 +3386,8 @@ g_bookmark_file_has_application (GBookmarkFile *bookmark,
* changed.
*
* Since: 2.12
* Deprecated: 2.66: Use g_bookmark_file_set_application_info() instead, as
* `time_t` is deprecated due to the year 2038 problem.
*/
gboolean
g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
@ -3233,6 +3397,67 @@ g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
gint count,
time_t stamp,
GError **error)
{
GDateTime *stamp_dt = (stamp != (time_t) -1) ? g_date_time_new_from_unix_utc (stamp) : g_date_time_new_now_utc ();
gboolean retval;
retval = g_bookmark_file_set_application_info (bookmark, uri, name, exec, count,
stamp_dt, error);
g_date_time_unref (stamp_dt);
return retval;
}
/**
* g_bookmark_file_set_application_info:
* @bookmark: a #GBookmarkFile
* @uri: a valid URI
* @name: an application's name
* @exec: an application's command line
* @count: the number of registrations done for this application
* @stamp: (nullable): the time of the last registration for this application,
* which may be %NULL if @count is 0
* @error: return location for a #GError or %NULL
*
* Sets the meta-data of application @name inside the list of
* applications that have registered a bookmark for @uri inside
* @bookmark.
*
* You should rarely use this function; use g_bookmark_file_add_application()
* and g_bookmark_file_remove_application() instead.
*
* @name can be any UTF-8 encoded string used to identify an
* application.
* @exec can have one of these two modifiers: "\%f", which will
* be expanded as the local file name retrieved from the bookmark's
* URI; "\%u", which will be expanded as the bookmark's URI.
* The expansion is done automatically when retrieving the stored
* command line using the g_bookmark_file_get_application_info() function.
* @count is the number of times the application has registered the
* bookmark; if is < 0, the current registration count will be increased
* by one, if is 0, the application with @name will be removed from
* the list of registered applications.
* @stamp is the Unix time of the last registration.
*
* If you try to remove an application by setting its registration count to
* zero, and no bookmark for @uri is found, %FALSE is returned and
* @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND; similarly,
* in the event that no application @name has registered a bookmark
* for @uri, %FALSE is returned and error is set to
* #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. Otherwise, if no bookmark
* for @uri is found, one is created.
*
* Returns: %TRUE if the application's meta-data was successfully
* changed.
*
* Since: 2.66
*/
gboolean
g_bookmark_file_set_application_info (GBookmarkFile *bookmark,
const char *uri,
const char *name,
const char *exec,
int count,
GDateTime *stamp,
GError **error)
{
BookmarkItem *item;
BookmarkAppInfo *ai;
@ -3241,6 +3466,8 @@ g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
g_return_val_if_fail (uri != NULL, FALSE);
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (exec != NULL, FALSE);
g_return_val_if_fail (count == 0 || stamp != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
item = g_bookmark_file_lookup_item (bookmark, uri);
if (!item)
@ -3290,7 +3517,7 @@ g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
g_hash_table_remove (item->metadata->apps_by_name, ai->name);
bookmark_app_info_free (ai);
item->modified = time (NULL);
bookmark_item_touch_modified (item);
return TRUE;
}
@ -3299,10 +3526,8 @@ g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
else
ai->count += 1;
if (stamp != (time_t) -1)
ai->stamp = stamp;
else
ai->stamp = time (NULL);
g_clear_pointer (&ai->stamp, g_date_time_unref);
ai->stamp = g_date_time_ref (stamp);
if (exec && exec[0] != '\0')
{
@ -3310,7 +3535,7 @@ g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
ai->exec = g_shell_quote (exec);
}
item->modified = time (NULL);
bookmark_item_touch_modified (item);
return TRUE;
}
@ -3379,7 +3604,7 @@ expand_exec_line (const gchar *exec_fmt,
* @error: return location for a #GError, or %NULL
*
* Gets the registration information of @app_name for the bookmark for
* @uri. See g_bookmark_file_set_app_info() for more information about
* @uri. See g_bookmark_file_set_application_info() for more information about
* the returned data.
*
* The string returned in @app_exec must be freed.
@ -3395,6 +3620,8 @@ expand_exec_line (const gchar *exec_fmt,
* Returns: %TRUE on success.
*
* Since: 2.12
* Deprecated: 2.66: Use g_bookmark_file_get_application_info() instead, as
* `time_t` is deprecated due to the year 2038 problem.
*/
gboolean
g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
@ -3404,6 +3631,56 @@ g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
guint *count,
time_t *stamp,
GError **error)
{
GDateTime *stamp_dt = NULL;
gboolean retval;
retval = g_bookmark_file_get_application_info (bookmark, uri, name, exec, count, &stamp_dt, error);
if (!retval)
return FALSE;
if (stamp != NULL)
*stamp = g_date_time_to_unix (stamp_dt);
return TRUE;
}
/**
* g_bookmark_file_get_application_info:
* @bookmark: a #GBookmarkFile
* @uri: a valid URI
* @name: an application's name
* @exec: (out) (optional): return location for the command line of the application, or %NULL
* @count: (out) (optional): return location for the registration count, or %NULL
* @stamp: (out) (optional) (transfer none): return location for the last registration time, or %NULL
* @error: return location for a #GError, or %NULL
*
* Gets the registration information of @app_name for the bookmark for
* @uri. See g_bookmark_file_set_application_info() for more information about
* the returned data.
*
* The string returned in @app_exec must be freed.
*
* In the event the URI cannot be found, %FALSE is returned and
* @error is set to #G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND. In the
* event that no application with name @app_name has registered a bookmark
* for @uri, %FALSE is returned and error is set to
* #G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED. In the event that unquoting
* the command line fails, an error of the #G_SHELL_ERROR domain is
* set and %FALSE is returned.
*
* Returns: %TRUE on success.
*
* Since: 2.66
*/
gboolean
g_bookmark_file_get_application_info (GBookmarkFile *bookmark,
const char *uri,
const char *name,
char **exec,
unsigned int *count,
GDateTime **stamp,
GError **error)
{
BookmarkItem *item;
BookmarkAppInfo *ai;
@ -3411,6 +3688,7 @@ g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
g_return_val_if_fail (bookmark != NULL, FALSE);
g_return_val_if_fail (uri != NULL, FALSE);
g_return_val_if_fail (name != NULL, FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
item = g_bookmark_file_lookup_item (bookmark, uri);
if (!item)
@ -3615,7 +3893,7 @@ g_bookmark_file_move_item (GBookmarkFile *bookmark,
g_free (item->uri);
item->uri = g_strdup (new_uri);
item->modified = time (NULL);
bookmark_item_touch_modified (item);
g_hash_table_replace (bookmark->items_by_uri, item->uri, item);
@ -3676,7 +3954,7 @@ g_bookmark_file_set_icon (GBookmarkFile *bookmark,
else
item->metadata->icon_mime = g_strdup ("application/octet-stream");
item->modified = time (NULL);
bookmark_item_touch_modified (item);
}
/**

View File

@ -23,6 +23,7 @@
#error "Only <glib.h> can be included directly."
#endif
#include <glib/gdatetime.h>
#include <glib/gerror.h>
#include <time.h>
@ -162,7 +163,7 @@ gchar ** g_bookmark_file_get_applications (GBookmarkFile *bookmark,
const gchar *uri,
gsize *length,
GError **error);
GLIB_AVAILABLE_IN_ALL
GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_application_info)
gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
@ -170,7 +171,15 @@ gboolean g_bookmark_file_set_app_info (GBookmarkFile *bookmark,
gint count,
time_t stamp,
GError **error);
GLIB_AVAILABLE_IN_ALL
GLIB_AVAILABLE_IN_2_66
gboolean g_bookmark_file_set_application_info (GBookmarkFile *bookmark,
const char *uri,
const char *name,
const char *exec,
int count,
GDateTime *stamp,
GError **error);
GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_application_info)
gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
const gchar *uri,
const gchar *name,
@ -178,6 +187,14 @@ gboolean g_bookmark_file_get_app_info (GBookmarkFile *bookmark,
guint *count,
time_t *stamp,
GError **error);
GLIB_AVAILABLE_IN_2_66
gboolean g_bookmark_file_get_application_info (GBookmarkFile *bookmark,
const char *uri,
const char *name,
char **exec,
unsigned int *count,
GDateTime **stamp,
GError **error);
GLIB_AVAILABLE_IN_ALL
void g_bookmark_file_set_is_private (GBookmarkFile *bookmark,
const gchar *uri,
@ -197,30 +214,54 @@ gboolean g_bookmark_file_get_icon (GBookmarkFile *bookmark,
gchar **href,
gchar **mime_type,
GError **error);
GLIB_AVAILABLE_IN_ALL
GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_added_date_time)
void g_bookmark_file_set_added (GBookmarkFile *bookmark,
const gchar *uri,
time_t added);
GLIB_AVAILABLE_IN_ALL
GLIB_AVAILABLE_IN_2_66
void g_bookmark_file_set_added_date_time (GBookmarkFile *bookmark,
const char *uri,
GDateTime *added);
GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_added_date_time)
time_t g_bookmark_file_get_added (GBookmarkFile *bookmark,
const gchar *uri,
GError **error);
GLIB_AVAILABLE_IN_ALL
GLIB_AVAILABLE_IN_2_66
GDateTime *g_bookmark_file_get_added_date_time (GBookmarkFile *bookmark,
const char *uri,
GError **error);
GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_modified_date_time)
void g_bookmark_file_set_modified (GBookmarkFile *bookmark,
const gchar *uri,
time_t modified);
GLIB_AVAILABLE_IN_ALL
GLIB_AVAILABLE_IN_2_66
void g_bookmark_file_set_modified_date_time (GBookmarkFile *bookmark,
const char *uri,
GDateTime *modified);
GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_modified_date_time)
time_t g_bookmark_file_get_modified (GBookmarkFile *bookmark,
const gchar *uri,
GError **error);
GLIB_AVAILABLE_IN_ALL
GLIB_AVAILABLE_IN_2_66
GDateTime *g_bookmark_file_get_modified_date_time (GBookmarkFile *bookmark,
const char *uri,
GError **error);
GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_set_visited_date_time)
void g_bookmark_file_set_visited (GBookmarkFile *bookmark,
const gchar *uri,
time_t visited);
GLIB_AVAILABLE_IN_ALL
GLIB_AVAILABLE_IN_2_66
void g_bookmark_file_set_visited_date_time (GBookmarkFile *bookmark,
const char *uri,
GDateTime *visited);
GLIB_DEPRECATED_IN_2_66_FOR(g_bookmark_file_get_visited_date_time)
time_t g_bookmark_file_get_visited (GBookmarkFile *bookmark,
const gchar *uri,
GError **error);
GLIB_AVAILABLE_IN_2_66
GDateTime *g_bookmark_file_get_visited_date_time (GBookmarkFile *bookmark,
const char *uri,
GError **error);
GLIB_AVAILABLE_IN_ALL
gboolean g_bookmark_file_has_item (GBookmarkFile *bookmark,
const gchar *uri);

View File

@ -127,7 +127,7 @@ test_misc (void)
gboolean res;
GError *error = NULL;
gchar *s;
time_t before, after, t;
GDateTime *before, *after, *t;
gchar *cmd, *exec;
guint count;
@ -196,47 +196,55 @@ test_misc (void)
g_assert_no_error (error);
g_assert_true (res);
time (&before);
before = g_date_time_new_now_utc ();
g_bookmark_file_set_added (bookmark,
"file:///tmp/schedule3.ps",
(time_t)-1);
t = g_bookmark_file_get_added (bookmark,
"file:///tmp/schedule3.ps",
&error);
g_bookmark_file_set_added_date_time (bookmark,
"file:///tmp/schedule3.ps",
before);
t = g_bookmark_file_get_added_date_time (bookmark,
"file:///tmp/schedule3.ps",
&error);
g_assert_no_error (error);
time (&after);
g_assert_cmpint (before, <=, t);
g_assert_cmpint (t, <=, after);
after = g_date_time_new_now_utc ();
g_assert_cmpint (g_date_time_compare (before, t), <=, 0);
g_assert_cmpint (g_date_time_compare (t, after), <=, 0);
time (&before);
g_date_time_unref (after);
g_date_time_unref (before);
g_bookmark_file_set_modified (bookmark,
"file:///tmp/schedule4.ps",
(time_t)-1);
t = g_bookmark_file_get_modified (bookmark,
"file:///tmp/schedule4.ps",
&error);
before = g_date_time_new_now_utc ();
g_bookmark_file_set_modified_date_time (bookmark,
"file:///tmp/schedule4.ps",
before);
t = g_bookmark_file_get_modified_date_time (bookmark,
"file:///tmp/schedule4.ps",
&error);
g_assert_no_error (error);
time (&after);
g_assert_cmpint (before, <=, t);
g_assert_cmpint (t, <=, after);
after = g_date_time_new_now_utc ();
g_assert_cmpint (g_date_time_compare (before, t), <=, 0);
g_assert_cmpint (g_date_time_compare (t, after), <=, 0);
time (&before);
g_date_time_unref (after);
g_date_time_unref (before);
g_bookmark_file_set_visited (bookmark,
"file:///tmp/schedule5.ps",
(time_t)-1);
t = g_bookmark_file_get_visited (bookmark,
"file:///tmp/schedule5.ps",
&error);
before = g_date_time_new_now_utc ();
g_bookmark_file_set_visited_date_time (bookmark,
"file:///tmp/schedule5.ps",
before);
t = g_bookmark_file_get_visited_date_time (bookmark,
"file:///tmp/schedule5.ps",
&error);
g_assert_no_error (error);
time (&after);
g_assert_cmpint (before, <=, t);
g_assert_cmpint (t, <=, after);
after = g_date_time_new_now_utc ();
g_assert_cmpint (g_date_time_compare (before, t), <=, 0);
g_assert_cmpint (g_date_time_compare (t, after), <=, 0);
g_date_time_unref (after);
g_date_time_unref (before);
g_bookmark_file_set_icon (bookmark,
"file:///tmp/schedule6.ps",
@ -271,16 +279,16 @@ test_misc (void)
g_assert_false (res);
g_clear_error (&error);
time (&before);
before = g_date_time_new_now_utc ();
g_bookmark_file_add_application (bookmark,
"file:///tmp/schedule7.ps",
NULL, NULL);
res = g_bookmark_file_get_app_info (bookmark,
"file:///tmp/schedule7.ps",
g_get_application_name (),
&exec, &count, &t,
&error);
res = g_bookmark_file_get_application_info (bookmark,
"file:///tmp/schedule7.ps",
g_get_application_name (),
&exec, &count, &t,
&error);
g_assert_no_error (error);
g_assert_true (res);
cmd = g_strconcat (g_get_prgname (), " file:///tmp/schedule7.ps", NULL);
@ -288,13 +296,111 @@ test_misc (void)
g_free (cmd);
g_free (exec);
g_assert_cmpuint (count, ==, 1);
time (&after);
g_assert_cmpint (before, <=, t);
g_assert_cmpint (t, <=, after);
after = g_date_time_new_now_utc ();
g_assert_cmpint (g_date_time_compare (before, t), <=, 0);
g_assert_cmpint (g_date_time_compare (t, after), <=, 0);
g_date_time_unref (after);
g_date_time_unref (before);
g_bookmark_file_free (bookmark);
}
static void
test_deprecated (void)
{
GBookmarkFile *file = NULL;
GError *local_error = NULL;
time_t t, now;
gboolean retval;
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
now = time (NULL);
file = g_bookmark_file_new ();
/* added */
g_bookmark_file_set_added (file, "file://test", -1);
t = g_bookmark_file_get_added (file, "file://test", &local_error);
g_assert_no_error (local_error);
g_assert_cmpint (t, >=, now);
g_bookmark_file_set_added (file, "file://test", 1234);
t = g_bookmark_file_get_added (file, "file://test", &local_error);
g_assert_no_error (local_error);
g_assert_cmpint (t, ==, 1234);
t = g_bookmark_file_get_added (file, "file://not-exist", &local_error);
g_assert_error (local_error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
g_assert_cmpint (t, ==, (time_t) -1);
g_clear_error (&local_error);
/* modified */
g_bookmark_file_set_modified (file, "file://test", -1);
t = g_bookmark_file_get_modified (file, "file://test", &local_error);
g_assert_no_error (local_error);
g_assert_cmpint (t, >=, now);
g_bookmark_file_set_modified (file, "file://test", 1234);
t = g_bookmark_file_get_modified (file, "file://test", &local_error);
g_assert_no_error (local_error);
g_assert_cmpint (t, ==, 1234);
t = g_bookmark_file_get_modified (file, "file://not-exist", &local_error);
g_assert_error (local_error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
g_assert_cmpint (t, ==, (time_t) -1);
g_clear_error (&local_error);
/* visited */
g_bookmark_file_set_visited (file, "file://test", -1);
t = g_bookmark_file_get_visited (file, "file://test", &local_error);
g_assert_no_error (local_error);
g_assert_cmpint (t, >=, now);
g_bookmark_file_set_visited (file, "file://test", 1234);
t = g_bookmark_file_get_visited (file, "file://test", &local_error);
g_assert_no_error (local_error);
g_assert_cmpint (t, ==, 1234);
t = g_bookmark_file_get_visited (file, "file://not-exist", &local_error);
g_assert_error (local_error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
g_assert_cmpint (t, ==, (time_t) -1);
g_clear_error (&local_error);
/* set app info */
retval = g_bookmark_file_set_app_info (file, "file://test", "app", "/path/to/app", 1, -1, &local_error);
g_assert_no_error (local_error);
g_assert_true (retval);
retval = g_bookmark_file_get_app_info (file, "file://test", "app", NULL, NULL, &t, &local_error);
g_assert_no_error (local_error);
g_assert_true (retval);
g_assert_cmpint (t, >=, now);
retval = g_bookmark_file_set_app_info (file, "file://test", "app", "/path/to/app", 1, 1234, &local_error);
g_assert_no_error (local_error);
g_assert_true (retval);
retval = g_bookmark_file_get_app_info (file, "file://test", "app", NULL, NULL, &t, &local_error);
g_assert_no_error (local_error);
g_assert_true (retval);
g_assert_cmpint (t, ==, 1234);
retval = g_bookmark_file_get_app_info (file, "file://test", "app", NULL, NULL, NULL, &local_error);
g_assert_no_error (local_error);
g_assert_true (retval);
retval = g_bookmark_file_get_app_info (file, "file://not-exist", "app", NULL, NULL, &t, &local_error);
g_assert_error (local_error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
g_assert_false (retval);
g_clear_error (&local_error);
g_bookmark_file_free (file);
G_GNUC_END_IGNORE_DEPRECATIONS
}
static gboolean
test_load (GBookmarkFile *bookmark,
const gchar *filename)
@ -349,8 +455,8 @@ test_modify (GBookmarkFile *bookmark)
{
gchar *text;
guint count;
time_t stamp;
time_t now;
GDateTime *stamp;
GDateTime *now = NULL;
GError *error = NULL;
gchar **groups;
gsize length;
@ -380,17 +486,17 @@ test_modify (GBookmarkFile *bookmark)
g_bookmark_file_set_title (bookmark, TEST_URI_0, "a title");
g_bookmark_file_set_description (bookmark, TEST_URI_0, "a description");
g_bookmark_file_set_is_private (bookmark, TEST_URI_0, TRUE);
time (&now);
g_bookmark_file_set_added (bookmark, TEST_URI_0, now);
g_bookmark_file_set_visited (bookmark, TEST_URI_0, now);
now = g_date_time_new_now_utc ();
g_bookmark_file_set_added_date_time (bookmark, TEST_URI_0, now);
g_bookmark_file_set_visited_date_time (bookmark, TEST_URI_0, now);
g_bookmark_file_set_icon (bookmark, TEST_URI_0, "testicon", "image/png");
/* Check the modification date by itself, as its updated whenever we modify
* other properties. */
g_bookmark_file_set_modified (bookmark, TEST_URI_0, now);
stamp = g_bookmark_file_get_modified (bookmark, TEST_URI_0, &error);
g_bookmark_file_set_modified_date_time (bookmark, TEST_URI_0, now);
stamp = g_bookmark_file_get_modified_date_time (bookmark, TEST_URI_0, &error);
g_assert_no_error (error);
g_assert_cmpint (stamp, ==, now);
g_assert_cmpint (g_date_time_compare (stamp, now), ==, 0);
text = g_bookmark_file_get_title (bookmark, TEST_URI_0, &error);
g_assert_no_error (error);
@ -402,12 +508,12 @@ test_modify (GBookmarkFile *bookmark)
g_free (text);
g_assert_true (g_bookmark_file_get_is_private (bookmark, TEST_URI_0, &error));
g_assert_no_error (error);
stamp = g_bookmark_file_get_added (bookmark, TEST_URI_0, &error);
stamp = g_bookmark_file_get_added_date_time (bookmark, TEST_URI_0, &error);
g_assert_no_error (error);
g_assert_cmpint (stamp, ==, now);
stamp = g_bookmark_file_get_visited (bookmark, TEST_URI_0, &error);
g_assert_cmpint (g_date_time_compare (stamp, now), ==, 0);
stamp = g_bookmark_file_get_visited_date_time (bookmark, TEST_URI_0, &error);
g_assert_no_error (error);
g_assert_cmpint (stamp, ==, now);
g_assert_cmpint (g_date_time_compare (stamp, now), ==, 0);
g_assert_true (g_bookmark_file_get_icon (bookmark, TEST_URI_0, &icon, &mime, &error));
g_assert_no_error (error);
g_assert_cmpstr (icon, ==, "testicon");
@ -425,13 +531,13 @@ test_modify (GBookmarkFile *bookmark)
g_bookmark_file_get_is_private (bookmark, TEST_URI_1, &error);
g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
g_clear_error (&error);
g_bookmark_file_get_added (bookmark, TEST_URI_1, &error);
g_bookmark_file_get_added_date_time (bookmark, TEST_URI_1, &error);
g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
g_clear_error (&error);
g_bookmark_file_get_modified (bookmark, TEST_URI_1, &error);
g_bookmark_file_get_modified_date_time (bookmark, TEST_URI_1, &error);
g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
g_clear_error (&error);
g_bookmark_file_get_visited (bookmark, TEST_URI_1, &error);
g_bookmark_file_get_visited_date_time (bookmark, TEST_URI_1, &error);
g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_URI_NOT_FOUND);
g_clear_error (&error);
if (g_test_verbose ())
@ -445,14 +551,14 @@ test_modify (GBookmarkFile *bookmark)
TEST_APP_NAME,
TEST_APP_EXEC);
g_assert_true (g_bookmark_file_has_application (bookmark, TEST_URI_0, TEST_APP_NAME, NULL));
g_bookmark_file_get_app_info (bookmark, TEST_URI_0, TEST_APP_NAME,
&text,
&count,
&stamp,
&error);
g_bookmark_file_get_application_info (bookmark, TEST_URI_0, TEST_APP_NAME,
&text,
&count,
&stamp,
&error);
g_assert_no_error (error);
g_assert_cmpuint (count, ==, 1);
g_assert_cmpint (stamp, ==, g_bookmark_file_get_modified (bookmark, TEST_URI_0, NULL));
g_assert_cmpint (g_date_time_compare (stamp, g_bookmark_file_get_modified_date_time (bookmark, TEST_URI_0, NULL)), <=, 0);
g_free (text);
g_assert_true (g_bookmark_file_remove_application (bookmark, TEST_URI_0, TEST_APP_NAME, &error));
g_assert_no_error (error);
@ -463,11 +569,11 @@ test_modify (GBookmarkFile *bookmark)
g_assert_cmpstr (apps[0], ==, TEST_APP_NAME);
g_strfreev (apps);
g_bookmark_file_get_app_info (bookmark, TEST_URI_0, "fail",
&text,
&count,
&stamp,
&error);
g_bookmark_file_get_application_info (bookmark, TEST_URI_0, "fail",
&text,
&count,
&stamp,
&error);
g_assert_error (error, G_BOOKMARK_FILE_ERROR, G_BOOKMARK_FILE_ERROR_APP_NOT_REGISTERED);
g_clear_error (&error);
@ -508,7 +614,9 @@ test_modify (GBookmarkFile *bookmark)
g_clear_error (&error);
if (g_test_verbose ())
g_printerr ("ok\n");
g_date_time_unref (now);
return TRUE;
}
@ -563,6 +671,7 @@ main (int argc, char *argv[])
g_test_add_func ("/bookmarks/to-file", test_to_file);
g_test_add_func ("/bookmarks/move-item", test_move_item);
g_test_add_func ("/bookmarks/misc", test_misc);
g_test_add_func ("/bookmarks/deprecated", test_deprecated);
error = NULL;
path = g_test_build_filename (G_TEST_DIST, "bookmarks", NULL);