priv = MODEST_MAIL_OPERATION_GET_PRIVATE(obj);
- priv->account = NULL;
+ priv->account = NULL;
priv->status = MODEST_MAIL_OPERATION_STATUS_INVALID;
priv->op_type = MODEST_MAIL_OPERATION_TYPE_UNKNOWN;
priv->error = NULL;
TnyIterator *iter = NULL;
TnyFolderStoreQuery *query = NULL;
ModestMailOperationPrivate *priv;
+ ModestTnySendQueue *send_queue;
info = (UpdateAccountInfo *) thr_user_data;
priv = MODEST_MAIL_OPERATION_GET_PRIVATE(info->mail_op);
g_object_unref (priv->account);
priv->account = g_object_ref (info->transport_account);
- ModestTnySendQueue *send_queue = modest_runtime_get_send_queue
- (info->transport_account);
-
- timeout = g_timeout_add (250, idle_notify_progress, info->mail_op);
- modest_tny_send_queue_try_to_send (send_queue);
- g_source_remove (timeout);
-
- g_object_unref (G_OBJECT(send_queue));
+ send_queue = modest_runtime_get_send_queue (info->transport_account);
+ if (send_queue) {
+ timeout = g_timeout_add (250, idle_notify_progress, info->mail_op);
+ modest_tny_send_queue_try_to_send (send_queue);
+ g_source_remove (timeout);
+ } else {
+ g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
+ MODEST_MAIL_OPERATION_ERROR_INSTANCE_CREATION_FAILED,
+ "cannot create a send queue for %s\n",
+ tny_account_get_name (TNY_ACCOUNT (info->transport_account)));
+ priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
+ }
/* Check if the operation was a success */
if (!priv->error) {
TnyFolderStore *parent,
const gchar *name)
{
- ModestTnyFolderRules rules;
ModestMailOperationPrivate *priv;
TnyFolder *new_folder = NULL;
- gboolean can_create = FALSE;
g_return_val_if_fail (TNY_IS_FOLDER_STORE (parent), NULL);
g_return_val_if_fail (name, NULL);
priv = MODEST_MAIL_OPERATION_GET_PRIVATE (self);
- /* Get account and set it into mail_operation */
- priv->account = tny_folder_get_account (TNY_FOLDER(parent));
-
/* Check parent */
- if (!TNY_IS_FOLDER (parent)) {
- /* Set status failed and set an error */
- priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
- g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
- MODEST_MAIL_OPERATION_ERROR_BAD_PARAMETER,
- _("mail_in_ui_folder_create_error"));
- } else {
+ if (TNY_IS_FOLDER (parent)) {
/* Check folder rules */
- rules = modest_tny_folder_get_rules (TNY_FOLDER (parent));
+ ModestTnyFolderRules rules = modest_tny_folder_get_rules (TNY_FOLDER (parent));
if (rules & MODEST_FOLDER_RULES_FOLDER_NON_WRITEABLE) {
/* Set status failed and set an error */
priv->status = MODEST_MAIL_OPERATION_STATUS_FAILED;
g_set_error (&(priv->error), MODEST_MAIL_OPERATION_ERROR,
MODEST_MAIL_OPERATION_ERROR_FOLDER_RULES,
_("mail_in_ui_folder_create_error"));
- }
- else
- can_create = TRUE;
+ }
}
- if (can_create) {
+ if (!priv->error) {
/* Create the folder */
new_folder = tny_folder_store_create_folder (parent, name, &(priv->error));
CHECK_EXCEPTION (priv, MODEST_MAIL_OPERATION_STATUS_FAILED);
+ if (!priv->error)
+ priv->status = MODEST_MAIL_OPERATION_STATUS_SUCCESS;
}
/* Notify about operation end */
if (result == GTK_RESPONSE_REJECT) {
finished = TRUE;
} else {
- ModestMailOperation *mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO, G_OBJECT(main_window));
+ ModestMailOperation *mail_op;
TnyFolder *new_folder = NULL;
+ mail_op = modest_mail_operation_new (MODEST_MAIL_OPERATION_TYPE_INFO,
+ G_OBJECT(main_window));
modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
mail_op);
-
new_folder = modest_mail_operation_create_folder (mail_op,
parent_folder,
(const gchar *) folder_name);
if (new_folder) {
g_object_unref (new_folder);
finished = TRUE;
- }
-/* else { */
-/* /\* TODO: check error and follow proper actions *\/ */
-/* /\* suggested_name = X; *\/ */
-/* /\* Show error to the user *\/ */
-/* modest_platform_run_information_dialog (GTK_WINDOW (main_window), */
-/* _("mail_in_ui_folder_create_error")); */
-/* } */
+ }
g_object_unref (mail_op);
}
g_free (folder_name);
#include <config.h>
#endif /*HAVE_CONFIG_H*/
+#include <string.h>
#include "modest-ui-dimming-rules.h"
#include "modest-tny-folder.h"
#include <modest-runtime.h>
modest_ui_dimming_rules_on_new_folder (ModestWindow *win, gpointer user_data)
{
gboolean dimmed = FALSE;
+ GtkWidget *folder_view = NULL;
+ TnyFolderStore *parent_folder = NULL;
g_return_val_if_fail (MODEST_IS_MAIN_WINDOW(win), FALSE);
-
- /* Check dimmed rule */
- if (!dimmed)
+
+
+ folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(win),
+ MODEST_WIDGET_TYPE_FOLDER_VIEW);
+ /* Get selected folder as parent of new folder to create */
+ parent_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW(folder_view));
+ if (!parent_folder)
+ return TRUE;
+
+ /* If it's the local account do not dimm */
+ if (modest_tny_folder_store_is_virtual_local_folders (parent_folder)) {
+ return FALSE;
+ } else if (TNY_IS_ACCOUNT (parent_folder)) {
+ /* If it's the MMC root folder then dimm it */
+ if (!strcmp (tny_account_get_id (TNY_ACCOUNT (parent_folder)), MODEST_MMC_ACCOUNT_ID)) {
+ dimmed = TRUE;
+ } else {
+ const gchar *proto_str = tny_account_get_proto (TNY_ACCOUNT (parent_folder));
+ /* If it's POP then dimm */
+ dimmed = (modest_protocol_info_get_transport_store_protocol (proto_str) ==
+ MODEST_PROTOCOL_STORE_POP) ? TRUE : FALSE;
+ }
+ } else {
+ /* TODO: the specs say that only one level of subfolder is allowed, is this true ? */
+
+ /* Apply folder rules */
dimmed = _selected_folder_not_writeable (MODEST_MAIN_WINDOW(win));
+ }
return dimmed;
}