evolution-3.6.4/mail/e-mail-folder-pane.c

No issues found

Incomplete coverage

Tool Failure ID Location Function Message Data
clang-analyzer no-output-found e-mail-folder-pane.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
clang-analyzer no-output-found e-mail-folder-pane.c Message(text='Unable to locate XML output from invoke-clang-analyzer') None
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
Failure running clang-analyzer ('no-output-found')
Message
Unable to locate XML output from invoke-clang-analyzer
  1 /*
  2  * e-mail-folder-pane.c
  3  *
  4  * This program is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2 of the License, or (at your option) version 3.
  8  *
  9  * This program is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with the program; if not, see <http://www.gnu.org/licenses/>
 16  *
 17  *
 18  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
 19  *
 20  */
 21 
 22 #ifdef HAVE_CONFIG_H
 23 #include <config.h>
 24 #endif
 25 
 26 #include "e-mail-folder-pane.h"
 27 
 28 #include <string.h>
 29 #include <glib/gi18n.h>
 30 
 31 #include "e-util/e-util.h"
 32 #include "e-util/e-plugin-ui.h"
 33 
 34 #include "shell/e-shell.h"
 35 #include "shell/e-shell-utils.h"
 36 
 37 #include "widgets/misc/e-popup-action.h"
 38 #include "widgets/misc/e-preview-pane.h"
 39 
 40 #include "libemail-engine/e-mail-utils.h"
 41 #include "libemail-engine/mail-tools.h"
 42 
 43 #include "mail/e-mail-reader.h"
 44 #include "mail/e-mail-reader-utils.h"
 45 #include "mail/em-folder-tree-model.h"
 46 #include "mail/em-composer-utils.h"
 47 #include "mail/em-utils.h"
 48 #include "mail/message-list.h"
 49 
 50 #define E_MAIL_FOLDER_PANE_GET_PRIVATE(obj) \
 51 	(G_TYPE_INSTANCE_GET_PRIVATE \
 52 	((obj), E_TYPE_MAIL_FOLDER_PANE, EMailFolderPanePrivate))
 53 
 54 struct _EMailFolderPanePrivate {
 55 	gint placeholder;
 56 };
 57 
 58 G_DEFINE_TYPE (EMailFolderPane, e_mail_folder_pane, E_TYPE_MAIL_PANED_VIEW)
 59 
 60 static gboolean
 61 folder_pane_get_preview_visible (EMailView *view)
 62 {
 63 	return FALSE;
 64 }
 65 
 66 static void
 67 folder_pane_set_preview_visible (EMailView *view,
 68                                  gboolean preview_visible)
 69 {
 70 	/* Ignore the request. */
 71 }
 72 
 73 static guint
 74 mail_paned_view_open_selected_mail (EMailPanedView *view)
 75 {
 76 	EShell *shell;
 77 	EMailReader *reader;
 78 	EMailBackend *backend;
 79 	ESourceRegistry *registry;
 80 	GPtrArray *uids;
 81 	gint i;
 82 	GtkWindow *window;
 83 	CamelFolder *folder;
 84 	GPtrArray *views;
 85 	guint n_views, ii;
 86 
 87 	reader = E_MAIL_READER (view);
 88 	folder = e_mail_reader_get_folder (reader);
 89 	window = e_mail_reader_get_window (reader);
 90 	uids = e_mail_reader_get_selected_uids (reader);
 91 	g_return_val_if_fail (uids != NULL, 0);
 92 
 93 	backend = e_mail_reader_get_backend (reader);
 94 	shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend));
 95 	registry = e_shell_get_registry (shell);
 96 
 97 	/* XXX Either e_mail_reader_get_selected_uids()
 98 	 *     or MessageList should do this itself. */
 99 	g_ptr_array_set_free_func (uids, (GDestroyNotify) g_free);
100 
101 	if (!em_utils_ask_open_many (window, uids->len)) {
102 		g_ptr_array_unref (uids);
103 		return 0;
104 	}
105 
106 	if (em_utils_folder_is_drafts (registry, folder) ||
107 		em_utils_folder_is_outbox (registry, folder) ||
108 		em_utils_folder_is_templates (registry, folder)) {
109 		em_utils_edit_messages (reader, folder, uids, TRUE);
110 		g_ptr_array_unref (uids);
111 		return 0;
112 	}
113 
114 	views = g_ptr_array_new_with_free_func ((GDestroyNotify) g_free);
115 
116 	/* For vfolders we need to edit the original, not the vfolder copy. */
117 	for (ii = 0; ii < uids->len; ii++) {
118 		const gchar *uid = uids->pdata[ii];
119 		CamelFolder *real_folder;
120 		CamelMessageInfo *info;
121 		gchar *real_uid;
122 
123 		if (!CAMEL_IS_VEE_FOLDER (folder)) {
124 			g_ptr_array_add (views, g_strdup (uid));
125 			continue;
126 		}
127 
128 		info = camel_folder_get_message_info (folder, uid);
129 		if (info == NULL)
130 			continue;
131 
132 		real_folder = camel_vee_folder_get_location (
133 			CAMEL_VEE_FOLDER (folder),
134 			(CamelVeeMessageInfo *) info, &real_uid);
135 
136 		if (em_utils_folder_is_drafts (registry, real_folder) ||
137 			em_utils_folder_is_outbox (registry, real_folder)) {
138 			GPtrArray *edits;
139 
140 			edits = g_ptr_array_new_with_free_func (
141 				(GDestroyNotify) g_free);
142 			g_ptr_array_add (edits, real_uid);
143 			em_utils_edit_messages (
144 				reader, real_folder, edits, TRUE);
145 			g_ptr_array_unref (edits);
146 		} else {
147 			g_free (real_uid);
148 			g_ptr_array_add (views, g_strdup (uid));
149 		}
150 
151 		camel_folder_free_message_info (folder, info);
152 	}
153 
154 	n_views = views->len;
155 
156 	for (i = 0; i < n_views; i++)
157 		g_signal_emit_by_name (view, "open-mail", views->pdata[i]);
158 
159 	g_ptr_array_unref (views);
160 	g_ptr_array_unref (uids);
161 
162 	return n_views;
163 }
164 
165 static void
166 e_mail_folder_pane_class_init (EMailFolderPaneClass *class)
167 {
168 	EMailViewClass *mail_view_class;
169 	EMailPanedViewClass *mail_paned_view_class;
170 
171 	g_type_class_add_private (class, sizeof (EMailFolderPanePrivate));
172 
173 	mail_view_class = E_MAIL_VIEW_CLASS (class);
174 	mail_view_class->get_preview_visible = folder_pane_get_preview_visible;
175 	mail_view_class->set_preview_visible = folder_pane_set_preview_visible;
176 
177 	mail_paned_view_class = E_MAIL_PANED_VIEW_CLASS (class);
178 	mail_paned_view_class->open_selected_mail = mail_paned_view_open_selected_mail;
179 }
180 
181 static void
182 e_mail_folder_pane_init (EMailFolderPane *folder_pane)
183 {
184 	folder_pane->priv = E_MAIL_FOLDER_PANE_GET_PRIVATE (folder_pane);
185 }
186 
187 EMailView *
188 e_mail_folder_pane_new (EShellView *shell_view)
189 {
190 	g_return_val_if_fail (E_IS_SHELL_VIEW (shell_view), NULL);
191 
192 	return g_object_new (
193 		E_TYPE_MAIL_FOLDER_PANE,
194 		"shell-view", shell_view, NULL);
195 }