示例#1
0
static void
report_error_to_ui (CamelService *service,
		    const gchar *folder_name,
		    const GError *error)
{
	gchar *tmp = NULL;
	const gchar *display_name, *ident;
	struct ReportErrorToUIData *data;

	g_return_if_fail (CAMEL_IS_SERVICE (service));
	g_return_if_fail (error != NULL);

	if (folder_name) {
		tmp = g_strdup_printf ("%s: %s",
			camel_service_get_display_name (service),
			folder_name);
		display_name = tmp;
		ident = "mail:no-refresh-folder";
	} else {
		display_name = camel_service_get_display_name (service);
		ident = "mail:failed-connect";
	}

	data = g_new0 (struct ReportErrorToUIData, 1);
	data->display_name = g_strdup (display_name);
	data->error_ident = g_strdup (ident);
	data->error = g_error_copy (error);

	g_idle_add_full (G_PRIORITY_DEFAULT, report_error_to_ui_cb, data, NULL);

	g_free (tmp);
}
示例#2
0
static void
send_receive (EMailSession *session,
              gboolean allow_send)
{
	CamelFolder *local_outbox;
	struct _send_data *data;
	GList *scan;
	
	if (send_data) /* Send Receive is already in progress */
		return;

	if (!camel_session_get_online (CAMEL_SESSION (session)))
		return;
	local_outbox = e_mail_session_get_local_folder (
			session, E_MAIL_LOCAL_FOLDER_OUTBOX);

	data = build_infra (session, allow_send);

	for (scan = data->infos; scan != NULL; scan = scan->next) {
		struct _send_info *info = scan->data;

		if (!CAMEL_IS_SERVICE (info->service))
			continue;

		switch (info->type) {
		case SEND_RECEIVE:
			mail_fetch_mail (
				CAMEL_STORE (info->service),
				CAMEL_FETCH_OLD_MESSAGES, -1,
				E_FILTER_SOURCE_INCOMING,
				mail_provider_fetch_lock, mail_provider_fetch_unlock, mail_provider_fetch_inbox_folder,
				info->cancellable,
				receive_get_folder, info,
				receive_status, info,
				receive_done, info);
			break;
		case SEND_SEND:
			/* todo, store the folder in info? */
			mail_send_queue (
				session, local_outbox,
				CAMEL_TRANSPORT (info->service),
				E_FILTER_SOURCE_OUTGOING,
				info->cancellable,
				receive_get_folder, info,
				receive_status, info,
				send_done, info);
			break;
		case SEND_UPDATE:
			receive_update_got_store (
				CAMEL_STORE (info->service), info);
			break;
		default:
			break;
		}
	}

	return ;
}
示例#3
0
/**
 * camel_session_get_storage_path:
 * @session: a #CamelSession object
 * @service: a #CamelService
 * @ex: a #CamelException
 *
 * This returns the path to a directory which the service can use for
 * its own purposes. Data stored there will remain between Evolution
 * sessions. No code outside of that service should ever touch the
 * files in this directory. If the directory does not exist, it will
 * be created.
 *
 * Returns the path (which the caller must free), or %NULL if an error
 * occurs.
 **/
char *
camel_session_get_storage_path (CamelSession *session, CamelService *service,
				CamelException *ex)
{
	g_return_val_if_fail (CAMEL_IS_SESSION (session), NULL);
	g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);

	return CS_CLASS (session)->get_storage_path (session, service, ex);
}
示例#4
0
static void
send_receive_account_item_activate_cb (GtkMenuItem *menu_item,
                                       SendReceiveData *data)
{
	CamelService *service;

	service = g_hash_table_lookup (data->menu_items, menu_item);
	g_return_if_fail (CAMEL_IS_SERVICE (service));

	mail_receive_service (service);
}
示例#5
0
static gboolean
auto_timeout (gpointer data)
{
	EMailSession *session;
	struct _auto_data *info = data;
	CamelService *service;
	const char *uid;

	session = info->session;
	uid = e_source_get_uid (info->account);
	
	service = camel_session_ref_service (
		CAMEL_SESSION (session), uid);
	printf("Timeout for %s: %p\n", uid, service);
	g_return_val_if_fail (CAMEL_IS_SERVICE (service), TRUE);


	if (camel_session_get_online (CAMEL_SESSION (session)))
		mail_receive_service (service);

	return TRUE;
}
示例#6
0
/* We setup the download info's in a hashtable, if we later
 * need to build the gui, we insert them in to add them. */
GCancellable *
mail_receive_service (CamelService *service)
{
	struct _send_info *info;
	struct _send_data *data;
	CamelFolder *local_outbox;
	const gchar *uid;
	EMailSession *session;

	send_info_t type = SEND_INVALID;

	g_return_val_if_fail (CAMEL_IS_SERVICE (service), NULL);

	session = (EMailSession *)camel_service_get_session (service);
	uid = camel_service_get_uid (service);

	data = setup_send_data (session);
	info = g_hash_table_lookup (data->active, uid);

	if (info != NULL)
		return info->cancellable;

	type = get_receive_type (service);

	if (type == SEND_INVALID || type == SEND_SEND)
		return NULL;

	info = g_malloc0 (sizeof (*info));
	info->type = type;
	info->session = g_object_ref (session);
	info->service = g_object_ref (service);
	info->keep_on_server = mail_get_keep_on_server (service);	
	info->cancellable = camel_operation_new ();
	info->data = data;
	info->state = SEND_ACTIVE;
	info->timeout_id = 0;

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

	d(printf("Adding new info %p\n", info));

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

	switch (info->type) {
	case SEND_RECEIVE:
		mail_fetch_mail (
			CAMEL_STORE (service),
			CAMEL_FETCH_OLD_MESSAGES, -1,
			E_FILTER_SOURCE_INCOMING,
			mail_provider_fetch_lock, mail_provider_fetch_unlock, mail_provider_fetch_inbox_folder,
			info->cancellable,
			receive_get_folder, info,
			receive_status, info,
			receive_done, info);
		break;
	case SEND_SEND:
		/* todo, store the folder in info? */
		local_outbox =
			e_mail_session_get_local_folder (
			session, E_MAIL_LOCAL_FOLDER_OUTBOX);
		mail_send_queue (
			info->session,
			local_outbox,
			CAMEL_TRANSPORT (service),
			E_FILTER_SOURCE_OUTGOING,
			info->cancellable,
			receive_get_folder, info,
			receive_status, info,
			send_done, info);
		break;
	case SEND_UPDATE:
		receive_update_got_store (CAMEL_STORE (service), info);
		break;
	default:
		g_return_val_if_reached (NULL);
	}

	return info->cancellable;
}