#include <modest-text-utils.h>
#include "modest-tny-folder.h"
#include <string.h>
+#include <libgnomevfs/gnome-vfs-mime-utils.h>
#define HILDON_OSSO_URI_ACTION "uri-action"
}
}
+
+
+static gboolean
+check_required_files (void)
+{
+ FILE *mcc_file = modest_maemo_open_mcc_mapping_file ();
+ if (!mcc_file) {
+ g_printerr ("modest: check for mcc file failed\n");
+ return FALSE;
+ } else
+ fclose (mcc_file);
+
+ if (access (MODEST_PROVIDERS_DATA_PATH, R_OK) != 0) {
+ g_printerr ("modest: cannot find providers data\n");
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+
gboolean
modest_platform_init (int argc, char *argv[])
{
osso_hw_state_t hw_state = { 0 };
DBusConnection *con;
+ if (!check_required_files ()) {
+ g_printerr ("modest: missing required files\n");
+ return FALSE;
+ }
+
+
osso_context =
osso_initialize(PACKAGE,PACKAGE_VERSION,
FALSE, NULL);
return FALSE;
}
-
+
/* Add a D-Bus handler to be used when the main osso-rpc
* D-Bus handler has not handled something.
* We use this for D-Bus methods that need to use more complex types
return TNY_DEVICE (tny_maemo_conic_device_new ());
}
-
-const gchar*
-guess_mime_type_from_name (const gchar* name)
-{
- int i;
- const static gchar* mime_type;
- const static gchar* mime_map[][2] = {
- { ".note.html", "text/note"}, /* for the osso_notes program */
- { ".deb", "application/x-deb"},
- { ".install", "application/x-install-instructions"},
- { ".html", "text/html"},
- { ".htm", "text/html"},
- { ".pdf", "application/pdf"},
- { ".doc", "application/msword"},
- { ".xls", "application/excel"},
- { ".png", "image/png" },
- { ".gif", "image/gif" },
- { ".jpg", "image/jpeg"},
- { ".jpeg", "image/jpeg"},
- { ".mp3", "audio/mp3" }
- };
-
- mime_type = "application/octet-stream";
-
- if (name) {
- gchar* lc_name = g_utf8_strdown (name, -1);
- for (i = 0; i != G_N_ELEMENTS(mime_map); ++i) {
- if (g_str_has_suffix (lc_name, mime_map[i][0])) {
- mime_type = mime_map[i][1];
- break;
- }
- }
- g_free (lc_name);
- }
-
- return mime_type;
-}
-
-
gchar*
modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type,
gchar **effective_mime_type)
GString *mime_str = NULL;
gchar *icon_name = NULL;
gchar **icons, **cursor;
-
+
if (!mime_type || !g_ascii_strcasecmp (mime_type, "application/octet-stream"))
- mime_str = g_string_new (guess_mime_type_from_name(name));
+ mime_str = g_string_new (gnome_vfs_get_mime_type_for_name (name));
else {
mime_str = g_string_new (mime_type);
g_string_ascii_down (mime_str);
HildonURIAction *action;
gboolean result = FALSE;
GSList *actions, *iter = NULL;
- const gchar *scheme;
g_return_val_if_fail (uri, FALSE);
if (!uri)
return FALSE;
-
- scheme = hildon_uri_get_scheme_from_uri (uri, NULL);
- actions = hildon_uri_get_actions (scheme, NULL);
+
+ actions = hildon_uri_get_actions_by_uri (uri, -1, NULL);
for (iter = actions; iter; iter = g_slist_next (iter)) {
action = (HildonURIAction*) iter->data;
}
}
- /* if we could open it with email, try something else */
+ /* if we could not open it with email, try something else */
if (!result)
result = hildon_uri_open (uri, NULL, NULL);
gboolean
modest_platform_show_uri_popup (const gchar *uri)
{
- gchar *scheme;
GSList *actions_list;
if (uri == NULL)
return FALSE;
-
- scheme = hildon_uri_get_scheme_from_uri (uri, NULL);
- actions_list = hildon_uri_get_actions (scheme, NULL);
+
+ actions_list = hildon_uri_get_actions_by_uri (uri, -1, NULL);
if (actions_list != NULL) {
GSList *node;
GtkWidget *menu = gtk_menu_new ();
} else {
hildon_banner_show_information (NULL, NULL, _("mcen_ib_unsupported_link"));
}
-
- g_free (scheme);
+
return TRUE;
}
/* Get header window */
if (MODEST_IS_MAIN_WINDOW (parent_window)) {
header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(parent_window),
- MODEST_WIDGET_TYPE_HEADER_VIEW));
+ MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
}
if (!header_view) return;
* a) They fundamentally need network access, so they can't really be offline.
* b) That might cause a transport connection to happen too early.
*/
- GError *error = NULL;
- tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (account), TRUE, &error);
- if (error) {
- g_warning ("%s: tny_camel_account_set_online() returned a GError:\n %s\n",
- __FUNCTION__, error->message);
- g_error_free (error);
- }
+
+ /* The last argument is user_data, the NULL before that is the callback */
+ tny_camel_account_set_online (TNY_CAMEL_ACCOUNT (account), TRUE, NULL, NULL);
}
#endif
}
modest_platform_on_new_header_received (TnyHeader *header)
{
#ifdef MODEST_HAVE_HILDON_NOTIFY
- HildonNotification *not;
+ HildonNotification *notification;
gchar *url = NULL;
TnyFolder *folder = NULL;
+ const gchar *subject;
- /* Create a new notification. TODO: per-mail data needed */
- not = hildon_notification_new (tny_header_get_from (header),
- tny_header_get_subject (header),
- "qgn_list_messagin_mail_unread",
- NULL);
+ subject = tny_header_get_subject (header);
+ if (!subject || strlen(subject) == 0)
+ subject = _("mail_va_no_subject");
+
+ notification = hildon_notification_new (tny_header_get_from (header),
+ subject,
+ "qgn_list_messagin",
+ NULL);
folder = tny_header_get_folder (header);
url = g_strdup_printf ("%s/%s",
tny_header_get_uid (header));
g_object_unref (folder);
- hildon_notification_add_dbus_action(not,
+ hildon_notification_add_dbus_action(notification,
"default",
"Cancel",
MODEST_DBUS_SERVICE,
-1);
g_free (url);
- /* Play sound SR-SND-18 */
- hildon_notification_set_sound
- (not, "/usr/share/sounds/ui-new_email.wav");
- notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (not), "dialog-type", 4);
-
+ /* Play sound if the user wants */
+ if (modest_conf_get_bool (modest_runtime_get_conf (),
+ MODEST_CONF_PLAY_SOUND_MSG_ARRIVE,
+ NULL)) {
+ hildon_notification_set_sound (HILDON_NOTIFICATION(notification),
+ "/usr/share/sounds/ui-new_email.wav");
+ }
+
/* Set the led pattern */
- notify_notification_set_hint_string(NOTIFY_NOTIFICATION (not),
+ notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION(notification),
+ "dialog-type", 4);
+ notify_notification_set_hint_string(NOTIFY_NOTIFICATION(notification),
"led-pattern",
"PatternCommunicationEmail");
/* Notify. We need to do this in an idle because this function
could be called from a thread */
- if (!notify_notification_show (NOTIFY_NOTIFICATION (not), NULL))
+ if (!notify_notification_show (NOTIFY_NOTIFICATION(notification), NULL))
g_error ("Failed to send notification");
-
- g_object_unref (not);
+
+ g_object_unref (notification);
#endif /*MODEST_HAVE_HILDON_NOTIFY*/
}
static void
on_cert_dialog_response (GtkDialog *dialog, gint response_id, const gchar* cert)
{
- // handle ok/cancel in the normal way
- if (response_id != GTK_RESPONSE_HELP)
- gtk_dialog_response (dialog, response_id);
- else {
- // GTK_RESPONSE_HELP means we need to show the certificate
+ /* GTK_RESPONSE_HELP means we need to show the certificate */
+ if (response_id == GTK_RESPONSE_HELP) {
GtkWidget *note;
gchar *msg;
+ /* Do not close the dialog */
+ g_signal_stop_emission_by_name (dialog, "response");
+
msg = g_strdup_printf (_("mcen_ni_view_unknown_certificate"), cert);
note = hildon_note_new_information (GTK_WINDOW(dialog), msg);
gtk_dialog_run (GTK_DIALOG(note));
GtkWindow *main_win =
(GtkWindow*)modest_window_mgr_get_main_window (modest_runtime_get_window_mgr());
- gchar *question = g_strdup_printf (_("mcen_mc_unknown_certificate"),
+ gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"),
server_name);
note = hildon_note_new_confirmation_add_buttons (
_("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL,
NULL, NULL);
- g_signal_connect (G_OBJECT(note), "response", G_CALLBACK(on_cert_dialog_response),
- (gpointer)certificate);
+ g_signal_connect (G_OBJECT(note), "response",
+ G_CALLBACK(on_cert_dialog_response),
+ (gpointer) certificate);
response = gtk_dialog_run(GTK_DIALOG(note));
gtk_widget_destroy(GTK_WIDGET(note));
gboolean
-modest_platform_run_alert_dialog (const gchar* prompt, gboolean is_question)
+modest_platform_run_alert_dialog (const gchar* prompt,
+ gboolean is_question)
{
ModestWindow *main_window =
modest_window_mgr_get_main_window (modest_runtime_get_window_mgr ());
} else {
/* Just show the error text and use the default response: */
- modest_maemo_show_information_note_and_forget(GTK_WINDOW (main_window),
- prompt);
+ modest_platform_run_information_dialog (GTK_WINDOW (main_window),
+ prompt);
}
return retval;
}