dylex / slack-libpurple

Slack module for libpurple
GNU General Public License v2.0
280 stars 38 forks source link

Convert URL for incoming calls #168

Closed DanielSiepmann closed 2 years ago

DanielSiepmann commented 2 years ago

Slack communicates legacy URLs for calls. We convert the incoming legacy URL to the new expected URL.

That allows users to click on the URL and end up within the call instead of an error page.

Relates: #166

DanielSiepmann commented 2 years ago

I'm a total noob, these are my first steps in c programming. I'm open for feedback.

EionRobb commented 2 years ago

g_string_replace() is a bit too new for Windows versions of Pidgin (it's part of glib 2.68 but winpidgin is only 2.30 or something), you might want to try using purple_strreplace() https://docs.imfreedom.org/pidgin2/util_8h.html#aee9e0a107a386408a2c6485b9adaf902 instead. This function doesn't do in-place replacement though, so you'll need to juggle memory around (like assign to a temp string, then free the old one).

Just for style and memory safety, you might also want to use g_strconcat() for joining together strings (or g_strdup_printf() if that's easier too). Mostly to make sure you don't accidentally have a buffer-overflow with a longer than expected host or team id later on down the track.

DanielSiepmann commented 2 years ago

Thanks @EionRobb for your feedback. I've adjusted the code and tested again. Still working.

I've added usage of g_string_assign() as that seemed necessary to me due to gchar and GString. Hope it's fine now. Still open for more feedback.

DanielSiepmann commented 2 years ago

Nice to hear :) What needs to be done in order to merge this change?