Tue, 15 Aug 2023 15:49:01 -0500
Add a basic status window to the IRCv3 protocol plugin
There's a lot more to be tweaked in here, including adding an account action
to toggle visibility, but the basics work for now.
Testing Done:
Connected to libera and my local ergo and checked it out!
Bugs closed: PIDGIN-17819
Reviewed at https://reviews.imfreedom.org/r/2563/
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
1 | /* |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
2 | * Purple - Internet Messaging Library |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
3 | * Copyright (C) Pidgin Developers <devel@pidgin.im> |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
4 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
5 | * This program is free software; you can redistribute it and/or modify |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * (at your option) any later version. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
9 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * This program is distributed in the hope that it will be useful, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * GNU General Public License for more details. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
14 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * You should have received a copy of the GNU General Public License |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * along with this program; if not, see <https://www.gnu.org/licenses/>. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
17 | */ |
|
42229
605f8cba9704
Add gobject-introspection for ircv3
Gary Kramlich <grim@reaperworld.com>
parents:
41881
diff
changeset
|
18 | #if !defined(PURPLE_IRCV3_GLOBAL_HEADER_INSIDE) && \ |
|
605f8cba9704
Add gobject-introspection for ircv3
Gary Kramlich <grim@reaperworld.com>
parents:
41881
diff
changeset
|
19 | !defined(PURPLE_IRCV3_COMPILATION) |
|
605f8cba9704
Add gobject-introspection for ircv3
Gary Kramlich <grim@reaperworld.com>
parents:
41881
diff
changeset
|
20 | # error "only <libpurple/protocols/ircv3.h> may be included directly" |
|
605f8cba9704
Add gobject-introspection for ircv3
Gary Kramlich <grim@reaperworld.com>
parents:
41881
diff
changeset
|
21 | #endif |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
23 | #ifndef PURPLE_IRCV3_PARSER_H |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | #define PURPLE_IRCV3_PARSER_H |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #include <glib.h> |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include <glib-object.h> |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | #include <purple.h> |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
31 | #include "purpleircv3messagehandlers.h" |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
33 | G_BEGIN_DECLS |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | #define PURPLE_IRCV3_TYPE_PARSER (purple_ircv3_parser_get_type()) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | G_DECLARE_FINAL_TYPE(PurpleIRCv3Parser, purple_ircv3_parser, PURPLE_IRCV3, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | PARSER, GObject) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | /** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | * purple_ircv3_parser_new: |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | * Creates a new instance. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | * Since: 3.0.0 |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | */ |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
46 | PurpleIRCv3Parser *purple_ircv3_parser_new(void); |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | /** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | * purple_ircv3_parser_set_fallback_handler: (skip): |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | * @parser: The instance. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | * @handler: A [func@PurpleIRCv3.MessageHandler]. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | * Sets @handler to be called for any messages that @parser doesn't know how to |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | * handle. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | * Since: 3.0.0 |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | */ |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
58 | void purple_ircv3_parser_set_fallback_handler(PurpleIRCv3Parser *parser, PurpleIRCv3MessageHandler handler); |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | /** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | * purple_ircv3_parser_parse: |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | * @parser: The instance. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | * @buffer: The buffer to parse. |
|
41881
7e1dd7e9efbb
Fix error parameter annotations
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41796
diff
changeset
|
64 | * @error: Return address for a #GError, or %NULL. |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | * @data: (nullable): Optional data to pass to the handler. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | * Parses @buffer with @parser. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | * Returns: %TRUE if the buffer was parsed correctly or %FALSE with @error set. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | * Since: 3.0.0 |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | */ |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
73 | gboolean purple_ircv3_parser_parse(PurpleIRCv3Parser *parser, const gchar *buffer, GError **error, gpointer data); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
74 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
75 | /** |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
76 | * purple_ircv3_parser_add_handler: |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
77 | * @parser: The instance. |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
78 | * @command: The command string. |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
79 | * @handler: (scope forever): The handler to call. |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
80 | * |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
81 | * Calls @handler every time @parser finds the command named @command. |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
82 | * |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
83 | * Since: 3.0.0 |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
84 | */ |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
85 | void purple_ircv3_parser_add_handler(PurpleIRCv3Parser *parser, const char *command, PurpleIRCv3MessageHandler handler); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
86 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
87 | /** |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
88 | * purple_ircv3_parser_add_handlers: |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
89 | * @parser: The instance. |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
90 | * @handler: (scope forever): The handler to call when the command is received. |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
91 | * @...: A %NULL terminated list of string command names. |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
92 | * |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
93 | * Like [method@Parser.add_handler] but allows you to add multiple commands at |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
94 | * once that share a handler. |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
95 | * |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
96 | * Since: 3.0.0 |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
97 | */ |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
98 | void purple_ircv3_parser_add_handlers(PurpleIRCv3Parser *parser, PurpleIRCv3MessageHandler handler, ...) G_GNUC_NULL_TERMINATED; |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
100 | /** |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
101 | * purple_ircv3_parser_add_default_handlers: |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
102 | * @parser: The instance. |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
103 | * |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
104 | * Adds all of the default handlers to @parser. |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
105 | * |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
106 | * Since: 3.0.0 |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
107 | */ |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42229
diff
changeset
|
108 | void purple_ircv3_parser_add_default_handlers(PurpleIRCv3Parser *parser); |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
109 | |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | G_END_DECLS |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | #endif /* PURPLE_IRCV3_PARSER_H */ |