Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/EionRobb/pidgin-opensteamworks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreionrobb <eionrobb@8ca6c67d-4297-256d-f884-781da6d5760b>2013-08-05 08:45:58 +0400
committereionrobb <eionrobb@8ca6c67d-4297-256d-f884-781da6d5760b>2013-08-05 08:45:58 +0400
commit5502663790f3177a79300e4d0897e573c9d73b0a (patch)
treee6c00e9ba47e159ea177f676026bfb863095ab71
parent71b4c875d11ff2d165fc22ea9e76b6a1675a52ac (diff)
Added account option to change Pidgin's status message when you start a game
-rw-r--r--steam-mobile/libsteam.c36
-rw-r--r--steam-mobile/libsteam.h1
2 files changed, 36 insertions, 1 deletions
diff --git a/steam-mobile/libsteam.c b/steam-mobile/libsteam.c
index 0cc9371..fadf297 100644
--- a/steam-mobile/libsteam.c
+++ b/steam-mobile/libsteam.c
@@ -567,7 +567,34 @@ steam_got_friend_summaries(SteamAccount *sa, JsonObject *obj, gpointer user_data
{
JsonObject *player = json_array_get_object_element(players, index);
const gchar *steamid = json_object_get_string_member(player, "steamid");
- gint64 personastate = -1;
+ gint64 personastate = -1;
+
+ if (g_str_equal(steamid, sa->steamid) && purple_account_get_bool(sa->account, "change_status_to_game", FALSE)) {
+ const gchar *gameid = json_object_get_string_member(player, "gameid");
+ const gchar *last_gameid = purple_account_get_string(sa->account, "current_gameid", NULL);
+ if (!purple_strequal(last_gameid, gameid)) {
+ PurpleSavedStatus *current_status = purple_savedstatus_get_current();
+ // We changed our in-game status
+ purple_account_set_string(sa->account, "current_gameid", gameid);
+
+ if (!last_gameid) {
+ //Starting a game
+ purple_account_set_string(sa->account, "last_status_message", purple_savedstatus_get_message(current_status));
+ }
+ if (!gameid) {
+ //Finishing game
+ purple_savedstatus_set_message(current_status, purple_account_get_string(sa->account, "last_status_message", NULL));
+ purple_account_set_string(sa->account, "last_status_message", NULL);
+ } else {
+ //Starting or changing a game
+ gchar *new_message = g_markup_printf_escaped("In game %s", json_object_get_string_member(player, "gameextrainfo"));
+ purple_savedstatus_set_message(current_status, new_message);
+ g_free(new_message);
+ }
+ purple_savedstatus_activate(current_status);
+ }
+ }
+
buddy = purple_find_buddy(sa->account, steamid);
if (!buddy)
continue;
@@ -585,6 +612,7 @@ steam_got_friend_summaries(SteamAccount *sa, JsonObject *obj, gpointer user_data
g_free(sbuddy->realname); sbuddy->realname = g_strdup(json_object_get_string_member(player, "realname"));
g_free(sbuddy->profileurl); sbuddy->profileurl = g_strdup(json_object_get_string_member(player, "profileurl"));
g_free(sbuddy->avatar); sbuddy->avatar = g_strdup(json_object_get_string_member(player, "avatarfull"));
+ // Optional :
g_free(sbuddy->gameid); sbuddy->gameid = g_strdup(json_object_get_string_member(player, "gameid"));
g_free(sbuddy->gameextrainfo); sbuddy->gameextrainfo = g_strdup(json_object_get_string_member(player, "gameextrainfo"));
g_free(sbuddy->gameserversteamid); sbuddy->gameserversteamid = g_strdup(json_object_get_string_member(player, "gameserversteamid"));
@@ -1314,6 +1342,12 @@ static void plugin_init(PurplePlugin *plugin)
"always_use_https", FALSE);
prpl_info->protocol_options = g_list_append(
prpl_info->protocol_options, option);
+
+ option = purple_account_option_bool_new(
+ _("Change status when in-game"),
+ "change_status_to_game", FALSE);
+ prpl_info->protocol_options = g_list_append(
+ prpl_info->protocol_options, option);
}
static PurplePluginProtocolInfo prpl_info = {
diff --git a/steam-mobile/libsteam.h b/steam-mobile/libsteam.h
index 018c3de..cedf2b4 100644
--- a/steam-mobile/libsteam.h
+++ b/steam-mobile/libsteam.h
@@ -52,6 +52,7 @@
#include "proxy.h"
#include "prpl.h"
#include "request.h"
+#include "savedstatuses.h"
#include "sslconn.h"
#include "version.h"