--- a/spasm-account.c Thu May 11 20:46:20 2017 -0500
+++ b/spasm-account.c Fri May 12 00:58:27 2017 -0500
@@ -19,6 +19,7 @@
#include "spasm-account.h"
struct _PurpleSpasmAccount {
@@ -26,7 +27,19 @@
PurpleConnection *connection;
+ gboolean email_verified; + gboolean twitter_connected; /******************************************************************************
@@ -104,7 +117,115 @@
purple_spasm_account_update_profile(PurpleSpasmAccount *sa, JsonParser *parser) {
- purple_debug_info("spasm", "Updating profile");
+ JsonObject *obj = NULL; + const gchar *str_attr = NULL; + "invalid spasm account" + root = json_parser_get_root(parser); + obj = json_node_get_object(root); + str_attr = json_object_get_string_member(obj, "display_name"); + sa->display_name = g_strdup(str_attr); + str_attr = json_object_get_string_member(obj, "_id"); + sa->id = g_strdup(str_attr); + str_attr = json_object_get_string_member(obj, "name"); + sa->name = g_strdup(str_attr); + str_attr = json_object_get_string_member(obj, "type"); + sa->type = g_strdup(str_attr); + str_attr = json_object_get_string_member(obj, "bio"); + sa->bio = g_strdup(str_attr); + str_attr = json_object_get_string_member(obj, "logo"); + sa->logo = g_strdup(str_attr); + str_attr = json_object_get_string_member(obj, "email"); + sa->email = g_strdup(str_attr); + sa->email_verified = json_object_get_boolean_member(obj, "email_verified"); + sa->partnered = json_object_get_boolean_member(obj, "partnered"); + sa->twitter_connected = json_object_get_boolean_member(obj, "twitter_connected"); +purple_spasm_account_get_display_name(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, NULL); + return sa->display_name; +purple_spasm_account_get_id(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, NULL); +purple_spasm_account_get_name(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, NULL); +purple_spasm_account_get_type(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, NULL); +purple_spasm_account_get_bio(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, NULL); +purple_spasm_account_get_logo(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, NULL); +purple_spasm_account_get_email(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, NULL); +purple_spasm_account_get_email_verified(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, FALSE); + return sa->email_verified; +purple_spasm_account_get_partnered(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, FALSE); +purple_spasm_account_get_twitter_connected(const PurpleSpasmAccount *sa) { + g_return_val_if_fail(sa, FALSE); + return sa->twitter_connected; --- a/spasm-account.h Thu May 11 20:46:20 2017 -0500
+++ b/spasm-account.h Fri May 12 00:58:27 2017 -0500
@@ -48,6 +48,17 @@
GError *purple_spasm_account_update_profile(PurpleSpasmAccount *sa, JsonParser *parser);
+const gchar *purple_spasm_account_get_display_name(const PurpleSpasmAccount *sa); +const gchar *purple_spasm_account_get_id(const PurpleSpasmAccount *sa); +const gchar *purple_spasm_account_get_name(const PurpleSpasmAccount *sa); +const gchar *purple_spasm_account_get_type(const PurpleSpasmAccount *sa); +const gchar *purple_spasm_account_get_bio(const PurpleSpasmAccount *sa); +const gchar *purple_spasm_account_get_logo(const PurpleSpasmAccount *sa); +const gchar *purple_spasm_account_get_email(const PurpleSpasmAccount *sa); +gboolean purple_spasm_account_get_email_verified(const PurpleSpasmAccount *sa); +gboolean purple_spasm_account_get_partnered(const PurpleSpasmAccount *sa); +gboolean purple_spasm_account_get_twitter_connected(const PurpleSpasmAccount *sa); #endif /* PURPLE_SPASM_ACCOUNT_H */
--- a/spasm-const.h Thu May 11 20:46:20 2017 -0500
+++ b/spasm-const.h Fri May 12 00:58:27 2017 -0500
@@ -22,6 +22,7 @@
#define PURPLE_SPASM_PLUGIN_ID "prpl-grim-spasm"
#define PURPLE_SPASM_BASE_URL "https://api.twitch.tv/kraken/"
+#define PURPLE_SPASM_WEBSOCKET_URL "wss://pubsub-edge.twitch.tv" #define PURPLE_SPASM_CONTENT_TYPE "application/vnd.twitchtv.v5+json"
#define PURPLE_SPASM_OAUTH2_CLIENT_ID "w7le4wyxwbipv6kf5qmqogwkqskl12"
#define PURPLE_SPASM_OAUTH2_SCOPES "user_read chat_login"
--- a/spasm-rest.c Thu May 11 20:46:20 2017 -0500
+++ b/spasm-rest.c Fri May 12 00:58:27 2017 -0500
@@ -19,6 +19,9 @@
#include <libsoup/soup.h>
@@ -41,6 +44,8 @@
GInputStream *istream = NULL;
JsonParser *parser = NULL;
+ JsonObject *json_obj = NULL; PurpleSpasmRestCallbackData *cb_data = (PurpleSpasmRestCallbackData *)data;
istream = soup_session_send_finish(SOUP_SESSION(obj), res, &error);
@@ -58,11 +63,67 @@
cb_data->cb(cb_data->sa, NULL, error, cb_data->data);
+ g_object_unref(G_OBJECT(parser)); + root = json_parser_get_root(parser); + if(root == NULL || !JSON_NODE_HOLDS_OBJECT(root)) { + "invalid json response" + cb_data->cb(cb_data->sa, NULL, error, cb_data->data); + g_object_unref(G_OBJECT(parser)); + json_obj = json_node_get_object(root); + "json is not an object" + cb_data->cb(cb_data->sa, NULL, error, cb_data->data); + g_object_unref(G_OBJECT(parser)); + if(json_object_has_member(json_obj, "error")) { + purple_debug_info("spasm", "error: %s\n", json_object_get_string_member(json_obj, "error")); + "error : %s : %" G_GINT64_FORMAT, + json_object_get_string_member(json_obj, "message"), + json_object_get_int_member(json_obj, "status") + cb_data->cb(cb_data->sa, NULL, error, cb_data->data); + g_object_unref(G_OBJECT(parser)); cb_data->cb(cb_data->sa, parser, NULL, cb_data->data);
+ g_object_unref(G_OBJECT(parser)); /******************************************************************************
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/spasm.h Fri May 12 00:58:27 2017 -0500
@@ -0,0 +1,27 @@
+ * 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. +#define PURPLE_SPASM_DOMAIN (g_quark_from_static_string("purple-spasm")) +#endif /* PURPLE_SPASM_H */ \ No newline at end of file