Compare commits
47 Commits
v0.22
...
notificati
Author | SHA1 | Date | |
---|---|---|---|
9e6e72c0a1 | |||
63def5530f | |||
c206a40e62 | |||
2889923940 | |||
3deabdbf36 | |||
89c8e6a194 | |||
19a5216373 | |||
f274ba9caa | |||
5a36db2366 | |||
9003d3c738 | |||
d06a32311e | |||
63fb0e0ff9 | |||
4e14801db6 | |||
926db6007a | |||
cf0e001cfc | |||
ee6370bb0b | |||
33ba50a7b4 | |||
29e8b00656 | |||
ff175c0c8f | |||
a015593971 | |||
fdbf42ad1a | |||
61583447b6 | |||
33ab63c1bc | |||
5b3a013766 | |||
69f8b79fc4 | |||
60d283f931 | |||
f41dd51dc7 | |||
a7173adc22 | |||
bbef34d125 | |||
277b10b155 | |||
6a69d4eaac | |||
4d3c1cacc9 | |||
2ed26bc8d9 | |||
52e55a24fa | |||
98b85435ac | |||
3903c5630f | |||
ac7ef77a8d | |||
c80ca295c6 | |||
19a9c305ce | |||
dca7b4a694 | |||
357d18fbe0 | |||
251623acf0 | |||
4caa5a6ab0 | |||
d1b11c0630 | |||
36b25e1c9f | |||
6a2407a07c | |||
64799d2e14 |
31
changelog.md
31
changelog.md
@@ -4,6 +4,37 @@
|
||||
|
||||
### New additions
|
||||
|
||||
* Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later.
|
||||
* Switching accounts is now supported in socializer. In the application menu, there is an option called "manage accounts" which allows you to add or remove an account. Socializer will take changes after a restart of the application. In case of having multiple accounts, every time Socializer starts, you will see a dialog from where is possible to choose the account for logging in.
|
||||
* when selecting multiple audio files in audio buffers, multiple actions can be performed in all items, these actions are present in the contextual menu of the buffer (namely play, add/remove from the library and move to a different playlist). This means you can select all the audios you want and Socializer will perform the selected options in all items, making it a bit easier to operate with multiple songs.
|
||||
* 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.
|
||||
* In the new timeline dialog, it is possible to create video buffers by selecting the "video" radio button as buffer type.
|
||||
|
||||
### bugfixes
|
||||
|
||||
* Fixed an error that was causing socializer to not update the "Online friends" buffer if chat notifications were disabled.
|
||||
* Fixed an error that was making Socializer unable to attach audio files from the computer, if the file does not include correct ID3 TAGS.
|
||||
* 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.
|
||||
* fixed an error that was making socializer unable to parse video data, thus video buffers were impossible to be loaded.
|
||||
|
||||
### Changes
|
||||
|
||||
* Less confidential user data will be send to the logs, so it will be much safer to pass logs publicly.
|
||||
* automatic update checks will be disabled if using socializer from the source code.
|
||||
* it is possible to post in an user's wall by using the post button located next to the user, in people buffers. This applies only to online users and list of friends.
|
||||
* When displaying a profile, information about mobile and home phone is displayed in the basic information tab.
|
||||
* In wall posts, all comments, including replies, will be displayed in the same list. Before, you had to open a comment to read its replies. When a new comment is posted by the current user, the list of comments will be reloaded and new additions will be fetched and sorted properly.
|
||||
|
||||
## changes in Versions 0.21 and 0.22 (14.07.2019)
|
||||
|
||||
### New additions
|
||||
|
||||
* Added "post in groups" feature. In order to do so, you need to load the posts for the group where you want to send something. Once loaded, go to the post button in the group's wall and select whether you want to post in the group's behalf or as yourself.
|
||||
* In all audio buffers, it is possible to select individual tracks to be played together. In order to do so, you need to press space to start the selection of items. When selected, the item will emit a sound to indicate the change. Press space in all items you want to select/unselect. When you're focusing an already selected item it will play a sound to indicate that it is already selected. Once you're done with your selection, pressing enter in the list of tracks will start the playback of the list of items you have selected. This is a very experimental feature. More actions can be supported based in this selection method if it proves to be useful.
|
||||
* In conversation buffers, it is possible to display and open wall posts sent as attachments in messages.
|
||||
|
@@ -1,2 +0,0 @@
|
||||
Manuel Cortéz
|
||||
Valeria K
|
@@ -9,7 +9,7 @@ Socializer is an application to use [VK.com](https://vk.com) in an easy and acce
|
||||
* audio support.
|
||||
* Post comments.
|
||||
* like, unlike and repost other's posts.
|
||||
* Open other's timelines so you could track their friends, posts or audio files.
|
||||
* Open other's timelines so you could track their friends, posts, audio or video files.
|
||||
* Basic chat features.
|
||||
|
||||
## Usage
|
||||
@@ -48,10 +48,10 @@ An item is an element representing some data provided by VK. Items are separated
|
||||
The following is a brief description of the kind of items socializer can work with, and what actions are available for those.
|
||||
|
||||
* Newsfeed post: It represents a post displayed in your "home" page on VK. It may contain a variety of information based in what you or your friends do. A newsfeed item may contain information about new audios added to your friend's library, new people added to friends, wall posts, reposts and new photos added. Depending on the kind of data VK has supplied, the item can open a dialog showing information about the post, a list displaying the people added to friends, or a dialog displaying information for every audio added to library. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. Available options for this item are different depending in the information the item contains. You can open or view the profile of the user that generated the item, like, dislike or add a comment to a post.
|
||||
* Wall post: Represent a post in an user's wall. This post will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. When opened (by pressing enter or the open option in the associated menu), it will show a dialogue where you can read the message, see how many times the post has been viewed by other users, interact with attachment files (by searching the list and pressing enter in the focused attachment to open it), see the photos included in the post, read information related to likes and times the post has been shared, read and reply to comments. Additionally, you can share the post, indicate you like it, or add a comment. You can cycle through every item in the dialog by pressing tab.
|
||||
* Audio: It represent an audio uploaded to the VK'S platform. Actions available for this item are opening the audio in a dialog, add or remove it from your library, move the audio to a playlist, and play it. When opened, it will be displayed in a dialog allowing you to read the title of the song, artist name, duration and a few buttons: play, add or remove from your library and download. You can control playback of audio items from the buffer by using the player menu on the menu bar or the corresponding keyboard shortcuts.
|
||||
* Video: It represent a video uploaded to the VK'S platform. Actions available for this item are opening the video in your default web browser and move it to a video album. When opened, it will open a web browser and play the video automatically due to VK limitations in access to video files.
|
||||
* person: It contains information about a VK user, this item is present in all buffers under the "people" category. Actions available for this item are view user profile, send message and create a timeline, which is a special buffer to track all posts, friends or audios owned by the user. When opened, it will display the profile of this user in a dialog and will provide actions to send a message to the user, or view other sections of her/his profile.
|
||||
* Wall post: Represents a post in an user's wall. This post will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. When opened (by pressing enter or the open option in the associated menu), it will show a dialogue where you can read the message, see how many times the post has been viewed by other users, interact with attachment files (by searching the list and pressing enter in the focused attachment to open it), see the photos included in the post, read information related to likes and times the post has been shared, read and reply to comments. Additionally, you can share the post, indicate you like it, or add a comment. You can cycle through every item in the dialog by pressing tab.
|
||||
* Audio: It represents an audio uploaded to the VK'S platform. Actions available for this item are opening the audio in a dialog, add or remove it from your library, move the audio to a playlist, and play it. When opened, it will be displayed in a dialog allowing you to read the title of the song, artist name, duration and a few buttons: play, add or remove from your library and download. You can control playback of audio items from the buffer by using the player menu on the menu bar or the corresponding keyboard shortcuts. Additionally, it is possible to select multiple audios in the same buffer to perform specific actions on them, such as play, remove or add the selected audios to a playlist. In order to select multiple audios, press the spacebar in every audio item you want to select. You will hear a sound when an item is selected, and when you focus a selected audio. When you're done, press enter to play all the selected audios or use the context menu to see available actions. All actions will be applied in the selected audios.
|
||||
* Video: It represents a video uploaded to the VK'S platform. Actions available for this item are opening the video in your default web browser and move it to a video album. When opened, it will open a web browser and play the video automatically due to VK limitations in access to video files.
|
||||
* person: It contains information about a VK user, this item is present in all buffers under the "people" category. Actions available for this item are view user profile, send message and create a timeline, which is a special buffer to track all posts, friends, audios or videos owned by the user. When opened, it will display the profile of this user in a dialog and will provide actions to send a message to the user, or view other sections of her/his profile.
|
||||
* Message: A message appears only in conversation buffers and represents a chat message. It may include a list of attached files that will be displayed in a separated list. You can tab to that list (from the history) and press enter in the attached file you want to open. Chat items are marked as read automatically as soon as they are focused.
|
||||
|
||||
## Main interface
|
||||
@@ -69,7 +69,7 @@ In summary, the GUI contains two core components. These are the controls you wil
|
||||
|
||||
### Buttons in the application
|
||||
|
||||
* Post: this button opens up a dialogue box to write a post in the wall of the focused user. For example, if you are in the "my wall" buffer you will send a post to your own wall, but if you are in an user timeline the post will be sent to the owner of the timeline. You can upload an attachment by pressing the "attach" button and choosing between uploading a photo or audio file in the dialog which will appear, check spelling or translate your message by selecting one of the available buttons in the dialogue box. In addition, you can tag a friend in your post by pressing the corresponding button for that purpose. Also it is possible to configure the privacy settings for your post by allowing all users or just your friends to read it. Press the send button to send the post.
|
||||
* Post: this button opens up a dialogue box to write a post in the wall of the focused user. For example, if you are in the "my wall" buffer you will send a post to your own wall, but if you are in an user timeline the post will be sent to the owner of the timeline. You can upload an attachment by pressing the "attach" button and choosing between uploading a photo, audio file or document in the dialog which will appear, check spelling or translate your message by selecting one of the available buttons in the dialogue box. In addition, you can tag a friend in your post by pressing the corresponding button for that purpose. Also it is possible to configure the privacy settings for your post by allowing all users or just your friends to read it. Press the send button to send the post.
|
||||
* Load buffer: Some buffers are created but not loaded in VK. These special buffers need to be loaded manually by pressing the load button. Once loaded, this kind of buffers will behave in the same way other buffers do. Examples of these buffers are audio and video albums, community walls, and the current user's documents
|
||||
* Play: In audio buffers, plays the focused song. In video buffers, this button will open a web browser for playing the focused video, due to a limitation VK placed to third party developers with videos.
|
||||
* Play all: In audio buffers, play all songs starting from the focused buffer, until the last item in the list.
|
||||
@@ -85,6 +85,8 @@ Visually, Towards the top of the main application window, A menu bar can be foun
|
||||
|
||||
* Create: opens a menu where you can create a new album. At the moment, only audio and video albums are supported.
|
||||
* Delete: opens a menu where you can delete an already existing album owned by yourself. Only audio and video albums are supported at this time.
|
||||
* blacklist: Opens a dialog which allows you to manage blocked people on VK.
|
||||
* Manage accounts: Opens up a dialogue from where you are able to add or delete an account in socializer. If you have more than an account, you will be asked at startup for the account you want to use in the application. You can use an account at once, but it is possible to have multiple accounts and switch between them by restarting the application.
|
||||
* Preferences: Opens a dialogue which lets you configure settings for the entire application.
|
||||
|
||||
### Me menu
|
||||
@@ -96,11 +98,11 @@ Visually, Towards the top of the main application window, A menu bar can be foun
|
||||
|
||||
### Buffer menu
|
||||
|
||||
* New timeline: Lets you open a user's timeline by choosing the user in a dialog box. You can choose which items you want to track: wall posts, friends or audio items. It is created when you press enter. If you invoke this option relative to a user that has no items of the kind you specified, the operation will fail. If you try creating an existing timeline the program will warn you and will not create it again.
|
||||
* New timeline: Lets you open an user's timeline by choosing the user in a dialog box. You can choose which items you want to track: wall posts, videos, friends or audio items. It is created when you press enter. If you invoke this option relative to a user that has no items of the kind you specified, the operation will fail. If you try creating an existing timeline the program will warn you and will not create it again.
|
||||
* Search: Shows a menu where you can search for audios or videos on VK. Search results will be created in a new buffer inside "music" or "videos".
|
||||
* Update buffer: Performs a manual update operation in the buffer, which will retrieve all new items present in the social network since the last update.
|
||||
* Load previous items: This allows more items to be loaded for the specified buffer. Bear in mind that not all buffers support this setting.
|
||||
* Destroy: dismisses the list you're on, if possible.
|
||||
* Remove buffer: dismisses the list you're on, if possible.
|
||||
|
||||
### Player menu
|
||||
|
||||
@@ -141,16 +143,20 @@ As described above, this application has a preferences dialogue accessible under
|
||||
|
||||
### General tab
|
||||
|
||||
* Number of items to load for newsfeed and wall buffers: Allows you to specify how many items should be retrieved from VK in the newsfeed buffer and when opening walls for other users. Default and maximum is 100.
|
||||
* Number of items to load in video buffers: Allows you to specify how many items should be retrieved from VK in video buffers. Default and maximum is 200.
|
||||
* Language: allows you to switch the interface language for socializer. The application must be restarted after changing the language.
|
||||
* Load images in posts: Allows you to specify whether you want socializer to display all images when opening a post, or not. This can be useful for people with slow connections or not needing images.
|
||||
* Use proxy: for countries where Vk is blocked by the internet providers, this settings allows socializer to connect via a proxy server already included in the application.
|
||||
* Update channel: allows you to specify how often you will receive updates for the program. There are two update channels available: Alpha channel, which contains unstable versions of the application and gets updates almost dayly, and stable, which contain tested and more stable versions of the program, but gets updates once in a month, approximately.
|
||||
|
||||
### Buffer settings tab
|
||||
|
||||
* Number of items to load for newsfeed and wall buffers: Allows you to specify how many items should be retrieved from VK in the newsfeed buffer and when opening walls for other users. Default is 50 items, and maximum is 100.
|
||||
* Number of items to load in video buffers: Allows you to specify how many items should be retrieved from VK in video buffers. Default is 50, maximum value is 200.
|
||||
* Number of items to load in conversation buffers: allows you to specify how many messages Socializer will retrieve when loading a conversation. Default is 50, maximum value is 200.
|
||||
|
||||
### Chat settings tab
|
||||
|
||||
* Show notifications when users are online/offline: These two checkboxes allows you to specify if you want socializer to notify you when someone is connected or disconnected in the VK network.
|
||||
* Open unread conversations at startup: When enabled, Socializer will load any conversation with unread messages after started.
|
||||
* Move focus to new conversations: When enabled, new conversations will be focused automatically right after being created.
|
||||
* Notification type: This setting allows you to specify the notification type you prefer to use in socializer. The options are native and custom. Native notifications send a system notification every time someone is online or offline, while custom notifications play a sound and announce the notification in the screen reader only.
|
||||
|
||||
### Optional buffers tab
|
||||
@@ -169,12 +175,11 @@ If you still have questions after reading this document, if you wish to collabor
|
||||
|
||||
## Credits
|
||||
|
||||
Socializer is developed and maintained by [Manuel Cortez,](https://manuelcortez.net) with contributions by [Anibal Hernandez](https://dragodark.com)
|
||||
Socializer is developed and maintained by [Manuel Cortez.](https://manuelcortez.net)
|
||||
|
||||
We would also like to thank the translators of Socializer, who have allowed the spreading of the application.
|
||||
|
||||
* English: Manuel Cortéz.
|
||||
* Spanish: Manuel Cortéz.
|
||||
* Russian: Дарья Ратникова.
|
||||
|
||||
Special thanks to Дарья Ратникова, as she also manages the Socializer's community in VK, translates the website and the documentation into Russian.
|
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
name = "Socializer"
|
||||
version = "0.22"
|
||||
version = "0.23"
|
||||
author = "Manuel Cortez"
|
||||
authorEmail = "manuel@manuelcortez.net"
|
||||
copyright = "Copyright (C) 2016-2019, Manuel Cortez"
|
||||
|
@@ -79,7 +79,10 @@ class baseBuffer(object):
|
||||
|
||||
def insert(self, item, reversed=False):
|
||||
""" Add a new item to the list. Uses renderers.composefunc for parsing the dictionary and create a valid result for putting it in the list."""
|
||||
item_ = getattr(renderers, self.compose_function)(item, self.session)
|
||||
try:
|
||||
item_ = getattr(renderers, self.compose_function)(item, self.session)
|
||||
except:
|
||||
log.exception(item)
|
||||
wx.CallAfter(self.tab.list.insert_item, reversed, *item_)
|
||||
|
||||
def get_items(self, show_nextpage=False):
|
||||
@@ -105,12 +108,12 @@ class baseBuffer(object):
|
||||
if self.tab.list.get_count() > 0 and num > 0:
|
||||
v = [i for i in self.session.db[self.name]["items"][:num]]
|
||||
v.reverse()
|
||||
[self.insert(i, True) for i in v]
|
||||
[wx.CallAfter(self.insert, i, True) for i in v]
|
||||
else:
|
||||
[self.insert(i) for i in self.session.db[self.name]["items"][:num]]
|
||||
[wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
|
||||
else:
|
||||
if num > 0:
|
||||
[self.insert(i, False) for i in self.session.db[self.name]["items"][-num:]]
|
||||
[wx.CallAfter(self.insert, i, False) for i in self.session.db[self.name]["items"][-num:]]
|
||||
return retrieved
|
||||
|
||||
def get_more_items(self):
|
||||
@@ -123,66 +126,11 @@ class baseBuffer(object):
|
||||
During the second part (threaded), the post will be sent to the API."""
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Write your post"), message="", text=""))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
call_threaded(self.do_last, p=p)
|
||||
|
||||
def do_last(self, p, parent_endpoint="wall", child_endpoint="post", *args, **kwargs):
|
||||
""" Second part of post function. Here everything is going to be sent to the API"""
|
||||
msg = p.text
|
||||
attachments = ""
|
||||
if hasattr(p, "attachments"):
|
||||
attachments = self.upload_attachments(p.attachments)
|
||||
urls = utils.find_urls_in_text(msg)
|
||||
if len(urls) != 0:
|
||||
if len(attachments) == 0: attachments = urls[0]
|
||||
else: attachments += urls[0]
|
||||
msg = msg.replace(urls[0], "")
|
||||
if msg != "":
|
||||
kwargs.update(message=msg)
|
||||
kwargs.update(privacy=p.privacy)
|
||||
if attachments != "":
|
||||
kwargs.update(attachments=attachments)
|
||||
# Determines the correct functions to call here.
|
||||
parent_endpoint = getattr(self.session.vk.client, parent_endpoint)
|
||||
endpoint = getattr(parent_endpoint, child_endpoint)
|
||||
post = endpoint(**kwargs)
|
||||
pub.sendMessage("posted", buffer=self.name)
|
||||
|
||||
def upload_attachments(self, attachments):
|
||||
""" Upload attachments to VK before posting them.
|
||||
Returns attachments formatted as string, as required by VK API."""
|
||||
# To do: Check the caption and description fields for this kind of attachments.
|
||||
local_attachments = ""
|
||||
uploader = upload.VkUpload(self.session.vk.session_object)
|
||||
for i in attachments:
|
||||
if i["from"] == "online":
|
||||
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
|
||||
elif i["from"] == "local" and i["type"] == "photo":
|
||||
photos = i["file"]
|
||||
description = i["description"]
|
||||
r = uploader.photo_wall(photos, caption=description)
|
||||
id = r[0]["id"]
|
||||
owner_id = r[0]["owner_id"]
|
||||
local_attachments += "photo{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "audio":
|
||||
audio = i["file"]
|
||||
title = "untitled"
|
||||
artist = "unnamed"
|
||||
if "artist" in i:
|
||||
artist = i["artist"]
|
||||
if "title" in i:
|
||||
title = i["title"]
|
||||
r = uploader.audio(audio, title=title, artist=artist)
|
||||
id = r["id"]
|
||||
owner_id = r["owner_id"]
|
||||
local_attachments += "audio{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "document":
|
||||
document = i["file"]
|
||||
title = i["title"]
|
||||
r = uploader.document(document, title=title, to_wall=True)
|
||||
id = r["doc"]["id"]
|
||||
owner_id = r["doc"]["owner_id"]
|
||||
local_attachments += "doc{0}_{1},".format(owner_id, id)
|
||||
return local_attachments
|
||||
post_arguments=dict(privacy=p.privacy, message=p.text)
|
||||
attachments = []
|
||||
if hasattr(p, "attachments"):
|
||||
attachments = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def connect_events(self):
|
||||
""" Bind all events to this buffer"""
|
||||
@@ -417,12 +365,12 @@ class feedBuffer(baseBuffer):
|
||||
if self.tab.list.get_count() > 0 and num > 0:
|
||||
v = [i for i in self.session.db[self.name]["items"][:num]]
|
||||
v.reverse()
|
||||
[self.insert(i, True) for i in v]
|
||||
[wx.CallAfter(self.insert, i, True) for i in v]
|
||||
else:
|
||||
[self.insert(i) for i in self.session.db[self.name]["items"][:num]]
|
||||
[wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
|
||||
else:
|
||||
if num > 0:
|
||||
[self.insert(i, False) for i in self.session.db[self.name]["items"][-num:]]
|
||||
[wx.CallAfter(self.insert, i, False) for i in self.session.db[self.name]["items"][-num:]]
|
||||
return retrieved
|
||||
|
||||
def remove_buffer(self, mandatory=False):
|
||||
@@ -465,7 +413,11 @@ class feedBuffer(baseBuffer):
|
||||
title = _("Post to {user1_nom}'s wall").format(**user)
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
call_threaded(self.do_last, p=p, owner_id=owner_id)
|
||||
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=owner_id)
|
||||
attachments = []
|
||||
if hasattr(p, "attachments"):
|
||||
attachments = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def open_in_browser(self, *args, **kwargs):
|
||||
post = self.get_post()
|
||||
@@ -522,7 +474,11 @@ class communityBuffer(feedBuffer):
|
||||
title = _("Post to {user1_nom}'s wall").format(**user)
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
call_threaded(self.do_last, p=p, owner_id=owner_id, from_group=from_group)
|
||||
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=owner_id, from_group=from_group)
|
||||
attachments = []
|
||||
if hasattr(p, "attachments"):
|
||||
attachments = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
class topicBuffer(feedBuffer):
|
||||
|
||||
@@ -567,28 +523,15 @@ class topicBuffer(feedBuffer):
|
||||
owner_id = self.kwargs["group_id"]
|
||||
user = self.session.get_user(-1*owner_id, key="user1")
|
||||
title = _("Create topic in {user1_nom}").format(**user)
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createTopicDialog(title=title, message="", text=""))
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createTopicDialog(title=title, message="", text="", topic_title=""))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
call_threaded(self.do_last, p=p, group_id=owner_id, from_group=from_group)
|
||||
|
||||
def do_last(self, p, *args, **kwargs):
|
||||
title = p.view.title
|
||||
msg = p.text
|
||||
attachments = ""
|
||||
if hasattr(p, "attachments"):
|
||||
attachments = self.upload_attachments(p.attachments)
|
||||
urls = utils.find_urls_in_text(msg)
|
||||
if len(urls) != 0:
|
||||
if len(attachments) == 0: attachments = urls[0]
|
||||
else: attachments += urls[0]
|
||||
msg = msg.replace(urls[0], "")
|
||||
if msg != "":
|
||||
kwargs.update(text=msg, title=title.GetValue())
|
||||
if attachments != "":
|
||||
kwargs.update(attachments=attachments)
|
||||
# Determines the correct functions to call here.
|
||||
post = self.session.vk.client.board.addTopic(**kwargs)
|
||||
pub.sendMessage("posted", buffer=self.name)
|
||||
title = p.view.title.GetValue()
|
||||
msg = p.text
|
||||
post_arguments = dict(title=title, text=msg, group_id=owner_id, from_group=from_group)
|
||||
attachments = []
|
||||
if hasattr(p, "attachments"):
|
||||
attachments = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="addTopic", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
class documentBuffer(feedBuffer):
|
||||
can_get_items = False
|
||||
@@ -738,10 +681,10 @@ class audioBuffer(feedBuffer):
|
||||
self.play_audio()
|
||||
|
||||
def open_post(self, *args, **kwargs):
|
||||
selected = self.tab.list.get_selected()
|
||||
if selected == -1:
|
||||
selected = self.tab.list.get_multiple_selection()
|
||||
if len(selected) < 1:
|
||||
return
|
||||
audios = [self.session.db[self.name]["items"][selected]]
|
||||
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
|
||||
a = presenters.displayAudioPresenter(session=self.session, postObject=audios, interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
|
||||
|
||||
def play_all(self, *args, **kwargs):
|
||||
@@ -777,44 +720,101 @@ class audioBuffer(feedBuffer):
|
||||
event.Skip()
|
||||
|
||||
def add_to_library(self, *args, **kwargs):
|
||||
post = self.get_post()
|
||||
if post == None:
|
||||
call_threaded(self._add_to_library, *args, **kwargs)
|
||||
|
||||
def _add_to_library(self, *args, **kwargs):
|
||||
selected = self.tab.list.get_multiple_selection()
|
||||
if len(selected) < 1:
|
||||
return
|
||||
args = {}
|
||||
args["audio_id"] = post["id"]
|
||||
if "album_id" in post:
|
||||
args["album_id"] = post["album_id"]
|
||||
args["owner_id"] = post["owner_id"]
|
||||
audio = self.session.vk.client.audio.add(**args)
|
||||
if audio != None and int(audio) > 21:
|
||||
output.speak(_("Audio added to your library"))
|
||||
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
|
||||
errors_detected = 0
|
||||
for i in audios:
|
||||
args = {}
|
||||
args["audio_id"] = i["id"]
|
||||
if "album_id" in i:
|
||||
args["album_id"] = i["album_id"]
|
||||
args["owner_id"] = i["owner_id"]
|
||||
try:
|
||||
audio = self.session.vk.client.audio.add(**args)
|
||||
except VkApiError:
|
||||
errors_detected = errors_detected + 1
|
||||
continue
|
||||
if audio != None and int(audio) < 21:
|
||||
errors_detected = errors_detected + 1
|
||||
if errors_detected == 0:
|
||||
if len(selected) == 1:
|
||||
msg = _("Audio added to your library")
|
||||
elif len(selected) > 1 and len(selected) < 5:
|
||||
msg = _("{0} audios were added to your library.").format(len(selected),)
|
||||
else:
|
||||
msg = _("{audios} audios were added to your library.").format(audios=len(selected),)
|
||||
output.speak(msg)
|
||||
else:
|
||||
output.speak(_("{0} errors occurred while attempting to add {1} audios to your library.").format(errors_detected, len(selected)))
|
||||
|
||||
def remove_from_library(self, *args, **kwargs):
|
||||
post = self.get_post()
|
||||
if post == None:
|
||||
call_threaded(self._remove_from_library, *args, **kwargs)
|
||||
|
||||
def _remove_from_library(self, *args, **kwargs):
|
||||
selected = self.tab.list.get_multiple_selection()
|
||||
if len(selected) < 1:
|
||||
return
|
||||
args = {}
|
||||
args["audio_id"] = post["id"]
|
||||
args["owner_id"] = self.session.user_id
|
||||
result = self.session.vk.client.audio.delete(**args)
|
||||
if int(result) == 1:
|
||||
output.speak(_("Removed audio from library"))
|
||||
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
|
||||
self.tab.list.remove_item(self.tab.list.get_selected())
|
||||
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
|
||||
errors_detected = 0
|
||||
audios_removed = 0
|
||||
for i in range(0, len(selected)):
|
||||
args = {}
|
||||
args["audio_id"] = audios[i]["id"]
|
||||
args["owner_id"] = self.session.user_id
|
||||
result = self.session.vk.client.audio.delete(**args)
|
||||
if int(result) != 1:
|
||||
errors_dtected = errors_detected + 1
|
||||
else:
|
||||
self.session.db[self.name]["items"].pop(selected[i]-audios_removed)
|
||||
self.tab.list.remove_item(selected[i]-audios_removed)
|
||||
audios_removed = audios_removed + 1
|
||||
if errors_detected == 0:
|
||||
if len(selected) == 1:
|
||||
msg = _("Audio removed.")
|
||||
elif len(selected) > 1 and len(selected) < 5:
|
||||
msg = _("{0} audios were removed.").format(len(selected),)
|
||||
else:
|
||||
msg = _("{audios} audios were removed.").format(audios=len(selected),)
|
||||
output.speak(msg)
|
||||
else:
|
||||
output.speak(_("{0} errors occurred while attempting to remove {1} audios.").format(errors_detected, len(selected)))
|
||||
|
||||
def move_to_album(self, *args, **kwargs):
|
||||
if len(self.session.audio_albums) == 0:
|
||||
return commonMessages.no_audio_albums()
|
||||
post = self.get_post()
|
||||
if post == None:
|
||||
return
|
||||
album = selector.album(_("Select the album where you want to move this song"), self.session)
|
||||
if album.item == None: return
|
||||
id = post["id"]
|
||||
response = self.session.vk.client.audio.add(playlist_id=album.item, audio_id=id, owner_id=post["owner_id"])
|
||||
if response == 1:
|
||||
# Translators: Used when the user has moved an audio to an album.
|
||||
output.speak(_("Moved"))
|
||||
if album.item == None:
|
||||
return
|
||||
call_threaded(self._move_to_album, album.item, *args, **kwargs)
|
||||
|
||||
def _move_to_album(self, album, *args, **kwargs):
|
||||
selected = self.tab.list.get_multiple_selection()
|
||||
if len(selected) < 1:
|
||||
return
|
||||
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
|
||||
errors_detected = 0
|
||||
for i in audios:
|
||||
id = i["id"]
|
||||
try:
|
||||
response = self.session.vk.client.audio.add(playlist_id=album, audio_id=id, owner_id=i["owner_id"])
|
||||
except VkApiError:
|
||||
errors_detected = errors_detected + 1
|
||||
if errors_detected == 0:
|
||||
if len(selected) == 1:
|
||||
msg = _("Audio added to playlist.")
|
||||
elif len(selected) > 1 and len(selected) < 5:
|
||||
msg = _("{0} audios were added to playlist.").format(len(selected),)
|
||||
else:
|
||||
msg = _("{audios} audios were added to playlist.").format(audios=len(selected),)
|
||||
output.speak(msg)
|
||||
else:
|
||||
output.speak(_("{0} errors occurred while attempting to add {1} audios to your playlist.").format(errors_detected, len(selected)))
|
||||
|
||||
|
||||
def get_menu(self):
|
||||
p = self.get_post()
|
||||
@@ -826,7 +826,7 @@ class audioBuffer(feedBuffer):
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move)
|
||||
# if owner_id is the current user, the audio is added to the user's audios.
|
||||
if p["owner_id"] == self.session.user_id:
|
||||
m.library.SetItemLabel(_("&Remove from library"))
|
||||
m.library.SetItemLabel(_("&Remove"))
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library)
|
||||
else:
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
|
||||
@@ -990,7 +990,7 @@ class videoBuffer(feedBuffer):
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move)
|
||||
# if owner_id is the current user, the audio is added to the user's audios.
|
||||
if p["owner_id"] == self.session.user_id:
|
||||
m.library.SetItemLabel(_("&Remove from library"))
|
||||
m.library.SetItemLabel(_("&Remove"))
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library)
|
||||
else:
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
|
||||
@@ -1182,69 +1182,16 @@ class chatBuffer(baseBuffer):
|
||||
wx.Bell()
|
||||
return
|
||||
self.tab.text.SetValue("")
|
||||
call_threaded(self._send_message, text=text)
|
||||
|
||||
def upload_attachments(self, attachments):
|
||||
""" Upload attachments to VK before posting them.
|
||||
Returns attachments formatted as string, as required by VK API.
|
||||
"""
|
||||
local_attachments = ""
|
||||
uploader = upload.VkUpload(self.session.vk.session_object)
|
||||
for i in attachments:
|
||||
if i["from"] == "online":
|
||||
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
|
||||
elif i["from"] == "local" and i["type"] == "photo":
|
||||
photos = i["file"]
|
||||
description = i["description"]
|
||||
r = uploader.photo_messages(photos)
|
||||
id = r[0]["id"]
|
||||
owner_id = r[0]["owner_id"]
|
||||
local_attachments += "photo{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "audio":
|
||||
audio = i["file"]
|
||||
title = "untitled"
|
||||
artist = "unnamed"
|
||||
if "artist" in i:
|
||||
artist = i["artist"]
|
||||
if "title" in i:
|
||||
title = i["title"]
|
||||
r = uploader.audio(audio, title=title, artist=artist)
|
||||
id = r["id"]
|
||||
owner_id = r["owner_id"]
|
||||
local_attachments += "audio{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "voice_message":
|
||||
r = uploader.audio_message(i["file"], peer_id=self.kwargs["peer_id"])
|
||||
id = r["audio_message"]["id"]
|
||||
owner_id = r["audio_message"]["owner_id"]
|
||||
local_attachments += "audio_message{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "document":
|
||||
document = i["file"]
|
||||
title = i["title"]
|
||||
r = uploader.document(document, title=title, message_peer_id=self.kwargs["peer_id"])
|
||||
id = r["doc"]["id"]
|
||||
owner_id = r["doc"]["owner_id"]
|
||||
local_attachments += "doc{0}_{1},".format(owner_id, id)
|
||||
return local_attachments
|
||||
|
||||
def _send_message(self, text, attachments=[]):
|
||||
if hasattr(self, "attachments_to_be_sent") and type(self.attachments_to_be_sent) == list:
|
||||
self.attachments_to_be_sent = self.upload_attachments(self.attachments_to_be_sent)
|
||||
try:
|
||||
# Let's take care about the random_id attribute.
|
||||
# This should be unique per message and should be changed right after the message has been sent.
|
||||
# If the message is tried to be sent twice this random_id should be the same for both copies.
|
||||
# At the moment we just calculate len(text)_user_id, hope that will work.
|
||||
random_id = random.randint(0, 100000)
|
||||
if hasattr(self, "attachments_to_be_sent"):
|
||||
response = self.session.vk.client.messages.send(peer_id=self.kwargs["peer_id"], message=text, attachment=self.attachments_to_be_sent, random_id=random_id)
|
||||
else:
|
||||
response = self.session.vk.client.messages.send(peer_id=self.kwargs["peer_id"], message=text, random_id=random_id)
|
||||
except ValueError as ex:
|
||||
if ex.code == 9:
|
||||
output.speak(_("You have been sending a message that is already sent. Try to update the buffer if you can't see the new message in the history."))
|
||||
finally:
|
||||
if hasattr(self, "attachments_to_be_sent"):
|
||||
del self.attachments_to_be_sent
|
||||
post_arguments = dict(random_id = random.randint(0, 100000), peer_id=self.kwargs["peer_id"])
|
||||
if len(text) > 0:
|
||||
post_arguments.update(message=text)
|
||||
if hasattr(self, "attachments_to_be_sent") and len(self.attachments_to_be_sent) > 0:
|
||||
attachments = self.attachments_to_be_sent[::]
|
||||
else:
|
||||
attachments = []
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="messages", child_endpoint="send", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
|
||||
if hasattr(self, "attachments_to_be_sent"):
|
||||
del self.attachments_to_be_sent
|
||||
|
||||
def __init__(self, unread=False, *args, **kwargs):
|
||||
super(chatBuffer, self).__init__(*args, **kwargs)
|
||||
@@ -1261,7 +1208,11 @@ class chatBuffer(baseBuffer):
|
||||
# We don't need the photos_list attachment, so skip it.
|
||||
if i["type"] == "photos_list":
|
||||
continue
|
||||
attachments.append(add_attachment(i))
|
||||
try:
|
||||
rendered_object = add_attachment(i)
|
||||
except:
|
||||
log.exception("Error parsing the following attachment on chat: %r" % (i,))
|
||||
attachments.append(rendered_object)
|
||||
self.attachments.append(i)
|
||||
self.tab.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_attachment)
|
||||
self.tab.insert_attachments(attachments)
|
||||
@@ -1332,6 +1283,21 @@ class chatBuffer(baseBuffer):
|
||||
|
||||
class peopleBuffer(feedBuffer):
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
user = self.get_post()
|
||||
if "can_post" not in user: # retrieve data if not present in the object.
|
||||
user = self.session.vk.client.users.get(user_ids=user["id"], fields="can_post")[0]
|
||||
if user.get("can_post") == True:
|
||||
user_str = self.session.get_user(user["id"], key="user1")
|
||||
title = _("Post to {user1_nom}'s wall").format(**user_str)
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=user["id"])
|
||||
attachments = []
|
||||
if hasattr(p, "attachments"):
|
||||
attachments = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def create_tab(self, parent):
|
||||
self.tab = home.peopleTab(parent)
|
||||
self.connect_events()
|
||||
@@ -1354,6 +1320,10 @@ class peopleBuffer(feedBuffer):
|
||||
post = self.get_post()
|
||||
if post == None:
|
||||
return
|
||||
if post.get("can_post") == True:
|
||||
self.tab.post.Enable(True)
|
||||
else:
|
||||
self.tab.post.Enable(False)
|
||||
if ("last_seen" in post) == False: return
|
||||
original_date = arrow.get(post["last_seen"]["time"])
|
||||
now = arrow.now()
|
||||
@@ -1392,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)
|
||||
@@ -1425,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
|
||||
|
||||
@@ -1519,9 +1505,9 @@ class requestsBuffer(peopleBuffer):
|
||||
if self.tab.list.get_count() > 0 and num > 0:
|
||||
v = [i for i in self.session.db[self.name]["items"][:num]]
|
||||
v.reverse()
|
||||
[self.insert(i, True) for i in v]
|
||||
[wx.CallAfter(self.insert, i, True) for i in v]
|
||||
else:
|
||||
[self.insert(i) for i in self.session.db[self.name]["items"][:num]]
|
||||
[wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
|
||||
return retrieved
|
||||
|
||||
def accept_friendship(self, *args, **kwargs):
|
||||
@@ -1566,4 +1552,14 @@ class requestsBuffer(peopleBuffer):
|
||||
msg = _("{0} {1} is following you.").format(person["first_name"], person["last_name"])
|
||||
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())
|
||||
self.tab.list.remove_item(self.tab.list.get_selected())
|
||||
|
||||
class notificationBuffer(feedBuffer):
|
||||
|
||||
def create_tab(self, parent):
|
||||
self.tab = home.notificationTab(parent)
|
||||
self.connect_events()
|
||||
self.tab.name = self.name
|
||||
|
||||
def onFocus(self, event, *args, **kwargs):
|
||||
event.Skip()
|
||||
|
@@ -3,6 +3,7 @@ import time
|
||||
import os
|
||||
import webbrowser
|
||||
import subprocess
|
||||
import functools
|
||||
import logging
|
||||
import wx
|
||||
import widgetUtils
|
||||
@@ -13,6 +14,7 @@ import views
|
||||
import config
|
||||
import paths
|
||||
import win32gui
|
||||
from concurrent import futures
|
||||
from vk_api.exceptions import LoginRequired, VkApiError
|
||||
from requests.exceptions import ConnectionError
|
||||
from pubsub import pub
|
||||
@@ -20,7 +22,7 @@ from mysc import restart
|
||||
from mysc.repeating_timer import RepeatingTimer
|
||||
from mysc.thread_utils import call_threaded
|
||||
from mysc import localization
|
||||
from sessionmanager import session, utils, renderers
|
||||
from sessionmanager import session, utils, renderers, sessionManager
|
||||
from wxUI import (mainWindow, commonMessages, menus)
|
||||
from wxUI.dialogs import search as searchDialogs
|
||||
from wxUI.dialogs import creation, timeline
|
||||
@@ -33,6 +35,30 @@ from . import selector
|
||||
|
||||
log = logging.getLogger("controller.main")
|
||||
|
||||
thread_pool_executor = futures.ThreadPoolExecutor(max_workers=1)
|
||||
|
||||
def wx_call_after(target):
|
||||
@functools.wraps(target)
|
||||
def wrapper(self, *args, **kwargs):
|
||||
args = (self,) + args
|
||||
wx.CallAfter(target, *args, **kwargs)
|
||||
return wrapper
|
||||
|
||||
def submit_to_pool_executor(executor):
|
||||
def decorator(target):
|
||||
@functools.wraps(target)
|
||||
def wrapper(*args, **kwargs):
|
||||
result = executor.submit(target, *args, **kwargs)
|
||||
result.add_done_callback(executor_done_call_back)
|
||||
return result
|
||||
return wrapper
|
||||
return decorator
|
||||
|
||||
def executor_done_call_back(future):
|
||||
exception = future.exception()
|
||||
if exception:
|
||||
raise exception
|
||||
|
||||
class Controller(object):
|
||||
|
||||
### utils
|
||||
@@ -67,7 +93,7 @@ class Controller(object):
|
||||
player.setup()
|
||||
self.window = mainWindow.mainWindow()
|
||||
log.debug("Main window created")
|
||||
self.window.change_status(_("Ready"))
|
||||
wx.CallAfter(self.window.change_status, _("Ready"))
|
||||
self.session = session.sessions[list(session.sessions.keys())[0]]
|
||||
self.window.Show()
|
||||
self.connect_pubsub_events()
|
||||
@@ -101,17 +127,18 @@ class Controller(object):
|
||||
pub.sendMessage("create_buffer", buffer_type="videoBuffer", buffer_title=_("My videos"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="me_video", composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"]))
|
||||
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Albums"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="video_albums"))
|
||||
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("People"), kwargs=dict(parent=self.window.tb, name="people"))
|
||||
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Online"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="online_friends", composefunc="render_person", session=self.session, endpoint="getOnline", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen"))
|
||||
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("All friends"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="friends_", composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen"))
|
||||
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Online"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="online_friends", composefunc="render_person", session=self.session, endpoint="getOnline", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen, can_post"))
|
||||
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("All friends"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="friends_", composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen, can_post"))
|
||||
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Friendship requests"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="requests"))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Pending requests"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("I follow"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Subscribers"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="subscribers", composefunc="render_person", session=self.session, count=1000, need_viewed=1))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Pending requests"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000, fields="can_post"))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("I follow"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1, fields="can_post"))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Subscribers"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="subscribers", composefunc="render_person", session=self.session, count=1000, need_viewed=1, fields="can_post"))
|
||||
# pub.sendMessage("create_buffer", buffer_type="notificationBuffer", buffer_title=_("Notifications"), parent_tab=None, loadable=False, kwargs=dict(parent=self.window.tb, name="notifications", composefunc="render_notification", session=self.session, endpoint="get", parent_endpoint="notifications", count=100, filters="wall,mentions,comments,likes,reposted,followers,friends"))
|
||||
pub.sendMessage("create_buffer", buffer_type="documentBuffer", buffer_title=_("Documents"), parent_tab=None, loadable=True, kwargs=dict(parent=self.window.tb, name="documents", composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs"))
|
||||
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Groups"), kwargs=dict(parent=self.window.tb, name="communities"))
|
||||
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Chats"), kwargs=dict(parent=self.window.tb, name="chats"))
|
||||
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Timelines"), kwargs=dict(parent=self.window.tb, name="timelines"))
|
||||
self.window.realize()
|
||||
wx.CallAfter(self.window.realize)
|
||||
self.repeatedUpdate = RepeatingTimer(120, self.update_all_buffers)
|
||||
self.repeatedUpdate.start()
|
||||
|
||||
@@ -151,8 +178,7 @@ class Controller(object):
|
||||
if ex.code == 6:
|
||||
log.exception("Something went wrong when getting messages. Waiting a second to retry")
|
||||
for i in msgs["items"]:
|
||||
call_threaded(self.chat_from_id, i["last_message"]["peer_id"], setfocus=False, unread=False)
|
||||
time.sleep(0.6)
|
||||
self.chat_from_id(i["last_message"]["peer_id"], setfocus=False, unread=False)
|
||||
|
||||
def get_audio_albums(self, user_id=None, create_buffers=True, force_action=False):
|
||||
if self.session.settings["load_at_startup"]["audio_albums"] == False and force_action == False:
|
||||
@@ -166,8 +192,7 @@ class Controller(object):
|
||||
self.session.audio_albums = albums
|
||||
if create_buffers:
|
||||
for i in albums:
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="audioAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="audio_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id, album_id=i["id"]))
|
||||
time.sleep(0.6)
|
||||
pub.sendMessage("create_buffer", buffer_type="audioAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="audio_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id, album_id=i["id"]))
|
||||
|
||||
def get_video_albums(self, user_id=None, create_buffers=True, force_action=False):
|
||||
if self.session.settings["load_at_startup"]["video_albums"] == False and force_action == False:
|
||||
@@ -177,8 +202,7 @@ class Controller(object):
|
||||
self.session.video_albums = albums["items"]
|
||||
if create_buffers:
|
||||
for i in albums["items"]:
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="videoAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="video_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_video_album".format(i["id"],), composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], user_id=user_id, album_id=i["id"]))
|
||||
time.sleep(0.15)
|
||||
pub.sendMessage("create_buffer", buffer_type="videoAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="video_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_video_album".format(i["id"],), composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], user_id=user_id, album_id=i["id"]))
|
||||
|
||||
def get_communities(self, user_id=None, create_buffers=True, force_action=False):
|
||||
if self.session.settings["vk"]["invited_to_group"] == False:
|
||||
@@ -206,20 +230,20 @@ class Controller(object):
|
||||
if create_buffers:
|
||||
for i in self.session.groups:
|
||||
self.session.db["group_info"][i["id"]*-1] = i
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="communityBuffer", buffer_title=i["name"], parent_tab="communities", loadable=True, get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_community".format(i["id"],), composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"]))
|
||||
time.sleep(0.15)
|
||||
pub.sendMessage("create_buffer", buffer_type="communityBuffer", buffer_title=i["name"], parent_tab="communities", loadable=True, get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_community".format(i["id"],), composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"]))
|
||||
|
||||
|
||||
def login(self):
|
||||
self.window.change_status(_("Logging in VK"))
|
||||
wx.CallAfter(self.window.change_status, _("Logging in VK"))
|
||||
self.session.login()
|
||||
self.window.change_status(_("Ready"))
|
||||
wx.CallAfter(self.window.change_status, _("Ready"))
|
||||
for i in self.buffers:
|
||||
if hasattr(i, "get_items"):
|
||||
# Translators: {0} will be replaced with the name of a buffer.
|
||||
self.window.change_status(_("Loading items for {0}").format(i.name,))
|
||||
wx.CallAfter(self.window.change_status, _("Loading items for {0}").format(i.name,))
|
||||
i.get_items()
|
||||
self.window.change_status(_("Ready"))
|
||||
self.create_unread_messages()
|
||||
wx.CallAfter(self.window.change_status, _("Ready"))
|
||||
call_threaded(self.create_unread_messages)
|
||||
self.status_setter = RepeatingTimer(280, self.set_online)
|
||||
self.status_setter.start()
|
||||
self.set_online(notify=True)
|
||||
@@ -281,6 +305,7 @@ class Controller(object):
|
||||
def connect_pubsub_events(self):
|
||||
log.debug("Connecting events to responses...")
|
||||
pub.subscribe(self.in_post, "posted")
|
||||
pub.subscribe(self.post_failed, "postFailed")
|
||||
pub.subscribe(self.download, "download-file")
|
||||
pub.subscribe(self.view_post, "open-post")
|
||||
pub.subscribe(self.update_status_bar, "update-status-bar")
|
||||
@@ -309,15 +334,64 @@ class Controller(object):
|
||||
pub.unsubscribe(self.notify, "notify")
|
||||
pub.subscribe(self.create_timeline, "create-timeline")
|
||||
|
||||
def in_post(self, buffer):
|
||||
""" This event is triggered whenever an user requires an update in their buffers. For example after sending a post successfully.
|
||||
The function updates the main newsfeed buffer, and the buffer from where the post was sent.
|
||||
@buffer str: name of the buffer where the post has been generated.
|
||||
"""
|
||||
buffer = self.search(buffer)
|
||||
buffer.get_items()
|
||||
buffer = self.search("home_timeline")
|
||||
buffer.get_items()
|
||||
def in_post(self, from_buffer=None):
|
||||
if from_buffer != None and "_messages" not in from_buffer:
|
||||
log.debug("Post received in buffer %s, updating... " % (from_buffer,))
|
||||
buffer = self.search(from_buffer)
|
||||
buffer.get_items()
|
||||
|
||||
def post_failed(self, parent_endpoint, child_endpoint, from_buffer=None, attachments_list=[], post_arguments={}):
|
||||
""" Function to be called when the post (using the pubsub method) fails. It takes the same params than post() and use the parent and child endpoints to call the appropiate dialogs. """
|
||||
# Ask the user if he/she wants to attempt to post the same again.
|
||||
msgdialog = commonMessages.post_failed()
|
||||
if msgdialog != widgetUtils.YES: # Cancelled.
|
||||
return
|
||||
# Let's check which kind of post has failed, and do something about it.
|
||||
if parent_endpoint == "wall":
|
||||
if child_endpoint == "post": # A wall post has failed, so let's create it in a dialogue.
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Write your post"), message="", text=post_arguments.get("message")))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
post_arguments.update(privacy=p.privacy, message=p.text)
|
||||
if hasattr(p, "attachments"):
|
||||
attachments_list = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||
elif child_endpoint == "repost": # repost
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Repost"), message="", text=post_arguments.get("message"), mode="comment"))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
post_arguments.update(message=p.text)
|
||||
if hasattr(p, "attachments"):
|
||||
attachments_list = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||
elif child_endpoint == "createComment": # comments.
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Add a comment"), message="", text=post_arguments.get("message"), mode="comment"))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
post_arguments.update(message=p.text)
|
||||
if hasattr(p, "attachments"):
|
||||
attachments_list = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||
elif parent_endpoint == "board": # topic creation and comments.
|
||||
if child_endpoint == "addTopic":
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createTopicDialog(title=_("Create topic"), message="", topic_title=post_arguments.get("title"), text=post_arguments.get("text")))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
post_arguments.update(title=p.view.title.GetValue(), text=p.text)
|
||||
if hasattr(p, "attachments"):
|
||||
attachments_list = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||
elif child_endpoint == "createComment": # topic comments.
|
||||
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Add a comment to the topic"), message="", text=post_arguments.get("message"), mode="comment"))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
post_arguments.update(message=p.text)
|
||||
if hasattr(p, "attachments"):
|
||||
attachments_list = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||
elif parent_endpoint == "messages": # Private messages
|
||||
if child_endpoint == "send":
|
||||
buffer = self.search(from_buffer)
|
||||
buffer_window = self.window.search(buffer.name)
|
||||
self.window.change_buffer(buffer_window)
|
||||
buffer.tab.text.SetValue(post_arguments.get("message"))
|
||||
buffer.tab.text.SetFocus()
|
||||
buffer.attachments_to_be_sent = attachments_list
|
||||
|
||||
def download(self, url, filename):
|
||||
""" Download a file to te current user's computer.
|
||||
@@ -340,7 +414,7 @@ class Controller(object):
|
||||
""" Update the status bar present in the main Window.
|
||||
@ status str: Text to be placed in the status bar.
|
||||
"""
|
||||
self.window.change_status(status)
|
||||
wx.CallAfter(self.window.change_status, status)
|
||||
|
||||
def chat_from_id(self, user_id, setfocus=True, unread=False):
|
||||
""" Create a conversation buffer for.
|
||||
@@ -363,7 +437,7 @@ class Controller(object):
|
||||
elif user_id > 2000000000:
|
||||
chat = self.session.vk.client.messages.getChat(chat_id=user_id-2000000000)
|
||||
name = chat["title"]
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="chatBuffer", buffer_title=name, parent_tab="chats", get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="render_message", parent_endpoint="messages", endpoint="getHistory", session=self.session, unread=unread, count=200, peer_id=user_id, rev=0, extended=True, fields="id, user_id, date, read_state, out, body, attachments, deleted"))
|
||||
pub.sendMessage("create_buffer", buffer_type="chatBuffer", buffer_title=name, parent_tab="chats", get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="render_message", parent_endpoint="messages", endpoint="getHistory", session=self.session, unread=unread, count=self.session.settings["buffers"]["count_for_chat_buffers"], peer_id=user_id, rev=0, extended=True, fields="id, user_id, date, read_state, out, body, attachments, deleted"))
|
||||
# if setfocus:
|
||||
# pos = self.window.search(buffer.name)
|
||||
# self.window.change_buffer(pos)
|
||||
@@ -390,15 +464,14 @@ class Controller(object):
|
||||
p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor())
|
||||
|
||||
def user_online(self, event):
|
||||
""" Sends a notification of an user connecting to VK.
|
||||
""" Add user to the online buffer and Send a notification of an user connecting to VK.
|
||||
@ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module.
|
||||
"""
|
||||
if self.session.settings["chat"]["notify_online"] == False:
|
||||
return
|
||||
user_name = self.session.get_user(event.user_id)
|
||||
msg = _("{user1_nom} is online.").format(**user_name)
|
||||
sound = "friend_online.ogg"
|
||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
||||
if self.session.settings["chat"]["notify_online"] == True:
|
||||
user_name = self.session.get_user(event.user_id)
|
||||
msg = _("{user1_nom} is online.").format(**user_name)
|
||||
sound = "friend_online.ogg"
|
||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
||||
online_buffer = self.search("online_friends")
|
||||
user = None
|
||||
for i in self.session.db["friends_"]["items"]:
|
||||
@@ -408,19 +481,18 @@ class Controller(object):
|
||||
break
|
||||
if user == None:
|
||||
log.exception("Getting user manually...")
|
||||
user = self.session.vk.client.users.get(user_ids=event.user_id, fields="last_seen")[0]
|
||||
user = self.session.vk.client.users.get(user_ids=event.user_id, fields="last_seen, can_post")[0]
|
||||
wx.CallAfter(online_buffer.add_person, user)
|
||||
|
||||
def user_offline(self, event):
|
||||
""" Sends a notification of an user logging off in VK.
|
||||
""" Remove user from the online buffer and Send a notification of an user logging off in VK.
|
||||
@ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module.
|
||||
"""
|
||||
if self.session.settings["chat"]["notify_offline"] == False:
|
||||
return
|
||||
user_name = self.session.get_user(event.user_id)
|
||||
msg = _("{user1_nom} is offline.").format(**user_name)
|
||||
sound = "friend_offline.ogg"
|
||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
||||
if self.session.settings["chat"]["notify_offline"] == True:
|
||||
user_name = self.session.get_user(event.user_id)
|
||||
msg = _("{user1_nom} is offline.").format(**user_name)
|
||||
sound = "friend_offline.ogg"
|
||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
||||
online_friends = self.search("online_friends")
|
||||
wx.CallAfter(online_friends.remove_person, event.user_id)
|
||||
|
||||
@@ -449,7 +521,7 @@ class Controller(object):
|
||||
if hasattr(self, "longpoll"):
|
||||
del self.longpoll
|
||||
self.create_longpoll_thread(notify=True)
|
||||
|
||||
@wx_call_after
|
||||
def create_buffer(self, buffer_type="baseBuffer", buffer_title="", parent_tab=None, loadable=False, get_items=False, kwargs={}):
|
||||
""" Create and insert a buffer in the specified place.
|
||||
@buffer_type str: name of the buffer type to be created. This should be a class in the buffers.py module.
|
||||
@@ -533,6 +605,10 @@ class Controller(object):
|
||||
buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_id,), composefunc="render_status", session=self.session, create_tab=False, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=user_id)
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
name_ = _("{user1_nom}'s posts").format(**user)
|
||||
elif buffer_type == "video":
|
||||
buffer = buffers.videoBuffer(parent=self.window.tb, name="{0}_video".format(user_id,), composefunc="render_video", session=self.session, create_tab=False, endpoint="get", parent_endpoint="video", owner_id=user_id, count=self.session.settings["buffers"]["count_for_video_buffers"])
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
name_ = _("{user1_nom}'s videos").format(**user)
|
||||
elif buffer_type == "friends":
|
||||
buffer = buffers.peopleBuffer(parent=self.window.tb, name="friends_{0}".format(user_id,), composefunc="render_person", session=self.session, create_tab=False, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen", user_id=user_id)
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
@@ -553,6 +629,8 @@ 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.manage_accounts, menuitem=self.window.accounts)
|
||||
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)
|
||||
@@ -652,10 +730,23 @@ 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 manage_accounts(self, *args, **kwargs):
|
||||
accounts = sessionManager.sessionManagerController(starting=False)
|
||||
accounts.view.get_response()
|
||||
if hasattr(accounts, "modified"):
|
||||
restart_msg = commonMessages.restart_program()
|
||||
if restart_msg == widgetUtils.YES:
|
||||
restart.restart_program()
|
||||
|
||||
def open_logs(self, *args, **kwargs):
|
||||
subprocess.call(["explorer", paths.logs_path()])
|
||||
|
||||
@@ -778,13 +869,16 @@ class Controller(object):
|
||||
self.search("me_audio").play_all()
|
||||
|
||||
def menu_volume_down(self, *args, **kwargs):
|
||||
player.player.volume = player.player.volume-2
|
||||
if player.player != None:
|
||||
player.player.volume = player.player.volume-2
|
||||
|
||||
def menu_volume_up(self, *args, **kwargs):
|
||||
player.player.volume = player.player.volume+2
|
||||
if player.player != None:
|
||||
player.player.volume = player.player.volume+2
|
||||
|
||||
def menu_mute(self, *args, **kwargs):
|
||||
player.player.volume = 0
|
||||
if player.player != None:
|
||||
player.player.volume = 0
|
||||
|
||||
def seek_left(self, *args, **kwargs):
|
||||
pub.sendMessage("seek", ms=-500000)
|
||||
@@ -903,7 +997,7 @@ class Controller(object):
|
||||
commonMessages.community_no_items()
|
||||
return
|
||||
new_name = current_buffer.name+"_audios"
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="audioBuffer", buffer_title=_("Audios"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=current_buffer.kwargs["owner_id"]))
|
||||
pub.sendMessage("create_buffer", buffer_type="audioBuffer", buffer_title=_("Audios"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=current_buffer.kwargs["owner_id"]))
|
||||
|
||||
def load_community_videos(self, *args, **kwargs):
|
||||
""" Load community videos if they are not loaded already."""
|
||||
@@ -916,7 +1010,7 @@ class Controller(object):
|
||||
commonMessages.community_no_items()
|
||||
return
|
||||
new_name = current_buffer.name+"_videos"
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="videoBuffer", buffer_title=_("Videos"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], owner_id=current_buffer.kwargs["owner_id"]))
|
||||
pub.sendMessage("create_buffer", buffer_type="videoBuffer", buffer_title=_("Videos"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], owner_id=current_buffer.kwargs["owner_id"]))
|
||||
|
||||
def load_community_topics(self, *args, **kwargs):
|
||||
""" Load community topics."""
|
||||
@@ -929,7 +1023,7 @@ class Controller(object):
|
||||
commonMessages.community_no_items()
|
||||
return
|
||||
new_name = current_buffer.name+"_topics"
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="topicBuffer", buffer_title=_("Topics"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_topic", session=self.session, endpoint="getTopics", parent_endpoint="board", count=100, group_id=-1*current_buffer.kwargs["owner_id"], extended=1))
|
||||
pub.sendMessage("create_buffer", buffer_type="topicBuffer", buffer_title=_("Topics"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_topic", session=self.session, endpoint="getTopics", parent_endpoint="board", count=100, group_id=-1*current_buffer.kwargs["owner_id"], extended=1))
|
||||
|
||||
def load_community_documents(self, *args, **kwargs):
|
||||
current_buffer = self.get_current_buffer()
|
||||
@@ -941,7 +1035,7 @@ class Controller(object):
|
||||
commonMessages.community_no_items()
|
||||
return
|
||||
new_name = current_buffer.name+"_documents"
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="documentCommunityBuffer", buffer_title=_("Documents"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs", owner_id=current_buffer.kwargs["owner_id"]))
|
||||
pub.sendMessage("create_buffer", buffer_type="documentCommunityBuffer", buffer_title=_("Documents"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs", owner_id=current_buffer.kwargs["owner_id"]))
|
||||
|
||||
def load_community_buffers(self, *args, **kwargs):
|
||||
""" Load all community buffers regardless of the setting present in optional buffers tab of the preferences dialog."""
|
||||
|
@@ -5,7 +5,7 @@ CRCCheck on
|
||||
ManifestSupportedOS all
|
||||
XPStyle on
|
||||
Name "Socializer"
|
||||
OutFile "socializer_0.22_setup.exe"
|
||||
OutFile "socializer_0.23_setup.exe"
|
||||
InstallDir "$PROGRAMFILES\socializer"
|
||||
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "InstallLocation"
|
||||
RequestExecutionLevel admin
|
||||
@@ -14,10 +14,10 @@ SetCompressor /solid lzma
|
||||
SetDatablockOptimize on
|
||||
VIAddVersionKey ProductName "Socializer"
|
||||
VIAddVersionKey LegalCopyright "Copyright 2019 Manuel Cortez."
|
||||
VIAddVersionKey ProductVersion "0.22"
|
||||
VIAddVersionKey FileVersion "0.22"
|
||||
VIProductVersion "0.22.0.0"
|
||||
VIFileVersion "0.22.0.0"
|
||||
VIAddVersionKey ProductVersion "0.23"
|
||||
VIAddVersionKey FileVersion "0.23"
|
||||
VIProductVersion "0.23.0.0"
|
||||
VIFileVersion "0.23.0.0"
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
var StartMenuFolder
|
||||
@@ -50,7 +50,7 @@ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "Publisher" "Manuel Cortez"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayVersion" "0.22"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayVersion" "0.23"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "URLInfoAbout" "http://socializer.su"
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMajor" 0
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMinor" 19
|
||||
|
@@ -1,5 +1,6 @@
|
||||
from .attach import *
|
||||
from . audioRecorder import *
|
||||
from . blacklist import *
|
||||
from .configuration import *
|
||||
from .postCreation import *
|
||||
from .postDisplayer import *
|
||||
|
31
src/interactors/blacklist.py
Normal file
31
src/interactors/blacklist.py
Normal file
@@ -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)
|
@@ -42,8 +42,9 @@ class configurationInteractor(base.baseInteractor):
|
||||
self.on_save_settings()
|
||||
|
||||
def on_save_settings(self, *args, **kwargs):
|
||||
self.presenter.update_setting(section="buffers", setting="count_for_wall_buffers", value=self.view.get_value("general", "wall_buffer_count"))
|
||||
self.presenter.update_setting(section="buffers", setting="count_for_video_buffers", value=self.view.get_value("general", "video_buffers_count"))
|
||||
self.presenter.update_setting(section="buffers", setting="count_for_wall_buffers", value=self.view.get_value("buffers", "wall_buffer_count"))
|
||||
self.presenter.update_setting(section="buffers", setting="count_for_video_buffers", value=self.view.get_value("buffers", "video_buffers_count"))
|
||||
self.presenter.update_setting(section="buffers", setting="count_for_chat_buffers", value=self.view.get_value("buffers", "chat_buffers_count"))
|
||||
self.presenter.update_setting(section="general", setting="load_images", value=self.view.get_value("general", "load_images"))
|
||||
update_channel = self.presenter.get_update_channel_type(self.view.get_value("general", "update_channel"))
|
||||
if update_channel != self.presenter.session.settings["general"]["update_channel"]:
|
||||
|
@@ -50,7 +50,9 @@ class displayPostInteractor(base.baseInteractor):
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(displayPostInteractor, self).install(*args, **kwargs)
|
||||
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_show_comment)
|
||||
if hasattr(self.view, "comments"):
|
||||
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_show_comment)
|
||||
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_comment_changed)
|
||||
self.view.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_open_attachment)
|
||||
widgetUtils.connect_event(self.view.like, widgetUtils.BUTTON_PRESSED, self.on_like)
|
||||
widgetUtils.connect_event(self.view.comment, widgetUtils.BUTTON_PRESSED, self.on_add_comment)
|
||||
@@ -76,7 +78,6 @@ class displayPostInteractor(base.baseInteractor):
|
||||
pub.subscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls")
|
||||
pub.subscribe(self.post_deleted, self.modulename+"_post_deleted")
|
||||
pub.subscribe(self.clean_list, self.modulename+"_clean_list")
|
||||
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_comment_changed)
|
||||
|
||||
def uninstall(self):
|
||||
super(displayPostInteractor, self).uninstall()
|
||||
@@ -103,7 +104,7 @@ class displayPostInteractor(base.baseInteractor):
|
||||
self.presenter.post_repost()
|
||||
|
||||
def on_reply(self, *args, **kwargs):
|
||||
if hasattr(self.view, "repost") or not hasattr(self, "post_view"):
|
||||
if hasattr(self.view, "comments") and (hasattr(self.view, "repost") or not hasattr(self, "post_view")):
|
||||
comment = self.view.comments.get_selected()
|
||||
self.presenter.reply(comment)
|
||||
else:
|
||||
|
@@ -14,6 +14,8 @@ formatter = logging.Formatter(MESSAGE_FORMAT, datefmt=DATE_FORMAT)
|
||||
|
||||
requests_log = logging.getLogger("requests")
|
||||
requests_log.setLevel(logging.WARNING)
|
||||
urllib3 = logging.getLogger("urllib3")
|
||||
urllib3.setLevel(logging.WARNING)
|
||||
|
||||
logger = logging.getLogger()
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
@@ -52,6 +52,7 @@ def setup():
|
||||
|
||||
log.debug("Created Application mainloop object")
|
||||
sm = sessionManager.sessionManagerController()
|
||||
sm.show()
|
||||
del sm
|
||||
r = mainController.Controller()
|
||||
call_threaded(r.login)
|
||||
|
@@ -13,6 +13,7 @@
|
||||
"""
|
||||
from .attach import *
|
||||
from .audioRecorder import *
|
||||
from .blacklist import *
|
||||
from .createPosts import *
|
||||
from .displayPosts import *
|
||||
from .configuration import *
|
||||
|
@@ -8,6 +8,7 @@ import logging
|
||||
import interactors
|
||||
import views
|
||||
from mutagen.id3 import ID3
|
||||
from mutagen.id3._util import ID3NoHeaderError
|
||||
from sessionmanager.utils import seconds_to_string
|
||||
from . import audioRecorder, base
|
||||
|
||||
@@ -24,7 +25,7 @@ class attachPresenter(base.basePresenter):
|
||||
def __init__(self, session, view, interactor, voice_messages=False):
|
||||
""" Constructor.
|
||||
@ session sessionmanager.session object: an object capable of calling all VK methods and accessing the session database.
|
||||
@voice_messages bool: If True, will add a button for sending voice messages. Functionality for this button has not been added yet.
|
||||
@voice_messages bool: If True, will add a button for sending voice messages.
|
||||
"""
|
||||
super(attachPresenter, self).__init__(view=view, interactor=interactor, modulename="attach")
|
||||
self.session = session
|
||||
@@ -33,7 +34,7 @@ class attachPresenter(base.basePresenter):
|
||||
self.run()
|
||||
|
||||
def upload_image(self, image, description):
|
||||
""" allows uploading an image from the computer.
|
||||
""" allows uploading an image from the computer. Description will be used when posting to VK.
|
||||
"""
|
||||
imageInfo = {"type": "photo", "file": image, "description": description, "from": "local"}
|
||||
self.attachments.append(imageInfo)
|
||||
@@ -47,15 +48,19 @@ class attachPresenter(base.basePresenter):
|
||||
if audio != None:
|
||||
# Define data structure for this attachment, as will be required by VK API later.
|
||||
# Let's extract the ID3 tags to show them in the list and send them to VK, too.
|
||||
audio_tags = ID3(audio)
|
||||
if "TIT2" in audio_tags:
|
||||
title = audio_tags["TIT2"].text[0]
|
||||
else:
|
||||
title = _("Untitled")
|
||||
if "TPE1" in audio_tags:
|
||||
artist = audio_tags["TPE1"].text[0]
|
||||
else:
|
||||
try:
|
||||
audio_tags = ID3(audio)
|
||||
if "TIT2" in audio_tags:
|
||||
title = audio_tags["TIT2"].text[0]
|
||||
else:
|
||||
title = _("Untitled")
|
||||
if "TPE1" in audio_tags:
|
||||
artist = audio_tags["TPE1"].text[0]
|
||||
else:
|
||||
artist = _("Unknown artist")
|
||||
except ID3NoHeaderError: # File doesn't include ID3 tags so let's assume unknown artist.
|
||||
artist = _("Unknown artist")
|
||||
title = os.path.basename(audio).replace(".mp3", "")
|
||||
audioInfo = {"type": "audio", "file": audio, "from": "local", "title": title, "artist": artist}
|
||||
self.attachments.append(audioInfo)
|
||||
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.
|
||||
|
30
src/presenters/blacklist.py
Normal file
30
src/presenters/blacklist.py
Normal file
@@ -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
|
@@ -51,11 +51,13 @@ class configurationPresenter(base.basePresenter):
|
||||
id = self.codes.index(config.app["app-settings"]["language"])
|
||||
self.send_message("create_tab", tab="general", arglist=dict(languages=langs))
|
||||
self.send_message("set_language", language=id)
|
||||
self.send_message("set", tab="general", setting="wall_buffer_count", value=self.session.settings["buffers"]["count_for_wall_buffers"])
|
||||
self.send_message("set", tab="general", setting="video_buffers_count", value=self.session.settings["buffers"]["count_for_video_buffers"])
|
||||
self.send_message("set", tab="general", setting="load_images", value=self.session.settings["general"]["load_images"])
|
||||
self.send_message("set", tab="general", setting="use_proxy", value=config.app["app-settings"]["use_proxy"])
|
||||
self.send_message("set", tab="general", setting="update_channel", value=self.get_update_channel_label(self.session.settings["general"]["update_channel"]))
|
||||
self.send_message("create_tab", tab="buffers")
|
||||
self.send_message("set", tab="buffers", setting="wall_buffer_count", value=self.session.settings["buffers"]["count_for_wall_buffers"])
|
||||
self.send_message("set", tab="buffers", setting="video_buffers_count", value=self.session.settings["buffers"]["count_for_video_buffers"])
|
||||
self.send_message("set", tab="buffers", setting="chat_buffers_count", value=self.session.settings["buffers"]["count_for_chat_buffers"])
|
||||
self.send_message("create_tab", tab="chat")
|
||||
self.send_message("set", tab="chat", setting="notify_online", value=self.session.settings["chat"]["notify_online"])
|
||||
self.send_message("set", tab="chat", setting="notify_offline", value=self.session.settings["chat"]["notify_offline"])
|
||||
|
@@ -58,13 +58,25 @@ class displayPostPresenter(base.basePresenter):
|
||||
self.worker = threading.Thread(target=self.load_all_components)
|
||||
self.worker.finished = threading.Event()
|
||||
self.worker.start()
|
||||
# connect here the pubsub event for successful posting of comments.
|
||||
pub.subscribe(self.posted, "posted")
|
||||
self.run()
|
||||
pub.unsubscribe(self.posted, "posted")
|
||||
|
||||
def posted(self, from_buffer=None):
|
||||
self.clear_comments_list()
|
||||
|
||||
def get_comments(self):
|
||||
""" Get comments and insert them in a list."""
|
||||
user = self.post[self.user_identifier]
|
||||
id = self.post[self.post_identifier]
|
||||
self.comments = self.session.vk.client.wall.getComments(owner_id=user, post_id=id, need_likes=1, count=100, extended=1, preview_length=0, thread_items_count=10)
|
||||
comments_data = self.session.vk.client.wall.getComments(owner_id=user, post_id=id, need_likes=1, count=100, extended=1, preview_length=0, thread_items_count=10)
|
||||
self.comments = dict(items=[], profiles=comments_data["profiles"])
|
||||
for i in comments_data["items"]:
|
||||
self.comments["items"].append(i)
|
||||
if i.get("thread") != None and i["thread"].get("count") > 0:
|
||||
for newI in i["thread"]["items"]:
|
||||
self.comments["items"].append(newI)
|
||||
comments_ = []
|
||||
# Save profiles in session local storage for a future usage.
|
||||
# Although community objects are returned here, we should not add those because their names are changed.
|
||||
@@ -88,8 +100,7 @@ class displayPostPresenter(base.basePresenter):
|
||||
original_date = arrow.get(i["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
likes = str(i["likes"]["count"])
|
||||
replies = str(i["thread"]["count"])
|
||||
comments_.append((from_, text, created_at, likes, replies))
|
||||
comments_.append((from_, text, created_at, likes))
|
||||
self.send_message("add_items", control="comments", items=comments_)
|
||||
|
||||
def get_post_information(self):
|
||||
@@ -251,8 +262,11 @@ class displayPostPresenter(base.basePresenter):
|
||||
object_id = "wall{0}_{1}".format(self.post[self.user_identifier], self.post[self.post_identifier])
|
||||
p = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Repost"), message=_("Add your comment here"), text="", mode="comment"))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
msg = p.text
|
||||
self.session.vk.client.wall.repost(object=object_id, message=msg)
|
||||
post_arguments = dict(object=object_id, message=p.text)
|
||||
attachments = []
|
||||
if hasattr(p, "attachments"):
|
||||
attachments = p.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="repost", attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def get_likes(self):
|
||||
self.send_message("set_label", control="likes", label=_("{0} people like this").format(self.post["likes"]["count"],))
|
||||
@@ -265,92 +279,22 @@ class displayPostPresenter(base.basePresenter):
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
owner_id = self.post[self.user_identifier]
|
||||
post_id = self.post[self.post_identifier]
|
||||
call_threaded(self.do_last, comment, owner_id=owner_id, post_id=post_id)
|
||||
|
||||
def do_last(self, comment, **kwargs):
|
||||
msg = comment.text
|
||||
attachments = ""
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = self.upload_attachments(comment.attachments)
|
||||
urls = utils.find_urls_in_text(msg)
|
||||
if len(urls) != 0:
|
||||
if len(attachments) == 0: attachments = urls[0]
|
||||
else: attachments += urls[0]
|
||||
msg = msg.replace(urls[0], "")
|
||||
if msg != "":
|
||||
kwargs.update(message=msg)
|
||||
if attachments != "":
|
||||
kwargs.update(attachments=attachments)
|
||||
if "message" not in kwargs and "attachments" not in kwargs:
|
||||
return # No comment made here.
|
||||
try:
|
||||
result = self.session.vk.client.wall.createComment(**kwargs)
|
||||
comment_object = self.session.vk.client.wall.getComment(comment_id=result["comment_id"], owner_id=kwargs["owner_id"])["items"][0]
|
||||
from_ = self.session.get_user(comment_object["from_id"])
|
||||
if "reply_to_user" in comment_object:
|
||||
extra_info = self.session.get_user(comment_object["reply_to_user"], "user2")
|
||||
extra_info.update(from_)
|
||||
from_ = _("{user1_nom} > {user2_nom}").format(**extra_info)
|
||||
else:
|
||||
from_ = from_["user1_nom"]
|
||||
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
|
||||
fixed_text = utils.clean_text(comment_object["text"])
|
||||
if len(fixed_text) > 140:
|
||||
text = fixed_text[:141]
|
||||
else:
|
||||
text = fixed_text
|
||||
original_date = arrow.get(comment_object["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
likes = str(comment_object["likes"]["count"])
|
||||
replies = ""
|
||||
item = (from_, text, created_at, likes, replies)
|
||||
if hasattr(self, "comments"):
|
||||
self.comments["items"].append(comment_object)
|
||||
else:
|
||||
if "items" not in self.post["thread"]:
|
||||
self.post["thread"]["items"] = []
|
||||
self.post["thread"]["items"].append(comment_object)
|
||||
self.send_message("add_items", control="comments", items=[item])
|
||||
output.speak(_("You've posted a comment"))
|
||||
except IndexError as msg:
|
||||
log.error(msg)
|
||||
|
||||
def upload_attachments(self, attachments):
|
||||
""" Upload attachments to VK before posting them.
|
||||
Returns attachments formatted as string, as required by VK API.
|
||||
Currently this function only supports photos and audios."""
|
||||
# To do: Check the caption and description fields for this kind of attachments.
|
||||
local_attachments = ""
|
||||
uploader = upload.VkUpload(self.session.vk.session_object)
|
||||
for i in attachments:
|
||||
if i["from"] == "online":
|
||||
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
|
||||
elif i["from"] == "local" and i["type"] == "photo":
|
||||
photos = i["file"]
|
||||
description = i["description"]
|
||||
r = uploader.photo_wall(photos, caption=description)
|
||||
id = r[0]["id"]
|
||||
owner_id = r[0]["owner_id"]
|
||||
local_attachments += "photo{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "audio":
|
||||
audio = i["file"]
|
||||
title = "untitled"
|
||||
artist = "unnamed"
|
||||
if "artist" in i:
|
||||
artist = i["artist"]
|
||||
if "title" in i:
|
||||
title = i["title"]
|
||||
r = uploader.audio(audio, title=title, artist=artist)
|
||||
id = r["id"]
|
||||
owner_id = r["owner_id"]
|
||||
local_attachments += "audio{0}_{1},".format(owner_id, id)
|
||||
return local_attachments
|
||||
post_arguments=dict(message=comment.text, owner_id=owner_id, post_id=post_id)
|
||||
attachments = []
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = comment.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def reply(self, comment):
|
||||
c = self.comments["items"][comment]
|
||||
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Reply to {user1_nom}").format(**self.session.get_user(c["from_id"])), message="", text="", mode="comment"))
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
call_threaded(self.do_last, comment, owner_id=c["owner_id"], reply_to_comment=c["id"], post_id=c["post_id"], reply_to_user=c["owner_id"])
|
||||
post_id = self.post[self.post_identifier]
|
||||
post_arguments=dict(message=comment.text, owner_id=c["owner_id"], reply_to_comment=c["id"], post_id=c["post_id"], reply_to_user=c["owner_id"])
|
||||
attachments = []
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = comment.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def show_comment(self, comment_index):
|
||||
from . import comment
|
||||
@@ -419,7 +363,7 @@ class displayPostPresenter(base.basePresenter):
|
||||
|
||||
def show_likes(self):
|
||||
""" show likes for the specified post."""
|
||||
data = dict(type="post", owner_id=self.post[self.user_identifier], item_id=self.post["id"], extended=True, count=1000, skip_own=True)
|
||||
data = dict(type="post", owner_id=self.post[self.user_identifier], item_id=self.post["id"], extended=True, count=100, skip_own=True)
|
||||
result = self.session.vk.client.likes.getList(**data)
|
||||
if result["count"] > 0:
|
||||
post = {"source_id": self.post[self.user_identifier], "friends": {"items": result["items"]}}
|
||||
|
@@ -5,6 +5,7 @@ import languageHandler
|
||||
import views
|
||||
import interactors
|
||||
import logging
|
||||
from pubsub import pub
|
||||
from sessionmanager import renderers, utils # We'll use some functions from there
|
||||
from mysc.thread_utils import call_threaded
|
||||
from presenters import base
|
||||
@@ -39,13 +40,15 @@ class displayCommentPresenter(basePost.displayPostPresenter):
|
||||
# We'll put images here, so it will be easier to work with them.
|
||||
self.images = []
|
||||
self.imageIndex = 0
|
||||
# connect here the pubsub event for successful posting of comments.
|
||||
pub.subscribe(self.posted, "posted")
|
||||
self.run()
|
||||
pub.unsubscribe(self.posted, "posted")
|
||||
|
||||
def load_all_components(self):
|
||||
self.get_post_information()
|
||||
self.get_likes()
|
||||
self.send_message("disable_control", control="comment")
|
||||
self.get_comments()
|
||||
if self.post["likes"]["can_like"] == 0 and self.post["likes"]["user_likes"] == 0:
|
||||
self.send_message("disable_control", "like")
|
||||
elif self.post["likes"]["user_likes"] == 1:
|
||||
@@ -67,39 +70,20 @@ class displayCommentPresenter(basePost.displayPostPresenter):
|
||||
def reply(self, *args, **kwargs):
|
||||
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Reply to {user1_nom}").format(**self.session.get_user(self.post["from_id"])), message="", text="", mode="comment"))
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
call_threaded(self.do_last, comment, owner_id=self.post["owner_id"], reply_to_comment=self.post["id"], post_id=self.post["post_id"], reply_to_user=self.post["owner_id"])
|
||||
post_arguments = dict(owner_id=self.post["owner_id"], reply_to_comment=self.post["id"], post_id=self.post["post_id"], reply_to_user=self.post["owner_id"], message=comment.text)
|
||||
attachments = []
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = comment.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def get_comments(self):
|
||||
""" Get comments and insert them in a list."""
|
||||
comments_ = []
|
||||
if "thread" not in self.post:
|
||||
return
|
||||
for i in self.post["thread"]["items"]:
|
||||
# If comment has a "deleted" key it should not be displayed, obviously.
|
||||
if "deleted" in i:
|
||||
continue
|
||||
from_ = self.session.get_user(i["from_id"])
|
||||
if "reply_to_user" in i:
|
||||
extra_info = self.session.get_user(i["reply_to_user"], "user2")
|
||||
extra_info.update(from_)
|
||||
from_ = _("{user1_nom} > {user2_nom}").format(**extra_info)
|
||||
else:
|
||||
from_ = from_["user1_nom"]
|
||||
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
|
||||
fixed_text = utils.clean_text(i["text"])
|
||||
if len(fixed_text) > 140:
|
||||
text = fixed_text[:141]
|
||||
else:
|
||||
text = fixed_text
|
||||
original_date = arrow.get(i["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
likes = str(i["likes"]["count"])
|
||||
replies = ""
|
||||
comments_.append((from_, text, created_at, likes, replies))
|
||||
self.send_message("add_items", control="comments", items=comments_)
|
||||
def show_likes(self):
|
||||
""" show likes for the specified post."""
|
||||
data = dict(type="comment", owner_id=self.post["owner_id"], item_id=self.post["id"], extended=True, count=100, skip_own=True)
|
||||
result = self.session.vk.client.likes.getList(**data)
|
||||
if result["count"] > 0:
|
||||
post = {"source_id": self.post[self.user_identifier], "friends": {"items": result["items"]}}
|
||||
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who liked this")))
|
||||
|
||||
def show_comment(self, comment_index):
|
||||
c = self.post["thread"]["items"][comment_index]
|
||||
c["post_id"] = self.post["post_id"]
|
||||
a = displayCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
|
||||
self.clear_comments_list()
|
||||
def posted(self, from_buffer=None):
|
||||
self.interactor.uninstall()
|
||||
return
|
@@ -6,6 +6,7 @@ import views
|
||||
import interactors
|
||||
import output
|
||||
import logging
|
||||
from pubsub import pub
|
||||
from sessionmanager import utils # We'll use some functions from there
|
||||
from mysc.thread_utils import call_threaded
|
||||
from presenters import base
|
||||
@@ -39,7 +40,10 @@ class displayTopicPresenter(basePost.displayPostPresenter):
|
||||
self.worker.finished = threading.Event()
|
||||
self.worker.start()
|
||||
self.attachments = []
|
||||
# connect pubsub event for posted comments.
|
||||
pub.subscribe(self.posted, "posted")
|
||||
self.run()
|
||||
pub.unsubscribe(self.posted, "posted")
|
||||
|
||||
def load_all_components(self):
|
||||
self.get_comments()
|
||||
@@ -106,23 +110,11 @@ class displayTopicPresenter(basePost.displayPostPresenter):
|
||||
def add_comment(self):
|
||||
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Add a comment"), message="", text="", mode="comment"))
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
group_id = self.group_id
|
||||
topic_id = self.post["id"]
|
||||
call_threaded(self.do_last, comment, group_id=group_id, topic_id=topic_id)
|
||||
|
||||
def do_last(self, comment, **kwargs):
|
||||
msg = comment.text
|
||||
attachments = ""
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = self.upload_attachments(comment.attachments)
|
||||
if msg != "":
|
||||
kwargs.update(message=msg)
|
||||
if attachments != "":
|
||||
kwargs.update(attachments=attachments)
|
||||
if "message" not in kwargs and "attachments" not in kwargs:
|
||||
return # No comment made here.
|
||||
result = self.session.vk.client.board.createComment(**kwargs)
|
||||
self.clear_comments_list()
|
||||
post_arguments = dict(group_id=self.group_id, topic_id=self.post["id"], message=comment.text)
|
||||
attachments = []
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = comment.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def reply(self, comment):
|
||||
c = self.comments["items"][comment]
|
||||
@@ -133,11 +125,16 @@ class displayTopicPresenter(basePost.displayPostPresenter):
|
||||
comment.text = "[post{post_id}|{name}], {text}".format(post_id=c["id"], text=comment.text, name=name)
|
||||
group_id = self.group_id
|
||||
topic_id = self.post["id"]
|
||||
call_threaded(self.do_last, comment, group_id=group_id, topic_id=topic_id, reply_to_comment=c["id"])
|
||||
post_arguments = dict(group_id=group_id, topic_id=topic_id, reply_to_comment=c["id"], message=comment.text)
|
||||
attachments = []
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = comment.attachments
|
||||
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
|
||||
|
||||
def show_comment(self, comment_index):
|
||||
c = self.comments["items"][comment_index]
|
||||
c["post_id"] = self.post["id"]
|
||||
c["group_id"] = -1*self.group_id
|
||||
a = displayTopicCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
|
||||
|
||||
def load_more_comments(self):
|
||||
@@ -166,3 +163,6 @@ class displayTopicPresenter(basePost.displayPostPresenter):
|
||||
if left_comments > 100:
|
||||
left_comments = 100
|
||||
self.send_message("set_label", control="load_more_comments", label=_("Load {comments} previous comments").format(comments=left_comments))
|
||||
|
||||
def posted(self, from_buffer=None):
|
||||
self.clear_comments_list()
|
@@ -1,5 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
import output
|
||||
from pubsub import pub
|
||||
from sessionmanager import renderers, utils # We'll use some functions from there
|
||||
from presenters import base
|
||||
from presenters.createPosts.basePost import createPostPresenter
|
||||
@@ -25,4 +27,27 @@ class displayTopicCommentPresenter(comment.displayCommentPresenter):
|
||||
self.get_attachments(self.post, message)
|
||||
self.check_image_load()
|
||||
self.send_message("disable_control", control="reply")
|
||||
self.send_message("disable_control", control="comments")
|
||||
|
||||
def post_like(self):
|
||||
id = self.post["id"]
|
||||
if self.post["likes"]["user_likes"] == 1:
|
||||
l = self.session.vk.client.likes.delete(owner_id=self.post["group_id"], item_id=id, type="topic_comment")
|
||||
output.speak(_("You don't like this"))
|
||||
self.post["likes"]["count"] = l["likes"]
|
||||
self.post["likes"]["user_likes"] = 2
|
||||
self.send_message("set_label", control="like", label=_("&Like"))
|
||||
else:
|
||||
l = self.session.vk.client.likes.add(owner_id=self.post["group_id"], item_id=id, type="topic_comment")
|
||||
output.speak(_("You liked this"))
|
||||
self.send_message("set_label", control="like", label=_("&Dislike"))
|
||||
self.post["likes"]["count"] = l["likes"]
|
||||
self.post["likes"]["user_likes"] = 1
|
||||
self.get_likes()
|
||||
|
||||
def show_likes(self):
|
||||
""" show likes for the specified post."""
|
||||
data = dict(type="topic_comment", owner_id=self.post["group_id"], item_id=self.post["id"], extended=True, count=100, skip_own=True)
|
||||
result = self.session.vk.client.likes.getList(**data)
|
||||
if result["count"] > 0:
|
||||
post = {"source_id": self.post["group_id"], "friends": {"items": result["items"]}}
|
||||
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who liked this")))
|
@@ -198,7 +198,7 @@ class audioPlayer(object):
|
||||
""" Check if the stream has reached the end of the file so it will play the next song. """
|
||||
if self.message != None and self.message.is_playing == False and len(self.message) == self.message.position:
|
||||
volume_step = self.volume*0.15
|
||||
while self.stream.volume*100 < self.volume:
|
||||
while self.stream != None and self.stream.volume*100 < self.volume:
|
||||
self.stream.volume = self.stream.volume+(volume_step/100)
|
||||
time.sleep(0.1)
|
||||
if self.stream != None and self.stream.is_playing == False and self.stopped == False and len(self.stream) == self.stream.position:
|
||||
|
@@ -38,7 +38,7 @@ class userProfilePresenter(base.basePresenter):
|
||||
See https://vk.com/dev/users.get"""
|
||||
# List of fields (information) to retrieve. For a list of fields available for user objects,
|
||||
# see https://vk.com/dev/fields
|
||||
fields = "first_name, last_name, bdate, city, country, home_town, photo_200_orig, online, site, status, last_seen, occupation, relation, relatives, personal, connections, activities, interests, music, movies, tv, books, games, about, quotes, can_write_private_message"
|
||||
fields = "first_name, last_name, bdate, city, country, home_town, photo_200_orig, online, site, status, last_seen, occupation, relation, relatives, personal, connections, activities, interests, music, movies, tv, books, games, about, quotes, can_write_private_message, contacts, has_mobile, universities, education, schools"
|
||||
# ToDo: this method supports multiple user IDS, I'm not sure if this may be of any help for profile viewer.
|
||||
person = self.session.vk.client.users.get(user_ids=self.user_id, fields=fields)
|
||||
# If VK does not return anything it is very likely we have found a community.
|
||||
@@ -50,6 +50,13 @@ class userProfilePresenter(base.basePresenter):
|
||||
# From this part we will format data from VK so users will see it in the GUI control.
|
||||
# Format full name.
|
||||
n = "{0} {1}".format(person["first_name"], person["last_name"])
|
||||
# format phones
|
||||
if person.get("mobile_phone") != None and person.get("mobile_phone") != "":
|
||||
self.send_message("enable_control", tab="main_info", control="mobile_phone")
|
||||
self.send_message("set", tab="main_info", control="mobile_phone", value=person["mobile_phone"])
|
||||
if person.get("home_phone") != None and person.get("home_phone") != "":
|
||||
self.send_message("enable_control", tab="main_info", control="home_phone")
|
||||
self.send_message("set", tab="main_info", control="home_phone", value=person["home_phone"])
|
||||
# Format birthdate.
|
||||
if "bdate" in person and person["bdate"] != "":
|
||||
self.send_message("enable_control", tab="main_info", control="bdate")
|
||||
@@ -59,7 +66,13 @@ class userProfilePresenter(base.basePresenter):
|
||||
self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D"), locale=languageHandler.curLang[:2]))
|
||||
else: # mm.dd.yyyy
|
||||
d = arrow.get(person["bdate"], "D.M.YYYY")
|
||||
self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D, YYYY"), locale=languageHandler.curLang[:2]))
|
||||
# Calculate user's years.
|
||||
now = arrow.get()
|
||||
timedelta = now-d
|
||||
years = int(timedelta.days/365)
|
||||
date = d.format(_("MMMM D, YYYY"), locale=languageHandler.curLang[:2])
|
||||
msg = _("{date} ({age} years)").format(date=date, age=years)
|
||||
self.send_message("set", tab="main_info", control="bdate", value=msg)
|
||||
# Format current city and home town
|
||||
city = ""
|
||||
if "home_town" in person and person["home_town"] != "":
|
||||
|
@@ -13,9 +13,10 @@ load_images = boolean(default=True)
|
||||
update_channel = string(default="stable")
|
||||
|
||||
[buffers]
|
||||
count_for_wall_buffers = integer(default=100)
|
||||
count_for_video_buffers = integer(default=200)
|
||||
count_for_wall_buffers = integer(default=50)
|
||||
count_for_video_buffers = integer(default=50)
|
||||
count_for_audio_buffers = integer(default=1000)
|
||||
count_for_chat_buffers = integer(default=50)
|
||||
|
||||
[chat]
|
||||
notify_online = boolean(default=True)
|
||||
|
@@ -280,4 +280,22 @@ def render_document(document, session):
|
||||
size = convert_bytes(document["size"])
|
||||
date = arrow.get(document["date"]).humanize(locale=languageHandler.curLang[:2])
|
||||
doc_type = doc_types[document["type"]]
|
||||
return [user["user1_nom"], title, doc_type, size, date]
|
||||
return [user["user1_nom"], title, doc_type, size, date]
|
||||
|
||||
def render_notification(notification, session):
|
||||
notification.pop("hide_buttons")
|
||||
print(notification["icon_type"])
|
||||
# print(notification["header"])
|
||||
print(notification)
|
||||
date = arrow.get(notification["date"]).humanize(locale=languageHandler.curLang[:2])
|
||||
msg = notification["header"]
|
||||
# msg = notification["header"]
|
||||
# if notification["type"] == "follow":
|
||||
# if len(notification["feedback"]) == 1:
|
||||
# user = session.get_user(notification["feedback"][0])
|
||||
# msg = _("{user1_nom} subscribed to your account").format(**user)
|
||||
# else:
|
||||
# users = ["{first_name} {last_name},".format(first_name=user["first_name"], last_name=user["last_name"]) for user in notification["feedback"]]
|
||||
# msg = " ".join(users)
|
||||
# print(msg)
|
||||
return [msg, date]
|
@@ -4,15 +4,18 @@ from __future__ import unicode_literals
|
||||
import os
|
||||
import logging
|
||||
import warnings
|
||||
import wx
|
||||
import languageHandler
|
||||
import paths
|
||||
import config
|
||||
import sound
|
||||
from requests.exceptions import ProxyError, ConnectionError
|
||||
from .config_utils import Configuration, ConfigurationResetException
|
||||
from . import vkSessionHandler
|
||||
from pubsub import pub
|
||||
from vk_api.exceptions import LoginRequired, VkApiError
|
||||
from vk_api import upload
|
||||
from .config_utils import Configuration, ConfigurationResetException
|
||||
from . import vkSessionHandler
|
||||
from . import utils
|
||||
|
||||
log = logging.getLogger("session")
|
||||
|
||||
@@ -24,7 +27,7 @@ sessions = {}
|
||||
identifiers = ["aid", "gid", "uid", "pid", "id", "post_id", "nid", "date"]
|
||||
|
||||
# Different VK post types, present in the newsfeed buffer. This is useful for filtering by post and remove deleted posts.
|
||||
post_types = dict(audio="audio", friend="friends", video="video", post="post_type", audio_playlist="audio_playlist")
|
||||
post_types = dict(audio="audio", friend="friends", video="files", post="post_type", audio_playlist="audio_playlist")
|
||||
|
||||
def find_item(list, item):
|
||||
""" Find an item in a list by taking an identifier.
|
||||
@@ -40,7 +43,7 @@ def find_item(list, item):
|
||||
break
|
||||
if identifier == None:
|
||||
# if there are objects that can't be processed by lack of identifier, let's print keys for finding one.
|
||||
log.exception("Can't find an identifier for the following object: %r" % (item.keys(),))
|
||||
log.exception("Can't find an identifier for the following object: %r" % (item,))
|
||||
return False
|
||||
for i in list:
|
||||
if identifier in i and i[identifier] == item[identifier]:
|
||||
@@ -71,7 +74,7 @@ class vkSession(object):
|
||||
if name.endswith("_messages") and show_nextpage == True:
|
||||
show_nextpage = False
|
||||
for i in data:
|
||||
if "type" in i and not isinstance(i["type"], int) and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
|
||||
if "type" in i and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo" or i["type"] == False or i["type"] == True):
|
||||
log.debug("Skipping unsupported item... %r" % (i,))
|
||||
continue
|
||||
# for some reason, VK sends post data if the post has been deleted already.
|
||||
@@ -108,7 +111,7 @@ class vkSession(object):
|
||||
def is_logged(self):
|
||||
return self.logged
|
||||
|
||||
def get_configuration(self):
|
||||
def get_configuration(self, nosound=False):
|
||||
|
||||
""" Gets settings for a session."""
|
||||
|
||||
@@ -116,8 +119,10 @@ class vkSession(object):
|
||||
# try:
|
||||
log.debug("Creating config file %s" % (file_,))
|
||||
self.settings = Configuration(os.path.join(paths.config_path(), file_), os.path.join(paths.app_path(), "session.defaults"))
|
||||
self.soundplayer = sound.soundSystem(config.app["sound"])
|
||||
pub.subscribe(self.play_sound, "play-sound")
|
||||
if nosound == False:
|
||||
self.soundplayer = sound.soundSystem(config.app["sound"])
|
||||
pub.subscribe(self.play_sound, "play-sound")
|
||||
pub.subscribe(self.post, "post")
|
||||
# except:
|
||||
# log.exception("The session configuration has failed.")
|
||||
|
||||
@@ -185,8 +190,10 @@ class vkSession(object):
|
||||
c = self.vk.client_audio
|
||||
else:
|
||||
c = self.vk.client
|
||||
formatted_endpoint = ""
|
||||
if "parent_endpoint" in kwargs:
|
||||
p = kwargs["parent_endpoint"]
|
||||
formatted_endpoint = kwargs["parent_endpoint"]
|
||||
if "audio" in p and self.settings["vk"]["use_alternative_tokens"]:
|
||||
log.info("Using alternative audio methods.")
|
||||
c = self.vk.client_audio
|
||||
@@ -199,7 +206,11 @@ class vkSession(object):
|
||||
kwargs.update(offset=self.db[name]["offset"])
|
||||
else:
|
||||
kwargs.update(offset=0)
|
||||
log.debug("Calling endpoint %s with params %r" % (p, kwargs,))
|
||||
formatted_endpoint = "{formatted_endpoint}.{new_path}".format(formatted_endpoint=formatted_endpoint, new_path=endpoint)
|
||||
offset_deprecated = ["notifications.get"]
|
||||
if formatted_endpoint in offset_deprecated:
|
||||
kwargs.update(offset=None)
|
||||
log.debug("Calling endpoint %s with params %r" % (formatted_endpoint, kwargs,))
|
||||
data = getattr(p, endpoint)(*args, **kwargs)
|
||||
if data != None:
|
||||
if "count" not in kwargs:
|
||||
@@ -210,7 +221,8 @@ class vkSession(object):
|
||||
data["items"].reverse()
|
||||
if type(data) == dict:
|
||||
num = self.order_buffer(name, data["items"], show_nextpage)
|
||||
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
|
||||
if formatted_endpoint not in offset_deprecated:
|
||||
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
|
||||
if len(data["items"]) > 0 and "first_name" in data["items"][0]:
|
||||
data2 = {"profiles": [], "groups": []}
|
||||
for i in data["items"]:
|
||||
@@ -300,4 +312,99 @@ class vkSession(object):
|
||||
def get_my_data(self):
|
||||
log.debug("Getting user identifier...")
|
||||
user = self.vk.client.users.get(fields="uid, first_name, last_name")
|
||||
self.user_id = user[0]["id"]
|
||||
self.user_id = user[0]["id"]
|
||||
|
||||
def post(self, parent_endpoint, child_endpoint, from_buffer=None, attachments_list=[], post_arguments={}):
|
||||
""" Generic function to be called whenever user wants to post something to VK.
|
||||
This function should be capable of uploading all attachments before posting, and send a special event in case the post has failed,
|
||||
So the program can recreate the post and show it back to the user."""
|
||||
# ToDo: this function will occasionally be called with attachments already set to post_arguments, example if the user could upload the files but was unable to send the post due to a connection problem.
|
||||
# We should see what can be done (reuploading everything vs using the already added attachments).
|
||||
attachments = ""
|
||||
# Firstly, let's try to upload the attachments here. If peer_id exists in post_arguments,
|
||||
# It means we are talking about private messages, whose attachment procedures have their own methods.
|
||||
if len(attachments_list) > 0:
|
||||
try:
|
||||
attachments = self.upload_attachments(attachments_list, post_arguments.get("peer_id"))
|
||||
except Exception as error:
|
||||
log.error("Error calling method %s.%s with arguments: %r. Failed during loading attachments. Error: %s" % (parent_endpoint, child_endpoint, post_arguments, str(error)))
|
||||
# Report a failed function here too with same arguments so the client should be able to recreate it again.
|
||||
wx.CallAfter(pub.sendMessage, "postFailed", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||
# VK generally defines all kind of messages under "text", "message" or "body" so let's try with all of those
|
||||
possible_message_keys = ["text", "message", "body"]
|
||||
for i in possible_message_keys:
|
||||
if post_arguments.get(i):
|
||||
urls = utils.find_urls_in_text(post_arguments[i])
|
||||
if len(urls) != 0:
|
||||
if len(attachments) == 0:
|
||||
attachments = urls[0]
|
||||
else:
|
||||
attachments += urls[0]
|
||||
post_arguments[i] = post_arguments[i].replace(urls[0], "")
|
||||
# After modifying everything, let's update the post arguments if needed.
|
||||
if len(attachments) > 0:
|
||||
if parent_endpoint == "messages":
|
||||
post_arguments.update(attachment=attachments)
|
||||
else:
|
||||
post_arguments.update(attachments=attachments)
|
||||
# Determines the correct functions to call here.
|
||||
endpoint = getattr(self.vk.client, parent_endpoint)
|
||||
endpoint = getattr(endpoint, child_endpoint)
|
||||
try:
|
||||
post = endpoint(**post_arguments)
|
||||
# Once the post has been send, let's report it to the interested objects.
|
||||
pub.sendMessage("posted", from_buffer=from_buffer)
|
||||
except Exception as error:
|
||||
log.exception("Error calling method %s.%s with arguments: %r. Error: %s" % (parent_endpoint, child_endpoint, post_arguments, str(error)))
|
||||
# Report a failed function here too with same arguments so the client should be able to recreate it again.
|
||||
wx.CallAfter(pub.sendMessage, "postFailed", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
|
||||
|
||||
def upload_attachments(self, attachments, peer_id=None):
|
||||
""" Upload attachments to VK before posting them.
|
||||
Returns attachments formatted as string, as required by VK API.
|
||||
@ peer_id int: if this value is passed, let's assume attachments will be send in private messages.
|
||||
"""
|
||||
# To do: Check the caption and description fields for this kind of attachments.
|
||||
local_attachments = ""
|
||||
uploader = upload.VkUpload(self.vk.session_object)
|
||||
for i in attachments:
|
||||
if i["from"] == "online":
|
||||
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
|
||||
elif i["from"] == "local" and i["type"] == "photo":
|
||||
photos = i["file"]
|
||||
description = i["description"]
|
||||
if peer_id == None:
|
||||
r = uploader.photo_wall(photos, caption=description)
|
||||
else:
|
||||
r = uploader.photo_messages(photos)
|
||||
id = r[0]["id"]
|
||||
owner_id = r[0]["owner_id"]
|
||||
local_attachments += "photo{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "audio":
|
||||
audio = i["file"]
|
||||
title = "untitled"
|
||||
artist = "unnamed"
|
||||
if "artist" in i:
|
||||
artist = i["artist"]
|
||||
if "title" in i:
|
||||
title = i["title"]
|
||||
r = uploader.audio(audio, title=title, artist=artist)
|
||||
id = r["id"]
|
||||
owner_id = r["owner_id"]
|
||||
local_attachments += "audio{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "voice_message":
|
||||
r = uploader.audio_message(i["file"], peer_id=peer_id)
|
||||
id = r["audio_message"]["id"]
|
||||
owner_id = r["audio_message"]["owner_id"]
|
||||
local_attachments += "audio_message{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "document":
|
||||
document = i["file"]
|
||||
title = i["title"]
|
||||
if peer_id == None:
|
||||
r = uploader.document(document, title=title, to_wall=True)
|
||||
else:
|
||||
r = uploader.document(document, title=title, message_peer_id=peer_id)
|
||||
id = r["doc"]["id"]
|
||||
owner_id = r["doc"]["owner_id"]
|
||||
local_attachments += "doc{0}_{1},".format(owner_id, id)
|
||||
return local_attachments
|
@@ -5,6 +5,7 @@ import widgetUtils
|
||||
import paths
|
||||
import time
|
||||
import logging
|
||||
import shutil
|
||||
from authenticator.official import AuthenticationError
|
||||
from . import wxUI as view
|
||||
from . import session
|
||||
@@ -13,15 +14,23 @@ from .config_utils import Configuration
|
||||
log = logging.getLogger("sessionmanager.sessionManager")
|
||||
|
||||
class sessionManagerController(object):
|
||||
def __init__(self):
|
||||
def __init__(self, starting=True):
|
||||
super(sessionManagerController, self).__init__()
|
||||
log.debug("Setting up the session manager.")
|
||||
if starting:
|
||||
title=_("Select an account")
|
||||
else:
|
||||
title = _("Manage accounts")
|
||||
self.view = view.sessionManagerWindow(starting=starting, title=title)
|
||||
widgetUtils.connect_event(self.view.new, widgetUtils.BUTTON_PRESSED, self.manage_new_account)
|
||||
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.remove)
|
||||
self.fill_list()
|
||||
if not hasattr(self, "session"):
|
||||
if len(self.sessions) == 0:
|
||||
log.debug("the session list is empty, creating a new one...")
|
||||
self.manage_new_account()
|
||||
|
||||
def fill_list(self):
|
||||
self.sessions = []
|
||||
log.debug("Filling the session list...")
|
||||
for i in os.listdir(paths.config_path()):
|
||||
if os.path.isdir(os.path.join(paths.config_path(), i)):
|
||||
@@ -29,12 +38,10 @@ class sessionManagerController(object):
|
||||
config_test = Configuration(os.path.join(paths.config_path(), i, "session.conf"))
|
||||
name = config_test["vk"]["user"]
|
||||
if name != "" and config_test["vk"]["password"] != "":
|
||||
self.session = i
|
||||
s = session.vkSession(self.session)
|
||||
s.get_configuration()
|
||||
session.sessions[self.session] = s
|
||||
self.sessions.append((i, name))
|
||||
self.view.list.insert_item(False, *[name])
|
||||
|
||||
def manage_new_account(self):
|
||||
def manage_new_account(self, *args, **kwargs):
|
||||
if view.new_account_dialog() == widgetUtils.YES:
|
||||
location = (str(time.time())[-6:])
|
||||
log.debug("Creating session in the %s path" % (location,))
|
||||
@@ -42,11 +49,12 @@ class sessionManagerController(object):
|
||||
path = os.path.join(paths.config_path(), location)
|
||||
if not os.path.exists(path):
|
||||
os.mkdir(path)
|
||||
s.get_configuration()
|
||||
s.get_configuration(True)
|
||||
self.get_authorisation(s)
|
||||
session.sessions[location] = s
|
||||
else:
|
||||
sys.exit()
|
||||
name = s.settings["vk"]["user"]
|
||||
self.sessions.append((location, name))
|
||||
self.view.list.insert_item(False, *[name])
|
||||
self.modified = True
|
||||
|
||||
def get_authorisation(self, c):
|
||||
log.debug("Starting the authorisation process...")
|
||||
@@ -59,4 +67,30 @@ class sessionManagerController(object):
|
||||
except AuthenticationError:
|
||||
c.settings["vk"]["password"] = ""
|
||||
c.settings["vk"]["user"]
|
||||
return self.get_authorisation(c)
|
||||
return self.get_authorisation(c)
|
||||
|
||||
def do_ok(self):
|
||||
selected_session = self.sessions[self.view.list.get_selected()]
|
||||
self.session = selected_session[0]
|
||||
self.session = session.vkSession(self.session)
|
||||
self.session.get_configuration()
|
||||
session.sessions[selected_session[1]] = self.session
|
||||
|
||||
def show(self):
|
||||
if len(self.sessions) > 1:
|
||||
answer = self.view.get_response()
|
||||
else:
|
||||
answer = widgetUtils.OK
|
||||
if answer == widgetUtils.OK:
|
||||
self.do_ok()
|
||||
else:
|
||||
sys.exit()
|
||||
self.view.destroy()
|
||||
|
||||
def remove(self, *args, **kwargs):
|
||||
if self.view.remove_account_dialog() == widgetUtils.YES:
|
||||
selected_session = self.sessions[self.view.list.get_selected()]
|
||||
shutil.rmtree(path=os.path.join(paths.config_path(), selected_session[0]), ignore_errors=True)
|
||||
self.sessions.remove(selected_session)
|
||||
self.view.list.remove_item(self.view.list.get_selected())
|
||||
self.modified = True
|
@@ -19,7 +19,7 @@ class VkApi(vk_api.VkApi):
|
||||
def __init__(self, login=None, password=None, token=None, secret=None, device_id=None,
|
||||
auth_handler=None, captcha_handler=None,
|
||||
config=jconfig.Config, config_filename='vk_config.v2.json',
|
||||
api_version='5.92', app_id=2685278, scope=DEFAULT_USER_SCOPE,
|
||||
api_version='5.101', app_id=2685278, scope=DEFAULT_USER_SCOPE,
|
||||
client_secret='lxhD8OD7dMsqtXIm5IUY'):
|
||||
|
||||
self.login = login
|
||||
|
@@ -36,4 +36,39 @@ class newSessionDialog(widgetUtils.BaseDialog):
|
||||
return self.email.GetValue()
|
||||
|
||||
def get_password(self):
|
||||
return self.passw.GetValue()
|
||||
return self.passw.GetValue()
|
||||
|
||||
class sessionManagerWindow(widgetUtils.BaseDialog):
|
||||
def __init__(self, title, starting=True):
|
||||
super(sessionManagerWindow, self).__init__(parent=None, title=title, size=wx.DefaultSize)
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
label = wx.StaticText(panel, -1, _(u"Accounts list"), size=wx.DefaultSize)
|
||||
listSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.list = widgetUtils.list(panel, _("Account"), style=wx.LC_SINGLE_SEL|wx.LC_REPORT)
|
||||
listSizer.Add(label, 0, wx.ALL, 5)
|
||||
listSizer.Add(self.list.list, 0, wx.ALL, 5)
|
||||
sizer.Add(listSizer, 0, wx.ALL, 5)
|
||||
self.new = wx.Button(panel, -1, _("New account"), size=wx.DefaultSize)
|
||||
self.remove = wx.Button(panel, -1, _(u"Remove account"))
|
||||
if starting:
|
||||
id_ok = wx.ID_OK
|
||||
else:
|
||||
id_ok = wx.ID_CANCEL
|
||||
ok = wx.Button(panel, id_ok, size=wx.DefaultSize)
|
||||
ok.SetDefault()
|
||||
if starting:
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize)
|
||||
self.SetAffirmativeId(id_ok)
|
||||
buttons = wx.BoxSizer(wx.HORIZONTAL)
|
||||
buttons.Add(self.new, 0, wx.ALL, 5)
|
||||
buttons.Add(ok, 0, wx.ALL, 5)
|
||||
if starting:
|
||||
buttons.Add(cancel, 0, wx.ALL, 5)
|
||||
sizer.Add(buttons, 0, wx.ALL, 5)
|
||||
panel.SetSizer(sizer)
|
||||
min = sizer.CalcMin()
|
||||
self.SetClientSize(min)
|
||||
|
||||
def remove_account_dialog(self):
|
||||
return wx.MessageDialog(self, _("Do you really want to delete this account?"), _("Remove account"), wx.YES_NO).ShowModal()
|
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys
|
||||
import application
|
||||
import platform
|
||||
import logging
|
||||
@@ -9,6 +10,9 @@ from .wxUpdater import *
|
||||
logger = logging.getLogger("updater")
|
||||
|
||||
def do_update(update_type="stable"):
|
||||
# Updates cannot be performed in the source code version of Socializer.
|
||||
if hasattr(sys, "frozen") == False:
|
||||
return
|
||||
if update_type == "stable":
|
||||
endpoint = application.update_stable_url
|
||||
version = application.version
|
||||
|
@@ -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 *
|
||||
|
@@ -41,7 +41,7 @@ class attachDialog(widgetUtils.BaseDialog):
|
||||
def get_image(self):
|
||||
openFileDialog = wx.FileDialog(self, _("Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
|
||||
if openFileDialog.ShowModal() == wx.ID_CANCEL:
|
||||
return None
|
||||
return (None, None)
|
||||
dsc = self.ask_description()
|
||||
return (openFileDialog.GetPath(), dsc)
|
||||
|
||||
|
20
src/views/dialogs/blacklist.py
Normal file
20
src/views/dialogs/blacklist.py
Normal file
@@ -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())
|
@@ -12,6 +12,23 @@ class general(wx.Panel, widgetUtils.BaseDialog):
|
||||
self.language.SetSize(self.language.GetBestSize())
|
||||
langBox.Add(self.language, 0, wx.ALL, 5)
|
||||
sizer.Add(langBox, 0, wx.ALL, 5)
|
||||
self.load_images = wx.CheckBox(self, wx.NewId(), _("Load images in posts"))
|
||||
sizer.Add(self.load_images, 0, wx.ALL, 5)
|
||||
self.use_proxy = wx.CheckBox(self, wx.NewId(), _("Use proxy"))
|
||||
sizer.Add(self.use_proxy, 0, wx.ALL, 5)
|
||||
lbl4 = wx.StaticText(self, wx.NewId(), _("Update channel"))
|
||||
self.update_channel = wx.ComboBox(self, wx.NewId(), choices=[_("Stable"), _("Alpha")], value=_("Native"), style=wx.CB_READONLY)
|
||||
box4 = wx.BoxSizer(wx.HORIZONTAL)
|
||||
box4.Add(lbl4, 0, wx.ALL, 5)
|
||||
box4.Add(self.update_channel, 0, wx.ALL, 5)
|
||||
sizer.Add(box4, 0, wx.ALL, 5)
|
||||
self.SetSizer(sizer)
|
||||
|
||||
class buffers(wx.Panel, widgetUtils.BaseDialog):
|
||||
|
||||
def __init__(self, panel):
|
||||
super(buffers, self).__init__(panel)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
lbl1 = wx.StaticText(self, wx.NewId(), _("Number of items to load for newsfeed and wall buffers (maximun 100)"))
|
||||
self.wall_buffer_count = wx.SpinCtrl(self, wx.NewId())
|
||||
self.wall_buffer_count.SetRange(1, 100)
|
||||
@@ -26,15 +43,12 @@ class general(wx.Panel, widgetUtils.BaseDialog):
|
||||
box3.Add(lbl3, 0, wx.ALL, 5)
|
||||
box3.Add(self.video_buffers_count, 0, wx.ALL, 5)
|
||||
sizer.Add(box3, 0, wx.ALL, 5)
|
||||
self.load_images = wx.CheckBox(self, wx.NewId(), _("Load images in posts"))
|
||||
sizer.Add(self.load_images, 0, wx.ALL, 5)
|
||||
self.use_proxy = wx.CheckBox(self, wx.NewId(), _("Use proxy"))
|
||||
sizer.Add(self.use_proxy, 0, wx.ALL, 5)
|
||||
lbl4 = wx.StaticText(self, wx.NewId(), _("Update channel"))
|
||||
self.update_channel = wx.ComboBox(self, wx.NewId(), choices=[_("Stable"), _("Alpha")], value=_("Native"), style=wx.CB_READONLY)
|
||||
lbl4 = wx.StaticText(self, wx.NewId(), _("Number of items to load in conversation buffers (maximun 200)"))
|
||||
self.chat_buffers_count = wx.SpinCtrl(self, wx.NewId())
|
||||
self.chat_buffers_count.SetRange(1, 200)
|
||||
box4 = wx.BoxSizer(wx.HORIZONTAL)
|
||||
box4.Add(lbl4, 0, wx.ALL, 5)
|
||||
box4.Add(self.update_channel, 0, wx.ALL, 5)
|
||||
box4.Add(self.chat_buffers_count, 0, wx.ALL, 5)
|
||||
sizer.Add(box4, 0, wx.ALL, 5)
|
||||
self.SetSizer(sizer)
|
||||
|
||||
@@ -121,6 +135,10 @@ class configurationDialog(widgetUtils.BaseDialog):
|
||||
self.notebook.AddPage(self.general, _("General"))
|
||||
self.general.SetFocus()
|
||||
|
||||
def create_buffers(self):
|
||||
self.buffers = buffers(self.notebook)
|
||||
self.notebook.AddPage(self.buffers, _("Buffer settings"))
|
||||
|
||||
def create_chat(self):
|
||||
self.chat = chat(self.notebook)
|
||||
self.notebook.AddPage(self.chat, _("Chat settings"))
|
||||
|
@@ -91,7 +91,7 @@ class createPostDialog(createTextMessage):
|
||||
self.SetClientSize(self.mainBox.CalcMin())
|
||||
|
||||
class createCommentDialog(createTextMessage):
|
||||
def createControls(self, title, message, text):
|
||||
def createControls(self, title, message, text, **kwargs):
|
||||
self.mainBox = wx.BoxSizer(wx.VERTICAL)
|
||||
self.createTextArea(message, text)
|
||||
self.mainBox.Add(self.textBox, 0, wx.ALL, 5)
|
||||
@@ -117,17 +117,17 @@ class createCommentDialog(createTextMessage):
|
||||
self.panel.SetSizer(self.mainBox)
|
||||
self.SetTitle(title)
|
||||
|
||||
def __init__(self, title, message, text):
|
||||
def __init__(self, title, message, text, *args, **kwargs):
|
||||
super(createCommentDialog, self).__init__()
|
||||
self.createControls(message, title, text)
|
||||
self.createControls(message, title, text, **kwargs)
|
||||
self.SetClientSize(self.mainBox.CalcMin())
|
||||
self.SetTitle(title)
|
||||
|
||||
class createTopicDialog(createCommentDialog):
|
||||
def createTextArea(self, message="", text=""):
|
||||
def createTextArea(self, message="", text="", topic_title=""):
|
||||
self.panel = wx.Panel(self)
|
||||
label = wx.StaticText(self.panel, -1, _("Title"))
|
||||
self.title = wx.TextCtrl(self.panel, wx.NewId())
|
||||
self.title = wx.TextCtrl(self.panel, wx.NewId(), topic_title)
|
||||
label2 = wx.StaticText(self.panel, -1, _("Message"))
|
||||
self.text = wx.TextCtrl(self.panel, -1, text, size=(439, -1), style=wx.TE_MULTILINE)
|
||||
self.title.SetFocus()
|
||||
@@ -141,9 +141,9 @@ class createTopicDialog(createCommentDialog):
|
||||
textb.Add(self.text, 0, wx.ALL, 5)
|
||||
self.textBox.Add(textb, 0, wx.ALL, 5)
|
||||
|
||||
def createControls(self, title, message, text):
|
||||
def createControls(self, title, message, text, topic_title):
|
||||
self.mainBox = wx.BoxSizer(wx.VERTICAL)
|
||||
self.createTextArea(message, text)
|
||||
self.createTextArea(message, text, topic_title)
|
||||
self.mainBox.Add(self.textBox, 0, wx.ALL, 5)
|
||||
self.attach = wx.Button(self.panel, -1, _("Attach"), size=wx.DefaultSize)
|
||||
self.mention = wx.Button(self.panel, wx.NewId(), _("Tag a friend"))
|
||||
|
@@ -40,7 +40,7 @@ class displayBasicPost(widgetUtils.BaseDialog):
|
||||
|
||||
def create_comments_list(self):
|
||||
lbl = wx.StaticText(self.panel, -1, _("Comments"))
|
||||
self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), _("replies"), style=wx.LC_REPORT)
|
||||
self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), style=wx.LC_REPORT)
|
||||
self.reply = wx.Button(self.panel, -1, _("Reply to comment"))
|
||||
self.reply.Enable(False)
|
||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||
@@ -170,22 +170,12 @@ class displayComment(displayBasicPost):
|
||||
self.sizer.Add(likes_box, 0, wx.ALL, 5)
|
||||
actions_box = self.create_action_buttons()
|
||||
self.sizer.Add(actions_box, 0, wx.ALL, 5)
|
||||
comments_box = self.create_comments_list()
|
||||
self.sizer.Add(comments_box, 0, wx.ALL, 5)
|
||||
self.sizer.Add(self.create_dialog_buttons())
|
||||
self.done()
|
||||
|
||||
def create_comments_list(self):
|
||||
lbl = wx.StaticText(self.panel, -1, _("Replies"))
|
||||
self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), _("Replies"), style=wx.LC_REPORT)
|
||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||
box.Add(lbl, 0, wx.ALL, 5)
|
||||
box.Add(self.comments.list, 0, wx.ALL, 5)
|
||||
return box
|
||||
|
||||
def create_action_buttons(self, comment=True):
|
||||
self.like = wx.Button(self.panel, -1, _("&Like"))
|
||||
self.reply = wx.Button(self.panel, -1, _("Reply to thread"))
|
||||
self.reply = wx.Button(self.panel, -1, _("Reply"))
|
||||
if comment: self.comment = wx.Button(self.panel, -1, _("Add comment"))
|
||||
box = wx.BoxSizer(wx.HORIZONTAL)
|
||||
box.Add(self.like, 0, wx.ALL, 5)
|
||||
|
@@ -14,7 +14,7 @@ def text_size(wxObject, chars):
|
||||
(x, y) = dc.GetMultiLineTextExtent("0"*chars)
|
||||
return (x, -1)
|
||||
|
||||
class mainInfo(wx.Panel):
|
||||
class baseTab(wx.Panel):
|
||||
""" Panel to store main user information in a profile viewer."""
|
||||
|
||||
def get(self, control):
|
||||
@@ -40,6 +40,8 @@ class mainInfo(wx.Panel):
|
||||
def disable(self, control):
|
||||
getattr(self, control).Enable(False)
|
||||
|
||||
class mainInfo(baseTab):
|
||||
|
||||
def __init__(self, panel):
|
||||
super(mainInfo, self).__init__(panel)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
@@ -68,6 +70,22 @@ class mainInfo(wx.Panel):
|
||||
sizerLastSeen.Add(self.last_seen, 0, wx.ALL, 5)
|
||||
sizer.Add(sizerLastSeen, 0, wx.ALL, 5)
|
||||
|
||||
lblMobilePhone = wx.StaticText(self, wx.NewId(), _("Mobile phone"))
|
||||
self.mobile_phone = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
|
||||
self.mobile_phone.Enable(False)
|
||||
sizerMobilePhone = wx.BoxSizer(wx.HORIZONTAL)
|
||||
sizerMobilePhone.Add(lblMobilePhone, 0, wx.ALL, 5)
|
||||
sizerMobilePhone.Add(self.mobile_phone, 0, wx.ALL, 5)
|
||||
sizer.Add(sizerMobilePhone, 0, wx.ALL, 5)
|
||||
|
||||
lblHomePhone = wx.StaticText(self, wx.NewId(), _("Home phone"))
|
||||
self.home_phone = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
|
||||
self.home_phone.Enable(False)
|
||||
sizerHomePhone = wx.BoxSizer(wx.HORIZONTAL)
|
||||
sizerHomePhone.Add(lblHomePhone, 0, wx.ALL, 5)
|
||||
sizerHomePhone.Add(self.home_phone, 0, wx.ALL, 5)
|
||||
sizer.Add(sizerHomePhone, 0, wx.ALL, 5)
|
||||
|
||||
lblBDate = wx.StaticText(self, wx.NewId(), _("Birthdate"))
|
||||
self.bdate = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
|
||||
self.bdate.Enable(False)
|
||||
|
@@ -67,3 +67,12 @@ 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()
|
@@ -20,9 +20,11 @@ class timelineDialog(widgetUtils.BaseDialog):
|
||||
actionsSizer = wx.StaticBoxSizer(parent=panel, orient=wx.VERTICAL, label=_("Buffer type"))
|
||||
self.wall = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("&Wall posts"), style=wx.RB_GROUP)
|
||||
self.audio = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("Audio"))
|
||||
self.video = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("Video"))
|
||||
self.friends = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("Friends"))
|
||||
actionsSizer.Add(self.wall, 0, wx.ALL, 5)
|
||||
actionsSizer.Add(self.audio, 0, wx.ALL, 5)
|
||||
actionsSizer.Add(self.video, 0, wx.ALL, 5)
|
||||
actionsSizer.Add(self.friends, 0, wx.ALL, 5)
|
||||
sizer.Add(actionsSizer, 0, wx.ALL, 5)
|
||||
ok = wx.Button(panel, wx.ID_OK, _("&OK"))
|
||||
@@ -41,6 +43,8 @@ class timelineDialog(widgetUtils.BaseDialog):
|
||||
def get_buffer_type(self):
|
||||
if self.audio.GetValue() == True:
|
||||
return "audio"
|
||||
elif self.video.GetValue() == True:
|
||||
return "video"
|
||||
elif self.wall.GetValue() == True:
|
||||
return "wall"
|
||||
elif self.friends.GetValue() == True:
|
||||
|
@@ -15,6 +15,8 @@ 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.accounts = app_.Append(wx.NewId(), _("Manage accounts"))
|
||||
self.settings_dialog = app_.Append(wx.NewId(), _("Preferences"))
|
||||
me = wx.Menu()
|
||||
profile = wx.Menu()
|
||||
|
@@ -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):
|
||||
|
@@ -100,9 +100,9 @@ class audioAlbumTab(audioTab):
|
||||
self.postBox.Add(self.play, 0, wx.ALL, 5)
|
||||
self.postBox.Add(self.play_all, 0, wx.ALL, 5)
|
||||
|
||||
class notificationsTab(homeTab):
|
||||
class notificationTab(homeTab):
|
||||
def __init__(self, parent):
|
||||
super(notificationsTab, self).__init__(parent=parent)
|
||||
super(notificationTab, self).__init__(parent=parent)
|
||||
self.name = "notifications"
|
||||
|
||||
def OnKeyDown(self, ev=None):
|
||||
@@ -110,7 +110,8 @@ class notificationsTab(homeTab):
|
||||
ev.Skip()
|
||||
|
||||
def create_list(self):
|
||||
self.list = widgetUtils.list(self, *[_("Notification")], style=wx.LC_REPORT)
|
||||
self.lbl = wx.StaticText(self, wx.NewId(), _("Po&sts"))
|
||||
self.list = widgetUtils.list(self, *[_("Notification"), _("Date")], style=wx.LC_REPORT)
|
||||
self.list.set_windows_size(0, 190)
|
||||
self.list.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnKeyDown)
|
||||
|
||||
@@ -265,7 +266,7 @@ class peopleTab(homeTab):
|
||||
|
||||
def create_post_buttons(self):
|
||||
self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions"))
|
||||
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post"))
|
||||
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post on user's wall"))
|
||||
self.new_chat = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Send message"))
|
||||
self.postBox.Add(self.post, 0, wx.ALL, 5)
|
||||
self.postBox.Add(self.new_chat, 0, wx.ALL, 5)
|
||||
|
@@ -1,4 +1,4 @@
|
||||
{"current_version": "0.21",
|
||||
{"current_version": "0.22",
|
||||
"description": ".",
|
||||
"downloads":
|
||||
{"Windows32": "https://code.manuelcortez.net/manuelcortez/socializer/-/jobs/artifacts/v0.21/raw/socializer.zip?job=stable"}}
|
||||
{"Windows32": "https://code.manuelcortez.net/manuelcortez/socializer/-/jobs/artifacts/v0.22/raw/socializer.zip?job=stable"}}
|
Reference in New Issue
Block a user