Sun, 10 Aug 2025 23:53:22 +0800
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/>. */ #ifndef PURPLE_SATORI_CONNECTION_H #define PURPLE_SATORI_CONNECTION_H #include <glib.h> #include <purple.h> #include <libsoup/soup.h> #include <libsoup/soup-types.h> G_BEGIN_DECLS #define PURPLE_SATORI_TYPE_CONNECTION (purple_satori_connection_get_type()) G_DECLARE_FINAL_TYPE(PurpleSatoriConnection, purple_satori_connection, PURPLE_SATORI, CONNECTION, PurpleConnection) G_GNUC_INTERNAL void purple_satori_connection_register(GPluginNativePlugin *plugin); static inline SoupMessage * SATORI_ENDPOINT(PurpleSatoriConnection *con, const gchar *p) { PurpleAccount *acc = \ purple_connection_get_account(PURPLE_CONNECTION(con)); gchar *url = \ g_strdup_printf("%s://%s%s%s", purple_account_get_bool(acc, "https", FALSE) ? "https" : "http", purple_account_get_string(acc, "host", "127.0.0.1:5600"), purple_account_get_string(acc, "path", "/v1"), p); SoupMessage *msg = soup_message_new("POST", url); SoupMessageHeaders *headers = soup_message_get_request_headers(msg); soup_message_headers_append(headers, "Satori-Platform", purple_account_get_string(acc, "platform", "")); soup_message_headers_append(headers, "Satori-User-ID", purple_account_get_username(acc)); g_free(url); return msg; } void purple_satori_connection_send_and_read_async(PurpleSatoriConnection *con, SoupMessage *msg, int io_priority, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); G_END_DECLS #endif /* PURPLE_SATORI_CONNECTION_H */