gint main (gint argc, gchar **argv) { ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; GError *error = NULL; gint ii; main_initialize (); /* Serially create, open, (close), and remove many cals */ for (ii = 0; ii < NUM_CLIENTS; ii++) { ECalClient *cal_client = new_temp_client (source_type, NULL); g_return_val_if_fail (cal_client != NULL, 1); if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); return 1; } if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (cal_client); return 1; } g_object_unref (cal_client); } return 0; }
static gboolean test_sync (void) { ECalClient *cal_client; GError *error = NULL; cal_client = new_temp_client (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL); g_return_val_if_fail (cal_client != NULL, FALSE); if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (cal_client); return FALSE; } if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (cal_client); return FALSE; } g_object_unref (cal_client); return TRUE; }
gint main (gint argc, gchar **argv) { GError *error = NULL; gint ii; main_initialize (); /* Serially create, open, (close), and remove many books */ for (ii = 0; ii < NUM_CLIENTS; ii++) { EBookClient *book_client = new_temp_client (NULL); g_return_val_if_fail (book_client != NULL, 1); if (!e_client_open_sync (E_CLIENT (book_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); return 1; } if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book_client); return 1; } g_object_unref (book_client); } return 0; }
static void action_address_book_delete_cb (GtkAction *action, EBookShellView *book_shell_view) { EShellView *shell_view; EShellWindow *shell_window; EBookShellBackend *book_shell_backend; EBookShellSidebar *book_shell_sidebar; ESource *source; ESourceSelector *selector; ESourceGroup *source_group; ESourceList *source_list; EBookClient *book; gint response; GError *error = NULL; shell_view = E_SHELL_VIEW (book_shell_view); shell_window = e_shell_view_get_shell_window (shell_view); book_shell_backend = book_shell_view->priv->book_shell_backend; source_list = e_book_shell_backend_get_source_list (book_shell_backend); book_shell_sidebar = book_shell_view->priv->book_shell_sidebar; selector = e_book_shell_sidebar_get_selector (book_shell_sidebar); source = e_source_selector_get_primary_selection (selector); g_return_if_fail (source != NULL); response = e_alert_run_dialog_for_args ( GTK_WINDOW (shell_window), "addressbook:ask-delete-addressbook", e_source_peek_name (source), NULL); if (response != GTK_RESPONSE_YES) return; book = e_book_client_new (source, &error); if (error != NULL) { g_warning ("Error removing addressbook: %s", error->message); g_error_free (error); return; } if (!e_client_remove_sync (E_CLIENT (book), NULL, NULL)) { e_alert_run_dialog_for_args ( GTK_WINDOW (shell_window), "addressbook:remove-addressbook", NULL); g_object_unref (book); return; } if (e_source_selector_source_is_selected (selector, source)) e_source_selector_unselect_source (selector, source); source_group = e_source_peek_group (source); e_source_group_remove_source (source_group, source); e_source_list_sync (source_list, NULL); g_object_unref (book); }
gint main (gint argc, gchar **argv) { #if 0 /* ACCOUNT_MGMT */ gchar *uri = NULL; EBookClient *book_client; GError *error = NULL; gint ii; main_initialize (); book_client = new_temp_client (&uri); g_return_val_if_fail (book_client != NULL, 1); g_return_val_if_fail (uri != NULL, 1); g_object_unref (book_client); /* open and close the same book repeatedly */ for (ii = 0; ii < NUM_OPENS; ii++) { book_client = e_book_client_new_from_uri (uri, &error); if (!book_client) { report_error ("new from uri", &error); break; } if (!e_client_open_sync (E_CLIENT (book_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (book_client); break; } g_object_unref (book_client); } book_client = e_book_client_new_from_uri (uri, &error); if (!book_client) { g_clear_error (&error); } else if (!e_client_open_sync (E_CLIENT (book_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (book_client); g_free (uri); return 1; } else if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book_client); g_free (uri); return 1; } g_free (uri); g_object_unref (book_client); return ii == NUM_OPENS ? 0 : 1; #endif /* ACCOUNT_MGMT */ return 0; }
gint main (gint argc, gchar **argv) { ECalClient *cal_client; GError *error = NULL; icalcomponent *icalcomp; struct icaltimetype now; gchar *uid = NULL; main_initialize (); cal_client = new_temp_client (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL); g_return_val_if_fail (cal_client != NULL, FALSE); if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (cal_client); return 1; } now = icaltime_current_time_with_zone (icaltimezone_get_utc_timezone ()); icalcomp = icalcomponent_new (ICAL_VEVENT_COMPONENT); icalcomponent_set_summary (icalcomp, "Test event summary"); icalcomponent_set_dtstart (icalcomp, now); icalcomponent_set_dtend (icalcomp, icaltime_from_timet (icaltime_as_timet (now) + 60 * 60 * 60, 0)); if (!e_cal_client_create_object_sync (cal_client, icalcomp, &uid, NULL, &error)) { report_error ("create object sync", &error); icalcomponent_free (icalcomp); g_object_unref (cal_client); return 1; } icalcomponent_free (icalcomp); g_free (uid); /* synchronously without main-loop */ if (!test_sync (cal_client)) { g_object_unref (cal_client); return 1; } start_in_thread_with_main_loop (test_sync_in_thread, cal_client); if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (cal_client); return 1; } g_object_unref (cal_client); if (get_main_loop_stop_result () == 0) g_print ("Test finished successfully.\n"); return get_main_loop_stop_result (); }
gint main (gint argc, gchar **argv) { ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; gchar *uri = NULL; ECalClient *cal_client; GError *error = NULL; gint ii; main_initialize (); cal_client = new_temp_client (source_type, &uri); g_return_val_if_fail (cal_client != NULL, 1); g_return_val_if_fail (uri != NULL, 1); g_object_unref (cal_client); /* open and close the same cal repeatedly */ for (ii = 0; ii < NUM_OPENS; ii++) { cal_client = e_cal_client_new_from_uri (uri, source_type, &error); if (!cal_client) { report_error ("new from uri", &error); break; } if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (cal_client); break; } g_object_unref (cal_client); } cal_client = e_cal_client_new_from_uri (uri, source_type, &error); if (!cal_client) { g_clear_error (&error); } else if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (cal_client); g_free (uri); return 1; } else if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (cal_client); g_free (uri); return 1; } g_free (uri); g_object_unref (cal_client); return ii == NUM_OPENS ? 0 : 1; }
static void on_delete_cb(GtkAction *action, EShellView *shell_view) { EShellSidebar *shell_sidebar = e_shell_view_get_shell_sidebar(shell_view); ESourceSelector *selector; g_object_get(shell_sidebar, "selector", &selector, NULL); ESource *source = e_source_selector_peek_primary_selection(selector); if (e_alert_run_dialog_for_args(GTK_WINDOW(shell_view), "calendar:prompt-delete-calendar", e_source_peek_name(source), NULL) != GTK_RESPONSE_YES) { g_object_unref (selector); return; } ESourceGroup *group = e_source_peek_group(source); char *calname = (char *)e_source_get_property(source, "eee-calname"); EeeAccount *account; GError *err = NULL; if (!eee_plugin_online) { display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), _("This action is not available with 3e plugin in offline mode.")); g_object_unref (selector); return; } if (!e_source_is_3e_owned_calendar(source)) { display_error_message (gtk_widget_get_toplevel (GTK_WIDGET (selector)), _("This action is available only for 3e calendars.")); g_object_unref (selector); return; } g_object_unref (selector); account = eee_accounts_manager_find_account_by_source(mgr(), source); if (eee_account_delete_calendar(account, calname)) { // get ECal and remove calendar from the server ECalClient *ecal = e_cal_client_new(source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &err); if (!e_client_remove_sync((EClient *)ecal, NULL, &err)) { g_warning("** EEE ** ECal remove failed (%d:%s)", err->code, err->message); g_clear_error(&err); } g_object_unref(ecal); e_source_group_remove_source(group, source); } eee_account_disconnect(account); eee_accounts_manager_restart_sync(mgr()); }
gint main (gint argc, gchar **argv) { EBookClient *book; EBookClientView *view; EBookQuery *query; GError *error = NULL; gchar *sexp; g_type_init (); setup_book (&book); query = e_book_query_any_field_contains (""); sexp = e_book_query_to_string (query); e_book_query_unref (query); if (!e_book_client_get_view_sync (book, sexp, &view, NULL, &error)) { report_error ("get book view sync", &error); g_free (sexp); g_object_unref (book); return 1; } g_free (sexp); setup_and_start_view (view); loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (loop); if (!e_client_remove_sync (E_CLIENT (book), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book); return 1; } g_object_unref (book); return 0; }
gint main (gint argc, gchar **argv) { ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS; ECalClient *cal_clients[NUM_CLIENTS]; GError *error = NULL; gint ii; main_initialize (); /* Create and open many cals; then remove each of them */ for (ii = 0; ii < NUM_CLIENTS; ii++) { cal_clients[ii] = new_temp_client (source_type, NULL); g_return_val_if_fail (cal_clients[ii] != NULL, 1); if (!e_client_open_sync (E_CLIENT (cal_clients[ii]), FALSE, NULL, &error)) { report_error ("client open sync", &error); while (ii >= 0) { g_object_unref (cal_clients[ii]); ii--; } return 1; } } for (ii = 0; ii < NUM_CLIENTS; ii++) { if (!e_client_remove_sync (E_CLIENT (cal_clients[ii]), NULL, &error)) { report_error ("client remove sync", &error); while (ii < NUM_CLIENTS) { g_object_unref (cal_clients[ii]); ii++; } return 1; } g_object_unref (cal_clients[ii]); } return 0; }
gint main (gint argc, gchar **argv) { ECalClient *cal_client; GError *error = NULL; main_initialize (); cal_client = new_temp_client (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL); g_return_val_if_fail (cal_client != NULL, FALSE); if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (cal_client); return 1; } /* synchronously without main-loop */ if (!test_sync (cal_client)) { g_object_unref (cal_client); return 1; } start_in_thread_with_main_loop (test_sync_in_thread, cal_client); if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (cal_client); return 1; } g_object_unref (cal_client); if (get_main_loop_stop_result () == 0) g_print ("Test finished successfully.\n"); return get_main_loop_stop_result (); }
gint main (gint argc, gchar **argv) { ECalClient *cal_client; GError *error = NULL; gint i; main_initialize (); /* * Setup */ cal_client = new_temp_client (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL); g_return_val_if_fail (cal_client != NULL, 1); if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (cal_client); return 1; } /* Test that modifications make the revisions increment */ for (i = 0; i < CYCLES; i++) get_revision_compare_cycle (cal_client); if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (cal_client); return 1; } g_object_unref (cal_client); return 0; }
gint main (gint argc, gchar **argv) { EBookClient *book_client; EBookQuery *query; EBookClientView *view; gchar *sexp; GError *error = NULL; main_initialize (); /* * Sync version */ if (!setup_book (&book_client)) return 1; query = e_book_query_any_field_contains (""); sexp = e_book_query_to_string (query); e_book_query_unref (query); if (!e_book_client_get_view_sync (book_client, sexp, &view, NULL, &error)) { report_error ("get book view sync", &error); g_free (sexp); g_object_unref (book_client); return 1; } g_free (sexp); setup_and_start_view (view); start_main_loop (NULL, NULL); if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book_client); return 1; } g_object_unref (book_client); /* * Async version uids only */ if (!setup_book (&book_client)) return 1; start_in_idle_with_main_loop (call_get_view, book_client); if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book_client); return 1; } g_object_unref (book_client); return get_main_loop_stop_result (); }
gint main (gint argc, gchar **argv) { EBookClient *book_client; GError *error = NULL; EContact *contact; gchar *vcard; main_initialize (); /* * Setup */ book_client = new_temp_client (NULL); g_return_val_if_fail (book_client != NULL, 1); if (!e_client_open_sync (E_CLIENT (book_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (book_client); return 1; } /* * Sync version */ if (!add_contact_from_test_case_verify (book_client, "simple-1", &contact)) { g_object_unref (book_client); return 1; } g_object_unref (contact); if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book_client); return 1; } g_object_unref (book_client); /* * Async version */ book_client = new_temp_client (NULL); g_return_val_if_fail (book_client != NULL, 1); if (!e_client_open_sync (E_CLIENT (book_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (book_client); return 1; } vcard = new_vcard_from_test_case ("simple-1"); contact = e_contact_new_from_vcard (vcard); g_free (vcard); e_book_client_add_contact (book_client, contact, NULL, add_contact_cb, NULL); g_object_unref (contact); start_main_loop (NULL, NULL); if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book_client); return 1; } g_object_unref (book_client); return get_main_loop_stop_result (); }
gint main (gint argc, gchar **argv) { EBookClient *book_client; GError *error = NULL; EContact *contact; gchar *uid; main_initialize (); /* * Setup */ book_client = new_temp_client (NULL); g_return_val_if_fail (book_client != NULL, 1); if (!e_client_open_sync (E_CLIENT (book_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (book_client); return 1; } /* * Sync version */ if (!add_contact_from_test_case_verify (book_client, "simple-1", &contact)) { g_object_unref (book_client); return 1; } uid = e_contact_get (contact, E_CONTACT_UID); g_object_unref (contact); if (!e_book_client_remove_contact_by_uid_sync (book_client, uid, NULL, &error)) { report_error ("remove contact sync", &error); g_object_unref (book_client); g_free (uid); return 1; } if (!e_book_client_get_contact_sync (book_client, uid, &contact, NULL, &error) && g_error_matches (error, E_BOOK_CLIENT_ERROR, E_BOOK_CLIENT_ERROR_CONTACT_NOT_FOUND)) { g_clear_error (&error); } else { report_error ("fail with get contact sync on removed contact", &error); g_object_unref (book_client); g_free (uid); return 1; } g_free (uid); if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book_client); return 1; } g_object_unref (book_client); /* * Async version */ book_client = new_temp_client (NULL); g_return_val_if_fail (book_client != NULL, 1); if (!e_client_open_sync (E_CLIENT (book_client), FALSE, NULL, &error)) { report_error ("client open sync", &error); g_object_unref (book_client); return 1; } contact = NULL; if (!add_contact_from_test_case_verify (book_client, "simple-1", &contact)) { g_object_unref (book_client); return 1; } uid = e_contact_get (contact, E_CONTACT_UID); g_object_unref (contact); e_book_client_remove_contact_by_uid (book_client, uid, NULL, remove_contact_by_uid_cb, uid); start_main_loop (NULL, NULL); g_free (uid); if (!e_client_remove_sync (E_CLIENT (book_client), NULL, &error)) { report_error ("client remove sync", &error); g_object_unref (book_client); return 1; } g_object_unref (book_client); return 0; }