コード例 #1
0
ファイル: sync.c プロジェクト: Commers/obexd
static DBusMessage *sync_setlocation(DBusConnection *connection,
			DBusMessage *message, void *user_data)
{
	struct session_data *session = user_data;
	struct sync_data *syncdata = session_get_data(session);
	const char *location;
	char *path = NULL, *tmp;

	if (dbus_message_get_args(message, NULL,
			DBUS_TYPE_STRING, &location,
			DBUS_TYPE_INVALID) == FALSE)
		return g_dbus_create_error(message,
			ERROR_INF ".InvalidArguments", NULL);

	if (!g_ascii_strcasecmp(location, "INT") ||
			!g_ascii_strcasecmp(location, "INTERNAL"))
		path = g_strdup("telecom/pb.vcf");
	else if (!g_ascii_strncasecmp(location, "SIM", 3)) {
		tmp = g_ascii_strup(location, 4);
		path = g_build_filename(tmp, "telecom/pb.vcf", NULL);
		g_free(tmp);
	} else
		return g_dbus_create_error(message,
			ERROR_INF ".InvalidArguments", "InvalidPhonebook");

	g_free(syncdata->phonebook_path);
	syncdata->phonebook_path = path;

	return dbus_message_new_method_return(message);
}
コード例 #2
0
ファイル: sync.c プロジェクト: Commers/obexd
static DBusMessage *sync_putphonebook(DBusConnection *connection,
			DBusMessage *message, void *user_data)
{
	struct session_data *session = user_data;
	struct sync_data *syncdata = session_get_data(session);
	const char *buf;
	char *buffer;

	if (dbus_message_get_args(message, NULL,
			DBUS_TYPE_STRING, &buf,
			DBUS_TYPE_INVALID) == FALSE)
		return g_dbus_create_error(message,
			ERROR_INF ".InvalidArguments", NULL);

	/* set default phonebook_path to memory internal phonebook */
	if (!syncdata->phonebook_path)
		syncdata->phonebook_path = g_strdup("telecom/pb.vcf");

	buffer = g_strdup(buf);

	if (session_put(session, buffer, syncdata->phonebook_path) < 0)
		return g_dbus_create_error(message,
				ERROR_INF ".Failed", "Failed");

	return dbus_message_new_method_return(message);
}
コード例 #3
0
ファイル: sync.c プロジェクト: Commers/obexd
void sync_unregister_interface(DBusConnection *connection, const char *path,
							void *user_data)
{
	struct session_data *session = user_data;
	struct sync_data *syncdata = session_get_data(session);

	g_dbus_unregister_interface(connection, path, SYNC_INTERFACE);

	if (syncdata) {
		g_free(syncdata->phonebook_path);
		g_free(syncdata);
	}
}
コード例 #4
0
ファイル: nntpdriver_tools.c プロジェクト: baiwyc119/etPanKit
int nntpdriver_authenticate_password(mailsession * session)
{
    struct nntp_session_state_data * data;
    int r;

    data = session_get_data(session);

    if (data->nntp_password == NULL)
        return MAIL_ERROR_LOGIN;

    r = newsnntp_authinfo_password(session_get_nntp_session(session),
                                   data->nntp_password);

    return nntpdriver_nntp_error_to_mail_error(r);
}
コード例 #5
0
ファイル: nntpdriver_tools.c プロジェクト: baiwyc119/etPanKit
int nntpdriver_authenticate_user(mailsession * session)
{
    struct nntp_session_state_data * data;
    int r;

    data = session_get_data(session);

    if (data->nntp_userid == NULL)
        return MAIL_ERROR_LOGIN;

    r = newsnntp_authinfo_username(session_get_nntp_session(session),
                                   data->nntp_userid);

    switch (r) {
    case NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD:
        return nntpdriver_authenticate_password(session);

    default:
        return nntpdriver_nntp_error_to_mail_error(r);
    }
}
コード例 #6
0
ファイル: sync.c プロジェクト: Commers/obexd
static DBusMessage *sync_getphonebook(DBusConnection *connection,
			DBusMessage *message, void *user_data)
{
	struct session_data *session = user_data;
	struct sync_data *syncdata = session_get_data(session);

	if (session->msg)
		return g_dbus_create_error(message,
			ERROR_INF ".InProgress", "Transfer in progress");

	/* set default phonebook_path to memory internal phonebook */
	if (!syncdata->phonebook_path)
		syncdata->phonebook_path = g_strdup("telecom/pb.vcf");

	if (session_get(session, "phonebook", syncdata->phonebook_path, NULL,
				NULL, 0, sync_getphonebook_callback) < 0)
		return g_dbus_create_error(message,
			ERROR_INF ".Failed", "Failed");

	session->msg = dbus_message_ref(message);

	return NULL;
}
コード例 #7
0
ファイル: nntpdriver_tools.c プロジェクト: baiwyc119/etPanKit
int nntp_get_messages_list(mailsession * nntp_session,
                           mailsession * session,
                           mailmessage_driver * driver,
                           struct mailmessage_list ** result)
{
    carray * tab;
    struct mailmessage_list * env_list;
    uint32_t i;
    int res;
    int r;
    struct nntp_session_state_data * data;
    struct newsnntp_group_info * group_info;
    uint32_t max;
    unsigned int cur;

