[balsa/gtk3] Cast new mailboxes as LibBalsaMailbox
- From: Peter Bloomfield <PeterB src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [balsa/gtk3] Cast new mailboxes as LibBalsaMailbox
- Date: Wed, 22 May 2013 17:15:16 +0000 (UTC)
commit 8e71e9b4c9eb07ef475a0e524e13608645da37f4
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date: Wed May 22 13:14:29 2013 -0400
Cast new mailboxes as LibBalsaMailbox
Cast new mailboxes as LibBalsaMailbox, to reduce static and
dynamic casting.
* libbalsa/mailbox_imap.c (libbalsa_mailbox_imap_new): return
new mailbox as (LibBalsaMailbox *).
* libbalsa/mailbox_imap.h: ditto.
* libbalsa/mailbox_local.c: ditto.
* libbalsa/mailbox_local.h: ditto.
* libbalsa/mailbox_maildir.c (libbalsa_mailbox_maildir_new):
ditto.
* libbalsa/mailbox_maildir.h: ditto.
* libbalsa/mailbox_mbox.c (libbalsa_mailbox_mbox_new): ditto.
* libbalsa/mailbox_mbox.h: ditto.
* libbalsa/mailbox_mh.c (libbalsa_mailbox_mh_new): ditto.
* libbalsa/mailbox_mh.h: ditto.
* libinit_balsa/assistant_page_directory.c
(unconditional_mailbox): remove static casts to (LibBalsaMailbox *).
* src/mailbox-node.c (imap_scan_attach_mailbox),
(balsa_mailbox_node_new_imap), (add_local_mailbox): avoid
dynmaic casts to LIBBALSA_MAILBOX.
ChangeLog | 23 +++++++++++++++++++++++
libbalsa/mailbox_imap.c | 4 ++--
libbalsa/mailbox_imap.h | 2 +-
libbalsa/mailbox_local.c | 2 +-
libbalsa/mailbox_local.h | 3 ++-
libbalsa/mailbox_maildir.c | 4 ++--
libbalsa/mailbox_maildir.h | 3 ++-
libbalsa/mailbox_mbox.c | 8 ++++----
libbalsa/mailbox_mbox.h | 3 ++-
libbalsa/mailbox_mh.c | 4 ++--
libbalsa/mailbox_mh.h | 3 ++-
libinit_balsa/assistant_page_directory.c | 9 ++++-----
src/mailbox-node.c | 24 +++++++++++++-----------
13 files changed, 60 insertions(+), 32 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 5ffc363..8561bfe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,28 @@
2013-05-22 Peter Bloomfield
+ Cast new mailboxes as LibBalsaMailbox, to reduce static and
+ dynamic casting.
+
+ * libbalsa/mailbox_imap.c (libbalsa_mailbox_imap_new): return
+ new mailbox as (LibBalsaMailbox *).
+ * libbalsa/mailbox_imap.h: ditto.
+ * libbalsa/mailbox_local.c: ditto.
+ * libbalsa/mailbox_local.h: ditto.
+ * libbalsa/mailbox_maildir.c (libbalsa_mailbox_maildir_new):
+ ditto.
+ * libbalsa/mailbox_maildir.h: ditto.
+ * libbalsa/mailbox_mbox.c (libbalsa_mailbox_mbox_new): ditto.
+ * libbalsa/mailbox_mbox.h: ditto.
+ * libbalsa/mailbox_mh.c (libbalsa_mailbox_mh_new): ditto.
+ * libbalsa/mailbox_mh.h: ditto.
+ * libinit_balsa/assistant_page_directory.c
+ (unconditional_mailbox): remove static casts to (LibBalsaMailbox *).
+ * src/mailbox-node.c (imap_scan_attach_mailbox),
+ (balsa_mailbox_node_new_imap), (add_local_mailbox): avoid
+ dynmaic casts to LIBBALSA_MAILBOX.
+
+2013-05-22 Peter Bloomfield
+
* src/balsa-message.c (part_info_init): do not mess with scroll
bars.
* src/balsa-mime-widget-text.c (balsa_mime_widget_new_text):
diff --git a/libbalsa/mailbox_imap.c b/libbalsa/mailbox_imap.c
index 8913154..dc921bb 100644
--- a/libbalsa/mailbox_imap.c
+++ b/libbalsa/mailbox_imap.c
@@ -349,10 +349,10 @@ libbalsa_mailbox_imap_finalize(GObject * object)
G_OBJECT_CLASS(parent_class)->finalize(object);
}
-LibBalsaMailboxImap*
+LibBalsaMailbox*
libbalsa_mailbox_imap_new(void)
{
- LibBalsaMailboxImap *mailbox;
+ LibBalsaMailbox *mailbox;
mailbox = g_object_new(LIBBALSA_TYPE_MAILBOX_IMAP, NULL);
return mailbox;
diff --git a/libbalsa/mailbox_imap.h b/libbalsa/mailbox_imap.h
index 07732a3..a26d2a2 100644
--- a/libbalsa/mailbox_imap.h
+++ b/libbalsa/mailbox_imap.h
@@ -43,7 +43,7 @@ typedef struct _LibBalsaMailboxImapClass LibBalsaMailboxImapClass;
#define POINTER_TO_UID(p) GPOINTER_TO_UINT(p)
#define UID_TO_POINTER(p) GUINT_TO_POINTER(p)
-LibBalsaMailboxImap *libbalsa_mailbox_imap_new(void);
+LibBalsaMailbox *libbalsa_mailbox_imap_new(void);
void libbalsa_mailbox_imap_update_url(LibBalsaMailboxImap* mailbox);
void libbalsa_mailbox_imap_set_path(LibBalsaMailboxImap * mailbox,
diff --git a/libbalsa/mailbox_local.c b/libbalsa/mailbox_local.c
index 7f4858a..9675f77 100644
--- a/libbalsa/mailbox_local.c
+++ b/libbalsa/mailbox_local.c
@@ -198,7 +198,7 @@ libbalsa_mailbox_local_init(LibBalsaMailboxLocal * mailbox)
mailbox->save_tree_id = 0;
}
-GObject *
+LibBalsaMailbox *
libbalsa_mailbox_local_new(const gchar * path, gboolean create)
{
GType magic_type = libbalsa_mailbox_type_from_path(path);
diff --git a/libbalsa/mailbox_local.h b/libbalsa/mailbox_local.h
index 054896c..91e4b6e 100644
--- a/libbalsa/mailbox_local.h
+++ b/libbalsa/mailbox_local.h
@@ -96,7 +96,8 @@ struct _LibBalsaMailboxLocalClass {
LibBalsaMailboxLocalAddMessageFunc *add_message;
};
-GObject *libbalsa_mailbox_local_new(const gchar * path, gboolean create);
+LibBalsaMailbox *libbalsa_mailbox_local_new(const gchar * path,
+ gboolean create);
gint libbalsa_mailbox_local_set_path(LibBalsaMailboxLocal * mailbox,
const gchar * path, gboolean create);
void libbalsa_mailbox_local_set_threading_info(LibBalsaMailboxLocal *
diff --git a/libbalsa/mailbox_maildir.c b/libbalsa/mailbox_maildir.c
index 28f7902..cf90543 100644
--- a/libbalsa/mailbox_maildir.c
+++ b/libbalsa/mailbox_maildir.c
@@ -259,7 +259,7 @@ lbm_maildir_set_path(LibBalsaMailboxLocal * local, const gchar * path)
lbm_maildir_set_subdirs(LIBBALSA_MAILBOX_MAILDIR(local), path);
}
-GObject *
+LibBalsaMailbox *
libbalsa_mailbox_maildir_new(const gchar * path, gboolean create)
{
LibBalsaMailbox *mailbox;
@@ -274,7 +274,7 @@ libbalsa_mailbox_maildir_new(const gchar * path, gboolean create)
return NULL;
}
- return G_OBJECT(mailbox);
+ return mailbox;
}
static void
diff --git a/libbalsa/mailbox_maildir.h b/libbalsa/mailbox_maildir.h
index 632078d..fde3456 100644
--- a/libbalsa/mailbox_maildir.h
+++ b/libbalsa/mailbox_maildir.h
@@ -54,7 +54,8 @@ struct _LibBalsaMailboxMaildirClass {
};
GType libbalsa_mailbox_maildir_get_type(void);
-GObject *libbalsa_mailbox_maildir_new(const gchar * path, gboolean create);
+LibBalsaMailbox *libbalsa_mailbox_maildir_new(const gchar * path,
+ gboolean create);
#endif
diff --git a/libbalsa/mailbox_mbox.c b/libbalsa/mailbox_mbox.c
index 090e69c..06296a7 100644
--- a/libbalsa/mailbox_mbox.c
+++ b/libbalsa/mailbox_mbox.c
@@ -225,7 +225,7 @@ lbm_mbox_check_files(const gchar * path, gboolean create)
return 0;
}
-GObject *
+LibBalsaMailbox *
libbalsa_mailbox_mbox_new(const gchar * path, gboolean create)
{
LibBalsaMailbox *mailbox;
@@ -233,14 +233,14 @@ libbalsa_mailbox_mbox_new(const gchar * path, gboolean create)
mailbox = g_object_new(LIBBALSA_TYPE_MAILBOX_MBOX, NULL);
mailbox->is_directory = FALSE;
-
+
if (libbalsa_mailbox_local_set_path(LIBBALSA_MAILBOX_LOCAL(mailbox),
path, create) != 0) {
g_object_unref(mailbox);
return NULL;
}
-
- return G_OBJECT(mailbox);
+
+ return mailbox;
}
/* Helper: seek to offset, and return TRUE if the seek succeeds and a
diff --git a/libbalsa/mailbox_mbox.h b/libbalsa/mailbox_mbox.h
index 74c8cd4..718a260 100644
--- a/libbalsa/mailbox_mbox.h
+++ b/libbalsa/mailbox_mbox.h
@@ -40,5 +40,6 @@ typedef struct _LibBalsaMailboxMbox LibBalsaMailboxMbox;
typedef struct _LibBalsaMailboxMboxClass LibBalsaMailboxMboxClass;
GType libbalsa_mailbox_mbox_get_type(void);
-GObject *libbalsa_mailbox_mbox_new(const gchar * path, gboolean create);
+LibBalsaMailbox *libbalsa_mailbox_mbox_new(const gchar * path,
+ gboolean create);
#endif
diff --git a/libbalsa/mailbox_mh.c b/libbalsa/mailbox_mh.c
index 0c1c468..66cd304 100644
--- a/libbalsa/mailbox_mh.c
+++ b/libbalsa/mailbox_mh.c
@@ -216,7 +216,7 @@ lbm_mh_set_path(LibBalsaMailboxLocal * local, const gchar * path)
lbm_mh_set_sequences_filename(LIBBALSA_MAILBOX_MH(local), path);
}
-GObject *
+LibBalsaMailbox *
libbalsa_mailbox_mh_new(const gchar * path, gboolean create)
{
LibBalsaMailbox *mailbox;
@@ -231,7 +231,7 @@ libbalsa_mailbox_mh_new(const gchar * path, gboolean create)
return NULL;
}
- return G_OBJECT(mailbox);
+ return mailbox;
}
static void
diff --git a/libbalsa/mailbox_mh.h b/libbalsa/mailbox_mh.h
index f4d6ac9..1de8f97 100644
--- a/libbalsa/mailbox_mh.h
+++ b/libbalsa/mailbox_mh.h
@@ -54,6 +54,7 @@ struct _LibBalsaMailboxMhClass {
};
GType libbalsa_mailbox_mh_get_type(void);
-GObject *libbalsa_mailbox_mh_new(const gchar * path, gboolean create);
+LibBalsaMailbox *libbalsa_mailbox_mh_new(const gchar * path,
+ gboolean create);
#endif
diff --git a/libinit_balsa/assistant_page_directory.c b/libinit_balsa/assistant_page_directory.c
index f38e1ac..6272c7d 100644
--- a/libinit_balsa/assistant_page_directory.c
+++ b/libinit_balsa/assistant_page_directory.c
@@ -116,7 +116,7 @@ unconditional_mailbox(const gchar * path, const gchar * prettyname,
case U_IMAPS:
ssl = TRUE;
case U_IMAP:
- *box = (LibBalsaMailbox *) libbalsa_mailbox_imap_new();
+ *box = libbalsa_mailbox_imap_new();
libbalsa_mailbox_imap_set_path((LibBalsaMailboxImap *) * box,
url.path);
is_remote = TRUE;
@@ -128,11 +128,10 @@ unconditional_mailbox(const gchar * path, const gchar * prettyname,
is_remote = TRUE;
break;
case U_FILE:
- *box =
- (LibBalsaMailbox *) libbalsa_mailbox_local_new(url.path, TRUE);
+ *box = libbalsa_mailbox_local_new(url.path, TRUE);
break;
default:
- *box = (LibBalsaMailbox *) libbalsa_mailbox_local_new(path, TRUE);
+ *box = libbalsa_mailbox_local_new(path, TRUE);
if (!*box) {
*error = g_strdup_printf(_("Could not create mailbox"
" at path \"%s\"\n"), path);
@@ -155,7 +154,7 @@ unconditional_mailbox(const gchar * path, const gchar * prettyname,
char tmp[32] = "/tmp/balsa.XXXXXX";
/* Don't fail if you can't create the spool mailbox. */
close(mkstemp(tmp));
- *box = (LibBalsaMailbox*)libbalsa_mailbox_local_new(tmp, FALSE);
+ *box = libbalsa_mailbox_local_new(tmp, FALSE);
if (*box) {
free((*box)->url);
(*box)->url = g_strdup_printf("file://%s",path);
diff --git a/src/mailbox-node.c b/src/mailbox-node.c
index 8a4b325..e06e701 100644
--- a/src/mailbox-node.c
+++ b/src/mailbox-node.c
@@ -412,6 +412,7 @@ load_mailbox_view(BalsaMailboxNode * mbnode)
static gboolean
imap_scan_attach_mailbox(BalsaMailboxNode * mbnode, imap_scan_item * isi)
{
+ LibBalsaMailbox *mailbox;
LibBalsaMailboxImap *m;
/* If the mailbox was added from the config file, it is already
@@ -424,26 +425,28 @@ imap_scan_attach_mailbox(BalsaMailboxNode * mbnode, imap_scan_item * isi)
if (LIBBALSA_IS_MAILBOX_IMAP(mbnode->mailbox))
/* it already has a mailbox */
return FALSE;
- m = LIBBALSA_MAILBOX_IMAP(libbalsa_mailbox_imap_new());
+
+ mailbox = libbalsa_mailbox_imap_new();
+ m = LIBBALSA_MAILBOX_IMAP(mailbox);
libbalsa_mailbox_remote_set_server(LIBBALSA_MAILBOX_REMOTE(m),
mbnode->server);
libbalsa_mailbox_imap_set_path(m, isi->fn);
if(balsa_app.debug)
printf("imap_scan_attach_mailbox: add mbox of name %s "
- "(full path %s)\n", isi->fn, LIBBALSA_MAILBOX(m)->url);
+ "(full path %s)\n", isi->fn, mailbox->url);
/* avoid allocating the name again: */
- LIBBALSA_MAILBOX(m)->name = mbnode->name;
+ mailbox->name = mbnode->name;
mbnode->name = NULL;
- mbnode->mailbox = LIBBALSA_MAILBOX(m);
+ mbnode->mailbox = mailbox;
load_mailbox_view(mbnode);
if (isi->special) {
if (*isi->special)
g_object_remove_weak_pointer(G_OBJECT(*isi->special),
(gpointer) isi->special);
- *isi->special = LIBBALSA_MAILBOX(m);
+ *isi->special = mailbox;
g_object_add_weak_pointer(G_OBJECT(m), (gpointer) isi->special);
if (isi->special == &balsa_app.outbox)
- LIBBALSA_MAILBOX(m)->no_reassemble = TRUE;
+ mailbox->no_reassemble = TRUE;
}
return TRUE;
@@ -654,7 +657,7 @@ balsa_mailbox_node_new_imap(LibBalsaServer* s, const char*p)
BalsaMailboxNode * folder = balsa_mailbox_node_new_imap_node(s, p);
g_assert(s);
- folder->mailbox = LIBBALSA_MAILBOX(libbalsa_mailbox_imap_new());
+ folder->mailbox = libbalsa_mailbox_imap_new();
g_object_ref(G_OBJECT(folder->mailbox));
libbalsa_mailbox_remote_set_server(
LIBBALSA_MAILBOX_REMOTE(folder->mailbox), s);
@@ -1220,12 +1223,11 @@ add_local_mailbox(BalsaMailboxNode *root, const gchar * name,
mbnode = remove_special_mailbox_by_url(url, NULL);
if (!mbnode) {
if ( type == LIBBALSA_TYPE_MAILBOX_MH ) {
- mailbox = LIBBALSA_MAILBOX(libbalsa_mailbox_mh_new(path, FALSE));
+ mailbox = libbalsa_mailbox_mh_new(path, FALSE);
} else if ( type == LIBBALSA_TYPE_MAILBOX_MBOX ) {
- mailbox = LIBBALSA_MAILBOX(libbalsa_mailbox_mbox_new(path, FALSE));
+ mailbox = libbalsa_mailbox_mbox_new(path, FALSE);
} else if ( type == LIBBALSA_TYPE_MAILBOX_MAILDIR ) {
- mailbox =
- LIBBALSA_MAILBOX(libbalsa_mailbox_maildir_new(path, FALSE));
+ mailbox = libbalsa_mailbox_maildir_new(path, FALSE);
} else {
/* type is not a valid local mailbox type. */
balsa_information(LIBBALSA_INFORMATION_DEBUG,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]