purplesatoriprotocol.c

Sat, 09 Aug 2025 00:19:03 +0800

author
William Goodspeed <goodspeed@mailo.cat>
date
Sat, 09 Aug 2025 00:19:03 +0800
changeset 1
98bcf06036b8
parent 0
cc7c1f9d20f7
child 3
33a7b189a2c6
permissions
-rw-r--r--

Another Minor Milestone Reached, Conversation Creation & Recv works now

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 "purplesatoriprotocol.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 #include "purplesatoriconnection.h"
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
24 #include "purplesatoriprotocolcontacts.h"
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
25 #include "purplesatoriprotocolconversation.h"
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
26
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
27 struct _PurpleSatoriProtocol {
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
28 PurpleProtocol parent;
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
29 };
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
30
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
31 /******************************************************************************
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
32 * PurpleProtocol Implementation
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
33 *****************************************************************************/
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
34 static PurpleConnection *
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
35 purple_satori_protocol_create_connection(PurpleProtocol *protocol,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
36 PurpleAccount *account,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
37 const char *password,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
38 G_GNUC_UNUSED GError **error)
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
39 {
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
40 g_return_val_if_fail(PURPLE_IS_PROTOCOL(protocol), NULL);
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
41 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
42
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
43 return g_object_new(PURPLE_SATORI_TYPE_CONNECTION,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
44 "protocol", protocol,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
45 "account", account,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
46 "password", password,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
47 NULL);
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
48
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
49 }
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
50
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
51 /******************************************************************************
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
52 * GObject Implementation
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
53 *****************************************************************************/
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
54 G_DEFINE_DYNAMIC_TYPE_EXTENDED(
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
55 PurpleSatoriProtocol,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
56 purple_satori_protocol,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
57 PURPLE_TYPE_PROTOCOL,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
58 G_TYPE_FLAG_FINAL,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
59 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CONTACTS,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
60 purple_satori_protocol_contacts_init)
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
61 G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CONVERSATION,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
62 purple_satori_protocol_conversation_init))
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
63
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
64 static void
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
65 purple_satori_protocol_init(G_GNUC_UNUSED PurpleSatoriProtocol *protocol) {
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
66 }
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
67
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
68 static void
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
69 purple_satori_protocol_class_finalize(G_GNUC_UNUSED PurpleSatoriProtocolClass *klass) {
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
70 }
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
71
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
72 static void
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
73 purple_satori_protocol_class_init(PurpleSatoriProtocolClass *klass) {
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
74 PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass);
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
75
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
76 protocol_class->create_connection = purple_satori_protocol_create_connection;
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
77 }
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
78
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
79 /******************************************************************************
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
80 * Local Exports
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
81 *****************************************************************************/
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
82 void
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
83 purple_satori_protocol_register(GPluginNativePlugin *plugin) {
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
84 purple_satori_protocol_register_type(G_TYPE_MODULE(plugin));
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
85 }
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
86
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
87 PurpleProtocol *
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
88 purple_satori_protocol_new(void) {
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
89 return g_object_new(
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
90 PURPLE_SATORI_TYPE_PROTOCOL,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
91 "id", "prpl-satori",
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
92 "name", "Satori",
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
93 "description", "Satori Protocol Plugin for Purple 3",
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
94 "icon-name", "im-purple-satori",
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
95 "icon-resource-path", "/im/pidgin/libpurple/protocols/satori/icons",
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
96 "options", OPT_PROTO_NO_PASSWORD,
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
97 NULL);
cc7c1f9d20f7 Initial Commit
William Goodspeed <goodspeed@mailo.cat>
parents:
diff changeset
98 }

mercurial