New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CAP 3.2 support #775

Merged
merged 19 commits into from Feb 5, 2018

Conversation

Projects
None yet
3 participants
@LemonBoy
Member

LemonBoy commented Oct 21, 2017

This is a prerequisite for the IRC v3.2 compliance.
Fuck this shit, I've accidentally implemented the whole thing.

This has been tested this with Freenode and Unrealircd and found no problem with the old 3.1 flow and Valgrind looks happy with this.
I've tested the multiline thing using netcat and the strings found on the ircv3 page and the ADD/DEL things are untested as of now (I'd like to talk with a real ircd instead of netcat...)
I'm not sure about the XS part as it kept loading the Irssi.pm module off /usr so feel free to give it a shot.

@LemonBoy LemonBoy added the WIP label Oct 21, 2017

@LemonBoy LemonBoy changed the title from Parse the K/V form in CAP LS to CAP 3.2 support Oct 21, 2017

@ailin-nemui

This comment has been minimized.

Show comment
Hide comment
@ailin-nemui

ailin-nemui Oct 23, 2017

Contributor

is this finished already or still wip?

Contributor

ailin-nemui commented Oct 23, 2017

is this finished already or still wip?

@LemonBoy LemonBoy added needs testing and removed WIP labels Oct 23, 2017

@LemonBoy

This comment has been minimized.

Show comment
Hide comment
@LemonBoy

LemonBoy Oct 23, 2017

Member

I guess it can be reviewed, yeah

Member

LemonBoy commented Oct 23, 2017

I guess it can be reviewed, yeah

@dequis

Let's cover case insensitivity for commands, but not for caps.

Show outdated Hide outdated src/irc/core/irc-cap.c
Show outdated Hide outdated src/irc/core/irc-cap.c
}
/* This branch covers the '*' parameter isn't present, adjust the
* parameter pointer to compensate for this */
else if (list[0] == '\0') {

This comment has been minimized.

@dequis

dequis Oct 29, 2017

Member

Same as above, not sure if this one can be null instead of an empty string.

@dequis

dequis Oct 29, 2017

Member

Same as above, not sure if this one can be null instead of an empty string.

Show outdated Hide outdated src/irc/core/irc-cap.c
Show outdated Hide outdated src/irc/core/irc-cap.c
Show outdated Hide outdated src/irc/core/irc-cap.c
char *val = (char *)val_;
hv_store(hv_, key, strlen(key), new_pv(val), 0);
}
(void) hv_store(hv, "cap_supported", 13, newRV_noinc((SV*)hv_), 0);

This comment has been minimized.

@dequis

dequis Oct 29, 2017

Member

So this is a perl api change, right? Does perl handle this decently enough, falling back to keys only if it is accessed like an array instead of a hash? @ailin-nemui

@dequis

dequis Oct 29, 2017

Member

So this is a perl api change, right? Does perl handle this decently enough, falling back to keys only if it is accessed like an array instead of a hash? @ailin-nemui

This comment has been minimized.

@ailin-nemui

ailin-nemui Oct 30, 2017

Contributor

no that would not work..

@ailin-nemui

ailin-nemui Oct 30, 2017

Contributor

no that would not work..

This comment has been minimized.

@ailin-nemui

ailin-nemui Jan 7, 2018

Contributor

(but I guess we can break the API)

@ailin-nemui

ailin-nemui Jan 7, 2018

Contributor

(but I guess we can break the API)

This comment has been minimized.

@LemonBoy

LemonBoy Jan 7, 2018

Member

My (wild) guess is that we have no users of this API heh
I'd avoid such a breaking change in a non-point release though, got a better idea that's backward compatible?

@LemonBoy

LemonBoy Jan 7, 2018

Member

My (wild) guess is that we have no users of this API heh
I'd avoid such a breaking change in a non-point release though, got a better idea that's backward compatible?

This comment has been minimized.

@ailin-nemui

ailin-nemui Jan 7, 2018

Contributor

well, I can't think of any way other than adding another key, say cap_supported_hash or another method, since we initially put it it all in an array. but that seems silly imo

@ailin-nemui

ailin-nemui Jan 7, 2018

Contributor

