grim/purple-spasm

Some quick memory hacks

2017-05-09, Gary Kramlich
c81e3dbaad99
Some quick memory hacks
/*
* 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 <json-glib/json-glib.h>
#include "debug.h"
#include "spasm-user.h"
#include "spasm-rest.h"
/******************************************************************************
* User endpoint
*****************************************************************************/
static void
_purple_spasm_refresh_user_cb(PurpleSpasmAccount *sa, JsonParser *parser,
GError *error, gpointer data)
{
JsonNode *node = NULL;
if(error) {
purple_debug_info("spasm", "refresh user error: %s", error->message);
g_error_free(error);
return;
}
node = json_parser_get_root(parser);
// now output the string to make sure it's all working
JsonGenerator *gen = json_generator_new();
json_generator_set_root(gen, node);
json_generator_set_pretty(gen, TRUE);
gchar *json_data = json_generator_to_data(gen, NULL);
purple_debug_info("spasm", "%s", json_data);
g_free(json_data);
g_object_unref(G_OBJECT(gen));
}
void
purple_spasm_refresh_user(PurpleSpasmAccount *sa) {
purple_spasm_rest_request(
sa,
"GET",
"/user",
NULL,
_purple_spasm_refresh_user_cb,
NULL
);
}