aboutsummaryrefslogtreecommitdiff
path: root/libsylph
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-11-06 09:19:14 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-11-06 09:19:14 +0000
commitb69e098519c056115763a19004c4fcefe4ad49d5 (patch)
tree75f41f45239f18a50afe9f7163671675f42c2604 /libsylph
parent9aa60b8ee830c9ecce85ba76bbd57085ef8bddb5 (diff)
svn s
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2337 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r--libsylph/account.c22
-rw-r--r--libsylph/account.h4
-rw-r--r--libsylph/folder.c3
-rw-r--r--libsylph/mh.c29
-rw-r--r--libsylph/sylmain.c10
5 files changed, 55 insertions, 13 deletions
diff --git a/libsylph/account.c b/libsylph/account.c
index e2fd8b38..a6f8da30 100644
--- a/libsylph/account.c
+++ b/libsylph/account.c
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -35,6 +35,7 @@
#include "procmsg.h"
#include "procheader.h"
#include "utils.h"
+#include "sylmain.h"
#define PREFSBUFSIZE 1024
@@ -464,10 +465,29 @@ void account_destroy(PrefsAccount *ac_prefs)
account_updated();
}
+static guint account_update_lock_count = 0;
+
+void account_update_lock(void)
+{
+ account_update_lock_count++;
+}
+
+void account_update_unlock(void)
+{
+ if (account_update_lock_count > 0)
+ account_update_lock_count--;
+}
+
void account_updated(void)
{
+ if (account_update_lock_count)
+ return;
+
if (address_table) {
g_hash_table_destroy(address_table);
address_table = NULL;
}
+
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "account-updated");
}
diff --git a/libsylph/account.h b/libsylph/account.h
index d6f01a9e..44851143 100644
--- a/libsylph/account.h
+++ b/libsylph/account.h
@@ -1,6 +1,6 @@
/*
* LibSylph -- E-Mail client library
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -63,6 +63,8 @@ FolderItem *account_get_special_folder(PrefsAccount *ac_prefs,
void account_destroy (PrefsAccount *ac_prefs);
+void account_update_lock (void);
+void account_update_unlock (void);
void account_updated (void);
#endif /* __ACCOUNT_H__ */
diff --git a/libsylph/folder.c b/libsylph/folder.c
index cefc3a0b..66d7702e 100644
--- a/libsylph/folder.c
+++ b/libsylph/folder.c
@@ -475,7 +475,8 @@ void folder_write_list(void)
if (prefs_file_close(pfile) < 0)
g_warning("failed to write folder list.\n");
- g_signal_emit_by_name(syl_app_get(), "folderlist-updated");
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "folderlist-updated");
}
struct TotalMsgStatus
diff --git a/libsylph/mh.c b/libsylph/mh.c
index e86b5671..6141abbe 100644
--- a/libsylph/mh.c
+++ b/libsylph/mh.c
@@ -515,7 +515,8 @@ static gint mh_add_msgs(Folder *folder, FolderItem *dest, GSList *file_list,
}
}
- g_signal_emit_by_name(syl_app_get(), "add-msg", dest, destfile, dest->last_num + 1);
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "add-msg", dest, destfile, dest->last_num + 1);
g_free(destfile);
dest->last_num++;
@@ -628,7 +629,8 @@ static gint mh_add_msgs_msginfo(Folder *folder, FolderItem *dest,
}
}
- g_signal_emit_by_name(syl_app_get(), "add-msg", dest, destfile, dest->last_num + 1);
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "add-msg", dest, destfile, dest->last_num + 1);
g_free(srcfile);
g_free(destfile);
@@ -718,8 +720,10 @@ static gint mh_do_move_msgs(Folder *folder, FolderItem *dest, GSList *msglist)
break;
}
- g_signal_emit_by_name(syl_app_get(), "add-msg", dest, destfile, dest->last_num + 1);
- g_signal_emit_by_name(syl_app_get(), "remove-msg", src, srcfile, msginfo->msgnum);
+ if (syl_app_get()) {
+ g_signal_emit_by_name(syl_app_get(), "add-msg", dest, destfile, dest->last_num + 1);
+ g_signal_emit_by_name(syl_app_get(), "remove-msg", src, srcfile, msginfo->msgnum);
+ }
g_free(srcfile);
g_free(destfile);
@@ -835,7 +839,8 @@ static gint mh_copy_msgs(Folder *folder, FolderItem *dest, GSList *msglist)
break;
}
- g_signal_emit_by_name(syl_app_get(), "add-msg", dest, destfile, dest->last_num + 1);
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "add-msg", dest, destfile, dest->last_num + 1);
g_free(srcfile);
g_free(destfile);
@@ -871,7 +876,8 @@ static gint mh_remove_msg(Folder *folder, FolderItem *item, MsgInfo *msginfo)
file = mh_fetch_msg(folder, item, msginfo->msgnum);
g_return_val_if_fail(file != NULL, -1);
- g_signal_emit_by_name(syl_app_get(), "remove-msg", item, file, msginfo->msgnum);
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "remove-msg", item, file, msginfo->msgnum);
S_LOCK(mh);
@@ -909,7 +915,8 @@ static gint mh_remove_all_msg(Folder *folder, FolderItem *item)
path = folder_item_get_path(item);
g_return_val_if_fail(path != NULL, -1);
- g_signal_emit_by_name(syl_app_get(), "remove-all-msg", item);
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "remove-all-msg", item);
S_LOCK(mh);
@@ -1399,8 +1406,9 @@ static gint mh_move_folder_real(Folder *folder, FolderItem *item,
g_free(paths[1]);
new_id = folder_item_get_identifier(item);
- g_signal_emit_by_name(syl_app_get(), "move-folder", item, old_id,
- new_id);
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "move-folder", item,
+ old_id, new_id);
g_free(new_id);
g_free(old_id);
@@ -1439,7 +1447,8 @@ static gint mh_remove_folder(Folder *folder, FolderItem *item)
}
g_free(path);
- g_signal_emit_by_name(syl_app_get(), "remove-folder", item);
+ if (syl_app_get())
+ g_signal_emit_by_name(syl_app_get(), "remove-folder", item);
folder_item_remove(item);
S_UNLOCK(mh);
diff --git a/libsylph/sylmain.c b/libsylph/sylmain.c
index 649c4d3a..6e8ccb80 100644
--- a/libsylph/sylmain.c
+++ b/libsylph/sylmain.c
@@ -63,6 +63,7 @@ enum {
REMOVE_FOLDER,
MOVE_FOLDER,
FOLDERLIST_UPDATED,
+ ACCOUNT_UPDATED,
LAST_SIGNAL
};
@@ -162,6 +163,15 @@ static void syl_app_class_init(SylAppClass *klass)
syl_marshal_VOID__VOID,
G_TYPE_NONE,
0);
+ app_signals[ACCOUNT_UPDATED] =
+ g_signal_new("account-updated",
+ G_TYPE_FROM_CLASS(gobject_class),
+ G_SIGNAL_RUN_FIRST,
+ 0,
+ NULL, NULL,
+ syl_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
GObject *syl_app_create(void)