well, I can't think of any way other than adding another key, say cap_supported_hash or another method, since we initially put it it all in an array. but that seems silly imo

@ailin-nemui

This comment has been minimized.

Show comment
Hide comment
@ailin-nemui

ailin-nemui Jan 5, 2018

Contributor

what's the status here @LemonBoy @dequis

Contributor

ailin-nemui commented Jan 5, 2018

what's the status here @LemonBoy @dequis

@LemonBoy

This comment has been minimized.

Show comment
Hide comment
@LemonBoy

LemonBoy Jan 5, 2018

Member

It's missing another round of review, an idea about what/how to expose those new fields to the perl side and a use case :)

Member

LemonBoy commented Jan 5, 2018

It's missing another round of review, an idea about what/how to expose those new fields to the perl side and a use case :)

@@ -218,6 +218,19 @@ GSList *gslist_remove_string (GSList *list, const char *str)
return list;
}
GSList *gslist_delete_string (GSList *list, const char *str, GDestroyNotify free_func)

This comment has been minimized.

@ailin-nemui

ailin-nemui Jan 6, 2018

Contributor

you can remove the remove_string method, which is apparently flawed

@ailin-nemui

ailin-nemui Jan 6, 2018

Contributor

you can remove the remove_string method, which is apparently flawed

This comment has been minimized.

@dequis

dequis Jan 24, 2018

Member

lol this comment came back

@dequis

dequis Jan 24, 2018

Member

lol this comment came back

