1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <libgnomevfs/gnome-vfs-mime.h>
31 #include <libgnomeui/gnome-icon-lookup.h>
32 #include <tny-gnome-device.h>
33 #include <tny-camel-imap-store-account.h>
34 #include <tny-camel-pop-store-account.h>
36 #include "modest-platform.h"
37 #include "modest-mail-operation-queue.h"
38 #include "modest-runtime.h"
40 #include "gnome/modest-gnome-global-settings-dialog.h"
43 modest_platform_init (int argc, char *argv[])
45 return TRUE; /* nothing to do */
49 gboolean modest_platform_uninit (void)
51 return TRUE; /*nothing to do */
56 modest_platform_get_new_device (void)
58 return TNY_DEVICE (tny_gnome_device_new ());
63 modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type,
64 gchar **effective_mime_type)
66 GString *mime_str = NULL;
67 gchar *icon_name = NULL;
69 const static gchar* octet_stream = "application/octet-stream";
71 g_return_val_if_fail (name || mime_type, NULL);
73 if (!mime_type || g_ascii_strcasecmp (mime_type, octet_stream))
74 mime_str = g_string_new(gnome_vfs_mime_type_from_name_or_default
75 (name, "application/octet-stream"));
77 mime_str = g_string_new (mime_type);
78 g_string_ascii_down (mime_str);
81 uri = g_strconcat ("file:///", name ? name : "dummy", NULL);
82 icon_name = gnome_icon_lookup (gtk_icon_theme_get_default(), NULL,
83 uri, NULL, NULL, mime_str->str, 0, 0);
86 if (effective_mime_type)
87 *effective_mime_type = g_string_free (mime_str, FALSE);
89 g_string_free (mime_str, TRUE);
95 modest_platform_activate_uri (const gchar *uri)
97 g_message ("NOT IMPLEMENTED");;
102 modest_platform_activate_file (const gchar *path, const gchar *mime_type)
104 g_message ("NOT IMPLEMENTED");;
109 modest_platform_show_uri_popup (const gchar *uri)
111 g_message ("NOT IMPLEMENTED");;
116 modest_platform_get_icon (const gchar *name)
121 g_return_val_if_fail (name, NULL);
123 pixbuf = gdk_pixbuf_new_from_file (name, &err);
126 g_printerr ("modest: error while loading icon '%s': %s\n",
136 modest_platform_get_app_name (void)
142 modest_platform_run_new_folder_dialog (GtkWindow *parent_window,
143 TnyFolderStore *parent_folder,
144 gchar *suggested_name,
147 GtkWidget *dialog, *entry;
150 /* Ask the user for the folder name */
151 dialog = gtk_dialog_new_with_buttons (_("New Folder Name"),
159 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
160 gtk_label_new (_("Please enter a name for the new folder")),
163 entry = gtk_entry_new_with_max_length (40);
164 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
168 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
170 result = gtk_dialog_run (GTK_DIALOG(dialog));
171 if (result == GTK_RESPONSE_ACCEPT)
172 *folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
174 gtk_widget_destroy (dialog);
181 modest_platform_run_confirmation_dialog (GtkWindow *parent_window,
184 /* TODO implement confirmation dialog */
185 return GTK_RESPONSE_CANCEL;
189 modest_platform_run_information_dialog (GtkWindow *parent_window,
190 const gchar *message)
192 /* TODO: implement a information dialog */
195 gboolean modest_platform_connect_and_wait (GtkWindow *parent_window, TnyAccount *account)
197 /* TODO: Do something with network-manager?
198 Otherwise, maybe it is safe to assume that we would already be online if we could be. */
202 gboolean modest_platform_connect_and_wait_if_network_account (GtkWindow *parent_window, TnyAccount *account)
204 /* TODO: Do something with network-manager?
205 Otherwise, maybe it is safe to assume that we would already be online if we could be. */
211 modest_platform_connect_if_remote_and_perform (GtkWindow *parent_window,
212 TnyFolderStore *folder_store,
213 ModestConnectedPerformer callback,
216 TnyAccount *account = NULL;
219 /* We promise to instantly perform the callback, so ... */
221 callback (FALSE, NULL, parent_window, NULL, user_data);
225 /* Original comment: Maybe it is something local. */
226 /* PVH's comment: maybe we should KNOW this in stead of assuming? */
228 } else if (TNY_IS_FOLDER (folder_store)) {
229 /* Get the folder's parent account: */
230 account = tny_folder_get_account(TNY_FOLDER (folder_store));
231 } else if (TNY_IS_ACCOUNT (folder_store)) {
232 /* Use the folder store as an account: */
233 account = TNY_ACCOUNT (folder_store);
236 if (tny_account_get_account_type (account) == TNY_ACCOUNT_TYPE_STORE) {
237 if (!TNY_IS_CAMEL_POP_STORE_ACCOUNT (account) &&
238 !TNY_IS_CAMEL_IMAP_STORE_ACCOUNT (account)) {
240 /* This IS a local account like a maildir account, which does not require
241 * a connection. (original comment had a vague assumption in its language
242 * usage. There's no assuming needed, this IS what it IS: a local account), */
244 /* We promise to instantly perform the callback, so ... */
246 callback (FALSE, NULL, parent_window, account, user_data);
253 modest_platform_connect_and_perform (parent_window, account, callback, user_data);
259 gboolean modest_platform_set_update_interval (guint minutes)
266 modest_platform_run_sort_dialog (GtkWindow *parent_window,
267 ModestSortDialogType type)
273 modest_platform_get_global_settings_dialog ()
275 return modest_gnome_global_settings_dialog_new ();
280 modest_platform_on_new_headers_received (TnyList *header_list)
282 /* TODO: implement this */
283 g_print ("--------------- NEW MESSAGE ARRIVED ---------------\n");
289 modest_platform_show_help (GtkWindow *parent_window, const gchar *help_id)
295 modest_platform_information_banner (GtkWidget *widget,
296 const gchar *icon_name,
299 g_message ("NOT IMPLEMENTED");;
303 modest_platform_animation_banner (GtkWidget *widget,
304 const gchar *icon_name,
307 g_message ("NOT IMPLEMENTED");
313 modest_platform_show_search_messages (GtkWindow *parent_window)
315 g_message ("NOT IMPLEMENTED");;
319 modest_platform_create_folder_view (TnyFolderStoreQuery *query)
321 GtkWidget *widget = modest_folder_view_new (query);
323 /* Show all accounts by default */
324 modest_folder_view_set_style (MODEST_FOLDER_VIEW (widget),
325 MODEST_FOLDER_VIEW_STYLE_SHOW_ALL);
331 modest_platform_run_alert_dialog (const gchar* prompt,
332 gboolean is_question)
339 modest_platform_connect_and_perform (GtkWindow *parent_window,
341 ModestConnectedPerformer callback,
345 callback (FALSE, NULL, parent_window, account, user_data);
349 modest_platform_connect_and_perform_if_network_account (GtkWindow *parent_window,
351 ModestConnectedPerformer callback,
355 callback (FALSE, NULL, parent_window, account, user_data);
359 modest_platform_connect_and_perform_if_network_folderstore (GtkWindow *parent_window,
360 TnyFolderStore *folder_store,
361 ModestConnectedPerformer callback,
365 callback (FALSE, NULL, parent_window, NULL, user_data);
370 modest_platform_remove_new_mail_notifications (void)
372 g_message ("NOT IMPLEMENTED %s", __FUNCTION__);
376 modest_platform_check_and_wait_for_account_is_online(TnyAccount *account)
378 g_message ("NOT IMPLEMENTED %s", __FUNCTION__);
383 modest_platform_run_certificate_confirmation_dialog (const gchar* server_name,
384 const gchar *certificate)
386 g_message ("NOT IMPLEMENTED %s", __FUNCTION__);
391 modest_platform_run_rename_folder_dialog (GtkWindow *parent_window,
392 TnyFolderStore *parent_folder,
393 const gchar *suggested_name,
396 g_message ("NOT IMPLEMENTED %s", __FUNCTION__);
397 return GTK_RESPONSE_CANCEL;
401 modest_platform_show_addressbook (GtkWindow *parent_window)
403 g_message ("NOT IMPLEMENTED %s", __FUNCTION__);