X-Git-Url: http://git.maemo.org/git/?p=modest;a=blobdiff_plain;f=src%2Fmodest-utils.c;h=fd3227af3814e980aad0a63910829fb25f74161c;hp=a7f09ab5550cb77065aab459daa18c957deb7e66;hb=ff1c10570c382523c3f9c414159a6eb4a6dd4c0f;hpb=91526797480db76525e1295ec4a65f29f4bdc9cf diff --git a/src/modest-utils.c b/src/modest-utils.c index a7f09ab..fd3227a 100644 --- a/src/modest-utils.c +++ b/src/modest-utils.c @@ -43,6 +43,7 @@ #include #include "modest-utils.h" #include "modest-platform.h" +#include GQuark modest_utils_get_supported_secure_authentication_error_quark (void) @@ -59,16 +60,18 @@ modest_utils_folder_writable (const gchar *filename) return FALSE; if (g_strncasecmp (filename, "obex", 4) != 0) { - GnomeVFSFileInfo folder_info; + GnomeVFSFileInfo *folder_info; gchar *folder; folder = g_path_get_dirname (filename); - gnome_vfs_get_file_info (folder, &folder_info, + folder_info = gnome_vfs_file_info_new (); + gnome_vfs_get_file_info (folder, folder_info, GNOME_VFS_FILE_INFO_GET_ACCESS_RIGHTS); g_free (folder); - if (!((folder_info.permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) || - (folder_info.permissions & GNOME_VFS_PERM_USER_WRITE))) { + if (!((folder_info->permissions & GNOME_VFS_PERM_ACCESS_WRITABLE) || + (folder_info->permissions & GNOME_VFS_PERM_USER_WRITE))) { return FALSE; } + gnome_vfs_file_info_unref (folder_info); } return TRUE; } @@ -79,6 +82,8 @@ modest_utils_file_exists (const gchar *filename) GnomeVFSURI *uri = NULL; gboolean result = FALSE; + g_return_val_if_fail (filename, FALSE); + uri = gnome_vfs_uri_new (filename); if (uri) { result = gnome_vfs_uri_exists (uri); @@ -187,18 +192,18 @@ on_idle_secure_auth_finished (gpointer user_data) } static void -on_camel_account_get_supported_secure_authentication ( - TnyCamelAccount *self, gboolean cancelled, - TnyList *auth_types, GError *err, - gpointer user_data) +on_camel_account_get_supported_secure_authentication (TnyCamelAccount *self, gboolean cancelled, + TnyList *auth_types, GError *err, gpointer user_data) { + g_return_if_fail (TNY_IS_CAMEL_ACCOUNT(self)); + g_return_if_fail (TNY_IS_LIST(auth_types)); + ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data; g_return_if_fail (info); /* Free everything if the actual action was canceled */ - if (info->cancel) - { + if (info->cancel) { /* The operation was canceled and the ownership of the info given to us * so that we could still check the cancel flag. */ g_slice_free (ModestGetSupportedAuthInfo, info); @@ -206,8 +211,7 @@ on_camel_account_get_supported_secure_authentication ( } else { - if (err) - { + if (err) { if (info->error) { g_error_free (info->error); info->error = NULL; @@ -219,10 +223,9 @@ on_camel_account_get_supported_secure_authentication ( if (!auth_types) { g_warning ("DEBUG: %s: auth_types is NULL.\n", __FUNCTION__); } - else if (tny_list_get_length(auth_types) == 0) { + else if (tny_list_get_length(auth_types) == 0) g_warning ("DEBUG: %s: auth_types is an empty TnyList.\n", __FUNCTION__); - } else - { + else { ModestPairList* pairs = modest_protocol_info_get_auth_protocol_pair_list (); /* Get the enum value for the strings: */ @@ -262,8 +265,9 @@ on_camel_account_get_supported_secure_authentication ( static void on_secure_auth_cancel(GtkWidget* dialog, int response, gpointer user_data) { - if(response == GTK_RESPONSE_REJECT || response == GTK_RESPONSE_DELETE_EVENT) - { + g_return_if_fail (GTK_IS_WIDGET(dialog)); + + if(response == GTK_RESPONSE_REJECT || response == GTK_RESPONSE_DELETE_EVENT) { ModestGetSupportedAuthInfo *info = (ModestGetSupportedAuthInfo*)user_data; g_return_if_fail(info); /* This gives the ownership of the info to the worker thread. */ @@ -397,6 +401,9 @@ void modest_utils_show_dialog_and_forget (GtkWindow *parent_window, GtkDialog *dialog) { + g_return_if_fail (GTK_IS_WINDOW(parent_window)); + g_return_if_fail (GTK_IS_DIALOG(dialog)); + gtk_window_set_transient_for (GTK_WINDOW (dialog), parent_window); /* Destroy the dialog when it is closed: */ @@ -438,6 +445,9 @@ modest_list_index (TnyList *list, GObject *object) TnyIterator *iter; gint index = 0; + g_return_val_if_fail (TNY_IS_LIST(list), -1); + g_return_val_if_fail (G_IS_OBJECT(object), -1); + iter = tny_list_create_iterator (list); while (!tny_iterator_is_done (iter)) { GObject *current = tny_iterator_get_current (iter); @@ -455,3 +465,28 @@ modest_list_index (TnyList *list, GObject *object) g_object_unref (iter); return index; } + +guint64 +modest_folder_available_space (const gchar *maildir_path) +{ + gchar *folder; + gchar *uri_string; + GnomeVFSURI *uri; + GnomeVFSFileSize size; + + folder = modest_local_folder_info_get_maildir_path (maildir_path); + uri_string = gnome_vfs_get_uri_from_local_path (folder); + uri = gnome_vfs_uri_new (uri_string); + g_free (folder); + g_free (uri_string); + + if (uri) { + if (gnome_vfs_get_volume_free_space (uri, &size) != GNOME_VFS_OK) + size = -1; + gnome_vfs_uri_unref (uri); + } else { + size = -1; + } + + return (guint64) size; +}