From 06c3fb58a765ef9af458f044aff063192f98b6c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Cort=C3=A9z?= Date: Fri, 3 Jun 2016 10:24:35 -0500 Subject: [PATCH] Create chat for unread messages. Set online and offline --- changelog.md | 4 ++++ src/controller/mainController.py | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index 75f1a85..7b285e0 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,10 @@ * Removed platform from "last seen" column in the friends list as it could cause some problems and it was being not so exact. * Now deleted audios are not parsed and displayed as "audio removed from library". They are silently ignored. * It's possible to open a friends timeline for others. +* Fixed some strange bugs in the built version. +* Deactivated accounts will not cause problems in friends lists. They will be displayed as deactivated, wich means that it'll be impossible to interact with those accounts. +* When opened, the client will set online for the user account, it'll inform VK that this user is currently online. This parameter will be updated every 15 minutes, as stated in the API documentation. When exiting, Socializer will try to set the account as offline. +* When opened, socializer will try to create chat buffers for all unread messages. ## Changes on build 2016.05.25 diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 358d95b..100275b 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -130,6 +130,10 @@ class Controller(object): self.window.change_status(_(u"Ready")) self.longpool = longpoolthread.worker(self.session) self.longpool.start() + self.status_setter = RepeatingTimer(900, self.set_online) + self.status_setter.start() + self.set_online() + self.create_unread_messages() def in_post(self, buffer): buffer = self.search(buffer) @@ -161,6 +165,7 @@ class Controller(object): def exit(self, *args, **kwargs): log.debug("Receibed an exit signal. closing...") + self.session.vk.client.account.setOffline() self.disconnect_events() self.window.Destroy() wx.GetApp().ExitMainLoop() @@ -300,4 +305,14 @@ class Controller(object): # ToDo: Clean this code and test how is the database working with this set to True. num = self.session.order_buffer(buffer.name, data, True) buffer.insert(self.session.db[buffer.name]["items"][-1], False) - self.session.soundplayer.play("chat.ogg") \ No newline at end of file + self.session.soundplayer.play("chat.ogg") + + def set_online(self): + r = self.session.vk.client.account.setOnline() + print "online: %d" % (r,) + + def create_unread_messages(self): + msgs = self.session.vk.client.messages.getDialogs(count=200, unread=1) + print msgs + for i in msgs["items"]: + self.chat_from_id(i["from_id"])