summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2010-11-04 23:29:34 -0400
committerMartin Pitt <martin.pitt@ubuntu.com>2010-11-04 23:29:34 -0400
commita4353d08015354898b7c53c494d969875e28c23a (patch)
tree726fc3aeb918fad0a1b8624aa906d6ab548ce785 /src
parent809eefc1453871f5a48871b2dde71face2f247f9 (diff)
UpHistory: Add method to set history dir
Add up_history_set_directory() method to change the directory for history files. This is mainly useful for our test suite.
Diffstat (limited to 'src')
-rw-r--r--src/up-history.c14
-rw-r--r--src/up-history.h3
2 files changed, 16 insertions, 1 deletions
diff --git a/src/up-history.c b/src/up-history.c
index eebbe44..24f9672 100644
--- a/src/up-history.c
+++ b/src/up-history.c
@@ -53,6 +53,7 @@ struct UpHistoryPrivate
GPtrArray *data_time_empty;
guint save_id;
guint max_data_age;
+ gchar *dir;
};
enum {
@@ -394,12 +395,22 @@ up_history_get_filename (UpHistory *history, const gchar *type)
gchar *filename;
filename = g_strdup_printf ("history-%s-%s.dat", type, history->priv->id);
- path = g_build_filename (PACKAGE_LOCALSTATE_DIR, "lib", "upower", filename, NULL);
+ path = g_build_filename (history->priv->dir, filename, NULL);
g_free (filename);
return path;
}
/**
+ * up_history_set_directory:
+ **/
+void
+up_history_set_directory (UpHistory *history, const gchar *dir)
+{
+ g_free (history->priv->dir);
+ history->priv->dir = g_strdup (dir);
+}
+
+/**
* up_history_array_to_file:
* @list: a valid #GPtrArray instance
* @filename: a filename
@@ -877,6 +888,7 @@ up_history_init (UpHistory *history)
history->priv->data_time_empty = g_ptr_array_new_with_free_func ((GDestroyNotify) g_object_unref);
history->priv->save_id = 0;
history->priv->max_data_age = UP_HISTORY_DEFAULT_MAX_DATA_AGE;
+ history->priv->dir = g_build_filename (PACKAGE_LOCALSTATE_DIR, "lib", "upower", NULL);
}
/**
diff --git a/src/up-history.h b/src/up-history.h
index 50b506d..87af5e3 100644
--- a/src/up-history.h
+++ b/src/up-history.h
@@ -84,6 +84,9 @@ void up_history_set_max_data_age (UpHistory *history,
guint max_data_age);
gboolean up_history_save_data (UpHistory *history);
+void up_history_set_directory (UpHistory *history,
+ const gchar *dir);
+
G_END_DECLS
#endif /* __UP_HISTORY_H */