pidgin/pidgin

Implement sending im's for IRCv3

18 months ago, Gary Kramlich
4ee9cb957595
Parents 9cb0ac7a3373
Children b3eda1d781c6
Implement sending im's for IRCv3

Also fix an issue on receiving on IM's where we were creating a conversation
with the target, not the source.

Testing Done:
Sent im's between pidgin2 and pidgin3 using a local ergo server.

Reviewed at https://reviews.imfreedom.org/r/2062/
--- a/libpurple/protocols/ircv3/meson.build Wed Nov 16 22:28:10 2022 -0600
+++ b/libpurple/protocols/ircv3/meson.build Wed Nov 16 22:31:08 2022 -0600
@@ -1,14 +1,19 @@
IRCV3_SOURCES = [
'purpleircv3connection.c',
+ 'purpleircv3core.c',
+ 'purpleircv3messagehandlers.c',
+ 'purpleircv3parser.c',
+ 'purpleircv3protocol.c',
+ 'purpleircv3protocolim.c',
+]
+
+IRCV3_HEADERS = [
'purpleircv3connection.h',
- 'purpleircv3core.c',
'purpleircv3core.h',
- 'purpleircv3messagehandlers.c',
'purpleircv3messagehandlers.h',
- 'purpleircv3parser.c',
'purpleircv3parser.h',
- 'purpleircv3protocol.c',
'purpleircv3protocol.h',
+ 'purpleircv3protocolim.h',
]
if DYNAMIC_IRCV3
@@ -18,7 +23,7 @@
c_name : 'purple_ircv3')
IRCV3_SOURCES += ircv3_resources
- ircv3_prpl = shared_library('ircv3', IRCV3_SOURCES,
+ ircv3_prpl = shared_library('ircv3', IRCV3_SOURCES + IRCV3_HEADERS,
c_args : ['-DG_LOG_USE_STRUCTURED', '-DG_LOG_DOMAIN="Purple-IRCv3"'],
dependencies : [sasl, libpurple_dep, glib, gio, ws2_32],
install : true, install_dir : PURPLE_PLUGINDIR)
--- a/libpurple/protocols/ircv3/purpleircv3messagehandlers.c Wed Nov 16 22:28:10 2022 -0600
+++ b/libpurple/protocols/ircv3/purpleircv3messagehandlers.c Wed Nov 16 22:31:08 2022 -0600
@@ -180,7 +180,7 @@
if(target[0] == '#') {
conversation = purple_chat_conversation_new(account, target);
} else {
- conversation = purple_im_conversation_new(account, target);
+ conversation = purple_im_conversation_new(account, source);
}
purple_conversation_manager_register(conversation_manager,
--- a/libpurple/protocols/ircv3/purpleircv3protocol.c Wed Nov 16 22:28:10 2022 -0600
+++ b/libpurple/protocols/ircv3/purpleircv3protocol.c Wed Nov 16 22:31:08 2022 -0600
@@ -22,6 +22,7 @@
#include "purpleircv3connection.h"
#include "purpleircv3core.h"
+#include "purpleircv3protocolim.h"
/******************************************************************************
* PurpleProtocol Implementation
@@ -137,8 +138,13 @@
/******************************************************************************
* GObject Implementation
*****************************************************************************/
-G_DEFINE_DYNAMIC_TYPE(PurpleIRCv3Protocol, purple_ircv3_protocol,
- PURPLE_TYPE_PROTOCOL)
+G_DEFINE_DYNAMIC_TYPE_EXTENDED(
+ PurpleIRCv3Protocol,
+ purple_ircv3_protocol,
+ PURPLE_TYPE_PROTOCOL,
+ G_TYPE_FLAG_DERIVABLE,
+ G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_IM,
+ purple_ircv3_protocol_im_init))
static void
purple_ircv3_protocol_init(PurpleIRCv3Protocol *protocol) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/ircv3/purpleircv3protocolim.c Wed Nov 16 22:31:08 2022 -0600
@@ -0,0 +1,49 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * 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/>.
+ */
+
+#include <glib/gi18n-lib.h>
+
+#include "purpleircv3protocolim.h"
+
+#include "purpleircv3connection.h"
+
+/******************************************************************************
+ * PurpleProtocolIM Implementation
+ *****************************************************************************/
+static gint
+purple_ircv3_protocol_send_im(PurpleProtocolIM *im,
+ PurpleConnection *conn,
+ PurpleMessage *message)
+{
+ PurpleIRCv3Connection *connection = PURPLE_IRCV3_CONNECTION(conn);
+ const char *contents = NULL;
+ const char *recipient = NULL;
+
+ contents = purple_message_get_contents(message);
+ recipient = purple_message_get_recipient(message);
+
+ purple_ircv3_connection_writef(connection, "PRIVMSG %s :%s", recipient,
+ contents);
+
+ return 1;
+}
+
+void
+purple_ircv3_protocol_im_init(PurpleProtocolIMInterface *iface) {
+ iface->send = purple_ircv3_protocol_send_im;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/libpurple/protocols/ircv3/purpleircv3protocolim.h Wed Nov 16 22:31:08 2022 -0600
@@ -0,0 +1,28 @@
+/*
+ * Purple - Internet Messaging Library
+ * Copyright (C) Pidgin Developers <devel@pidgin.im>
+ *
+ * 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_IRCV3_PROTOCOL_IM_H
+#define PURPLE_IRCV3_PROTOCOL_IM_H
+
+#include <glib.h>
+
+#include <purple.h>
+
+G_GNUC_INTERNAL void purple_ircv3_protocol_im_init(PurpleProtocolIMInterface *iface);
+
+#endif /* PURPLE_IRCV3_PROTOCOL_IM_H */