purplesatoriprotocolcontacts.c

Sun, 10 Aug 2025 23:53:22 +0800

author
Gong Zhile <gongzl@stu.hebust.edu.cn>
date
Sun, 10 Aug 2025 23:53:22 +0800
changeset 3
33a7b189a2c6
parent 0
cc7c1f9d20f7
permissions
-rw-r--r--

Various improvement, Support configuration from UI

/*
 * Purple Satori Plugin - Satori Protocol Plugin for Purple3
 * Copyright (C) 2025 Gong Zhile
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
 */

#include <glib/gi18n-lib.h>

#include "purplesatoriprotocolcontacts.h"

/******************************************************************************
 * PurpleProtocolContacts Implementation
 *****************************************************************************/
static char *
purple_satori_protocol_contacts_get_profile_finish(G_GNUC_UNUSED PurpleProtocolContacts *contacts,
                                                 GAsyncResult *result,
                                                 GError **error)
{
	g_return_val_if_fail(G_IS_TASK(result), NULL);

	return g_task_propagate_pointer(G_TASK(result), error);
}

static void
purple_satori_protocol_contacts_get_profile_async(PurpleProtocolContacts *contacts,
                                                PurpleContactInfo *info,
                                                GCancellable *cancellable,
                                                GAsyncReadyCallback callback,
                                                gpointer data)
{
	GTask *task = NULL;
	const char *profile = NULL;

	task = g_task_new(contacts, cancellable, callback, data);

	profile = g_object_get_data(G_OBJECT(info), "satori-profile");
	g_task_return_pointer(task, g_strdup(profile), g_free);
	g_clear_object(&task);
}

void
purple_satori_protocol_contacts_init(PurpleProtocolContactsInterface *iface) {
	iface->get_profile_async = purple_satori_protocol_contacts_get_profile_async;
	iface->get_profile_finish = purple_satori_protocol_contacts_get_profile_finish;
}

mercurial