@@ -440,8 +440,10 @@ static void sig_disconnected(IRC_SERVER_REC *server)
gslist_free_full(server->cap_active, (GDestroyNotify) g_free);
server->cap_active = NULL;
gslist_free_full(server->cap_supported, (GDestroyNotify) g_free);
server->cap_supported = NULL;
if (server->cap_supported) {

This comment has been minimized.

@ailin-nemui

ailin-nemui Jan 7, 2018

Contributor

indentation is off here. you can also try our new git-clang-format

@ailin-nemui

ailin-nemui Jan 7, 2018

Contributor

indentation is off here. you can also try our new git-clang-format

@ailin-nemui

This comment has been minimized.

Show comment
Hide comment
@ailin-nemui

ailin-nemui Jan 7, 2018

Contributor

would be nice if you can reply to all open comments @LemonBoy then we can merge this.

Contributor

ailin-nemui commented Jan 7, 2018

would be nice if you can reply to all open comments @LemonBoy then we can merge this.

LemonBoy added some commits Oct 21, 2017

Parse the K/V form in CAP LS
This is a prerequisite for the IRC v3.2 compliance.
Factor out the parsing function
This is also needed for CAP NEW and CAP DEL.
Don't free the hash table if there's none
Glib doesn't like that and shows a harmless warning.
Parse multiline responses to CAP LS
The parsing logic isn't too elegant because of the optional parameter
used for signaling if a response has a continuation one.
Handle CAP {ADD,DEL} from cap-notify
This is the last piece of the puzzle.
Properly dispose the GSList chains
We forgot to free the link and the data, oops.
Use strcmp instead of g_strcmp0
There's no need to use the latter.
Prevent a NULL pointer deference
Always create the cap_supported table when a CAP event is received.
Miscellaneous fixes
Stylistic stuff, please ignore.
Prevent a memory leak
When a CAP DEL is received the key/val pair is not stored in the
hashtable at all so just free them when we're done.
Keep processing the CAPs on error
If an invalid CAP is found we keep going by parsing the next one.
Simplify the code
Early exit, simpler code.
Command names may be in lower-case
Do not take the string case into account when comparing the command
name.
Fix a problem with multiline responses
Do not clear the whole table every time a response is received.
@ailin-nemui

This comment has been minimized.

Show comment
Hide comment
@ailin-nemui

ailin-nemui Jan 9, 2018

Contributor

(and fix the errors caused by -Werror=declaration-after-statement, see travis)

Contributor

ailin-nemui commented Jan 9, 2018

(and fix the errors caused by -Werror=declaration-after-statement, see travis)

@ailin-nemui

This comment has been minimized.

Show comment
Hide comment
@ailin-nemui

ailin-nemui Jan 19, 2018

Contributor

@irssi/developers tagging this for merge

Contributor

ailin-nemui commented Jan 19, 2018

@irssi/developers tagging this for merge

@dequis

This comment has been minimized.

Show comment
Hide comment
@dequis

dequis Jan 19, 2018

Member

Hm, haven't looked at this one in a while (silly rebases making it hard to tell which was the last commit i reviewed), I'll look again over the weekend.

Member

dequis commented Jan 19, 2018

Hm, haven't looked at this one in a while (silly rebases making it hard to tell which was the last commit i reviewed), I'll look again over the weekend.

Show outdated Hide outdated src/core/misc.c
Show outdated Hide outdated src/irc/core/irc-cap.c
else
server->cap_active = g_slist_prepend(server->cap_active, g_strdup(caps[i]));
if (!g_strcmp0(caps[i], "sasl"))
if (!strcmp(caps[i], "sasl"))

This comment has been minimized.

@dequis

dequis Jan 22, 2018

Member

This change is just increasing the crashiness lol.

@dequis

dequis Jan 22, 2018

Member

This change is just increasing the crashiness lol.

This comment has been minimized.

@LemonBoy

LemonBoy Jan 22, 2018

Member

Not quite as the right hand side is a constant string and the left hand side comes from a null-terminated vector of strings, I used the plain strcmp because of that.

@LemonBoy

LemonBoy Jan 22, 2018

Member

Not quite as the right hand side is a constant string and the left hand side comes from a null-terminated vector of strings, I used the plain strcmp because of that.

This comment has been minimized.

@dequis

dequis Jan 24, 2018

Member

It just seemed pointless to bother changing it, but sure, it's harmless.

@dequis

dequis Jan 24, 2018

Member

It just seemed pointless to bother changing it, but sure, it's harmless.

@LemonBoy

This comment has been minimized.

Show comment
Hide comment
@LemonBoy

LemonBoy Jan 24, 2018

Member

Done, I've addressed all the review comments. I think the whole PR should be squashed before merging it.

Member

LemonBoy commented Jan 24, 2018

Done, I've addressed all the review comments. I think the whole PR should be squashed before merging it.

@ailin-nemui

This comment has been minimized.

Show comment
Hide comment
@ailin-nemui

ailin-nemui Feb 2, 2018

Contributor

@LemonBoy you still need to remove the remove_string method

Contributor

ailin-nemui commented Feb 2, 2018

@LemonBoy you still need to remove the remove_string method

@LemonBoy

This comment has been minimized.

Show comment
Hide comment
@LemonBoy

LemonBoy Feb 2, 2018

Member

remove_string has been deprecated since @dequis noted that's part of the public API.

Member

LemonBoy commented Feb 2, 2018

remove_string has been deprecated since @dequis noted that's part of the public API.

@dequis

This comment has been minimized.

Show comment
Hide comment
@dequis

dequis Feb 2, 2018

Member

Yeah in #775 (comment) I basically suggested the opposite of what nei suggested in #775 (review) (which i hadn't seen before) so adding that function back meant showing that comment again

Member

dequis commented Feb 2, 2018

Yeah in #775 (comment) I basically suggested the opposite of what nei suggested in #775 (review) (which i hadn't seen before) so adding that function back meant showing that comment again

@ailin-nemui

This comment has been minimized.

Show comment
Hide comment
@ailin-nemui

ailin-nemui Feb 2, 2018

Contributor

we need to get rid of broken functions

Contributor

ailin-nemui commented Feb 2, 2018

we need to get rid of broken functions

@ailin-nemui ailin-nemui merged commit f8fbc1e into irssi:master Feb 5, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@dequis

This comment has been minimized.

Show comment
Hide comment
@dequis

dequis Apr 8, 2018

Member

lol we forgot to send CAP LS 302

Member

dequis commented Apr 8, 2018

lol we forgot to send CAP LS 302

@LemonBoy

This comment has been minimized.

Show comment
Hide comment
@LemonBoy

LemonBoy Apr 8, 2018

Member

The plan was to bump the required version once we had some feature requiring to do so.

Member

LemonBoy commented Apr 8, 2018

The plan was to bump the required version once we had some feature requiring to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment