101 Commits
v0.18 ... v0.19

Author SHA1 Message Date
77a959fe29 Moved documentation locales to Src directory, as doc is generated already from the src dir in CI environments 2019-03-12 16:33:18 -06:00
d8db111d30 Updaed locales for documentation 2019-03-12 16:04:29 -06:00
c2811f2818 Updated Russian translation 2019-03-12 12:09:01 -06:00
b258a3ff9c Updated installer file 2019-03-12 12:08:43 -06:00
02029d22b0 Updated information before release of 0.19 2019-03-11 17:34:33 -06:00
1f7f1c170d Updated translations 2019-03-11 02:17:46 -06:00
a13a4a5695 display results of polls closed when reaching end_date, and polls where the current user cannot vote 2019-03-07 15:23:37 -06:00
0b9dcaa8f1 Remove option 'view information' from documents menu as there is not much to show from a document 2019-03-07 15:12:17 -06:00
9c7030f80e prefix calls to scripts 2019-03-06 16:52:58 -06:00
d8112550f5 Updates some strings 2019-03-06 16:38:11 -06:00
4eb662d314 Modify move command for generated files 2019-03-06 16:28:27 -06:00
8e06ffc3b1 Attempt to upload translation catalogs to CI artifacts 2019-03-06 16:19:22 -06:00
98c5c052de Added option to download document from the context menu 2019-03-05 17:43:19 -06:00
95fe0c9516 Focus should be more persistent when dealing with the online friends buffer 2019-03-05 16:51:19 -06:00
2908b1449c Fixed small issue in audio player 2019-03-05 13:44:35 -06:00
454b461e89 Added basic support to polls (only voting and seeing results is implemented) 2019-03-05 05:58:41 -06:00
0a8d2ad233 started poll implementation 2019-03-01 17:41:46 -06:00
35e34e44ee Fix libloader stuff 2019-03-01 17:33:54 -06:00
b6ce1f62e0 display poll in attachments for posts (no actions are available, yet) 2019-02-26 16:41:30 -06:00
55eaa85979 Announcement of users typing will be send only when the socializer window is focused 2019-02-26 16:17:53 -06:00
b3f5c532dd Allows uploading audio directly from the 'my audios' buffer 2019-02-26 13:57:37 -06:00
0821565a75 Fixed a typo 2019-02-26 11:18:02 -06:00
d187ad43f3 Updated documentation 2019-02-26 11:08:08 -06:00
b5aff6a8eb display document type properly in buffers 2019-02-26 09:02:18 -06:00
a6291b3ee2 Started the documents menu. For now it just allows to add and remove a document to your documents list 2019-02-26 08:38:49 -06:00
f1f86e04e6 Fixed buffer updates for buffers depending on get_page. That includes wall buffers and everything else which is not the home buffer 2019-02-26 08:35:42 -06:00
06898ca0af Updated context menu for buffers. Now it allows to load and discard audio and video albums 2019-02-25 15:42:59 -06:00
305f8317fe Merge branch 'master' of code.manuelcortez.net:manuelcortez/socializer 2019-02-25 05:31:29 -06:00
d7d13dd523 Fixed call to reply() in comment presenter 2019-02-24 19:40:59 -06:00
84dd9dbcea RepeatingTimer should not raise tracebacks when loading all buffers periodically 2019-02-18 13:45:47 -06:00
a345fa8874 Improved Button's label 2019-02-18 13:41:49 -06:00
5780d3ca21 Added online friends buffer 2019-02-14 13:09:44 -06:00
4c220cbb36 display error if there is an internet connection problem during startup 2019-02-14 08:36:31 -06:00
942f9296a0 Added options in the help menu to go to the logs and config folder 2019-02-13 16:48:00 -06:00
fb50f2783f Improved GUI for topic comments. Authentication errors should be handled gracefully now 2019-02-12 17:49:33 -06:00
a50ddd25b2 Fixed an error when displaying posts in a community wall, if the community had shared another community's post 2019-02-11 05:33:18 -06:00
4b6d5a86b2 It is possible to load previous items in the home buffer properly, and the feature works too in wall buffers and timelines 2019-02-11 04:53:32 -06:00
fbada0c4be Fixed get previous item in newsfeed buffer. Now it should load around 700 items 2019-02-11 03:55:16 -06:00
6a8459cc4e Reorganized source code in main module, added docstrings to lots of functions 2019-02-06 17:47:49 -06:00
fce9e9a73f Removed create-empty_buffer and improved create_buffer for dealing with empty buffers too 2019-02-06 11:35:38 -06:00
8ab3c937b6 Renamed some buffers 2019-02-06 11:35:07 -06:00
f8e431cc2e Fixes in document buffers 2019-02-06 11:34:54 -06:00
3f7c069ce0 Added basic creation of document buffers in communities 2019-02-05 12:20:50 -06:00
21895d307b Added correct unicode representation to chat messages 2019-02-03 21:04:10 -06:00
38b0eec741 Text should be cleaned better in posts, coments and topic comments. Cleaned texts will render properly usernames, group names and render properly certain unicode characters 2019-02-03 20:56:32 -06:00
2496f19bee Updated main controller 2019-02-03 18:55:14 -06:00
21932dc329 Group mentions are displayed properly when mentioned in comments 2019-02-03 18:54:31 -06:00
35fc287d55 Added support for reply to topic comments 2019-02-01 13:25:47 -06:00
3a3623859b Changelog should be displayed properly when opened from the help menu. Fixes #21 2019-02-01 11:03:26 -06:00
f623e78bdc Updated changelog 2019-01-31 16:50:53 -06:00
2bcc14888c Added view and presenter for topic displayer. Needs some more methods yet 2019-01-31 16:48:21 -06:00
7bee6cf1ea Display load topics menu item 2019-01-31 16:47:51 -06:00
eea264a099 Added topic buffer's GUI 2019-01-31 16:47:27 -06:00
b99d872c53 Allow creation of topic buffers, loading and unloading of groups too 2019-01-31 16:46:55 -06:00
f09d1b5da1 Added a buffer for displaying topics. Community buffers will keep group_info on them so we can check for group permissions and available post types 2019-01-31 16:46:26 -06:00
9e3ff74b98 Added renderer for group topics 2019-01-31 16:45:31 -06:00
2e64e31a8f Fixed clean_list for all post interactor dialogs 2019-01-31 16:45:05 -06:00
150f9d6c08 Added actions in community buffers from context menu in the treebook 2019-01-30 15:32:46 -06:00
a6565aae53 Added proxy setting to preferences dialog 2019-01-29 16:23:02 -06:00
ac268c0672 Attaching documents is now supported 2019-01-28 05:36:51 -06:00
94902c661f chat names have been simplified for an easier navigation 2019-01-27 05:37:42 -06:00
0a90e1fe4a Fixed an error when removing audio items from my audios buffer 2019-01-26 18:51:34 -06:00
9f1a09689f Updated changelog 2019-01-26 18:45:07 -06:00
af68d9b0cf Fixed errors in move to album option for audios 2019-01-26 18:44:23 -06:00
d75b7de20b Implemented adding and removing audio albums appropiately 2019-01-26 18:42:50 -06:00
f968e618ac Reenabled create and delete audio albums 2019-01-26 18:42:20 -06:00
fb9717a00f Added more parameters to audio search feature 2019-01-26 17:45:10 -06:00
0acdf41fa3 Switched to a proper context menu handler 2019-01-26 07:11:11 -06:00
f5fddd0369 Fixed issues in post displayer dialogs introduced in previous alpha 2019-01-26 07:10:53 -06:00
660f801afd Replaced bytes object for unicode counterpart 2019-01-25 17:52:59 -06:00
da66118d20 Attempt to fix proxy not working in audio playback 2019-01-25 11:46:15 -06:00
93d1de941c volume for application sounds will not be connected to app volume for audio files 2019-01-25 11:45:45 -06:00
94106a11c0 Improved handling for deleted posts. Now they should display an error 2019-01-25 10:36:28 -06:00
76f0ee3ef0 Documentation and changelog should be included in all builds 2019-01-24 17:11:33 -06:00
712792ac9f Remove friend implementation finished 2019-01-24 17:10:32 -06:00
56424cf0d1 Implemented Ctrl+A to select all in important edit boxes 2019-01-24 16:07:02 -06:00
9230bd8115 fixed an error in community buffers 2019-01-24 13:30:40 -06:00
ab0d34599f Fixed an error in chat messages that was making the program unable to keep sending messages after an attachment file has been sent 2019-01-23 09:17:33 -06:00
0c4ee6a033 Updated russian translation with a few suggestions 2019-01-23 09:16:29 -06:00
f5b80b6e63 Remove None values from sig generation 2019-01-23 08:55:23 -06:00
63f4a8310e Sound player module take volume config properly 2019-01-23 08:54:06 -06:00
53176a9a26 Sound settings are taken from app-settings instead of session settings 2019-01-23 08:22:22 -06:00
8422243465 Volume should be saved across restarts 2019-01-22 17:49:18 -06:00
91317b7a41 Added some modifications to the way the media player works 2019-01-22 17:41:39 -06:00
cbcc6f812a Fixed an error raised when there were attempts to set volume before the URL Player has played something 2019-01-22 16:40:00 -06:00
a53a3d595c Improved notifications a little bit 2019-01-22 16:35:52 -06:00
d741035707 Chats receiving new messages will be moved automatically to the first position in the chats section 2019-01-22 16:20:37 -06:00
bab02110b0 Fixed error in Media player. Now it should not skip the first song if you are in the last track and pressed 'play next' 2019-01-22 10:29:37 -06:00
1db4e10dc8 Load all chats during startup 2019-01-21 17:32:23 -06:00
d6a87bc426 Play is now play/pause in the player menu. Removed stop item 2019-01-21 16:48:51 -06:00
d8096a3695 Added some keystrokes for audio playback. Read changelog for more references 2019-01-21 16:48:09 -06:00
0927695261 Updated requirements to match python 3 only 2019-01-21 16:46:36 -06:00
97380e9833 Started implementation for friends removal 2019-01-21 05:42:21 -06:00
2c64581a2c Changed friends order by rating 2019-01-21 05:31:32 -06:00
05a00e8ce0 Disable alpha for Python 2. Ends support to Python 2 builds. Closes #16 2019-01-21 05:17:42 -06:00
d056bd0bd2 Fixed error when displaying certain user profile info. Closes #29 2019-01-21 05:13:05 -06:00
fa187be88a Updated readme 2019-01-21 05:04:12 -06:00
357ccca819 Don't create socializer.exe.log, save log errors to log file instead. Closes #27 2019-01-21 04:51:59 -06:00
993f49c0a0 Unread messages should be detected appropiately 2019-01-21 04:44:16 -06:00
3b180cda83 Added support to subscribers buffer 2019-01-21 04:42:52 -06:00
1a877bbfa1 Automove to conversation is unchecked by default for new sessions 2019-01-20 12:01:50 -06:00
47 changed files with 4977 additions and 2260 deletions

View File

@@ -21,7 +21,7 @@ test_py3:
- '%PYTHON3% -m coverage report --omit="test*"'
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
alpha:
.alpha:
type: deploy
tags:
- windows
@@ -56,7 +56,6 @@ alpha_python3:
- '%PYTHON3% -v'
- '%PYTHON3% -m pip install --upgrade pip'
- '%PYTHON3% -m pip install --upgrade -r requirements.txt'
- '%PYTHON3% -m pip install --upgrade pyenchant pypubsub'
- '%PYTHON3% -m pip uninstall enum34 -y'
script:
- copy changelog.md doc\changelog.md
@@ -69,13 +68,19 @@ alpha_python3:
- cd ..
- cd scripts
- '%PYTHON3% prepare_zipversion.py'
- call genpot_interface.bat
- call genpot_doc.bat
- cd ..
- move src\socializer.zip socializer.zip
- move scripts\socializer.pot socializer.pot
- move scripts\socializer-documentation.pot socializer-documentation.pot
only:
- schedules
artifacts:
paths:
- socializer.zip
- socializer.pot
- socializer-documentation.pot
name: socializer_py3
expire_in: 1 day
@@ -87,7 +92,6 @@ stable:
- '%PYTHON3% -v'
- '%PYTHON3% -m pip install --upgrade pip'
- '%PYTHON3% -m pip install --upgrade -r requirements.txt'
- '%PYTHON3% -m pip install --upgrade pyenchant pypubsub'
- '%PYTHON3% -m pip uninstall enum34 -y'
script:
- copy changelog.md doc\changelog.md

View File

