コード例 #1
0
static gboolean
source_viewer_initable_init (GInitable *initable,
                             GCancellable *cancellable,
                             GError **error)
{
	ESourceViewer *viewer;
	ESourceRegistry *registry;

	viewer = E_SOURCE_VIEWER (initable);

	registry = e_source_registry_new_sync (cancellable, error);

	if (registry == NULL)
		return FALSE;

	viewer->registry = registry;  /* takes ownership */

	g_signal_connect (
		registry, "source-added",
		G_CALLBACK (source_viewer_source_added_cb), viewer);

	g_signal_connect (
		registry, "source-changed",
		G_CALLBACK (source_viewer_source_changed_cb), viewer);

	g_signal_connect (
		registry, "source-removed",
		G_CALLBACK (source_viewer_source_removed_cb), viewer);

	source_viewer_build_model (viewer);

	gtk_tree_view_expand_all (GTK_TREE_VIEW (viewer->tree_view));

	return TRUE;
}
コード例 #2
0
static void
calendar_sources_init (CalendarSources *sources)
{
  GError *error = NULL;

  sources->priv = CALENDAR_SOURCES_GET_PRIVATE (sources);

  /* XXX Not sure what to do if this fails.
   *     Should this class implement GInitable or pass the
   *     registry in as a G_PARAM_CONSTRUCT_ONLY property? */
  sources->priv->registry = e_source_registry_new_sync (NULL, &error);
  if (error != NULL)
    {
      g_error ("%s: %s", G_STRFUNC, error->message);
    }

  sources->priv->source_added_id   = g_signal_connect (sources->priv->registry,
                                                       "source-added",
                                                       G_CALLBACK (calendar_sources_registry_source_changed_cb),
                                                       sources);
  sources->priv->source_changed_id = g_signal_connect (sources->priv->registry,
                                                       "source-changed",
                                                       G_CALLBACK (calendar_sources_registry_source_changed_cb),
                                                       sources);
  sources->priv->source_removed_id = g_signal_connect (sources->priv->registry,
                                                       "source-removed",
                                                       G_CALLBACK (calendar_sources_registry_source_removed_cb),
                                                       sources);

  sources->priv->appointment_sources.source_type    = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
  sources->priv->appointment_sources.sources        = sources;
  sources->priv->appointment_sources.changed_signal = signals [APPOINTMENT_SOURCES_CHANGED];
  sources->priv->appointment_sources.clients        = g_hash_table_new_full ((GHashFunc) e_source_hash,
                                                                             (GEqualFunc) e_source_equal,
                                                                             (GDestroyNotify) g_object_unref,
                                                                             (GDestroyNotify) client_data_free);
  sources->priv->appointment_sources.timeout_id     = 0;

  sources->priv->task_sources.source_type    = E_CAL_CLIENT_SOURCE_TYPE_TASKS;
  sources->priv->task_sources.sources        = sources;
  sources->priv->task_sources.changed_signal = signals [TASK_SOURCES_CHANGED];
  sources->priv->task_sources.clients        = g_hash_table_new_full ((GHashFunc) e_source_hash,
                                                                      (GEqualFunc) e_source_equal,
                                                                      (GDestroyNotify) g_object_unref,
                                                                      (GDestroyNotify) client_data_free);
  sources->priv->task_sources.timeout_id     = 0;
}
コード例 #3
0
gint
main (gint argc,
      gchar **argv)
{
	ESourceRegistry *registry;
	ESource *source = NULL;
	GtkWidget *config;
	GtkWidget *dialog;
	GError *error = NULL;

	gtk_init (&argc, &argv);

	registry = e_source_registry_new_sync (NULL, &error);

	if (error != NULL) {
		g_printerr ("%s\n", error->message);
		exit (EXIT_FAILURE);
	}

	if (argc > 1) {
		source = e_source_registry_ref_source (registry, argv[1]);
		if (source == NULL) {
			g_printerr ("No such UID: %s\n", argv[1]);
			exit (EXIT_FAILURE);
		}
	}

	config = e_source_config_new (registry, source);
	dialog = e_source_config_dialog_new (E_SOURCE_CONFIG (config));

	g_signal_connect (
		dialog, "response",
		G_CALLBACK (dialog_response), NULL);

	gtk_widget_show (config);
	gtk_widget_show (dialog);

	g_object_unref (source);

	gtk_main ();

	e_util_cleanup_settings ();

	return 0;
}
コード例 #4
0
gint
main (gint argc,
      gchar **argv)
{
	ESourceRegistry *registry;
	GtkWidget *window;
	GtkWidget *widget;
	GError *local_error = NULL;

	gtk_init (&argc, &argv);

	registry = e_source_registry_new_sync (NULL, &local_error);

	if (local_error != NULL) {
		g_error (
			"Failed to load ESource registry: %s",
			local_error->message);
		g_assert_not_reached ();
	}

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_container_set_border_width (GTK_CONTAINER (window), 12);
	gtk_window_set_default_size (GTK_WINDOW (window), 400, 300);
	gtk_window_set_title (GTK_WINDOW (window), "Proxy Preferences");
	gtk_widget_show (window);

	g_signal_connect (
		window, "delete-event",
		G_CALLBACK (delete_event_cb), NULL);

	widget = e_proxy_preferences_new (registry);
	gtk_container_add (GTK_CONTAINER (window), widget);
	preferences = E_PROXY_PREFERENCES (widget);
	gtk_widget_show (widget);

	g_object_unref (registry);

	gtk_main ();

	return 0;
}
コード例 #5
0
gint
main (gint argc,
      gchar **argv)
{
	ESourceRegistry *registry;
	EMailAutoconfig *autoconfig;
	GError *error = NULL;

	if (argc < 2) {
		g_printerr ("USAGE: %s EMAIL-ADDRESS\n", argv[0]);
		exit (EXIT_FAILURE);
	}

	registry = e_source_registry_new_sync (NULL, &error);

	if (registry != NULL) {
		autoconfig = e_mail_autoconfig_new_sync (
			registry, argv[1], NULL, &error);
		g_object_unref (registry);
	}

	/* Sanity check. */
	g_assert (
		((autoconfig != NULL) && (error == NULL)) ||
		((autoconfig == NULL) && (error != NULL)));

	if (error != NULL) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		exit (EXIT_FAILURE);
	}

	e_mail_autoconfig_dump_results (autoconfig);

	g_object_unref (autoconfig);

	return EXIT_SUCCESS;
}
コード例 #6
0
/* Entry point for this file, here we take care of
 * creating the addressbook if it doesnt exist,
 * getting an EBookClient, and creating our EBookClientCursor.
 */
