Sun, 10 Aug 2025 23:53:22 +0800
Various improvement, Support configuration from UI
| 0 | 1 | /* |
| 2 | * Purple Satori Plugin - Satori Protocol Plugin for Purple3 | |
| 3 | * Copyright (C) 2025 Gong Zhile | |
| 4 | * | |
| 5 | * This library is free software; you can redistribute it and/or | |
| 6 | * modify it under the terms of the GNU Lesser General Public | |
| 7 | * License as published by the Free Software Foundation; either | |
| 8 | * version 2 of the License, or (at your option) any later version. | |
| 9 | * | |
| 10 | * This library is distributed in the hope that it will be useful, | |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | * Lesser General Public License for more details. | |
| 14 | * | |
| 15 | * You should have received a copy of the GNU Lesser General Public | |
| 16 | * License along with this library; if not, see <https://www.gnu.org/licenses/>. | |
| 17 | */ | |
| 18 | ||
| 19 | #include <glib/gi18n-lib.h> | |
| 20 | ||
| 21 | #include "purplesatoriprotocolcontacts.h" | |
| 22 | ||
| 23 | /****************************************************************************** | |
| 24 | * PurpleProtocolContacts Implementation | |
| 25 | *****************************************************************************/ | |
| 26 | static char * | |
| 27 | purple_satori_protocol_contacts_get_profile_finish(G_GNUC_UNUSED PurpleProtocolContacts *contacts, | |
| 28 | GAsyncResult *result, | |
| 29 | GError **error) | |
| 30 | { | |
| 31 | g_return_val_if_fail(G_IS_TASK(result), NULL); | |
| 32 | ||
| 33 | return g_task_propagate_pointer(G_TASK(result), error); | |
| 34 | } | |
| 35 | ||
| 36 | static void | |
| 37 | purple_satori_protocol_contacts_get_profile_async(PurpleProtocolContacts *contacts, | |
| 38 | PurpleContactInfo *info, | |
| 39 | GCancellable *cancellable, | |
| 40 | GAsyncReadyCallback callback, | |
| 41 | gpointer data) | |
| 42 | { | |
| 43 | GTask *task = NULL; | |
| 44 | const char *profile = NULL; | |
| 45 | ||
| 46 | task = g_task_new(contacts, cancellable, callback, data); | |
| 47 | ||
| 48 | profile = g_object_get_data(G_OBJECT(info), "satori-profile"); | |
| 49 | g_task_return_pointer(task, g_strdup(profile), g_free); | |
| 50 | g_clear_object(&task); | |
| 51 | } | |
| 52 | ||
| 53 | void | |
| 54 | purple_satori_protocol_contacts_init(PurpleProtocolContactsInterface *iface) { | |
| 55 | iface->get_profile_async = purple_satori_protocol_contacts_get_profile_async; | |
| 56 | iface->get_profile_finish = purple_satori_protocol_contacts_get_profile_finish; | |
| 57 | } |