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

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

mercurial