static gchar * vfolder_adduri_desc (struct _adduri_msg *m) { CamelStore *store; CamelService *service; EMailSession *session; const gchar *display_name; gchar *folder_name; gchar *description; gboolean success; session = e_mail_backend_get_session (m->backend); success = e_mail_folder_uri_parse ( CAMEL_SESSION (session), m->uri, &store, &folder_name, NULL); if (!success) return NULL; service = CAMEL_SERVICE (store); display_name = camel_service_get_display_name (service); description = g_strdup_printf ( _("Updating Search Folders for '%s' : %s"), display_name, folder_name); g_object_unref (store); g_free (folder_name); return description; }
gboolean e_mail_session_unsubscribe_folder_sync (EMailSession *session, const gchar *folder_uri, GCancellable *cancellable, GError **error) { CamelStore *store = NULL; gchar *folder_name = NULL; const gchar *message; gboolean success = FALSE; g_return_val_if_fail (E_IS_MAIL_SESSION (session), FALSE); g_return_val_if_fail (folder_uri != NULL, FALSE); success = e_mail_folder_uri_parse ( CAMEL_SESSION (session), folder_uri, &store, &folder_name, error); if (!success) return FALSE; message = _("Unsubscribing from folder '%s'"); camel_operation_push_message (cancellable, message, folder_name); /* FIXME This should take our GCancellable. */ success = em_utils_connect_service_sync ( CAMEL_SERVICE (store), cancellable, error) && camel_subscribable_unsubscribe_folder_sync ( CAMEL_SUBSCRIBABLE (store), folder_name, cancellable, error); camel_operation_pop_message (cancellable); g_object_unref (store); g_free (folder_name); return success; }
static gboolean ews_transport_can_server_side_sent_folder (CamelService *service, EwsFolderId **folder_id, GCancellable *cancellable) { CamelSession *session; ESourceRegistry *registry; ESource *sibling, *source = NULL; gboolean is_server_side = FALSE; g_return_val_if_fail (CAMEL_IS_EWS_TRANSPORT (service), FALSE); g_return_val_if_fail (folder_id != NULL, FALSE); session = camel_service_ref_session (service); if (session && E_IS_MAIL_SESSION (session)) registry = g_object_ref (e_mail_session_get_registry (E_MAIL_SESSION (session))); else registry = e_source_registry_new_sync (cancellable, NULL); if (!registry) { g_clear_object (&session); return FALSE; } sibling = e_source_registry_ref_source (registry, camel_service_get_uid (service)); if (sibling) { GList *sources, *siter; sources = e_source_registry_list_sources (registry, E_SOURCE_EXTENSION_MAIL_SUBMISSION); for (siter = sources; siter; siter = siter->next) { source = siter->data; if (!source || g_strcmp0 (e_source_get_parent (source), e_source_get_parent (sibling)) != 0 || !e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_SUBMISSION) || !e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_COMPOSITION)) source = NULL; else break; } if (source && e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_SUBMISSION) && e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_COMPOSITION)) { ESourceMailSubmission *subm_extension; CamelStore *store = NULL; gchar *folder_name = NULL; subm_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_MAIL_SUBMISSION); /* Copy messages on the server side only if the replies might not be saved to the original folder, which is handled by the evolution itself. */ if (!e_source_mail_submission_get_replies_to_origin_folder (subm_extension) && e_source_mail_submission_get_sent_folder (subm_extension) && e_mail_folder_uri_parse (session, e_source_mail_submission_get_sent_folder (subm_extension), &store, &folder_name, NULL) & CAMEL_IS_EWS_STORE (store)) { CamelEwsStore *ews_store = CAMEL_EWS_STORE (store); gchar *folder_id_str; folder_id_str = camel_ews_store_summary_get_folder_id_from_name ( ews_store->summary, folder_name); if (folder_id_str) { gchar *change_key; change_key = camel_ews_store_summary_get_change_key (ews_store->summary, folder_name, NULL); *folder_id = e_ews_folder_id_new (folder_id_str, change_key, FALSE); g_free (change_key); is_server_side = *folder_id != NULL; } g_free (folder_id_str); } g_clear_object (&store); g_free (folder_name); } g_list_free_full (sources, g_object_unref); g_object_unref (sibling); } g_object_unref (registry); g_clear_object (&session); return is_server_side; }
void vfolder_edit_rule (EMailBackend *backend, const gchar *folder_uri) { GtkWidget *dialog; GtkWidget *widget; GtkWidget *container; EFilterRule *rule = NULL; EFilterRule *newrule; EMailSession *session; gchar *folder_name = NULL; g_return_if_fail (E_IS_MAIL_BACKEND (backend)); g_return_if_fail (folder_uri != NULL); session = e_mail_backend_get_session (backend); e_mail_folder_uri_parse ( CAMEL_SESSION (session), folder_uri, NULL, &folder_name, NULL); if (folder_name != NULL) { rule = e_rule_context_find_rule ( (ERuleContext *) context, folder_name, NULL); g_free (folder_name); } if (rule == NULL) { /* TODO: we should probably just create it ... */ e_mail_backend_submit_alert ( backend, "mail:vfolder-notexist", folder_uri, NULL); return; } g_object_ref (rule); newrule = e_filter_rule_clone (rule); dialog = gtk_dialog_new_with_buttons ( _("Edit Search Folder"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_container_set_border_width (GTK_CONTAINER (dialog), 6); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_window_set_default_size (GTK_WINDOW (dialog), 500, 500); gtk_window_set_resizable (GTK_WINDOW (dialog), TRUE); container = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); gtk_box_set_spacing (GTK_BOX (container), 6); widget = e_filter_rule_get_widget ( (EFilterRule *) newrule, (ERuleContext *) context); gtk_box_pack_start (GTK_BOX (container), widget, TRUE, TRUE, 0); gtk_widget_show (widget); g_object_set_data_full (G_OBJECT (dialog), "vfolder-rule", rule, g_object_unref); g_object_set_data_full (G_OBJECT (dialog), "vfolder-newrule", newrule, g_object_unref); g_signal_connect (dialog, "response", G_CALLBACK (vfolder_edit_response_cb), NULL); gtk_widget_show (dialog); }