diff --git a/changelog.md b/changelog.md index 2469bec..5b98166 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,7 @@ * Now it is possible to like and see who liked a comment when displaying it individually. This applies to comments in wall posts and topics. * Now it is possible to choose how many items Socializer will load in conversation buffers, from the General tab in the preferences dialog. The default value is 50 items, and the maximum value is 200. * There is a new tab called buffer settings, in the preferences dialog. Settings related to how many items should be loaded in certain buffer types have been moved to this tab, so it will separate better the configuration options in the application. +* Added management of the Blacklist on VK. Users can be blocked from people buffers (friends, online, or any buffer inside friend requests). You can access the blacklist from the application menu, located in the menu bar. From there, you can unblock any previously blocked user. ### bugfixes @@ -17,6 +18,7 @@ * Fixed a traceback that was being logged when attempting to load an image but cancel the dialog for attaching it. * Fixed an error that was making Socializer to fail when loading the newsfeed buffer, thus not loading any other buffers. This error was caused due to VK sending a new object type representing push subscriptions. The item is ignored by Socializer so it will not break the newsfeed buffer anymore. * Fixed an error that was making the status bar to not fit the full size of the Window. This was cutting the messages placed on it, now, all messages are displayed properly again. +* fixed an unhandled condition when playing a song and voice message at the same time, that was potentially making Socializer to stop loading certain buffers. ### Changes diff --git a/src/controller/buffers.py b/src/controller/buffers.py index 67db4e9..b56b426 100644 --- a/src/controller/buffers.py +++ b/src/controller/buffers.py @@ -1362,6 +1362,7 @@ class peopleBuffer(feedBuffer): else: m = menus.peopleMenu(is_request=False) widgetUtils.connect_event(m, widgetUtils.MENU, self.decline_friendship, menuitem=m.decline) + widgetUtils.connect_event(m, widgetUtils.MENU, self.block_person, menuitem=m.block) # It is not allowed to send messages to people who is not your friends, so let's disable it if we're in a pending or outgoing requests buffer. if "friend_requests" in self.name: m.message.Enable(False) @@ -1395,6 +1396,21 @@ class peopleBuffer(feedBuffer): self.session.db[self.name]["items"].pop(self.tab.list.get_selected()) self.tab.list.remove_item(self.tab.list.get_selected()) + def block_person(self, *args, **kwargs): + person = self.get_post() + if person == None: + return + user = self.session.get_user(person["id"]) + question = commonMessages.block_person(user) + if question == widgetUtils.NO: + return + result = self.session.vk.client.account.ban(owner_id=person["id"]) + if result == 1: + msg = _("You've blocked {user1_nom} from your friends.").format(**user,) + pub.sendMessage("notify", message=msg) + self.session.db[self.name]["items"].pop(self.tab.list.get_selected()) + self.tab.list.remove_item(self.tab.list.get_selected()) + def keep_as_follower(self, *args, **kwargs): pass diff --git a/src/controller/mainController.py b/src/controller/mainController.py index 319dcaa..d59aeb8 100644 --- a/src/controller/mainController.py +++ b/src/controller/mainController.py @@ -624,6 +624,7 @@ class Controller(object): widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.open_logs, menuitem=self.window.open_logs) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.open_config, menuitem=self.window.open_config) + widgetUtils.connect_event(self.window, widgetUtils.MENU, self.blacklist, menuitem=self.window.blacklist) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.configuration, menuitem=self.window.settings_dialog) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_audio_album, menuitem=self.window.audio_album) @@ -723,10 +724,15 @@ class Controller(object): os.chdir("documentation/%s" % (lang,)) webbrowser.open("changelog.html") os.chdir("../../") + def configuration(self, *args, **kwargs): """ Opens the global settings dialogue.""" presenter = presenters.configurationPresenter(session=self.session, view=views.configurationDialog(title=_("Preferences")), interactor=interactors.configurationInteractor()) + def blacklist(self, *args, **kwargs): + """ Opens the blacklist presenter.""" + presenter = presenters.blacklistPresenter(session=self.session, view=views.blacklistDialog(), interactor=interactors.blacklistInteractor()) + def open_logs(self, *args, **kwargs): subprocess.call(["explorer", paths.logs_path()]) diff --git a/src/interactors/__init__.py b/src/interactors/__init__.py index 1586425..37c3f3f 100644 --- a/src/interactors/__init__.py +++ b/src/interactors/__init__.py @@ -1,5 +1,6 @@ from .attach import * from . audioRecorder import * +from . blacklist import * from .configuration import * from .postCreation import * from .postDisplayer import * diff --git a/src/interactors/blacklist.py b/src/interactors/blacklist.py new file mode 100644 index 0000000..912e4eb --- /dev/null +++ b/src/interactors/blacklist.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +import widgetUtils +from wxUI import commonMessages +from pubsub import pub +from . import base + +class blacklistInteractor(base.baseInteractor): + + def add_items(self, control, items): + if not hasattr(self.view, control): + raise AttributeError("The control is not present in the view.") + for i in items: + getattr(self.view, control).insert_item(False, *i) + + def install(self, *args, **kwargs): + super(blacklistInteractor, self).install(*args, **kwargs) + widgetUtils.connect_event(self.view.unblock, widgetUtils.BUTTON_PRESSED, self.on_unblock) + pub.subscribe(self.add_items, self.modulename+"_add_items") + + def uninstall(self): + super(blacklistInteractor, self).uninstall() + pub.unsubscribe(self.add_items, self.modulename+"_add_items") + + + def on_unblock(self, *args, **kwargs): + question = commonMessages.unblock_person() + if question == widgetUtils.NO: + return + item = self.view.persons.get_selected() + if self.presenter.unblock_person(item) == 1: + self.view.persons.remove_item(item) diff --git a/src/presenters/__init__.py b/src/presenters/__init__.py index f11bea9..e470733 100644 --- a/src/presenters/__init__.py +++ b/src/presenters/__init__.py @@ -13,6 +13,7 @@ """ from .attach import * from .audioRecorder import * +from .blacklist import * from .createPosts import * from .displayPosts import * from .configuration import * diff --git a/src/presenters/blacklist.py b/src/presenters/blacklist.py new file mode 100644 index 0000000..02e3865 --- /dev/null +++ b/src/presenters/blacklist.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +import threading +from pubsub import pub +from . import base + +class blacklistPresenter(base.basePresenter): + + def __init__(self, session, view, interactor): + self.session = session + super(blacklistPresenter, self).__init__(view=view, interactor=interactor, modulename="blacklist") + self.worker = threading.Thread(target=self.load_information) + self.worker.finished = threading.Event() + self.worker.start() + self.run() + + def load_information(self): + banned_users = self.session.vk.client.account.getBanned(count=200) + self.users = banned_users["profiles"] + items = [] + for i in self.users: + str_user = "{first_name} {last_name}".format(first_name=i["first_name"], last_name=i["last_name"]) + items.append([str_user]) + self.send_message("add_items", control="persons", items=items) + + def unblock_person(self, item): + result = self.session.vk.client.account.unban(owner_id=self.users[item]["id"]) + if result == 1: + msg = _("You've unblocked {user1_nom} from your friends.").format(**self.session.get_user(self.users[item]["id"]),) + pub.sendMessage("notify", message=msg) + return result \ No newline at end of file diff --git a/src/views/__init__.py b/src/views/__init__.py index 5ee8491..e74e40f 100644 --- a/src/views/__init__.py +++ b/src/views/__init__.py @@ -5,6 +5,7 @@ """ from .dialogs.attach import * from .dialogs.audioRecorder import * +from .dialogs.blacklist import * from .dialogs.postCreation import * from .dialogs.postDisplay import * from .dialogs.configuration import * diff --git a/src/views/dialogs/blacklist.py b/src/views/dialogs/blacklist.py new file mode 100644 index 0000000..461ec46 --- /dev/null +++ b/src/views/dialogs/blacklist.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals +import wx +import widgetUtils + +class blacklistDialog(widgetUtils.BaseDialog): + def __init__(self): + super(blacklistDialog, self).__init__(parent=None, title=_("blacklist")) + panel = wx.Panel(self) + sizer = wx.BoxSizer(wx.VERTICAL) + box1 = wx.StaticBoxSizer(parent=panel, orient=wx.HORIZONTAL, label=_("blocked users")) + self.persons = widgetUtils.list(panel, _("User"), style=wx.LC_REPORT) + box1.Add(self.persons.list, 0, wx.ALL, 5) + sizer.Add(box1, 0, wx.ALL, 5) + self.unblock = wx.Button(panel, wx.NewId(), _("Unblock")) + sizer.Add(self.unblock, 0, wx.ALL, 5) + close = wx.Button(panel, wx.ID_CLOSE) + sizer.Add(close, 0, wx.ALL, 5) + panel.SetSizer(sizer) + self.SetClientSize(sizer.CalcMin()) diff --git a/src/wxUI/commonMessages.py b/src/wxUI/commonMessages.py index ad7a4a7..0b3326a 100644 --- a/src/wxUI/commonMessages.py +++ b/src/wxUI/commonMessages.py @@ -68,5 +68,11 @@ def community_no_items(): def delete_conversation(): return wx.MessageDialog(None, _("do you really want to delete all messages of this conversation in VK?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() +def block_person(person): + return wx.MessageDialog(None, _("Are you really sure you want to block {user1_nom} from your VK account?").format(**person,), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() + +def unblock_person(): + return wx.MessageDialog(None, _("Are you sure you want to unblock this user?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() + def post_failed(): return wx.MessageDialog(None, _("Unfortunately, we could not send your last post or message to VK. Would you like to try again?"), _("Post failed"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal() \ No newline at end of file diff --git a/src/wxUI/mainWindow.py b/src/wxUI/mainWindow.py index d37256f..fd8bfe4 100644 --- a/src/wxUI/mainWindow.py +++ b/src/wxUI/mainWindow.py @@ -15,6 +15,7 @@ class mainWindow(wx.Frame): self.delete_audio_album = delete.Append(wx.NewId(), _("Audio album")) self.delete_video_album = delete.Append(wx.NewId(), _("Video album")) app_.Append(wx.NewId(), _("Delete"), delete) + self.blacklist = app_.Append(wx.NewId(), _("Blacklist")) self.settings_dialog = app_.Append(wx.NewId(), _("Preferences")) me = wx.Menu() profile = wx.Menu() diff --git a/src/wxUI/menus.py b/src/wxUI/menus.py index 9dd52bf..a97136d 100644 --- a/src/wxUI/menus.py +++ b/src/wxUI/menus.py @@ -45,15 +45,18 @@ class peopleMenu(wx.Menu): self.common_friends = self.Append(wx.NewId(), _("View friends in common")) if is_request == False and is_subscriber == False and not_friend == False: self.decline = self.Append(wx.NewId(), _("Remove from friends")) + self.block = self.Append(wx.NewId(), _("Block")) self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com")) def create_request_items(self): self.accept = self.Append(wx.NewId(), _("Accept")) self.decline = self.Append(wx.NewId(), _("Decline")) self.keep_as_follower = self.Append(wx.NewId(), _("Keep as follower")) + self.block = self.Append(wx.NewId(), _("Block")) def create_subscriber_items(self): self.add = self.Append(wx.NewId(), _("Add to friends")) + self.block = self.Append(wx.NewId(), _("Block")) class documentMenu(wx.Menu): def __init__(self, added=False, *args, **kwargs):