EBookClient *
cursor_load_data (const gchar *vcard_path,
                  EBookClientCursor **ret_cursor)
{
	ESourceRegistry *registry;
	ESource *scratch;
	ESourceBackend *backend = NULL;
	GMainLoop *loop;
	GError  *error = NULL;
	EBookClient *ret_book;

	g_return_val_if_fail (vcard_path != NULL, NULL);
	g_return_val_if_fail (ret_cursor != NULL, NULL);

	g_print ("Cursor loading data from %s\n", vcard_path);

	loop = g_main_loop_new (NULL, FALSE);

	registry = e_source_registry_new_sync (NULL, &error);
	if (!registry)
		g_error ("Unable to create the registry: %s", error->message);

	/* Listen to the registry for our added source */
	g_signal_connect (
		registry, "source-added",
		G_CALLBACK (cursor_data_source_added), loop);

	/* Now create a scratch source for our addressbook */
	scratch = e_source_new_with_uid (CURSOR_DATA_SOURCE_ID, NULL, &error);

	/* Ensure the new ESource will be a local addressbook source */
	backend = e_source_get_extension (scratch, E_SOURCE_EXTENSION_ADDRESS_BOOK);
	e_source_backend_set_backend_name (backend, "local");

	/* Now is the right time to use the ESourceBackendSummarySetup to configure
	 * your newly created addressbook. This configuration should happen on the
	 * scratch source before calling e_source_registry_commit_source_sync().
	 */

	/* Commit the source to the registry */
	if (!e_source_registry_commit_source_sync (registry, scratch, NULL, &error)) {

		/* It's possible the source already exists if we already ran the example with this data server */
		if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
			/* If so... then just call our callback early */
			ESource *source = e_source_registry_ref_source (registry, CURSOR_DATA_SOURCE_ID);

			g_clear_error (&error);
			g_return_val_if_fail (E_IS_SOURCE (source), NULL);

			/* Run the callback which creates the addressbook client connection */
			cursor_data_source_added (registry, source, NULL);
			g_object_unref (source);
		} else
			g_error ("Unable to add new addressbook source to the registry: %s", error->message);
	}

	g_object_unref (scratch);

	/* Give EDS a little time to actually create the ESource remotely and
	 * also have a copy if it cached locally, wait for the "source-added"
	 * signal.
	 */
	if (address_book == NULL) {
		g_timeout_add_seconds (20, cursor_data_source_timeout, NULL);
		g_main_loop_run (loop);

		/* By now we aborted or we have an addressbook created */
		g_return_val_if_fail (address_book != NULL, NULL);
	}

	/**********************************************************
	 * Ok, done with creating an addressbook, let's add data  *
	 **********************************************************/
	load_contacts (address_book, vcard_path);

	/* Addressbook should have contacts now, let's create the cursor */
	*ret_cursor = get_cursor (address_book);

	/* Cleanup some resources we used to populate the addressbook */
	g_main_loop_unref (loop);
	g_object_unref (address_book_source);
	g_object_unref (registry);

	/* Give the ref through the return value*/
	ret_book = address_book;

	address_book_source = NULL;
	address_book = NULL;

	/* Return the addressbook */
	return ret_book;
}
コード例 #7
0
gint
main (gint argc,
      gchar **argv)
{
	ActionContext actctx;
	GOptionContext *context;
	GError *error = NULL;

	gint current_action = ACTION_NOTHING;
	gint IsCSV = FALSE;
	gint IsVCard = FALSE;

#ifdef G_OS_WIN32
	e_util_win32_initialize ();
#endif

	/*i18n-lize */
	bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	context = g_option_context_new (NULL);
	g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		exit (-1);
	}

	actctx.registry = e_source_registry_new_sync (NULL, &error);
	if (error != NULL) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		exit (-1);
	}

	/* Parsing Parameter */
	if (opt_remaining && g_strv_length (opt_remaining) > 0)
		opt_addressbook_source_uid = g_strdup (opt_remaining[0]);

	if (opt_list_folders_mode != FALSE) {
		current_action = ACTION_LIST_FOLDERS;
		if (opt_addressbook_source_uid != NULL || opt_output_format != NULL) {
			g_warning (_("Command line arguments error, please use --help option to see the usage."));
			exit (-1);
		}
	} else {

		current_action = ACTION_LIST_CARDS;

		/* check the output format */
		if (opt_output_format == NULL) {
			IsVCard = TRUE;
		} else {
			IsCSV = !strcmp (opt_output_format, "csv");
			IsVCard = !strcmp (opt_output_format, "vcard");
			if (IsCSV == FALSE && IsVCard == FALSE) {
				g_warning (_("Only support csv or vcard format."));
				exit (-1);
			}
		}
	}

	/* do actions */
	if (current_action == ACTION_LIST_FOLDERS) {
		actctx.action_type = current_action;
		if (opt_output_file == NULL) {
			actctx.output_file = NULL;
		} else {
			actctx.output_file = g_strdup (opt_output_file);
		}
		action_list_folders_init (&actctx);

	} else if (current_action == ACTION_LIST_CARDS) {
		actctx.action_type = current_action;
		if (opt_output_file == NULL) {
			actctx.output_file = NULL;
		} else {
			actctx.output_file = g_strdup (opt_output_file);
		}
		actctx.IsCSV = IsCSV;
		actctx.IsVCard = IsVCard;
		actctx.addressbook_source_uid =
			g_strdup (opt_addressbook_source_uid);

		action_list_cards_init (&actctx);

	} else {
		g_warning (_("Unhandled error"));
		exit (-1);
	}

	g_object_unref (actctx.registry);

	/*FIXME:should free actctx's some gchar * field, such as output_file! but since the program will end, so that will not cause mem leak.  */

	return 0;
}
コード例 #8
0
static void add_gnome_addressbook(GList **address_list)
{
  ESourceRegistry * registry = NULL;
  GError *error = NULL;
  GList *a;

  registry = e_source_registry_new_sync (NULL, &error);

  if (!registry || error) {
    debug_print("Error: Failed to get access to source registry: %s\n", error->message);
    g_error_free(error);
    return;
  }

  // create book accessor if necessary
  if(!eds_books) {
    GList *list_sources = e_source_registry_list_sources (registry, E_SOURCE_EXTENSION_ADDRESS_BOOK);
    for (a = list_sources; a; a = a->next) {
      ESource *source = E_SOURCE (a->data);
      if (e_source_get_enabled(source)) {
        EBook *eds_book = e_book_new(source, &error);

        if(!eds_book) {
          g_list_free_full(list_sources, g_object_unref);
          debug_print("Error: Could not get eds addressbook: %s\n", error->message);
          g_error_free(error);
          return;
        }
        eds_books = g_list_append (eds_books, eds_book);
      }
    }
    g_list_free_full(list_sources, g_object_unref);
  }

  for (a = eds_books; a; a = a->next) {
    EBook *eds_book = a->data;
    EBookQuery *query;
    EBookView *view;

    // open book if necessary
    if(!e_book_is_opened(eds_book) && !e_book_open(eds_book, TRUE, &error)) {
      debug_print("Error: Could not open eds addressbook: %s\n", error->message);
      g_error_free(error);
      return;
    }

    // query book
    query = e_book_query_field_exists(E_CONTACT_EMAIL);
    if(!e_book_get_book_view(eds_book, query, NULL, 0, &view, &error)) {
      debug_print("Error: Could not get eds addressbook view: %s\n", error->message);
      g_error_free(error);
    }
    e_book_query_unref(query);

    g_signal_connect(G_OBJECT(view), "contacts-added", G_CALLBACK(eds_contacts_added_cb), address_list);
    g_signal_connect(G_OBJECT(view), "sequence-complete", G_CALLBACK(eds_sequence_complete_cb), NULL);

    eds_waiting = TRUE;
    e_book_view_start(view);

    while(eds_waiting)
      gtk_main_iteration();

    e_book_view_stop(view);
    g_object_unref(view);
  }

}
コード例 #9
0
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;
}
コード例 #10
0
ファイル: camel-test.c プロジェクト: sragavan/evolution-map
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;
}
コード例 #11
0
enum OpenAB_Storage::Storage::eInit EDSCalendarStorage::init()
{
  LOG_FUNC() << "DB: " << database<<std::endl;

