aboutsummaryrefslogtreecommitdiffstats
path: root/camel
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2000-07-13 04:37:00 +0800
committerDan Winship <danw@src.gnome.org>2000-07-13 04:37:00 +0800
commit540e1d7671ec843c2db2d03810d948f879ac1bfc (patch)
tree93b23a7c4a19ef3db93730064e0a9c5035a04f81 /camel
parent4b7d13b41ff3dd03e8490108f30277f5469d40bf (diff)
downloadgsoc2013-evolution-540e1d7671ec843c2db2d03810d948f879ac1bfc.tar
gsoc2013-evolution-540e1d7671ec843c2db2d03810d948f879ac1bfc.tar.gz
gsoc2013-evolution-540e1d7671ec843c2db2d03810d948f879ac1bfc.tar.bz2
gsoc2013-evolution-540e1d7671ec843c2db2d03810d948f879ac1bfc.tar.lz
gsoc2013-evolution-540e1d7671ec843c2db2d03810d948f879ac1bfc.tar.xz
gsoc2013-evolution-540e1d7671ec843c2db2d03810d948f879ac1bfc.tar.zst
gsoc2013-evolution-540e1d7671ec843c2db2d03810d948f879ac1bfc.zip
Useful default implementations for free_{uids,subfolder_names,summary}.
* camel-folder.c (camel_folder_free_deep, camel_folder_free_shallow, camel_folder_free_nop): Useful default implementations for free_{uids,subfolder_names,summary}. (free_subfolder_names, free_uids): Make these g_warning-ing default implementations. * providers/*/camel-*-folder.c: Use the new functions where appropriate, remove duplicated code. svn path=/trunk/; revision=4120
Diffstat (limited to 'camel')
-rw-r--r--camel/ChangeLog11
-rw-r--r--camel/camel-folder.c71
-rw-r--r--camel/camel-folder.h6
-rw-r--r--camel/providers/imap/camel-imap-folder.c16
-rw-r--r--camel/providers/mbox/camel-mbox-folder.c11
-rw-r--r--camel/providers/nntp/camel-nntp-folder.c22
-rw-r--r--camel/providers/pop3/camel-pop3-folder.c10
-rw-r--r--camel/providers/vee/camel-vee-folder.c9
8 files changed, 90 insertions, 66 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog
index 3b4abd304c..e1918ca7be 100644
--- a/camel/ChangeLog
+++ b/camel/ChangeLog
@@ -1,3 +1,14 @@
+2000-07-12 Dan Winship <danw@helixcode.com>
+
+ * camel-folder.c (camel_folder_free_deep,
+ camel_folder_free_shallow, camel_folder_free_nop): Useful default
+ implementations for free_{uids,subfolder_names,summary}.
+ (free_subfolder_names, free_uids): Make these g_warning-ing
+ default implementations.
+
+ * providers/*/camel-*-folder.c: Use the new functions where
+ appropriate, remove duplicated code.
+
2000-07-12 Peter Williams <peterw@helixcode.com>
* providers/imap/camel-imap-store.c (query_auth_types): Check for
diff --git a/camel/camel-folder.c b/camel/camel-folder.c
index e7af6f6d37..0b1b92b982 100644
--- a/camel/camel-folder.c
+++ b/camel/camel-folder.c
@@ -77,6 +77,8 @@ static void set_message_user_flag (CamelFolder *folder, const char *uid,
static GPtrArray *get_subfolder_names (CamelFolder *folder,
CamelException *ex);
+static void free_subfolder_names (CamelFolder *folder,
+ GPtrArray *array);
static CamelFolder *get_subfolder (CamelFolder *folder,
const gchar *folder_name,
gboolean create,
@@ -162,7 +164,7 @@ camel_folder_class_init (CamelFolderClass *camel_folder_class)
camel_folder_class->get_parent_folder = get_parent_folder;
camel_folder_class->get_parent_store = get_parent_store;
camel_folder_class->get_subfolder_names = get_subfolder_names;
- camel_folder_class->free_subfolder_names = free_uids;
+ camel_folder_class->free_subfolder_names = free_subfolder_names;
camel_folder_class->expunge = expunge;
camel_folder_class->get_message_count = get_message_count;
camel_folder_class->get_unread_message_count = get_unread_message_count;
@@ -532,6 +534,13 @@ camel_folder_get_subfolder_names (CamelFolder *folder, CamelException *ex)
}
+static void
+free_subfolder_names (CamelFolder *folder, GPtrArray *array)
+{
+ g_warning ("CamelFolder::free_subfolder_names not implemented "
+ "for `%s'", gtk_type_name (GTK_OBJECT_TYPE (folder)));
+}
+
/**
* camel_folder_free_subfolder_names:
* @folder: folder object
@@ -952,14 +961,8 @@ camel_folder_get_uids (CamelFolder *folder, CamelException *ex)
static void
free_uids (CamelFolder *folder, GPtrArray *array)
{
- int i;
-
- /* Default implementation: free all of the strings and
- * the array itself.
- */
- for (i = 0; i < array->len; i++)
- g_free (array->pdata[i]);
- g_ptr_array_free (array, TRUE);
+ g_warning ("CamelFolder::free_uids not implemented for `%s'",
+ gtk_type_name (GTK_OBJECT_TYPE (folder)));
}
/**
@@ -1285,3 +1288,53 @@ message_changed (CamelFolder *folder, const char *uid)
}
}
}
+
+
+/**
+ * camel_folder_free_nop:
+ * @folder: a folder
+ * @array: an array of uids, subfolder names, or CamelMessageInfo
+ *
+ * "Frees" the provided array by doing nothing. Used by CamelFolder
+ * subclasses as an implementation for free_uids, free_summary,
+ * or free_subfolder_names when the returned array is "static"
+ * information and should not be freed.
+ **/
+void
+camel_folder_free_nop (CamelFolder *folder, GPtrArray *array)
+{
+ ;
+}
+
+/**
+ * camel_folder_free_shallow:
+ * @folder: a folder
+ * @array: an array of uids, subfolder names, or CamelMessageInfo
+ *
+ * Frees the provided array but not its contents. Used by CamelFolder
+ * subclasses as an implementation for free_uids, free_summary, or
+ * free_subfolder_names when the returned array needs to be freed
+ * but its contents come from "static" information.
+ **/
+void
+camel_folder_free_shallow (CamelFolder *folder, GPtrArray *array)
+{
+ g_ptr_array_free (array, TRUE);
+}
+
+/**
+ * camel_folder_free_deep:
+ * @folder: a folder
+ * @array: an array of uids or subfolder names
+ *
+ * Frees the provided array and its contents. Used by CamelFolder
+ * subclasses as an implementation for free_uids or
+ * free_subfolder_names (but NOT free_summary) when the provided
+ * information was created explicitly by the corresponding get_ call.
+ **/
+void
+camel_folder_free_deep (CamelFolder *folder, GPtrArray *array)
+{
+ g_strfreev ((gchar **)array->pdata);
+ g_ptr_array_free (array, FALSE);
+}
diff --git a/camel/camel-folder.h b/camel/camel-folder.h
index 121a0277cb..392d4901ff 100644
--- a/camel/camel-folder.h
+++ b/camel/camel-folder.h
@@ -312,6 +312,12 @@ void camel_folder_move_message_to (CamelFolder *source,
void camel_folder_freeze (CamelFolder *folder);
void camel_folder_thaw (CamelFolder *folder);
+
+/* For use by subclasses (for free_{uids,summary,subfolder_names}) */
+void camel_folder_free_nop (CamelFolder *folder, GPtrArray *array);
+void camel_folder_free_shallow (CamelFolder *folder, GPtrArray *array);
+void camel_folder_free_deep (CamelFolder *folder, GPtrArray *array);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/camel/providers/imap/camel-imap-folder.c b/camel/providers/imap/camel-imap-folder.c
index 0f704477a6..5165845a32 100644
--- a/camel/providers/imap/camel-imap-folder.c
+++ b/camel/providers/imap/camel-imap-folder.c
@@ -71,7 +71,6 @@ static GPtrArray *imap_get_uids (CamelFolder *folder, CamelException *ex);
static gboolean imap_parse_subfolder_line (gchar *buf, gchar **flags, gchar **sep, gchar **folder);
static GPtrArray *imap_get_subfolder_names (CamelFolder *folder, CamelException *ex);
static GPtrArray *imap_get_summary (CamelFolder *folder, CamelException *ex);
-static void imap_free_summary (CamelFolder *folder, GPtrArray *array);
static CamelMimeMessage *imap_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
static void imap_delete_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
@@ -109,7 +108,9 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->expunge = imap_expunge;
camel_folder_class->get_uids = imap_get_uids;
+ camel_folder_class->free_uids = camel_folder_free_nop;
camel_folder_class->get_subfolder_names = imap_get_subfolder_names;
+ camel_folder_class->free_subfolder_names = camel_folder_free_deep;
camel_folder_class->get_message_count = imap_get_message_count;
camel_folder_class->get_unread_message_count = imap_get_unread_message_count;
@@ -121,7 +122,7 @@ camel_imap_folder_class_init (CamelImapFolderClass *camel_imap_folder_class)
camel_folder_class->get_summary = imap_get_summary;
camel_folder_class->get_message_info = imap_get_message_info;
- camel_folder_class->free_summary = imap_free_summary;
+ camel_folder_class->free_summary = camel_folder_free_nop;
camel_folder_class->search_by_expression = imap_search_by_expression;
@@ -472,8 +473,6 @@ imap_get_unread_message_count (CamelFolder *folder, CamelException *ex)
count++;
}
- imap_free_summary (folder, infolist);
-
return count;
}
@@ -642,8 +641,6 @@ imap_get_uids (CamelFolder *folder, CamelException *ex)
array->pdata[i] = g_strdup (info->uid);
}
- imap_free_summary (folder, infolist);
-
return array;
}
@@ -1240,13 +1237,6 @@ imap_get_summary (CamelFolder *folder, CamelException *ex)
return array;
}
-void
-imap_free_summary (CamelFolder *folder, GPtrArray *array)
-{
- /* no-op */
- return;
-}
-
/* get a single message info, by uid */
static const CamelMessageInfo *
imap_get_message_info (CamelFolder *folder, const char *uid)
diff --git a/camel/providers/mbox/camel-mbox-folder.c b/camel/providers/mbox/camel-mbox-folder.c
index 2f254e1919..6e94456b8b 100644
--- a/camel/providers/mbox/camel-mbox-folder.c
+++ b/camel/providers/mbox/camel-mbox-folder.c
@@ -69,7 +69,6 @@ static void mbox_append_message (CamelFolder *folder, CamelMimeMessage *message,
static GPtrArray *mbox_get_uids (CamelFolder *folder, CamelException *ex);
static GPtrArray *mbox_get_subfolder_names (CamelFolder *folder, CamelException *ex);
static GPtrArray *mbox_get_summary (CamelFolder *folder, CamelException *ex);
-static void mbox_free_summary (CamelFolder *folder, GPtrArray *array);
static CamelMimeMessage *mbox_get_message (CamelFolder *folder, const gchar *uid, CamelException *ex);
static void mbox_expunge (CamelFolder *folder, CamelException *ex);
@@ -105,9 +104,11 @@ camel_mbox_folder_class_init (CamelMboxFolderClass *camel_mbox_folder_class)
camel_folder_class->get_unread_message_count = mbox_get_unread_message_count;
camel_folder_class->append_message = mbox_append_message;
camel_folder_class->get_uids = mbox_get_uids;
+ camel_folder_class->free_uids = camel_folder_free_deep;
camel_folder_class->get_subfolder_names = mbox_get_subfolder_names;
+ camel_folder_class->free_subfolder_names = camel_folder_free_deep;
camel_folder_class->get_summary = mbox_get_summary;
- camel_folder_class->free_summary = mbox_free_summary;
+ camel_folder_class->free_summary = camel_folder_free_nop;
camel_folder_class->expunge = mbox_expunge;
camel_folder_class->get_message = mbox_get_message;
@@ -509,12 +510,6 @@ mbox_get_summary (CamelFolder *folder, CamelException *ex)
return CAMEL_FOLDER_SUMMARY (mbox_folder->summary)->messages;
}
-void
-mbox_free_summary (CamelFolder *folder, GPtrArray *array)
-{
- /* no-op */
-}
-
/* get a single message info, by uid */
static const CamelMessageInfo *
mbox_get_message_info (CamelFolder *folder, const char *uid)
diff --git a/camel/providers/nntp/camel-nntp-folder.c b/camel/providers/nntp/camel-nntp-folder.c
index 00e709b20b..2b41768d36 100644
--- a/camel/providers/nntp/camel-nntp-folder.c
+++ b/camel/providers/nntp/camel-nntp-folder.c
@@ -334,17 +334,6 @@ nntp_folder_get_uids (CamelFolder *folder,
return out;
}
-static void
-nntp_folder_free_uids (CamelFolder *folder,
- GPtrArray *array)
-{
- int i;
- for (i = 0; i < array->len; i ++) {
- g_free (g_ptr_array_index (array, i));
- }
- g_ptr_array_free (array, TRUE /* XXX? */);
-}
-
static GPtrArray *
nntp_folder_get_summary (CamelFolder *folder,
CamelException *ex)
@@ -354,13 +343,6 @@ nntp_folder_get_summary (CamelFolder *folder,
return nntp_folder->summary->messages;
}
-static void
-nntp_folder_free_summary (CamelFolder *folder,
- GPtrArray *summary)
-{
- g_assert (0);
-}
-
static GPtrArray *
nntp_folder_get_subfolder_names (CamelFolder *folder, CamelException *ex)
{
@@ -441,9 +423,9 @@ camel_nntp_folder_class_init (CamelNNTPFolderClass *camel_nntp_folder_class)
camel_folder_class->get_message = nntp_folder_get_message;
camel_folder_class->delete_message = nntp_folder_delete_message;
camel_folder_class->get_uids = nntp_folder_get_uids;
- camel_folder_class->free_uids = nntp_folder_free_uids;
+ camel_folder_class->free_uids = camel_folder_free_deep;
camel_folder_class->get_summary = nntp_folder_get_summary;
- camel_folder_class->free_summary = nntp_folder_free_summary;
+ camel_folder_class->free_summary = camel_folder_free_nop;
camel_folder_class->get_subfolder_names = nntp_folder_get_subfolder_names;
camel_folder_class->free_subfolder_names = nntp_folder_free_subfolder_names;
camel_folder_class->search_by_expression = nntp_folder_search_by_expression;
diff --git a/camel/providers/pop3/camel-pop3-folder.c b/camel/providers/pop3/camel-pop3-folder.c
index fbfb8c6129..713cb646d5 100644
--- a/camel/providers/pop3/camel-pop3-folder.c
+++ b/camel/providers/pop3/camel-pop3-folder.c
@@ -43,7 +43,6 @@ static void pop3_sync (CamelFolder *folder, gboolean expunge,
static gint pop3_get_message_count (CamelFolder *folder, CamelException *ex);
static GPtrArray *pop3_get_uids (CamelFolder *folder, CamelException *ex);
-static void pop3_free_uids (CamelFolder *folder, GPtrArray *uids);
static CamelMimeMessage *pop3_get_message (CamelFolder *folder,
const char *uid,
CamelException *ex);
@@ -66,7 +65,7 @@ camel_pop3_folder_class_init (CamelPop3FolderClass *camel_pop3_folder_class)
camel_folder_class->get_message_count = pop3_get_message_count;
camel_folder_class->get_uids = pop3_get_uids;
- camel_folder_class->free_uids = pop3_free_uids;
+ camel_folder_class->free_uids = camel_folder_free_nop;
camel_folder_class->get_message = pop3_get_message;
camel_folder_class->delete_message = pop3_delete_message;
@@ -327,10 +326,3 @@ pop3_get_uids (CamelFolder *folder, CamelException *ex)
return pop3_folder->uids;
}
-
-static void
-pop3_free_uids (CamelFolder *folder, GPtrArray *uids)
-{
- ;
-}
-
diff --git a/camel/providers/vee/camel-vee-folder.c b/camel/providers/vee/camel-vee-folder.c
index 70f03e6c0e..54417bac64 100644
--- a/camel/providers/vee/camel-vee-folder.c
+++ b/camel/providers/vee/camel-vee-folder.c
@@ -47,7 +47,6 @@ static void vee_sync (CamelFolder *folder, gboolean expunge, CamelException *ex)
static GPtrArray *vee_get_uids (CamelFolder *folder, CamelException *ex);
GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex);
-void vee_free_summary (CamelFolder *folder, GPtrArray *array);
static gint vee_get_message_count (CamelFolder *folder, CamelException *ex);
static gint vee_get_unread_message_count (CamelFolder *folder, CamelException *ex);
@@ -111,8 +110,9 @@ camel_vee_folder_class_init (CamelVeeFolderClass *klass)
folder_class->sync = vee_sync;
folder_class->get_uids = vee_get_uids;
+ folder_class->free_uids = camel_folder_free_deep;
folder_class->get_summary = vee_get_summary;
- folder_class->free_summary = vee_free_summary;
+ folder_class->free_summary = camel_folder_free_nop;
folder_class->get_message = vee_get_message;
folder_class->get_message_info = vee_get_message_info;
@@ -344,11 +344,6 @@ GPtrArray *vee_get_summary (CamelFolder *folder, CamelException *ex)
return vf->messages;
}
-void vee_free_summary (CamelFolder *folder, GPtrArray *array)
-{
- /* no op */
-}
-
static const CamelMessageInfo *vee_get_message_info (CamelFolder *f, const char *uid)
{
CamelVeeFolder *vf = (CamelVeeFolder *)f;