    data = session_get_data(nntp_session);

    if (data->nntp_group_name == NULL) {
        res = MAIL_ERROR_BAD_STATE;
        goto err;
    }

    r = nntpdriver_select_folder(nntp_session, data->nntp_group_name);
    if (r != MAIL_NO_ERROR) {
        res = r;
        goto err;
    }

    group_info = data->nntp_group_info;

    if (group_info == NULL) {
        res = MAIL_ERROR_BAD_STATE;
        goto err;
    }

    max = group_info->grp_first;
    if (data->nntp_max_articles != 0) {
        if (group_info->grp_last - data->nntp_max_articles + 1 > max)
            max = group_info->grp_last - data->nntp_max_articles + 1;
    }

    tab = carray_new(128);
    if (tab == NULL) {
        res = MAIL_ERROR_MEMORY;
        goto err;
    }

    for(i = max ; i <= group_info->grp_last ; i++) {
        mailmessage * msg;

        msg = mailmessage_new();
        if (msg == NULL) {
            res = MAIL_ERROR_MEMORY;
            goto free_list;
        }

        r = mailmessage_init(msg, session, driver, i, 0);
        if (r != MAIL_NO_ERROR) {
            mailmessage_free(msg);
            res = r;
            goto free_list;
        }

        r = carray_add(tab, msg, NULL);
        if (r < 0) {
            mailmessage_free(msg);
            res = MAIL_ERROR_MEMORY;
            goto free_list;
        }
    }

    env_list = mailmessage_list_new(tab);
    if (env_list == NULL) {
        res = MAIL_ERROR_MEMORY;
        goto free_list;
    }

    * result = env_list;

    return MAIL_NO_ERROR;

free_list:
    for(cur = 0 ; cur < carray_count(tab) ; cur ++)
        mailmessage_free(carray_get(tab, cur));
    carray_free(tab);
err:
    return res;
}
コード例 #8
0
ファイル: nntpdriver_tools.c プロジェクト: baiwyc119/etPanKit
int nntpdriver_select_folder(mailsession * session, const char * mb)
{
    int r;
    struct newsnntp_group_info * info;
    newsnntp * nntp_session;
    struct nntp_session_state_data * data;
    char * new_name;
    int done;

    data = session_get_data(session);

    if (!data->nntp_mode_reader) {
        r = nntpdriver_mode_reader(session);
        if (r != MAIL_NO_ERROR)
            return r;

        data->nntp_mode_reader = TRUE;
    }

    if (data->nntp_group_name != NULL)
        if (strcmp(data->nntp_group_name, mb) == 0)
            return MAIL_NO_ERROR;

    nntp_session = session_get_nntp_session(session);

    done = FALSE;
    do {
        r = newsnntp_group(nntp_session, mb, &info);

        switch (r) {
        case NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_USERNAME:
            r = nntpdriver_authenticate_user(session);
            if (r != MAIL_NO_ERROR)
                return r;
            break;

        case NEWSNNTP_WARNING_REQUEST_AUTHORIZATION_PASSWORD:
            r = nntpdriver_authenticate_password(session);
            if (r != MAIL_NO_ERROR)
                return r;
            break;

        case NEWSNNTP_NO_ERROR:
            done = TRUE;
            break;

        default:
            return nntpdriver_nntp_error_to_mail_error(r);
        }

    }
    while (!done);

    new_name = strdup(mb);
    if (new_name == NULL)
        return MAIL_ERROR_MEMORY;

    if (data->nntp_group_name != NULL)
        free(data->nntp_group_name);
    data->nntp_group_name = new_name;
    if (data->nntp_group_info != NULL)
        newsnntp_group_free(data->nntp_group_info);
    data->nntp_group_info = info;

    return MAIL_NO_ERROR;
}
コード例 #9
0
ファイル: nntpdriver_tools.c プロジェクト: baiwyc119/etPanKit
static inline struct nntp_session_state_data *
cached_session_get_ancestor_data(mailsession * session)
{
    return session_get_data(cached_session_get_ancestor(session));
}
コード例 #10
0
ファイル: nntpdriver_tools.c プロジェクト: baiwyc119/etPanKit
static inline newsnntp * session_get_nntp_session(mailsession * session)
{
    return session_get_data(session)->nntp_session;
}