From: Jose Dapena Paz Date: Mon, 4 May 2009 06:26:07 +0000 (+0200) Subject: Added method find_registered_message_uid in window mgr. X-Git-Tag: 3.0.16-rc1~9 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=b8143cd888f24df1dd8a77b2bb3206e8fd72314c Added method find_registered_message_uid in window mgr. --- diff --git a/src/hildon2/modest-hildon2-window-mgr.c b/src/hildon2/modest-hildon2-window-mgr.c index c007e0f..4cef7e6 100644 --- a/src/hildon2/modest-hildon2-window-mgr.c +++ b/src/hildon2/modest-hildon2-window-mgr.c @@ -79,6 +79,9 @@ static void modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self, static gboolean modest_hildon2_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header, ModestWindow **win); +static gboolean modest_hildon2_window_mgr_find_registered_message_uid (ModestWindowMgr *self, + const gchar *msg_uid, + ModestWindow **win); static GList *modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self); static gboolean modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self); static gboolean window_can_close (ModestWindow *window); @@ -164,6 +167,7 @@ modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass) mgr_class->get_modal = modest_hildon2_window_mgr_get_modal; mgr_class->set_modal = modest_hildon2_window_mgr_set_modal; mgr_class->find_registered_header = modest_hildon2_window_mgr_find_registered_header; + mgr_class->find_registered_message_uid = modest_hildon2_window_mgr_find_registered_message_uid; mgr_class->get_window_list = modest_hildon2_window_mgr_get_window_list; mgr_class->close_all_windows = modest_hildon2_window_mgr_close_all_windows; mgr_class->show_initial_window = modest_hildon2_window_mgr_show_initial_window; @@ -373,6 +377,38 @@ modest_hildon2_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHead return has_header || has_window; } +static gboolean +modest_hildon2_window_mgr_find_registered_message_uid (ModestWindowMgr *self, const gchar *msg_uid, + ModestWindow **win) +{ + ModestHildon2WindowMgrPrivate *priv = NULL; + gboolean has_header, has_window = FALSE; + GList *item = NULL; + + g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE); + g_return_val_if_fail (msg_uid && msg_uid[0] != '\0', FALSE); + + priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self); + + has_header = MODEST_WINDOW_MGR_CLASS (parent_class)->find_registered_message_uid (self, msg_uid, win); + + item = g_list_find_custom (priv->window_list, msg_uid, (GCompareFunc) compare_msguids); + if (item) { + has_window = TRUE; + if (win) { + if ((!MODEST_IS_MSG_VIEW_WINDOW(item->data)) && + (!MODEST_IS_MSG_EDIT_WINDOW (item->data))) + g_debug ("not a valid window!"); + else { + g_debug ("found a window"); + *win = MODEST_WINDOW (item->data); + } + } + } + + return has_header || has_window; +} + static GList * modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self) { diff --git a/src/widgets/modest-hildon1-window-mgr.c b/src/widgets/modest-hildon1-window-mgr.c index 2a56f3b..eb1de4e 100644 --- a/src/widgets/modest-hildon1-window-mgr.c +++ b/src/widgets/modest-hildon1-window-mgr.c @@ -83,6 +83,9 @@ static void modest_hildon1_window_mgr_set_modal (ModestWindowMgr *self, static gboolean modest_hildon1_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header, ModestWindow **win); +static gboolean modest_hildon1_window_mgr_find_registered_message_uid (ModestWindowMgr *self, + const gchar *msg_uid, + ModestWindow **win); static GList *modest_hildon1_window_mgr_get_window_list (ModestWindowMgr *self); static gboolean modest_hildon1_window_mgr_close_all_windows (ModestWindowMgr *self); static ModestWindow *modest_hildon1_window_mgr_get_current_top (ModestWindowMgr *self); @@ -155,6 +158,7 @@ modest_hildon1_window_mgr_class_init (ModestHildon1WindowMgrClass *klass) mgr_class->get_modal = modest_hildon1_window_mgr_get_modal; mgr_class->set_modal = modest_hildon1_window_mgr_set_modal; mgr_class->find_registered_header = modest_hildon1_window_mgr_find_registered_header; + mgr_class->find_registered_message_uid = modest_hildon1_window_mgr_find_registered_message_uid; mgr_class->get_window_list = modest_hildon1_window_mgr_get_window_list; mgr_class->close_all_windows = modest_hildon1_window_mgr_close_all_windows; mgr_class->get_current_top = modest_hildon1_window_mgr_get_current_top; @@ -336,6 +340,38 @@ modest_hildon1_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHead return has_header || has_window; } +static gboolean +modest_hildon1_window_mgr_find_registered_message_uid (ModestWindowMgr *self, const gchar *msg_uid, + ModestWindow **win) +{ + ModestHildon1WindowMgrPrivate *priv = NULL; + gboolean has_header, has_window = FALSE; + GList *item = NULL; + + g_return_val_if_fail (MODEST_IS_HILDON1_WINDOW_MGR (self), FALSE); + g_return_val_if_fail (msg_uid && msg_uid[0] != '\0', FALSE); + + priv = MODEST_HILDON1_WINDOW_MGR_GET_PRIVATE (self); + + has_header = MODEST_WINDOW_MGR_CLASS (parent_class)->find_registered_message_uid (self, msg_uid, win); + + item = g_list_find_custom (priv->window_list, msg_uid, (GCompareFunc) compare_msguids); + if (item) { + has_window = TRUE; + if (win) { + if ((!MODEST_IS_MSG_VIEW_WINDOW(item->data)) && + (!MODEST_IS_MSG_EDIT_WINDOW (item->data))) + g_debug ("not a valid window!"); + else { + g_debug ("found a window"); + *win = MODEST_WINDOW (item->data); + } + } + } + + return has_header || has_window; +} + static GList * modest_hildon1_window_mgr_get_window_list (ModestWindowMgr *self) { diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index 7182e7c..9c71594 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -66,6 +66,9 @@ static gboolean modest_window_mgr_close_all_windows_default (ModestWindowMgr *se static gboolean modest_window_mgr_find_registered_header_default (ModestWindowMgr *self, TnyHeader *header, ModestWindow **win); +static gboolean modest_window_mgr_find_registered_message_uid_default (ModestWindowMgr *self, + const gchar *msg_uid, + ModestWindow **win); static GList *modest_window_mgr_get_window_list_default (ModestWindowMgr *self); static ModestWindow *modest_window_mgr_show_initial_window_default (ModestWindowMgr *self); static ModestWindow *modest_window_mgr_get_current_top_default (ModestWindowMgr *self); @@ -161,6 +164,7 @@ modest_window_mgr_class_init (ModestWindowMgrClass *klass) mgr_class->set_modal = modest_window_mgr_set_modal_default; mgr_class->close_all_windows = modest_window_mgr_close_all_windows_default; mgr_class->find_registered_header = modest_window_mgr_find_registered_header_default; + mgr_class->find_registered_message_uid = modest_window_mgr_find_registered_message_uid_default; mgr_class->get_window_list = modest_window_mgr_get_window_list_default; mgr_class->show_initial_window = modest_window_mgr_show_initial_window_default; mgr_class->get_current_top = modest_window_mgr_get_current_top_default; @@ -469,21 +473,40 @@ static gboolean modest_window_mgr_find_registered_header_default (ModestWindowMgr *self, TnyHeader *header, ModestWindow **win) { + gchar* uid = NULL; + + g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), FALSE); + g_return_val_if_fail (TNY_IS_HEADER(header), FALSE); + + uid = modest_tny_folder_get_header_unique_id (header); + + return modest_window_mgr_find_registered_message_uid (self, uid, win); +} + +gboolean +modest_window_mgr_find_registered_message_uid (ModestWindowMgr *self, const gchar *msg_uid, + ModestWindow **win) +{ + return MODEST_WINDOW_MGR_GET_CLASS (self)->find_registered_message_uid (self, msg_uid, win); +} + +static gboolean +modest_window_mgr_find_registered_message_uid_default (ModestWindowMgr *self, const gchar *msg_uid, + ModestWindow **win) +{ ModestWindowMgrPrivate *priv = NULL; gchar* uid = NULL; gboolean has_header = FALSE; g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), FALSE); - g_return_val_if_fail (TNY_IS_HEADER(header), FALSE); + g_return_val_if_fail (msg_uid && msg_uid[0] != '\0', FALSE); priv = MODEST_WINDOW_MGR_GET_PRIVATE (self); - uid = modest_tny_folder_get_header_unique_id (header); - if (win) *win = NULL; - has_header = has_uid (priv->preregistered_uids, uid); + has_header = has_uid (priv->preregistered_uids, msg_uid); g_free (uid); return has_header; diff --git a/src/widgets/modest-window-mgr.h b/src/widgets/modest-window-mgr.h index ca22f62..f0a3a7c 100644 --- a/src/widgets/modest-window-mgr.h +++ b/src/widgets/modest-window-mgr.h @@ -76,6 +76,9 @@ struct _ModestWindowMgrClass { gboolean (*find_registered_header) (ModestWindowMgr *self, TnyHeader *header, ModestWindow **win); + gboolean (*find_registered_message_uid) (ModestWindowMgr *self, + const gchar *msg_uid, + ModestWindow **win); GList * (*get_window_list) (ModestWindowMgr *self); ModestWindow * (*show_initial_window) (ModestWindowMgr *self); ModestWindow * (*get_current_top) (ModestWindowMgr *self); @@ -283,6 +286,20 @@ modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win); gboolean modest_window_mgr_find_registered_header (ModestWindowMgr *self, TnyHeader *header, ModestWindow **win); + +/** + * modest_window_mgr_find_registered_header + * @self: a #ModestWindowMgr + * @msg_uid: a message uid + * + * search for the given uid in both the list of preregistered uids and in the window list; + * if it's available in the window list, fill the *win out-param + * + * returns TRUE if found, FALSE otherwise + **/ +gboolean modest_window_mgr_find_registered_message_uid (ModestWindowMgr *self, const gchar *msg_uid, + ModestWindow **win); + /** * modest_window_mgr_get_window_list: * @self: a #ModestWindowMgr