Ejemplo n.º 1
0
static void
calendar_sources_registry_source_changed_cb (ESourceRegistry *registry,
                                             ESource         *source,
                                             CalendarSources *sources)
{
  if (e_source_has_extension (source, E_SOURCE_EXTENSION_CALENDAR))
    {
      CalendarSourceData *source_data;
      ESourceSelectable *extension;
      gboolean have_client;
      gboolean show_source;

      source_data = &sources->priv->appointment_sources;
      extension = e_source_get_extension (source, E_SOURCE_EXTENSION_CALENDAR);
      have_client = (g_hash_table_lookup (source_data->clients, source) != NULL);
      show_source = e_source_get_enabled (source) && e_source_selectable_get_selected (extension);

      if (!show_source && have_client)
        {
          g_hash_table_remove (source_data->clients, source);
          g_signal_emit (sources, source_data->changed_signal, 0);
        }
      if (show_source && !have_client)
        {
          create_client_for_source (source, source_data->source_type, source_data);
          g_signal_emit (sources, source_data->changed_signal, 0);
        }
    }

  if (e_source_has_extension (source, E_SOURCE_EXTENSION_TASK_LIST))
    {
      CalendarSourceData *source_data;
      ESourceSelectable *extension;
      gboolean have_client;
      gboolean show_source;

      source_data = &sources->priv->task_sources;
      extension = e_source_get_extension (source, E_SOURCE_EXTENSION_TASK_LIST);
      have_client = (g_hash_table_lookup (source_data->clients, source) != NULL);
      show_source = e_source_get_enabled (source) && e_source_selectable_get_selected (extension);

      if (!show_source && have_client)
        {
          g_hash_table_remove (source_data->clients, source);
          g_signal_emit (sources, source_data->changed_signal, 0);
        }
      if (show_source && !have_client)
        {
          create_client_for_source (source, source_data->source_type, source_data);
          g_signal_emit (sources, source_data->changed_signal, 0);
        }
    }
}
Ejemplo n.º 2
0
static void
auto_online (EMailSession *session)
{
	struct _auto_data *info;
	gboolean can_update_all;
	GList *accounts = NULL;
	GList *link;

	accounts = mail_get_store_accounts();

	link = accounts;
	while (link) {
		ESource *source = (ESource *)link->data;
		if (!e_source_get_enabled(source)) {
      link=link->next;
			continue;
    }
		info = g_object_get_data (
			G_OBJECT (source), "mail-autoreceive");
		if (info && (info->timeout_id || can_update_all))
			g_idle_add (auto_timeout_once, info);

		link = link->next;
	}

	g_list_free_full (accounts, (GDestroyNotify) g_object_unref);
}
Ejemplo n.º 3
0
static void
auto_account_commit (struct _auto_data *info)
{
	gint period, check;
	const gchar *extension_name;
	ESourceExtension *extension;

	extension_name = E_SOURCE_EXTENSION_REFRESH;
	extension = e_source_get_extension (info->account, extension_name);

	check = e_source_get_enabled (info->account) 
		&& e_source_refresh_get_enabled ((ESourceRefresh *)extension);

	period = e_source_refresh_get_interval_minutes ((ESourceRefresh *)extension) * 60;
	period = MAX (60, period);

	if (info->timeout_id
	    && (!check
		|| period != info->period)) {
		g_source_remove (info->timeout_id);
		info->timeout_id = 0;
	}
	info->period = period;
	if (check && info->timeout_id == 0)
		info->timeout_id = g_timeout_add_seconds (info->period, auto_timeout, info);
}
Ejemplo n.º 4
0
static void
auto_account_added (ESourceRegistry *registry,
                    ESource *source,
                    EMailSession *session)
{
	struct _auto_data *info;

	if (!e_source_get_enabled(source))
		return;

	info = g_malloc0 (sizeof (*info));
	info->account = source;
	info->session = g_object_ref (session);
	g_object_set_data_full (
		G_OBJECT (source), "mail-autoreceive", info,
		(GDestroyNotify) auto_account_finalized);
	auto_account_commit (info);
	if (data_session)
		e_mail_session_emit_account_added (data_session, e_source_get_uid(source));	
}
Ejemplo n.º 5
0
static void
calendar_sources_load_esource_list (ESourceRegistry *registry,
                                    CalendarSourceData *source_data)
{
  GList *list, *link;
  const gchar *extension_name;

  switch (source_data->source_type)
    {
      case E_CAL_SOURCE_TYPE_EVENT:
        extension_name = E_SOURCE_EXTENSION_CALENDAR;
        break;
      case E_CAL_SOURCE_TYPE_TODO:
        extension_name = E_SOURCE_EXTENSION_TASK_LIST;
        break;
      case E_CAL_SOURCE_TYPE_JOURNAL:
      case E_CAL_SOURCE_TYPE_LAST:
      default:
        g_return_if_reached ();
    }

  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);
      ESourceSelectable *extension;
      gboolean show_source;

      extension = e_source_get_extension (source, extension_name);
      show_source = e_source_get_enabled (source) && e_source_selectable_get_selected (extension);

      if (show_source)
        create_client_for_source (source, source_data->source_type, source_data);
    }

  debug_dump_ecal_list (source_data->clients);

  g_list_free_full (list, g_object_unref);
}
Ejemplo n.º 6
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);
  }

}
Ejemplo n.º 7
0
static struct _send_data *
build_infra (EMailSession *session, gboolean allow_send)
{
	struct _send_data *data;
	struct _send_info *info;
	CamelService *transport = NULL;
	GList *link;
	GList *list = NULL;
	GList *accounts=NULL;

	transport = ref_default_transport (session);

	accounts = mail_get_all_accounts();

	data = setup_send_data (session);

	link = accounts;
	while (link) {
		ESource *source;
		CamelService *service;
		const gchar *uid;

		
		source = (ESource *)link->data;
		if (!e_source_get_enabled(source)) {
			link = link->next;
			continue;
		}

		uid = e_source_get_uid (source);
		service = camel_session_ref_service (
			CAMEL_SESSION (session), uid);

		/* see if we have an outstanding download active */
		info = g_hash_table_lookup (data->active, uid);
		if (info == NULL) {
			send_info_t type = SEND_INVALID;

			type = get_receive_type (service);

			if (type == SEND_INVALID || type == SEND_SEND) {
				link = link->next;
				continue;
			}

			info = g_malloc0 (sizeof (*info));
			info->type = type;
			info->session = g_object_ref (session);

			d(printf("adding source %s\n", source->url));
			info->service = g_object_ref (service);
			info->keep_on_server = mail_get_keep_on_server (service);
			info->cancellable = camel_operation_new ();
			info->state = allow_send ? SEND_ACTIVE : SEND_COMPLETE;
			info->timeout_id = g_timeout_add (
				STATUS_TIMEOUT, operation_status_timeout, info);

			g_signal_connect (
				info->cancellable, "status",
				G_CALLBACK (operation_status), info);

			g_hash_table_insert (
				data->active, g_strdup(uid), info);
			list = g_list_prepend (list, info);

		} else if (info->timeout_id == 0)
			info->timeout_id = g_timeout_add (
				STATUS_TIMEOUT, operation_status_timeout, info);

		info->data = data;

		link = link->next;
	}

	g_list_free_full (accounts, (GDestroyNotify) g_object_unref);


	/* Skip displaying the SMTP row if we've got no outbox,
	 * outgoing account or unsent mails. */
	CamelFolder *local_outbox;
	local_outbox =
		e_mail_session_get_local_folder (
		session, E_MAIL_LOCAL_FOLDER_OUTBOX);
	
	if (allow_send && local_outbox && CAMEL_IS_TRANSPORT (transport)
	 && (camel_folder_get_message_count (local_outbox) -
		camel_folder_get_deleted_message_count (local_outbox)) != 0) {
		info = g_hash_table_lookup (data->active, SEND_URI_KEY);
		if (info == NULL) {
			info = g_malloc0 (sizeof (*info));
			info->type = SEND_SEND;

			info->service = g_object_ref (transport);
			info->keep_on_server = FALSE;
			info->cancellable = camel_operation_new ();
			info->state = SEND_ACTIVE;
			info->timeout_id = g_timeout_add (
				STATUS_TIMEOUT, operation_status_timeout, info);

			g_signal_connect (
				info->cancellable, "status",
				G_CALLBACK (operation_status), info);

			g_hash_table_insert (data->active, g_strdup(SEND_URI_KEY), info);
			list = g_list_prepend (list, info);
		} else if (info->timeout_id == 0)
			info->timeout_id = g_timeout_add (
				STATUS_TIMEOUT, operation_status_timeout, info);

		info->data = data;

	}

	data->infos = list;

	return data;
}
Ejemplo n.º 8
0
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;
}