Compare commits
98 Commits
v0.20
...
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 | |||
cd623065e7 | |||
2b462bfecb | |||
9353ea93c1 | |||
853cce4a66 | |||
2d944b276c | |||
b4299ef066 | |||
64799d2e14 | |||
ead54fce3f | |||
ae93efb17a | |||
d95dfb18fd | |||
4e3c397ce5 | |||
4e6126405f | |||
8cdec543e1 | |||
4810cbe138 | |||
8ec7fbb49e | |||
7d52ed8802 | |||
9d44d063eb | |||
d5eb9ed478 | |||
40afb6cdc2 | |||
74234476ab | |||
82c71a3bd8 | |||
5161e1c045 | |||
40052dbf3f | |||
e73d92754e | |||
6df1b80941 | |||
a9e5963b74 | |||
95671966cd | |||
a8ce7216e1 | |||
5c6829165b | |||
91eebfd895 | |||
72cc04342f | |||
75267294f9 | |||
f81d302c9a | |||
c3ab0406e4 | |||
fdcaf4e596 | |||
ca7b3eff29 | |||
f1eb640564 | |||
194ca2d380 | |||
976e90f0a0 | |||
2c836f473d | |||
f834b6046e | |||
e6087f3818 | |||
20c3df6be2 | |||
b914e4b548 | |||
f336489609 | |||
4ce2e88568 | |||
a917a6a9cd | |||
a01eabea91 | |||
605f0da751 | |||
6bd0c10ef2 | |||
a9032602bf | |||
8c03601bd2 |
@@ -21,6 +21,27 @@ test_py3:
|
||||
- '%PYTHON3% -m coverage report --omit="test*"'
|
||||
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
|
||||
|
||||
documentation:
|
||||
type: deploy
|
||||
tags:
|
||||
- windows10
|
||||
before_script:
|
||||
- '%PYTHON3% -v'
|
||||
script:
|
||||
- copy changelog.md doc\changelog.md
|
||||
- cd doc
|
||||
- '%PYTHON2% documentation_importer.py'
|
||||
- cd ..\src
|
||||
- '%PYTHON2% ..\doc\generator.py'
|
||||
- 'move documentation ..\'
|
||||
only:
|
||||
- master
|
||||
artifacts:
|
||||
paths:
|
||||
- documentation
|
||||
name: socializer_documentation
|
||||
expire_in: 1 day
|
||||
|
||||
alpha_python3:
|
||||
type: deploy
|
||||
tags:
|
||||
|
59
changelog.md
59
changelog.md
@@ -4,6 +4,65 @@
|
||||
|
||||
### 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.
|
||||
* In people buffers, it is possible to create a new timeline by using the context menu while focusing an user. This method will create the buffer for the selected user, as opposed to creating the buffer from the menu bar, where you have to type the username or find it in a list.
|
||||
|
||||
### bugfixes
|
||||
|
||||
* Fixed an error with two factor authentication in the recent socializer version. Now it works reliably again.
|
||||
* Fixed an error when trying to attach a photo to a wall post. The error was fixed in the [vk_api](https://github.com/python273/vk_api) module and the fix was sent to the developer of the library, so he will be able to merge it in the next version. In the meantime, socializer already includes the fix for this method, so you can upload photos to wall posts normally.
|
||||
* Fixed an error retrieving some group information for the current session.
|
||||
* When posting in a topic, links will be posted properly.
|
||||
|
||||
|
||||
### Changes
|
||||
|
||||
* the audio player module has received some improvements:
|
||||
- When there is something being played, the label of the "play" button, located in all audio buffers, will change automatically to "pause". When pressed, it will pause the song instead of starting the playback again since the beginning.
|
||||
- The last change will work also in the dialog for displaying audio information. Now it's possible to play and pause an audio from such dialog.
|
||||
- When playing a voice message, if a song is playing already socializer will decrease the volume so you can hear the voice message well enough. Some seconds after the message has finished, the song's volume will be restored.
|
||||
* In audio buffers, you will play the focused audio when pressing enter in the item, instead of opening the audio information dialog.
|
||||
* Removed some old keystrokes in socializer buffers due to better alternatives. The reason for this change is that currently you don't need to be focusing an item in a buffer for being able to use the alternative keystrokes, which makes those a better implementation.
|
||||
- Control+Enter and control+Shift+Enter: superseeded by Control+P for playing (and pausing) the currently focused audio.
|
||||
- F5 and F6: superseeded by Alt+down and up arrows for modifying volume.
|
||||
|
||||
## changes in version 0.20 (25.04.2019)
|
||||
|
||||
### New additions
|
||||
|
||||
* For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define which soundcard will be used for input and output. [#25,](https://code.manuelcortez.net/manuelcortez/socializer/issues/25)
|
||||
* the audio player can seek positions in the currently playing track. You can use the menu items (located in the main menu) or use the new available keystrokes dedicated to the actions. Seeking will be made in 5 second intervals.
|
||||
* Alt+Shift+Left arrow: Seek 5 seconds backwards.
|
||||
|
@@ -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.
|
@@ -3,7 +3,10 @@ wxpython==4.0.3
|
||||
pywin32
|
||||
pyenchant
|
||||
markdown
|
||||
vk_api
|
||||
# For the moment we will use the modified vk_api version that does not try to include enum34 and
|
||||
# already fixed the caption for wall uploaded photos.
|
||||
# Hopefully I can uncomment this in the near future when my changes will get merged upstream.
|
||||
#vk_api
|
||||
bs4
|
||||
configobj
|
||||
pypubsub
|
||||
@@ -18,4 +21,6 @@ mock
|
||||
git+https://code.manuelcortez.net/manuelcortez/libloader
|
||||
git+https://code.manuelcortez.net/manuelcortez/platform_utils
|
||||
git+https://github.com/chrisnorman7/sound_lib
|
||||
git+https://code.manuelcortez.net/manuelcortez/accessible_output2
|
||||
git+https://code.manuelcortez.net/manuelcortez/accessible_output2
|
||||
# Modified vk_api.
|
||||
git+https://github.com/manuelcortez/vk_api
|
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
name = "Socializer"
|
||||
version = "0.20"
|
||||
version = "0.23"
|
||||
author = "Manuel Cortez"
|
||||
authorEmail = "manuel@manuelcortez.net"
|
||||
copyright = "Copyright (C) 2016-2019, Manuel Cortez"
|
||||
|
@@ -55,11 +55,12 @@ def get_non_refreshed(login, password, scope=scope):
|
||||
url = "https://oauth.vk.com/token"
|
||||
params = dict(grant_type="password",
|
||||
client_id=client_id, client_secret=client_secret, username=login,
|
||||
password=password, v=api_ver, scope=scope, lang="en", device_id=device_id)
|
||||
password=password, v=api_ver, scope=scope, lang="en", device_id=device_id, force_sms=1)
|
||||
# Add two factor auth later due to python's syntax.
|
||||
params["2fa_supported"] = 1
|
||||
headers = {'User-Agent': user_agent}
|
||||
r = requests.get(url, params=params, headers=headers)
|
||||
log.exception(r.json())
|
||||
# If a 401 error is raised, we need to use 2FA here.
|
||||
# see https://vk.com/dev/auth_direct (switch lang to russian, english docs are very incomplete in the matter)
|
||||
# ToDo: this needs testing after implemented official VK tokens.
|
||||
|
@@ -4,24 +4,14 @@ import time
|
||||
import wx
|
||||
import widgetUtils
|
||||
|
||||
code = None
|
||||
remember = True
|
||||
|
||||
def two_factor_auth():
|
||||
global code, remember
|
||||
wx.CallAfter(get_code)
|
||||
while code == None:
|
||||
time.sleep(0.5)
|
||||
return (code, remember)
|
||||
|
||||
def get_code():
|
||||
global code, remember
|
||||
code = None
|
||||
dlg = wx.TextEntryDialog(None, _("Please provide the authentication code you have received from VK."), _("Two factor authentication code"))
|
||||
response = dlg.ShowModal()
|
||||
if response == widgetUtils.OK:
|
||||
code = dlg.GetValue()
|
||||
dlg.Destroy()
|
||||
dlg.Destroy()
|
||||
return (code, True)
|
||||
|
||||
def bad_password():
|
||||
return wx.MessageDialog(None, _("Your password or email address are incorrect. Please fix the mistakes and try it again."), _("Wrong data"), wx.ICON_ERROR).ShowModal()
|
@@ -19,6 +19,7 @@ from requests.exceptions import ReadTimeout, ConnectionError
|
||||
from mutagen.id3 import ID3
|
||||
from presenters import player
|
||||
from wxUI.tabs import home
|
||||
from wxUI.dialogs import timeline
|
||||
from sessionmanager import session, renderers, utils
|
||||
from mysc.thread_utils import call_threaded
|
||||
from wxUI import commonMessages, menus
|
||||
@@ -78,8 +79,11 @@ 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)
|
||||
self.tab.list.insert_item(reversed, *item_)
|
||||
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):
|
||||
""" Retrieve items from the VK API. This function is called repeatedly by the main controller and users could call it implicitly as well with the update buffer option.
|
||||
@@ -104,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):
|
||||
@@ -122,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"""
|
||||
@@ -304,11 +253,7 @@ class baseBuffer(object):
|
||||
|
||||
def get_event(self, ev):
|
||||
""" Parses keyboard input in the ListCtrl and executes the event associated with user keypresses."""
|
||||
if ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown() and ev.ShiftDown(): event = "pause_audio"
|
||||
elif ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown(): event = "play_audio"
|
||||
elif ev.GetKeyCode() == wx.WXK_RETURN: event = "open_post"
|
||||
elif ev.GetKeyCode() == wx.WXK_F5: event = "volume_down"
|
||||
elif ev.GetKeyCode() == wx.WXK_F6: event = "volume_up"
|
||||
if ev.GetKeyCode() == wx.WXK_RETURN: event = "open_post"
|
||||
else:
|
||||
event = None
|
||||
ev.Skip()
|
||||
@@ -377,7 +322,7 @@ class baseBuffer(object):
|
||||
else:
|
||||
return [post["source_id"]]
|
||||
|
||||
def onFocus(self, *args,**kwargs):
|
||||
def onFocus(self, event, *args,**kwargs):
|
||||
""" Function executed when the item in a list is selected.
|
||||
For this buffer it updates the date of posts in the list."""
|
||||
post = self.get_post()
|
||||
@@ -386,6 +331,7 @@ class baseBuffer(object):
|
||||
original_date = arrow.get(post["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
self.tab.list.list.SetItem(self.tab.list.get_selected(), 2, created_at)
|
||||
event.Skip()
|
||||
|
||||
def open_in_browser(self, *args, **kwargs):
|
||||
post = self.get_post()
|
||||
@@ -419,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):
|
||||
@@ -467,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()
|
||||
@@ -478,12 +428,15 @@ class feedBuffer(baseBuffer):
|
||||
|
||||
class communityBuffer(feedBuffer):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(communityBuffer, self).__init__(*args, **kwargs)
|
||||
self.group_id = self.kwargs["owner_id"]
|
||||
|
||||
def create_tab(self, parent):
|
||||
self.tab = home.communityTab(parent)
|
||||
self.connect_events()
|
||||
self.tab.name = self.name
|
||||
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
|
||||
self.tab.post.Enable(False)
|
||||
self.tab.post.Enable(False)
|
||||
|
||||
def connect_events(self):
|
||||
super(communityBuffer, self).connect_events()
|
||||
@@ -499,21 +452,45 @@ class communityBuffer(feedBuffer):
|
||||
""" This method retrieves community information, useful to show different parts of the community itself."""
|
||||
if self.can_get_items:
|
||||
# Strangely, groups.get does not return counters so we need those to show options for loading specific posts for communities.
|
||||
self.group_info = self.session.vk.client.groups.getById(group_ids=-1*self.kwargs["owner_id"], fields="counters")[0]
|
||||
# print(self.group_info["counters"])
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*self.kwargs["owner_id"], fields="counters")[0]
|
||||
self.session.db["group_info"][self.group_id].update(group_info)
|
||||
if "can_post" in self.session.db["group_info"][self.group_id] and self.session.db["group_info"][self.group_id]["can_post"] == True:
|
||||
self.tab.post.Enable(True)
|
||||
super(communityBuffer, self).get_items(*args, **kwargs)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
menu = wx.Menu()
|
||||
user1 = self.session.get_user(self.session.user_id)
|
||||
user2 = self.session.get_user(self.kwargs["owner_id"])
|
||||
user = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user1))
|
||||
group = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user2))
|
||||
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 1), group)
|
||||
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 0), user)
|
||||
self.tab.post.PopupMenu(menu, self.tab.post.GetPosition())
|
||||
|
||||
def _post(self, event, from_group):
|
||||
owner_id = self.kwargs["owner_id"]
|
||||
user = self.session.get_user(owner_id, key="user1")
|
||||
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"):
|
||||
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):
|
||||
|
||||
def create_tab(self, parent):
|
||||
self.tab = home.topicTab(parent)
|
||||
self.connect_events()
|
||||
self.tab.name = self.name
|
||||
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
|
||||
if "can_create_topic" not in self.session.db["group_info"][self.kwargs["group_id"]*-1] or ("can_create_topic" in self.session.db["group_info"][self.kwargs["group_id"]*-1] and self.session.db["group_info"][self.kwargs["group_id"]*-1]["can_create_topic"] != True):
|
||||
self.tab.post.Enable(False)
|
||||
|
||||
def onFocus(self, *args, **kwargs):
|
||||
pass
|
||||
def onFocus(self, event, *args, **kwargs):
|
||||
event.Skip()
|
||||
|
||||
def open_post(self, *args, **kwargs):
|
||||
""" Opens the currently focused post."""
|
||||
@@ -524,7 +501,6 @@ class topicBuffer(feedBuffer):
|
||||
|
||||
def open_in_browser(self, *args, **kwargs):
|
||||
post = self.get_post()
|
||||
print(post)
|
||||
if post == None:
|
||||
return
|
||||
# In order to load the selected topic we firstly have to catch the group_id, which is present in self.kwargs
|
||||
@@ -533,6 +509,30 @@ class topicBuffer(feedBuffer):
|
||||
url = "https://vk.com/topic{group_id}_{topic_id}".format(group_id=group_id, topic_id=post["id"])
|
||||
webbrowser.open_new_tab(url)
|
||||
|
||||
def post(self, *args, **kwargs):
|
||||
menu = wx.Menu()
|
||||
user1 = self.session.get_user(self.session.user_id)
|
||||
user2 = self.session.get_user(-1*self.kwargs["group_id"])
|
||||
user = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user1))
|
||||
group = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user2))
|
||||
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 1), group)
|
||||
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 0), user)
|
||||
self.tab.post.PopupMenu(menu, self.tab.post.GetPosition())
|
||||
|
||||
def _post(self, event, from_group):
|
||||
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="", topic_title=""))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
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
|
||||
|
||||
@@ -543,13 +543,14 @@ class documentBuffer(feedBuffer):
|
||||
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
|
||||
self.tab.post.Enable(False)
|
||||
|
||||
def onFocus(self, *args,**kwargs):
|
||||
def onFocus(self, event, *args,**kwargs):
|
||||
post = self.get_post()
|
||||
if post == None:
|
||||
return
|
||||
original_date = arrow.get(post["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
self.tab.list.list.SetItem(self.tab.list.get_selected(), 4, created_at)
|
||||
event.Skip()
|
||||
|
||||
def connect_events(self):
|
||||
super(documentBuffer, self).connect_events()
|
||||
@@ -619,9 +620,6 @@ class documentCommunityBuffer(documentBuffer):
|
||||
self.tab.post.Enable(False)
|
||||
|
||||
class audioBuffer(feedBuffer):
|
||||
""" this buffer was supposed to be used with audio elements
|
||||
but is deprecated as VK removed its audio support for third party apps."""
|
||||
|
||||
def create_tab(self, parent):
|
||||
self.tab = home.audioTab(parent)
|
||||
self.tab.name = self.name
|
||||
@@ -629,16 +627,38 @@ class audioBuffer(feedBuffer):
|
||||
if self.name == "me_audio":
|
||||
self.tab.post.Enable(True)
|
||||
|
||||
def get_event(self, ev):
|
||||
if ev.GetKeyCode() == wx.WXK_RETURN:
|
||||
if len(self.tab.list.get_multiple_selection()) < 2:
|
||||
event = "play_all"
|
||||
else:
|
||||
event = "play_audio"
|
||||
else:
|
||||
event = None
|
||||
ev.Skip()
|
||||
if event != None:
|
||||
try:
|
||||
getattr(self, event)(skip_pause=True)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
def connect_events(self):
|
||||
widgetUtils.connect_event(self.tab.play, widgetUtils.BUTTON_PRESSED, self.play_audio)
|
||||
widgetUtils.connect_event(self.tab.play_all, widgetUtils.BUTTON_PRESSED, self.play_all)
|
||||
pub.subscribe(self.change_label, "playback-changed")
|
||||
super(audioBuffer, self).connect_events()
|
||||
|
||||
def play_audio(self, *args, **kwargs):
|
||||
selected = self.tab.list.get_selected()
|
||||
if selected == -1:
|
||||
selected = 0
|
||||
pub.sendMessage("play", object=self.session.db[self.name]["items"][selected])
|
||||
if player.player.check_is_playing() and not "skip_pause" in kwargs:
|
||||
return pub.sendMessage("pause")
|
||||
selected = self.tab.list.get_multiple_selection()
|
||||
if len(selected) == 0:
|
||||
return
|
||||
elif len(selected) == 1:
|
||||
pub.sendMessage("play", object=self.session.db[self.name]["items"][selected[0]])
|
||||
else:
|
||||
selected_audios = [self.session.db[self.name]["items"][item] for item in selected]
|
||||
pub.sendMessage("play-all", list_of_songs=selected_audios)
|
||||
return True
|
||||
|
||||
def play_next(self, *args, **kwargs):
|
||||
@@ -661,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):
|
||||
@@ -696,48 +716,105 @@ class audioBuffer(feedBuffer):
|
||||
# Translators: Some buffers can't use the get previous item feature due to API limitations.
|
||||
output.speak(_("This buffer doesn't support getting more items."))
|
||||
|
||||
def onFocus(self, *args, **kwargs):
|
||||
pass
|
||||
def onFocus(self, event, *args, **kwargs):
|
||||
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()
|
||||
@@ -749,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)
|
||||
@@ -778,6 +855,16 @@ class audioBuffer(feedBuffer):
|
||||
url = "https://vk.com/audio{user_id}_{post_id}".format(user_id=post["owner_id"], post_id=post["id"])
|
||||
webbrowser.open_new_tab(url)
|
||||
|
||||
def change_label(self, stopped):
|
||||
if hasattr(self.tab, "play"):
|
||||
if stopped == False:
|
||||
self.tab.play.SetLabel(_("P&ause"))
|
||||
else:
|
||||
self.tab.play.SetLabel(_("P&lay"))
|
||||
|
||||
def __del__(self):
|
||||
pub.unsubscribe(self.change_label, "playback-changed")
|
||||
|
||||
class audioAlbum(audioBuffer):
|
||||
""" this buffer was supposed to be used with audio albums
|
||||
but is deprecated as VK removed its audio support for third party apps."""
|
||||
@@ -852,8 +939,8 @@ class videoBuffer(feedBuffer):
|
||||
# Translators: Some buffers can't use the get previous item feature due to API limitations.
|
||||
output.speak(_("This buffer doesn't support getting more items."))
|
||||
|
||||
def onFocus(self, *args, **kwargs):
|
||||
pass
|
||||
def onFocus(self, event, *args, **kwargs):
|
||||
event.Skip()
|
||||
|
||||
def add_to_library(self, *args, **kwargs):
|
||||
post = self.get_post()
|
||||
@@ -903,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)
|
||||
@@ -1056,9 +1143,9 @@ class chatBuffer(baseBuffer):
|
||||
if show_nextpage == False:
|
||||
if self.tab.history.GetValue() != "" and num > 0:
|
||||
v = [i for i in self.session.db[self.name]["items"][:num]]
|
||||
[self.insert(i, False) for i in v]
|
||||
[wx.CallAfter(self.insert, i, False) 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:
|
||||
# At this point we save more CPU and mathematical work if we just delete everything in the chat history and readd all messages.
|
||||
@@ -1068,7 +1155,7 @@ class chatBuffer(baseBuffer):
|
||||
self.chats = dict()
|
||||
self.tab.history.SetValue("")
|
||||
v = [i for i in self.session.db[self.name]["items"]]
|
||||
[self.insert(i) for i in v]
|
||||
[wx.CallAfter(self.insert, i) for i in v]
|
||||
# Now it's time to set back the focus in the post.
|
||||
for i in self.chats.keys():
|
||||
if self.chats[i] == focused_post["id"]:
|
||||
@@ -1095,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)
|
||||
@@ -1174,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)
|
||||
@@ -1186,8 +1224,7 @@ class chatBuffer(baseBuffer):
|
||||
a = presenters.displayAudioPresenter(session=self.session, postObject=[attachment["audio"]], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
|
||||
elif attachment["type"] == "audio_message":
|
||||
link = attachment["audio_message"]["link_mp3"]
|
||||
output.speak(_("Playing..."))
|
||||
pub.sendMessage("play", object=dict(url=link), set_info=False)
|
||||
pub.sendMessage("play-message", message_url=link)
|
||||
elif attachment["type"] == "link":
|
||||
output.speak(_("Opening URL..."), True)
|
||||
webbrowser.open_new_tab(attachment["link"]["url"])
|
||||
@@ -1217,6 +1254,8 @@ class chatBuffer(baseBuffer):
|
||||
break
|
||||
if url != "":
|
||||
webbrowser.open_new_tab(url)
|
||||
if attachment["type"] == "wall":
|
||||
pub.sendMessage("open-post", post_object=attachment["wall"], controller_="displayPost")
|
||||
else:
|
||||
log.debug("Unhandled attachment: %r" % (attachment,))
|
||||
|
||||
@@ -1244,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()
|
||||
@@ -1266,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()
|
||||
@@ -1279,7 +1337,14 @@ class peopleBuffer(feedBuffer):
|
||||
self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, online_status)
|
||||
|
||||
def open_timeline(self, *args, **kwargs):
|
||||
pass
|
||||
user = self.get_post()
|
||||
if user == None:
|
||||
return
|
||||
a = timeline.timelineDialog([self.session.get_user(user["id"])["user1_gen"]], show_selector=False)
|
||||
if a.get_response() == widgetUtils.OK:
|
||||
buffer_type = a.get_buffer_type()
|
||||
user_id = user["id"]
|
||||
pub.sendMessage("create-timeline", user_id=user_id, buffer_type=buffer_type)
|
||||
|
||||
def get_menu(self, *args, **kwargs):
|
||||
""" display menu for people buffers (friends and requests)"""
|
||||
@@ -1297,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)
|
||||
@@ -1330,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
|
||||
|
||||
@@ -1424,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):
|
||||
@@ -1471,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()
|
||||
|
||||
@@ -144,17 +171,14 @@ class Controller(object):
|
||||
log.error("Error in setting offline status for the current user")
|
||||
|
||||
def create_unread_messages(self):
|
||||
if self.session.settings["chat"]["open_unread_conversations"] == False:
|
||||
return
|
||||
try:
|
||||
log.debug("Getting possible unread messages.")
|
||||
log.debug("Creating conversation buffers...")
|
||||
msgs = self.session.vk.client.messages.getConversations(count=200)
|
||||
except VkApiError as ex:
|
||||
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:
|
||||
@@ -168,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:
|
||||
@@ -179,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:
|
||||
@@ -200,27 +222,28 @@ class Controller(object):
|
||||
if self.session.settings["load_at_startup"]["communities"] == False and force_action == False:
|
||||
return
|
||||
log.debug("Create community buffers...")
|
||||
groups= self.session.vk.client.groups.get(user_id=user_id, extended=1, count=1000)
|
||||
groups= self.session.vk.client.groups.get(user_id=user_id, extended=1, count=1000, fields="can_post,can_create_topic")
|
||||
self.session.groups=groups["items"]
|
||||
# Let's feed the local database cache with new groups coming from here.
|
||||
data= dict(profiles=[], groups=self.session.groups)
|
||||
self.session.process_usernames(data)
|
||||
if create_buffers:
|
||||
for i in self.session.groups:
|
||||
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)
|
||||
self.session.db["group_info"][i["id"]*-1] = i
|
||||
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)
|
||||
@@ -282,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")
|
||||
@@ -296,6 +320,7 @@ class Controller(object):
|
||||
pub.subscribe(self.create_buffer, "create_buffer")
|
||||
pub.subscribe(self.user_typing, "user-typing")
|
||||
pub.subscribe(self.get_chat, "order-sent-message")
|
||||
pub.subscribe(self.create_timeline, "create-timeline")
|
||||
|
||||
def disconnect_events(self):
|
||||
log.debug("Disconnecting some events...")
|
||||
@@ -307,16 +332,66 @@ class Controller(object):
|
||||
pub.unsubscribe(self.user_online, "user-online")
|
||||
pub.unsubscribe(self.user_offline, "user-offline")
|
||||
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.
|
||||
@@ -339,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.
|
||||
@@ -362,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)
|
||||
@@ -389,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"]:
|
||||
@@ -407,21 +481,20 @@ 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]
|
||||
online_buffer.add_person(user)
|
||||
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")
|
||||
online_friends.remove_person(event.user_id)
|
||||
wx.CallAfter(online_friends.remove_person, event.user_id)
|
||||
|
||||
def notify(self, message="", sound="", type="native"):
|
||||
""" display a notification in Socializer.
|
||||
@@ -448,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.
|
||||
@@ -509,7 +582,7 @@ class Controller(object):
|
||||
# Let's add this to the buffer.
|
||||
# ToDo: Clean this code and test how is the database working with this set to True.
|
||||
buffer.session.db[buffer.name]["items"].append(message)
|
||||
buffer.insert(self.session.db[buffer.name]["items"][-1], False)
|
||||
wx.CallAfter(buffer.insert, self.session.db[buffer.name]["items"][-1], False)
|
||||
self.session.soundplayer.play("message_received.ogg")
|
||||
wx.CallAfter(self.reorder_buffer, buffer)
|
||||
# Check if we have to read the message aloud
|
||||
@@ -517,13 +590,38 @@ class Controller(object):
|
||||
rendered_message = renderers.render_message(message, self.session)
|
||||
output.speak(rendered_message[0])
|
||||
|
||||
def create_timeline(self, user_id, buffer_type, user=""):
|
||||
if user_id == "":
|
||||
user_data = self.session.vk.client.utils.resolveScreenName(screen_name=user)
|
||||
if type(user_data) == list:
|
||||
commonMessages.no_user_exist()
|
||||
return
|
||||
user_id = user_data["object_id"]
|
||||
if buffer_type == "audio":
|
||||
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, create_tab=False, endpoint="get", parent_endpoint="audio", owner_id=user_id)
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
name_ = _("{user1_nom}'s audios").format(**user)
|
||||
elif buffer_type == "wall":
|
||||
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")
|
||||
name_ = _("{user1_nom}'s friends").format(**user)
|
||||
wx.CallAfter(self.complete_buffer_creation, buffer=buffer, name_=name_, position=self.window.search("timelines"))
|
||||
|
||||
### GUI events
|
||||
# These functions are connected to GUI elements such as menus, buttons and so on.
|
||||
def connect_gui_events(self):
|
||||
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.window.about_dialog, menuitem=self.window.about)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_about, menuitem=self.window.about)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_audios, menuitem=self.window.search_audios)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_videos, menuitem=self.window.search_videos)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU,self.remove_buffer, menuitem=self.window.remove_buffer_)
|
||||
@@ -531,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)
|
||||
@@ -574,6 +674,10 @@ class Controller(object):
|
||||
if update == False:
|
||||
commonMessages.no_update_available()
|
||||
|
||||
def on_about(self, *args, **kwargs):
|
||||
channel = self.session.settings["general"]["update_channel"]
|
||||
self.window.about_dialog(channel)
|
||||
|
||||
def search_audios(self, *args, **kwargs):
|
||||
dlg = searchDialogs.searchAudioDialog()
|
||||
if dlg.get_response() == widgetUtils.OK:
|
||||
@@ -626,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()])
|
||||
|
||||
@@ -656,25 +773,7 @@ class Controller(object):
|
||||
for i in d:
|
||||
if i[1] == user:
|
||||
user_id = i[0]
|
||||
if user_id == "":
|
||||
user_data = self.session.vk.client.utils.resolveScreenName(screen_name=user)
|
||||
if type(user_data) == list:
|
||||
commonMessages.no_user_exist()
|
||||
return
|
||||
user_id = user_data["object_id"]
|
||||
if buffertype == "audio":
|
||||
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, create_tab=False, endpoint="get", parent_endpoint="audio", owner_id=user_id)
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
name_ = _("{user1_nom}'s audios").format(**user)
|
||||
elif buffertype == "wall":
|
||||
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 buffertype == "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")
|
||||
name_ = _("{user1_nom}'s friends").format(**user)
|
||||
wx.CallAfter(self.complete_buffer_creation, buffer=buffer, name_=name_, position=self.window.search("timelines"))
|
||||
pub.sendMessage("create-timeline", user_id=user_id, buffer_type=buffertype)
|
||||
|
||||
def create_audio_album(self, *args, **kwargs):
|
||||
d = creation.audio_album()
|
||||
@@ -770,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)
|
||||
@@ -821,19 +923,19 @@ class Controller(object):
|
||||
# 2. If the group_info does not have counters for such items, which would indicate there are no items posted yet.
|
||||
if self.search(current_buffer.name+"_audios") != False:
|
||||
menu.load_audios.Enable(False)
|
||||
elif hasattr(current_buffer, "group_info") and "audios" not in current_buffer.group_info["counters"]:
|
||||
elif "counters" in self.session.db["group_info"][current_buffer.group_id] and "audios" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
|
||||
menu.load_audios.Enable(False)
|
||||
if self.search(current_buffer.name+"_videos") != False:
|
||||
menu.load_videos.Enable(False)
|
||||
elif hasattr(current_buffer, "group_info") and "videos" not in current_buffer.group_info["counters"]:
|
||||
elif "counters" in self.session.db["group_info"][current_buffer.group_id] and "videos" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
|
||||
menu.load_videos.Enable(False)
|
||||
if self.search(current_buffer.name+"_topics") != False:
|
||||
menu.load_topics.Enable(False)
|
||||
elif hasattr(current_buffer, "group_info") and "topics" not in current_buffer.group_info["counters"]:
|
||||
elif "counters" in self.session.db["group_info"][current_buffer.group_id] and "topics" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
|
||||
menu.load_topics.Enable(False)
|
||||
if self.search(current_buffer.name+"_documents") != False:
|
||||
menu.load_documents.Enable(False)
|
||||
elif hasattr(current_buffer, "group_info") and "docs" not in current_buffer.group_info["counters"]:
|
||||
elif "counters" in self.session.db["group_info"][current_buffer.group_id] and "docs" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
|
||||
menu.load_documents.Enable(False)
|
||||
# Connect the rest of the functions.
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_posts, menuitem=menu.load_posts)
|
||||
@@ -888,52 +990,52 @@ class Controller(object):
|
||||
""" Load community audios if they are not loaded already."""
|
||||
current_buffer = self.get_current_buffer()
|
||||
# Get group_info if the community buffer does not have it already, so future menus will be able to use it.
|
||||
if not hasattr(current_buffer, "group_info"):
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0]
|
||||
current_buffer.group_info = group_info
|
||||
if "audios" not in current_buffer.group_info["counters"]:
|
||||
if current_buffer.group_id not in self.session.db["group_info"] or "counters" not in self.session.db["group_info"][current_buffer.group_id]:
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters,can_create_topics,can_post")[0]
|
||||
self.session.db["group_info"][current_buffer.kwargs["owner_id"]].update(group_info)
|
||||
if "audios" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
|
||||
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."""
|
||||
current_buffer = self.get_current_buffer()
|
||||
# Get group_info if the community buffer does not have it already, so future menus will be able to use it.
|
||||
if not hasattr(current_buffer, "group_info"):
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0]
|
||||
current_buffer.group_info = group_info
|
||||
if "videos" not in current_buffer.group_info["counters"]:
|
||||
if current_buffer.group_id not in self.session.db["group_info"] or "counters" not in self.session.db["group_info"][current_buffer.group_id]:
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters,can_create_topics,can_post")[0]
|
||||
self.session.db["group_info"][current_buffer.kwargs["owner_id"]].update(group_info)
|
||||
if "videos" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
|
||||
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."""
|
||||
current_buffer = self.get_current_buffer()
|
||||
# Get group_info if the community buffer does not have it already, so future menus will be able to use it.
|
||||
if not hasattr(current_buffer, "group_info"):
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0]
|
||||
current_buffer.group_info = group_info
|
||||
if "topics" not in current_buffer.group_info["counters"]:
|
||||
if current_buffer.group_id not in self.session.db["group_info"] or "counters" not in self.session.db["group_info"][current_buffer.group_id]:
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters,can_create_topic,can_post")[0]
|
||||
self.session.db["group_info"][current_buffer.kwargs["owner_id"]].update(group_info)
|
||||
if "topics" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
|
||||
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()
|
||||
# Get group_info if the community buffer does not have it already, so future menus will be able to use it.
|
||||
if not hasattr(current_buffer, "group_info"):
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0]
|
||||
current_buffer.group_info = group_info
|
||||
if "docs" not in current_buffer.group_info["counters"]:
|
||||
if current_buffer.group_id not in self.session.db["group_info"] or "counters" not in self.session.db["group_info"][current_buffer.group_id]:
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters,can_create_topics,can_post")[0]
|
||||
self.session.db["group_info"][current_buffer.kwargs["owner_id"]].update(group_info)
|
||||
if "docs" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
|
||||
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.20_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.20"
|
||||
VIAddVersionKey FileVersion "0.20"
|
||||
VIProductVersion "0.20.0.0"
|
||||
VIFileVersion "0.20.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.20"
|
||||
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"]:
|
||||
@@ -59,8 +60,6 @@ class configurationInteractor(base.baseInteractor):
|
||||
self.presenter.update_setting(section="general", setting="update_channel", value=update_channel)
|
||||
self.presenter.update_setting(section="chat", setting="notify_online", value=self.view.get_value("chat", "notify_online"))
|
||||
self.presenter.update_setting(section="chat", setting="notify_offline", value=self.view.get_value("chat", "notify_offline"))
|
||||
self.presenter.update_setting(section="chat", setting="open_unread_conversations", value=self.view.get_value("chat", "open_unread_conversations"))
|
||||
self.presenter.update_setting(section="chat", setting="automove_to_conversations", value=self.view.get_value("chat", "automove_to_conversations"))
|
||||
self.presenter.update_setting(section="chat", setting="notifications", value=self.presenter.get_notification_type(self.view.get_value("chat", "notifications")))
|
||||
self.presenter.update_setting(section="load_at_startup", setting="audio_albums", value=self.view.get_value("startup", "audio_albums"))
|
||||
self.presenter.update_setting(section="load_at_startup", setting="video_albums", value=self.view.get_value("startup", "video_albums"))
|
||||
|
@@ -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:
|
||||
@@ -171,6 +172,13 @@ class displayAudioInteractor(base.baseInteractor):
|
||||
getattr(self.view, control).Append(i)
|
||||
getattr(self.view, control).SetSelection(0)
|
||||
|
||||
def change_label(self, stopped):
|
||||
|
||||
if stopped == False:
|
||||
self.view.play.SetLabel(_("P&ause"))
|
||||
else:
|
||||
self.view.play.SetLabel(_("P&lay"))
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(displayAudioInteractor, self).install(*args, **kwargs)
|
||||
widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_CHANGED, self.on_change)
|
||||
@@ -180,11 +188,13 @@ class displayAudioInteractor(base.baseInteractor):
|
||||
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_from_library)
|
||||
pub.subscribe(self.set, self.modulename+"_set")
|
||||
pub.subscribe(self.add_items, self.modulename+"_add_items")
|
||||
pub.subscribe(self.change_label, "playback-changed")
|
||||
|
||||
def uninstall(self):
|
||||
super(displayAudioInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.set, self.modulename+"_set")
|
||||
pub.unsubscribe(self.add_items, self.modulename+"_add_items")
|
||||
pub.unsubscribe(self.change_label, "playback-changed")
|
||||
|
||||
def on_change(self, *args, **kwargs):
|
||||
post = self.view.get_audio()
|
||||
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -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,16 +51,16 @@ 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"])
|
||||
self.send_message("set", tab="chat", setting="open_unread_conversations", value=self.session.settings["chat"]["open_unread_conversations"])
|
||||
self.send_message("set", tab="chat", setting="automove_to_conversations", value=self.session.settings["chat"]["automove_to_conversations"])
|
||||
self.send_message("set", tab="chat", setting="notifications", value=self.get_notification_label(self.session.settings["chat"]["notifications"]))
|
||||
self.send_message("create_tab", tab="startup_options")
|
||||
self.send_message("set", tab="startup", setting="audio_albums", value=self.session.settings["load_at_startup"]["audio_albums"])
|
||||
|
@@ -3,7 +3,7 @@ import logging
|
||||
from sessionmanager import utils
|
||||
from pubsub import pub
|
||||
from mysc.thread_utils import call_threaded
|
||||
from presenters import base
|
||||
from presenters import base, player
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
@@ -82,6 +82,8 @@ class displayAudioPresenter(base.basePresenter):
|
||||
|
||||
def play(self, audio_index):
|
||||
post = self.post[audio_index]
|
||||
if player.player.check_is_playing() == True:
|
||||
return pub.sendMessage("stop")
|
||||
pub.sendMessage("play", object=post)
|
||||
|
||||
def load_audios(self):
|
||||
|
@@ -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,28 +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)
|
||||
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.
|
||||
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]
|
||||
@@ -138,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):
|
||||
@@ -171,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")))
|
@@ -3,6 +3,7 @@
|
||||
As this player does not have (still) an associated GUI, I have decided to place here the code for the interactor, which connects a bunch of pubsub events, and the presenter itself.
|
||||
"""
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import logging
|
||||
import sound_lib
|
||||
@@ -19,7 +20,6 @@ from sessionmanager import utils
|
||||
player = None
|
||||
log = logging.getLogger("player")
|
||||
|
||||
# This function will be deprecated when the player works with pubsub events, as will no longer be needed to instantiate and import the player directly.
|
||||
def setup():
|
||||
global player
|
||||
if player == None:
|
||||
@@ -34,6 +34,7 @@ class audioPlayer(object):
|
||||
self.is_playing = False
|
||||
# This will be the URLStream handler
|
||||
self.stream = None
|
||||
self.message = None
|
||||
self.vol = config.app["sound"]["volume"]
|
||||
# this variable is set to true when the URLPlayer is decoding something, thus it will block other calls to the play method.
|
||||
self.is_working = False
|
||||
@@ -41,13 +42,18 @@ class audioPlayer(object):
|
||||
self.queue = []
|
||||
# Index of the currently playing track.
|
||||
self.playing_track = 0
|
||||
self.playing_all = False
|
||||
self.worker = RepeatingTimer(5, self.player_function)
|
||||
self.worker.start()
|
||||
# Status of the player.
|
||||
self.stopped = True
|
||||
# Modify some default settings present in Bass so it will increase timeout connection, thus causing less "connection timed out" errors when playing.
|
||||
bassconfig = BassConfig()
|
||||
# Set timeout connection to 30 seconds.
|
||||
bassconfig["net_timeout"] = 30000
|
||||
# subscribe all pubsub events.
|
||||
pub.subscribe(self.play, "play")
|
||||
pub.subscribe(self.play_message, "play-message")
|
||||
pub.subscribe(self.play_all, "play-all")
|
||||
pub.subscribe(self.pause, "pause")
|
||||
pub.subscribe(self.stop, "stop")
|
||||
@@ -55,6 +61,18 @@ class audioPlayer(object):
|
||||
pub.subscribe(self.play_previous, "play-previous")
|
||||
pub.subscribe(self.seek, "seek")
|
||||
|
||||
# Stopped has a special function here, hence the decorator
|
||||
# when stopped will be set to True, it will send a pubsub event to inform other parts of the application about the status change.
|
||||
# this is useful for changing labels between play and pause, and so on, in buttons.
|
||||
@property
|
||||
def stopped(self):
|
||||
return self._stopped
|
||||
|
||||
@stopped.setter
|
||||
def stopped(self, value):
|
||||
self._stopped = value
|
||||
pub.sendMessage("playback-changed", stopped=value)
|
||||
|
||||
def play(self, object, set_info=True, fresh=False):
|
||||
""" Play an URl Stream.
|
||||
@object dict: typically an audio object as returned by VK, with a "url" component which must be a valid URL to a media file.
|
||||
@@ -70,9 +88,7 @@ class audioPlayer(object):
|
||||
log.exception("error when stopping the file")
|
||||
self.stream = None
|
||||
self.stopped = True
|
||||
if fresh == True and hasattr(self, "worker") and self.worker != None:
|
||||
self.worker.cancel()
|
||||
self.worker = None
|
||||
if fresh == True:
|
||||
self.queue = []
|
||||
# Make sure that there are no other sounds trying to be played.
|
||||
if self.is_working == False:
|
||||
@@ -94,16 +110,41 @@ class audioPlayer(object):
|
||||
self.stopped = False
|
||||
self.is_working = False
|
||||
|
||||
def play_message(self, message_url):
|
||||
if self.message != None and (self.message.is_playing == True or self.message.is_stalled == True):
|
||||
return self.stop_message()
|
||||
output.speak(_("Playing..."))
|
||||
url_ = utils.transform_audio_url(message_url)
|
||||
url_ = bytes(url_, "utf-8")
|
||||
try:
|
||||
self.message = URLStream(url=url_)
|
||||
except:
|
||||
log.error("Unable to play URL %s" % (url_))
|
||||
return
|
||||
self.message.volume = self.vol/100.0
|
||||
self.message.play()
|
||||
volume_percent = self.volume*0.25
|
||||
volume_step = self.volume*0.15
|
||||
while self.stream.volume*100 > volume_percent:
|
||||
self.stream.volume = self.stream.volume-(volume_step/100)
|
||||
time.sleep(0.1)
|
||||
|
||||
def stop(self):
|
||||
""" Stop audio playback. """
|
||||
if self.stream != None and self.stream.is_playing == True:
|
||||
self.stream.stop()
|
||||
self.stopped = True
|
||||
if hasattr(self, "worker") and self.worker != None:
|
||||
self.worker.cancel()
|
||||
self.worker = None
|
||||
self.queue = []
|
||||
|
||||
def stop_message(self):
|
||||
if hasattr(self, "message") and self.message != None and self.message.is_playing == True:
|
||||
self.message.stop()
|
||||
volume_step = self.volume*0.15
|
||||
while self.stream.volume*100 < self.volume:
|
||||
self.stream.volume = self.stream.volume+(volume_step/100)
|
||||
time.sleep(0.1)
|
||||
self.message = None
|
||||
|
||||
def pause(self):
|
||||
""" pause the current playback, without destroying the queue or the current stream. If the stream is already paused this function will resume the playback. """
|
||||
if self.stream != None:
|
||||
@@ -116,6 +157,8 @@ class audioPlayer(object):
|
||||
self.stopped = False
|
||||
except BassError:
|
||||
pass
|
||||
if self.playing_all == False and len(self.queue) > 0:
|
||||
self.playing_all = True
|
||||
|
||||
@property
|
||||
def volume(self):
|
||||
@@ -130,7 +173,11 @@ class audioPlayer(object):
|
||||
elif vol > 100:
|
||||
self.vol = 100
|
||||
if self.stream != None:
|
||||
self.stream.volume = self.vol/100.0
|
||||
if self.message != None and self.message.is_playing:
|
||||
self.stream.volume = (self.vol*0.25)/100.0
|
||||
self.message.volume = self.vol/100.0
|
||||
else:
|
||||
self.stream.volume = self.vol/100.0
|
||||
|
||||
def play_all(self, list_of_songs, shuffle=False):
|
||||
""" Play all passed songs and adds all of those to the queue.
|
||||
@@ -145,16 +192,24 @@ class audioPlayer(object):
|
||||
if shuffle:
|
||||
random.shuffle(self.queue)
|
||||
call_threaded(self.play, self.queue[self.playing_track])
|
||||
self.worker = RepeatingTimer(5, self.player_function)
|
||||
self.worker.start()
|
||||
self.playing_all = True
|
||||
|
||||
def player_function(self):
|
||||
""" 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 != 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:
|
||||
if len(self.queue) == 0 or self.playing_track >= len(self.queue):
|
||||
self.worker.cancel()
|
||||
if self.playing_track >= len(self.queue):
|
||||
self.stopped = True
|
||||
self.playing_all = False
|
||||
return
|
||||
if self.playing_track < len(self.queue):
|
||||
elif self.playing_all == False:
|
||||
self.stopped = True
|
||||
return
|
||||
elif self.playing_track < len(self.queue):
|
||||
self.playing_track += 1
|
||||
self.play(self.queue[self.playing_track])
|
||||
|
||||
|
@@ -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,15 +13,14 @@ 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)
|
||||
notify_offline = boolean(default=True)
|
||||
open_unread_conversations = boolean(default=True)
|
||||
automove_to_conversations = boolean(default=False)
|
||||
notifications = string(default="custom")
|
||||
|
||||
[load_at_startup]
|
||||
|
@@ -75,6 +75,14 @@ def add_attachment(attachment):
|
||||
elif attachment["type"] == "poll":
|
||||
tpe = _("Poll")
|
||||
msg = attachment["poll"]["question"]
|
||||
elif attachment["type"] == "wall":
|
||||
tpe = _("Post")
|
||||
user = attachment["wall"]["from"]["name"]
|
||||
if len(attachment["wall"]["text"]) > 140:
|
||||
text = attachment["wall"]["text"][:145]+"..."
|
||||
else:
|
||||
text = attachment["wall"]["text"]
|
||||
msg = _("{user}: {post}").format(user=user, post=text)
|
||||
else:
|
||||
print(attachment)
|
||||
return [tpe, msg]
|
||||
@@ -272,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,8 @@ 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" % (list(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]:
|
||||
return True
|
||||
@@ -53,7 +57,7 @@ class vkSession(object):
|
||||
""" Put new items on the local cache database.
|
||||
@name str: The name for the buffer stored in the dictionary.
|
||||
@data list: A list with items and some information about cursors.
|
||||
returns the number of items that has been added in this execution"""
|
||||
returns the number of items that have been added in this execution"""
|
||||
global post_types
|
||||
# When this method is called by friends.getOnlyne, it gives only friend IDS so we need to retrieve full objects from VK.
|
||||
# ToDo: It would be nice to investigate whether reusing some existing objects would be a good idea, whenever possible.
|
||||
@@ -70,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.
|
||||
@@ -101,12 +105,13 @@ class vkSession(object):
|
||||
self.db = {}
|
||||
self.db["users"] = {}
|
||||
self.db["groups"] = {}
|
||||
self.db["group_info"] = {}
|
||||
|
||||
@property
|
||||
def is_logged(self):
|
||||
return self.logged
|
||||
|
||||
def get_configuration(self):
|
||||
def get_configuration(self, nosound=False):
|
||||
|
||||
""" Gets settings for a session."""
|
||||
|
||||
@@ -114,10 +119,16 @@ 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"])
|
||||
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.")
|
||||
|
||||
def play_sound(self, sound):
|
||||
self.soundplayer.play(sound)
|
||||
|
||||
def login(self):
|
||||
""" Logging in VK.com. This is basically the first method interacting with VK. """
|
||||
# If user is already logged in, we should skip this method.
|
||||
@@ -179,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
|
||||
@@ -193,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:
|
||||
@@ -204,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"]:
|
||||
@@ -258,6 +276,10 @@ class vkSession(object):
|
||||
k = "{key}_{case}".format(key=key, case=i)
|
||||
v = self.db["groups"][abs(user_id)][i]
|
||||
user_data[k] = v
|
||||
else:
|
||||
group = self.vk.client.groups.getById(group_ids=-1*user_id)[0]
|
||||
self.process_usernames(data=dict(profiles=[], groups=[group]))
|
||||
return self.get_user(user_id=user_id, key=key)
|
||||
return user_data
|
||||
|
||||
def process_usernames(self, data):
|
||||
@@ -290,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
|
@@ -78,19 +78,16 @@ def transform_audio_url(url):
|
||||
""" Transforms the URL offered by VK to the unencrypted stream so we can still play it.
|
||||
This function will be updated every time VK decides to change something in their Audio API'S.
|
||||
Changelog:
|
||||
16/04/2019: Implemented this function. For now it replaces /index.m3u8 by .mp3, also removes the path component before "/audios" if the URL contains the word /audios, or the last path component before the filename if doesn't.
|
||||
17/04/2019: Updated function. Now it is not required to strip anything, just replacing /index.m3u8 with .mp3 should be enough.
|
||||
30/04/2019: Re-enabled old methods as VK changed everything as how it was working on 16.04.2019.
|
||||
17.04.2019: Updated function. Now it is not required to strip anything, just replacing /index.m3u8 with .mp3 should be enough.
|
||||
16.04.2019: Implemented this function. For now it replaces /index.m3u8 by .mp3, also removes the path component before "/audios" if the URL contains the word /audios, or the last path component before the filename if doesn't.
|
||||
"""
|
||||
if "vkuseraudio.net" not in url and "index.m3u8" not in url:
|
||||
return url
|
||||
url = url.replace("/index.m3u8", ".mp3")
|
||||
return url
|
||||
### The following code was useful for VK audio methods prior to 17/04/2019.
|
||||
# I just left this here because they may enable such change any time soon.
|
||||
### basically this method was requiring us to strip a part of the full URL.
|
||||
# parts = url.split("/")
|
||||
# if "/audio" not in url:
|
||||
# url = url.replace("/"+parts[-2], "")
|
||||
# else:
|
||||
# url = url.replace("/"+parts[-3], "")
|
||||
# return url
|
||||
parts = url.split("/")
|
||||
if "/audios" not in url:
|
||||
url = url.replace("/"+parts[-2], "")
|
||||
else:
|
||||
url = url.replace("/"+parts[-3], "")
|
||||
return url
|
@@ -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()
|
BIN
src/sounds/default/checked.ogg
Normal file
BIN
src/sounds/default/checked.ogg
Normal file
Binary file not shown.
BIN
src/sounds/default/selected.ogg
Normal file
BIN
src/sounds/default/selected.ogg
Normal file
Binary file not shown.
BIN
src/sounds/default/unchecked.ogg
Normal file
BIN
src/sounds/default/unchecked.ogg
Normal file
Binary file not shown.
@@ -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)
|
||||
|
||||
@@ -46,10 +60,6 @@ class chat(wx.Panel, widgetUtils.BaseDialog):
|
||||
sizer.Add(self.notify_online, 0, wx.ALL, 5)
|
||||
self.notify_offline = wx.CheckBox(self, wx.NewId(), _("Show notifications when users are offline"))
|
||||
sizer.Add(self.notify_offline, 0, wx.ALL, 5)
|
||||
self.open_unread_conversations = wx.CheckBox(self, wx.NewId(), _("Open unread conversations at startup"))
|
||||
sizer.Add(self.open_unread_conversations, 0, wx.ALL, 5)
|
||||
self.automove_to_conversations = wx.CheckBox(self, wx.NewId(), _("Move focus to new conversations"))
|
||||
sizer.Add(self.automove_to_conversations, 0, wx.ALL, 5)
|
||||
lbl = wx.StaticText(self, wx.NewId(), _("Notification type"))
|
||||
self.notifications = wx.ComboBox(self, wx.NewId(), choices=[_("Native"), _("Custom"),], value=_("Native"), style=wx.CB_READONLY)
|
||||
nbox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
@@ -125,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,7 +117,55 @@ 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="", topic_title=""):
|
||||
self.panel = wx.Panel(self)
|
||||
label = wx.StaticText(self.panel, -1, _("Title"))
|
||||
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()
|
||||
self.textBox = wx.BoxSizer(wx.VERTICAL)
|
||||
titleb = wx.BoxSizer(wx.HORIZONTAL)
|
||||
titleb.Add(label, 0, wx.ALL, 5)
|
||||
titleb.Add(self.title, 0, wx.ALL, 5)
|
||||
self.textBox.Add(titleb, 0, wx.ALL, 5)
|
||||
textb = wx.BoxSizer(wx.HORIZONTAL)
|
||||
textb.Add(label2, 0, wx.ALL, 5)
|
||||
textb.Add(self.text, 0, wx.ALL, 5)
|
||||
self.textBox.Add(textb, 0, wx.ALL, 5)
|
||||
|
||||
def createControls(self, title, message, text, topic_title):
|
||||
self.mainBox = wx.BoxSizer(wx.VERTICAL)
|
||||
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"))
|
||||
self.spellcheck = wx.Button(self.panel, -1, _("Spelling &correction"), size=wx.DefaultSize)
|
||||
self.translateButton = wx.Button(self.panel, -1, _("&Translate message"), size=wx.DefaultSize)
|
||||
self.okButton = wx.Button(self.panel, wx.ID_OK, _("Send"), size=wx.DefaultSize)
|
||||
self.okButton.SetDefault()
|
||||
cancelButton = wx.Button(self.panel, wx.ID_CANCEL, _("Close"), size=wx.DefaultSize)
|
||||
self.buttonsBox1 = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.buttonsBox1.Add(self.attach, 0, wx.ALL, 10)
|
||||
self.buttonsBox1.Add(self.mention, 0, wx.ALL, 10)
|
||||
self.buttonsBox1.Add(self.spellcheck, 0, wx.ALL, 10)
|
||||
self.buttonsBox1.Add(self.translateButton, 0, wx.ALL, 10)
|
||||
self.mainBox.Add(self.buttonsBox1, 0, wx.ALL, 10)
|
||||
self.ok_cancelSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
self.ok_cancelSizer.Add(self.okButton, 0, wx.ALL, 10)
|
||||
self.ok_cancelSizer.Add(cancelButton, 0, wx.ALL, 10)
|
||||
self.mainBox.Add(self.ok_cancelSizer)
|
||||
selectId = wx.NewId()
|
||||
self.Bind(wx.EVT_MENU, self.onSelect, id=selectId)
|
||||
self.accel_tbl = wx.AcceleratorTable([
|
||||
(wx.ACCEL_CTRL, ord('A'), selectId),])
|
||||
self.SetAcceleratorTable(self.accel_tbl)
|
||||
self.panel.SetSizer(self.mainBox)
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -4,7 +4,9 @@ from __future__ import unicode_literals
|
||||
import languageHandler
|
||||
import paths
|
||||
import wx
|
||||
import wx.lib.mixins.listctrl as listmix
|
||||
from builtins import range
|
||||
from pubsub import pub
|
||||
|
||||
toolkit = "wx"
|
||||
|
||||
@@ -134,51 +136,91 @@ class mainLoopObject(wx.App):
|
||||
def run(self):
|
||||
self.app.MainLoop()
|
||||
|
||||
class multiselectionBaseList(wx.ListCtrl, listmix.CheckListCtrlMixin):
|
||||
def __init__(self, *args, **kwargs):
|
||||
wx.ListCtrl.__init__(self, *args, **kwargs)
|
||||
listmix.CheckListCtrlMixin.__init__(self)
|
||||
self.Bind(wx.EVT_CHAR_HOOK, self.on_keydown)
|
||||
self.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_focus)
|
||||
|
||||
def on_focus(self, event):
|
||||
currentItem = self.GetFocusedItem()
|
||||
if self.IsChecked(currentItem):
|
||||
pub.sendMessage("play-sound", sound="selected.ogg")
|
||||
event.Skip()
|
||||
|
||||
def OnCheckItem(self, index, flag):
|
||||
if flag == True:
|
||||
pub.sendMessage("play-sound", sound="checked.ogg")
|
||||
else:
|
||||
pub.sendMessage("play-sound", sound="unchecked.ogg")
|
||||
|
||||
def on_keydown(self, event):
|
||||
if event.GetKeyCode() == wx.WXK_SPACE:
|
||||
self.ToggleItem(self.GetFocusedItem())
|
||||
event.Skip()
|
||||
|
||||
class list(object):
|
||||
def __init__(self, parent, *columns, **listArguments):
|
||||
self.columns = columns
|
||||
self.listArguments = listArguments
|
||||
self.create_list(parent)
|
||||
def __init__(self, parent, *columns, **listArguments):
|
||||
self.columns = columns
|
||||
self.listArguments = listArguments
|
||||
self.create_list(parent)
|
||||
|
||||
def set_windows_size(self, column, characters_max):
|
||||
self.list.SetColumnWidth(column, characters_max*2)
|
||||
def set_windows_size(self, column, characters_max):
|
||||
self.list.SetColumnWidth(column, characters_max*2)
|
||||
|
||||
def set_size(self):
|
||||
self.list.SetSize((self.list.GetBestSize()[0], 1000))
|
||||
def set_size(self):
|
||||
self.list.SetSize((self.list.GetBestSize()[0], 1000))
|
||||
|
||||
def create_list(self, parent):
|
||||
self.list = wx.ListCtrl(parent, -1, **self.listArguments)
|
||||
for i in range(0, len(self.columns)):
|
||||
self.list.InsertColumn(i, "%s" % (self.columns[i]))
|
||||
def create_list(self, parent):
|
||||
self.list = wx.ListCtrl(parent, -1, **self.listArguments)
|
||||
for i in range(0, len(self.columns)):
|
||||
self.list.InsertColumn(i, "%s" % (self.columns[i]))
|
||||
|
||||
def insert_item(self, reversed, *item):
|
||||
""" Inserts an item on the list."""
|
||||
if reversed == False: items = self.list.GetItemCount()
|
||||
else: items = 0
|
||||
self.list.InsertItem(items, item[0])
|
||||
for i in range(1, len(self.columns)):
|
||||
self.list.SetItem(items, i, item[i])
|
||||
def insert_item(self, reversed, *item):
|
||||
""" Inserts an item on the list."""
|
||||
if reversed == False: items = self.list.GetItemCount()
|
||||
else: items = 0
|
||||
self.list.InsertItem(items, item[0])
|
||||
for i in range(1, len(self.columns)):
|
||||
self.list.SetItem(items, i, item[i])
|
||||
|
||||
def remove_item(self, pos):
|
||||
""" Deletes an item from the list."""
|
||||
if pos > 0: self.list.Focus(pos-1)
|
||||
self.list.DeleteItem(pos)
|
||||
def remove_item(self, pos):
|
||||
""" Deletes an item from the list."""
|
||||
if pos > 0: self.list.Focus(pos-1)
|
||||
self.list.DeleteItem(pos)
|
||||
|
||||
def clear(self):
|
||||
self.list.DeleteAllItems()
|
||||
def clear(self):
|
||||
self.list.DeleteAllItems()
|
||||
|
||||
def get_selected(self):
|
||||
return self.list.GetFocusedItem()
|
||||
def get_selected(self):
|
||||
return self.list.GetFocusedItem()
|
||||
|
||||
def select_item(self, pos):
|
||||
self.list.Focus(pos)
|
||||
def select_item(self, pos):
|
||||
self.list.Focus(pos)
|
||||
|
||||
def get_count(self):
|
||||
selected = self.list.GetItemCount()
|
||||
if selected == -1:
|
||||
return 0
|
||||
else:
|
||||
return selected
|
||||
def get_count(self):
|
||||
selected = self.list.GetItemCount()
|
||||
if selected == -1:
|
||||
return 0
|
||||
else:
|
||||
return selected
|
||||
|
||||
def Enable(self, value):
|
||||
return self.list.Enable(value)
|
||||
def Enable(self, value):
|
||||
return self.list.Enable(value)
|
||||
|
||||
class multiselectionList(list):
|
||||
|
||||
def create_list(self, parent):
|
||||
self.list = multiselectionBaseList(parent, -1, **self.listArguments)
|
||||
for i in range(0, len(self.columns)):
|
||||
self.list.InsertColumn(i, "%s" % (self.columns[i]))
|
||||
|
||||
def get_multiple_selection(self):
|
||||
selected = []
|
||||
for item in range(0, self.list.GetItemCount()):
|
||||
if self.list.IsChecked(item):
|
||||
selected.append(item)
|
||||
if len(selected) == 0 and self.list.GetFocusedItem() != -1:
|
||||
selected.append(self.list.GetFocusedItem())
|
||||
return selected
|
@@ -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()
|
@@ -5,22 +5,26 @@ import widgetUtils
|
||||
|
||||
class timelineDialog(widgetUtils.BaseDialog):
|
||||
|
||||
def __init__(self, users=[]):
|
||||
def __init__(self, users=[], show_selector=True):
|
||||
super(timelineDialog, self).__init__(parent=None, title=_("New timeline for {0}").format(users[0],))
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||
userLabel = wx.StaticText(panel, -1, _("User"))
|
||||
self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0])
|
||||
self.cb.SetFocus()
|
||||
userSizer = wx.BoxSizer()
|
||||
userSizer.Add(userLabel, 0, wx.ALL, 5)
|
||||
userSizer.Add(self.cb, 0, wx.ALL, 5)
|
||||
if show_selector:
|
||||
userLabel = wx.StaticText(panel, -1, _("User"))
|
||||
self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0])
|
||||
self.cb.SetFocus()
|
||||
userSizer = wx.BoxSizer()
|
||||
userSizer.Add(userLabel, 0, wx.ALL, 5)
|
||||
userSizer.Add(self.cb, 0, wx.ALL, 5)
|
||||
sizer.Add(userSizer, 0, wx.ALL, 5)
|
||||
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"))
|
||||
@@ -39,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()
|
||||
@@ -133,10 +135,14 @@ class mainWindow(wx.Frame):
|
||||
def advance_selection(self, forward):
|
||||
self.tb.AdvanceSelection(forward)
|
||||
|
||||
def about_dialog(self, *args, **kwargs):
|
||||
def about_dialog(self, channel="stable", *args, **kwargs):
|
||||
if channel == "stable":
|
||||
version = _("{version} (stable)").format(version=application.version)
|
||||
else:
|
||||
version = _("{version} (alpha)").format(version=application.update_next_version)
|
||||
info = wx.adv.AboutDialogInfo()
|
||||
info.SetName(application.name)
|
||||
info.SetVersion(application.version)
|
||||
info.SetVersion(version)
|
||||
info.SetDescription(application.description)
|
||||
info.SetCopyright(application.copyright)
|
||||
info.SetTranslators(application.translators)
|
||||
|
@@ -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):
|
||||
|
@@ -57,14 +57,14 @@ class communityTab(feedTab):
|
||||
def create_post_buttons(self):
|
||||
self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions"))
|
||||
self.load = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Load buffer"))
|
||||
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post"))
|
||||
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post in group"))
|
||||
self.postBox.Add(self.load, 0, wx.ALL, 5)
|
||||
self.postBox.Add(self.post, 0, wx.ALL, 5)
|
||||
|
||||
class audioTab(homeTab):
|
||||
def create_list(self):
|
||||
self.lbl = wx.StaticText(self, wx.NewId(), _("Mu&sic"))
|
||||
self.list = widgetUtils.list(self, *[_("Title"), _("Artist"), _("Duration")], style=wx.LC_REPORT)
|
||||
self.list = widgetUtils.multiselectionList(self, *[_("Title"), _("Artist"), _("Duration")], style=wx.LC_REPORT)
|
||||
self.list.set_windows_size(0, 160)
|
||||
self.list.set_windows_size(1, 380)
|
||||
self.list.set_windows_size(2, 80)
|
||||
@@ -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.19",
|
||||
{"current_version": "0.22",
|
||||
"description": ".",
|
||||
"downloads":
|
||||
{"Windows32": "https://code.manuelcortez.net/manuelcortez/socializer/-/jobs/artifacts/v0.19/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