  GError *gerror = NULL;

  // 1. Get access to all databases in EDS.
  registry = e_source_registry_new_sync(NULL, &gerror);
  if (!registry)
  {
    LOG_ERROR() << "e_source_registry not found " << GERROR_MESSAGE(gerror)<<std::endl;
    GERROR_FREE(gerror);
    return eInitFail;
  }

  // 2. Look up one particular database.
  // special use case - "system" db - use system storage
  std::string dbName = database;
  if (dbName == "system")
  {
    if (OpenAB::eEvent == getItemType())
    {
      source = e_source_registry_ref_default_calendar(registry);
    }
    else if (OpenAB::eTask == getItemType())
    {
      source = e_source_registry_ref_default_task_list(registry);
    }
  }
  else
  {
    source = e_source_registry_ref_source(registry, dbName.c_str());
  }

  if (!source)
  {
    LOG_ERROR() << "e_source not found"<<std::endl;
    GERROR_FREE(gerror);
    return eInitFail;
  }

  GERROR_FREE(gerror);

  const gchar *userDataDir = NULL;
  userDataDir = e_get_user_data_dir();
  gchar* dirname = NULL;

  if (OpenAB::eEvent == getItemType())
  {
    client = (ECalClient *) e_cal_client_connect_sync(source, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL, &gerror);
    dirname = g_build_filename(userDataDir, "calendar", dbName.c_str(), "calendar.ics", NULL);

  }
  else
  {
    client = (ECalClient *) e_cal_client_connect_sync(source, E_CAL_CLIENT_SOURCE_TYPE_TASKS, NULL, &gerror);
    dirname = g_build_filename(userDataDir, "tasks", dbName.c_str(), "tasks.ics", NULL);
  }

  databaseFileName = dirname;
  g_free(dirname);

  if (gerror)
  {
    LOG_ERROR() << "Error e_cal_client_connect_sync results: " << GERROR_MESSAGE(gerror)<<std::endl;
    GERROR_FREE(gerror);
    return eInitFail;
  }
  LOG_VERBOSE() << "e_cal_client_connect_sync\n"<<std::endl;

  return eInitOk;
}