Initial revision, basic oauth flow is in but super happy pathed!
--- a/.hgignore Thu Apr 27 22:24:08 2017 -0500
+++ b/.hgignore Thu May 04 23:13:55 2017 -0500
@@ -2,3 +2,5 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile Thu May 04 23:13:55 2017 -0500
@@ -0,0 +1,19 @@
+PIDGIN_TREE_TOP ?= ../pidgin-2.12.0 +WIN32_DEV_TOP ?= $(PIDGIN_TREE_TOP)/../win32-dev +PLUGIN_NAME := purple-spasm + $(shell pkg-config --cflags json-glib-1.0) + $(shell pkg-config --libs json-glib-1.0) --- a/helloworld.c Thu Apr 27 22:24:08 2017 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
- * HelloWorld - A hello world libpurple plugin
- * Copyright (C) 2006 John Bailey <rekkanoryo@rekkanoryo.org>
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-plugin_load(PurplePlugin *plugin) {
- PURPLE_NOTIFY_MSG_INFO,
- "This is the Hello World! plugin :)",
-static PurplePluginInfo info = {
- .magic = PURPLE_PLUGIN_MAGIC,
- .major_version = PURPLE_MAJOR_VERSION,
- .minor_version = PURPLE_MINOR_VERSION,
- .type = PURPLE_PLUGIN_STANDARD,
- .priority = PURPLE_PRIORITY_DEFAULT,
- .id = "core-hello_world",
- .name = "Hello World!",
- .version = PLUGIN_VERSION,
- .summary = "Hello World Plugin",
- .description = "Hello World Plugin",
- .author = "My Name <email@helloworld.tld>",
- .homepage = "http://helloworld.tld",
-init_plugin(PurplePlugin *plugin) {
-PURPLE_INIT_PLUGIN(hello_world, init_plugin, info);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/purple-spasm.sublime-project Thu May 04 23:13:55 2017 -0500
@@ -0,0 +1,8 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spasm-account.h Thu May 04 23:13:55 2017 -0500
@@ -0,0 +1,34 @@
+ * PurpleSpasm - A Twitch Protocol Plugin + * Copyright (C) 2017 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifndef PURPLE_SPASM_ACCOUNT_H +#define PURPLE_SPASM_ACCOUNT_H + PurpleAccount *account; + PurpleConnection *connection; +#endif /* PURPLE_SPASM_ACCOUNT_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spasm-auth.c Thu May 04 23:13:55 2017 -0500
@@ -0,0 +1,105 @@
+ * PurpleSpasm - A Twitch Protocol Plugin + * Copyright (C) 2017 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#include "spasm-account.h" +#include "spasm-const.h" +/****************************************************************************** + *****************************************************************************/ +purple_spasm_access_token_input_cb(gpointer data, const gchar *access_token) { + SpasmAccount *sa = data; + g_free(sa->access_token); + sa->access_token = (access_token) ? g_strdup(access_token) : NULL; + purple_account_set_remember_password(sa->account, TRUE); + purple_account_set_password(sa->account, sa->access_token); + purple_connection_set_state(sa->connection, PURPLE_CONNECTED); +purple_spasm_access_token_cancel_cb(gpointer data) { + SpasmAccount *sa = data; + purple_connection_error( + "User cancelled authorization" +/****************************************************************************** + *****************************************************************************/ +purple_spasm_login(PurpleAccount *account) { + PurpleConnection *pc = NULL; + SpasmAccount *sa = NULL; + gchar *state = NULL, *uri = NULL; + const gchar *username = NULL; + pc = purple_account_get_connection(account); + username = purple_account_get_username(account); + sa = g_new0(SpasmAccount, 1); + purple_connection_set_protocol_data(pc, sa); + purple_connection_set_state(pc, PURPLE_CONNECTING); + state = g_strdup_printf("%s,%s", PURPLE_SPASM_PLUGIN_ID, username); + PURPLE_SPASM_OAUTH2_URI, + PURPLE_SPASM_OAUTH2_CLIENT_ID, + PURPLE_SPASM_OAUTH2_REDIRECT_URI, + PURPLE_SPASM_OAUTH2_SCOPES, + purple_connection_update_progress(sa->connection, "Authenticating", 1, 2); + /* send off the oauth implicit request */ + purple_notify_uri(pc, uri); + "Enter the access token from https://pidgin.im/oauth.html which should have opened in your web browser", + "OK", G_CALLBACK(purple_spasm_access_token_input_cb), + "Cancel", G_CALLBACK(purple_spasm_access_token_cancel_cb), --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spasm-auth.h Thu May 04 23:13:55 2017 -0500
@@ -0,0 +1,33 @@
+ * PurpleSpasm - A Twitch Protocol Plugin + * Copyright (C) 2017 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifndef PURPLE_SPASM_AUTH_H +#define PURPLE_SPASM_AUTH_H +void purple_spasm_login(PurpleAccount *account); +#endif /* PURPLE_SPASM_AUTH_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spasm-const.h Thu May 04 23:13:55 2017 -0500
@@ -0,0 +1,34 @@
+ * PurpleSpasm - A Twitch Protocol Plugin + * Copyright (C) 2017 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#ifndef PURPLE_SPASM_CONSTS_H +#define PURPLE_SPASM_CONSTS_H +#define PURPLE_SPASM_PLUGIN_ID "prpl-grim-spasm" +#define PURPLE_SPASM_OAUTH2_CLIENT_ID "w7le4wyxwbipv6kf5qmqogwkqskl12" +#define PURPLE_SPASM_OAUTH2_SCOPES "user_read chat_login" +#define PURPLE_SPASM_OAUTH2_REDIRECT_URI "https://pidgin.im/oauth.html" +#define PURPLE_SPASM_OAUTH2_URI "https://api.twitch.tv/kraken/oauth2/authorize?" \ + "response_type=token&" \ +#endif /* PURPLE_SPASM_CONSTS_H */ --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spasm.c Thu May 04 23:13:55 2017 -0500
@@ -0,0 +1,112 @@
+ * PurpleSpasm - A Twitch Protocol Plugin + * Copyright (C) 2017 Gary Kramlich <grim@reaperworld.com> + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +#include "spasm-account.h" +#include "spasm-const.h" +/****************************************************************************** + *****************************************************************************/ +/****************************************************************************** + *****************************************************************************/ +purple_spasm_list_icon(PurpleAccount *account, PurpleBuddy *buddy) { +purple_spasm_close(PurpleConnection *connection) { +purple_spasm_get_status_types(PurpleAccount *account) { + PurpleStatusType *status; + status = purple_status_type_new_full(PURPLE_STATUS_AVAILABLE, "online", "Online", TRUE, TRUE, FALSE); + types = g_list_append(types, status); + status = purple_status_type_new_full(PURPLE_STATUS_OFFLINE, NULL, "Offline", TRUE, TRUE, FALSE); + types = g_list_append(types, status); +purple_spasm_set_status(PurpleAccount *account, PurpleStatus *status) { +/****************************************************************************** + *****************************************************************************/ +static PurplePluginProtocolInfo prpl_info = { + .struct_size = sizeof(PurplePluginProtocolInfo), + .options = OPT_PROTO_NO_PASSWORD, + .login = purple_spasm_login, + .close = purple_spasm_close, + .list_icon = purple_spasm_list_icon, + .status_types = purple_spasm_get_status_types, + .set_status = purple_spasm_set_status, +static PurplePluginInfo info = { + .magic = PURPLE_PLUGIN_MAGIC, + .major_version = PURPLE_MAJOR_VERSION, + .minor_version = PURPLE_MINOR_VERSION, + .type = PURPLE_PLUGIN_PROTOCOL, + .priority = PURPLE_PRIORITY_DEFAULT, + .id = PURPLE_SPASM_PLUGIN_ID, + .version = PLUGIN_VERSION, + .extra_info = &prpl_info, + .summary = "Twitch.tv Protocol Plugin", + .description = "Implements the Twitch.tv chat protocol", + .author = "Gary Kramlich <grim@reaperworld.com>", + .homepage = "https://bitbucket.org/rw_grim/purple-spasm", +init_plugin(PurplePlugin *plugin) { +PURPLE_INIT_PLUGIN(purple_spasm, init_plugin, info);