static void action_task_list_delete_cb (GtkAction *action, ETaskShellView *task_shell_view) { ETaskShellSidebar *task_shell_sidebar; EShellWindow *shell_window; EShellView *shell_view; ESource *source; ESourceSelector *selector; gint response; shell_view = E_SHELL_VIEW (task_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); task_shell_sidebar = task_shell_view->priv->task_shell_sidebar; selector = e_task_shell_sidebar_get_selector (task_shell_sidebar); source = e_source_selector_ref_primary_selection (selector); g_return_if_fail (source != NULL); if (e_source_get_remote_deletable (source)) { response = e_alert_run_dialog_for_args ( GTK_WINDOW (shell_window), "calendar:prompt-delete-remote-task-list", e_source_get_display_name (source), NULL); if (response == GTK_RESPONSE_YES) e_shell_view_remote_delete_source (shell_view, source); } else { response = e_alert_run_dialog_for_args ( GTK_WINDOW (shell_window), "calendar:prompt-delete-task-list", e_source_get_display_name (source), NULL); if (response == GTK_RESPONSE_YES) e_shell_view_remove_source (shell_view, source); } g_object_unref (source); }
static void action_address_book_delete_cb (GtkAction *action, EBookShellView *book_shell_view) { EShellView *shell_view; EShellWindow *shell_window; EBookShellSidebar *book_shell_sidebar; ESource *source; ESourceSelector *selector; gint response; shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); source = e_source_selector_ref_primary_selection (selector); g_return_if_fail (source != NULL); if (e_source_get_remote_deletable (source)) { response = e_alert_run_dialog_for_args ( GTK_WINDOW (shell_window), "addressbook:ask-delete-remote-addressbook", e_source_get_display_name (source), NULL); if (response == GTK_RESPONSE_YES) e_shell_view_remote_delete_source (shell_view, source); } else { response = e_alert_run_dialog_for_args ( GTK_WINDOW (shell_window), "addressbook:ask-delete-addressbook", e_source_get_display_name (source), NULL); if (response == GTK_RESPONSE_YES) e_shell_view_remove_source (shell_view, source); } g_object_unref (source); }
static void source_viewer_update_row (ESourceViewer *viewer, ESource *source) { GHashTable *source_index; GtkTreeRowReference *reference; GtkTreeModel *model; GtkTreePath *path; GtkTreeIter iter; const gchar *display_name; const gchar *source_uid; gboolean removable; gboolean writable; gboolean remote_creatable; gboolean remote_deletable; source_index = viewer->source_index; reference = g_hash_table_lookup (source_index, source); /* We show all sources, so the reference should be valid. */ g_return_if_fail (gtk_tree_row_reference_valid (reference)); model = gtk_tree_row_reference_get_model (reference); path = gtk_tree_row_reference_get_path (reference); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); source_uid = e_source_get_uid (source); display_name = e_source_get_display_name (source); removable = e_source_get_removable (source); writable = e_source_get_writable (source); remote_creatable = e_source_get_remote_creatable (source); remote_deletable = e_source_get_remote_deletable (source); gtk_tree_store_set ( GTK_TREE_STORE (model), &iter, COLUMN_DISPLAY_NAME, display_name, COLUMN_SOURCE_UID, source_uid, COLUMN_REMOVABLE, removable, COLUMN_WRITABLE, writable, COLUMN_REMOTE_CREATABLE, remote_creatable, COLUMN_REMOTE_DELETABLE, remote_deletable, COLUMN_SOURCE, source, -1); }
static inline void debug_dump_ecal_list (GHashTable *clients) { #ifdef CALENDAR_ENABLE_DEBUG GList *list, *link; dprintf ("Loaded clients:\n"); list = g_hash_table_get_keys (clients); for (link = list; link != NULL; link = g_list_next (link)) { ESource *source = E_SOURCE (link->data); dprintf (" %s %s\n", e_source_get_uid (source), e_source_get_display_name (source)); } #endif }
static void backend_died_cb (EClient *client, CalendarSourceData *source_data) { ESource *source; const char *display_name; source = e_client_get_source (client); display_name = e_source_get_display_name (source); g_warning ("The calendar backend for '%s' has crashed.", display_name); g_hash_table_remove (source_data->clients, source); if (source_data->timeout_id != 0) { g_source_remove (source_data->timeout_id); source_data->timeout_id = 0; } source_data->timeout_id = g_timeout_add_seconds (2, backend_restart, source_data); }
static void address_book_refresh_done_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { EClient *client; ESource *source; EActivity *activity; EAlertSink *alert_sink; const gchar *display_name; GError *local_error = NULL; g_return_if_fail (E_IS_CLIENT (source_object)); client = E_CLIENT (source_object); source = e_client_get_source (client); activity = user_data; e_client_refresh_finish (client, result, &local_error); alert_sink = e_activity_get_alert_sink (activity); display_name = e_source_get_display_name (source); if (e_activity_handle_cancellation (activity, local_error)) { /* nothing to do */ } else if (local_error != NULL) { e_alert_submit ( alert_sink, "addressbook:refresh-error", display_name, local_error->message, NULL); } else { e_activity_set_state (activity, E_ACTIVITY_COMPLETED); } g_clear_object (&activity); g_clear_error (&local_error); }
static void source_util_remove_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { ESource *source; EActivity *activity; EAlertSink *alert_sink; AsyncContext *async_context; const gchar *display_name; GError *error = NULL; source = E_SOURCE (source_object); async_context = (AsyncContext *) user_data; activity = async_context->activity; alert_sink = e_activity_get_alert_sink (activity); display_name = e_source_get_display_name (source); e_source_remove_finish (source, result, &error); if (e_activity_handle_cancellation (activity, error)) { g_error_free (error); } else if (error != NULL) { e_alert_submit ( alert_sink, "system:remove-source-fail", display_name, error->message, NULL); g_error_free (error); } else { e_activity_set_state (activity, E_ACTIVITY_COMPLETED); } async_context_free (async_context); }
/** * e_trust_prompt_run_for_source: * @parent: A #GtkWindow to use as a parent for the trust prompt dialog * @source: an #ESource, with %E_SOURCE_EXTENSION_AUTHENTICATION * @certificate_pem: a PEM-encoded certificate for which to show the trust prompt * @certificate_errors: errors of the @certificate_pem * @error_text: (allow-none): an optional error text to show in the dialog; can be %NULL * @allow_source_save: whether can also save any @source changes * @cancellable: (allow-none): a #GCancellable, or %NULL * @callback: a callback to call, when the prompt (an @source save) is done * @user_data: user data passed into @callback * * Similar to e_trust_prompt_run_modal(), except it also manages all the necessary things * around the @source<!-- -->'s SSL/TLS trust properties when it also contains %E_SOURCE_EXTENSION_WEBDAV, * thus the SSL/TLS trust on the WebDAV @source is properly updated based on the user's choice. * The call is finished with e_trust_prompt_run_for_source_finish(), * which also returns the user's choice. The finish happens in the @callback. * This is necessary, because the @source can be also saved. * * The function fails, if the @source doesn't contain the %E_SOURCE_EXTENSION_AUTHENTICATION. * * Note: The dialog is not shown when the stored certificate trust in the WebDAV @source * matches the @certificate_pem and the stored result is #E_TRUST_PROMPT_RESPONSE_REJECT. * * Since: 3.16 **/ void e_trust_prompt_run_for_source (GtkWindow *parent, ESource *source, const gchar *certificate_pem, GTlsCertificateFlags certificate_errors, const gchar *error_text, gboolean allow_source_save, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { ESourceAuthentication *extension_authentication = NULL; ESourceWebdav *extension_webdav = NULL; SaveSourceData *save_data; GTlsCertificate *certificate; gchar *host; GTask *task; if (parent) g_return_if_fail (GTK_IS_WINDOW (parent)); g_return_if_fail (E_IS_SOURCE (source)); g_return_if_fail (certificate_pem != NULL); if (e_source_has_extension (source, E_SOURCE_EXTENSION_GOA) || e_source_has_extension (source, E_SOURCE_EXTENSION_UOA)) { /* Make sure that GOA/UOA collection sources contain these extensions too */ g_warn_if_fail (e_source_get_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION)); g_warn_if_fail (e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND)); } if (e_source_has_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION)) extension_authentication = e_source_get_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION); if (e_source_has_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND)) extension_webdav = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND); save_data = g_new0 (SaveSourceData, 1); save_data->response = E_TRUST_PROMPT_RESPONSE_UNKNOWN; save_data->call_save = FALSE; /* Lookup used host name */ if (extension_authentication) host = e_source_authentication_dup_host (extension_authentication); else host = NULL; if (!host || !*host) { g_free (host); host = NULL; if (e_source_has_extension (source, E_SOURCE_EXTENSION_GOA)) { ESourceGoa *goa_extension; gchar *url; goa_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_GOA); url = e_source_goa_dup_calendar_url (goa_extension); host = trust_prompt_get_host_from_url (url); g_free (url); if (!host) { url = e_source_goa_dup_contacts_url (goa_extension); host = trust_prompt_get_host_from_url (url); g_free (url); } } } certificate = g_tls_certificate_new_from_pem (certificate_pem, -1, &save_data->error); if (certificate) { if (extension_webdav && host) save_data->response = e_source_webdav_verify_ssl_trust (extension_webdav, host, certificate, 0); else save_data->response = E_TRUST_PROMPT_RESPONSE_REJECT_TEMPORARILY; if (save_data->response != E_TRUST_PROMPT_RESPONSE_REJECT) { const gchar *source_extension = NULL; if (e_source_has_extension (source, E_SOURCE_EXTENSION_ADDRESS_BOOK)) source_extension = E_SOURCE_EXTENSION_ADDRESS_BOOK; if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_CALENDAR; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } if (e_source_has_extension (source, E_SOURCE_EXTENSION_MEMO_LIST)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_MEMO_LIST; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_TASK_LIST; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_ACCOUNT)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_MAIL_ACCOUNT; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } if (e_source_has_extension (source, E_SOURCE_EXTENSION_MAIL_TRANSPORT)) { if (!source_extension) source_extension = E_SOURCE_EXTENSION_MAIL_TRANSPORT; else source_extension = E_SOURCE_EXTENSION_COLLECTION; } save_data->response = e_trust_prompt_run_with_dialog_ready_callback (parent, source_extension, e_source_get_display_name (source), host, certificate_pem, certificate_errors, error_text, trust_prompt_listen_for_source_changes_cb, source); } } g_signal_handlers_disconnect_matched (source, G_SIGNAL_MATCH_FUNC, 0, 0, NULL, source_connection_status_changed_cb, NULL); if (save_data->response != E_TRUST_PROMPT_RESPONSE_UNKNOWN) { if (certificate && extension_webdav) { e_source_webdav_update_ssl_trust (extension_webdav, host, certificate, save_data->response); save_data->call_save = allow_source_save; } } g_clear_object (&certificate); g_free (host); task = g_task_new (source, cancellable, callback, user_data); g_task_set_source_tag (task, e_trust_prompt_run_for_source); g_task_set_task_data (task, save_data, save_source_data_free); g_task_run_in_thread (task, save_source_thread); g_object_unref (task); }
static void do_save_calendar_rdf (FormatHandler *handler, ESourceSelector *selector, ECalClientSourceType type, gchar *dest_uri) { /* * According to some documentation about CSV, newlines 'are' allowed * in CSV-files. But you 'do' have to put the value between quotes. * The helper 'string_needsquotes' will check for that * * http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm * http://www.creativyst.com/cgi-bin/Prod/15/eg/csv2xml.pl */ ESource *primary_source; EClient *source_client; GError *error = NULL; GSList *objects = NULL; gchar *temp = NULL; GOutputStream *stream; if (!dest_uri) return; /* open source client */ primary_source = e_source_selector_ref_primary_selection (selector); source_client = e_cal_client_connect_sync ( primary_source, type, NULL, &error); g_object_unref (primary_source); /* Sanity check. */ g_return_if_fail ( ((source_client != NULL) && (error == NULL)) || ((source_client == NULL) && (error != NULL))); if (source_client == NULL) { display_error_message ( gtk_widget_get_toplevel (GTK_WIDGET (selector)), error->message); g_error_free (error); return; } stream = open_for_writing (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (selector))), dest_uri, &error); if (stream && e_cal_client_get_object_list_as_comps_sync (E_CAL_CLIENT (source_client), "#t", &objects, NULL, NULL)) { GSList *iter; xmlBufferPtr buffer = xmlBufferCreate (); xmlDocPtr doc = xmlNewDoc ((xmlChar *) "1.0"); xmlNodePtr fnode; doc->children = xmlNewDocNode (doc, NULL, (const guchar *)"rdf:RDF", NULL); xmlSetProp (doc->children, (const guchar *)"xmlns:rdf", (const guchar *)"http://www.w3.org/1999/02/22-rdf-syntax-ns#"); xmlSetProp (doc->children, (const guchar *)"xmlns", (const guchar *)"http://www.w3.org/2002/12/cal/ical#"); fnode = xmlNewChild (doc->children, NULL, (const guchar *)"Vcalendar", NULL); /* Should Evolution publicise these? */ xmlSetProp (fnode, (const guchar *)"xmlns:x-wr", (const guchar *)"http://www.w3.org/2002/12/cal/prod/Apple_Comp_628d9d8459c556fa#"); xmlSetProp (fnode, (const guchar *)"xmlns:x-lic", (const guchar *)"http://www.w3.org/2002/12/cal/prod/Apple_Comp_628d9d8459c556fa#"); /* Not sure if it's correct like this */ xmlNewChild (fnode, NULL, (const guchar *)"prodid", (const guchar *)"-//" PACKAGE_STRING "//iCal 1.0//EN"); /* Assuming GREGORIAN is the only supported calendar scale */ xmlNewChild (fnode, NULL, (const guchar *)"calscale", (const guchar *)"GREGORIAN"); temp = calendar_config_get_timezone (); xmlNewChild (fnode, NULL, (const guchar *)"x-wr:timezone", (guchar *) temp); g_free (temp); xmlNewChild (fnode, NULL, (const guchar *)"method", (const guchar *)"PUBLISH"); xmlNewChild (fnode, NULL, (const guchar *)"x-wr:relcalid", (guchar *) e_source_get_uid (primary_source)); xmlNewChild (fnode, NULL, (const guchar *)"x-wr:calname", (guchar *) e_source_get_display_name (primary_source)); /* Version of this RDF-format */ xmlNewChild (fnode, NULL, (const guchar *)"version", (const guchar *)"2.0"); for (iter = objects; iter; iter = iter->next) { ECalComponent *comp = iter->data; const gchar *temp_constchar; gchar *tmp_str = NULL; GSList *temp_list; ECalComponentDateTime temp_dt; struct icaltimetype *temp_time; gint *temp_int; ECalComponentText temp_comptext; xmlNodePtr c_node = xmlNewChild (fnode, NULL, (const guchar *)"component", NULL); xmlNodePtr node = xmlNewChild (c_node, NULL, (const guchar *)"Vevent", NULL); /* Getting the stuff */ e_cal_component_get_uid (comp, &temp_constchar); tmp_str = g_strdup_printf ("#%s", temp_constchar); xmlSetProp (node, (const guchar *)"about", (guchar *) tmp_str); g_free (tmp_str); add_string_to_rdf (node, "uid",temp_constchar); e_cal_component_get_summary (comp, &temp_comptext); add_string_to_rdf (node, "summary", temp_comptext.value); e_cal_component_get_description_list (comp, &temp_list); add_list_to_rdf (node, "description", temp_list, ECALCOMPONENTTEXT); if (temp_list) e_cal_component_free_text_list (temp_list); e_cal_component_get_categories_list (comp, &temp_list); add_list_to_rdf (node, "categories", temp_list, CONSTCHAR); if (temp_list) e_cal_component_free_categories_list (temp_list); e_cal_component_get_comment_list (comp, &temp_list); add_list_to_rdf (node, "comment", temp_list, ECALCOMPONENTTEXT); if (temp_list) e_cal_component_free_text_list (temp_list); e_cal_component_get_completed (comp, &temp_time); add_time_to_rdf (node, "completed", temp_time); if (temp_time) e_cal_component_free_icaltimetype (temp_time); e_cal_component_get_created (comp, &temp_time); add_time_to_rdf (node, "created", temp_time); if (temp_time) e_cal_component_free_icaltimetype (temp_time); e_cal_component_get_contact_list (comp, &temp_list); add_list_to_rdf (node, "contact", temp_list, ECALCOMPONENTTEXT); if (temp_list) e_cal_component_free_text_list (temp_list); e_cal_component_get_dtstart (comp, &temp_dt); add_time_to_rdf (node, "dtstart", temp_dt.value ? temp_dt.value : NULL); e_cal_component_free_datetime (&temp_dt); e_cal_component_get_dtend (comp, &temp_dt); add_time_to_rdf (node, "dtend", temp_dt.value ? temp_dt.value : NULL); e_cal_component_free_datetime (&temp_dt); e_cal_component_get_due (comp, &temp_dt); add_time_to_rdf (node, "due", temp_dt.value ? temp_dt.value : NULL); e_cal_component_free_datetime (&temp_dt); e_cal_component_get_percent (comp, &temp_int); add_nummeric_to_rdf (node, "percentComplete", temp_int); e_cal_component_get_priority (comp, &temp_int); add_nummeric_to_rdf (node, "priority", temp_int); e_cal_component_get_url (comp, &temp_constchar); add_string_to_rdf (node, "URL", temp_constchar); if (e_cal_component_has_attendees (comp)) { e_cal_component_get_attendee_list (comp, &temp_list); add_list_to_rdf (node, "attendee", temp_list, ECALCOMPONENTATTENDEE); if (temp_list) e_cal_component_free_attendee_list (temp_list); } e_cal_component_get_location (comp, &temp_constchar); add_string_to_rdf (node, "location", temp_constchar); e_cal_component_get_last_modified (comp, &temp_time); add_time_to_rdf (node, "lastModified",temp_time); /* Important note! * The documentation is not requiring this! * * if (temp_time) e_cal_component_free_icaltimetype (temp_time); * * Please uncomment and fix documentation if untrue * http://www.gnome.org/projects/evolution/developer-doc/libecal/ECalComponent.html * #e-cal-component-get-last-modified */ } /* I used a buffer rather than xmlDocDump: I want gio support */ xmlNodeDump (buffer, doc, doc->children, 2, 1); g_output_stream_write_all (stream, xmlBufferContent (buffer), xmlBufferLength (buffer), NULL, NULL, &error); g_output_stream_close (stream, NULL, NULL); e_cal_client_free_ecalcomp_slist (objects); xmlBufferFree (buffer); xmlFreeDoc (doc); } if (stream) g_object_unref (stream); g_object_unref (source_client); if (error != NULL) { display_error_message ( gtk_widget_get_toplevel (GTK_WIDGET (selector)), error->message); g_error_free (error); } }
gint main (gint argc, gchar *argv[]) { CamelSession *session; CamelService *service; ESourceRegistry *registry; GList *list, *link; const gchar *extension_name; g_type_init (); system ("rm -rf /tmp/test-map"); camel_init ("/tmp/test-map", TRUE); e_source_camel_register_types (); session = g_object_new ( CAMEL_TYPE_SESSION, "user-data-dir", "/tmp/test-map", "user-cache-dir", "/tmp/test-map/cache", NULL); /* Browse through the ESource registry to find out the MAP account */ registry = e_source_registry_new_sync (NULL, NULL); extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT; list = e_source_registry_list_sources (registry, extension_name); for (link = list; link != NULL; link = g_list_next (link)) { ESource *source = E_SOURCE (link->data); const gchar *uid; const gchar *backend_name = "INVALID"; const gchar *display_name; ESourceBackend *extension; if (!e_source_get_enabled (source)) continue; uid = e_source_get_uid (source); display_name = e_source_get_display_name (source); printf("Looking for: %s\n", display_name); extension = e_source_get_extension (source, extension_name); backend_name = e_source_backend_get_backend_name (extension); if (strcmp (backend_name, "map") == 0) { /* Lets add just map backend to the session. */ CamelFolderInfo *info; CamelFolder *folder; GPtrArray *uids; int i; GError *error=NULL; service = camel_session_add_service ( CAMEL_SESSION (session), uid, backend_name, CAMEL_PROVIDER_STORE, NULL); e_source_camel_configure_service (source, service); camel_service_connect_sync (service, NULL, NULL); info = camel_store_get_folder_info_sync ( CAMEL_STORE (service), "", 0, NULL, NULL); print_folder_info (info, 0); folder = camel_store_get_folder_sync ( CAMEL_STORE (service), "inbox", 0, NULL, NULL); camel_folder_refresh_info_sync (folder, NULL, &error); if (error) printf("Refresh info failed: %s\n", error->message); uids = camel_folder_get_uids (folder); printf("Length of messages: %p %d\n", folder, uids->len); for (i=0; i<uids->len; i++) printf("UID: %s\n", (char *)uids->pdata[i]); } } return 0; }