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