@@ -6,24 +6,13 @@
A desktop application for handling [vk.com](http://vk.com) in an easy way.
## download the current build
Socializer's functionality is far to be perfect, in fact there are lots of methods of the VK API that this application doesn't support right now, but if you are curious enough, and you want to help by giving me your impressions and making tests for fixing bugs, you can download the last source code, compiled as an application. This is the snapshot build of socializer. This version is only for testing purposes, never think that it can be used for everyday use. This version does not include any documentation, Only the changelog, because it's build with an authomatic process.
Before downloading, take in to account the following: This source code is completely experimental. The current functionality in this application is not very useful. If you decide to use nightly build versions, take into account that this doesn't work as an application for everyday use yet.
Version: 0.16
Build date: Dec 14 2018
[Download socializer](https://code.manuelcortez.net/manuelcortez/socializer/-/jobs/artifacts/master/raw/socializer.zip?job=alpha)
I have started this effort as an open source project on Feb 13, 2016. Pull requests and bug reports are welcome.
[See Socializer's website](http://socializer.su)
## dependencies not installed by PIP
For other dependencies, do pip install --upgrade -r requirements.txt
* [Python,](http://python.org) version 2.7.15
* [PyEnchant,](http://pythonhosted.org/pyenchant/) version 1.6.6.
* [Python,](http://python.org) version 3.7.2
## Documentation

View File

@@ -2,6 +2,51 @@
## changes in this version
* Added a new buffer called documents. When loading the buffer, it will contain all documents owned by the current user. The context menu of any item will allow you to download the document to your computer or remove it from VK.
* A new buffer, called online, has been added in the friends section. It contains friends currently connected to VK. Items in this buffer will be added as soon as new friends are online in the social network, and will be removed when friends are offline. This buffer needs a lot of testing. Please report any possible inconsistency on this method.
* Added new options to open the config and logs folder, these options are located in the help menu and may be useful during error reporting.
* Added experimental support to "subscribers" buffer, inside frienship requests. This shows friend requests that have been declined by the current user.
* the message when an user is typing in conversation buffers will be announced only if the socializer window is focused.
* In "my audios" buffer, there is a button that allows a direct audio upload from your computer. The audio will be placed in your library.
* Added experimental support to user and community polls:
* If the poll is already closed or the user has send a vote to the poll previously, it will display only the results of the poll.
* Otherwise it will display a dialog from where the user can vote in the current poll.
* Fixed an error in Socializer that was making it unable to detect unread messages properly.
* Socializer should save all tracebacks directly to error.log instead of displaying an error message during exit. ([#27,](https://code.manuelcortez.net/manuelcortez/socializer/issues/27))
* When displaying user profiles, fixed an error where a married person without specifing relation partner would cause an error in the program. ([#29,](https://code.manuelcortez.net/manuelcortez/socializer/issues/29))
* Socializer will load all conversations during startup, not only conversations with unread messages.
* Added new global keystrokes, available in the main window.
* Alt + up/down arrows: Increase / decrease volume.
* Alt + Left/down arrows: Play previous and next song if playing an audios buffer.
* Control + P: Play/pause.
* control+Shift+P: Play all.
* Fixed an error in the audio player that was skipping the first track if you were in the last song and pressed "play next" in the menu bar or via the keystroke.
* Chats with unread messages will be placed at the top of the chats section. When a chat buffer receives a new message, socializer will move the buffer to the first position in the chats list. This should make easier for everyone to determine which chats contain unread items. ([#24,](https://code.manuelcortez.net/manuelcortez/socializer/issues/24))
* In dialogs for displaying posts and comments, and also in the two edit boxes present in chat buffers, it is possible to select all by pressing Control+A.
* Now it is possible to remove friends directly from the friends buffer. There is a new option for this purpose in the context menu for the focused friend. After being removed, the person will be placed in the subscribers buffer.
* Deleted posts will display an error message when trying to view details about those. Before, the dialog was created and left blank.
* Improvements in audio features present in Socializer:
* The audio search feature has received improvements: Now it is possible to indicate wether the search will be performed by title or artist, and select to sort the results by duration, popularity or date of addition to VK.
* Now it is possible to create and delete audio albums again.
* Fixed errors when moving songs to albums. Now everything works as expected.
* Added documents to the list of supported files when adding attachments to a wall post or private message.
* It is possible to enable or disable proxy from the preferences dialog. The application must be restarted for this change to take effect.
* Fixed an error that was making Socializer unable to display the changelog properly, when opened from the help menu. ([#21](https://code.manuelcortez.net/manuelcortez/socializer/issues/21))
* When receiving chat messages and in some other situations, socializer will display all characters properly. Before, usernames were rendered using the internal code VK uses for them, and some unicode characters were displaying their HTML representation.
* It is possible to retrieve previous items for the home buffer and walls (current user's wall and any other timeline):
* For the home buffer, only a limited amount of items (around 700) can be loaded, supposedly due to VK API limits.
* For walls, all posts should be possible to be loaded, however, testing with walls containing more than 2000 posts are not performed yet.
* Added improvements to groups:
* It is possible to load topics, audios, videos and documents for a group. In order to do so, you need to go to the group buffer and press the menu key, or right mouse click, in the tree item representing the group. New buffers will be created inside the current group's buffer.
* You can create or delete all buffers for groups by pressing the menu key or right mouse click in the "communities" buffer.
* There is support for group topics. When opening them, they will be displayed as a list of posts. You can like or reply to such posts, as well as adding new posts in the topic.
* Authentication errors should be handled gracefully by the application:
* When there is a password change, Socializer must be reauthorized again. An error message will indicate this if the user forgot to do that. After the error, the app will be restarted, prompting the user to introduce the new data for authorizing the application.
* If the user introduced incorrect or invalid data, Socializer will display an error and prompt the user again for valid information.
* If there is a connection problem when opening Socializer, it will display an error and inform the user about the issue.
## Changes in version 0.18 (21.01.2019)
* Changed authentication tokens in Socializer. It is mandatory to download a fresh copy of socializer and start a new configuration for your account.
* Stable versions of Socializer are built with Python 3. Previous versions are built with Python 2, however support for Python 2 will be dropped very soon.
* There is an installer file for Socializer, available in our downloads page. Installed version of Socializer will be more confortable for some people.

View File

@@ -5,7 +5,7 @@
Socializer is an application to use [VK.com](https://vk.com) in an easy and accessible way with minimal CPU resource usage. Socializer will allow you to interact with the VK social network by giving you access to the most relevant features such as:
* Supports two factor authentication (2FA).
* Basic post creation in your wall (including photos).
* Post creation in user and community walls.
* audio support.
* Post comments.
* like, unlike and repost other's posts.
@@ -24,6 +24,8 @@ If this is the first time you have launched socializer, you will see a message a
After the proxy message, you will see a new message dialog asking you to proceed with the account authorisation process. It consists in providing the authentication data you normally use to sign in VK. It is very important to know that this data will be stored in a folder called config, located in the same folder where the socializer files are. Your config folder is a very important storage for your authentication data, so you must be sure you never will share it with anyone, mostly because your data is stored as plain text (this will be fixed in a future release and your data will be properly encrypted). Socializer will need your authentication data for acting in your behalf and offering you a better experience that what it could do with a simple access token. You must provide your phone number or email address in the first text box, and your password in the second. When pressing OK, your data will be saved and the application will start to retrieve all the required information for showing your buffers. If you have two factor authentication configured in your account, you will see an additional dialog where you have to type the code provided by VK via SMS.
It is worth saying that whenever you change your password in the VK website, you will need to authorize Socializer again. When you open socializer after changing your password, you will see a message informing you of the problem and the application will be restarted, allowing you to write your new data and start the authorization again.
Once started, the application will start loading your data (posts, audio files, conversations, friends). When done, it will show you a notification indicating that the program is ready.
## General concepts
@@ -32,12 +34,12 @@ Before starting to describe Socializer's usage, we'll explain some concepts that
### Buffer
A buffer is a list of items that will manage the data which arrives from VK, after being processed by the application. When you configure your account on Socializer and start it, many buffers are created. Each of them may contain some of the items which this program works with: Newsfeed posts, wall posts, audio and video files, friendship requests and conversations. According to the buffer you are focusing, you will be able to do different actions with these items.
A buffer is a list of items that will manage the data which arrives from VK, after being processed by the application. When you configure your account on Socializer and start it, many buffers are created. Each of them may contain some of the items which this program works with: Newsfeed posts, wall posts, audio and video files, documents, friendship requests and conversations. According to the buffer you are focusing, you will be able to do different actions with these items.
All buffers will be updated in one of the following ways:
* Periodically: Most buffers containing posts, audio or video files and people, will be updated periodically to reflect the new additions to them. Updates will be every 2 minutes for every buffer, so if you posted something and did not see the post in the buffer, you may need to wait a moment. There is an option, located in the buffer menu on the menu bar, which allows you to trigger a manual update in the current buffer.
* Real time: Conversation buffers will be updated every time someone sends a message to you. When an user sends you a message, if there is not a conversation buffer created to receive the message, a new conversation buffer will be opened automatically and the message will be placed on it. If you already have an opened conversation for the user sending the message, the message will be placed at the end of the buffer. A different sound will indicate whether a new conversation has been opened or an existing buffer gets updated.
* Real time: Conversation buffers will be updated every time someone sends a message to you. When an user sends you a message, if there is not a conversation buffer created to receive the message, a new conversation buffer will be opened automatically and the message will be placed on it. If you already have an opened conversation for the user sending the message, the message will be placed at the end of the buffer. A different sound will indicate whether a new conversation has been opened or an existing buffer gets updated. Socializer will sort conversation buffers by placing buffers with unread messages at the top of the conversations section. When a buffer gets a new message, it will be moved automatically to the first place in the conversations category.
### item
@@ -57,8 +59,8 @@ The following is a brief description of the kind of items socializer can work wi
The graphical user interface of Socializer consists of a window containing:
* a menu bar accomodating five menus (application, Me, buffer, player and help),
* One tree view,
* One list of items
* One tree view, where you can press the menu key or right mouse click to display a context menu which contains actions you can apply in the selected buffer,
* One list of items, which also accepts the menu key to display actions available for the selected item,
* Some buttons, depending which is the focused buffer.
The actions that are available for every item will be described later.
@@ -68,6 +70,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.
* 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.
* Send message: Send a message to a friend, which will open a conversation buffer if it does not exist already. Conversation buffers contain a full conversation, accommodating chat messages, between the current user and someone else. You can type your message in the provided box and press enter to send it to your friend. Additionally, You can upload an attachment by pressing the "attach" button and choosing between uploading a photo, audio file or record a voice message in the dialog which will appear, and open attachments sent in the focused message by pressing tab and finding them in the attachments list.
@@ -80,8 +83,8 @@ Visually, Towards the top of the main application window, A menu bar can be foun
### Application menu
* Create: opens a menu where you can create a new album. At the moment, only video albums are supported.
* Delete: opens a menu where you can delete an already existing album owned by yourself. Only video albums are supported at this time.
* 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.
* Preferences: Opens a dialogue which lets you configure settings for the entire application.
### Me menu
@@ -117,17 +120,20 @@ Visually, Towards the top of the main application window, A menu bar can be foun
* Documentation: opens up this file, where you can read some useful program concepts.
* Check for updates: every time you open the program it automatically checks for new versions. If an update is available, it will ask you if you want to download the update. If you accept, the updating process will commence. When complete, Socializer will be restarted. This item checks for new updates without having to restart the application.
* Changelog: opens up a document with the list of changes from the current version to the earliest.
* Open logs directory: Opens windows explorer in the logs directory, useful to include your logs in a bug report.
* Open config directory: Opens Windows explorer in your config directory.
* Report an error: opens up a dialogue box to report a bug by completing a small number of fields. Pressing enter will send the report. If the operation doesn't succeed the program will display a warning.
## Keyboard shortcuts
Socializer includes some keyboard shortcuts, available from any buffer (except empty buffers and conversations). Here you have the list of the available shortcuts:
Socializer includes some keyboard shortcuts, available from any buffer. Here you have the list of the available shortcuts:
* Enter: Execute the default action for the focused item. It may be opening a post, view friends added by someone else, view audio details or opening an user profile.
* Control + Enter: Play audio.
* Control + Shift+Enter: pause audio playback.
* F5: Decrease volume by 5%.
* F6: Increase volume by 5%.
* Enter: Execute the default action for the focused item. It may be opening a post, view friends added by someone else, view audio details or opening an user profile. You need to be in the items list for using this key.
* Alt+Up/down: Increase and decrease audio volume by 5%.
* Control+P: Play/pause. If this is the firt time you press this keystroke, it will automatically play all items present in the focused buffer or in your audios.
* control+Shift+P: Play all audio tracks. If the currently focused buffer does not contain audio items, it will play all items present in your audios buffer.
* Alt+Left: Play the previous song.
* Alt+Right: Play the next song.
## configuration
@@ -163,7 +169,7 @@ If you still have questions after reading this document, if you wish to collabor
## Credits
Socializer is developed and mantained 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) with contributions by [Anibal Hernandez](https://dragodark.com)
We would also like to thank the translators of Socializer, who have allowed the spreading of the application.

View File

@@ -1,11 +1,12 @@
# Stay in wxPython 4.0.3 because 4.0.4 has some regressions in accessibility related components.
wxpython==4.0.3
pywin32
pyenchant
markdown
vk_api
bs4
configobj
pypubsub==3.3.0
pypubsub
requests-oauthlib
future
arrow

View File

@@ -1,6 +1,11 @@
[app-settings]
username = string(default="")
password = string(default="")
language = string(default="system")
use_proxy = boolean(default=False)
first_start = boolean(default=True)
first_start = boolean(default=True)
[sound]
volume = integer(default=100)
input_device = string(default="Default")
output_device = string(default="Default")
session_mute = boolean(default=False)
current_soundpack = string(default="default")

View File

@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
name = "Socializer"
version = "0.18"
version = "0.19"
author = "Manuel Cortez"
authorEmail = "manuel@manuelcortez.net"
copyright = "Copyright (C) 2016-2018, Manuel Cortez"
copyright = "Copyright (C) 2016-2019, Manuel Cortez"
description = name+" Is an accessible VK client for Windows."
url = "https://manuelcortez.net/socializer"
url = "http://socializer.su"
# The short name will be used for detecting translation files. See languageHandler for more details.
short_name = "socializer"
translators = ["Darya Ratnikova (Russian)", "Manuel Cortez (Spanish)"]

View File

@@ -4,7 +4,7 @@ import random
import requests
import logging
from hashlib import md5
from .wxUI import two_factor_auth
from .wxUI import two_factor_auth, bad_password
log = logging.getLogger("authenticator.official")
@@ -28,7 +28,9 @@ def get_sig(method, values, secret):
""" Create a signature for parameters passed to VK API. """
postdata = ""
for key in values:
postdata = postdata + "{key}={value}&".format(key=key, value=values[key])
# None values should be excluded from SIG, otherwise VK won't validate it correctly.
if values[key] != None:
postdata = postdata + "{key}={value}&".format(key=key, value=values[key])
# Remove the last "&" character.
postdata = postdata[:-1]
sig = md5(b"/method/"+method.encode("utf-8")+b"?"+postdata.encode("utf-8")+secret.encode("utf-8"))
@@ -47,7 +49,7 @@ def get_non_refreshed(login, password, scope=scope):
""" Retrieves a non-refreshed token, this should be the first token needed to authenticate in VK.
returns the access_token which still needs to be refreshed, device_id, and secret code, needed to sign all petitions in VK."""
if not (login or password):
raise ValueError
raise ValueError("Both user and password are required.")
device_id = get_device_id()
# Let's authenticate.
url = "https://oauth.vk.com/token"
@@ -87,8 +89,12 @@ def refresh_token(token, secret, device_id):
return perform_request(method, postdata, secret)
def login(user, password):
access_token, secret, device_id = get_non_refreshed(user, password)
response = refresh_token(access_token, secret, device_id)
try:
access_token, secret, device_id = get_non_refreshed(user, password)
response = refresh_token(access_token, secret, device_id)
except AuthenticationError:
bad_password()
raise AuthenticationError("")
try:
return response["response"]["token"], secret, device_id
except KeyError:

View File

@@ -22,3 +22,6 @@ def get_code():
code = dlg.GetValue()
dlg.Destroy()
dlg.Destroy()
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()

View File

@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
from __future__ import unicode_literals
import time
import random
import logging
@@ -12,18 +11,19 @@ import views
import interactors
import languageHandler
import widgetUtils
from presenters import player
import output
from . import selector
from pubsub import pub
from vk_api.exceptions import VkApiError
from vk_api import upload
from requests.exceptions import ReadTimeout, ConnectionError
from mutagen.id3 import ID3
from presenters import player
from wxUI.tabs import home
from sessionmanager import session, renderers, utils
from mysc.thread_utils import call_threaded
from wxUI import commonMessages, menus
from sessionmanager.renderers import add_attachment
from . import selector
log = logging.getLogger("controller.buffers")
@@ -93,7 +93,7 @@ class baseBuffer(object):
log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code
return retrieved
except ReadTimeout as ConnectionError:
except:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if not hasattr(self, "tab"):
@@ -109,7 +109,7 @@ class baseBuffer(object):
[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]]
[self.insert(i, False) for i in self.session.db[self.name]["items"][-num:]]
return retrieved
def get_more_items(self):
@@ -148,8 +148,7 @@ class baseBuffer(object):
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."""
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)
@@ -175,14 +174,20 @@ class baseBuffer(object):
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
def connect_events(self):
""" Bind all events to this buffer"""
widgetUtils.connect_event(self.tab.post, widgetUtils.BUTTON_PRESSED, self.post)
widgetUtils.connect_event(self.tab.list.list, widgetUtils.KEYPRESS, self.get_event)
widgetUtils.connect_event(self.tab.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu)
widgetUtils.connect_event(self.tab.list.list, wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key)
widgetUtils.connect_event(self.tab.list.list, wx.EVT_CONTEXT_MENU, self.show_menu)
self.tab.set_focus_function(self.onFocus)
def show_menu(self, ev, pos=0, *args, **kwargs):
@@ -391,7 +396,7 @@ class feedBuffer(baseBuffer):
log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code
return retrieved
except ReadTimeout as ConnectionError:
except:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if not hasattr(self, "tab"):
@@ -406,6 +411,9 @@ class feedBuffer(baseBuffer):
[self.insert(i, True) for i in v]
else:
[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:]]
return retrieved
def remove_buffer(self, mandatory=False):
@@ -445,7 +453,7 @@ class feedBuffer(baseBuffer):
return super(feedBuffer, self).post()
owner_id = self.kwargs["owner_id"]
user = self.session.get_user(owner_id, key="user1")
title = _("Post to {user1_nom]'s wall").format(**user)
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)
@@ -469,6 +477,110 @@ class communityBuffer(feedBuffer):
self.tab.load.Enable(False)
wx.CallAfter(self.get_items)
def get_items(self, *args, **kwargs):
""" 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"])
super(communityBuffer, self).get_items(*args, **kwargs)
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"):
self.tab.post.Enable(False)
def onFocus(self, *args, **kwargs):
pass
def open_post(self, *args, **kwargs):
""" Opens the currently focused post."""
post = self.get_post()
if post == None:
return
a = presenters.displayTopicPresenter(session=self.session, postObject=post, group_id=self.kwargs["group_id"], interactor=interactors.displayPostInteractor(), view=views.displayTopic())
class documentBuffer(feedBuffer):
can_get_items = False
def create_tab(self, parent):
self.tab = home.documentTab(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)
def onFocus(self, *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)
def connect_events(self):
super(documentBuffer, self).connect_events()
# Check if we have a load button in the tab, because documents community buffers don't include it.
if hasattr(self.tab, "load"):
widgetUtils.connect_event(self.tab.load, widgetUtils.BUTTON_PRESSED, self.load_documents)
def load_documents(self, *args, **kwargs):
output.speak(_("Loading documents..."))
self.can_get_items = True
self.tab.load.Enable(False)
wx.CallAfter(self.get_items)
def get_menu(self):
p = self.get_post()
if p == None:
return
if p["owner_id"] == self.session.user_id:
added = True
else:
added = False
m = menus.documentMenu(added)
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_remove_document, menuitem=m.action)
widgetUtils.connect_event(m, widgetUtils.MENU, self.download, menuitem=m.download)
return m
def add_remove_document(self, *args, **kwargs):
p = self.get_post()
if p == None:
return
if p["owner_id"] == self.session.user_id:
result = self.session.vk.client.docs.delete(owner_id=p["owner_id"], doc_id=p["id"])
if result == 1:
output.speak(_("The document has been successfully deleted."))
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
else:
result = self.session.vk.client.docs.add(owner_id=p["owner_id"], doc_id=p["id"])
output.speak(_("The document has been successfully added."))
def download(self, *args, **kwargs):
post = self.get_post()
filename = post["title"]
# If document does not end in .extension we must fix it so the file dialog will save it properly later.
if filename.endswith(post["ext"]) == False:
filename = filename+ "."+post["ext"]
filepath = self.tab.get_download_path(filename)
if filepath != None:
pub.sendMessage("download-file", url=post["url"], filename=filepath)
class documentCommunityBuffer(documentBuffer):
can_get_items = True
def create_tab(self, parent):
self.tab = home.documentCommunityTab(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)
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."""
@@ -477,8 +589,8 @@ class audioBuffer(feedBuffer):
self.tab = home.audioTab(parent)
self.tab.name = self.name
self.connect_events()
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)
if self.name == "me_audio":
self.tab.post.Enable(True)
def connect_events(self):
widgetUtils.connect_event(self.tab.play, widgetUtils.BUTTON_PRESSED, self.play_audio)
@@ -494,7 +606,7 @@ class audioBuffer(feedBuffer):
def play_next(self, *args, **kwargs):
selected = self.tab.list.get_selected()
if selected < 0 or selected == self.tab.list.get_count()-1:
if selected < 0:
selected = 0
if self.tab.list.get_count() <= selected+1:
newpos = 0
@@ -573,6 +685,7 @@ class audioBuffer(feedBuffer):
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())
def move_to_album(self, *args, **kwargs):
@@ -584,7 +697,7 @@ class audioBuffer(feedBuffer):
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.moveToAlbum(album_id=album.item, audio_ids=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"))
@@ -604,6 +717,22 @@ class audioBuffer(feedBuffer):
else:
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
return m
def post(self, *args, **kwargs):
""" Uploads an audio to the current user's library from the computer. """
file = self.tab.get_file_to_upload()
if file == None:
return
audio_tags = ID3(file)
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")
uploader = upload.VkUpload(self.session.vk.session_object)
call_threaded(uploader.audio, file, title=title, artist=artist)
class audioAlbum(audioBuffer):
""" this buffer was supposed to be used with audio albums
@@ -759,7 +888,7 @@ class videoAlbum(videoBuffer):
wx.CallAfter(self.get_items)
self.tab.play.Enable(True)
class empty(object):
class emptyBuffer(object):
def __init__(self, name=None, parent=None, *args, **kwargs):
self.tab = home.empty(parent=parent, name=name)
@@ -855,7 +984,7 @@ class chatBuffer(baseBuffer):
call_threaded(self.session.vk.client.messages.setActivity, peer_id=self.kwargs["peer_id"], type="typing")
event.Skip()
def get_items(self, show_nextpage=False, unread=False):
def get_items(self, show_nextpage=False):
if self.can_get_items == False: return
retrieved = True # Control variable for handling unauthorised/connection errors.
try:
@@ -864,7 +993,7 @@ class chatBuffer(baseBuffer):
log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code
return retrieved
except ReadTimeout as ConnectionError:
except:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if not hasattr(self, "tab"):
@@ -882,7 +1011,7 @@ class chatBuffer(baseBuffer):
else:
if num > 0:
[self.insert(i, False) for i in self.session.db[self.name]["items"][:num]]
if unread == True and num > 0:
if self.unread == True and num > 0:
self.session.db[self.name]["items"][-1].update(read_state=0)
return retrieved
@@ -932,10 +1061,17 @@ class chatBuffer(baseBuffer):
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"):
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.
@@ -950,9 +1086,13 @@ class chatBuffer(baseBuffer):
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
def __init__(self, *args, **kwargs):
def __init__(self, unread=False, *args, **kwargs):
super(chatBuffer, self).__init__(*args, **kwargs)
self.unread = unread
self.reads = []
self.chats = dict()
self.peer_typing = 0
@@ -1055,8 +1195,15 @@ class peopleBuffer(feedBuffer):
return
if ("last_seen" in post) == False: return
original_date = arrow.get(post["last_seen"]["time"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, created_at)
now = arrow.now()
original_date.to(now.tzinfo)
diffdate = now-original_date
if diffdate.days == 0 and diffdate.seconds <= 360:
online_status = _("Online")
else:
# Translators: This is the date of last seen
online_status = _("Last seen {0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, online_status)
def open_timeline(self, *args, **kwargs):
pass
@@ -1071,9 +1218,13 @@ class peopleBuffer(feedBuffer):
widgetUtils.connect_event(m, widgetUtils.MENU, self.accept_friendship, menuitem=m.accept)
widgetUtils.connect_event(m, widgetUtils.MENU, self.decline_friendship, menuitem=m.decline)
widgetUtils.connect_event(m, widgetUtils.MENU, self.keep_as_follower, menuitem=m.keep_as_follower)
elif self.name == "subscribers":
m = menus.peopleMenu(is_subscriber=True)
widgetUtils.connect_event(m, widgetUtils.MENU, self.accept_friendship, menuitem=m.add)
else:
m = menus.peopleMenu(is_request=False)
# It is not allowed to send messages to people who is not your friends, so let's disble it if we're in a pending or outgoing requests folder.
widgetUtils.connect_event(m, widgetUtils.MENU, self.decline_friendship, menuitem=m.decline)
# 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 folder.
if "friend_requests" in self.name:
m.message.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.new_chat, menuitem=m.message)
@@ -1091,11 +1242,83 @@ class peopleBuffer(feedBuffer):
pass
def decline_friendship(self, *args, **kwargs):
pass
person = self.get_post()
if person == None:
return
user = self.session.get_user(person["id"])
question = commonMessages.remove_friend(user)
if question == widgetUtils.NO:
return
result = self.session.vk.client.friends.delete(user_id=person["id"])
if "friend_deleted" in result:
msg = _("You've removed {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
def add_person(self, person):
# This tracks if the user already exists here, in such case we just will update the last_seen variable
existing = False
for i in self.session.db[self.name]["items"]:
if person["id"] == i["id"]:
existing = True
i["last_seen"]["time"] = person["last_seen"]["time"]
break
# Add the new user to the buffer just if it does not exists previously.
if existing == False:
# Ensure the user won't loose the focus after the new item is added.
focused_item = self.tab.list.get_selected()+1
self.session.db[self.name]["items"].insert(0, person)
self.insert(person, True)
# Selects back the previously focused item.
self.tab.list.select_item(focused_item)
def remove_person(self, user_id):
# Make sure the user is present in the buffer, otherwise don't attempt to remove a None Value from the list.
user = None
focused_user = self.get_post()
for i in self.session.db[self.name]["items"]:
if i["id"] == user_id:
user = i
break
if user != None:
person_index = self.session.db[self.name]["items"].index(user)
focused_item = self.tab.list.get_selected()
self.session.db[self.name]["items"].pop(person_index)
self.tab.list.remove_item(person_index)
if user != focused_user:
# Let's find the position of the previously focused user.
focus = None
for i in range(0, len(self.session.db[self.name]["items"])):
if focused_user["id"] == self.session.db[self.name]["items"][i]["id"]:
self.tab.list.select_item(i)
return
elif user == focused_user and user_index < len(self.tab.list.get_count()):
self.tab.list.select_item(user_index)
else:
self.tab.list.select_item(self.tab.list.get_count()-1)
def get_friend(self, user_id):
for i in self.session.db["friends_"]["items"]:
if i["id"] == user_id:
return i
log.exception("Getting user manually...")
user = self.session.vk.client.users.get(user_ids=event.user_id, fields="last_seen")[0]
return user
def update_online(self):
online_users = self.session.vk.client.friends.getOnline()
now = time.time()
for i in self.session.db[self.name]["items"]:
if i["id"] in online_users:
i["last_seen"]["time"] = now
else:
log.exception("Removing an user from online status manually... %r" % (i))
self.remove_person(i["id"])
class requestsBuffer(peopleBuffer):
def get_items(self, show_nextpage=False):
@@ -1107,7 +1330,7 @@ class requestsBuffer(peopleBuffer):
log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code
return retrieved
except ReadTimeout as ConnectionError:
except:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
num = self.session.get_page(name=self.name, show_nextpage=show_nextpage, endpoint="get", parent_endpoint="users", count=1000, user_ids=", ".join([str(i) for i in ids["items"]]), fields="uid, first_name, last_name, last_seen")

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import win32com
import paths
win32com.__gen_path__=paths.com_path()
win32com.__build_path__=paths.com_path()
import sys
import os
sys.path.append(os.path.join(win32com.__gen_path__, "."))

View File

@@ -5,7 +5,7 @@ CRCCheck on
ManifestSupportedOS all
XPStyle on
Name "Socializer"
OutFile "socializer_0.18_setup.exe"
OutFile "socializer_0.19_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.18"
VIAddVersionKey FileVersion "0.18"
VIProductVersion "0.18.0.0"
VIFileVersion "0.18.0.0"
VIAddVersionKey ProductVersion "0.19"
VIAddVersionKey FileVersion "0.19"
VIProductVersion "0.19.0.0"
VIFileVersion "0.19.0.0"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY
var StartMenuFolder
@@ -50,10 +50,10 @@ 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.18"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayVersion" "0.19"
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" 18
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMinor" 19
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "NoModify" 1
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "NoRepair" 1
SectionEnd

View File

@@ -18,6 +18,7 @@ class attachInteractor(base.baseInteractor):
super(attachInteractor, self).install(*args, **kwargs)
widgetUtils.connect_event(self.view.photo, widgetUtils.BUTTON_PRESSED, self.on_image)
widgetUtils.connect_event(self.view.audio, widgetUtils.BUTTON_PRESSED, self.on_audio)
widgetUtils.connect_event(self.view.document, widgetUtils.BUTTON_PRESSED, self.on_document)
if hasattr(self.view, "voice_message"):
widgetUtils.connect_event(self.view.voice_message, widgetUtils.BUTTON_PRESSED, self.on_upload_voice_message)
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_attachment)
@@ -44,6 +45,14 @@ class attachInteractor(base.baseInteractor):
widgetUtils.connect_event(m, widgetUtils.MENU, self.on_add_audio, menuitem=m.add)
self.view.PopupMenu(m, self.view.audio.GetPosition())
def on_document(self, *args, **kwargs):
""" display menu for adding document attachments. """
m = attachMenu()
# disable add from VK as it is not supported in documents, yet.
m.add.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.on_upload_document, menuitem=m.upload)
self.view.PopupMenu(m, self.view.photo.GetPosition())
def on_upload_image(self, *args, **kwargs):
""" allows uploading an image from the computer.
"""
@@ -57,6 +66,16 @@ class attachInteractor(base.baseInteractor):
if audio != None:
self.presenter.upload_audio(audio)
def on_upload_document(self, *args, **kwargs):
""" allows uploading a document from the computer.
"""
document = self.view.get_document()
if document != None:
if document.endswith(".mp3") or document.endswith(".exe"):
self.view.invalid_attachment()
return
self.presenter.upload_document(document)
def on_upload_voice_message(self, *args, **kwargs):
self.presenter.upload_voice_message()

View File

@@ -2,6 +2,7 @@
from __future__ import unicode_literals
import widgetUtils
from pubsub import pub
from wxUI.commonMessages import restart_program as restart_program_dialog
from . import base
class configurationInteractor(base.baseInteractor):
@@ -12,15 +13,22 @@ class configurationInteractor(base.baseInteractor):
def set_setting(self, tab, setting, value):
self.view.set_value(tab, setting, value)
def restart(self):
dlg = restart_program_dialog()
if dlg == widgetUtils.YES:
self.presenter.restart_application()
def install(self, *args, **kwargs):
super(configurationInteractor, self).install(*args, **kwargs)
pub.subscribe(self.create_tab, self.modulename+"_create_tab")
pub.subscribe(self.set_setting, self.modulename+"_set")
pub.subscribe(self.restart, self.modulename+"_restart_program")
def uninstall(self):
super(configurationInteractor, self).uninstall()
pub.unsubscribe(self.create_tab, self.modulename+"_create_tab")
pub.unsubscribe(self.set_setting, self.modulename+"_set")
pub.unsubscribe(self.restart, self.modulename+"_restart_program")
def start(self):
self.view.realize()
@@ -52,4 +60,5 @@ class configurationInteractor(base.baseInteractor):
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"))
self.presenter.update_setting(section="load_at_startup", setting="communities", value=self.view.get_value("startup", "communities"))
self.presenter.save_settings_file()
self.presenter.save_settings_file()
self.presenter.update_proxy(self.view.get_value("general", "use_proxy"))

View File

@@ -5,6 +5,7 @@ import widgetUtils
import wx
from pubsub import pub
from wxUI import menus
from wxUI import commonMessages
from .import base
class displayPostInteractor(base.baseInteractor):
@@ -37,7 +38,10 @@ class displayPostInteractor(base.baseInteractor):
def clean_list(self, list):
if not hasattr(self.view, list):
raise AttributeError("The control is not present in the view.")
getattr(self.view, control).clear()
getattr(self.view, list).clear()
def post_deleted(self):
msg = commonMessages.post_deleted()
def install(self, *args, **kwargs):
super(displayPostInteractor, self).install(*args, **kwargs)
@@ -58,6 +62,9 @@ class displayPostInteractor(base.baseInteractor):
pub.subscribe(self.add_items, self.modulename+"_add_items")
pub.subscribe(self.enable_attachments, self.modulename+"_enable_attachments")
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()
@@ -66,6 +73,8 @@ class displayPostInteractor(base.baseInteractor):
pub.unsubscribe(self.add_items, self.modulename+"_add_items")
pub.unsubscribe(self.enable_attachments, self.modulename+"_enable_attachments")
pub.unsubscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls")
pub.unsubscribe(self.post_deleted, self.modulename+"_post_deleted")
pub.unsubscribe(self.clean_list, self.modulename+"_clean_list")
def on_focus(self, *args, **kwargs):
item = self.view.comments.get_selected()
@@ -81,7 +90,7 @@ class displayPostInteractor(base.baseInteractor):
self.presenter.post_repost()
def on_reply(self, *args, **kwargs):
if hasattr(self.view, "repost"):
if hasattr(self.view, "repost") or not hasattr(self, "post_view"):
comment = self.view.comments.get_selected()
self.presenter.reply(comment)
else:
@@ -120,6 +129,11 @@ class displayPostInteractor(base.baseInteractor):
comment = self.view.comments.get_selected()
self.presenter.show_comment(comment)
def on_comment_changed(self, *args, **kwargs):
if hasattr(self.presenter, "change_comment"):
comment = self.view.comments.get_selected()
self.presenter.change_comment(comment)
class displayAudioInteractor(base.baseInteractor):
def set(self, control, value):
@@ -171,6 +185,37 @@ class displayAudioInteractor(base.baseInteractor):
post = self.view.get_audio()
self.presenter.remove_from_library(post)
class displayPollInteractor(base.baseInteractor):
def set(self, control, value):
if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.")
getattr(self.view, control).SetValue(value)
def done(self):
self.view.done()
def add_options(self, options, multiple):
self.view.add_options(options, multiple)
def install(self, *args, **kwargs):
super(displayPollInteractor, self).install(*args, **kwargs)
pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.done, self.modulename+"_done")
pub.subscribe(self.add_options, self.modulename+"_add_options")
def uninstall(self):
super(displayPollInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.done, self.modulename+"_done")
pub.unsubscribe(self.add_options, self.modulename+"_add_options")
def start(self, *args, **kwargs):
super(displayPollInteractor, self).start(*args, **kwargs)
if self.result == widgetUtils.OK: # USer votd.
answers = self.view.get_answers()
self.presenter.vote(answers)
class displayFriendshipInteractor(base.baseInteractor):
def add_items(self, control, items):

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,8 @@ import output
import logging
import keys
import application
#sys.excepthook = lambda x, y, z: logging.critical(''.join(traceback.format_exception(x, y, z)))
if hasattr(sys, "frozen"):
sys.excepthook = lambda x, y, z: logging.critical(''.join(traceback.format_exception(x, y, z)))
from mysc.thread_utils import call_threaded
from wxUI import commonMessages

View File

@@ -5,6 +5,7 @@ block_cipher = None
a = Analysis(['main.py'],
pathex=['.'],
binaries=[("sounds", "sounds"),
("documentation", "documentation"),
("locales", "locales"),
("..\\windows-dependencies\\x86\\oggenc2.exe", "."),
("..\\windows-dependencies\\x86\\bootstrap.exe", "."),

View File

@@ -63,6 +63,16 @@ class attachPresenter(base.basePresenter):
self.send_message("insert_attachment", attachment=info)
self.send_message("enable_control", control="remove")
def upload_document(self, document):
""" allows uploading a document from the computer.
"""
doc_info = {"type": "document", "file": document, "from": "local", "title": os.path.basename(os.path.splitext(document)[0])}
self.attachments.append(doc_info)
# Translators: This is the text displayed in the attachments dialog, when the user adds a document.
info = [_("Document"), os.path.basename(document)]
self.send_message("insert_attachment", attachment=info)
self.send_message("enable_control", control="remove")
def upload_voice_message(self):
a = audioRecorder.audioRecorderPresenter(view=views.audioRecorderDialog(), interactor=interactors.audioRecorderInteractor())
if a.file != None and a.duration != 0:

View File

@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import config
from mysc import restart
from . import base
class configurationPresenter(base.basePresenter):
@@ -43,6 +45,7 @@ class configurationPresenter(base.basePresenter):
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="chat")
self.send_message("set", tab="chat", setting="notify_online", value=self.session.settings["chat"]["notify_online"])
@@ -63,4 +66,13 @@ class configurationPresenter(base.basePresenter):
self.session.settings[section][setting] = value
def save_settings_file(self):
self.session.settings.write()
self.session.settings.write()
def update_proxy(self, proxy_value):
if proxy_value != config.app["app-settings"]["use_proxy"]:
config.app["app-settings"]["use_proxy"] = proxy_value
config.app.write()
self.send_message("restart_program")
def restart_application(self):
restart.restart_program()

836
src/presenters/main.py Normal file
View File

@@ -0,0 +1,836 @@
# -*- coding: utf-8 -*-
import time
import os
import webbrowser
import logging
import output
import interactors
import views
import config
from vk_api.exceptions import LoginRequired, VkApiError
from requests.exceptions import ConnectionError
from pubsub import pub
from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded
from mysc import localization
from sessionmanager import session, utils, renderers
from update import updater
from issueReporter import issueReporter
from controller import buffers, selector
from . import player, longpollthread
from . import base
log = logging.getLogger("controller.main")
class Controller(base.basePresenter):
def search(self, tab_name):
for i in range(0, len(self.buffers)):
if self.buffers[i].name == tab_name:
return self.buffers[i]
return False
def get_all_buffers(self, contains):
results = []
for i in self.buffers:
if contains in i.name:
results.append(i)
return results
def __init__(self, *args, **kwargs):
super(Controller, self).__init__(*args, **kwargs)
log.debug("Starting main controller...")
self.buffers = []
player.setup()
self.session = session.sessions[list(session.sessions.keys())[0]]
self.create_controls()
call_threaded(updater.do_update, update_type=self.session.settings["general"]["update_channel"])
def create_buffer(self, buffer_type="baseBuffer", buffer_title="", parent_tab=None, loadable=False, get_items=False, kwargs={}):
if not hasattr(buffers, buffer_type):
raise AttributeError("Specified buffer type does not exist.")
buffer = getattr(buffers, buffer_type)(**kwargs)
if loadable:
buffer.can_get_items = False
self.buffers.append(buffer)
if parent_tab == None:
self.send_message("add_buffer", widget=buffer.tab, title=buffer_title)
else:
self.send_message("insert_buffer", widget=buffer.tab, title=buffer_title, parent=parent_tab)
if get_items:
call_threaded(buffer.get_items)
def create_empty_buffer(self, buffer_type="empty", buffer_title="", parent_tab=None, kwargs={}):
if not hasattr(buffers, buffer_type):
raise AttributeError("Specified buffer type does not exist.")
buffer = getattr(buffers, buffer_type)(**kwargs)
self.buffers.append(buffer)
if parent_tab == None:
self.window.add_buffer(buffer.tab, buffer_title)
else:
self.window.insert_buffer(buffer.tab, buffer_title, self.window.search(parent_tab))
def create_controls(self):
log.debug("Creating controls for the window...")
pub.sendMessage("create_empty_buffer", buffer_title=_("Posts"), kwargs=dict(parent=self.window.tb, name="posts"))
pub.sendMessage("create_buffer", buffer_type="baseBuffer", buffer_title=_("Home"), parent_tab="posts", kwargs=dict(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="render_newsfeed_item", endpoint="newsfeed", count=self.session.settings["buffers"]["count_for_wall_buffers"]))
pub.sendMessage("create_buffer", buffer_type="feedBuffer", buffer_title=_("My wall"), parent_tab="posts", kwargs=dict(parent=self.window.tb, name="me_feed", composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"]))
pub.sendMessage("create_empty_buffer", buffer_title=_("Music"), kwargs=dict(parent=self.window.tb, name="audios"))
pub.sendMessage("create_buffer", buffer_type="audioBuffer", buffer_title=_("My audios"), parent_tab="audios", kwargs=dict(parent=self.window.tb, name="me_audio", composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio"))
if self.session.settings["vk"]["use_alternative_tokens"] == False:
pub.sendMessage("create_buffer", buffer_type="audioBuffer", buffer_title=_("Populars"), parent_tab="audios", kwargs=dict(parent=self.window.tb, name="popular_audio", composefunc="render_audio", session=self.session, endpoint="getPopular", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"]))
pub.sendMessage("create_buffer", buffer_type="audioBuffer", buffer_title=_("Recommendations"), parent_tab="audios", kwargs=dict(parent=self.window.tb, name="recommended_audio", composefunc="render_audio", session=self.session, endpoint="getRecommendations", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"]))
pub.sendMessage("create_empty_buffer", buffer_type="empty", buffer_title=_("Albums"), parent_tab="audios", kwargs=dict(parent=self.window.tb, name="albums"))
pub.sendMessage("create_empty_buffer", buffer_title=_("Video"), kwargs=dict(parent=self.window.tb, name="videos"))
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_empty_buffer", buffer_title=_("Albums"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="video_albums"))
pub.sendMessage("create_empty_buffer", buffer_title=_("People"), kwargs=dict(parent=self.window.tb, name="people"))
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("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_empty_buffer", 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="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_empty_buffer", buffer_title=_("Communities"), kwargs=dict(parent=self.window.tb, name="communities"))
pub.sendMessage("create_empty_buffer", buffer_title=_("Chats"), kwargs=dict(parent=self.window.tb, name="chats"))
pub.sendMessage("create_empty_buffer", buffer_title=_("Timelines"), kwargs=dict(parent=self.window.tb, name="timelines"))
self.window.realize()
self.repeatedUpdate = RepeatingTimer(120, self.update_all_buffers)
self.repeatedUpdate.start()
self.readMarker = RepeatingTimer(60, self.mark_as_read)
self.readMarker.start()
def connect_events(self):
log.debug("Connecting events to responses...")
pub.subscribe(self.in_post, "posted")
pub.subscribe(self.download, "download-file")
pub.subscribe(self.play_audio, "play-audio")
pub.subscribe(self.play_audios, "play-audios")
pub.subscribe(self.view_post, "open-post")
pub.subscribe(self.update_status_bar, "update-status-bar")
pub.subscribe(self.chat_from_id, "new-chat")
pub.subscribe(self.authorisation_failed, "authorisation-failed")
pub.subscribe(self.user_profile, "user-profile")
pub.subscribe(self.user_online, "user-online")
pub.subscribe(self.user_offline, "user-offline")
pub.subscribe(self.notify, "notify")
pub.subscribe(self.handle_longpoll_read_timeout, "longpoll-read-timeout")
pub.subscribe(self.create_buffer, "create_buffer")
pub.subscribe(self.create_empty_buffer, "create_empty_buffer")
pub.subscribe(self.user_typing, "user-typing")
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.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_)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.get_more_items, menuitem=self.window.load_previous_items)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog)
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)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_audio_album, menuitem=self.window.delete_audio_album)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_video_album, menuitem=self.window.video_album)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_video_album, menuitem=self.window.delete_video_album)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_documentation, menuitem=self.window.documentation)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_pause, menuitem=self.window.player_play)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_next, menuitem=self.window.player_next)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_previous, menuitem=self.window.player_previous)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_all, menuitem=self.window.player_play_all)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_down, menuitem=self.window.player_volume_down)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_up, menuitem=self.window.player_volume_up)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute)
pub.subscribe(self.get_chat, "order-sent-message")
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile, menuitem=self.window.view_profile)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile_in_browser, menuitem=self.window.open_in_browser)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.set_status, menuitem=self.window.set_status)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_report_error, menuitem=self.window.report)
self.window.tb.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu)
def disconnect_events(self):
log.debug("Disconnecting some events...")
pub.unsubscribe(self.in_post, "posted")
pub.unsubscribe(self.download, "download-file")
pub.unsubscribe(self.play_audio, "play-audio")
pub.unsubscribe(self.authorisation_failed, "authorisation-failed")
pub.unsubscribe(self.play_audios, "play-audios")
pub.unsubscribe(self.view_post, "open-post")
pub.unsubscribe(self.update_status_bar, "update-status-bar")
pub.unsubscribe(self.user_online, "user-online")
pub.unsubscribe(self.user_offline, "user-offline")
pub.unsubscribe(self.notify, "notify")
def on_context_menu(self, event, *args, **kwargs):
""" Handles context menu event in the tree buffers."""
# If the focus is not in the TreeCtrl of the Treebook, then we should not display any menu.
if isinstance(self.window.FindFocus(), wx.TreeCtrl) == False:
event.Skip()
return
menu = None
# Get the current buffer and let's choose a different menu depending on the selected buffer.
current_buffer = self.get_current_buffer()
# Deal with menu for community buffers.
if current_buffer.name.endswith("_community"):
menu = menus.communityBufferMenu()
# disable post loading if the community has already loaded posts.
if current_buffer.can_get_items:
menu.load_posts.Enable(False)
# Disable loading of audios, videos, documents or topics depending in two conditions.
# 1. If the buffer already exists, which means they are already loaded, or
# 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"]:
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"]:
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"]:
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"]:
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)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_topics, menuitem=menu.load_topics)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_audios, menuitem=menu.load_audios)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_videos, menuitem=menu.load_videos)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_documents, menuitem=menu.load_documents)
# Deal with the communities section itself.
if current_buffer.name == "communities":
menu = wx.Menu()
# Insert a different option depending if group buffers are loaded or scheduled to be loaded or not.
if self.session.settings["load_at_startup"]["communities"] == False and not hasattr(self.session, "groups"):
option = menu.Append(wx.NewId(), _("Load groups"))
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_buffers, menuitem=option)
else:
option = menu.Append(wx.NewId(), _("Discard groups"))
widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_community_buffers, menuitem=option)
if menu != None:
self.window.PopupMenu(menu, self.window.FindFocus().GetPosition())
# If there are no available menus, let's indicate it.
else:
output.speak(_("menu unavailable for this buffer."))
def authorisation_failed(self):
commonMessages.bad_authorisation()
def login(self):
self.window.change_status(_("Logging in VK"))
self.session.login()
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,))
i.get_items()
self.window.change_status(_("Ready"))
self.create_unread_messages()
self.status_setter = RepeatingTimer(280, self.set_online)
self.status_setter.start()
self.set_online(notify=True)
self.get_audio_albums(self.session.user_id)
self.get_video_albums(self.session.user_id)
self.get_communities(self.session.user_id)
self.create_longpoll_thread()
def create_longpoll_thread(self, notify=False):
try:
self.longpoll = longpollthread.worker(self.session)
self.longpoll.start()
if notify:
self.notify(message=_("Chat server reconnected"))
except ConnectionError:
pub.sendMessage("longpoll-read-timeout")
def in_post(self, buffer):
buffer = self.search(buffer)
buffer.get_items()
buffer = self.search("home_timeline")
buffer.get_items()
def update_all_buffers(self):
log.debug("Updating buffers...")
self.get_audio_albums(self.session.user_id, create_buffers=False)
self.get_video_albums(self.session.user_id, create_buffers=False)
for i in self.buffers:
if hasattr(i, "get_items"):
i.get_items()
log.debug("Updated %s" % (i.name))
def download(self, url, filename):
log.debug("downloading %s URL to %s filename" % (url, filename,))
call_threaded(utils.download_file, url, filename, self.window)
def play_audio(self, audio_object):
# Restricted audios don't include an URL paramether.
# Restriction can be due to licensed content to unauthorized countries.
if "url" in audio_object and audio_object["url"] =="":
self.notify(message=_("This file could not be played because it is not allowed in your country"))
return
call_threaded(player.player.play, audio_object, fresh=True)
def play_audios(self, audios):
player.player.play_all(audios, shuffle=self.window.player_shuffle.IsChecked())
def view_post(self, post_object, controller_):
p = getattr(presenters, controller_+"Presenter")(session=self.session, postObject=post_object, interactor=getattr(interactors, controller_+"Interactor")(), view=getattr(views, controller_)())
def exit(self, *args, **kwargs):
log.debug("Receibed an exit signal. closing...")
self.set_offline()
self.disconnect_events()
volume = player.player.volume
config.app["sound"]["volume"] = volume
config.app.write()
self.window.Destroy()
wx.GetApp().ExitMainLoop()
def update_buffer(self, *args, **kwargs):
b = self.get_current_buffer()
b.get_items()
def get_more_items(self, *args, **kwargs):
b = self.get_current_buffer()
b.get_more_items()
def check_for_updates(self, *args, **kwargs):
update = updater.do_update(update_type=self.session.settings["general"]["update_channel"])
if update == False:
commonMessages.no_update_available()
def search_audios(self, *args, **kwargs):
dlg = searchDialogs.searchAudioDialog()
if dlg.get_response() == widgetUtils.OK:
q = dlg.get("term")
auto_complete = True
count = 300
performer_only = dlg.get_state("title")
sort = dlg.get_sort_order()
newbuff = buffers.audioBuffer(parent=self.window.tb, name="{0}_audiosearch".format(q,), session=self.session, composefunc="render_audio", parent_endpoint="audio", endpoint="search", q=q, auto_complete=auto_complete, count=count, performer_only=performer_only, sort=sort)
self.buffers.append(newbuff)
call_threaded(newbuff.get_items)
# Translators: {0} will be replaced with the search term.
self.window.insert_buffer(newbuff.tab, _("Search for {0}").format(q,), self.window.search("audios"))
def search_videos(self, *args, **kwargs):
dlg = searchDialogs.searchVideoDialog()
if dlg.get_response() == widgetUtils.OK:
params = {}
params["q"] = dlg.get("term")
params["count"] = 200
hd = dlg.get_checkable("hd")
if hd != 0:
params["hd"] = 1
params["adult"] = dlg.get_checkable("safe_search")
params["sort"] = dlg.get_sort_order()
# params["filters"] = "youtube, vimeo, short, long, mp4"
print(params)
newbuff = buffers.videoBuffer(parent=self.window.tb, name="{0}_videosearch".format(params["q"],), session=self.session, composefunc="render_video", parent_endpoint="video", endpoint="search", **params)
self.buffers.append(newbuff)
call_threaded(newbuff.get_items)
# Translators: {0} will be replaced with the search term.
self.window.insert_buffer(newbuff.tab, _("Search for {0}").format(params["q"],), self.window.search("videos"))
def update_status_bar(self, status):
self.window.change_status(status)
def remove_buffer(self, event, mandatory=False, *args, **kwargs):
buffer = self.get_current_buffer()
buff = self.window.search(buffer.name)
answer = buffer.remove_buffer(mandatory)
if answer == False:
return
self.window.remove_buffer(buff)
self.buffers.remove(buffer)
del buffer
def changelog(self, *args, **kwargs):
lang = localization.get("documentation")
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 new_timeline(self, *args, **kwargs):
b = self.get_current_buffer()
# If executing this method from an empty buffer we should get the newsfeed buffer.
if not hasattr(b, "get_users"):
b = self.search("home_timeline")
# Get a list of (id, user) objects.
d = []
for i in self.session.db["users"]:
d.append((i, self.session.get_user(i)["user1_gen"]))
# Do the same for communities.
for i in self.session.db["groups"]:
d.append((-i, self.session.get_user(-i)["user1_nom"]))
a = timeline.timelineDialog([i[1] for i in d])
if a.get_response() == widgetUtils.OK:
user = a.get_user()
buffertype = a.get_buffer_type()
user_id = ""
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"))
def complete_buffer_creation(self, buffer, name_, position):
answer = buffer.get_items()
if answer is not True:
commonMessages.show_error_code(answer)
return
self.buffers.append(buffer)
self.window.insert_buffer(buffer.tab, name_, position)
def search_chat_buffer(self, user_id):
for i in self.buffers:
if "_messages" in i.name:
if "peer_id" in i.kwargs and i.kwargs["peer_id"] == user_id: return i
return None
def chat_from_id(self, user_id, setfocus=True, unread=False):
b = self.search_chat_buffer(user_id)
if b != None:
pos = self.window.search(b.name)
if setfocus:
self.window.change_buffer(pos)
return b.tab.text.SetFocus()
return
# Get name based in the ID.
# for users.
if user_id > 0 and user_id < 2000000000:
user = self.session.get_user(user_id, key="user1")
name = user["user1_nom"]
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", 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"))
# if setfocus:
# pos = self.window.search(buffer.name)
# self.window.change_buffer(pos)
# call_threaded(buffer.get_items, unread=unread)
# if setfocus: buffer.tab.text.SetFocus()
# return True
def user_online(self, event):
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"])
def user_offline(self, event):
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"])
def user_typing(self, obj):
buffer = self.search_chat_buffer(obj.user_id)
if buffer != None and buffer == self.get_current_buffer():
user = self.session.get_user(obj.user_id)
output.speak(_("{user1_nom} is typing...").format(**user))
def get_chat(self, obj=None):
""" Searches or creates a chat buffer with the id of the user that is sending or receiving a message.
obj vk_api.longpoll.EventType: an event wich defines some data from the vk's long poll server."""
message = {}
uid = obj.peer_id
buffer = self.search_chat_buffer(uid)
if obj.from_me:
message.update(out=0)
# If there is no buffer, we must create one in a wxThread so it will not crash.
if buffer == None:
wx.CallAfter(self.chat_from_id, uid, setfocus=self.session.settings["chat"]["automove_to_conversations"], unread=True)
self.session.soundplayer.play("conversation_opened.ogg")
return
# If the chat already exists, let's create a dictionary wich will contains data of the received message.
message.update(id=obj.message_id, user_id=uid, date=obj.timestamp, body=utils.clean_text(obj.text), attachments=obj.attachments)
# if attachments is true, let's request for the full message with attachments formatted in a better way.
# ToDo: code improvements. We shouldn't need to request the same message again just for these attachments.
if len(message["attachments"]) != 0:
message_ids = message["id"]
results = self.session.vk.client.messages.getById(message_ids=message_ids)
message = results["items"][0]
if obj.from_me:
message["from_id"] = self.session.user_id
else:
message.update(read_state=0, out=0)
message["from_id"] = obj.user_id
data = [message]
# Let's add this to the buffer.
# ToDo: Clean this code and test how is the database working with this set to True.
num = self.session.order_buffer(buffer.name, data, True)
buffer.insert(self.session.db[buffer.name]["items"][-1], False)
self.session.soundplayer.play("message_received.ogg")
wx.CallAfter(self.reorder_buffer, buffer)
# Check if we have to read the message aloud
if buffer == self.get_current_buffer():
rendered_message = renderers.render_message(message, self.session)
output.speak(rendered_message[0])
def set_online(self, notify=False):
try:
r = self.session.vk.client.account.setOnline()
except:
log.error("Error in setting online for the current user")
if notify:
self.window.notify("Socializer", "online now!")
def set_offline(self):
try:
r = self.session.vk.client.account.setOffline()
except:
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.")
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)
def mark_as_read(self):
for i in self.buffers:
if hasattr(i, "reads") and len(i.reads) != 0:
response = self.session.vk.client.messages.markAsRead(peer_id=i.kwargs["peer_id"])
i.clear_reads()
i.reads = []
time.sleep(1)
def get_audio_albums(self, user_id=None, create_buffers=True):
if self.session.settings["load_at_startup"]["audio_albums"] == False:
return
log.debug("Create audio albums...")
if self.session.settings["vk"]["use_alternative_tokens"]:
albums = self.session.vk.client_audio.get_albums(owner_id=user_id)
else:
albums = self.session.vk.client.audio.getPlaylists(owner_id=user_id)
albums = albums["items"]
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="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)
def get_video_albums(self, user_id=None, create_buffers=True):
if self.session.settings["load_at_startup"]["video_albums"] == False:
return
log.debug("Create video albums...")
albums = self.session.vk.client.video.getAlbums(owner_id=user_id)
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)
def get_communities(self, user_id=None, create_buffers=True, force_action=False):
if self.session.settings["vk"]["invited_to_group"] == False:
self.session.settings["vk"]["invited_to_group"] = True
self.session.settings.write()
socializer_group = self.session.vk.client.groups.getById(group_ids="175825000")[0]
if socializer_group["is_member"] ==False:
d = commonMessages.join_group()
self.session.settings["vk"]["invited_to_group"] = True
self.session.settings.write()
if d == widgetUtils.YES:
result = self.session.vk.client.groups.join(group_id=socializer_group["id"])
if result == 1:
commonMessages.group_joined()
else:
log.error("Invalid result when joining the Socializer's group: %d" % (result))
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)
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", count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"]))
time.sleep(0.15)
def create_audio_album(self, *args, **kwargs):
d = creation.audio_album()
if d.get_response() == widgetUtils.OK and d.get("title") != "":
response = self.session.vk.client.audio.createPlaylist(owner_id=self.session.user_id, title=d.get("title"))
if "id" not in response:
return
album_id = response["id"]
buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(album_id,), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=self.session.user_id, album_id=album_id)
buffer.can_get_items = False
# Translators: {0} will be replaced with an audio album's title.
name_ = _("Album: {0}").format(d.get("title"),)
self.buffers.append(buffer)
self.window.insert_buffer(buffer.tab, name_, self.window.search("albums"))
buffer.get_items()
self.get_audio_albums(user_id=self.session.user_id, create_buffers=False)
def delete_audio_album(self, *args, **kwargs):
if len(self.session.audio_albums) == 0:
return commonMessages.no_audio_albums()
answer = selector.album(_("Select the album you want to delete"), self.session)
if answer.item == None:
return
response = commonMessages.delete_audio_album()
if response != widgetUtils.YES: return
removal = self.session.vk.client.audio.deletePlaylist(playlist_id=answer.item, owner_id=self.session.user_id)
if removal == 1:
buffer = self.search("{0}_audio_album".format(answer.item,))
buff = self.window.search(buffer.name)
self.window.remove_buffer(buff)
self.buffers.remove(buffer)
del buffer
self.get_audio_albums(user_id=self.session.user_id, create_buffers=False)
def create_video_album(self, *args, **kwargs):
d = creation.audio_album()
if d.get_response() == widgetUtils.OK and d.get("title") != "":
response = self.session.vk.client.video.addAlbum(title=d.get("title"))
if ("album_id" in response) == False: return
album_id = response["album_id"]
buffer = buffers.videoAlbum(parent=self.window.tb, name="{0}_video_album".format(album_id,), composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], user_id=self.session.user_id, album_id=album_id)
buffer.can_get_items = False
# Translators: {0} will be replaced with a video album's title.
name_ = _("Album: {0}").format(d.get("title"),)
self.buffers.append(buffer)
self.window.insert_buffer(buffer.tab, name_, self.window.search("video_albums"))
buffer.get_items()
self.session.video_albums = self.session.vk.client.video.getAlbums(owner_id=self.session.user_id)["items"]
def delete_video_album(self, *args, **kwargs):
if len(self.session.video_albums) == 0:
return commonMessages.no_video_albums()
answer = selector.album(_("Select the album you want to delete"), self.session, "video_albums")
if answer.item == None:
return
response = commonMessages.delete_audio_album()
if response != widgetUtils.YES: return
removal = self.session.vk.client.video.deleteAlbum(album_id=answer.item)
buffer = self.search("{0}_video_album".format(answer.item,))
buff = self.window.search(buffer.name)
self.window.remove_buffer(buff)
self.buffers.remove(buffer)
del buffer
self.session.video_albums = self.session.vk.client.video.getAlbums(owner_id=self.session.user_id)["items"]
def check_documentation(self, *args, **kwargs):
lang = localization.get("documentation")
os.chdir("documentation/%s" % (lang,))
webbrowser.open("manual.html")
os.chdir("../../")
def menu_play_pause(self, *args, **kwargs):
if player.player.stream != None:
return player.player.pause()
else:
b = self.get_current_buffer()
if hasattr(b, "play_all"):
b.play_all()
else:
self.search("me_audio").play_all()
def menu_play_next(self, *args, **kwargs):
return player.player.play_next()
# b = self.get_current_buffer()
# if hasattr(b, "play_next"):
# b.play_next()
# else:
# self.search("me_audio").play_next()
def menu_play_previous(self, *args, **kwargs):
return player.player.play_previous()
# b = self.get_current_buffer()
# if hasattr(b, "play_previous"):
# b.play_previous()
# else:
# self.search("me_audio").play_previous()
def menu_play_all(self, *args, **kwargs):
b = self.get_current_buffer()
if hasattr(b, "play_all"):
b.play_all()
else:
self.search("me_audio").play_all()
def menu_volume_down(self, *args, **kwargs):
player.player.volume = player.player.volume-5
def menu_volume_up(self, *args, **kwargs):
player.player.volume = player.player.volume+5
def menu_mute(self, *args, **kwargs):
player.player.volume = 0
def user_profile(self, person):
p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor())
def view_my_profile(self, *args, **kwargs):
self.user_profile(self.session.user_id)
def view_my_profile_in_browser(self, *args, **kwargs):
webbrowser.open_new_tab("https://vk.com/id{id}".format(id=self.session.user_id,))
def notify(self, message="", sound="", type="native"):
if type == "native":
self.window.notify(_("Socializer"), message)
else:
if sound != "":
self.session.soundplayer.play(sound)
if message != "":
output.speak(message)
def handle_longpoll_read_timeout(self):
if hasattr(self, "longpoll"):
self.notify(message=_("Chat disconnected. Trying to connect in 60 seconds"))
time.sleep(60)
if hasattr(self, "longpoll"):
del self.longpoll
self.create_longpoll_thread(notify=True)
def set_status(self, *args, **kwargs):
dlg = wx.TextEntryDialog(self.window, _("Write your status message"), _("Set status"))
if dlg.ShowModal() == widgetUtils.OK:
result = dlg.GetValue()
info = self.session.vk.client.account.saveProfileInfo(status=result)
commonMessages.updated_status()
dlg.Destroy()
def on_report_error(self, *args, **kwargs):
r = issueReporter.reportBug()
def reorder_buffer(self, buffer):
""" this puts the chat buffers at the top of the list when there are new incoming messages.
In order to do so, we search for the current buffer's tab, remove the page from the TreeCtrl (without destroying the associated tab)
and reinsert it as a new child of the chat buffer.
Lastly we ensure the user is focused in the same buffer than before."""
buffer_window = self.window.search(buffer.name)
# If buffer window is already in the first position after chat, we should not do anything here because calculations for moving buffers are expensive.
if buffer_window == self.window.search("chats")+1:
return
# Gets buffer title so we don't have to generate it again in future.
buffer_title = self.window.get_buffer_text(buffer_window)
# Determine if the current buffer is the buffer receiving a new message.
if buffer == self.get_current_buffer():
focused_buffer = True
else:
focused_buffer = False
# This call will not destroy the associated tab for the chat buffer, thus allowing us to readd it in other position.
self.window.remove_buffer_from_position(buffer_window)
self.window.insert_chat_buffer(buffer.tab, buffer_title, self.window.search("chats")+1)
# Let's manipulate focus so users will not notice the change in buffers.
if focused_buffer:
new_position = self.window.search(buffer.name)
self.window.change_buffer(new_position)
else:
new_position = self.window.search(self.get_current_buffer().name)
self.window.change_buffer(new_position)
def load_community_posts(self, *args, **kwargs):
""" Load community posts. It just calls to the needed method in the community buffer."""
current_buffer = self.get_current_buffer()
if current_buffer.name.endswith("_community"):
current_buffer.load_community()
def load_community_audios(self, *args, **kwargs):
""" 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"]:
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"]))
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"]:
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"]))
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"]:
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))
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"]:
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"]))
def load_community_buffers(self, *args, **kwargs):
""" Load all community buffers regardless of the setting present in optional buffers tab of the preferences dialog."""
call_threaded(self.get_communities, self.session.user_id, force_action=True)
def unload_community_buffers(self, *args, **kwargs):
""" Delete all buffers belonging to groups."""
communities = self.get_all_buffers("_community")
for buffer in communities:
buff = self.window.search(buffer.name)
self.window.remove_buffer(buff)
self.buffers.remove(buffer)
del self.session.groups

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
import random
import output
@@ -25,19 +24,17 @@ class audioPlayer(object):
def __init__(self):
self.is_playing = False
self.stream = None
self.vol = 100
self.vol = config.app["sound"]["volume"]
self.is_working = False
self.queue = []
self.playing_track = 0
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
# Adds proxy settings
if config.app["app-settings"]["use_proxy"] == True:
bassconfig["net_proxy"] = b"socializer:socializer@socializer.su:3128"
def play(self, url, set_info=True):
def play(self, url, set_info=True, fresh=False):
if self.stream != None and self.stream.is_playing == True:
try:
self.stream.stop()
@@ -45,7 +42,7 @@ class audioPlayer(object):
log.exception("error when stopping the file")
self.stream = None
self.stopped = True
if hasattr(self, "worker") and self.worker != None:
if fresh == True and hasattr(self, "worker") and self.worker != None:
self.worker.cancel()
self.worker = None
self.queue = []
@@ -95,8 +92,7 @@ class audioPlayer(object):
@property
def volume(self):
if self.stream != None:
return self.vol
return self.vol
@volume.setter
def volume(self, vol):
@@ -106,23 +102,42 @@ class audioPlayer(object):
self.stream.volume = self.vol/100.0
def play_all(self, list_of_urls, shuffle=False):
self.playing_track = 0
self.stop()
# Skip all country restricted tracks as they are not playable here.
self.queue = [i for i in list_of_urls if i["url"] != ""]
if shuffle:
random.shuffle(self.queue)
self.play(self.queue[0])
self.queue.remove(self.queue[0])
self.play(self.queue[self.playing_track])
self.worker = RepeatingTimer(5, self.player_function)
self.worker.start()
def player_function(self):
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:
if len(self.queue) == 0 or self.playing_track >= len(self.queue):
self.worker.cancel()
return
self.play(self.queue[0])
self.queue.remove(self.queue[0])
if self.playing_track < len(self.queue):
self.playing_track += 1
self.play(self.queue[self.playing_track])
def play_next(self):
if len(self.queue) == 0:
return
if self.playing_track < len(self.queue)-1:
self.playing_track += 1
else:
self.playing_track = 0
self.play(self.queue[self.playing_track])
def play_previous(self):
if len(self.queue) == 0:
return
if self.playing_track <= 0:
self.playing_track = len(self.queue)-1
else:
self.playing_track -= 1
self.play(self.queue[self.playing_track])
def check_is_playing(self):
if self.stream == None:

View File

@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
import os
import six
import threading
@@ -22,18 +20,10 @@ from .postCreation import createPostPresenter
log = logging.getLogger(__file__)
def get_user(id, profiles):
""" Returns an user name and last name based in the id receibed."""
for i in profiles:
if i["id"] == id:
return "{0} {1}".format(i["first_name"], i["last_name"])
# Translators: This string is used when socializer can't find the right user information.
return _("Unknown username")
def get_message(status):
message = ""
if "text" in status:
message = renderers.clean_text(status["text"])
message = utils.clean_text(status["text"])
return message
class displayPostPresenter(base.basePresenter):
@@ -56,14 +46,19 @@ class displayPostPresenter(base.basePresenter):
else:
self.user_identifier = "owner_id"
self.post_identifier = "id"
self.worker = threading.Thread(target=self.load_all_components)
self.worker.finished = threading.Event()
self.worker.start()
self.attachments = []
self.load_images = False
# We'll put images here, so it will be easier to work with them.
self.images = []
self.imageIndex = 0
result = self.get_post_information()
# Stop loading everything else if post was deleted.
if result == False:
self.interactor.uninstall()
return
self.worker = threading.Thread(target=self.load_all_components)
self.worker.finished = threading.Event()
self.worker.start()
self.run()
def get_comments(self):
@@ -72,16 +67,21 @@ class displayPostPresenter(base.basePresenter):
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_ = []
# 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.
# For example, self reference to a group is marked as "Administrator", which would ruin this profile to be rendered somewhere else.
data = dict(groups=[], profiles=self.comments["profiles"])
self.session.process_usernames(data)
for i in self.comments["items"]:
# If comment has a "deleted" key it should not be displayed, obviously.
if "deleted" in i:
continue
from_ = get_user(i["from_id"], self.comments["profiles"])
from_ = self.session.get_user(i["from_id"])["user1_nom"]
if "reply_to_user" in i:
extra_info = get_user(i["reply_to_user"], self.comments["profiles"])
extra_info = self.session.get_user(i["reply_to_user"])["user1_nom"]
from_ = _("{0} > {1}").format(from_, extra_info)
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
fixed_text = re.sub("^\[id\d+\|\D+\], ", "", i["text"])
fixed_text = utils.clean_text(i["text"])
if len(fixed_text) > 140:
text = fixed_text[:141]
else:
@@ -110,6 +110,10 @@ class displayPostPresenter(base.basePresenter):
# Retrieve again the post, so we'll make sure to get the most up to date information.
# And we add a counter for views.
post = self.session.vk.client.wall.getById(posts="{owner_id}_{post_id}".format(owner_id=self.post[self.user_identifier], post_id=self.post[self.post_identifier]))
# If this post has been deleted, let's send an event to the interactor so it won't be displayed.
if len(post) == 0:
self.send_message("post_deleted")
return False
self.post = post[0]
if "views" in self.post and self.post["views"]["count"] > 0:
self.send_message("set", control="views", value=str(self.post["views"]["count"]))
@@ -135,6 +139,7 @@ class displayPostPresenter(base.basePresenter):
def get_attachments(self, post, text):
attachments = []
self.attachments = []
if "attachments" in post:
for i in post["attachments"]:
# We don't need the photos_list attachment, so skip it.
@@ -158,6 +163,8 @@ class displayPostPresenter(base.basePresenter):
if len(self.attachments) > 0:
self.send_message("enable_attachments")
self.send_message("add_items", control="attachments", items=attachments)
else:
self.interactor.view.attachments.list.Enable(False)
def check_image_load(self):
if self.load_images and len(self.images) > 0 and self.session.settings["general"]["load_images"]:
@@ -204,7 +211,6 @@ class displayPostPresenter(base.basePresenter):
return url
def load_all_components(self):
self.get_post_information()
self.get_likes()
self.get_reposts()
self.get_comments()
@@ -289,7 +295,7 @@ class displayPostPresenter(base.basePresenter):
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 = re.sub("^\[id\d+\|\D+\], ", "", comment_object["text"])
fixed_text = utils.clean_text(comment_object["text"])
if len(fixed_text) > 140:
text = fixed_text[:141]
else:
@@ -398,6 +404,8 @@ class displayPostPresenter(base.basePresenter):
break
if url != "":
webbrowser.open_new_tab(url)
elif attachment["type"] == "poll":
a = displayPollPresenter(session=self.session, poll=attachment, interactor=interactors.displayPollInteractor(), view=views.displayPoll())
else:
log.debug("Unhandled attachment: %r" % (attachment,))
@@ -454,7 +462,7 @@ class displayCommentPresenter(displayPostPresenter):
self.get_attachments(self.post, message)
self.check_image_load()
def reply(self):
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"])
@@ -476,7 +484,7 @@ class displayCommentPresenter(displayPostPresenter):
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 = re.sub("^\[id\d+\|\D+\], ", "", i["text"])
fixed_text = utils.clean_text(i["text"])
if len(fixed_text) > 140:
text = fixed_text[:141]
else:
@@ -494,6 +502,192 @@ class displayCommentPresenter(displayPostPresenter):
a = displayCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
self.clear_comments_list()
class displayTopicCommentPresenter(displayCommentPresenter):
def get_post_information(self):
from_ = self.session.get_user(self.post[self.user_identifier])
title = from_["user1_nom"]
self.send_message("set_title", value=title)
message = ""
message = get_message(self.post)
self.send_message("set", control="post_view", value=message)
self.get_attachments(self.post, message)
self.check_image_load()
self.send_message("disable_control", control="reply")
self.send_message("disable_control", control="comments")
class displayTopicPresenter(displayPostPresenter):
def __init__(self, session, postObject, group_id, view, interactor):
self.type = "topic"
self.modulename = "display_topic"
self.interactor = interactor
self.view = view
self.interactor.install(view=view, presenter=self, modulename=self.modulename)
self.session = session
self.post = postObject
self.group_id = group_id
self.load_images = False
# We'll put images here, so it will be easier to work with them.
self.images = []
self.imageIndex = 0
result = self.get_post_information()
# Stop loading everything else if post was deleted.
if result == False:
self.interactor.uninstall()
return
self.worker = threading.Thread(target=self.load_all_components)
self.worker.finished = threading.Event()
self.worker.start()
self.attachments = []
self.run()
def load_all_components(self):
self.get_comments()
def get_post_information(self):
title = self.post["title"]
self.send_message("set_title", value=title)
return True
def get_comments(self):
""" Get comments and insert them in a list."""
self.comments = self.session.vk.client.board.getComments(group_id=self.group_id, topic_id=self.post["id"], need_likes=1, count=100, extended=1)
comments_ = []
data = dict(profiles=self.comments["profiles"], groups=[])
self.session.process_usernames(data)
for i in self.comments["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"])["user1_nom"]
# match user mentions inside text comment.
original_date = arrow.get(i["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
likes = str(i["likes"]["count"])
text = utils.clean_text(text=i["text"])
comments_.append((from_, text, created_at, likes))
self.send_message("add_items", control="comments", items=comments_)
def post_like(self):
c = self.interactor.view.comments.get_selected()
id = self.comments["items"][c]["id"]
if self.comments["items"][c]["likes"]["user_likes"] == 1:
l = self.session.vk.client.likes.delete(owner_id=-1*self.group_id, item_id=id, type="topic_comment")
output.speak(_("You don't like this"))
self.comments["items"][c]["likes"]["count"] = l["likes"]
self.comments["items"][c]["likes"]["user_likes"] = 2
self.send_message("set_label", control="like", label=_("&Like"))
else:
l = self.session.vk.client.likes.add(owner_id=-1*self.group_id, item_id=id, type="topic_comment")
output.speak(_("You liked this"))
self.send_message("set_label", control="like", label=_("&Dislike"))
self.comments["items"][c]["likes"]["count"] = l["likes"]
self.comments["items"][c]["likes"]["user_likes"] = 1
self.clear_comments_list()
def change_comment(self, comment):
comment = self.comments["items"][comment]
self.send_message("clean_list", list="attachments")
self.get_attachments(comment, "")
if comment["likes"]["user_likes"] == 1:
self.send_message("set_label", control="like", label=_("&Dislike"))
else:
self.send_message("set_label", control="like", label=_("&Like"))
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()
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"):
user = self.session.get_user(c["from_id"])
name = user["user1_nom"].split(" ")[0]
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"])
def show_comment(self, comment_index):
c = self.comments["items"][comment_index]
c["post_id"] = self.post["id"]
a = displayTopicCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
class displayPollPresenter(base.basePresenter):
def __init__(self, session, poll, view, interactor, show_results=False):
super(displayPollPresenter, self).__init__(view=view, interactor=interactor, modulename="display_poll")
self.poll = poll["poll"]
self.session = session
self.get_poll()
self.load_poll(show_results)
self.run()
def get_poll(self):
# Retrieve the poll again so we will have a fresh and updated object.
data = dict(owner_id=self.poll["owner_id"], is_board=int(self.poll["is_board"]), poll_id=self.poll["id"])
self.poll = self.session.vk.client.polls.getById(**data)
def load_poll(self, load_results=False):
user = self.session.get_user(self.poll["author_id"])
title = _("Poll from {user1_nom}").format(**user)
self.send_message("set_title", value=title)
self.send_message("set", control="question", value=self.poll["question"])
if len(self.poll["answer_ids"]) > 0 or ("is_closed" in self.poll and self.poll["is_closed"] == True) or load_results == True or ("can_vote" in self.poll and self.poll["can_vote"] == False):
options = []
for i in self.poll["answers"]:
options.append((i["text"], i["votes"], i["rate"]))
self.send_message("add_options", options=options, multiple=self.poll["multiple"])
self.send_message("done")
self.send_message("disable_control", control="ok")
else:
options = []
for i in self.poll["answers"]:
options.append(i["text"])
self.send_message("add_options", options=options, multiple=self.poll["multiple"])
self.send_message("done")
def vote(self, answers):
ids = ""
for i in range(0, len(self.poll["answers"])):
if answers[i] == True:
ids = ids+"{answer_id},".format(answer_id=self.poll["answers"][i]["id"])
if self.poll["multiple"] == False:
break
if ids == "":
log.exception("An error occurred when retrieving answer IDS for the following poll: %r. Provided answer list: %r" % (self.poll, answers))
return
data = dict(owner_id=self.poll["owner_id"], poll_id=self.poll["id"], answer_ids=ids, is_board=int(self.poll["is_board"]))
result = self.session.vk.client.polls.addVote(**data)
if result == 1:
output.speak(_("Your vote has been added to this poll."))
class displayAudioPresenter(base.basePresenter):
def __init__(self, session, postObject, view, interactor):
super(displayAudioPresenter, self).__init__(view=view, interactor=interactor, modulename="display_audio")

View File

@@ -113,7 +113,10 @@ class userProfilePresenter(base.basePresenter):
elif person["relation"] == 3:
r = _("Engaged with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
elif person["relation"] == 4:
r = _("Married with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
if "relation_partner" in person:
r = _("Married to {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
else:
r = _("Married")
elif person["relation"] == 5:
r = _("It's complicated")
elif person["relation"] == 6:

View File

@@ -17,18 +17,11 @@ count_for_wall_buffers = integer(default=100)
count_for_video_buffers = integer(default=200)
count_for_audio_buffers = integer(default=1000)
[sound]
volume = float(default=1.0)
input_device = string(default="Default")
output_device = string(default="Default")
session_mute = boolean(default=False)
current_soundpack = string(default="default")
[chat]
notify_online = boolean(default=True)
notify_offline = boolean(default=True)
open_unread_conversations = boolean(default=True)
automove_to_conversations = boolean(default=True)
automove_to_conversations = boolean(default=False)
notifications = string(default="custom")
[load_at_startup]

View File

@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
""" this module contains everything used to render different kind of posts (posts in the home buffer,
Chat messages, audios, videos, photos, comments in posts, etc)"""
from __future__ import unicode_literals
from builtins import range
import arrow
import languageHandler
import logging
from . utils import seconds_to_string
from update.utils import convert_bytes
from . utils import seconds_to_string, clean_text
log = logging.getLogger(__file__)
@@ -50,12 +49,6 @@ def clean_audio(audio):
audio["count"] = audio["count"] -1
return audio
def clean_text(text):
""" Replaces all HTML entities and put the plain text equivalent if it's possible."""
text = text.replace("<br>", "\n")
text = text.replace("\\n", "\n")
return text
def add_attachment(attachment):
msg = ""
tpe = ""
@@ -79,6 +72,9 @@ def add_attachment(attachment):
elif attachment["type"] == "audio_message":
msg = "{0}".format(" ".join(render_audio_message(attachment["audio_message"])))
tpe = _("Voice message")
elif attachment["type"] == "poll":
tpe = _("Poll")
msg = attachment["poll"]["question"]
else:
print(attachment)
return [tpe, msg]
@@ -91,12 +87,18 @@ def render_person(status, session):
Reference: https://vk.com/dev/fields"""
if "last_seen" in status:
original_date = arrow.get(status["last_seen"]["time"])
now = arrow.now()
original_date.to(now.tzinfo)
diffdate = now-original_date
if diffdate.days == 0 and diffdate.seconds <= 360:
online_status = _("Online")
else:
# Translators: This is the date of last seen
last_seen = _("{0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
online_status = _("Last seen {0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
# Account suspended or deleted.
elif ("last_seen" in status) == False and "deactivated" in status:
last_seen = _("Account deactivated")
return ["{0} {1}".format(status["first_name"], status["last_name"]), last_seen]
online_status = _("Account deactivated")
return ["{0} {1}".format(status["first_name"], status["last_name"]), online_status]
def render_newsfeed_item(status, session):
""" This me☻thod is used to render an item of the news feed.
@@ -249,4 +251,25 @@ def render_audio_message(audio_message, session=None):
["Voice message", "01:30:28"]"""
if audio_message == False:
return [_("Voice message not available"), "", ""]
return [seconds_to_string(audio_message["duration"])]
return [seconds_to_string(audio_message["duration"])]
def render_topic(topic, session):
""" Render topics for a community.
Reference: https://vk.com/dev/objects/topic"""
user = session.get_user(topic["created_by"])
title = topic["title"]
comments = topic["comments"]
last_commenter = session.get_user(topic["updated_by"])
last_update = arrow.get(topic["updated"]).humanize(locale=languageHandler.curLang[:2])
last_commenter.update(date=last_update)
lastupdate = _("Last post by {user1_nom} {date}").format(**last_commenter)
return [user["user1_nom"], title, str(comments), lastupdate]
def render_document(document, session):
doc_types = {1: _("Text document"), 2: _("Archive"), 3: _("Gif"), 4: _("Image"), 5: _("Audio"), 6: _("Video"), 7: _("Ebook"), 8: _("Unknown document")}
user = session.get_user(document["owner_id"])
title = document["title"]
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]

View File

@@ -6,9 +6,11 @@ import logging
import warnings
import languageHandler
import paths
from . import vkSessionHandler
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
@@ -53,6 +55,11 @@ class vkSession(object):
@data list: A list with items and some information about cursors.
returns the number of items that has 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.
if name == "online_friends":
newdata = self.vk.client.users.get(user_ids=",".join([str(z) for z in data]), fields="last_seen")
data = newdata
first_addition = False
num = 0
if (name in self.db) == False:
@@ -60,14 +67,14 @@ class vkSession(object):
self.db[name]["items"] = []
first_addition = True
for i in data:
if "type" in i and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
if "type" in i and not isinstance(i["type"], int) and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
log.debug("Skipping unsupported item... %r" % (i,))
continue
# for some reason, VK sends post data if the post has been deleted already.
# Example of this behaviour is when you upload an audio and inmediately delete the audio, VK still sends the post stating that you uploaded an audio file,
# But without the audio data, making socializer to render an empty post.
# Here we check if the post contains data of the type it advertises.
if i.get("type") != None and post_types.get(i["type"]) not in i:
if i.get("type") != None and isinstance(i["type"], str) and post_types.get(i["type"]) not in i:
log.error("Detected invalid or unsupported post. Skipping...")
log.error(i)
continue
@@ -104,11 +111,15 @@ 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(self.settings["sound"])
self.soundplayer = sound.soundSystem(config.app["sound"])
# except:
# log.exception("The session configuration has failed.")
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.
if self.logged == True:
return
try:
config_filename = os.path.join(paths.config_path(), self.session_id, "vkconfig.json")
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"], token=self.settings["vk"]["token"], secret=self.settings["vk"]["secret"], device_id=self.settings["vk"]["device_id"], alt_token=self.settings["vk"]["use_alternative_tokens"], filename=config_filename)
@@ -118,11 +129,21 @@ class vkSession(object):
self.settings.write()
self.logged = True
self.get_my_data()
except ValueError:
self.settings["vk"]["user"] = ""
self.settings["vk"]["password"] = ""
self.settings.write()
pub.sendMessage("authorisation-failed")
except VkApiError as error:
if error.code == 5: # this means invalid access token.
self.settings["vk"]["user"] = ""
self.settings["vk"]["password"] = ""
self.settings["vk"]["token"] = ""
self.settings["vk"]["secret"] = ""
self.settings["vk"]["device_id"] = ""
self.settings.write()
pub.sendMessage("authorisation-failed")
else: # print out error so we we will handle it in future versions.
log.exception("Fatal error when authenticating the application.")
log.exception(error.code)
log.exception(error.message)
except (ProxyError, ConnectionError):
pub.sendMessage("connection_error")
def post_wall_status(self, message, *args, **kwargs):
""" Sends a post to an user, group or community wall."""
@@ -137,14 +158,12 @@ class vkSession(object):
log.debug("Params for sending to vk: %r" % (kwargs,))
data = getattr(self.vk.client.newsfeed, "get")(*args, **kwargs)
if data != None:
if show_nextpage == False:
self.process_usernames(data)
# else:
# print data.keys(), len(data["items"]), data["next_from"]
self.process_usernames(data)
num = self.order_buffer(name, data["items"], show_nextpage)
log.debug("Keys of the returned data for debug purposes: %r" % (list(data.keys()),))
if "next_from" in data:
self.db[name]["cursor"] = data["next_from"]
log.debug("Next cursor saved for data: {cursor}".format(cursor=data["next_from"]))
return num
def get_page(self, name="", show_nextpage=False, endpoint="", *args, **kwargs):
@@ -164,11 +183,18 @@ class vkSession(object):
p = getattr(c, p)
except AttributeError:
p = c
if name in self.db and "offset" in self.db[name] and show_nextpage == True:
kwargs.update(offset=self.db[name]["offset"])
else:
kwargs.update(offset=0)
log.debug("Calling endpoint %s with params %r" % (p, kwargs,))
data = getattr(p, endpoint)(*args, **kwargs)
if data != None:
if "count" not in kwargs:
kwargs["count"] = 100
if type(data) == dict:
num = self.order_buffer(name, data["items"], show_nextpage)
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"]:
@@ -178,6 +204,7 @@ class vkSession(object):
self.process_usernames(data)
else:
num = self.order_buffer(name, data, show_nextpage)
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
return num
def get_messages(self, name="", *args, **kwargs):
@@ -235,8 +262,9 @@ class vkSession(object):
ids = ids + "{0},".format(i["id"],)
gids = ""
for i in data["groups"]:
self.db["groups"][i["id"]] = dict(nom=i["name"], gen=i["name"], dat=i["name"], acc=i["name"], ins=i["name"], abl=i["name"])
gids = "{0},".format(i["id"],)
if i["id"] not in self.db["groups"]:
self.db["groups"][i["id"]] = dict(nom=i["name"], gen=i["name"], dat=i["name"], acc=i["name"], ins=i["name"], abl=i["name"])
gids = "{0},".format(i["id"],)
user_fields = "first_name_nom, last_name_nom, first_name_gen, last_name_gen, first_name_ins, last_name_ins, first_name_dat, last_name_dat, first_name_abl, last_name_abl, first_name_acc, last_name_acc, sex"
user_fields_list = user_fields.split(", ")
if ids != "":

View File

@@ -2,10 +2,11 @@
import os
import sys
import widgetUtils
from . import wxUI as view
import paths
import time
import logging
from authenticator.official import AuthenticationError
from . import wxUI as view
from . import session
from .config_utils import Configuration
@@ -53,4 +54,9 @@ class sessionManagerController(object):
if dl.ShowModal() == widgetUtils.OK:
c.settings["vk"]["user"] = dl.get_email()
c.settings["vk"]["password"] = dl.get_password()
c.settings.write()
try:
c.login()
except AuthenticationError:
c.settings["vk"]["password"] = ""
c.settings["vk"]["user"]
return self.get_authorisation(c)

View File

@@ -1,17 +1,18 @@
# -*- coding: utf-8 -*-
""" Some utilities. I no have idea how I should put these, so..."""
from __future__ import division
from __future__ import unicode_literals
import os
import requests
import re
import html
import logging
import requests
log = logging.getLogger("utils")
url_re = re.compile("(?:\w+://|www\.)[^ ,.?!#%=+][^ ]*")
bad_chars = '\'\\.,[](){}:;"'
def seconds_to_string(seconds, precision=0):
""" convert a number of seconds in a string representation."""
# ToDo: Improve it to handle properly Russian plurals.
day = seconds // 86400
hour = seconds // 3600
min = (seconds // 60) % 60
@@ -57,3 +58,18 @@ def download_file(url, local_filename, window):
window.change_status(_("Ready"))
return local_filename
def detect_users(text):
""" Detect all users and communities mentionned in any text posted in VK."""
# This regexp gets group and users mentionned in topic comments.
for matched_data in re.finditer("(\[)(id|club)(\d+:bp-\d+_\d+\|)(\D+)(\])", text):
text = re.sub("\[(id|club)\d+:bp-\d+_\d+\|\D+\]", matched_data.groups()[3]+", ", text, count=1)
# This is for users and communities just mentionned in wall comments or posts.
for matched_data in re.finditer("(\[)(id|club)(\d+\|)(\D+)(\])", text):
text = re.sub("\[(id|club)\d+\|\D+\]", matched_data.groups()[3]+", ", text, count=1)
return text
def clean_text(text):
""" Clean text, removing all unneeded HTMl and converting HTML represented characters in their unicode counterparts."""
text = detect_users(text)
text = html.unescape(text)
return text

View File

@@ -9,6 +9,7 @@ import logging
import paths
import sound_lib
import output
import config
from sound_lib import recording
from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded
@@ -61,7 +62,9 @@ class soundSystem(object):
log.error("Error in input or output devices, using defaults...")
self.config["output_device"] = "Default"
self.config["input_device"] = "Default"
# Set proxy for audio.
if config.app["app-settings"]["use_proxy"]:
self.output.set_proxy(b"socializer:socializer@socializer.su:3128")
self.files = []
self.cleaner = RepeatingTimer(60, self.clear_list)
self.cleaner.start()
@@ -81,6 +84,6 @@ class soundSystem(object):
if self.soundpack_OK == False: return
if self.config["session_mute"] == True: return
sound_object = sound_lib.stream.FileStream(file="%s/%s" % (self.path, sound))
sound_object.volume = float(self.config["volume"])
# sound_object.volume = self.config["volume"]/100
self.files.append(sound_object)
sound_object.play()

View File

@@ -8,7 +8,7 @@ from . import utils
progress_dialog = None
def available_update_dialog(version, description):
dialog = wx.MessageDialog(None, _("There's a new %s version available. Would you like to download it now?\n\n %s version: %s\n\nChanges:\n%s") % (application.name, application.name, version, description), _("New version for %s") % application.name, style=wx.YES|wx.NO|wx.ICON_WARNING)
dialog = wx.MessageDialog(None, _("There's a new {app_name} version available. Would you like to download it now?\n\n {app_name} version: {app_version}\n\nChanges:\n{changes}").format(app_name=application.name, app_version=version, changes=description), _("New version for %s") % application.name, style=wx.YES|wx.NO|wx.ICON_WARNING)
if dialog.ShowModal() == wx.ID_YES:
return True
else:
@@ -28,7 +28,7 @@ def _progress_callback(total_downloaded, total_size):
if total_downloaded == total_size:
progress_dialog.Destroy()
else:
progress_dialog.Update((total_downloaded*100)/total_size, _("Updating... %s of %s") % (utils.convert_bytes(total_downloaded), utils.convert_bytes(total_size)))
progress_dialog.Update((total_downloaded*100)/total_size, _("Updating... {total_transferred} of {total_size}").format(total_transferred=utils.convert_bytes(total_downloaded), total_size=utils.convert_bytes(total_size)))
def update_finished():
return wx.MessageDialog(None, _("The update has been downloaded and installed successfully. Press OK to continue."), _("Done!")).ShowModal()

View File

@@ -14,19 +14,20 @@ class attachDialog(widgetUtils.BaseDialog):
box.Add(lbl1, 0, wx.ALL, 5)
box.Add(self.attachments.list, 0, wx.ALL, 5)
sizer.Add(box, 0, wx.ALL, 5)
static = wx.StaticBox(panel, label=_("Add attachments"))
self.photo = wx.Button(panel, wx.NewId(), _("&Photo"))
self.audio = wx.Button(panel, wx.NewId(), _("Audio file"))
static = wx.StaticBoxSizer(parent=panel, orient=wx.HORIZONTAL, label=_("Add attachments"))
self.photo = wx.Button(static.GetStaticBox(), wx.NewId(), _("&Photo"))
self.audio = wx.Button(static.GetStaticBox(), wx.NewId(), _("Audio file"))
self.document = wx.Button(static.GetStaticBox(), wx.NewId(), _("Document"))
if voice_messages:
self.voice_message = wx.Button(panel, wx.NewId(), _("Voice message"))
self.remove = wx.Button(panel, wx.NewId(), _("Remove attachment"))
self.voice_message = wx.Button(static.GetStaticBox(), wx.NewId(), _("Voice message"))
self.remove = wx.Button(static.GetStaticBox(), wx.NewId(), _("Remove attachment"))
self.remove.Enable(False)
btnsizer = wx.StaticBoxSizer(static, wx.HORIZONTAL)
btnsizer.Add(self.photo, 0, wx.ALL, 5)
btnsizer.Add(self.audio, 0, wx.ALL, 5)
static.Add(self.photo, 0, wx.ALL, 5)
static.Add(self.audio, 0, wx.ALL, 5)
static.Add(self.document, 0, wx.ALL, 5)
if voice_messages:
btnsizer.Add(self.voice_message, 0, wx.ALL, 5)
sizer.Add(btnsizer, 0, wx.ALL, 5)
static.Add(self.voice_message, 0, wx.ALL, 5)
sizer.Add(static, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK)
ok.SetDefault()
cancelBtn = wx.Button(panel, wx.ID_CANCEL)
@@ -56,3 +57,12 @@ class attachDialog(widgetUtils.BaseDialog):
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return None
return openFileDialog.GetPath()
def get_document(self):
openFileDialog = wx.FileDialog(self, _("Select the file to be uploaded. All extensions are allowed except .mp3 and .exe."), "", "", _("All files (*.*)|*.*"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return None
return openFileDialog.GetPath()
def invalid_attachment(self):
return wx.MessageDialog(None, _("The file you are trying to upload contains an extension that is not allowed by VK."), _("Error"), style=wx.ICON_ERROR).ShowModal()

View File

@@ -23,6 +23,8 @@ class general(wx.Panel, widgetUtils.BaseDialog):
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)
box4 = wx.BoxSizer(wx.HORIZONTAL)

View File

@@ -16,11 +16,19 @@ class displayBasicPost(widgetUtils.BaseDialog):
def create_post_view(self, label=_("Message")):
lbl = wx.StaticText(self.panel, -1, label)
self.post_view = wx.TextCtrl(self.panel, -1, size=(730, -1), style=wx.TE_READONLY|wx.TE_MULTILINE)
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)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl, 0, wx.ALL, 5)
box.Add(self.post_view, 0, wx.ALL, 5)
return box
def onSelect(self, event):
self.post_view.SelectAll()
def create_views_control(self):
lbl = wx.StaticText(self.panel, -1, _("Views"))
self.views = wx.TextCtrl(self.panel, -1, style=wx.TE_READONLY|wx.TE_MULTILINE)
@@ -185,6 +193,41 @@ class displayComment(displayBasicPost):
if comment: box.Add(self.comment, 0, wx.ALL, 5)
return box
class displayTopic(displayBasicPost):
def __init__(self, *args, **kwargs):
super(displayTopic, self).__init__(*args, **kwargs)
comments_box = self.create_comments_list()
self.sizer.Add(comments_box, 0, wx.ALL, 5)
attachments_box = self.create_attachments()
self.sizer.Add(attachments_box, 0, wx.ALL, 5)
self.attachments.list.Enable(False)
self.create_photo_viewer()
self.image.Enable(False)
self.create_tools_button()
self.sizer.Add(self.tools, 0, wx.ALL, 5)
actions_box = self.create_action_buttons()
self.sizer.Add(actions_box, 0, wx.ALL, 5)
self.sizer.Add(self.create_dialog_buttons())
self.done()
def create_action_buttons(self, comment=True):
self.like = wx.Button(self.panel, -1, _("&Like"))
if comment: self.comment = wx.Button(self.panel, -1, _("Add comment"))
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(self.like, 0, wx.ALL, 5)
if comment: box.Add(self.comment, 0, wx.ALL, 5)
return box
def create_comments_list(self):
lbl = wx.StaticText(self.panel, -1, _("Posts"))
self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), style=wx.LC_REPORT)
self.reply = wx.Button(self.panel, -1, _("Reply"))
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl, 0, wx.ALL, 5)
box.Add(self.comments.list, 0, wx.ALL, 5)
box.Add(self.reply, 0, wx.ALL, 5)
return box
class displayAudio(widgetUtils.BaseDialog):
def __init__(self, *args, **kwargs):
super(displayAudio, self).__init__(parent=None, *args, **kwargs)
@@ -261,4 +304,59 @@ class displayFriendship(widgetUtils.BaseDialog):
btnbox.Add(close, 0, wx.ALL, 5)
sizer.Add(btnbox, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
self.SetClientSize(sizer.CalcMin())
class displayPoll(widgetUtils.BaseDialog):
def __init__(self, question="", *args, **kwargs):
super(displayPoll, self).__init__(parent=None, *args, **kwargs)
self.panel = wx.Panel(self, -1)
self.sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self.panel, wx.NewId(), _("Question"))
self.question = wx.TextCtrl(self.panel, wx.NewId(), question, style=wx.TE_MULTILINE|wx.TE_READONLY, size=(730, -1))
self.sizer.Add(label, 0, wx.ALL, 5)
self.sizer.Add(self.question, 0, wx.ALL, 5)
def add_options(self, options, multiple=False):
if not isinstance(options[0], str):
return self.add_results(options)
self.options = []
sizer = wx.StaticBoxSizer(parent=self.panel, orient=wx.VERTICAL, label=_("Options"))
for i in options:
if multiple == False:
if len(self.options) == 0:
control = wx.RadioButton(sizer.GetStaticBox(), wx.NewId(), i, style=wx.RB_GROUP)
else:
control = wx.RadioButton(sizer.GetStaticBox(), wx.NewId(), i)
else:
control = wx.CheckBox(sizer.GetStaticBox(), wx.NewId(), i)
self.options.append(control)
sizer.Add(control, 0, wx.ALL, 5)
self.sizer.Add(sizer, 0, wx.ALL, 5)
def get_answers(self):
answers = []
for i in self.options:
answers.append(i.GetValue())
return answers
def add_results(self, options):
sizer = wx.StaticBoxSizer(parent=self.panel, orient=wx.VERTICAL, label=_("Poll results"))
for i in options:
sizer2 = wx.StaticBoxSizer(parent=sizer.GetStaticBox(), orient=wx.HORIZONTAL, label=i[0])
staticcontrol = wx.StaticText(sizer2.GetStaticBox(), wx.NewId(), i[0])
control = wx.TextCtrl(sizer2.GetStaticBox(), wx.NewId(), _("{votes} ({rate}%)").format(votes=i[1], rate=i[2]), style=wx.TE_READONLY|wx.TE_MULTILINE)
sizer2.Add(staticcontrol, 0, wx.ALL, 5)
sizer2.Add(control, 0, wx.ALL, 5)
sizer.Add(sizer2, 0, wx.ALL, 5)
self.sizer.Add(sizer, 0, wx.ALL, 5)
def done(self):
self.ok = wx.Button(self.panel, wx.ID_OK, _("Vote"))
cancel = wx.Button(self.panel, wx.ID_CANCEL)
sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer.Add(self.ok, 0, wx.ALL, 5)
sizer.Add(cancel, 0, wx.ALL, 5)
self.panel.SetSizer(self.sizer)
self.SetClientSize(self.sizer.CalcMin())

View File

@@ -179,3 +179,6 @@ class list(object):
return 0
else:
return selected
def Enable(self, value):
return self.list.Enable(value)

View File

@@ -24,7 +24,10 @@ def show_error_code(code):
return wx.MessageDialog(None, message, title, style=wx.ICON_ERROR).ShowModal()
def bad_authorisation():
return wx.MessageDialog(None, _("authorisation failed. Your configuration will not be saved. Please close and open again the application for authorising your account. Make sure you have typed your credentials correctly."), _("Error"), style=wx.ICON_ERROR).ShowModal()
return wx.MessageDialog(None, _("authorisation failed. Your configuration will be deleted. If you recently changed your password in VK, you need to reauthorize Socializer. The application will be restarted and prompt you again for your user and password. Press OK to continue."), _("Error"), style=wx.ICON_ERROR).ShowModal()
def connection_error():
return wx.MessageDialog(None, _("Socializer could not connect to VK due to a connection issue. Be sure you have a working internet connection. The application will be closed when you press the OK button. If your internet connection is working correctly, please try to open socializer in a few minutes. If this problem persists, contact the developers to receive further assistance."), _("Connection Error"), style=wx.ICON_ERROR).ShowModal()
def no_audio_albums():
return wx.MessageDialog(None, _("You do not have audio albums."), _("Error"), style=wx.ICON_ERROR).ShowModal()
@@ -49,3 +52,15 @@ def group_joined():
def proxy_question():
return wx.MessageDialog(None, _("If you live in a country where VK is blocked, you can use a proxy to bypass such restrictions. Socializer includes a working proxy to ensure all users can connect to VK. Do you want to use Socializer through the proxy?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()
def remove_friend(user):
return wx.MessageDialog(None, _("Are you sure you want to remove {user1_nom} from your friends?").format(**user), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()
def post_deleted():
return wx.MessageDialog(None, _("This post has been removed."), _("Error"), wx.ICON_ERROR).ShowModal()
def restart_program():
return wx.MessageDialog(None, _("In order to apply the changes you requested, you must restart the program. Do you want to restart Socializer now?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()
def community_no_items():
return wx.MessageDialog(None, _("There are 0 items for this community."), _("Error"), wx.ICON_ERROR).ShowModal()

View File

@@ -16,6 +16,16 @@ class searchAudioDialog(widgetUtils.BaseDialog):
self.term.SetSize(dc.GetTextExtent("0"*40))
sizer.Add(label, 0, wx.ALL, 5)
sizer.Add(self.term, 0, wx.ALL, 5)
radioSizer = wx.StaticBoxSizer(parent=panel, orient=wx.HORIZONTAL, label=_("Search by"))
self.title = wx.RadioButton(radioSizer.GetStaticBox(), wx.NewId(), _("Title"), style=wx.RB_GROUP)
self.artist = wx.RadioButton(radioSizer.GetStaticBox(), wx.NewId(), _("Artist"))
radioSizer.Add(self.title, 0, wx.ALL, 5)
radioSizer.Add(self.artist, 0, wx.ALL, 5)
sizer.Add(radioSizer, 0, wx.ALL, 5)
sortBox = wx.StaticBoxSizer(parent=panel, orient=wx.HORIZONTAL, label=_("Sort by"))
self.sortorder = wx.ComboBox(sortBox.GetStaticBox(), wx.NewId(), choices=[_("Date added"), _("Duration"), _("Popularity")], value=_("Popularity"), style=wx.CB_READONLY)
sortBox.Add(self.sortorder, 0, wx.ALL, 5)
sizer.Add(sortBox, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _("&OK"))
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL, _("&Close"))
@@ -26,6 +36,15 @@ class searchAudioDialog(widgetUtils.BaseDialog):
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def get_state(self, control):
if getattr(self, control).GetValue() == True:
return 1
else:
return 0
def get_sort_order(self):
return self.sortorder.GetSelection()
class searchVideoDialog(widgetUtils.BaseDialog):
def __init__(self, value=""):
super(searchVideoDialog, self).__init__(None, -1)

View File

@@ -1,21 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from builtins import range
import wx
import wx.adv
import application
from wx.lib.agw import toasterbox
class mainWindow(wx.Frame):
def makeMenu(self):
mb = wx.MenuBar()
app_ = wx.Menu()
create = wx.Menu()
# self.audio_album = create.Append(wx.NewId(), _("Audio album"))
self.audio_album = create.Append(wx.NewId(), _("Audio album"))
self.video_album = create.Append(wx.NewId(), _("Video album"))
app_.Append(wx.NewId(), _("Create"), create)
delete = wx.Menu()
# self.delete_audio_album = delete.Append(wx.NewId(), _("Audio album"))
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.settings_dialog = app_.Append(wx.NewId(), _("Preferences"))
@@ -39,9 +36,8 @@ class mainWindow(wx.Frame):
mb.Append(me, _("Me"))
mb.Append(buffer, _("Buffer"))
player = wx.Menu()
self.player_play = player.Append(wx.NewId(), _("Play"))
self.player_play = player.Append(wx.NewId(), _("Play/Pause"))
self.player_play_all = player.Append(wx.NewId(), _("Play all"))
self.player_stop = player.Append(wx.NewId(), _("Stop"))
self.player_previous = player.Append(wx.NewId(), _("Previous"))
self.player_next = player.Append(wx.NewId(), _("Next"))
self.player_shuffle = player.AppendCheckItem(wx.NewId(), _("Shuffle"))
@@ -53,10 +49,24 @@ class mainWindow(wx.Frame):
self.documentation = help_.Append(wx.NewId(), _("Manual"))
self.check_for_updates = help_.Append(wx.NewId(), _("Check for updates"))
self.changelog = help_.Append(wx.NewId(), _("Chan&gelog"))
self.open_logs = help_.Append(wx.NewId(), _("Open logs directory"))
self.open_config = help_.Append(wx.NewId(), _("Open config directory"))
self.report = help_.Append(wx.NewId(), _("Report an error"))
mb.Append(player, _("Audio player"))
mb.Append(help_, _("Help"))
self.SetMenuBar(mb)
self.accel_tbl = wx.AcceleratorTable([
# Assign keystrokes to control the player object.
(wx.ACCEL_ALT, wx.WXK_LEFT, self.player_previous.GetId()),
(wx.ACCEL_ALT, wx.WXK_RIGHT, self.player_next.GetId()),
(wx.ACCEL_ALT, wx.WXK_DOWN, self.player_volume_down.GetId()),
(wx.ACCEL_ALT, wx.WXK_UP, self.player_volume_up.GetId()),
# Translators: Keystroke used to play/pause the current item in the playback queue. Use the latin alphabet, but you can match a different key here. For example if you want to assign this to the key "П", use G.
(wx.ACCEL_CTRL, ord(_("P")), self.player_play.GetId()),
(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord(_("P")), self.player_play_all.GetId()),
])
self.SetAcceleratorTable(self.accel_tbl)
def __init__(self):
super(mainWindow, self).__init__(parent=None, id=wx.NewId(), title=application.name)
@@ -89,6 +99,9 @@ class mainWindow(wx.Frame):
def insert_buffer(self, buffer, name, pos):
return self.tb.InsertSubPage(pos, buffer, name)
def insert_chat_buffer(self, buffer, name, pos):
return self.tb.InsertPage(pos, buffer, name)
def search(self, name_):
for i in range(0, self.tb.GetPageCount()):
if self.tb.GetPage(i).name == name_: return i
@@ -105,8 +118,10 @@ class mainWindow(wx.Frame):
def change_buffer(self, position):
self.tb.ChangeSelection(position)
def get_buffer_text(self):
return self.tb.GetPageText(self.tb.GetSelection())
def get_buffer_text(self, pos=None):
if pos == None:
pos = self.tb.GetSelection()
return self.tb.GetPageText(pos)
def get_buffer_by_id(self, id):
return self.nb.FindWindowById(id)
@@ -128,9 +143,9 @@ class mainWindow(wx.Frame):
def remove_buffer(self, pos):
self.tb.DeletePage(pos)
def remove_buffer_from_position(self, pos):
return self.tb.RemovePage(pos)
def notify(self, title, text):
try:
self.notification = wx.adv.NotificationMessage(title, text, parent=self)
except AttributeError:
self.notification = wx.NotificationMessage(title, text)
self.notification = wx.adv.NotificationMessage(title=title, message=text, parent=self)
self.notification.Show()

View File

@@ -1,8 +1,11 @@
# -*- coding: utf-8 -*-
""" This module contains all context menus needed to be displayed in different sections. Basically any menu that is bigger than 2 menu items should be here."""
from __future__ import unicode_literals
import wx
class postMenu(wx.Menu):
""" Display a menu with actions related to posts in the news feed or walls. """
def __init__(self, can_delete=False, *args, **kwargs):
super(postMenu, self).__init__(*args, **kwargs)
self.open = wx.MenuItem(self, wx.NewId(), _("Open"))
@@ -44,10 +47,12 @@ class audioMenu(wx.Menu):
self.Append(self.move)
class peopleMenu(wx.Menu):
def __init__(self, is_request=False, *args, **kwargs):
def __init__(self, is_request=False, is_subscriber=False, *args, **kwargs):
super(peopleMenu, self).__init__(*args, **kwargs)
if is_request:
self.create_extra_items()
self.create_request_items()
elif is_subscriber:
self.create_subscriber_items()
self.view_profile = wx.MenuItem(self, wx.NewId(), _("View profile"))
self.Append(self.view_profile)
self.message = wx.MenuItem(self, wx.NewId(), _("Send a message"))
@@ -56,8 +61,11 @@ class peopleMenu(wx.Menu):
self.Append(self.timeline)
self.common_friends = wx.MenuItem(self, wx.NewId(), _("View friends in common"))
self.Append(self.common_friends)
if is_request == False and is_subscriber == False:
self.decline = wx.MenuItem(self, wx.NewId(), _("Remove from friends"))
self.Append(self.decline)
def create_extra_items(self):
def create_request_items(self):
self.accept = wx.MenuItem(self, wx.NewId(), _("Accept"))
self.Append(self.accept)
self.decline = wx.MenuItem(self, wx.NewId(), _("Decline"))
@@ -65,6 +73,20 @@ class peopleMenu(wx.Menu):
self.keep_as_follower = wx.MenuItem(self, wx.NewId(), _("Keep as follower"))
self.Append(self.keep_as_follower)
def create_subscriber_items(self):
self.add = wx.MenuItem(self, wx.NewId(), _("Add to friends"))
self.Append(self.add)
class documentMenu(wx.Menu):
def __init__(self, added=False, *args, **kwargs):
super(documentMenu, self).__init__(*args, **kwargs)
# self.view_info = self.Append(wx.NewId(), _("View information"))
self.download = self.Append(wx.NewId(), _("Download document"))
if added == True:
self.action = self.Append(wx.NewId(), _("Remove from my documents"))
else:
self.action = self.Append(wx.NewId(), _("Add to my documents"))
class commentMenu(wx.Menu):
def __init__(self, *args, **kwargs):
super(commentMenu, self).__init__(*args, **kwargs)
@@ -91,4 +113,15 @@ class attachMenu(wx.Menu):
self.upload = wx.MenuItem(self, wx.NewId(), _("Upload from computer"))
self.Append(self.upload)
self.add = wx.MenuItem(self, wx.NewId(), _("Add from VK"))
self.Append(self.add)
self.Append(self.add)
class communityBufferMenu(wx.Menu):
def __init__(self):
super(communityBufferMenu, self).__init__()
load = wx.Menu()
self.load_posts = load.Append(wx.NewId(), _("Load posts"))
self.load_topics = load.Append(wx.NewId(), _("Load topics"))
self.load_audios = load.Append(wx.NewId(), _("Load audios"))
self.load_videos = load.Append(wx.NewId(), _("Load videos"))
self.load_documents = load.Append(wx.NewId(), _("Load documents"))
self.Append(wx.NewId(), _("Load"), load)

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
#from __future__ import unicode_literals
from __future__ import unicode_literals
import wx
import widgetUtils
@@ -57,7 +56,7 @@ 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.GetBoxSizer(), wx.NewId(), _("Load community"))
self.load = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Load buffer"))
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post"))
self.postBox.Add(self.load, 0, wx.ALL, 5)
self.postBox.Add(self.post, 0, wx.ALL, 5)
@@ -74,18 +73,25 @@ class audioTab(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, _("&Upload audio"))
self.post.Enable(False)
self.play = wx.Button(self.postBox.GetStaticBox(), -1, _("P&lay"))
self.play_all = wx.Button(self.postBox.GetStaticBox(), -1, _("Play &All"))
self.postBox.Add(self.post, 0, wx.ALL, 5)
self.postBox.Add(self.play, 0, wx.ALL, 5)
self.postBox.Add(self.play_all, 0, wx.ALL, 5)
def get_file_to_upload(self):
openFileDialog = wx.FileDialog(self, _("Select the audio file to be uploaded"), "", "", _("Audio files (*.mp3)|*.mp3"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return None
return openFileDialog.GetPath()
class audioAlbumTab(audioTab):
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 album"))
self.load = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Load buffer"))
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post"))
self.play = wx.Button(self.postBox.GetStaticBox(), -1, _("P&lay"))
self.play_all = wx.Button(self.postBox.GetStaticBox(), -1, _("Play &All"))
@@ -136,6 +142,42 @@ class friendsTab(homeTab):
self.list.set_windows_size(0, 400)
self.list.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnKeyDown)
class topicTab(homeTab):
def create_list(self):
self.lbl = wx.StaticText(self, wx.NewId(), _("Topics"))
self.list = widgetUtils.list(self, *[_("User"), _("Title"), _("Posts"), _("Last")], style=wx.LC_REPORT)
self.list.set_windows_size(0, 200)
self.list.set_windows_size(1, 64)
self.list.set_windows_size(2, 15)
self.list.set_windows_size(2, 250)
self.list.set_size()
self.list.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnKeyDown)
class documentCommunityTab(homeTab):
def create_list(self):
self.lbl = wx.StaticText(self, wx.NewId(), _("Documents"))
self.list = widgetUtils.list(self, *[_("User"), _("Title"), _("Type"), _("Size"), _("Date")], style=wx.LC_REPORT)
self.list.set_windows_size(0, 200)
self.list.set_windows_size(1, 128)
self.list.set_windows_size(2, 35)
self.list.set_windows_size(3, 15)
self.list.set_windows_size(4, 25)
self.list.set_size()
self.list.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnKeyDown)
def get_download_path(self, filename):
saveFileDialog = wx.FileDialog(self, _("Save document as"), "", filename, _("All files (*.*)|*.*"), wx.FD_SAVE | wx.FD_OVERWRITE_PROMPT)
if saveFileDialog.ShowModal() == widgetUtils.OK:
return saveFileDialog.GetPath()
class documentTab(documentCommunityTab):
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.postBox.Add(self.load, 0, wx.ALL, 5)
self.postBox.Add(self.post, 0, wx.ALL, 5)
class empty(wx.Panel):
def __init__(self, parent, name):
super(empty, self).__init__(parent=parent, name=name)
@@ -164,11 +206,22 @@ class chatTab(wx.Panel):
def create_controls(self):
lbl1 = wx.StaticText(self, wx.NewId(), _("History"))
self.history = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE, size=(500, 300))
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)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl1, 0, wx.ALL, 5)
box.Add(self.history, 0, wx.ALL, 5)
return box
def onSelect(self, event, *args, **kwargs):
if self.history.HasFocus():
self.history.SelectAll()
else:
self.text.SelectAll()
event.Skip()
def create_attachments(self):
lbl = wx.StaticText(self, -1, _("Attachments"))
self.attachments = widgetUtils.list(self, _("Type"), _("Title"), style=wx.LC_REPORT)
@@ -238,7 +291,7 @@ class videoAlbumTab(videoTab):
def create_post_buttons(self):
self.postBox = wx.BoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions"))
self.load = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Load album"))
self.load = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Load buffer"))
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post"))
self.play = wx.Button(self.postBox.GetStaticBox(), -1, _("P&lay"))
self.postBox.Add(self.post, 0, wx.ALL, 5)