From ab6d446860fc9b9b68918d2222c6a6afbd89d6ca Mon Sep 17 00:00:00 2001 From: Eion Robb Date: Fri, 29 Sep 2017 11:43:51 +1300 Subject: Add an option to redeem game keys to the accounts menu --- steam-mobile/libsteam.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/steam-mobile/libsteam.c b/steam-mobile/libsteam.c index 8523cdd..9caae49 100644 --- a/steam-mobile/libsteam.c +++ b/steam-mobile/libsteam.c @@ -219,6 +219,37 @@ steam_friend_invite_action(SteamAccount *sa, const gchar *who, const gchar *acti g_string_free(postdata, TRUE); } +static void +steam_register_game_key_text(SteamAccount *sa, const gchar *game_key) +{ + //Possible actions: accept, ignore, block + GString *postdata = g_string_new(NULL); + + g_string_append_printf(postdata, "product_key=%s&", purple_url_encode(game_key)); + g_string_append_printf(postdata, "sessionid=%s&", purple_url_encode(sa->sessionid)); + + steam_post_or_get(sa, STEAM_METHOD_POST | STEAM_METHOD_SSL, "store.steampowered.com", "/account/ajaxregisterkey/", postdata->str, NULL, NULL, FALSE); + + g_string_free(postdata, TRUE); +} + +static void +steam_register_game_key(PurplePluginAction *action) +{ + PurpleConnection *pc = (PurpleConnection *) action->context; + SteamAccount *sa = pc->proto_data; + + purple_request_input(pc, "Activate a Product on Steam", + "Redeem a Steam Key", + NULL, + "XXXXX-XXXXX-XXXXX", FALSE, FALSE, NULL, + _("_Search"), G_CALLBACK(steam_register_game_key_text), + _("_Cancel"), NULL, + purple_connection_get_account(pc), NULL, NULL, + sa); + +} + static void steam_fetch_new_sessionid_cb(SteamAccount *sa, JsonObject *obj, gpointer user_data) { @@ -1751,6 +1782,10 @@ static GList *steam_actions(PurplePlugin *plugin, gpointer context) steam_search_users); m = g_list_append(m, act); + act = purple_plugin_action_new(_("Redeem game key..."), + steam_register_game_key); + m = g_list_append(m, act); + return m; } -- cgit v1.2.3