[evolution-data-server] Convert camel_store_info_path() macro to a function.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Convert camel_store_info_path() macro to a function.
- Date: Fri, 16 Aug 2013 18:06:59 +0000 (UTC)
commit 792bd292c4d72a6526f241dfd9643ed6cf67e966
Author: Matthew Barnes <mbarnes redhat com>
Date: Fri Aug 16 10:36:49 2013 -0400
Convert camel_store_info_path() macro to a function.
camel/camel-imapx-store.c | 40 +++++++++++++++++++++-------------------
camel/camel-store-summary.c | 20 ++++++++++++++++++++
camel/camel-store-summary.h | 8 +++-----
3 files changed, 44 insertions(+), 24 deletions(-)
---
diff --git a/camel/camel-imapx-store.c b/camel/camel-imapx-store.c
index dac466f..1e7a2bc 100644
--- a/camel/camel-imapx-store.c
+++ b/camel/camel-imapx-store.c
@@ -853,20 +853,21 @@ rename_folder_info (CamelIMAPXStore *imapx_store,
const gchar *old_name,
const gchar *new_name)
{
+ CamelStoreSummary *summary;
gint i, count;
CamelStoreInfo *si;
gint olen = strlen (old_name);
const gchar *path;
gchar *npath, *nfull;
- count = camel_store_summary_count (
- (CamelStoreSummary *) imapx_store->summary);
+ summary = CAMEL_STORE_SUMMARY (imapx_store->summary);
+
+ count = camel_store_summary_count (summary);
for (i = 0; i < count; i++) {
- si = camel_store_summary_index (
- (CamelStoreSummary *) imapx_store->summary, i);
+ si = camel_store_summary_index (summary, i);
if (si == NULL)
continue;
- path = camel_store_info_path (imapx_store->summary, si);
+ path = camel_store_info_path (summary, si);
if (strncmp (path, old_name, olen) == 0) {
if (strlen (path) > olen)
npath = g_strdup_printf ("%s/%s", new_name, path + olen + 1);
@@ -877,21 +878,19 @@ rename_folder_info (CamelIMAPXStore *imapx_store,
imapx_store->dir_sep);
camel_store_info_set_string (
- (CamelStoreSummary *) imapx_store->summary,
- si, CAMEL_STORE_INFO_PATH, npath);
+ summary, si,
+ CAMEL_STORE_INFO_PATH, npath);
camel_store_info_set_string (
- (CamelStoreSummary *) imapx_store->summary,
- si, CAMEL_IMAPX_STORE_INFO_FULL_NAME, nfull);
+ summary, si,
+ CAMEL_IMAPX_STORE_INFO_FULL_NAME, nfull);
- camel_store_summary_touch (
- (CamelStoreSummary *) imapx_store->summary);
+ camel_store_summary_touch (summary);
g_free (nfull);
g_free (npath);
}
- camel_store_summary_info_unref (
- (CamelStoreSummary *) imapx_store->summary, si);
+ camel_store_summary_info_unref (summary, si);
}
}
@@ -1112,7 +1111,8 @@ add_folder_to_summary (CamelIMAPXStore *imapx_store,
fi = camel_folder_info_new ();
fi->full_name = g_strdup (camel_store_info_path (
- imapx_store->summary, si));
+ CAMEL_STORE_SUMMARY (imapx_store->summary),
+ (CamelStoreInfo *) si));
if (g_ascii_strcasecmp (fi->full_name, "inbox") == 0) {
flags |= CAMEL_FOLDER_SYSTEM;
flags |= CAMEL_FOLDER_TYPE_INBOX;
@@ -1802,15 +1802,17 @@ imapx_store_create_folder_sync (CamelStore *store,
imapx_server, full_name, cancellable, error);
if (success) {
+ CamelStoreSummary *summary;
CamelIMAPXStoreInfo *si;
+ const gchar *path;
+
+ summary = CAMEL_STORE_SUMMARY (imapx_store->summary);
si = camel_imapx_store_summary_add_from_full (
imapx_store->summary, full_name, dir_sep);
- camel_store_summary_save (
- (CamelStoreSummary *) imapx_store->summary);
- fi = imapx_build_folder_info (
- imapx_store,
- camel_store_info_path (imapx_store->summary, si));
+ camel_store_summary_save (summary);
+ path = camel_store_info_path (summary, (CamelStoreInfo *) si);
+ fi = imapx_build_folder_info (imapx_store, path);
fi->flags |= CAMEL_FOLDER_NOCHILDREN;
camel_store_folder_created (store, fi);
}
diff --git a/camel/camel-store-summary.c b/camel/camel-store-summary.c
index 43d0756..7ddc0aa 100644
--- a/camel/camel-store-summary.c
+++ b/camel/camel-store-summary.c
@@ -935,6 +935,26 @@ camel_store_info_set_string (CamelStoreSummary *summary,
}
/**
+ * camel_store_info_path:
+ * @summary: a #CamelStoreSummary
+ * @info: a #CamelStoreInfo
+ *
+ * Returns the path string from @info.
+ *
+ * Returns: the path string from @info
+ **/
+const gchar *
+camel_store_info_path (CamelStoreSummary *summary,
+ CamelStoreInfo *info)
+{
+ g_return_val_if_fail (CAMEL_IS_STORE_SUMMARY (summary), NULL);
+ g_return_val_if_fail (info != NULL, NULL);
+
+ /* XXX Not thread-safe; should return a duplicate. */
+ return info->path;
+}
+
+/**
* camel_store_summary_lock:
* @summary: a #CamelStoreSummary
* @lock: lock type to lock
diff --git a/camel/camel-store-summary.h b/camel/camel-store-summary.h
index f17035d..f14f4c6 100644
--- a/camel/camel-store-summary.h
+++ b/camel/camel-store-summary.h
@@ -206,12 +206,10 @@ void camel_store_info_set_string (CamelStoreSummary *summary,
gint type,
const gchar *value);
+const gchar * camel_store_info_path (CamelStoreSummary *summary,
+ CamelStoreInfo *info);
+
/* helper macro's */
-#define camel_store_info_path(summary, info) \
- (camel_store_info_string ( \
- (CamelStoreSummary *) summary, \
- (const CamelStoreInfo *) info, \
- CAMEL_STORE_INFO_PATH))
#define camel_store_info_name(summary, info) \
(camel_store_info_string ( \
(CamelStoreSummary *) summary, \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]