Thu, 11 Apr 2024 21:32:59 -0500
Remove PurpleConnectionUiOps as they are no longer used
Testing Done:
Checked in with the turtles.
Reviewed at https://reviews.imfreedom.org/r/3090/
|
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 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
5 | * Purple is the legal property of its developers, whose names are too numerous |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
6 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
7 | * source distribution. |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
8 | * |
|
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
9 | * This library is free software; you can redistribute it and/or modify |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
10 | * 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
|
11 | * 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
|
12 | * (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
|
13 | * |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
14 | * This library is distributed in the hope that it will be useful, |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
15 | * 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
|
16 | * 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
|
17 | * 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
|
18 | * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
42568
31e8c7c92e2f
Make sure all of the license headers for IRCv3 are GPLv2
Gary Kramlich <grim@reaperworld.com>
parents:
42510
diff
changeset
|
20 | * along with this library; if not, see <https://www.gnu.org/licenses/>. |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | */ |
|
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 | #include "purpleircv3parser.h" |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
25 | #include "purpleircv3capabilities.h" |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
26 | #include "purpleircv3constants.h" |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include "purpleircv3core.h" |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
28 | #include "purpleircv3message.h" |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
29 | #include "purpleircv3messagehandlers.h" |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
30 | #include "purpleircv3sasl.h" |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | struct _PurpleIRCv3Parser { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | GObject parent; |
|
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 | GRegex *regex_message; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | GRegex *regex_tags; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | PurpleIRCv3MessageHandler fallback_handler; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | GHashTable *handlers; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | }; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | |
|
42570
a980db2607fd
Make sure all of the final types in the protocols are defined as such
Gary Kramlich <grim@reaperworld.com>
parents:
42568
diff
changeset
|
42 | G_DEFINE_FINAL_TYPE(PurpleIRCv3Parser, purple_ircv3_parser, G_TYPE_OBJECT) |
|
41774
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 | /****************************************************************************** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | * Helpers |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | *****************************************************************************/ |
|
41931
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
47 | static char * |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
48 | purple_ircv3_parser_unescape_tag_value(const char *value) { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
49 | GString *unescaped = g_string_new(""); |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
50 | gboolean escaping = FALSE; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
51 | |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
52 | /* Walk the string and replace escaped values according to |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
53 | * https://ircv3.net/specs/extensions/message-tags.html#escaping-values |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
54 | */ |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
55 | for(int i = 0; value[i] != '\0'; i++) { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
56 | if(escaping) { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
57 | /* Set the replacement to the current character which will fall |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
58 | * through for everything, including '\\' |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
59 | */ |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
60 | char replacement = value[i]; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
61 | |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
62 | if(value[i] == ':') { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
63 | replacement = ';'; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
64 | } else if(value[i] == 's') { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
65 | replacement = ' '; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
66 | } else if(value[i] == 'r') { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
67 | replacement = '\r'; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
68 | } else if(value[i] == 'n') { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
69 | replacement = '\n'; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
70 | } |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
71 | |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
72 | g_string_append_c(unescaped, replacement); |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
73 | escaping = FALSE; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
74 | } else { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
75 | if(value[i] == '\\') { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
76 | escaping = TRUE; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
77 | } else { |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
78 | g_string_append_c(unescaped, value[i]); |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
79 | } |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
80 | } |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
81 | } |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
82 | |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
83 | return g_string_free(unescaped, FALSE); |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
84 | } |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
85 | |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | static GHashTable * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | purple_ircv3_parser_parse_tags(PurpleIRCv3Parser *parser, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | const gchar *tags_string, GError **error) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | GError *local_error = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | GHashTable *tags = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | GMatchInfo *info = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | gboolean matches = FALSE; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | tags = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | /* tags_string can never be NULL, because g_match_info_fetch_named always |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | * returns a string. So if we were passed an empty string, just return the |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
99 | * empty hash table. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | if(*tags_string == '\0') { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
102 | return tags; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
104 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | matches = g_regex_match_full(parser->regex_tags, tags_string, -1, 0, 0, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | &info, &local_error); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | if(local_error != NULL) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | g_propagate_error(error, local_error); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
111 | g_match_info_unref(info); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
112 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
113 | return tags; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | if(!matches) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | g_set_error_literal(error, PURPLE_IRCV3_DOMAIN, 0, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
118 | "failed to parse tags: unknown error"); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
119 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
120 | g_match_info_unref(info); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
122 | return tags; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
123 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
124 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
125 | while(g_match_info_matches(info)) { |
|
41931
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
126 | char *key = NULL; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
127 | char *value = NULL; |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
128 | char *unescaped = NULL; |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | key = g_match_info_fetch_named(info, "key"); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | value = g_match_info_fetch_named(info, "value"); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | |
|
41931
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
133 | unescaped = purple_ircv3_parser_unescape_tag_value(value); |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
134 | g_free(value); |
|
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
135 | |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | /* the hash table is created with destroy notifies for both key and |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
137 | * value, so there's no need to free the allocated memory right now. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | */ |
|
41931
f35eb5adb2e0
Unescape tag values in IRCv3
Gary Kramlich <grim@reaperworld.com>
parents:
41821
diff
changeset
|
139 | g_hash_table_insert(tags, key, unescaped); |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | g_match_info_next(info, &local_error); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | if(local_error != NULL) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | g_propagate_error(error, local_error); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
145 | break; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
146 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
147 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
148 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
149 | g_match_info_unref(info); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
150 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | return tags; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | static guint |
|
41941
355bd17297f0
Set the C standard to C99 and set warning_level to 2 for the IRCv3 Protocol Plugin
Gary Kramlich <grim@reaperworld.com>
parents:
41931
diff
changeset
|
155 | purple_ircv3_parser_extract_params(G_GNUC_UNUSED PurpleIRCv3Parser *parser, |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | GStrvBuilder *builder, const gchar *str) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | gchar *ptr = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | guint count = 0; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | /* Loop through str finding each space separated string. */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
162 | while(str != NULL && *str != '\0') { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | /* Look for a space. */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
164 | ptr = strchr(str, ' '); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | /* If we found one, set it to null terminator and add the string to our |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | * builder. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
169 | if(ptr != NULL) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | *ptr = '\0'; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
171 | g_strv_builder_add(builder, str); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | /* Move str to the next character as we know there's another |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | * character which might be another null terminator. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
176 | str = ptr + 1; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | /* And don't forget to increment the count... ah ah ah! */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
179 | count++; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | } else { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | /* Add the remaining string. */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | g_strv_builder_add(builder, str); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
183 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
184 | /* Give the count another one, ah ah ah! */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
185 | count++; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
186 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | /* Finally break out of the loop. */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | break; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
189 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
190 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
191 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
192 | return count; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
193 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | static GStrv |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | purple_ircv3_parser_build_params(PurpleIRCv3Parser *parser, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | const gchar *middle, const gchar *coda, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | const gchar *trailing, guint *n_params) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
199 | { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | GStrvBuilder *builder = g_strv_builder_new(); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | GStrv result = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
203 | purple_ircv3_parser_extract_params(parser, builder, middle); |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
204 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | if(*coda != '\0') { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | g_strv_builder_add(builder, trailing); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | result = g_strv_builder_end(builder); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
210 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
211 | g_strv_builder_unref(builder); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
213 | if(result != NULL && n_params != NULL) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
214 | *n_params = g_strv_length(result); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
215 | } |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
216 | |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
217 | return result; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | /****************************************************************************** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | * Handlers |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | *****************************************************************************/ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | static gboolean |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
224 | purple_ircv3_fallback_handler(PurpleIRCv3Message *message, |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | GError **error, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | G_GNUC_UNUSED gpointer data) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, "no handler for command %s", |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
229 | purple_ircv3_message_get_command(message)); |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
231 | return FALSE; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
232 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
233 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
234 | /****************************************************************************** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
235 | * GObject Implementation |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | *****************************************************************************/ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | static void |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
238 | purple_ircv3_parser_finalize(GObject *obj) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
239 | PurpleIRCv3Parser *parser = PURPLE_IRCV3_PARSER(obj); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
240 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
241 | g_clear_pointer(&parser->regex_message, g_regex_unref); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
242 | g_clear_pointer(&parser->regex_tags, g_regex_unref); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
243 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
244 | g_hash_table_destroy(parser->handlers); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
245 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
246 | G_OBJECT_CLASS(purple_ircv3_parser_parent_class)->finalize(obj); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
247 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
248 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
249 | static void |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
250 | purple_ircv3_parser_init(PurpleIRCv3Parser *parser) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
251 | parser->regex_message = g_regex_new("(?:@(?<tags>[^ ]+) )?" |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
252 | "(?::(?<source>[^ ]+) +)?" |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
253 | "(?<command>[^ :]+)" |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
254 | "(?: +(?<middle>(?:[^ :]+(?: +[^ :]+)*)))*" |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
255 | "(?<coda> +:(?<trailing>.*)?)?", |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
256 | 0, 0, NULL); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
257 | g_assert(parser->regex_message != NULL); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
258 | |
|
42055
2f5bbcc91854
IRCv3: Negotiate the message-tags capability and make sure our regex matches the BNF
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
259 | parser->regex_tags = g_regex_new("(?<key>(?<client_prefix>\\+?)" |
|
2f5bbcc91854
IRCv3: Negotiate the message-tags capability and make sure our regex matches the BNF
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
260 | "(?:(?<vendor>[A-Za-z0-9-\\.]+)\\/)?" |
|
2f5bbcc91854
IRCv3: Negotiate the message-tags capability and make sure our regex matches the BNF
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
261 | "(?<key_name>[A-Za-z0-9-]+)" |
|
2f5bbcc91854
IRCv3: Negotiate the message-tags capability and make sure our regex matches the BNF
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
262 | ")" |
|
2f5bbcc91854
IRCv3: Negotiate the message-tags capability and make sure our regex matches the BNF
Gary Kramlich <grim@reaperworld.com>
parents:
42023
diff
changeset
|
263 | "(?:=(?<value>[^\r\n;]*))?(?:;|$)", |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
264 | 0, 0, NULL); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
265 | g_assert(parser->regex_tags != NULL); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
266 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
267 | parser->fallback_handler = purple_ircv3_fallback_handler; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
268 | parser->handlers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
269 | NULL); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
270 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
271 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
272 | static void |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
273 | purple_ircv3_parser_class_init(PurpleIRCv3ParserClass *klass) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
274 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
275 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
276 | obj_class->finalize = purple_ircv3_parser_finalize; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
277 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
278 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
279 | /****************************************************************************** |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
280 | * Public API |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
281 | *****************************************************************************/ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
282 | PurpleIRCv3Parser * |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
283 | purple_ircv3_parser_new(void) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
284 | return g_object_new(PURPLE_IRCV3_TYPE_PARSER, NULL); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
285 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
286 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
287 | void |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
288 | purple_ircv3_parser_set_fallback_handler(PurpleIRCv3Parser *parser, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
289 | PurpleIRCv3MessageHandler handler) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
290 | { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
291 | g_return_if_fail(PURPLE_IRCV3_IS_PARSER(parser)); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
292 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
293 | parser->fallback_handler = handler; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
294 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
295 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
296 | gboolean |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
297 | purple_ircv3_parser_parse(PurpleIRCv3Parser *parser, const gchar *buffer, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
298 | GError **error, gpointer data) |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
299 | { |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
300 | PurpleIRCv3Message *message = NULL; |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
301 | PurpleIRCv3MessageHandler handler = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
302 | GError *local_error = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
303 | GHashTable *tags = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
304 | GMatchInfo *info = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
305 | GStrv params = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
306 | gchar *coda = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
307 | gchar *command = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
308 | gchar *middle = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
309 | gchar *source = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
310 | gchar *tags_string = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
311 | gchar *trailing = NULL; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
312 | gboolean matches = FALSE; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
313 | gboolean result = FALSE; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
314 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
315 | g_return_val_if_fail(PURPLE_IRCV3_IS_PARSER(parser), FALSE); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
316 | g_return_val_if_fail(buffer != NULL, FALSE); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
317 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
318 | /* Check if the buffer matches our regex for messages. */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
319 | matches = g_regex_match(parser->regex_message, buffer, 0, &info); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
320 | if(!matches) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
321 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
322 | "failed to parser buffer '%s'", buffer); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
323 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
324 | g_match_info_unref(info); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
325 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
326 | return FALSE; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
327 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
328 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
329 | /* Extract the command from the buffer, so we can find the handler. */ |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
330 | command = g_match_info_fetch_named(info, "command"); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
331 | handler = g_hash_table_lookup(parser->handlers, command); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
332 | if(handler == NULL) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
333 | if(parser->fallback_handler == NULL) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
334 | g_set_error(error, PURPLE_IRCV3_DOMAIN, 0, |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
335 | "no handler found for command %s and no default " |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
336 | "handler set.", command); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
337 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | g_free(command); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
339 | g_match_info_unref(info); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | return FALSE; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
344 | handler = parser->fallback_handler; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
345 | } |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
346 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
347 | /* If we made it this far, we have our handler, so lets get the rest of the |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
348 | * parameters and call the handler. |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
349 | */ |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
350 | message = purple_ircv3_message_new(command); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
351 | |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
352 | tags_string = g_match_info_fetch_named(info, "tags"); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
353 | tags = purple_ircv3_parser_parse_tags(parser, tags_string, &local_error); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
354 | g_free(tags_string); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
355 | if(local_error != NULL) { |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
356 | g_propagate_error(error, local_error); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
357 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
358 | g_free(command); |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
359 | g_clear_object(&message); |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | g_hash_table_destroy(tags); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | g_match_info_unref(info); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
363 | return FALSE; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
364 | } |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
365 | if(tags != NULL) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
366 | purple_ircv3_message_set_tags(message, tags); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
367 | g_hash_table_unref(tags); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
368 | } |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
369 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
370 | source = g_match_info_fetch_named(info, "source"); |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
371 | if(!purple_strempty(source)) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
372 | purple_ircv3_message_set_source(message, source); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
373 | } |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
374 | g_free(source); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
375 | |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
376 | middle = g_match_info_fetch_named(info, "middle"); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
377 | coda = g_match_info_fetch_named(info, "coda"); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
378 | trailing = g_match_info_fetch_named(info, "trailing"); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
379 | params = purple_ircv3_parser_build_params(parser, middle, coda, trailing, |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
380 | NULL); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
381 | if(params != NULL) { |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
382 | purple_ircv3_message_set_params(message, params); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
383 | } |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
384 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
385 | g_free(command); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
386 | g_free(middle); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
387 | g_free(coda); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
388 | g_free(trailing); |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
389 | g_strfreev(params); |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
390 | |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
391 | /* Call the handler. */ |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
392 | result = handler(message, error, data); |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
393 | |
|
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
394 | /* Cleanup the left overs. */ |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
395 | g_match_info_unref(info); |
|
42333
a34601ac633c
Add PurpleIRCv3Message represent messages rather than multiple variables
Gary Kramlich <grim@reaperworld.com>
parents:
42275
diff
changeset
|
396 | g_clear_object(&message); |
|
41774
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
397 | |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
398 | return result; |
|
170078e728c0
Implement a parser for ircv3 and add unit tests to it.
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
399 | } |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
400 | |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
401 | void |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
402 | purple_ircv3_parser_add_handler(PurpleIRCv3Parser *parser, |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
403 | const char *command, |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
404 | PurpleIRCv3MessageHandler handler) |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
405 | { |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
406 | g_return_if_fail(PURPLE_IRCV3_IS_PARSER(parser)); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
407 | g_return_if_fail(command != NULL); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
408 | g_return_if_fail(handler != NULL); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
409 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
410 | g_hash_table_insert(parser->handlers, g_strdup(command), handler); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
411 | } |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
412 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
413 | void |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
414 | purple_ircv3_parser_add_handlers(PurpleIRCv3Parser *parser, |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
415 | PurpleIRCv3MessageHandler handler, |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
416 | ...) |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
417 | { |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
418 | va_list vargs; |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
419 | const char *command = NULL; |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
420 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
421 | g_return_if_fail(PURPLE_IRCV3_IS_PARSER(parser)); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
422 | g_return_if_fail(handler != NULL); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
423 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
424 | va_start(vargs, handler); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
425 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
426 | while((command = va_arg(vargs, const char *)) != NULL) { |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
427 | purple_ircv3_parser_add_handler(parser, command, handler); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
428 | } |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
429 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
430 | va_end(vargs); |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
431 | } |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
432 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
433 | void |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
434 | purple_ircv3_parser_add_default_handlers(PurpleIRCv3Parser *parser) { |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
435 | g_return_if_fail(PURPLE_IRCV3_IS_PARSER(parser)); |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
436 | |
|
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
437 | purple_ircv3_parser_set_fallback_handler(parser, |
|
41821
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41813
diff
changeset
|
438 | purple_ircv3_message_handler_fallback); |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
439 | |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
440 | /* Core functionality. */ |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
441 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_CAP, |
|
41951
00c472cd0fff
Create PurpleIRCv3Capabilities for managing capabilities for each connection
Gary Kramlich <grim@reaperworld.com>
parents:
41941
diff
changeset
|
442 | purple_ircv3_capabilities_message_handler); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
443 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_NOTICE, |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
444 | purple_ircv3_message_handler_privmsg); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
445 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_PING, |
|
41821
ec766a6f010a
Properly namespace the message handlers and reorganize them
Gary Kramlich <grim@reaperworld.com>
parents:
41813
diff
changeset
|
446 | purple_ircv3_message_handler_ping); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
447 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_PRIVMSG, |
|
41813
86302ce7e3c1
Add support for handling PRIVMSG and NOTICE messages from the server
Gary Kramlich <grim@reaperworld.com>
parents:
41807
diff
changeset
|
448 | purple_ircv3_message_handler_privmsg); |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
449 | |
|
42503
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
450 | /* Topic stuff. */ |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
451 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_TOPIC, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
452 | purple_ircv3_message_handler_topic); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
453 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_NOTOPIC, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
454 | purple_ircv3_message_handler_topic); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
455 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_TOPIC, |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
456 | purple_ircv3_message_handler_topic); |
|
55eff782a478
IRCv3: Add support for updating topics
Gary Kramlich <grim@reaperworld.com>
parents:
42333
diff
changeset
|
457 | |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
458 | /* Post Registration Greetings */ |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
459 | purple_ircv3_parser_add_handlers(parser, |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
460 | purple_ircv3_message_handler_status_ignore_param0, |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
461 | PURPLE_IRCV3_RPL_WELCOME, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
462 | PURPLE_IRCV3_RPL_YOURHOST, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
463 | PURPLE_IRCV3_RPL_CREATED, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
464 | PURPLE_IRCV3_RPL_MYINFO, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
465 | NULL); |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
466 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
467 | /* Luser's */ |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
468 | purple_ircv3_parser_add_handlers(parser, |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
469 | purple_ircv3_message_handler_status_ignore_param0, |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
470 | PURPLE_IRCV3_RPL_LUSERCLIENT, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
471 | PURPLE_IRCV3_RPL_LUSEROP, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
472 | PURPLE_IRCV3_RPL_LUSERUNKNOWN, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
473 | PURPLE_IRCV3_RPL_LUSERCHANNELS, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
474 | PURPLE_IRCV3_RPL_LUSERME, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
475 | NULL); |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
476 | |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
477 | /* MOTD */ |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
478 | purple_ircv3_parser_add_handlers(parser, |
|
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
479 | purple_ircv3_message_handler_status_ignore_param0, |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
480 | PURPLE_IRCV3_RPL_MOTD, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
481 | PURPLE_IRCV3_RPL_MOTDSTART, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
482 | PURPLE_IRCV3_RPL_ENDOFMOTD, |
|
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
483 | NULL); |
|
42275
7568bf87e388
Add a basic status window to the IRCv3 protocol plugin
Gary Kramlich <grim@reaperworld.com>
parents:
42055
diff
changeset
|
484 | |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
485 | /* SASL stuff. */ |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
486 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_LOGGEDIN, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
487 | purple_ircv3_sasl_logged_in); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
488 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_LOGGEDOUT, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
489 | purple_ircv3_sasl_logged_out); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
490 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_NICKLOCKED, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
491 | purple_ircv3_sasl_nick_locked); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
492 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_SASLSUCCESS, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
493 | purple_ircv3_sasl_success); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
494 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_SASLFAIL, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
495 | purple_ircv3_sasl_failed); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
496 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_SASLTOOLONG, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
497 | purple_ircv3_sasl_message_too_long); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
498 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_SASLABORTED, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
499 | purple_ircv3_sasl_aborted); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
500 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_ERR_SASLALREADY, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
501 | purple_ircv3_sasl_already_authed); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
502 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_RPL_SASLMECHS, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
503 | purple_ircv3_sasl_mechanisms); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
504 | purple_ircv3_parser_add_handler(parser, PURPLE_IRCV3_MSG_AUTHENTICATE, |
|
42023
5bda87b90d8d
Implement SASL for IRCv3 using GSASL
Gary Kramlich <grim@reaperworld.com>
parents:
41951
diff
changeset
|
505 | purple_ircv3_sasl_authenticate); |
|
42510
fe16c4d773b4
IRCv3: Add constants for all existing errors, messages, and replies.
Gary Kramlich <grim@reaperworld.com>
parents:
42503
diff
changeset
|
506 | |
|
41796
ebe4ff278b02
Use the parser on ircv3 messages and handle pings
Gary Kramlich <grim@reaperworld.com>
parents:
41774
diff
changeset
|
507 | } |