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>2014-02-09 03:21:32 +0400
committereionrobb <eionrobb@8ca6c67d-4297-256d-f884-781da6d5760b>2014-02-09 03:21:32 +0400
commit6a45db2ff6fc2e3ea789ae734f732833a1a7b99a (patch)
tree8bc17ae426190a18447cc98865ceb648016bf13f /steam-mobile/libsteam.c
parentaf75851b147ca5af9fd38ce4c021e9fd2a1eb77e (diff)
Limit number of simultaneous buddy icon downloads to 4 to reduce threading. Fixes issue #37
Diffstat (limited to 'steam-mobile/libsteam.c')
-rw-r--r--steam-mobile/libsteam.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/steam-mobile/libsteam.c b/steam-mobile/libsteam.c
index 8220862..e3e4cd2 100644
--- a/steam-mobile/libsteam.c
+++ b/steam-mobile/libsteam.c
@@ -227,6 +227,8 @@ steam_fetch_new_sessionid(SteamAccount *sa)
steam_post_or_get(sa, STEAM_METHOD_GET | STEAM_METHOD_SSL, "steamcommunity.com", "/mobilesettings/GetManifest/v0001", NULL, steam_fetch_new_sessionid_cb, NULL, FALSE);
}
+static guint active_icon_downloads = 0;
+
static void
steam_get_icon_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, gsize len, const gchar *error_message)
{
@@ -239,10 +241,12 @@ steam_get_icon_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gc
sbuddy = buddy->proto_data;
purple_buddy_icons_set_for_user(buddy->account, buddy->name, g_memdup(url_text, len), len, sbuddy->avatar);
+
+ active_icon_downloads--;
}
static void
-steam_get_icon(PurpleBuddy *buddy)
+steam_get_icon_now(PurpleBuddy *buddy)
{
const gchar *old_avatar = purple_buddy_icons_get_checksum_for_user(buddy);
SteamBuddy *sbuddy;
@@ -264,6 +268,29 @@ steam_get_icon(PurpleBuddy *buddy)
#else
purple_util_fetch_url_request(sbuddy->avatar, TRUE, NULL, FALSE, NULL, FALSE, steam_get_icon_cb, buddy);
#endif
+
+ active_icon_downloads++;
+}
+
+static gboolean
+steam_get_icon_queuepop(gpointer data)
+{
+ PurpleBuddy *buddy = data;
+
+ // Only allow 4 simultaneous downloads
+ if (active_icon_downloads > 4)
+ return TRUE;
+
+ steam_get_icon_now(buddy);
+ return FALSE;
+}
+
+static void
+steam_get_icon(PurpleBuddy *buddy)
+{
+ if (!buddy) return;
+
+ purple_timeout_add(100, steam_get_icon_queuepop, (gpointer)buddy);
}
static void steam_poll(SteamAccount *sa, gboolean secure, guint message);