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>2012-08-24 06:03:04 +0400
committereionrobb <eionrobb@8ca6c67d-4297-256d-f884-781da6d5760b>2012-08-24 06:03:04 +0400
commit27a398eecd876ba3037b4b34e4d924dde3149dc2 (patch)
tree54c3b37b5a98720e48e757a26360c39ed5c27a75
parent1a890ddbfb9b1dc0b17057a1eee706e95bfa8f42 (diff)
Attempt to prevent messages from being received in duplicate
-rw-r--r--steam-mobile/libsteam.c43
-rw-r--r--steam-mobile/libsteam.h1
2 files changed, 26 insertions, 18 deletions
diff --git a/steam-mobile/libsteam.c b/steam-mobile/libsteam.c
index 99460b4..675e575 100644
--- a/steam-mobile/libsteam.c
+++ b/steam-mobile/libsteam.c
@@ -350,25 +350,32 @@ steam_poll_cb(SteamAccount *sa, JsonObject *obj, gpointer user_data)
{
if (json_object_has_member(message, "secure_message_id"))
{
- steam_poll(sa, TRUE, (guint) json_object_get_int_member(message, "secure_message_id"));
- sa->message = MAX(sa->message, (guint) json_object_get_int_member(obj, "secure_message_id"));
- } else {
- gchar *text, *html;
- PurpleMessageFlags flags;
- if (g_str_equal(type, "emote") || g_str_equal(type, "my_emote"))
+ guint secure_message_id = (guint) json_object_get_int_member(message, "secure_message_id");
+ steam_poll(sa, TRUE, secure_message_id);
+ sa->message = MAX(sa->message, secure_message_id);
+ } else {
+ guint new_timestamp = (guint) json_object_get_int_member(message, "timestamp");
+ if (new_timestamp > sa->last_message_timestamp)
{
- text = g_strconcat("/me ", json_object_get_string_member(message, "text"), NULL);
- } else {
- text = g_strdup(json_object_get_string_member(message, "text"));
- }
- html = purple_strdup_withhtml(text);
- if (g_str_has_prefix(type, "my_"))
- flags = PURPLE_MESSAGE_SEND;
- else
- flags = PURPLE_MESSAGE_RECV;
- serv_got_im(sa->pc, json_object_get_string_member(message, "steamid_from"), html, flags, time(NULL));
- g_free(html);
- g_free(text);
+ gchar *text, *html;
+ PurpleMessageFlags flags;
+ if (g_str_equal(type, "emote") || g_str_equal(type, "my_emote"))
+ {
+ text = g_strconcat("/me ", json_object_get_string_member(message, "text"), NULL);
+ } else {
+ text = g_strdup(json_object_get_string_member(message, "text"));
+ }
+ html = purple_strdup_withhtml(text);
+ if (g_str_has_prefix(type, "my_"))
+ flags = PURPLE_MESSAGE_SEND;
+ else
+ flags = PURPLE_MESSAGE_RECV;
+ serv_got_im(sa->pc, json_object_get_string_member(message, "steamid_from"), html, flags, time(NULL));
+ g_free(html);
+ g_free(text);
+
+ sa->last_message_timestamp = new_timestamp;
+ }
}
} else if (g_str_equal(type, "personastate"))
{
diff --git a/steam-mobile/libsteam.h b/steam-mobile/libsteam.h
index 449320a..9706a71 100644
--- a/steam-mobile/libsteam.h
+++ b/steam-mobile/libsteam.h
@@ -85,6 +85,7 @@ struct _SteamAccount {
gchar *steamid;
gchar *sessionid;
gint idletime;
+ guint last_message_timestamp;
};
struct _SteamBuddy {