133 Commits

Author SHA1 Message Date
9e6e72c0a1 Started some kind of implementation 2019-10-11 17:39:19 -05:00
63def5530f Added 'manage accounts' option in the application menu 2019-10-11 13:19:53 -05:00
c206a40e62 Updated documentation regarding account management 2019-10-11 13:19:32 -05:00
2889923940 Added video buffers to the timeline dialog 2019-10-11 12:05:27 -05:00
3deabdbf36 Fixed parsing of video data. Now videos are loaded correctly again 2019-10-11 12:04:46 -05:00
89c8e6a194 Added information related to blacklist support and video buffers on timelines 2019-10-11 12:03:43 -05:00
19a5216373 Added block in people buffers' menu and blacklist management in the application menu 2019-10-10 10:43:29 -05:00
f274ba9caa fixed some issues when rendering topic comments 2019-10-09 09:25:39 -05:00
5a36db2366 Added checks when using player_function 2019-10-07 16:50:30 -05:00
9003d3c738 Added accounts dialog at startup in socializer (implementation is half pending) 2019-09-23 17:47:26 -05:00
d06a32311e Update version number to 0.23 2019-09-23 12:52:48 -05:00
63fb0e0ff9 Finished fault tolerance in socializer. Now also topic comments are fully supported 2019-09-20 14:07:44 -05:00
4e14801db6 Updated documentation 2019-09-20 13:50:00 -05:00
926db6007a Added fault tolerance to wall coments and reposts 2019-09-19 17:52:04 -05:00
cf0e001cfc display wall comments and replies in the same list. 2019-09-19 11:25:28 -05:00
ee6370bb0b (pubsub) Refresh comments when a new one is added in wall posts and comments 2019-09-18 14:49:00 -05:00
33ba50a7b4 Show age in profile dialog 2019-09-18 13:56:07 -05:00
29e8b00656 calls to wall.createcomment and wall.report are done via the pubsub method (pubsub reply for failed posts not implementd yet) 2019-09-18 13:55:30 -05:00
ff175c0c8f Added mobile and home phone to basic info tab in the profile display dialog 2019-09-17 17:26:23 -05:00
a015593971 Changed to VK APi V 5.101 2019-09-17 17:23:46 -05:00
fdbf42ad1a Added a new tab called buffer settings to the preferences dialog. Moved some settings to that new tab 2019-09-15 14:13:25 -05:00
61583447b6 Replaced the post button for post in wall in people buffers 2019-09-15 12:42:01 -05:00
33ab63c1bc Added chat buffer count in the preferences dialog 2019-09-15 10:52:01 -05:00
5b3a013766 Update online friends buffer even if chat notifications are disabled 2019-09-15 09:58:22 -05:00
69f8b79fc4 Added fault tolerance to socializer in posts, topic creation and chat messages 2019-08-30 11:26:00 -05:00
60d283f931 Added some comments to the new post function 2019-08-28 08:53:37 -05:00
f41dd51dc7 Added error reports to failed posts in VK (pubsub). Added an extra param called from_post which specifies which buffer will get updated if the post is created successfully 2019-08-27 16:59:57 -05:00
a7173adc22 Chat messages were upgraded to the new post method, too 2019-08-27 12:13:13 -05:00
bbef34d125 Removed unneeded prints 2019-08-27 11:14:29 -05:00
277b10b155 Updated post in walls and topic creation to use the new pubsub event for posting 2019-08-27 11:12:54 -05:00
6a69d4eaac Added new methods (pubsub) for uploading attachments and sending posts to VK. Those methods will be extended to support all post types and attachments lately and will be able to report errors and success when posting to the full application 2019-08-27 11:10:15 -05:00
4d3c1cacc9 Updated changelog 2019-08-27 08:33:12 -05:00
2ed26bc8d9 DisplayPost: It is possible to see who liked a comment or topic comment by pressing the likes button 2019-08-27 08:29:02 -05:00
52e55a24fa Display topic post: It is possible to like or dislike a topic comment when displaying it individually 2019-08-22 09:22:16 -05:00
98b85435ac Now it is possible to add/remove from library or move to a different album all selected audios when multiselection is used 2019-08-19 17:15:44 -05:00
3903c5630f Fixed the status bar size in the window 2019-08-19 11:25:52 -05:00
ac7ef77a8d Skipping update check when running from sources 2019-08-19 10:02:05 -05:00
c80ca295c6 Attempted to collect more data in incorrect attachment parsing 2019-08-06 08:41:46 -05:00
19a9c305ce Added more type fixes 2019-08-06 08:41:26 -05:00
dca7b4a694 Fixed problems when loading newsfeed buffers sometimes in Socializer 2019-07-27 12:45:03 -05:00
357d18fbe0 fixed incorrect display of the method being called from VK in the logs 2019-07-22 13:21:13 -05:00
251623acf0 Removed contributors file as is not needed in the repository 2019-07-22 12:54:21 -05:00
4caa5a6ab0 Merge branch 'next' 2019-07-22 12:53:10 -05:00
d1b11c0630 Fixed errors when uploading audio files without ID3 tags to VK 2019-07-22 12:49:46 -05:00
36b25e1c9f Removed some confidential data from the logs generated by socializer 2019-07-22 10:04:56 -05:00
6a2407a07c Bump new version 2019-07-14 11:37:10 -05:00
cd623065e7 Fixed a few important errors avoiding normal usage of Socializer 2019-07-14 11:31:10 -05:00
2b462bfecb Merge branch 'next' 2019-07-13 12:15:30 -05:00
9353ea93c1 Update file now points to the latest v0.21 version 2019-07-13 08:57:35 -05:00
853cce4a66 Bumped version to 0.21 2019-07-13 08:56:00 -05:00
2d944b276c Updated translations 2019-07-13 08:47:40 -05:00
b4299ef066 Updated translations 2019-07-13 08:40:33 -05:00
64799d2e14 Attempt to speed up the initial buffer loading on socializer 2019-07-04 09:34:05 -05:00
ead54fce3f Fixed error with some posts in the home timeline that were making socializer to not load anything else 2019-07-04 08:38:47 -05:00
ae93efb17a Display version type in about dialog between alpha or stable 2019-07-02 09:26:07 -05:00
d95dfb18fd Removed some settings no longer needed 2019-07-02 08:55:55 -05:00
4e3c397ce5 Refactored some functions to call wx's threads properly. 2019-06-10 09:26:10 -05:00
4e6126405f Send links when posting a topic comment 2019-06-06 13:42:22 -05:00
8cdec543e1 Modified auth info for 2 factor auth 2019-06-05 10:38:59 -05:00
4810cbe138 Added timeline creation from the context menu in people buffers 2019-05-29 17:51:37 -05:00
8ec7fbb49e Added support for displaying and opening wall posts as attachments in conversations 2019-05-29 09:17:02 -05:00
7d52ed8802 Fixed error retrieving group information of objects not present in the db. 2019-05-29 09:16:16 -05:00
9d44d063eb Modified timeline dialog for a future change 2019-05-24 17:42:59 -05:00
d5eb9ed478 Merge branch 'master' of code.manuelcortez.net:manuelcortez/socializer 2019-05-24 16:33:20 -05:00
40afb6cdc2 Fixed error when attenpting to upload photos to wall posts. Now it should work normally 2019-05-21 16:20:38 -05:00
74234476ab Updated button label in group feed buffers 2019-05-20 21:32:51 -05:00
82c71a3bd8 Merge branch 'master' of code.manuelcortez.net:manuelcortez/socializer 2019-05-20 00:42:19 -05:00
5161e1c045 Updated changelog 2019-05-19 12:35:19 -05:00
40052dbf3f Fixed audio player on walls 2019-05-15 17:19:02 -05:00
e73d92754e Fixed a typo in documentation translation 2019-05-07 11:38:04 -05:00
6df1b80941 Test 4 2019-05-07 10:37:31 -05:00
a9e5963b74 Test 3 2019-05-07 10:35:12 -05:00
95671966cd Test 2 2019-05-07 10:32:12 -05:00
a8ce7216e1 Test 2019-05-07 10:29:15 -05:00
5c6829165b Fixed a typo 2019-05-07 03:46:14 -05:00
91eebfd895 Added topic creation in groups (experimental) 2019-05-06 17:57:34 -05:00
72cc04342f Restructured group info storage for a wider usage 2019-05-06 15:50:45 -05:00
75267294f9 Now it is possible to post as group or username in group walls 2019-05-06 14:58:45 -05:00
f81d302c9a Updated player 2019-05-06 12:09:53 -05:00
c3ab0406e4 Updated documentation translations 2019-05-06 11:45:58 -05:00
fdcaf4e596 Fixed two factor auth in socializer! 2019-05-05 01:01:31 -05:00
ca7b3eff29 Added some debug info 2019-05-04 14:25:39 -05:00
f1eb640564 Select songs with spacebar and play audio from selected tracks has been implemented 2019-05-02 05:57:49 -05:00
194ca2d380 Implemented a selection control in audio buffers (not working yet) 2019-04-30 17:36:53 -05:00
976e90f0a0 Fixed audio methods 2019-04-30 15:32:38 -05:00
2c836f473d Fixed a strange issue with play_all function 2019-04-30 15:31:54 -05:00
f834b6046e Added the full implementation, pending usage into an experiment 2019-04-26 17:53:55 -05:00
e6087f3818 Fixed a typo 2019-04-26 17:51:18 -05:00
20c3df6be2 Added experiment of a selectableList (not implemented, et) 2019-04-26 17:49:54 -05:00
b914e4b548 Merge branch 'next' 2019-04-25 17:42:16 -05:00
f336489609 Released v0.20 2019-04-25 12:10:35 -05:00
4ce2e88568 Updated changelog 2019-04-25 11:38:38 -05:00
a917a6a9cd Ducking when voice messages are being played 2019-04-25 11:38:00 -05:00
a01eabea91 Separate playback of voice messages from regular audio playback 2019-04-25 10:18:13 -05:00
605f0da751 Modified worker in player module so it will set stopped to True after finishing playback 2019-04-25 09:58:53 -05:00
6bd0c10ef2 Removed some old keystrokes no longer needed 2019-04-25 09:17:48 -05:00
a9032602bf Added play and pause functionality in the audios displayer 2019-04-25 08:56:12 -05:00
8c03601bd2 Change lable to 'pause' in the play button when something is playing 2019-04-25 08:48:19 -05:00
afc4c0ca1f prepared content for V0.20 2019-04-24 17:39:25 -05:00
e0ee8a7040 Updated translations 2019-04-24 17:34:09 -05:00
e32336aff8 Added support for loading all comments in topics 2019-04-23 13:13:58 -05:00
0edbba5625 fixed a typo in last commit 2019-04-23 11:31:49 -05:00
eec5350926 Improve checks for audio in stayed state 2019-04-22 00:10:40 -05:00
20f0b3f782 Updated changelog 2019-04-20 14:17:36 -05:00
5cf4128c49 Fixed error in disconnected friends algorithm 2019-04-19 14:41:57 -05:00
47768acf5c Fixed session error in new config files 2019-04-19 02:13:29 -05:00
f88d2177c3 Updated audio methods for changes introduced in 17/04 2019-04-17 11:50:15 -05:00
9373f10d68 Added seeking in the audio player menu and in new keystrokes (read changelog) 2019-04-17 11:46:26 -05:00
4f3bb6ac93 Fixed all audio methods due to latest VK changes 2019-04-16 15:45:25 -05:00
5f224a077c Reordered presenters for post display and cretion 2019-04-16 12:24:42 -05:00
14cdeb0b5a Updated and restructured Socializer's changelog 2019-04-16 09:41:47 -05:00
b02137c216 Added display of people who shared the post in the post displayer dialog 2019-04-16 09:41:32 -05:00
7c90103af4 Show people who have liked a post if pressing the likes button in the post displayer 2019-04-15 17:50:56 -05:00
903af03d15 Added menu in list of added friends in home timeline buffer 2019-04-15 16:16:17 -05:00
b57ca4d207 Fix error on 'open in vk' for group topics 2019-04-14 23:51:18 -05:00
2fe58941ea Added open in vk.com option in context menu for lots of items 2019-04-13 18:43:48 -05:00
04f734bebe some functions present in the player should not freeze the app while taking place 2019-04-11 17:43:52 -05:00
a0d43ebe0e Moved audio playback infrastructure to pubsub events 2019-04-11 17:15:45 -05:00
6d80dce66d Sent voice messages from socializer should work in phones now 2019-04-11 15:52:41 -05:00
3d765dd701 Fix some issues introduced in the last player stuff 2019-04-11 15:52:18 -05:00
2b42c64160 Fix AttributeError when saving data from the alternative tokens method 2019-04-11 05:29:42 -05:00
7928131112 Added language settings in preferences dialog 2019-04-11 05:25:43 -05:00
9cb1f9647c Started pubsub implementation in all player related functions 2019-04-10 17:49:23 -05:00
6d6daa60b6 Added comments to the player module 2019-04-10 17:36:02 -05:00
81a454c29c Read confirmations will be sent in real time in conversations 2019-04-10 15:19:22 -05:00
6f245d9b7f Added support to delete conversations 2019-04-09 17:55:05 -05:00
05c001067e Removed old alpha version built with Python 2 2019-04-09 16:15:38 -05:00
fea57a4034 Updated changelog with getting more items to conversation buffers 2019-04-09 16:09:33 -05:00
00eebf9260 Added support for loading more items in conversation buffers 2019-04-09 16:08:14 -05:00
cde18c8d35 Include all relevant spelling dictionaries in binary builds 2019-03-28 10:18:44 -06:00
0b2c3fa96e Added sound settings tab in the preferences dialog. Only available options there are input and output device 2019-03-28 08:57:48 -06:00
8f631cfe4b Modify audio player volume by 2% instead of 5% 2019-03-25 16:35:56 -06:00
f10b25c07f Updated app to 0.19 2019-03-12 17:19:10 -06:00
93 changed files with 1990066 additions and 4796 deletions

View File

@@ -21,31 +21,25 @@ test_py3:
- '%PYTHON3% -m coverage report --omit="test*"' - '%PYTHON3% -m coverage report --omit="test*"'
coverage: '/TOTAL.+ ([0-9]{1,3}%)/' coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
.alpha: documentation:
type: deploy type: deploy
tags: tags:
- windows - windows10
before_script:
- '%PYTHON3% -v'
script: script:
- pip install --upgrade pip
- pip install --upgrade -r requirements.txt
- copy changelog.md doc\changelog.md - copy changelog.md doc\changelog.md
- cd doc - cd doc
- python documentation_importer.py - '%PYTHON2% documentation_importer.py'
- cd ..\src - cd ..\src
- python ..\doc\generator.py - '%PYTHON2% ..\doc\generator.py'
- python write_version_data.py - 'move documentation ..\'
- python setup.py py2exe
- cd ..
- cd scripts
- python prepare_zipversion.py
- cd ..
- move src\socializer.zip socializer.zip
only: only:
- schedules - master
artifacts: artifacts:
paths: paths:
- socializer.zip - documentation
name: socializer name: socializer_documentation
expire_in: 1 day expire_in: 1 day
alpha_python3: alpha_python3:

View File

@@ -1,6 +1,95 @@
# Changelog # Changelog
## changes in this version ## News in this version
### New additions
* Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later.
* Switching accounts is now supported in socializer. In the application menu, there is an option called "manage accounts" which allows you to add or remove an account. Socializer will take changes after a restart of the application. In case of having multiple accounts, every time Socializer starts, you will see a dialog from where is possible to choose the account for logging in.
* when selecting multiple audio files in audio buffers, multiple actions can be performed in all items, these actions are present in the contextual menu of the buffer (namely play, add/remove from the library and move to a different playlist). This means you can select all the audios you want and Socializer will perform the selected options in all items, making it a bit easier to operate with multiple songs.
* Now it is possible to like and see who liked a comment when displaying it individually. This applies to comments in wall posts and topics.
* Now it is possible to choose how many items Socializer will load in conversation buffers, from the General tab in the preferences dialog. The default value is 50 items, and the maximum value is 200.
* There is a new tab called buffer settings, in the preferences dialog. Settings related to how many items should be loaded in certain buffer types have been moved to this tab, so it will separate better the configuration options in the application.
* Added management of the Blacklist on VK. Users can be blocked from people buffers (friends, online, or any buffer inside friend requests). You can access the blacklist from the application menu, located in the menu bar. From there, you can unblock any previously blocked user.
* In the new timeline dialog, it is possible to create video buffers by selecting the "video" radio button as buffer type.
### bugfixes
* Fixed an error that was causing socializer to not update the "Online friends" buffer if chat notifications were disabled.
* Fixed an error that was making Socializer unable to attach audio files from the computer, if the file does not include correct ID3 TAGS.
* Fixed a traceback that was being logged when attempting to load an image but cancel the dialog for attaching it.
* Fixed an error that was making Socializer to fail when loading the newsfeed buffer, thus not loading any other buffers. This error was caused due to VK sending a new object type representing push subscriptions. The item is ignored by Socializer so it will not break the newsfeed buffer anymore.
* Fixed an error that was making the status bar to not fit the full size of the Window. This was cutting the messages placed on it, now, all messages are displayed properly again.
* fixed an unhandled condition when playing a song and voice message at the same time, that was potentially making Socializer to stop loading certain buffers.
* fixed an error that was making socializer unable to parse video data, thus video buffers were impossible to be loaded.
### Changes
* Less confidential user data will be send to the logs, so it will be much safer to pass logs publicly.
* automatic update checks will be disabled if using socializer from the source code.
* it is possible to post in an user's wall by using the post button located next to the user, in people buffers. This applies only to online users and list of friends.
* When displaying a profile, information about mobile and home phone is displayed in the basic information tab.
* In wall posts, all comments, including replies, will be displayed in the same list. Before, you had to open a comment to read its replies. When a new comment is posted by the current user, the list of comments will be reloaded and new additions will be fetched and sorted properly.
## changes in Versions 0.21 and 0.22 (14.07.2019)
### New additions
* Added "post in groups" feature. In order to do so, you need to load the posts for the group where you want to send something. Once loaded, go to the post button in the group's wall and select whether you want to post in the group's behalf or as yourself.
* In all audio buffers, it is possible to select individual tracks to be played together. In order to do so, you need to press space to start the selection of items. When selected, the item will emit a sound to indicate the change. Press space in all items you want to select/unselect. When you're focusing an already selected item it will play a sound to indicate that it is already selected. Once you're done with your selection, pressing enter in the list of tracks will start the playback of the list of items you have selected. This is a very experimental feature. More actions can be supported based in this selection method if it proves to be useful.
* In conversation buffers, it is possible to display and open wall posts sent as attachments in messages.
* In people buffers, it is possible to create a new timeline by using the context menu while focusing an user. This method will create the buffer for the selected user, as opposed to creating the buffer from the menu bar, where you have to type the username or find it in a list.
### bugfixes
* Fixed an error with two factor authentication in the recent socializer version. Now it works reliably again.
* Fixed an error when trying to attach a photo to a wall post. The error was fixed in the [vk_api](https://github.com/python273/vk_api) module and the fix was sent to the developer of the library, so he will be able to merge it in the next version. In the meantime, socializer already includes the fix for this method, so you can upload photos to wall posts normally.
* Fixed an error retrieving some group information for the current session.
* When posting in a topic, links will be posted properly.
### Changes
* the audio player module has received some improvements:
- When there is something being played, the label of the "play" button, located in all audio buffers, will change automatically to "pause". When pressed, it will pause the song instead of starting the playback again since the beginning.
- The last change will work also in the dialog for displaying audio information. Now it's possible to play and pause an audio from such dialog.
- When playing a voice message, if a song is playing already socializer will decrease the volume so you can hear the voice message well enough. Some seconds after the message has finished, the song's volume will be restored.
* In audio buffers, you will play the focused audio when pressing enter in the item, instead of opening the audio information dialog.
* Removed some old keystrokes in socializer buffers due to better alternatives. The reason for this change is that currently you don't need to be focusing an item in a buffer for being able to use the alternative keystrokes, which makes those a better implementation.
- Control+Enter and control+Shift+Enter: superseeded by Control+P for playing (and pausing) the currently focused audio.
- F5 and F6: superseeded by Alt+down and up arrows for modifying volume.
## changes in version 0.20 (25.04.2019)
### New additions
* For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define which soundcard will be used for input and output. [#25,](https://code.manuelcortez.net/manuelcortez/socializer/issues/25)
* the audio player can seek positions in the currently playing track. You can use the menu items (located in the main menu) or use the new available keystrokes dedicated to the actions. Seeking will be made in 5 second intervals.
* Alt+Shift+Left arrow: Seek 5 seconds backwards.
* Alt+Shift+Right arrow: Seek 5 seconds forwards.
* it is possible to select the language used in socializer from the preferences dialog. When changing the language, the application must be restarted for the changes to take effect.
* A new option, called open in vk.com, has been added in the context menu for almost all objects (items in home timeline, walls, documents, people, group topics and in buffers for conversations). This option will open the selected item in the VK website.
* when opening the list of friends added by an user, you can display the context menu from an item on the list and view the user profile, open it in VK.com, among other actions. [#8,](https://code.manuelcortez.net/manuelcortez/socializer/issues/8)
* When displaying a post, if you press enter in the button indicating how many people liked or shared the post, Socializer will display the listt of people who have liked or shared it. You can use the context menu in the list to do certain actions. [#38,](https://code.manuelcortez.net/manuelcortez/socializer/issues/38)
* it is possible to retrieve more items for conversation buffers. Due to API limitations, it is possible to load up to the last 600 messages for every conversation. Take into account that the process of loading more items takes some time. You will hear a message when the process is done.
* It is possible to delete entire conversations from the buffer's tree, by using the menu key and selecting "delete conversation". The conversation will be removed from VK.
* When loading a topic in a group, socializer will display the latest 100 messages. In order to load more messages, you will find a button that will load the previous 100 messages present in the topic, or the amount of messages not loaded yet.
### bugfixes
* All spelling dictionaries are included by default for the following languages: Russian, English, German, French, italian, Polish, spanish and Turkish. Before, some dictionaries were missing and the spelling checker was failing.
* Fixed an error in the default configuration template used for new sessions in the application. This error was making Socializer to fail when loading any conversation buffer.
* Fixed an error in the algorithm to detect friends disconnecting from VK. This problem was interrupting the connection with the chat server every time it was happening, thus chat server's connection should be more reliable now.
* The audio player should behave better in situations where a song is interrupted. Before, if you pressed "next song" while the currently playing sound was interrupted due to internet connection issues, two or more songs were played at the same time.
* The bug reporting feature works normally again.
### Changes
* Updated method for accessing audio files due to the latest changes on VK apps.
* When changing volume of the playing audio, it will decrease or increase the volume by 2% instead of 5%.
* Read confirmations will be sent to VK as soon as you read the message. Before, read confirmations were being sent every 3 minutes to the social network.
## Changes in version 0.19 (13.03.2019)
* 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. * 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. * 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.

View File

@@ -1,2 +0,0 @@
Manuel Cortéz
Valeria K

View File

@@ -9,7 +9,7 @@ Socializer is an application to use [VK.com](https://vk.com) in an easy and acce
* audio support. * audio support.
* Post comments. * Post comments.
* like, unlike and repost other's posts. * like, unlike and repost other's posts.
* Open other's timelines so you could track their friends, posts or audio files. * Open other's timelines so you could track their friends, posts, audio or video files.
* Basic chat features. * Basic chat features.
## Usage ## Usage
@@ -48,10 +48,10 @@ An item is an element representing some data provided by VK. Items are separated
The following is a brief description of the kind of items socializer can work with, and what actions are available for those. The following is a brief description of the kind of items socializer can work with, and what actions are available for those.
* Newsfeed post: It represents a post displayed in your "home" page on VK. It may contain a variety of information based in what you or your friends do. A newsfeed item may contain information about new audios added to your friend's library, new people added to friends, wall posts, reposts and new photos added. Depending on the kind of data VK has supplied, the item can open a dialog showing information about the post, a list displaying the people added to friends, or a dialog displaying information for every audio added to library. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. Available options for this item are different depending in the information the item contains. You can open or view the profile of the user that generated the item, like, dislike or add a comment to a post. * Newsfeed post: It represents a post displayed in your "home" page on VK. It may contain a variety of information based in what you or your friends do. A newsfeed item may contain information about new audios added to your friend's library, new people added to friends, wall posts, reposts and new photos added. Depending on the kind of data VK has supplied, the item can open a dialog showing information about the post, a list displaying the people added to friends, or a dialog displaying information for every audio added to library. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. Available options for this item are different depending in the information the item contains. You can open or view the profile of the user that generated the item, like, dislike or add a comment to a post.
* Wall post: Represent a post in an user's wall. This post will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. When opened (by pressing enter or the open option in the associated menu), it will show a dialogue where you can read the message, see how many times the post has been viewed by other users, interact with attachment files (by searching the list and pressing enter in the focused attachment to open it), see the photos included in the post, read information related to likes and times the post has been shared, read and reply to comments. Additionally, you can share the post, indicate you like it, or add a comment. You can cycle through every item in the dialog by pressing tab. * Wall post: Represents a post in an user's wall. This post will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. When opened (by pressing enter or the open option in the associated menu), it will show a dialogue where you can read the message, see how many times the post has been viewed by other users, interact with attachment files (by searching the list and pressing enter in the focused attachment to open it), see the photos included in the post, read information related to likes and times the post has been shared, read and reply to comments. Additionally, you can share the post, indicate you like it, or add a comment. You can cycle through every item in the dialog by pressing tab.
* Audio: It represent an audio uploaded to the VK'S platform. Actions available for this item are opening the audio in a dialog, add or remove it from your library, move the audio to a playlist, and play it. When opened, it will be displayed in a dialog allowing you to read the title of the song, artist name, duration and a few buttons: play, add or remove from your library and download. You can control playback of audio items from the buffer by using the player menu on the menu bar or the corresponding keyboard shortcuts. * Audio: It represents an audio uploaded to the VK'S platform. Actions available for this item are opening the audio in a dialog, add or remove it from your library, move the audio to a playlist, and play it. When opened, it will be displayed in a dialog allowing you to read the title of the song, artist name, duration and a few buttons: play, add or remove from your library and download. You can control playback of audio items from the buffer by using the player menu on the menu bar or the corresponding keyboard shortcuts. Additionally, it is possible to select multiple audios in the same buffer to perform specific actions on them, such as play, remove or add the selected audios to a playlist. In order to select multiple audios, press the spacebar in every audio item you want to select. You will hear a sound when an item is selected, and when you focus a selected audio. When you're done, press enter to play all the selected audios or use the context menu to see available actions. All actions will be applied in the selected audios.
* Video: It represent a video uploaded to the VK'S platform. Actions available for this item are opening the video in your default web browser and move it to a video album. When opened, it will open a web browser and play the video automatically due to VK limitations in access to video files. * Video: It represents a video uploaded to the VK'S platform. Actions available for this item are opening the video in your default web browser and move it to a video album. When opened, it will open a web browser and play the video automatically due to VK limitations in access to video files.
* person: It contains information about a VK user, this item is present in all buffers under the "people" category. Actions available for this item are view user profile, send message and create a timeline, which is a special buffer to track all posts, friends or audios owned by the user. When opened, it will display the profile of this user in a dialog and will provide actions to send a message to the user, or view other sections of her/his profile. * person: It contains information about a VK user, this item is present in all buffers under the "people" category. Actions available for this item are view user profile, send message and create a timeline, which is a special buffer to track all posts, friends, audios or videos owned by the user. When opened, it will display the profile of this user in a dialog and will provide actions to send a message to the user, or view other sections of her/his profile.
* Message: A message appears only in conversation buffers and represents a chat message. It may include a list of attached files that will be displayed in a separated list. You can tab to that list (from the history) and press enter in the attached file you want to open. Chat items are marked as read automatically as soon as they are focused. * Message: A message appears only in conversation buffers and represents a chat message. It may include a list of attached files that will be displayed in a separated list. You can tab to that list (from the history) and press enter in the attached file you want to open. Chat items are marked as read automatically as soon as they are focused.
## Main interface ## Main interface
@@ -69,7 +69,7 @@ In summary, the GUI contains two core components. These are the controls you wil
### Buttons in the application ### Buttons in the application
* Post: this button opens up a dialogue box to write a post in the wall of the focused user. For example, if you are in the "my wall" buffer you will send a post to your own wall, but if you are in an user timeline the post will be sent to the owner of the timeline. You can upload an attachment by pressing the "attach" button and choosing between uploading a photo or audio file in the dialog which will appear, check spelling or translate your message by selecting one of the available buttons in the dialogue box. In addition, you can tag a friend in your post by pressing the corresponding button for that purpose. Also it is possible to configure the privacy settings for your post by allowing all users or just your friends to read it. Press the send button to send the post. * Post: this button opens up a dialogue box to write a post in the wall of the focused user. For example, if you are in the "my wall" buffer you will send a post to your own wall, but if you are in an user timeline the post will be sent to the owner of the timeline. You can upload an attachment by pressing the "attach" button and choosing between uploading a photo, audio file or document in the dialog which will appear, check spelling or translate your message by selecting one of the available buttons in the dialogue box. In addition, you can tag a friend in your post by pressing the corresponding button for that purpose. Also it is possible to configure the privacy settings for your post by allowing all users or just your friends to read it. Press the send button to send the post.
* Load buffer: Some buffers are created but not loaded in VK. These special buffers need to be loaded manually by pressing the load button. Once loaded, this kind of buffers will behave in the same way other buffers do. Examples of these buffers are audio and video albums, community walls, and the current user's documents * 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: 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. * Play all: In audio buffers, play all songs starting from the focused buffer, until the last item in the list.
@@ -85,6 +85,8 @@ Visually, Towards the top of the main application window, A menu bar can be foun
* Create: opens a menu where you can create a new album. At the moment, only audio and video albums are supported. * 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. * Delete: opens a menu where you can delete an already existing album owned by yourself. Only audio and video albums are supported at this time.
* blacklist: Opens a dialog which allows you to manage blocked people on VK.
* Manage accounts: Opens up a dialogue from where you are able to add or delete an account in socializer. If you have more than an account, you will be asked at startup for the account you want to use in the application. You can use an account at once, but it is possible to have multiple accounts and switch between them by restarting the application.
* Preferences: Opens a dialogue which lets you configure settings for the entire application. * Preferences: Opens a dialogue which lets you configure settings for the entire application.
### Me menu ### Me menu
@@ -96,11 +98,11 @@ Visually, Towards the top of the main application window, A menu bar can be foun
### Buffer menu ### Buffer menu
* New timeline: Lets you open a user's timeline by choosing the user in a dialog box. You can choose which items you want to track: wall posts, friends or audio items. It is created when you press enter. If you invoke this option relative to a user that has no items of the kind you specified, the operation will fail. If you try creating an existing timeline the program will warn you and will not create it again. * New timeline: Lets you open an user's timeline by choosing the user in a dialog box. You can choose which items you want to track: wall posts, videos, friends or audio items. It is created when you press enter. If you invoke this option relative to a user that has no items of the kind you specified, the operation will fail. If you try creating an existing timeline the program will warn you and will not create it again.
* Search: Shows a menu where you can search for audios or videos on VK. Search results will be created in a new buffer inside "music" or "videos". * Search: Shows a menu where you can search for audios or videos on VK. Search results will be created in a new buffer inside "music" or "videos".
* Update buffer: Performs a manual update operation in the buffer, which will retrieve all new items present in the social network since the last update. * Update buffer: Performs a manual update operation in the buffer, which will retrieve all new items present in the social network since the last update.
* Load previous items: This allows more items to be loaded for the specified buffer. Bear in mind that not all buffers support this setting. * Load previous items: This allows more items to be loaded for the specified buffer. Bear in mind that not all buffers support this setting.
* Destroy: dismisses the list you're on, if possible. * Remove buffer: dismisses the list you're on, if possible.
### Player menu ### Player menu
@@ -141,16 +143,20 @@ As described above, this application has a preferences dialogue accessible under
### General tab ### General tab
* Number of items to load for newsfeed and wall buffers: Allows you to specify how many items should be retrieved from VK in the newsfeed buffer and when opening walls for other users. Default and maximum is 100. * Language: allows you to switch the interface language for socializer. The application must be restarted after changing the language.
* Number of items to load in video buffers: Allows you to specify how many items should be retrieved from VK in video buffers. Default and maximum is 200.
* Load images in posts: Allows you to specify whether you want socializer to display all images when opening a post, or not. This can be useful for people with slow connections or not needing images. * Load images in posts: Allows you to specify whether you want socializer to display all images when opening a post, or not. This can be useful for people with slow connections or not needing images.
* Use proxy: for countries where Vk is blocked by the internet providers, this settings allows socializer to connect via a proxy server already included in the application.
* Update channel: allows you to specify how often you will receive updates for the program. There are two update channels available: Alpha channel, which contains unstable versions of the application and gets updates almost dayly, and stable, which contain tested and more stable versions of the program, but gets updates once in a month, approximately. * Update channel: allows you to specify how often you will receive updates for the program. There are two update channels available: Alpha channel, which contains unstable versions of the application and gets updates almost dayly, and stable, which contain tested and more stable versions of the program, but gets updates once in a month, approximately.
### Buffer settings tab
* Number of items to load for newsfeed and wall buffers: Allows you to specify how many items should be retrieved from VK in the newsfeed buffer and when opening walls for other users. Default is 50 items, and maximum is 100.
* Number of items to load in video buffers: Allows you to specify how many items should be retrieved from VK in video buffers. Default is 50, maximum value is 200.
* Number of items to load in conversation buffers: allows you to specify how many messages Socializer will retrieve when loading a conversation. Default is 50, maximum value is 200.
### Chat settings tab ### Chat settings tab
* Show notifications when users are online/offline: These two checkboxes allows you to specify if you want socializer to notify you when someone is connected or disconnected in the VK network. * Show notifications when users are online/offline: These two checkboxes allows you to specify if you want socializer to notify you when someone is connected or disconnected in the VK network.
* Open unread conversations at startup: When enabled, Socializer will load any conversation with unread messages after started.
* Move focus to new conversations: When enabled, new conversations will be focused automatically right after being created.
* Notification type: This setting allows you to specify the notification type you prefer to use in socializer. The options are native and custom. Native notifications send a system notification every time someone is online or offline, while custom notifications play a sound and announce the notification in the screen reader only. * Notification type: This setting allows you to specify the notification type you prefer to use in socializer. The options are native and custom. Native notifications send a system notification every time someone is online or offline, while custom notifications play a sound and announce the notification in the screen reader only.
### Optional buffers tab ### Optional buffers tab
@@ -169,12 +175,11 @@ If you still have questions after reading this document, if you wish to collabor
## Credits ## Credits
Socializer is developed and maintained by [Manuel Cortez,](https://manuelcortez.net) with contributions by [Anibal Hernandez](https://dragodark.com) Socializer is developed and maintained by [Manuel Cortez.](https://manuelcortez.net)
We would also like to thank the translators of Socializer, who have allowed the spreading of the application. We would also like to thank the translators of Socializer, who have allowed the spreading of the application.
* English: Manuel Cortéz. * English: Manuel Cortéz.
* Spanish: Manuel Cortéz.
* Russian: Дарья Ратникова. * Russian: Дарья Ратникова.
Special thanks to Дарья Ратникова, as she also manages the Socializer's community in VK, translates the website and the documentation into Russian. Special thanks to Дарья Ратникова, as she also manages the Socializer's community in VK, translates the website and the documentation into Russian.

View File

@@ -3,7 +3,10 @@ wxpython==4.0.3
pywin32 pywin32
pyenchant pyenchant
markdown markdown
vk_api # For the moment we will use the modified vk_api version that does not try to include enum34 and
# already fixed the caption for wall uploaded photos.
# Hopefully I can uncomment this in the near future when my changes will get merged upstream.
#vk_api
bs4 bs4
configobj configobj
pypubsub pypubsub
@@ -18,4 +21,6 @@ mock
git+https://code.manuelcortez.net/manuelcortez/libloader git+https://code.manuelcortez.net/manuelcortez/libloader
git+https://code.manuelcortez.net/manuelcortez/platform_utils git+https://code.manuelcortez.net/manuelcortez/platform_utils
git+https://github.com/chrisnorman7/sound_lib git+https://github.com/chrisnorman7/sound_lib
git+https://code.manuelcortez.net/manuelcortez/accessible_output2 git+https://code.manuelcortez.net/manuelcortez/accessible_output2
# Modified vk_api.
git+https://github.com/manuelcortez/vk_api

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
name = "Socializer" name = "Socializer"
version = "0.19" version = "0.23"
author = "Manuel Cortez" author = "Manuel Cortez"
authorEmail = "manuel@manuelcortez.net" authorEmail = "manuel@manuelcortez.net"
copyright = "Copyright (C) 2016-2019, Manuel Cortez" copyright = "Copyright (C) 2016-2019, Manuel Cortez"

View File

@@ -55,11 +55,12 @@ def get_non_refreshed(login, password, scope=scope):
url = "https://oauth.vk.com/token" url = "https://oauth.vk.com/token"
params = dict(grant_type="password", params = dict(grant_type="password",
client_id=client_id, client_secret=client_secret, username=login, client_id=client_id, client_secret=client_secret, username=login,
password=password, v=api_ver, scope=scope, lang="en", device_id=device_id) password=password, v=api_ver, scope=scope, lang="en", device_id=device_id, force_sms=1)
# Add two factor auth later due to python's syntax. # Add two factor auth later due to python's syntax.
params["2fa_supported"] = 1 params["2fa_supported"] = 1
headers = {'User-Agent': user_agent} headers = {'User-Agent': user_agent}
r = requests.get(url, params=params, headers=headers) r = requests.get(url, params=params, headers=headers)
log.exception(r.json())
# If a 401 error is raised, we need to use 2FA here. # If a 401 error is raised, we need to use 2FA here.
# see https://vk.com/dev/auth_direct (switch lang to russian, english docs are very incomplete in the matter) # see https://vk.com/dev/auth_direct (switch lang to russian, english docs are very incomplete in the matter)
# ToDo: this needs testing after implemented official VK tokens. # ToDo: this needs testing after implemented official VK tokens.

View File

@@ -4,24 +4,14 @@ import time
import wx import wx
import widgetUtils import widgetUtils
code = None
remember = True
def two_factor_auth(): def two_factor_auth():
global code, remember code = None
wx.CallAfter(get_code)
while code == None:
time.sleep(0.5)
return (code, remember)
def get_code():
global code, remember
dlg = wx.TextEntryDialog(None, _("Please provide the authentication code you have received from VK."), _("Two factor authentication code")) dlg = wx.TextEntryDialog(None, _("Please provide the authentication code you have received from VK."), _("Two factor authentication code"))
response = dlg.ShowModal() response = dlg.ShowModal()
if response == widgetUtils.OK: if response == widgetUtils.OK:
code = dlg.GetValue() code = dlg.GetValue()
dlg.Destroy()
dlg.Destroy() dlg.Destroy()
return (code, True)
def bad_password(): 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() 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

@@ -19,6 +19,7 @@ from requests.exceptions import ReadTimeout, ConnectionError
from mutagen.id3 import ID3 from mutagen.id3 import ID3
from presenters import player from presenters import player
from wxUI.tabs import home from wxUI.tabs import home
from wxUI.dialogs import timeline
from sessionmanager import session, renderers, utils from sessionmanager import session, renderers, utils
from mysc.thread_utils import call_threaded from mysc.thread_utils import call_threaded
from wxUI import commonMessages, menus from wxUI import commonMessages, menus
@@ -78,8 +79,11 @@ class baseBuffer(object):
def insert(self, item, reversed=False): def insert(self, item, reversed=False):
""" Add a new item to the list. Uses renderers.composefunc for parsing the dictionary and create a valid result for putting it in the list.""" """ Add a new item to the list. Uses renderers.composefunc for parsing the dictionary and create a valid result for putting it in the list."""
item_ = getattr(renderers, self.compose_function)(item, self.session) try:
self.tab.list.insert_item(reversed, *item_) item_ = getattr(renderers, self.compose_function)(item, self.session)
except:
log.exception(item)
wx.CallAfter(self.tab.list.insert_item, reversed, *item_)
def get_items(self, show_nextpage=False): def get_items(self, show_nextpage=False):
""" Retrieve items from the VK API. This function is called repeatedly by the main controller and users could call it implicitly as well with the update buffer option. """ Retrieve items from the VK API. This function is called repeatedly by the main controller and users could call it implicitly as well with the update buffer option.
@@ -104,12 +108,12 @@ class baseBuffer(object):
if self.tab.list.get_count() > 0 and num > 0: if self.tab.list.get_count() > 0 and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]] v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse() v.reverse()
[self.insert(i, True) for i in v] [wx.CallAfter(self.insert, i, True) for i in v]
else: else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]] [wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
else: else:
if num > 0: if num > 0:
[self.insert(i, False) for i in self.session.db[self.name]["items"][-num:]] [wx.CallAfter(self.insert, i, False) for i in self.session.db[self.name]["items"][-num:]]
return retrieved return retrieved
def get_more_items(self): def get_more_items(self):
@@ -122,66 +126,11 @@ class baseBuffer(object):
During the second part (threaded), the post will be sent to the API.""" During the second part (threaded), the post will be sent to the API."""
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Write your post"), message="", text="")) p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Write your post"), message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"): if hasattr(p, "text") or hasattr(p, "privacy"):
call_threaded(self.do_last, p=p) post_arguments=dict(privacy=p.privacy, message=p.text)
attachments = []
def do_last(self, p, parent_endpoint="wall", child_endpoint="post", *args, **kwargs): if hasattr(p, "attachments"):
""" Second part of post function. Here everything is going to be sent to the API""" attachments = p.attachments
msg = p.text call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
attachments = ""
if hasattr(p, "attachments"):
attachments = self.upload_attachments(p.attachments)
urls = utils.find_urls_in_text(msg)
if len(urls) != 0:
if len(attachments) == 0: attachments = urls[0]
else: attachments += urls[0]
msg = msg.replace(urls[0], "")
if msg != "":
kwargs.update(message=msg)
kwargs.update(privacy=p.privacy)
if attachments != "":
kwargs.update(attachments=attachments)
# Determines the correct functions to call here.
parent_endpoint = getattr(self.session.vk.client, parent_endpoint)
endpoint = getattr(parent_endpoint, child_endpoint)
post = endpoint(**kwargs)
pub.sendMessage("posted", buffer=self.name)
def upload_attachments(self, attachments):
""" Upload attachments to VK before posting them.
Returns attachments formatted as string, as required by VK API."""
# To do: Check the caption and description fields for this kind of attachments.
local_attachments = ""
uploader = upload.VkUpload(self.session.vk.session_object)
for i in attachments:
if i["from"] == "online":
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
elif i["from"] == "local" and i["type"] == "photo":
photos = i["file"]
description = i["description"]
r = uploader.photo_wall(photos, caption=description)
id = r[0]["id"]
owner_id = r[0]["owner_id"]
local_attachments += "photo{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "audio":
audio = i["file"]
title = "untitled"
artist = "unnamed"
if "artist" in i:
artist = i["artist"]
if "title" in i:
title = i["title"]
r = uploader.audio(audio, title=title, artist=artist)
id = r["id"]
owner_id = r["owner_id"]
local_attachments += "audio{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "document":
document = i["file"]
title = i["title"]
r = uploader.document(document, title=title, to_wall=True)
id = r["doc"]["id"]
owner_id = r["doc"]["owner_id"]
local_attachments += "doc{0}_{1},".format(owner_id, id)
return local_attachments
def connect_events(self): def connect_events(self):
""" Bind all events to this buffer""" """ Bind all events to this buffer"""
@@ -224,10 +173,14 @@ class baseBuffer(object):
m.dislike.Enable(True) m.dislike.Enable(True)
if ("comments" in p) == False: if ("comments" in p) == False:
m.comment.Enable(False) m.comment.Enable(False)
m.open_in_browser.Enable(False)
if "type" in p and p["type"] != "friend" and p["type"] != "audio" and p["type"] != "video" and p["type"] != "playlist" or self.name != "home_timeline":
m.open_in_browser.Enable(True)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_post, menuitem=m.open) widgetUtils.connect_event(m, widgetUtils.MENU, self.open_post, menuitem=m.open)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_like, menuitem=m.like) widgetUtils.connect_event(m, widgetUtils.MENU, self.do_like, menuitem=m.like)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_dislike, menuitem=m.dislike) widgetUtils.connect_event(m, widgetUtils.MENU, self.do_dislike, menuitem=m.dislike)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_comment, menuitem=m.comment) widgetUtils.connect_event(m, widgetUtils.MENU, self.do_comment, menuitem=m.comment)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
if hasattr(m, "view_profile"): if hasattr(m, "view_profile"):
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile) widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
if hasattr(m, "delete"): if hasattr(m, "delete"):
@@ -300,11 +253,7 @@ class baseBuffer(object):
def get_event(self, ev): def get_event(self, ev):
""" Parses keyboard input in the ListCtrl and executes the event associated with user keypresses.""" """ Parses keyboard input in the ListCtrl and executes the event associated with user keypresses."""
if ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown() and ev.ShiftDown(): event = "pause_audio" if ev.GetKeyCode() == wx.WXK_RETURN: event = "open_post"
elif ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown(): event = "play_audio"
elif ev.GetKeyCode() == wx.WXK_RETURN: event = "open_post"
elif ev.GetKeyCode() == wx.WXK_F5: event = "volume_down"
elif ev.GetKeyCode() == wx.WXK_F6: event = "volume_up"
else: else:
event = None event = None
ev.Skip() ev.Skip()
@@ -315,12 +264,12 @@ class baseBuffer(object):
pass pass
def volume_down(self): def volume_down(self):
""" Decreases player volume by 5%""" """ Decreases player volume by 2%"""
player.player.volume = player.player.volume-5 player.player.volume = player.player.volume-2
def volume_up(self): def volume_up(self):
""" Increases player volume by 5%""" """ Increases player volume by 2%"""
player.player.volume = player.player.volume+5 player.player.volume = player.player.volume+2
def play_audio(self, *args, **kwargs): def play_audio(self, *args, **kwargs):
""" Play audio in currently focused buffer, if possible.""" """ Play audio in currently focused buffer, if possible."""
@@ -328,7 +277,7 @@ class baseBuffer(object):
if post == None: if post == None:
return return
if "type" in post and post["type"] == "audio": if "type" in post and post["type"] == "audio":
pub.sendMessage("play-audio", audio_object=post["audio"]["items"][0]) pub.sendMessage("play", object=post["audio"]["items"][0])
return True return True
def open_person_profile(self, *args, **kwargs): def open_person_profile(self, *args, **kwargs):
@@ -351,13 +300,13 @@ class baseBuffer(object):
if "type" in post and post["type"] == "audio": if "type" in post and post["type"] == "audio":
a = presenters.displayAudioPresenter(session=self.session, postObject=post["audio"]["items"], interactor=interactors.displayAudioInteractor(), view=views.displayAudio()) a = presenters.displayAudioPresenter(session=self.session, postObject=post["audio"]["items"], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
elif "type" in post and post["type"] == "friend": elif "type" in post and post["type"] == "friend":
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship") pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("{user1_nom} added the following friends")))
else: else:
pub.sendMessage("open-post", post_object=post, controller_="displayPost") pub.sendMessage("open-post", post_object=post, controller_="displayPost")
def pause_audio(self, *args, **kwargs): def pause_audio(self, *args, **kwargs):
""" pauses audio playback.""" """ pauses audio playback."""
player.player.pause() pub.sendMessage("pause")
def remove_buffer(self, mandatory): def remove_buffer(self, mandatory):
""" Function for removing a buffer. Returns True if removal is successful, False otherwise""" """ Function for removing a buffer. Returns True if removal is successful, False otherwise"""
@@ -373,7 +322,7 @@ class baseBuffer(object):
else: else:
return [post["source_id"]] return [post["source_id"]]
def onFocus(self, *args,**kwargs): def onFocus(self, event, *args,**kwargs):
""" Function executed when the item in a list is selected. """ Function executed when the item in a list is selected.
For this buffer it updates the date of posts in the list.""" For this buffer it updates the date of posts in the list."""
post = self.get_post() post = self.get_post()
@@ -382,6 +331,14 @@ class baseBuffer(object):
original_date = arrow.get(post["date"]) original_date = arrow.get(post["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2]) created_at = original_date.humanize(locale=languageHandler.curLang[:2])
self.tab.list.list.SetItem(self.tab.list.get_selected(), 2, created_at) self.tab.list.list.SetItem(self.tab.list.get_selected(), 2, created_at)
event.Skip()
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/wall{user_id}_{post_id}".format(user_id=post["source_id"], post_id=post["post_id"])
webbrowser.open_new_tab(url)
class feedBuffer(baseBuffer): class feedBuffer(baseBuffer):
""" This buffer represents an user's wall. It may be used either for the current user or someone else.""" """ This buffer represents an user's wall. It may be used either for the current user or someone else."""
@@ -408,12 +365,12 @@ class feedBuffer(baseBuffer):
if self.tab.list.get_count() > 0 and num > 0: if self.tab.list.get_count() > 0 and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]] v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse() v.reverse()
[self.insert(i, True) for i in v] [wx.CallAfter(self.insert, i, True) for i in v]
else: else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]] [wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
else: else:
if num > 0: if num > 0:
[self.insert(i, False) for i in self.session.db[self.name]["items"][-num:]] [wx.CallAfter(self.insert, i, False) for i in self.session.db[self.name]["items"][-num:]]
return retrieved return retrieved
def remove_buffer(self, mandatory=False): def remove_buffer(self, mandatory=False):
@@ -456,16 +413,30 @@ class feedBuffer(baseBuffer):
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="")) p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"): if hasattr(p, "text") or hasattr(p, "privacy"):
call_threaded(self.do_last, p=p, owner_id=owner_id) post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=owner_id)
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/wall{user_id}_{post_id}".format(user_id=post["from_id"], post_id=post["id"])
webbrowser.open_new_tab(url)
class communityBuffer(feedBuffer): class communityBuffer(feedBuffer):
def __init__(self, *args, **kwargs):
super(communityBuffer, self).__init__(*args, **kwargs)
self.group_id = self.kwargs["owner_id"]
def create_tab(self, parent): def create_tab(self, parent):
self.tab = home.communityTab(parent) self.tab = home.communityTab(parent)
self.connect_events() self.connect_events()
self.tab.name = self.name self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"): self.tab.post.Enable(False)
self.tab.post.Enable(False)
def connect_events(self): def connect_events(self):
super(communityBuffer, self).connect_events() super(communityBuffer, self).connect_events()
@@ -481,21 +452,45 @@ class communityBuffer(feedBuffer):
""" This method retrieves community information, useful to show different parts of the community itself.""" """ This method retrieves community information, useful to show different parts of the community itself."""
if self.can_get_items: 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. # 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] group_info = self.session.vk.client.groups.getById(group_ids=-1*self.kwargs["owner_id"], fields="counters")[0]
# print(self.group_info["counters"]) self.session.db["group_info"][self.group_id].update(group_info)
if "can_post" in self.session.db["group_info"][self.group_id] and self.session.db["group_info"][self.group_id]["can_post"] == True:
self.tab.post.Enable(True)
super(communityBuffer, self).get_items(*args, **kwargs) super(communityBuffer, self).get_items(*args, **kwargs)
def post(self, *args, **kwargs):
menu = wx.Menu()
user1 = self.session.get_user(self.session.user_id)
user2 = self.session.get_user(self.kwargs["owner_id"])
user = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user1))
group = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user2))
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 1), group)
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 0), user)
self.tab.post.PopupMenu(menu, self.tab.post.GetPosition())
def _post(self, event, from_group):
owner_id = self.kwargs["owner_id"]
user = self.session.get_user(owner_id, key="user1")
title = _("Post to {user1_nom}'s wall").format(**user)
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=owner_id, from_group=from_group)
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
class topicBuffer(feedBuffer): class topicBuffer(feedBuffer):
def create_tab(self, parent): def create_tab(self, parent):
self.tab = home.topicTab(parent) self.tab = home.topicTab(parent)
self.connect_events() self.connect_events()
self.tab.name = self.name self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"): if "can_create_topic" not in self.session.db["group_info"][self.kwargs["group_id"]*-1] or ("can_create_topic" in self.session.db["group_info"][self.kwargs["group_id"]*-1] and self.session.db["group_info"][self.kwargs["group_id"]*-1]["can_create_topic"] != True):
self.tab.post.Enable(False) self.tab.post.Enable(False)
def onFocus(self, *args, **kwargs): def onFocus(self, event, *args, **kwargs):
pass event.Skip()
def open_post(self, *args, **kwargs): def open_post(self, *args, **kwargs):
""" Opens the currently focused post.""" """ Opens the currently focused post."""
@@ -504,6 +499,40 @@ class topicBuffer(feedBuffer):
return return
a = presenters.displayTopicPresenter(session=self.session, postObject=post, group_id=self.kwargs["group_id"], interactor=interactors.displayPostInteractor(), view=views.displayTopic()) a = presenters.displayTopicPresenter(session=self.session, postObject=post, group_id=self.kwargs["group_id"], interactor=interactors.displayPostInteractor(), view=views.displayTopic())
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
# In order to load the selected topic we firstly have to catch the group_id, which is present in self.kwargs
# After getting the group_id we should make it negative
group_id = self.kwargs["group_id"]*-1
url = "https://vk.com/topic{group_id}_{topic_id}".format(group_id=group_id, topic_id=post["id"])
webbrowser.open_new_tab(url)
def post(self, *args, **kwargs):
menu = wx.Menu()
user1 = self.session.get_user(self.session.user_id)
user2 = self.session.get_user(-1*self.kwargs["group_id"])
user = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user1))
group = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user2))
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 1), group)
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 0), user)
self.tab.post.PopupMenu(menu, self.tab.post.GetPosition())
def _post(self, event, from_group):
owner_id = self.kwargs["group_id"]
user = self.session.get_user(-1*owner_id, key="user1")
title = _("Create topic in {user1_nom}").format(**user)
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createTopicDialog(title=title, message="", text="", topic_title=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
title = p.view.title.GetValue()
msg = p.text
post_arguments = dict(title=title, text=msg, group_id=owner_id, from_group=from_group)
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="addTopic", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
class documentBuffer(feedBuffer): class documentBuffer(feedBuffer):
can_get_items = False can_get_items = False
@@ -514,13 +543,14 @@ class documentBuffer(feedBuffer):
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"): if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False) self.tab.post.Enable(False)
def onFocus(self, *args,**kwargs): def onFocus(self, event, *args,**kwargs):
post = self.get_post() post = self.get_post()
if post == None: if post == None:
return return
original_date = arrow.get(post["date"]) original_date = arrow.get(post["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2]) created_at = original_date.humanize(locale=languageHandler.curLang[:2])
self.tab.list.list.SetItem(self.tab.list.get_selected(), 4, created_at) self.tab.list.list.SetItem(self.tab.list.get_selected(), 4, created_at)
event.Skip()
def connect_events(self): def connect_events(self):
super(documentBuffer, self).connect_events() super(documentBuffer, self).connect_events()
@@ -545,6 +575,7 @@ class documentBuffer(feedBuffer):
m = menus.documentMenu(added) m = menus.documentMenu(added)
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_remove_document, menuitem=m.action) widgetUtils.connect_event(m, widgetUtils.MENU, self.add_remove_document, menuitem=m.action)
widgetUtils.connect_event(m, widgetUtils.MENU, self.download, menuitem=m.download) widgetUtils.connect_event(m, widgetUtils.MENU, self.download, menuitem=m.download)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
return m return m
def add_remove_document(self, *args, **kwargs): def add_remove_document(self, *args, **kwargs):
@@ -571,6 +602,13 @@ class documentBuffer(feedBuffer):
if filepath != None: if filepath != None:
pub.sendMessage("download-file", url=post["url"], filename=filepath) pub.sendMessage("download-file", url=post["url"], filename=filepath)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/doc{user_id}_{post_id}".format(user_id=post["owner_id"], post_id=post["id"])
webbrowser.open_new_tab(url)
class documentCommunityBuffer(documentBuffer): class documentCommunityBuffer(documentBuffer):
can_get_items = True can_get_items = True
@@ -582,9 +620,6 @@ class documentCommunityBuffer(documentBuffer):
self.tab.post.Enable(False) self.tab.post.Enable(False)
class audioBuffer(feedBuffer): class audioBuffer(feedBuffer):
""" this buffer was supposed to be used with audio elements
but is deprecated as VK removed its audio support for third party apps."""
def create_tab(self, parent): def create_tab(self, parent):
self.tab = home.audioTab(parent) self.tab = home.audioTab(parent)
self.tab.name = self.name self.tab.name = self.name
@@ -592,16 +627,38 @@ class audioBuffer(feedBuffer):
if self.name == "me_audio": if self.name == "me_audio":
self.tab.post.Enable(True) self.tab.post.Enable(True)
def get_event(self, ev):
if ev.GetKeyCode() == wx.WXK_RETURN:
if len(self.tab.list.get_multiple_selection()) < 2:
event = "play_all"
else:
event = "play_audio"
else:
event = None
ev.Skip()
if event != None:
try:
getattr(self, event)(skip_pause=True)
except AttributeError:
pass
def connect_events(self): def connect_events(self):
widgetUtils.connect_event(self.tab.play, widgetUtils.BUTTON_PRESSED, self.play_audio) widgetUtils.connect_event(self.tab.play, widgetUtils.BUTTON_PRESSED, self.play_audio)
widgetUtils.connect_event(self.tab.play_all, widgetUtils.BUTTON_PRESSED, self.play_all) widgetUtils.connect_event(self.tab.play_all, widgetUtils.BUTTON_PRESSED, self.play_all)
pub.subscribe(self.change_label, "playback-changed")
super(audioBuffer, self).connect_events() super(audioBuffer, self).connect_events()
def play_audio(self, *args, **kwargs): def play_audio(self, *args, **kwargs):
selected = self.tab.list.get_selected() if player.player.check_is_playing() and not "skip_pause" in kwargs:
if selected == -1: return pub.sendMessage("pause")
selected = 0 selected = self.tab.list.get_multiple_selection()
pub.sendMessage("play-audio", audio_object=self.session.db[self.name]["items"][selected]) if len(selected) == 0:
return
elif len(selected) == 1:
pub.sendMessage("play", object=self.session.db[self.name]["items"][selected[0]])
else:
selected_audios = [self.session.db[self.name]["items"][item] for item in selected]
pub.sendMessage("play-all", list_of_songs=selected_audios)
return True return True
def play_next(self, *args, **kwargs): def play_next(self, *args, **kwargs):
@@ -624,10 +681,10 @@ class audioBuffer(feedBuffer):
self.play_audio() self.play_audio()
def open_post(self, *args, **kwargs): def open_post(self, *args, **kwargs):
selected = self.tab.list.get_selected() selected = self.tab.list.get_multiple_selection()
if selected == -1: if len(selected) < 1:
return return
audios = [self.session.db[self.name]["items"][selected]] audios = [self.session.db[self.name]["items"][audio] for audio in selected]
a = presenters.displayAudioPresenter(session=self.session, postObject=audios, interactor=interactors.displayAudioInteractor(), view=views.displayAudio()) a = presenters.displayAudioPresenter(session=self.session, postObject=audios, interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
def play_all(self, *args, **kwargs): def play_all(self, *args, **kwargs):
@@ -637,7 +694,7 @@ class audioBuffer(feedBuffer):
if self.name not in self.session.db: if self.name not in self.session.db:
return return
audios = [i for i in self.session.db[self.name]["items"][selected:]] audios = [i for i in self.session.db[self.name]["items"][selected:]]
pub.sendMessage("play-audios", audios=audios) pub.sendMessage("play-all", list_of_songs=audios)
return True return True
def remove_buffer(self, mandatory=False): def remove_buffer(self, mandatory=False):
@@ -659,48 +716,105 @@ class audioBuffer(feedBuffer):
# Translators: Some buffers can't use the get previous item feature due to API limitations. # Translators: Some buffers can't use the get previous item feature due to API limitations.
output.speak(_("This buffer doesn't support getting more items.")) output.speak(_("This buffer doesn't support getting more items."))
def onFocus(self, *args, **kwargs): def onFocus(self, event, *args, **kwargs):
pass event.Skip()
def add_to_library(self, *args, **kwargs): def add_to_library(self, *args, **kwargs):
post = self.get_post() call_threaded(self._add_to_library, *args, **kwargs)
if post == None:
def _add_to_library(self, *args, **kwargs):
selected = self.tab.list.get_multiple_selection()
if len(selected) < 1:
return return
args = {} audios = [self.session.db[self.name]["items"][audio] for audio in selected]
args["audio_id"] = post["id"] errors_detected = 0
if "album_id" in post: for i in audios:
args["album_id"] = post["album_id"] args = {}
args["owner_id"] = post["owner_id"] args["audio_id"] = i["id"]
audio = self.session.vk.client.audio.add(**args) if "album_id" in i:
if audio != None and int(audio) > 21: args["album_id"] = i["album_id"]
output.speak(_("Audio added to your library")) args["owner_id"] = i["owner_id"]
try:
audio = self.session.vk.client.audio.add(**args)
except VkApiError:
errors_detected = errors_detected + 1
continue
if audio != None and int(audio) < 21:
errors_detected = errors_detected + 1
if errors_detected == 0:
if len(selected) == 1:
msg = _("Audio added to your library")
elif len(selected) > 1 and len(selected) < 5:
msg = _("{0} audios were added to your library.").format(len(selected),)
else:
msg = _("{audios} audios were added to your library.").format(audios=len(selected),)
output.speak(msg)
else:
output.speak(_("{0} errors occurred while attempting to add {1} audios to your library.").format(errors_detected, len(selected)))
def remove_from_library(self, *args, **kwargs): def remove_from_library(self, *args, **kwargs):
post = self.get_post() call_threaded(self._remove_from_library, *args, **kwargs)
if post == None:
def _remove_from_library(self, *args, **kwargs):
selected = self.tab.list.get_multiple_selection()
if len(selected) < 1:
return return
args = {} audios = [self.session.db[self.name]["items"][audio] for audio in selected]
args["audio_id"] = post["id"] errors_detected = 0
args["owner_id"] = self.session.user_id audios_removed = 0
result = self.session.vk.client.audio.delete(**args) for i in range(0, len(selected)):
if int(result) == 1: args = {}
output.speak(_("Removed audio from library")) args["audio_id"] = audios[i]["id"]
self.session.db[self.name]["items"].pop(self.tab.list.get_selected()) args["owner_id"] = self.session.user_id
self.tab.list.remove_item(self.tab.list.get_selected()) result = self.session.vk.client.audio.delete(**args)
if int(result) != 1:
errors_dtected = errors_detected + 1
else:
self.session.db[self.name]["items"].pop(selected[i]-audios_removed)
self.tab.list.remove_item(selected[i]-audios_removed)
audios_removed = audios_removed + 1
if errors_detected == 0:
if len(selected) == 1:
msg = _("Audio removed.")
elif len(selected) > 1 and len(selected) < 5:
msg = _("{0} audios were removed.").format(len(selected),)
else:
msg = _("{audios} audios were removed.").format(audios=len(selected),)
output.speak(msg)
else:
output.speak(_("{0} errors occurred while attempting to remove {1} audios.").format(errors_detected, len(selected)))
def move_to_album(self, *args, **kwargs): def move_to_album(self, *args, **kwargs):
if len(self.session.audio_albums) == 0: if len(self.session.audio_albums) == 0:
return commonMessages.no_audio_albums() return commonMessages.no_audio_albums()
post = self.get_post()
if post == None:
return
album = selector.album(_("Select the album where you want to move this song"), self.session) album = selector.album(_("Select the album where you want to move this song"), self.session)
if album.item == None: return if album.item == None:
id = post["id"] return
response = self.session.vk.client.audio.add(playlist_id=album.item, audio_id=id, owner_id=post["owner_id"]) call_threaded(self._move_to_album, album.item, *args, **kwargs)
if response == 1:
# Translators: Used when the user has moved an audio to an album. def _move_to_album(self, album, *args, **kwargs):
output.speak(_("Moved")) selected = self.tab.list.get_multiple_selection()
if len(selected) < 1:
return
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
errors_detected = 0
for i in audios:
id = i["id"]
try:
response = self.session.vk.client.audio.add(playlist_id=album, audio_id=id, owner_id=i["owner_id"])
except VkApiError:
errors_detected = errors_detected + 1
if errors_detected == 0:
if len(selected) == 1:
msg = _("Audio added to playlist.")
elif len(selected) > 1 and len(selected) < 5:
msg = _("{0} audios were added to playlist.").format(len(selected),)
else:
msg = _("{audios} audios were added to playlist.").format(audios=len(selected),)
output.speak(msg)
else:
output.speak(_("{0} errors occurred while attempting to add {1} audios to your playlist.").format(errors_detected, len(selected)))
def get_menu(self): def get_menu(self):
p = self.get_post() p = self.get_post()
@@ -712,7 +826,7 @@ class audioBuffer(feedBuffer):
widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move) widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move)
# if owner_id is the current user, the audio is added to the user's audios. # if owner_id is the current user, the audio is added to the user's audios.
if p["owner_id"] == self.session.user_id: if p["owner_id"] == self.session.user_id:
m.library.SetItemLabel(_("&Remove from library")) m.library.SetItemLabel(_("&Remove"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library) widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library)
else: else:
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library) widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
@@ -734,6 +848,23 @@ class audioBuffer(feedBuffer):
uploader = upload.VkUpload(self.session.vk.session_object) uploader = upload.VkUpload(self.session.vk.session_object)
call_threaded(uploader.audio, file, title=title, artist=artist) call_threaded(uploader.audio, file, title=title, artist=artist)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/audio{user_id}_{post_id}".format(user_id=post["owner_id"], post_id=post["id"])
webbrowser.open_new_tab(url)
def change_label(self, stopped):
if hasattr(self.tab, "play"):
if stopped == False:
self.tab.play.SetLabel(_("P&ause"))
else:
self.tab.play.SetLabel(_("P&lay"))
def __del__(self):
pub.unsubscribe(self.change_label, "playback-changed")
class audioAlbum(audioBuffer): class audioAlbum(audioBuffer):
""" this buffer was supposed to be used with audio albums """ this buffer was supposed to be used with audio albums
but is deprecated as VK removed its audio support for third party apps.""" but is deprecated as VK removed its audio support for third party apps."""
@@ -808,8 +939,8 @@ class videoBuffer(feedBuffer):
# Translators: Some buffers can't use the get previous item feature due to API limitations. # Translators: Some buffers can't use the get previous item feature due to API limitations.
output.speak(_("This buffer doesn't support getting more items.")) output.speak(_("This buffer doesn't support getting more items."))
def onFocus(self, *args, **kwargs): def onFocus(self, event, *args, **kwargs):
pass event.Skip()
def add_to_library(self, *args, **kwargs): def add_to_library(self, *args, **kwargs):
post = self.get_post() post = self.get_post()
@@ -856,17 +987,22 @@ class videoBuffer(feedBuffer):
if p == None: if p == None:
return return
m = menus.audioMenu() m = menus.audioMenu()
# widgetUtils.connect_event(m, widgetUtils.MENU, self.open_post, menuitem=m.open)
# widgetUtils.connect_event(m, widgetUtils.MENU, self.play_audio, menuitem=m.play)
widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move) widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move)
# if owner_id is the current user, the audio is added to the user's audios. # if owner_id is the current user, the audio is added to the user's audios.
if p["owner_id"] == self.session.user_id: if p["owner_id"] == self.session.user_id:
m.library.SetItemLabel(_("&Remove from library")) m.library.SetItemLabel(_("&Remove"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library) widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library)
else: else:
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library) widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
return m return m
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/video{user_id}_{video_id}".format(user_id=post["owner_id"], video_id=post["id"])
webbrowser.open_new_tab(url)
class videoAlbum(videoBuffer): class videoAlbum(videoBuffer):
def create_tab(self, parent): def create_tab(self, parent):
@@ -911,10 +1047,11 @@ class chatBuffer(baseBuffer):
def insert(self, item, reversed=False): def insert(self, item, reversed=False):
""" Add a new item to the list. Uses session.composefunc for parsing the dictionary and create a valid result for putting it in the list.""" """ Add a new item to the list. Uses session.composefunc for parsing the dictionary and create a valid result for putting it in the list."""
# as this tab is based in a text control, we have to overwrite the defaults.
item_ = getattr(renderers, self.compose_function)(item, self.session) item_ = getattr(renderers, self.compose_function)(item, self.session)
# the self.chat dictionary will have (first_line, last_line) as keys and message ID as a value for looking into it when needed. # the self.chat dictionary will have (first_line, last_line) as keys and message ID as a value for looking into it when needed.
# Here we will get first and last line of a chat message appended to the history. # Here we will get first and last line of a chat message appended to the history.
values = self.tab.add_message(item_[0]) values = self.tab.add_message(item_[0], reverse=reversed)
self.chats[values] = item["id"] self.chats[values] = item["id"]
def get_focused_post(self): def get_focused_post(self):
@@ -930,7 +1067,6 @@ class chatBuffer(baseBuffer):
# position[2]+1 is added because line may start with 0, while in wx.TextCtrl.GetNumberLines() that is not possible. # position[2]+1 is added because line may start with 0, while in wx.TextCtrl.GetNumberLines() that is not possible.
if position[2]+1 >= i[0] and position[2]+1 < i[1]: if position[2]+1 >= i[0] and position[2]+1 < i[1]:
id_ = self.chats[i] id_ = self.chats[i]
# print i
break break
# Retrieve here the object based in id_ # Retrieve here the object based in id_
if id_ != None: if id_ != None:
@@ -946,9 +1082,10 @@ class chatBuffer(baseBuffer):
msg = self.get_focused_post() msg = self.get_focused_post()
if msg == False: # Handle the case where the last line of the control cannot be matched to anything. if msg == False: # Handle the case where the last line of the control cannot be matched to anything.
return return
if "read_state" in msg and msg["read_state"] == 0 and msg["id"] not in self.reads and "out" in msg and msg["out"] == 0: # Mark unread conversations as read.
if "read_state" in msg and msg["read_state"] == 0 and "out" in msg and msg["out"] == 0:
self.session.soundplayer.play("message_unread.ogg") self.session.soundplayer.play("message_unread.ogg")
self.reads.append(msg["id"]) call_threaded(self.session.vk.client.messages.markAsRead, peer_id=self.kwargs["peer_id"])
self.session.db[self.name]["items"][-1]["read_state"] = 1 self.session.db[self.name]["items"][-1]["read_state"] = 1
if "attachments" in msg and len(msg["attachments"]) > 0: if "attachments" in msg and len(msg["attachments"]) > 0:
self.tab.attachments.list.Enable(True) self.tab.attachments.list.Enable(True)
@@ -985,10 +1122,11 @@ class chatBuffer(baseBuffer):
event.Skip() event.Skip()
def get_items(self, show_nextpage=False): def get_items(self, show_nextpage=False):
""" Update buffer with newest items or get older items in the buffer."""
if self.can_get_items == False: return if self.can_get_items == False: return
retrieved = True # Control variable for handling unauthorised/connection errors. retrieved = True
try: try:
num = getattr(self.session, "get_messages")(name=self.name, *self.args, **self.kwargs) num = getattr(self.session, "get_page")(show_nextpage=show_nextpage, name=self.name, *self.args, **self.kwargs)
except VkApiError as err: except VkApiError as err:
log.error("Error {0}: {1}".format(err.code, err.error)) log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code retrieved = err.code
@@ -1001,20 +1139,38 @@ class chatBuffer(baseBuffer):
self.create_tab(self.parent) self.create_tab(self.parent)
# Add name to the new control so we could look for it when needed. # Add name to the new control so we could look for it when needed.
self.tab.name = self.name self.tab.name = self.name
if show_nextpage == False: if show_nextpage == False:
if self.tab.history.GetValue() != "" and num > 0: if self.tab.history.GetValue() != "" and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]] v = [i for i in self.session.db[self.name]["items"][:num]]
# v.reverse() [wx.CallAfter(self.insert, i, False) for i in v]
[self.insert(i, False) for i in v]
else: else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]] [wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
else: else:
if num > 0: if num > 0:
[self.insert(i, False) for i in self.session.db[self.name]["items"][:num]] # At this point we save more CPU and mathematical work if we just delete everything in the chat history and readd all messages.
# Otherwise we'd have to insert new lines at the top and recalculate positions everywhere else.
# Firstly, we'd have to save the current focused object so we will place the user in the right part of the text after loading everything again.
focused_post = self.get_post()
self.chats = dict()
self.tab.history.SetValue("")
v = [i for i in self.session.db[self.name]["items"]]
[wx.CallAfter(self.insert, i) for i in v]
# Now it's time to set back the focus in the post.
for i in self.chats.keys():
if self.chats[i] == focused_post["id"]:
line = i[0]
self.tab.history.SetInsertionPoint(self.tab.history.XYToPosition(0, line))
output.speak(_("Items loaded"))
break
if self.unread == True and num > 0: if self.unread == True and num > 0:
self.session.db[self.name]["items"][-1].update(read_state=0) self.session.db[self.name]["items"][-1].update(read_state=0)
return retrieved return retrieved
def get_more_items(self):
output.speak(_("Getting more items..."))
call_threaded(self.get_items, show_nextpage=True)
def add_attachment(self, *args, **kwargs): def add_attachment(self, *args, **kwargs):
a = presenters.attachPresenter(session=self.session, view=views.attachDialog(voice_messages=True), interactor=interactors.attachInteractor()) a = presenters.attachPresenter(session=self.session, view=views.attachDialog(voice_messages=True), interactor=interactors.attachInteractor())
if len(a.attachments) != 0: if len(a.attachments) != 0:
@@ -1026,74 +1182,20 @@ class chatBuffer(baseBuffer):
wx.Bell() wx.Bell()
return return
self.tab.text.SetValue("") self.tab.text.SetValue("")
call_threaded(self._send_message, text=text) post_arguments = dict(random_id = random.randint(0, 100000), peer_id=self.kwargs["peer_id"])
if len(text) > 0:
def upload_attachments(self, attachments): post_arguments.update(message=text)
""" Upload attachments to VK before posting them. if hasattr(self, "attachments_to_be_sent") and len(self.attachments_to_be_sent) > 0:
Returns attachments formatted as string, as required by VK API. attachments = self.attachments_to_be_sent[::]
""" else:
local_attachments = "" attachments = []
uploader = upload.VkUpload(self.session.vk.session_object) call_threaded(pub.sendMessage, "post", parent_endpoint="messages", child_endpoint="send", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
for i in attachments: if hasattr(self, "attachments_to_be_sent"):
if i["from"] == "online": del self.attachments_to_be_sent
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
elif i["from"] == "local" and i["type"] == "photo":
photos = i["file"]
description = i["description"]
r = uploader.photo_messages(photos)
id = r[0]["id"]
owner_id = r[0]["owner_id"]
local_attachments += "photo{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "audio":
audio = i["file"]
title = "untitled"
artist = "unnamed"
if "artist" in i:
artist = i["artist"]
if "title" in i:
title = i["title"]
r = uploader.audio(audio, title=title, artist=artist)
id = r["id"]
owner_id = r["owner_id"]
local_attachments += "audio{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "voice_message":
r = uploader.audio_message(i["file"], peer_id=self.kwargs["peer_id"])
id = r["audio_message"]["id"]
owner_id = r["audio_message"]["owner_id"]
local_attachments += "audio_message{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "document":
document = i["file"]
title = i["title"]
r = uploader.document(document, title=title, message_peer_id=self.kwargs["peer_id"])
id = r["doc"]["id"]
owner_id = r["doc"]["owner_id"]
local_attachments += "doc{0}_{1},".format(owner_id, id)
return local_attachments
def _send_message(self, text, attachments=[]):
if hasattr(self, "attachments_to_be_sent") and type(self.attachments_to_be_sent) == list:
self.attachments_to_be_sent = self.upload_attachments(self.attachments_to_be_sent)
try:
# Let's take care about the random_id attribute.
# This should be unique per message and should be changed right after the message has been sent.
# If the message is tried to be sent twice this random_id should be the same for both copies.
# At the moment we just calculate len(text)_user_id, hope that will work.
random_id = random.randint(0, 100000)
if hasattr(self, "attachments_to_be_sent"):
response = self.session.vk.client.messages.send(peer_id=self.kwargs["peer_id"], message=text, attachment=self.attachments_to_be_sent, random_id=random_id)
else:
response = self.session.vk.client.messages.send(peer_id=self.kwargs["peer_id"], message=text, random_id=random_id)
except ValueError as ex:
if ex.code == 9:
output.speak(_("You have been sending a message that is already sent. Try to update the buffer if you can't see the new message in the history."))
finally:
if hasattr(self, "attachments_to_be_sent"):
del self.attachments_to_be_sent
def __init__(self, unread=False, *args, **kwargs): def __init__(self, unread=False, *args, **kwargs):
super(chatBuffer, self).__init__(*args, **kwargs) super(chatBuffer, self).__init__(*args, **kwargs)
self.unread = unread self.unread = unread
self.reads = []
self.chats = dict() self.chats = dict()
self.peer_typing = 0 self.peer_typing = 0
self.last_keypress = time.time() self.last_keypress = time.time()
@@ -1106,7 +1208,11 @@ class chatBuffer(baseBuffer):
# We don't need the photos_list attachment, so skip it. # We don't need the photos_list attachment, so skip it.
if i["type"] == "photos_list": if i["type"] == "photos_list":
continue continue
attachments.append(add_attachment(i)) try:
rendered_object = add_attachment(i)
except:
log.exception("Error parsing the following attachment on chat: %r" % (i,))
attachments.append(rendered_object)
self.attachments.append(i) self.attachments.append(i)
self.tab.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_attachment) self.tab.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_attachment)
self.tab.insert_attachments(attachments) self.tab.insert_attachments(attachments)
@@ -1118,8 +1224,7 @@ class chatBuffer(baseBuffer):
a = presenters.displayAudioPresenter(session=self.session, postObject=[attachment["audio"]], interactor=interactors.displayAudioInteractor(), view=views.displayAudio()) a = presenters.displayAudioPresenter(session=self.session, postObject=[attachment["audio"]], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
elif attachment["type"] == "audio_message": elif attachment["type"] == "audio_message":
link = attachment["audio_message"]["link_mp3"] link = attachment["audio_message"]["link_mp3"]
output.speak(_("Playing...")) pub.sendMessage("play-message", message_url=link)
player.player.play(url=dict(url=link), set_info=False)
elif attachment["type"] == "link": elif attachment["type"] == "link":
output.speak(_("Opening URL..."), True) output.speak(_("Opening URL..."), True)
webbrowser.open_new_tab(attachment["link"]["url"]) webbrowser.open_new_tab(attachment["link"]["url"])
@@ -1149,6 +1254,8 @@ class chatBuffer(baseBuffer):
break break
if url != "": if url != "":
webbrowser.open_new_tab(url) webbrowser.open_new_tab(url)
if attachment["type"] == "wall":
pub.sendMessage("open-post", post_object=attachment["wall"], controller_="displayPost")
else: else:
log.debug("Unhandled attachment: %r" % (attachment,)) log.debug("Unhandled attachment: %r" % (attachment,))
@@ -1169,8 +1276,28 @@ class chatBuffer(baseBuffer):
else: else:
return False return False
def open_in_browser(self, *args, **kwargs):
peer_id = self.kwargs["peer_id"]
url = "https://vk.com/im?sel={peer_id}".format(peer_id=peer_id)
webbrowser.open_new_tab(url)
class peopleBuffer(feedBuffer): class peopleBuffer(feedBuffer):
def post(self, *args, **kwargs):
user = self.get_post()
if "can_post" not in user: # retrieve data if not present in the object.
user = self.session.vk.client.users.get(user_ids=user["id"], fields="can_post")[0]
if user.get("can_post") == True:
user_str = self.session.get_user(user["id"], key="user1")
title = _("Post to {user1_nom}'s wall").format(**user_str)
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=user["id"])
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
def create_tab(self, parent): def create_tab(self, parent):
self.tab = home.peopleTab(parent) self.tab = home.peopleTab(parent)
self.connect_events() self.connect_events()
@@ -1193,6 +1320,10 @@ class peopleBuffer(feedBuffer):
post = self.get_post() post = self.get_post()
if post == None: if post == None:
return return
if post.get("can_post") == True:
self.tab.post.Enable(True)
else:
self.tab.post.Enable(False)
if ("last_seen" in post) == False: return if ("last_seen" in post) == False: return
original_date = arrow.get(post["last_seen"]["time"]) original_date = arrow.get(post["last_seen"]["time"])
now = arrow.now() now = arrow.now()
@@ -1206,7 +1337,14 @@ class peopleBuffer(feedBuffer):
self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, online_status) self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, online_status)
def open_timeline(self, *args, **kwargs): def open_timeline(self, *args, **kwargs):
pass user = self.get_post()
if user == None:
return
a = timeline.timelineDialog([self.session.get_user(user["id"])["user1_gen"]], show_selector=False)
if a.get_response() == widgetUtils.OK:
buffer_type = a.get_buffer_type()
user_id = user["id"]
pub.sendMessage("create-timeline", user_id=user_id, buffer_type=buffer_type)
def get_menu(self, *args, **kwargs): def get_menu(self, *args, **kwargs):
""" display menu for people buffers (friends and requests)""" """ display menu for people buffers (friends and requests)"""
@@ -1224,12 +1362,14 @@ class peopleBuffer(feedBuffer):
else: else:
m = menus.peopleMenu(is_request=False) m = menus.peopleMenu(is_request=False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.decline_friendship, menuitem=m.decline) widgetUtils.connect_event(m, widgetUtils.MENU, self.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. widgetUtils.connect_event(m, widgetUtils.MENU, self.block_person, menuitem=m.block)
# It is not allowed to send messages to people who is not your friends, so let's disable it if we're in a pending or outgoing requests buffer.
if "friend_requests" in self.name: if "friend_requests" in self.name:
m.message.Enable(False) m.message.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.new_chat, menuitem=m.message) widgetUtils.connect_event(m, widgetUtils.MENU, self.new_chat, menuitem=m.message)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_timeline, menuitem=m.timeline) widgetUtils.connect_event(m, widgetUtils.MENU, self.open_timeline, menuitem=m.timeline)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile) widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
return m return m
def open_post(self, *args, **kwargs): pass def open_post(self, *args, **kwargs): pass
@@ -1256,6 +1396,21 @@ class peopleBuffer(feedBuffer):
self.session.db[self.name]["items"].pop(self.tab.list.get_selected()) self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected()) self.tab.list.remove_item(self.tab.list.get_selected())
def block_person(self, *args, **kwargs):
person = self.get_post()
if person == None:
return
user = self.session.get_user(person["id"])
question = commonMessages.block_person(user)
if question == widgetUtils.NO:
return
result = self.session.vk.client.account.ban(owner_id=person["id"])
if result == 1:
msg = _("You've blocked {user1_nom} from your friends.").format(**user,)
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
def keep_as_follower(self, *args, **kwargs): def keep_as_follower(self, *args, **kwargs):
pass pass
@@ -1296,8 +1451,8 @@ class peopleBuffer(feedBuffer):
if focused_user["id"] == self.session.db[self.name]["items"][i]["id"]: if focused_user["id"] == self.session.db[self.name]["items"][i]["id"]:
self.tab.list.select_item(i) self.tab.list.select_item(i)
return return
elif user == focused_user and user_index < len(self.tab.list.get_count()): elif user == focused_user and person_index < self.tab.list.get_count():
self.tab.list.select_item(user_index) self.tab.list.select_item(person_index)
else: else:
self.tab.list.select_item(self.tab.list.get_count()-1) self.tab.list.select_item(self.tab.list.get_count()-1)
@@ -1319,6 +1474,13 @@ class peopleBuffer(feedBuffer):
log.exception("Removing an user from online status manually... %r" % (i)) log.exception("Removing an user from online status manually... %r" % (i))
self.remove_person(i["id"]) self.remove_person(i["id"])
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/id{user_id}".format(user_id=post["id"])
webbrowser.open_new_tab(url)
class requestsBuffer(peopleBuffer): class requestsBuffer(peopleBuffer):
def get_items(self, show_nextpage=False): def get_items(self, show_nextpage=False):
@@ -1343,9 +1505,9 @@ class requestsBuffer(peopleBuffer):
if self.tab.list.get_count() > 0 and num > 0: if self.tab.list.get_count() > 0 and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]] v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse() v.reverse()
[self.insert(i, True) for i in v] [wx.CallAfter(self.insert, i, True) for i in v]
else: else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]] [wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
return retrieved return retrieved
def accept_friendship(self, *args, **kwargs): def accept_friendship(self, *args, **kwargs):
@@ -1390,4 +1552,14 @@ class requestsBuffer(peopleBuffer):
msg = _("{0} {1} is following you.").format(person["first_name"], person["last_name"]) msg = _("{0} {1} is following you.").format(person["first_name"], person["last_name"])
pub.sendMessage("notify", message=msg) pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected()) self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected()) self.tab.list.remove_item(self.tab.list.get_selected())
class notificationBuffer(feedBuffer):
def create_tab(self, parent):
self.tab = home.notificationTab(parent)
self.connect_events()
self.tab.name = self.name
def onFocus(self, event, *args, **kwargs):
event.Skip()

View File

@@ -3,6 +3,7 @@ import time
import os import os
import webbrowser import webbrowser
import subprocess import subprocess
import functools
import logging import logging
import wx import wx
import widgetUtils import widgetUtils
@@ -13,6 +14,7 @@ import views
import config import config
import paths import paths
import win32gui import win32gui
from concurrent import futures
from vk_api.exceptions import LoginRequired, VkApiError from vk_api.exceptions import LoginRequired, VkApiError
from requests.exceptions import ConnectionError from requests.exceptions import ConnectionError
from pubsub import pub from pubsub import pub
@@ -20,7 +22,7 @@ from mysc import restart
from mysc.repeating_timer import RepeatingTimer from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded from mysc.thread_utils import call_threaded
from mysc import localization from mysc import localization
from sessionmanager import session, utils, renderers from sessionmanager import session, utils, renderers, sessionManager
from wxUI import (mainWindow, commonMessages, menus) from wxUI import (mainWindow, commonMessages, menus)
from wxUI.dialogs import search as searchDialogs from wxUI.dialogs import search as searchDialogs
from wxUI.dialogs import creation, timeline from wxUI.dialogs import creation, timeline
@@ -33,6 +35,30 @@ from . import selector
log = logging.getLogger("controller.main") log = logging.getLogger("controller.main")
thread_pool_executor = futures.ThreadPoolExecutor(max_workers=1)
def wx_call_after(target):
@functools.wraps(target)
def wrapper(self, *args, **kwargs):
args = (self,) + args
wx.CallAfter(target, *args, **kwargs)
return wrapper
def submit_to_pool_executor(executor):
def decorator(target):
@functools.wraps(target)
def wrapper(*args, **kwargs):
result = executor.submit(target, *args, **kwargs)
result.add_done_callback(executor_done_call_back)
return result
return wrapper
return decorator
def executor_done_call_back(future):
exception = future.exception()
if exception:
raise exception
class Controller(object): class Controller(object):
### utils ### utils
@@ -67,7 +93,7 @@ class Controller(object):
player.setup() player.setup()
self.window = mainWindow.mainWindow() self.window = mainWindow.mainWindow()
log.debug("Main window created") log.debug("Main window created")
self.window.change_status(_("Ready")) wx.CallAfter(self.window.change_status, _("Ready"))
self.session = session.sessions[list(session.sessions.keys())[0]] self.session = session.sessions[list(session.sessions.keys())[0]]
self.window.Show() self.window.Show()
self.connect_pubsub_events() self.connect_pubsub_events()
@@ -101,21 +127,20 @@ class Controller(object):
pub.sendMessage("create_buffer", buffer_type="videoBuffer", buffer_title=_("My videos"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="me_video", composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"])) pub.sendMessage("create_buffer", buffer_type="videoBuffer", buffer_title=_("My videos"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="me_video", composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"]))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Albums"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="video_albums")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Albums"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="video_albums"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("People"), kwargs=dict(parent=self.window.tb, name="people")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("People"), kwargs=dict(parent=self.window.tb, name="people"))
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Online"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="online_friends", composefunc="render_person", session=self.session, endpoint="getOnline", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen")) pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Online"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="online_friends", composefunc="render_person", session=self.session, endpoint="getOnline", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen, can_post"))
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("All friends"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="friends_", composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen")) pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("All friends"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="friends_", composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen, can_post"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Friendship requests"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="requests")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Friendship requests"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="requests"))
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Pending requests"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000)) pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Pending requests"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000, fields="can_post"))
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("I follow"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1)) pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("I follow"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1, fields="can_post"))
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Subscribers"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="subscribers", composefunc="render_person", session=self.session, count=1000, need_viewed=1)) pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Subscribers"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="subscribers", composefunc="render_person", session=self.session, count=1000, need_viewed=1, fields="can_post"))
# pub.sendMessage("create_buffer", buffer_type="notificationBuffer", buffer_title=_("Notifications"), parent_tab=None, loadable=False, kwargs=dict(parent=self.window.tb, name="notifications", composefunc="render_notification", session=self.session, endpoint="get", parent_endpoint="notifications", count=100, filters="wall,mentions,comments,likes,reposted,followers,friends"))
pub.sendMessage("create_buffer", buffer_type="documentBuffer", buffer_title=_("Documents"), parent_tab=None, loadable=True, kwargs=dict(parent=self.window.tb, name="documents", composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs")) pub.sendMessage("create_buffer", buffer_type="documentBuffer", buffer_title=_("Documents"), parent_tab=None, loadable=True, kwargs=dict(parent=self.window.tb, name="documents", composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Groups"), kwargs=dict(parent=self.window.tb, name="communities")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Groups"), kwargs=dict(parent=self.window.tb, name="communities"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Chats"), kwargs=dict(parent=self.window.tb, name="chats")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Chats"), kwargs=dict(parent=self.window.tb, name="chats"))
pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Timelines"), kwargs=dict(parent=self.window.tb, name="timelines")) pub.sendMessage("create_buffer", buffer_type="emptyBuffer", buffer_title=_("Timelines"), kwargs=dict(parent=self.window.tb, name="timelines"))
self.window.realize() wx.CallAfter(self.window.realize)
self.repeatedUpdate = RepeatingTimer(120, self.update_all_buffers) self.repeatedUpdate = RepeatingTimer(120, self.update_all_buffers)
self.repeatedUpdate.start() self.repeatedUpdate.start()
self.readMarker = RepeatingTimer(60, self.mark_as_read)
self.readMarker.start()
def complete_buffer_creation(self, buffer, name_, position): def complete_buffer_creation(self, buffer, name_, position):
answer = buffer.get_items() answer = buffer.get_items()
@@ -146,25 +171,14 @@ class Controller(object):
log.error("Error in setting offline status for the current user") log.error("Error in setting offline status for the current user")
def create_unread_messages(self): def create_unread_messages(self):
if self.session.settings["chat"]["open_unread_conversations"] == False:
return
try: try:
log.debug("Getting possible unread messages.") log.debug("Creating conversation buffers...")
msgs = self.session.vk.client.messages.getConversations(count=200) msgs = self.session.vk.client.messages.getConversations(count=200)
except VkApiError as ex: except VkApiError as ex:
if ex.code == 6: if ex.code == 6:
log.exception("Something went wrong when getting messages. Waiting a second to retry") log.exception("Something went wrong when getting messages. Waiting a second to retry")
for i in msgs["items"]: for i in msgs["items"]:
call_threaded(self.chat_from_id, i["last_message"]["peer_id"], setfocus=False, unread=False) 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, force_action=False): def get_audio_albums(self, user_id=None, create_buffers=True, force_action=False):
if self.session.settings["load_at_startup"]["audio_albums"] == False and force_action == False: if self.session.settings["load_at_startup"]["audio_albums"] == False and force_action == False:
@@ -178,8 +192,7 @@ class Controller(object):
self.session.audio_albums = albums self.session.audio_albums = albums
if create_buffers: if create_buffers:
for i in albums: for i in albums:
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="audioAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="audio_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id, album_id=i["id"])) pub.sendMessage("create_buffer", buffer_type="audioAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="audio_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id, album_id=i["id"]))
time.sleep(0.6)
def get_video_albums(self, user_id=None, create_buffers=True, force_action=False): def get_video_albums(self, user_id=None, create_buffers=True, force_action=False):
if self.session.settings["load_at_startup"]["video_albums"] == False and force_action == False: if self.session.settings["load_at_startup"]["video_albums"] == False and force_action == False:
@@ -189,8 +202,7 @@ class Controller(object):
self.session.video_albums = albums["items"] self.session.video_albums = albums["items"]
if create_buffers: if create_buffers:
for i in albums["items"]: 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"])) 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): def get_communities(self, user_id=None, create_buffers=True, force_action=False):
if self.session.settings["vk"]["invited_to_group"] == False: if self.session.settings["vk"]["invited_to_group"] == False:
@@ -210,27 +222,28 @@ class Controller(object):
if self.session.settings["load_at_startup"]["communities"] == False and force_action == False: if self.session.settings["load_at_startup"]["communities"] == False and force_action == False:
return return
log.debug("Create community buffers...") log.debug("Create community buffers...")
groups= self.session.vk.client.groups.get(user_id=user_id, extended=1, count=1000) groups= self.session.vk.client.groups.get(user_id=user_id, extended=1, count=1000, fields="can_post,can_create_topic")
self.session.groups=groups["items"] self.session.groups=groups["items"]
# Let's feed the local database cache with new groups coming from here. # Let's feed the local database cache with new groups coming from here.
data= dict(profiles=[], groups=self.session.groups) data= dict(profiles=[], groups=self.session.groups)
self.session.process_usernames(data) self.session.process_usernames(data)
if create_buffers: if create_buffers:
for i in self.session.groups: for i in self.session.groups:
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="communityBuffer", buffer_title=i["name"], parent_tab="communities", loadable=True, get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_community".format(i["id"],), composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"])) self.session.db["group_info"][i["id"]*-1] = i
time.sleep(0.15) pub.sendMessage("create_buffer", buffer_type="communityBuffer", buffer_title=i["name"], parent_tab="communities", loadable=True, get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_community".format(i["id"],), composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"]))
def login(self): def login(self):
self.window.change_status(_("Logging in VK")) wx.CallAfter(self.window.change_status, _("Logging in VK"))
self.session.login() self.session.login()
self.window.change_status(_("Ready")) wx.CallAfter(self.window.change_status, _("Ready"))
for i in self.buffers: for i in self.buffers:
if hasattr(i, "get_items"): if hasattr(i, "get_items"):
# Translators: {0} will be replaced with the name of a buffer. # Translators: {0} will be replaced with the name of a buffer.
self.window.change_status(_("Loading items for {0}").format(i.name,)) wx.CallAfter(self.window.change_status, _("Loading items for {0}").format(i.name,))
i.get_items() i.get_items()
self.window.change_status(_("Ready")) wx.CallAfter(self.window.change_status, _("Ready"))
self.create_unread_messages() call_threaded(self.create_unread_messages)
self.status_setter = RepeatingTimer(280, self.set_online) self.status_setter = RepeatingTimer(280, self.set_online)
self.status_setter.start() self.status_setter.start()
self.set_online(notify=True) self.set_online(notify=True)
@@ -292,9 +305,8 @@ class Controller(object):
def connect_pubsub_events(self): def connect_pubsub_events(self):
log.debug("Connecting events to responses...") log.debug("Connecting events to responses...")
pub.subscribe(self.in_post, "posted") pub.subscribe(self.in_post, "posted")
pub.subscribe(self.post_failed, "postFailed")
pub.subscribe(self.download, "download-file") 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.view_post, "open-post")
pub.subscribe(self.update_status_bar, "update-status-bar") pub.subscribe(self.update_status_bar, "update-status-bar")
pub.subscribe(self.chat_from_id, "new-chat") pub.subscribe(self.chat_from_id, "new-chat")
@@ -308,29 +320,78 @@ class Controller(object):
pub.subscribe(self.create_buffer, "create_buffer") pub.subscribe(self.create_buffer, "create_buffer")
pub.subscribe(self.user_typing, "user-typing") pub.subscribe(self.user_typing, "user-typing")
pub.subscribe(self.get_chat, "order-sent-message") pub.subscribe(self.get_chat, "order-sent-message")
pub.subscribe(self.create_timeline, "create-timeline")
def disconnect_events(self): def disconnect_events(self):
log.debug("Disconnecting some events...") log.debug("Disconnecting some events...")
pub.unsubscribe(self.in_post, "posted") pub.unsubscribe(self.in_post, "posted")
pub.unsubscribe(self.download, "download-file") pub.unsubscribe(self.download, "download-file")
pub.unsubscribe(self.play_audio, "play-audio")
pub.unsubscribe(self.authorisation_failed, "authorisation-failed") pub.unsubscribe(self.authorisation_failed, "authorisation-failed")
pub.unsubscribe(self.play_audios, "play-audios")
pub.unsubscribe(self.view_post, "open-post") pub.unsubscribe(self.view_post, "open-post")
pub.unsubscribe(self.update_status_bar, "update-status-bar") pub.unsubscribe(self.update_status_bar, "update-status-bar")
pub.unsubscribe(self.user_online, "user-online") pub.unsubscribe(self.user_online, "user-online")
pub.unsubscribe(self.user_offline, "user-offline") pub.unsubscribe(self.user_offline, "user-offline")
pub.unsubscribe(self.notify, "notify") pub.unsubscribe(self.notify, "notify")
pub.subscribe(self.create_timeline, "create-timeline")
def in_post(self, buffer): def in_post(self, from_buffer=None):
""" This event is triggered whenever an user requires an update in their buffers. For example after sending a post successfully. if from_buffer != None and "_messages" not in from_buffer:
The function updates the main newsfeed buffer, and the buffer from where the post was sent. log.debug("Post received in buffer %s, updating... " % (from_buffer,))
@buffer str: name of the buffer where the post has been generated. buffer = self.search(from_buffer)
""" buffer.get_items()
buffer = self.search(buffer)
buffer.get_items() def post_failed(self, parent_endpoint, child_endpoint, from_buffer=None, attachments_list=[], post_arguments={}):
buffer = self.search("home_timeline") """ Function to be called when the post (using the pubsub method) fails. It takes the same params than post() and use the parent and child endpoints to call the appropiate dialogs. """
buffer.get_items() # Ask the user if he/she wants to attempt to post the same again.
msgdialog = commonMessages.post_failed()
if msgdialog != widgetUtils.YES: # Cancelled.
return
# Let's check which kind of post has failed, and do something about it.
if parent_endpoint == "wall":
if child_endpoint == "post": # A wall post has failed, so let's create it in a dialogue.
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Write your post"), message="", text=post_arguments.get("message")))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments.update(privacy=p.privacy, message=p.text)
if hasattr(p, "attachments"):
attachments_list = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
elif child_endpoint == "repost": # repost
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Repost"), message="", text=post_arguments.get("message"), mode="comment"))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments.update(message=p.text)
if hasattr(p, "attachments"):
attachments_list = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
elif child_endpoint == "createComment": # comments.
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Add a comment"), message="", text=post_arguments.get("message"), mode="comment"))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments.update(message=p.text)
if hasattr(p, "attachments"):
attachments_list = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
elif parent_endpoint == "board": # topic creation and comments.
if child_endpoint == "addTopic":
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createTopicDialog(title=_("Create topic"), message="", topic_title=post_arguments.get("title"), text=post_arguments.get("text")))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments.update(title=p.view.title.GetValue(), text=p.text)
if hasattr(p, "attachments"):
attachments_list = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
elif child_endpoint == "createComment": # topic comments.
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Add a comment to the topic"), message="", text=post_arguments.get("message"), mode="comment"))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments.update(message=p.text)
if hasattr(p, "attachments"):
attachments_list = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
elif parent_endpoint == "messages": # Private messages
if child_endpoint == "send":
buffer = self.search(from_buffer)
buffer_window = self.window.search(buffer.name)
self.window.change_buffer(buffer_window)
buffer.tab.text.SetValue(post_arguments.get("message"))
buffer.tab.text.SetFocus()
buffer.attachments_to_be_sent = attachments_list
def download(self, url, filename): def download(self, url, filename):
""" Download a file to te current user's computer. """ Download a file to te current user's computer.
@@ -338,38 +399,22 @@ class Controller(object):
@ filename: the current path to where the file will be saved. @ filename: the current path to where the file will be saved.
The dowwload progress will be displayed in the status bar on the window. The dowwload progress will be displayed in the status bar on the window.
""" """
url = utils.transform_audio_url(url)
log.debug("downloading %s URL to %s filename" % (url, filename,)) log.debug("downloading %s URL to %s filename" % (url, filename,))
call_threaded(utils.download_file, url, filename, self.window) call_threaded(utils.download_file, url, filename, self.window)
def play_audio(self, audio_object): def view_post(self, post_object, controller_, vars=dict()):
""" Play an audio by using the local media player object.
@ audio_object dict: An audio representation returned by the VK API.
"""
# 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):
""" Play all audios passed in alist, putting the audio in a queue of the media player.
@audios list: A list of Vk audio objects.
"""
player.player.play_all(audios, shuffle=self.window.player_shuffle.IsChecked())
def view_post(self, post_object, controller_):
""" Display the passed post in the passed post presenter. """ Display the passed post in the passed post presenter.
@ post_object dict: A post representation returned by the VK api. The fields present in this dict are different depending on the presenter used to render it. @ post_object dict: A post representation returned by the VK api. The fields present in this dict are different depending on the presenter used to render it.
@controller_ string: Name of the post controller, this name will be used for calling interactors, views and presenters. For example, displayPost, displayAudio, etc. @controller_ string: Name of the post controller, this name will be used for calling interactors, views and presenters. For example, displayPost, displayAudio, etc.
""" """
p = getattr(presenters, controller_+"Presenter")(session=self.session, postObject=post_object, interactor=getattr(interactors, controller_+"Interactor")(), view=getattr(views, controller_)()) p = getattr(presenters, controller_+"Presenter")(session=self.session, postObject=post_object, interactor=getattr(interactors, controller_+"Interactor")(), view=getattr(views, controller_)(), **vars)
def update_status_bar(self, status): def update_status_bar(self, status):
""" Update the status bar present in the main Window. """ Update the status bar present in the main Window.
@ status str: Text to be placed in the status bar. @ status str: Text to be placed in the status bar.
""" """
self.window.change_status(status) wx.CallAfter(self.window.change_status, status)
def chat_from_id(self, user_id, setfocus=True, unread=False): def chat_from_id(self, user_id, setfocus=True, unread=False):
""" Create a conversation buffer for. """ Create a conversation buffer for.
@@ -392,7 +437,7 @@ class Controller(object):
elif user_id > 2000000000: elif user_id > 2000000000:
chat = self.session.vk.client.messages.getChat(chat_id=user_id-2000000000) chat = self.session.vk.client.messages.getChat(chat_id=user_id-2000000000)
name = chat["title"] 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")) pub.sendMessage("create_buffer", buffer_type="chatBuffer", buffer_title=name, parent_tab="chats", get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="render_message", parent_endpoint="messages", endpoint="getHistory", session=self.session, unread=unread, count=self.session.settings["buffers"]["count_for_chat_buffers"], peer_id=user_id, rev=0, extended=True, fields="id, user_id, date, read_state, out, body, attachments, deleted"))
# if setfocus: # if setfocus:
# pos = self.window.search(buffer.name) # pos = self.window.search(buffer.name)
# self.window.change_buffer(pos) # self.window.change_buffer(pos)
@@ -419,15 +464,14 @@ class Controller(object):
p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor()) p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor())
def user_online(self, event): def user_online(self, event):
""" Sends a notification of an user connecting to VK. """ Add user to the online buffer and Send a notification of an user connecting to VK.
@ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module. @ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module.
""" """
if self.session.settings["chat"]["notify_online"] == False: if self.session.settings["chat"]["notify_online"] == True:
return user_name = self.session.get_user(event.user_id)
user_name = self.session.get_user(event.user_id) msg = _("{user1_nom} is online.").format(**user_name)
msg = _("{user1_nom} is online.").format(**user_name) sound = "friend_online.ogg"
sound = "friend_online.ogg" self.notify(msg, sound, self.session.settings["chat"]["notifications"])
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
online_buffer = self.search("online_friends") online_buffer = self.search("online_friends")
user = None user = None
for i in self.session.db["friends_"]["items"]: for i in self.session.db["friends_"]["items"]:
@@ -437,21 +481,20 @@ class Controller(object):
break break
if user == None: if user == None:
log.exception("Getting user manually...") log.exception("Getting user manually...")
user = self.session.vk.client.users.get(user_ids=event.user_id, fields="last_seen")[0] user = self.session.vk.client.users.get(user_ids=event.user_id, fields="last_seen, can_post")[0]
online_buffer.add_person(user) wx.CallAfter(online_buffer.add_person, user)
def user_offline(self, event): def user_offline(self, event):
""" Sends a notification of an user logging off in VK. """ Remove user from the online buffer and Send a notification of an user logging off in VK.
@ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module. @ event vk_api.longpoll.event object: The event sent by the vk_api's longPoll module.
""" """
if self.session.settings["chat"]["notify_offline"] == False: if self.session.settings["chat"]["notify_offline"] == True:
return user_name = self.session.get_user(event.user_id)
user_name = self.session.get_user(event.user_id) msg = _("{user1_nom} is offline.").format(**user_name)
msg = _("{user1_nom} is offline.").format(**user_name) sound = "friend_offline.ogg"
sound = "friend_offline.ogg" self.notify(msg, sound, self.session.settings["chat"]["notifications"])
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
online_friends = self.search("online_friends") online_friends = self.search("online_friends")
online_friends.remove_person(event.user_id) wx.CallAfter(online_friends.remove_person, event.user_id)
def notify(self, message="", sound="", type="native"): def notify(self, message="", sound="", type="native"):
""" display a notification in Socializer. """ display a notification in Socializer.
@@ -478,7 +521,7 @@ class Controller(object):
if hasattr(self, "longpoll"): if hasattr(self, "longpoll"):
del self.longpoll del self.longpoll
self.create_longpoll_thread(notify=True) self.create_longpoll_thread(notify=True)
@wx_call_after
def create_buffer(self, buffer_type="baseBuffer", buffer_title="", parent_tab=None, loadable=False, get_items=False, kwargs={}): def create_buffer(self, buffer_type="baseBuffer", buffer_title="", parent_tab=None, loadable=False, get_items=False, kwargs={}):
""" Create and insert a buffer in the specified place. """ Create and insert a buffer in the specified place.
@buffer_type str: name of the buffer type to be created. This should be a class in the buffers.py module. @buffer_type str: name of the buffer type to be created. This should be a class in the buffers.py module.
@@ -538,8 +581,8 @@ class Controller(object):
data = [message] data = [message]
# Let's add this to the buffer. # Let's add this to the buffer.
# ToDo: Clean this code and test how is the database working with this set to True. # 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.session.db[buffer.name]["items"].append(message)
buffer.insert(self.session.db[buffer.name]["items"][-1], False) wx.CallAfter(buffer.insert, self.session.db[buffer.name]["items"][-1], False)
self.session.soundplayer.play("message_received.ogg") self.session.soundplayer.play("message_received.ogg")
wx.CallAfter(self.reorder_buffer, buffer) wx.CallAfter(self.reorder_buffer, buffer)
# Check if we have to read the message aloud # Check if we have to read the message aloud
@@ -547,13 +590,38 @@ class Controller(object):
rendered_message = renderers.render_message(message, self.session) rendered_message = renderers.render_message(message, self.session)
output.speak(rendered_message[0]) output.speak(rendered_message[0])
def create_timeline(self, user_id, buffer_type, user=""):
if user_id == "":
user_data = self.session.vk.client.utils.resolveScreenName(screen_name=user)
if type(user_data) == list:
commonMessages.no_user_exist()
return
user_id = user_data["object_id"]
if buffer_type == "audio":
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, create_tab=False, endpoint="get", parent_endpoint="audio", owner_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s audios").format(**user)
elif buffer_type == "wall":
buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_id,), composefunc="render_status", session=self.session, create_tab=False, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s posts").format(**user)
elif buffer_type == "video":
buffer = buffers.videoBuffer(parent=self.window.tb, name="{0}_video".format(user_id,), composefunc="render_video", session=self.session, create_tab=False, endpoint="get", parent_endpoint="video", owner_id=user_id, count=self.session.settings["buffers"]["count_for_video_buffers"])
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s videos").format(**user)
elif buffer_type == "friends":
buffer = buffers.peopleBuffer(parent=self.window.tb, name="friends_{0}".format(user_id,), composefunc="render_person", session=self.session, create_tab=False, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen", user_id=user_id)
user = self.session.get_user(user_id, key="user1")
name_ = _("{user1_nom}'s friends").format(**user)
wx.CallAfter(self.complete_buffer_creation, buffer=buffer, name_=name_, position=self.window.search("timelines"))
### GUI events ### GUI events
# These functions are connected to GUI elements such as menus, buttons and so on. # These functions are connected to GUI elements such as menus, buttons and so on.
def connect_gui_events(self): def connect_gui_events(self):
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit) 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.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.check_for_updates, menuitem=self.window.check_for_updates)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.window.about_dialog, menuitem=self.window.about) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_about, menuitem=self.window.about)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_audios, menuitem=self.window.search_audios) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_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.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.remove_buffer, menuitem=self.window.remove_buffer_)
@@ -561,6 +629,8 @@ class Controller(object):
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.open_logs, menuitem=self.window.open_logs) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.open_logs, menuitem=self.window.open_logs)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.open_config, menuitem=self.window.open_config) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.open_config, menuitem=self.window.open_config)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.blacklist, menuitem=self.window.blacklist)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.manage_accounts, menuitem=self.window.accounts)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.configuration, menuitem=self.window.settings_dialog) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.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.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.create_audio_album, menuitem=self.window.audio_album)
@@ -572,6 +642,8 @@ class Controller(object):
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_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_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_play_all, menuitem=self.window.player_play_all)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.seek_left, menuitem=self.window.player_seek_left)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.seek_right, menuitem=self.window.player_seek_right)
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_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_volume_up, menuitem=self.window.player_volume_up)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute) widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute)
@@ -602,6 +674,10 @@ class Controller(object):
if update == False: if update == False:
commonMessages.no_update_available() commonMessages.no_update_available()
def on_about(self, *args, **kwargs):
channel = self.session.settings["general"]["update_channel"]
self.window.about_dialog(channel)
def search_audios(self, *args, **kwargs): def search_audios(self, *args, **kwargs):
dlg = searchDialogs.searchAudioDialog() dlg = searchDialogs.searchAudioDialog()
if dlg.get_response() == widgetUtils.OK: if dlg.get_response() == widgetUtils.OK:
@@ -654,10 +730,23 @@ class Controller(object):
os.chdir("documentation/%s" % (lang,)) os.chdir("documentation/%s" % (lang,))
webbrowser.open("changelog.html") webbrowser.open("changelog.html")
os.chdir("../../") os.chdir("../../")
def configuration(self, *args, **kwargs): def configuration(self, *args, **kwargs):
""" Opens the global settings dialogue.""" """ Opens the global settings dialogue."""
presenter = presenters.configurationPresenter(session=self.session, view=views.configurationDialog(title=_("Preferences")), interactor=interactors.configurationInteractor()) presenter = presenters.configurationPresenter(session=self.session, view=views.configurationDialog(title=_("Preferences")), interactor=interactors.configurationInteractor())
def blacklist(self, *args, **kwargs):
""" Opens the blacklist presenter."""
presenter = presenters.blacklistPresenter(session=self.session, view=views.blacklistDialog(), interactor=interactors.blacklistInteractor())
def manage_accounts(self, *args, **kwargs):
accounts = sessionManager.sessionManagerController(starting=False)
accounts.view.get_response()
if hasattr(accounts, "modified"):
restart_msg = commonMessages.restart_program()
if restart_msg == widgetUtils.YES:
restart.restart_program()
def open_logs(self, *args, **kwargs): def open_logs(self, *args, **kwargs):
subprocess.call(["explorer", paths.logs_path()]) subprocess.call(["explorer", paths.logs_path()])
@@ -684,25 +773,7 @@ class Controller(object):
for i in d: for i in d:
if i[1] == user: if i[1] == user:
user_id = i[0] user_id = i[0]
if user_id == "": pub.sendMessage("create-timeline", user_id=user_id, buffer_type=buffertype)
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 create_audio_album(self, *args, **kwargs): def create_audio_album(self, *args, **kwargs):
d = creation.audio_album() d = creation.audio_album()
@@ -785,20 +856,10 @@ class Controller(object):
self.search("me_audio").play_all() self.search("me_audio").play_all()
def menu_play_next(self, *args, **kwargs): def menu_play_next(self, *args, **kwargs):
return player.player.play_next() pub.sendMessage("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): def menu_play_previous(self, *args, **kwargs):
return player.player.play_previous() pub.sendMessage("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): def menu_play_all(self, *args, **kwargs):
b = self.get_current_buffer() b = self.get_current_buffer()
@@ -808,13 +869,22 @@ class Controller(object):
self.search("me_audio").play_all() self.search("me_audio").play_all()
def menu_volume_down(self, *args, **kwargs): def menu_volume_down(self, *args, **kwargs):
player.player.volume = player.player.volume-5 if player.player != None:
player.player.volume = player.player.volume-2
def menu_volume_up(self, *args, **kwargs): def menu_volume_up(self, *args, **kwargs):
player.player.volume = player.player.volume+5 if player.player != None:
player.player.volume = player.player.volume+2
def menu_mute(self, *args, **kwargs): def menu_mute(self, *args, **kwargs):
player.player.volume = 0 if player.player != None:
player.player.volume = 0
def seek_left(self, *args, **kwargs):
pub.sendMessage("seek", ms=-500000)
def seek_right(self, *args, **kwargs):
pub.sendMessage("seek", ms=500000)
def view_my_profile(self, *args, **kwargs): def view_my_profile(self, *args, **kwargs):
self.user_profile(self.session.user_id) self.user_profile(self.session.user_id)
@@ -853,19 +923,19 @@ class Controller(object):
# 2. If the group_info does not have counters for such items, which would indicate there are no items posted yet. # 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: if self.search(current_buffer.name+"_audios") != False:
menu.load_audios.Enable(False) menu.load_audios.Enable(False)
elif hasattr(current_buffer, "group_info") and "audios" not in current_buffer.group_info["counters"]: elif "counters" in self.session.db["group_info"][current_buffer.group_id] and "audios" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
menu.load_audios.Enable(False) menu.load_audios.Enable(False)
if self.search(current_buffer.name+"_videos") != False: if self.search(current_buffer.name+"_videos") != False:
menu.load_videos.Enable(False) menu.load_videos.Enable(False)
elif hasattr(current_buffer, "group_info") and "videos" not in current_buffer.group_info["counters"]: elif "counters" in self.session.db["group_info"][current_buffer.group_id] and "videos" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
menu.load_videos.Enable(False) menu.load_videos.Enable(False)
if self.search(current_buffer.name+"_topics") != False: if self.search(current_buffer.name+"_topics") != False:
menu.load_topics.Enable(False) menu.load_topics.Enable(False)
elif hasattr(current_buffer, "group_info") and "topics" not in current_buffer.group_info["counters"]: elif "counters" in self.session.db["group_info"][current_buffer.group_id] and "topics" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
menu.load_topics.Enable(False) menu.load_topics.Enable(False)
if self.search(current_buffer.name+"_documents") != False: if self.search(current_buffer.name+"_documents") != False:
menu.load_documents.Enable(False) menu.load_documents.Enable(False)
elif hasattr(current_buffer, "group_info") and "docs" not in current_buffer.group_info["counters"]: elif "counters" in self.session.db["group_info"][current_buffer.group_id] and "docs" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
menu.load_documents.Enable(False) menu.load_documents.Enable(False)
# Connect the rest of the functions. # 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_posts, menuitem=menu.load_posts)
@@ -883,6 +953,7 @@ class Controller(object):
else: else:
option = menu.Append(wx.NewId(), _("Discard groups")) option = menu.Append(wx.NewId(), _("Discard groups"))
widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_community_buffers, menuitem=option) widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_community_buffers, menuitem=option)
# Deal with video and audio albums' sections.
elif current_buffer.name == "audio_albums": elif current_buffer.name == "audio_albums":
menu = wx.Menu() menu = wx.Menu()
if self.session.settings["load_at_startup"]["audio_albums"] == False and not hasattr(self.session, "audio_albums"): if self.session.settings["load_at_startup"]["audio_albums"] == False and not hasattr(self.session, "audio_albums"):
@@ -899,7 +970,10 @@ class Controller(object):
else: else:
option = menu.Append(wx.NewId(), _("Discard video albums")) option = menu.Append(wx.NewId(), _("Discard video albums"))
widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_video_album_buffers, menuitem=option) widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_video_album_buffers, menuitem=option)
elif current_buffer.name.endswith("_messages"):
menu = menus.conversationBufferMenu()
widgetUtils.connect_event(menu, widgetUtils.MENU, self.delete_conversation, menuitem=menu.delete)
widgetUtils.connect_event(menu, widgetUtils.MENU, current_buffer.open_in_browser, menuitem=menu.open_in_browser)
if menu != None: if menu != None:
self.window.PopupMenu(menu, self.window.FindFocus().GetPosition()) self.window.PopupMenu(menu, self.window.FindFocus().GetPosition())
# If there are no available menus, let's indicate it. # If there are no available menus, let's indicate it.
@@ -916,52 +990,52 @@ class Controller(object):
""" Load community audios if they are not loaded already.""" """ Load community audios if they are not loaded already."""
current_buffer = self.get_current_buffer() 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. # 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"): if current_buffer.group_id not in self.session.db["group_info"] or "counters" not in self.session.db["group_info"][current_buffer.group_id]:
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0] group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters,can_create_topics,can_post")[0]
current_buffer.group_info = group_info self.session.db["group_info"][current_buffer.kwargs["owner_id"]].update(group_info)
if "audios" not in current_buffer.group_info["counters"]: if "audios" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
commonMessages.community_no_items() commonMessages.community_no_items()
return return
new_name = current_buffer.name+"_audios" new_name = current_buffer.name+"_audios"
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="audioBuffer", buffer_title=_("Audios"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=current_buffer.kwargs["owner_id"])) pub.sendMessage("create_buffer", buffer_type="audioBuffer", buffer_title=_("Audios"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=current_buffer.kwargs["owner_id"]))
def load_community_videos(self, *args, **kwargs): def load_community_videos(self, *args, **kwargs):
""" Load community videos if they are not loaded already.""" """ Load community videos if they are not loaded already."""
current_buffer = self.get_current_buffer() 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. # 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"): if current_buffer.group_id not in self.session.db["group_info"] or "counters" not in self.session.db["group_info"][current_buffer.group_id]:
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0] group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters,can_create_topics,can_post")[0]
current_buffer.group_info = group_info self.session.db["group_info"][current_buffer.kwargs["owner_id"]].update(group_info)
if "videos" not in current_buffer.group_info["counters"]: if "videos" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
commonMessages.community_no_items() commonMessages.community_no_items()
return return
new_name = current_buffer.name+"_videos" new_name = current_buffer.name+"_videos"
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="videoBuffer", buffer_title=_("Videos"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], owner_id=current_buffer.kwargs["owner_id"])) pub.sendMessage("create_buffer", buffer_type="videoBuffer", buffer_title=_("Videos"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], owner_id=current_buffer.kwargs["owner_id"]))
def load_community_topics(self, *args, **kwargs): def load_community_topics(self, *args, **kwargs):
""" Load community topics.""" """ Load community topics."""
current_buffer = self.get_current_buffer() 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. # 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"): if current_buffer.group_id not in self.session.db["group_info"] or "counters" not in self.session.db["group_info"][current_buffer.group_id]:
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0] group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters,can_create_topic,can_post")[0]
current_buffer.group_info = group_info self.session.db["group_info"][current_buffer.kwargs["owner_id"]].update(group_info)
if "topics" not in current_buffer.group_info["counters"]: if "topics" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
commonMessages.community_no_items() commonMessages.community_no_items()
return return
new_name = current_buffer.name+"_topics" new_name = current_buffer.name+"_topics"
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="topicBuffer", buffer_title=_("Topics"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_topic", session=self.session, endpoint="getTopics", parent_endpoint="board", count=100, group_id=-1*current_buffer.kwargs["owner_id"], extended=1)) pub.sendMessage("create_buffer", buffer_type="topicBuffer", buffer_title=_("Topics"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_topic", session=self.session, endpoint="getTopics", parent_endpoint="board", count=100, group_id=-1*current_buffer.kwargs["owner_id"], extended=1))
def load_community_documents(self, *args, **kwargs): def load_community_documents(self, *args, **kwargs):
current_buffer = self.get_current_buffer() 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. # 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"): if current_buffer.group_id not in self.session.db["group_info"] or "counters" not in self.session.db["group_info"][current_buffer.group_id]:
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0] group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters,can_create_topics,can_post")[0]
current_buffer.group_info = group_info self.session.db["group_info"][current_buffer.kwargs["owner_id"]].update(group_info)
if "docs" not in current_buffer.group_info["counters"]: if "docs" not in self.session.db["group_info"][current_buffer.group_id]["counters"]:
commonMessages.community_no_items() commonMessages.community_no_items()
return return
new_name = current_buffer.name+"_documents" new_name = current_buffer.name+"_documents"
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="documentCommunityBuffer", buffer_title=_("Documents"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs", owner_id=current_buffer.kwargs["owner_id"])) pub.sendMessage("create_buffer", buffer_type="documentCommunityBuffer", buffer_title=_("Documents"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs", owner_id=current_buffer.kwargs["owner_id"]))
def load_community_buffers(self, *args, **kwargs): def load_community_buffers(self, *args, **kwargs):
""" Load all community buffers regardless of the setting present in optional buffers tab of the preferences dialog.""" """ Load all community buffers regardless of the setting present in optional buffers tab of the preferences dialog."""
@@ -1000,4 +1074,13 @@ class Controller(object):
buff = self.window.search(buffer.name) buff = self.window.search(buffer.name)
self.window.remove_buffer(buff) self.window.remove_buffer(buff)
self.buffers.remove(buffer) self.buffers.remove(buffer)
del self.session.video_albums del self.session.video_albums
def delete_conversation(self, *args, **kwargs):
current_buffer = self.get_current_buffer()
d = commonMessages.delete_conversation()
if d == widgetUtils.YES:
results = self.session.vk.client.messages.deleteConversation(peer_id=current_buffer.kwargs["peer_id"])
buff = self.window.search(current_buffer.name)
self.window.remove_buffer(buff)
self.buffers.remove(current_buffer)

View File

@@ -5,7 +5,7 @@ CRCCheck on
ManifestSupportedOS all ManifestSupportedOS all
XPStyle on XPStyle on
Name "Socializer" Name "Socializer"
OutFile "socializer_0.19_setup.exe" OutFile "socializer_0.23_setup.exe"
InstallDir "$PROGRAMFILES\socializer" InstallDir "$PROGRAMFILES\socializer"
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "InstallLocation" InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "InstallLocation"
RequestExecutionLevel admin RequestExecutionLevel admin
@@ -14,10 +14,10 @@ SetCompressor /solid lzma
SetDatablockOptimize on SetDatablockOptimize on
VIAddVersionKey ProductName "Socializer" VIAddVersionKey ProductName "Socializer"
VIAddVersionKey LegalCopyright "Copyright 2019 Manuel Cortez." VIAddVersionKey LegalCopyright "Copyright 2019 Manuel Cortez."
VIAddVersionKey ProductVersion "0.19" VIAddVersionKey ProductVersion "0.23"
VIAddVersionKey FileVersion "0.19" VIAddVersionKey FileVersion "0.23"
VIProductVersion "0.19.0.0" VIProductVersion "0.23.0.0"
VIFileVersion "0.19.0.0" VIFileVersion "0.23.0.0"
!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
var StartMenuFolder var StartMenuFolder
@@ -50,7 +50,7 @@ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR 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" "Publisher" "Manuel Cortez"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayVersion" "0.19" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayVersion" "0.23"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "URLInfoAbout" "http://socializer.su" 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" "VersionMajor" 0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMinor" 19 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMinor" 19

View File

@@ -1,5 +1,6 @@
from .attach import * from .attach import *
from . audioRecorder import * from . audioRecorder import *
from . blacklist import *
from .configuration import * from .configuration import *
from .postCreation import * from .postCreation import *
from .postDisplayer import * from .postDisplayer import *

View File

@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
import widgetUtils
from wxUI import commonMessages
from pubsub import pub
from . import base
class blacklistInteractor(base.baseInteractor):
def add_items(self, control, items):
if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.")
for i in items:
getattr(self.view, control).insert_item(False, *i)
def install(self, *args, **kwargs):
super(blacklistInteractor, self).install(*args, **kwargs)
widgetUtils.connect_event(self.view.unblock, widgetUtils.BUTTON_PRESSED, self.on_unblock)
pub.subscribe(self.add_items, self.modulename+"_add_items")
def uninstall(self):
super(blacklistInteractor, self).uninstall()
pub.unsubscribe(self.add_items, self.modulename+"_add_items")
def on_unblock(self, *args, **kwargs):
question = commonMessages.unblock_person()
if question == widgetUtils.NO:
return
item = self.view.persons.get_selected()
if self.presenter.unblock_person(item) == 1:
self.view.persons.remove_item(item)

View File

@@ -7,8 +7,8 @@ from . import base
class configurationInteractor(base.baseInteractor): class configurationInteractor(base.baseInteractor):
def create_tab(self, tab): def create_tab(self, tab, arglist=dict()):
getattr(self.view, "create_"+tab)() getattr(self.view, "create_"+tab)(**arglist)
def set_setting(self, tab, setting, value): def set_setting(self, tab, setting, value):
self.view.set_value(tab, setting, value) self.view.set_value(tab, setting, value)
@@ -18,17 +18,22 @@ class configurationInteractor(base.baseInteractor):
if dlg == widgetUtils.YES: if dlg == widgetUtils.YES:
self.presenter.restart_application() self.presenter.restart_application()
def set_language(self, language):
self.view.general.language.SetSelection(language)
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(configurationInteractor, self).install(*args, **kwargs) super(configurationInteractor, self).install(*args, **kwargs)
pub.subscribe(self.create_tab, self.modulename+"_create_tab") pub.subscribe(self.create_tab, self.modulename+"_create_tab")
pub.subscribe(self.set_setting, self.modulename+"_set") pub.subscribe(self.set_setting, self.modulename+"_set")
pub.subscribe(self.restart, self.modulename+"_restart_program") pub.subscribe(self.restart, self.modulename+"_restart_program")
pub.subscribe(self.set_language, self.modulename+"_set_language")
def uninstall(self): def uninstall(self):
super(configurationInteractor, self).uninstall() super(configurationInteractor, self).uninstall()
pub.unsubscribe(self.create_tab, self.modulename+"_create_tab") pub.unsubscribe(self.create_tab, self.modulename+"_create_tab")
pub.unsubscribe(self.set_setting, self.modulename+"_set") pub.unsubscribe(self.set_setting, self.modulename+"_set")
pub.unsubscribe(self.restart, self.modulename+"_restart_program") pub.unsubscribe(self.restart, self.modulename+"_restart_program")
pub.unsubscribe(self.set_language, self.modulename+"_set_language")
def start(self): def start(self):
self.view.realize() self.view.realize()
@@ -37,8 +42,9 @@ class configurationInteractor(base.baseInteractor):
self.on_save_settings() self.on_save_settings()
def on_save_settings(self, *args, **kwargs): def on_save_settings(self, *args, **kwargs):
self.presenter.update_setting(section="buffers", setting="count_for_wall_buffers", value=self.view.get_value("general", "wall_buffer_count")) self.presenter.update_setting(section="buffers", setting="count_for_wall_buffers", value=self.view.get_value("buffers", "wall_buffer_count"))
self.presenter.update_setting(section="buffers", setting="count_for_video_buffers", value=self.view.get_value("general", "video_buffers_count")) self.presenter.update_setting(section="buffers", setting="count_for_video_buffers", value=self.view.get_value("buffers", "video_buffers_count"))
self.presenter.update_setting(section="buffers", setting="count_for_chat_buffers", value=self.view.get_value("buffers", "chat_buffers_count"))
self.presenter.update_setting(section="general", setting="load_images", value=self.view.get_value("general", "load_images")) self.presenter.update_setting(section="general", setting="load_images", value=self.view.get_value("general", "load_images"))
update_channel = self.presenter.get_update_channel_type(self.view.get_value("general", "update_channel")) update_channel = self.presenter.get_update_channel_type(self.view.get_value("general", "update_channel"))
if update_channel != self.presenter.session.settings["general"]["update_channel"]: if update_channel != self.presenter.session.settings["general"]["update_channel"]:
@@ -54,11 +60,13 @@ class configurationInteractor(base.baseInteractor):
self.presenter.update_setting(section="general", setting="update_channel", value=update_channel) self.presenter.update_setting(section="general", setting="update_channel", value=update_channel)
self.presenter.update_setting(section="chat", setting="notify_online", value=self.view.get_value("chat", "notify_online")) self.presenter.update_setting(section="chat", setting="notify_online", value=self.view.get_value("chat", "notify_online"))
self.presenter.update_setting(section="chat", setting="notify_offline", value=self.view.get_value("chat", "notify_offline")) self.presenter.update_setting(section="chat", setting="notify_offline", value=self.view.get_value("chat", "notify_offline"))
self.presenter.update_setting(section="chat", setting="open_unread_conversations", value=self.view.get_value("chat", "open_unread_conversations"))
self.presenter.update_setting(section="chat", setting="automove_to_conversations", value=self.view.get_value("chat", "automove_to_conversations"))
self.presenter.update_setting(section="chat", setting="notifications", value=self.presenter.get_notification_type(self.view.get_value("chat", "notifications"))) self.presenter.update_setting(section="chat", setting="notifications", value=self.presenter.get_notification_type(self.view.get_value("chat", "notifications")))
self.presenter.update_setting(section="load_at_startup", setting="audio_albums", value=self.view.get_value("startup", "audio_albums")) self.presenter.update_setting(section="load_at_startup", setting="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="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.update_setting(section="load_at_startup", setting="communities", value=self.view.get_value("startup", "communities"))
self.presenter.update_app_setting(section="app-settings", setting="language", value=self.presenter.codes[self.view.general.language.GetSelection()])
self.presenter.update_app_setting(section="sound", setting="input_device", value=self.view.get_value("sound", "input"))
self.presenter.update_app_setting(section="sound", setting="output_device", value=self.view.get_value("sound", "output"))
self.presenter.update_app_setting(section="app-settings", setting="use_proxy", value=self.view.get_value("general", "use_proxy"))
self.presenter.save_app_settings_file()
self.presenter.save_settings_file() self.presenter.save_settings_file()
self.presenter.update_proxy(self.view.get_value("general", "use_proxy"))

View File

@@ -29,6 +29,11 @@ class displayPostInteractor(base.baseInteractor):
for i in items: for i in items:
getattr(self.view, control).insert_item(False, *i) getattr(self.view, control).insert_item(False, *i)
def add_item(self, control, item, reversed=False):
if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.")
getattr(self.view, control).insert_item(reversed, *item)
def enable_attachments(self): def enable_attachments(self):
self.view.attachments.list.Enable(True) self.view.attachments.list.Enable(True)
@@ -45,32 +50,41 @@ class displayPostInteractor(base.baseInteractor):
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(displayPostInteractor, self).install(*args, **kwargs) super(displayPostInteractor, self).install(*args, **kwargs)
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_show_comment) if hasattr(self.view, "comments"):
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_show_comment)
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_comment_changed)
self.view.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_open_attachment) self.view.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_open_attachment)
widgetUtils.connect_event(self.view.like, widgetUtils.BUTTON_PRESSED, self.on_like) widgetUtils.connect_event(self.view.like, widgetUtils.BUTTON_PRESSED, self.on_like)
widgetUtils.connect_event(self.view.comment, widgetUtils.BUTTON_PRESSED, self.on_add_comment) widgetUtils.connect_event(self.view.comment, widgetUtils.BUTTON_PRESSED, self.on_add_comment)
widgetUtils.connect_event(self.view.tools, widgetUtils.BUTTON_PRESSED, self.on_show_tools_menu) widgetUtils.connect_event(self.view.tools, widgetUtils.BUTTON_PRESSED, self.on_show_tools_menu)
if hasattr(self.view, "likes"):
widgetUtils.connect_event(self.view.likes, widgetUtils.BUTTON_PRESSED, self.on_show_likes_menu)
if hasattr(self.view, "shares"):
widgetUtils.connect_event(self.view.shares, widgetUtils.BUTTON_PRESSED, self.on_show_shares_menu)
if hasattr(self.view, "repost"): if hasattr(self.view, "repost"):
widgetUtils.connect_event(self.view.repost, widgetUtils.BUTTON_PRESSED, self.on_repost) widgetUtils.connect_event(self.view.repost, widgetUtils.BUTTON_PRESSED, self.on_repost)
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_focus) self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_focus)
if hasattr(self.view, "reply"): if hasattr(self.view, "reply"):
widgetUtils.connect_event(self.view.reply, widgetUtils.BUTTON_PRESSED, self.on_reply) widgetUtils.connect_event(self.view.reply, widgetUtils.BUTTON_PRESSED, self.on_reply)
if hasattr(self.view, "load_more_comments"):
widgetUtils.connect_event(self.view.load_more_comments, widgetUtils.BUTTON_PRESSED, self.on_load_more_comments)
# self.view.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_show_menu, self.view.comments.list) # self.view.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_show_menu, self.view.comments.list)
# self.view.Bind(wx.EVT_LIST_KEY_DOWN, self.on_show_menu_by_key, self.view.comments.list) # self.view.Bind(wx.EVT_LIST_KEY_DOWN, self.on_show_menu_by_key, self.view.comments.list)
pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.load_image, self.modulename+"_load_image") pub.subscribe(self.load_image, self.modulename+"_load_image")
pub.subscribe(self.add_items, self.modulename+"_add_items") pub.subscribe(self.add_items, self.modulename+"_add_items")
pub.subscribe(self.add_item, self.modulename+"_add_item")
pub.subscribe(self.enable_attachments, self.modulename+"_enable_attachments") pub.subscribe(self.enable_attachments, self.modulename+"_enable_attachments")
pub.subscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls") pub.subscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls")
pub.subscribe(self.post_deleted, self.modulename+"_post_deleted") pub.subscribe(self.post_deleted, self.modulename+"_post_deleted")
pub.subscribe(self.clean_list, self.modulename+"_clean_list") 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): def uninstall(self):
super(displayPostInteractor, self).uninstall() super(displayPostInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.load_image, self.modulename+"_load_image") pub.unsubscribe(self.load_image, self.modulename+"_load_image")
pub.unsubscribe(self.add_items, self.modulename+"_add_items") pub.unsubscribe(self.add_items, self.modulename+"_add_items")
pub.unsubscribe(self.add_item, self.modulename+"_add_item")
pub.unsubscribe(self.enable_attachments, self.modulename+"_enable_attachments") pub.unsubscribe(self.enable_attachments, self.modulename+"_enable_attachments")
pub.unsubscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls") pub.unsubscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls")
pub.unsubscribe(self.post_deleted, self.modulename+"_post_deleted") pub.unsubscribe(self.post_deleted, self.modulename+"_post_deleted")
@@ -90,7 +104,7 @@ class displayPostInteractor(base.baseInteractor):
self.presenter.post_repost() self.presenter.post_repost()
def on_reply(self, *args, **kwargs): def on_reply(self, *args, **kwargs):
if hasattr(self.view, "repost") or not hasattr(self, "post_view"): if hasattr(self.view, "comments") and (hasattr(self.view, "repost") or not hasattr(self, "post_view")):
comment = self.view.comments.get_selected() comment = self.view.comments.get_selected()
self.presenter.reply(comment) self.presenter.reply(comment)
else: else:
@@ -99,6 +113,10 @@ class displayPostInteractor(base.baseInteractor):
def on_add_comment(self, *args, **kwargs): def on_add_comment(self, *args, **kwargs):
self.presenter.add_comment() self.presenter.add_comment()
def on_load_more_comments(self, *args, **kwargs):
if hasattr(self.presenter, "load_more_comments"):
self.presenter.load_more_comments()
def on_show_tools_menu(self, *args, **kwargs): def on_show_tools_menu(self, *args, **kwargs):
menu = menus.toolsMenu() menu = menus.toolsMenu()
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_open_url, menuitem=menu.url) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_open_url, menuitem=menu.url)
@@ -134,6 +152,12 @@ class displayPostInteractor(base.baseInteractor):
comment = self.view.comments.get_selected() comment = self.view.comments.get_selected()
self.presenter.change_comment(comment) self.presenter.change_comment(comment)
def on_show_likes_menu(self, *args, **kwargs):
self.presenter.show_likes()
def on_show_shares_menu(self, *args, **kwargs):
self.presenter.show_shares()
class displayAudioInteractor(base.baseInteractor): class displayAudioInteractor(base.baseInteractor):
def set(self, control, value): def set(self, control, value):
@@ -148,6 +172,13 @@ class displayAudioInteractor(base.baseInteractor):
getattr(self.view, control).Append(i) getattr(self.view, control).Append(i)
getattr(self.view, control).SetSelection(0) getattr(self.view, control).SetSelection(0)
def change_label(self, stopped):
if stopped == False:
self.view.play.SetLabel(_("P&ause"))
else:
self.view.play.SetLabel(_("P&lay"))
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(displayAudioInteractor, self).install(*args, **kwargs) super(displayAudioInteractor, self).install(*args, **kwargs)
widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_CHANGED, self.on_change) widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_CHANGED, self.on_change)
@@ -157,11 +188,13 @@ class displayAudioInteractor(base.baseInteractor):
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_from_library) widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_from_library)
pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.add_items, self.modulename+"_add_items") pub.subscribe(self.add_items, self.modulename+"_add_items")
pub.subscribe(self.change_label, "playback-changed")
def uninstall(self): def uninstall(self):
super(displayAudioInteractor, self).uninstall() super(displayAudioInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.add_items, self.modulename+"_add_items") pub.unsubscribe(self.add_items, self.modulename+"_add_items")
pub.unsubscribe(self.change_label, "playback-changed")
def on_change(self, *args, **kwargs): def on_change(self, *args, **kwargs):
post = self.view.get_audio() post = self.view.get_audio()
@@ -224,11 +257,30 @@ class displayFriendshipInteractor(base.baseInteractor):
for i in items: for i in items:
getattr(self.view, control).insert_item(False, *[i]) getattr(self.view, control).insert_item(False, *[i])
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(displayFriendshipInteractor, self).install(*args, **kwargs) super(displayFriendshipInteractor, self).install(*args, **kwargs)
pub.subscribe(self.add_items, self.modulename+"_add_items") pub.subscribe(self.add_items, self.modulename+"_add_items")
self.view.friends.list.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu)
def uninstall(self): def uninstall(self):
super(displayFriendshipInteractor, self).uninstall() super(displayFriendshipInteractor, self).uninstall()
pub.unsubscribe(self.add_items, self.modulename+"_add_items") pub.unsubscribe(self.add_items, self.modulename+"_add_items")
def on_context_menu(self, *args, **kwargs):
item = self.view.friends.get_selected()
if item < 0:
return
menu = menus.peopleMenu(False, False, True)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.on_view_profile, menuitem=menu.view_profile)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.on_open_in_browser, menuitem=menu.open_in_browser)
# Generally message sending is blocked.
menu.message.Enable(False)
self.view.PopupMenu(menu, self.view.friends.list.GetPosition())
def on_view_profile(self, *args, **kwargs):
item = self.view.friends.get_selected()
self.presenter.view_profile(item)
def on_open_in_browser(self, *args, **kwargs):
item = self.view.friends.get_selected()
self.presenter.open_in_browser(item)

View File

@@ -82,7 +82,7 @@ def getAvailableLanguages():
""" """
#Make a list of all the locales found in NVDA's locale dir #Make a list of all the locales found in NVDA's locale dir
l=[x for x in os.listdir(paths.locale_path()) if not x.startswith('.')] l=[x for x in os.listdir(paths.locale_path()) if not x.startswith('.')]
l=[x for x in l if os.path.isfile(paths.locale_path('%s/LC_MESSAGES/%s.po' % (x, application.short_name)))] l=[x for x in l if os.path.isfile(os.path.join(paths.locale_path(), '%s/LC_MESSAGES/%s.po' % (x, application.short_name)))]
#Make sure that en (english) is in the list as it may not have any locale files, but is default #Make sure that en (english) is in the list as it may not have any locale files, but is default
if 'en' not in l: if 'en' not in l:
l.append('en') l.append('en')

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -14,6 +14,8 @@ formatter = logging.Formatter(MESSAGE_FORMAT, datefmt=DATE_FORMAT)
requests_log = logging.getLogger("requests") requests_log = logging.getLogger("requests")
requests_log.setLevel(logging.WARNING) requests_log.setLevel(logging.WARNING)
urllib3 = logging.getLogger("urllib3")
urllib3.setLevel(logging.WARNING)
logger = logging.getLogger() logger = logging.getLogger()
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)

View File

@@ -52,6 +52,7 @@ def setup():
log.debug("Created Application mainloop object") log.debug("Created Application mainloop object")
sm = sessionManager.sessionManagerController() sm = sessionManager.sessionManagerController()
sm.show()
del sm del sm
r = mainController.Controller() r = mainController.Controller()
call_threaded(r.login) call_threaded(r.login)

View File

@@ -7,6 +7,7 @@ a = Analysis(['main.py'],
binaries=[("sounds", "sounds"), binaries=[("sounds", "sounds"),
("documentation", "documentation"), ("documentation", "documentation"),
("locales", "locales"), ("locales", "locales"),
("..\\windows-dependencies\\dictionaries", "enchant\\share\\enchant\\myspell"),
("..\\windows-dependencies\\x86\\oggenc2.exe", "."), ("..\\windows-dependencies\\x86\\oggenc2.exe", "."),
("..\\windows-dependencies\\x86\\bootstrap.exe", "."), ("..\\windows-dependencies\\x86\\bootstrap.exe", "."),
("app-configuration.defaults", "."), ("app-configuration.defaults", "."),

View File

@@ -13,7 +13,8 @@
""" """
from .attach import * from .attach import *
from .audioRecorder import * from .audioRecorder import *
from .postCreation import * from .blacklist import *
from .postDisplayer import * from .createPosts import *
from .displayPosts import *
from .configuration import * from .configuration import *
from .profiles import * from .profiles import *

View File

@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
""" A "presenter" in the socializer's terminology is a module that handles business logic in the application's workflow.
All presenter classes should derive from base.basePresenter and will be completely abstracted from views (the GUI elements). It means presenters and views don't know anything about the each other.
Both Presenters and views can communicate through the interactors. Interactors are responsible to receive user input and send requests to the presenters, aswell as receiving presenter requests and render those in the view.
So, in a tipical user interaction made in socializer, the following could happen when someone decides to do something:
1. A new presenter is created, with two mandatory arguments: The corresponding view and interactor.
2. The presenter will call to the install() method in the interactor, to connect all GUI events to their corresponding methods. All of these functions will be present in the interactor only.
3. After install(), the presenter will run the View, which will display the graphical user interface that users can see and interact with. The view is the only layer directly accessible from the user world and does not handle any kind of logic.
4. If the user presses a button or generates an event connected to a function in the interactor side, the function will be executed in the interactor. The interactor is aware of the View, and holds a reference to the presenter. The interactor should call other GUI elements if necessary and handle some logic (related to GUI, like yes/no dialogs). The interactor can call the presenter to retrieve some information, though the interactor cannot perform any business logic (like altering the cache database, retrieving usernames and so on).
5. If the interactor calls something in the presenter, it will be executed. The presenter knows everything about VK and the session object, so it will fetch data, save it in the cache, call other methods from VK and what not. If the presenter wants to change something in the GUI elements (for example, hiding a control or displaying something else), it will send a pubsub event that the interactor will receive and act on accordingly.
By using this design pattern it allows more decoupled code, easier testing (as we don't need to instantiate the views) and easy to switch (or add) a new graphical user interface by replacing interactors and views.
"""
from .attach import *
from .audioRecorder import *
from .postCreation import *
from .postDisplayer import *
from .configuration import *
from .profiles import *

View File

@@ -8,6 +8,7 @@ import logging
import interactors import interactors
import views import views
from mutagen.id3 import ID3 from mutagen.id3 import ID3
from mutagen.id3._util import ID3NoHeaderError
from sessionmanager.utils import seconds_to_string from sessionmanager.utils import seconds_to_string
from . import audioRecorder, base from . import audioRecorder, base
@@ -24,7 +25,7 @@ class attachPresenter(base.basePresenter):
def __init__(self, session, view, interactor, voice_messages=False): def __init__(self, session, view, interactor, voice_messages=False):
""" Constructor. """ Constructor.
@ session sessionmanager.session object: an object capable of calling all VK methods and accessing the session database. @ session sessionmanager.session object: an object capable of calling all VK methods and accessing the session database.
@voice_messages bool: If True, will add a button for sending voice messages. Functionality for this button has not been added yet. @voice_messages bool: If True, will add a button for sending voice messages.
""" """
super(attachPresenter, self).__init__(view=view, interactor=interactor, modulename="attach") super(attachPresenter, self).__init__(view=view, interactor=interactor, modulename="attach")
self.session = session self.session = session
@@ -33,7 +34,7 @@ class attachPresenter(base.basePresenter):
self.run() self.run()
def upload_image(self, image, description): def upload_image(self, image, description):
""" allows uploading an image from the computer. """ allows uploading an image from the computer. Description will be used when posting to VK.
""" """
imageInfo = {"type": "photo", "file": image, "description": description, "from": "local"} imageInfo = {"type": "photo", "file": image, "description": description, "from": "local"}
self.attachments.append(imageInfo) self.attachments.append(imageInfo)
@@ -47,15 +48,19 @@ class attachPresenter(base.basePresenter):
if audio != None: if audio != None:
# Define data structure for this attachment, as will be required by VK API later. # Define data structure for this attachment, as will be required by VK API later.
# Let's extract the ID3 tags to show them in the list and send them to VK, too. # Let's extract the ID3 tags to show them in the list and send them to VK, too.
audio_tags = ID3(audio) try:
if "TIT2" in audio_tags: audio_tags = ID3(audio)
title = audio_tags["TIT2"].text[0] if "TIT2" in audio_tags:
else: title = audio_tags["TIT2"].text[0]
title = _("Untitled") else:
if "TPE1" in audio_tags: title = _("Untitled")
artist = audio_tags["TPE1"].text[0] if "TPE1" in audio_tags:
else: artist = audio_tags["TPE1"].text[0]
else:
artist = _("Unknown artist")
except ID3NoHeaderError: # File doesn't include ID3 tags so let's assume unknown artist.
artist = _("Unknown artist") artist = _("Unknown artist")
title = os.path.basename(audio).replace(".mp3", "")
audioInfo = {"type": "audio", "file": audio, "from": "local", "title": title, "artist": artist} audioInfo = {"type": "audio", "file": audio, "from": "local", "title": title, "artist": artist}
self.attachments.append(audioInfo) self.attachments.append(audioInfo)
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file. # Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.

View File

@@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
import threading
from pubsub import pub
from . import base
class blacklistPresenter(base.basePresenter):
def __init__(self, session, view, interactor):
self.session = session
super(blacklistPresenter, self).__init__(view=view, interactor=interactor, modulename="blacklist")
self.worker = threading.Thread(target=self.load_information)
self.worker.finished = threading.Event()
self.worker.start()
self.run()
def load_information(self):
banned_users = self.session.vk.client.account.getBanned(count=200)
self.users = banned_users["profiles"]
items = []
for i in self.users:
str_user = "{first_name} {last_name}".format(first_name=i["first_name"], last_name=i["last_name"])
items.append([str_user])
self.send_message("add_items", control="persons", items=items)
def unblock_person(self, item):
result = self.session.vk.client.account.unban(owner_id=self.users[item]["id"])
if result == 1:
msg = _("You've unblocked {user1_nom} from your friends.").format(**self.session.get_user(self.users[item]["id"]),)
pub.sendMessage("notify", message=msg)
return result

View File

@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals from __future__ import unicode_literals
import sound_lib.input, sound_lib.output
import config import config
import languageHandler
from mysc import restart from mysc import restart
from . import base from . import base
@@ -9,6 +11,8 @@ class configurationPresenter(base.basePresenter):
def __init__(self, session, view, interactor): def __init__(self, session, view, interactor):
self.session = session self.session = session
super(configurationPresenter, self).__init__(view=view, interactor=interactor, modulename="configuration") super(configurationPresenter, self).__init__(view=view, interactor=interactor, modulename="configuration")
# Control requirement for a restart of the application.
self.needs_restart = False
self.create_config() self.create_config()
self.run() self.run()
@@ -41,22 +45,32 @@ class configurationPresenter(base.basePresenter):
return "alpha" return "alpha"
def create_config(self): def create_config(self):
self.send_message("create_tab", tab="general") self.langs = languageHandler.getAvailableLanguages()
self.send_message("set", tab="general", setting="wall_buffer_count", value=self.session.settings["buffers"]["count_for_wall_buffers"]) langs = [i[1] for i in self.langs]
self.send_message("set", tab="general", setting="video_buffers_count", value=self.session.settings["buffers"]["count_for_video_buffers"]) self.codes = [i[0] for i in self.langs]
id = self.codes.index(config.app["app-settings"]["language"])
self.send_message("create_tab", tab="general", arglist=dict(languages=langs))
self.send_message("set_language", language=id)
self.send_message("set", tab="general", setting="load_images", value=self.session.settings["general"]["load_images"]) 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="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("set", tab="general", setting="update_channel", value=self.get_update_channel_label(self.session.settings["general"]["update_channel"]))
self.send_message("create_tab", tab="buffers")
self.send_message("set", tab="buffers", setting="wall_buffer_count", value=self.session.settings["buffers"]["count_for_wall_buffers"])
self.send_message("set", tab="buffers", setting="video_buffers_count", value=self.session.settings["buffers"]["count_for_video_buffers"])
self.send_message("set", tab="buffers", setting="chat_buffers_count", value=self.session.settings["buffers"]["count_for_chat_buffers"])
self.send_message("create_tab", tab="chat") self.send_message("create_tab", tab="chat")
self.send_message("set", tab="chat", setting="notify_online", value=self.session.settings["chat"]["notify_online"]) self.send_message("set", tab="chat", setting="notify_online", value=self.session.settings["chat"]["notify_online"])
self.send_message("set", tab="chat", setting="notify_offline", value=self.session.settings["chat"]["notify_offline"]) self.send_message("set", tab="chat", setting="notify_offline", value=self.session.settings["chat"]["notify_offline"])
self.send_message("set", tab="chat", setting="open_unread_conversations", value=self.session.settings["chat"]["open_unread_conversations"])
self.send_message("set", tab="chat", setting="automove_to_conversations", value=self.session.settings["chat"]["automove_to_conversations"])
self.send_message("set", tab="chat", setting="notifications", value=self.get_notification_label(self.session.settings["chat"]["notifications"])) self.send_message("set", tab="chat", setting="notifications", value=self.get_notification_label(self.session.settings["chat"]["notifications"]))
self.send_message("create_tab", tab="startup_options") self.send_message("create_tab", tab="startup_options")
self.send_message("set", tab="startup", setting="audio_albums", value=self.session.settings["load_at_startup"]["audio_albums"]) self.send_message("set", tab="startup", setting="audio_albums", value=self.session.settings["load_at_startup"]["audio_albums"])
self.send_message("set", tab="startup", setting="video_albums", value=self.session.settings["load_at_startup"]["video_albums"]) self.send_message("set", tab="startup", setting="video_albums", value=self.session.settings["load_at_startup"]["video_albums"])
self.send_message("set", tab="startup", setting="communities", value=self.session.settings["load_at_startup"]["communities"]) self.send_message("set", tab="startup", setting="communities", value=self.session.settings["load_at_startup"]["communities"])
self.input_devices = sound_lib.input.Input.get_device_names()
self.output_devices = sound_lib.output.Output.get_device_names()
self.send_message("create_tab", tab="sound", arglist=dict(input_devices=self.input_devices, output_devices=self.output_devices, soundpacks=[]))
self.send_message("set", tab="sound", setting="input", value=config.app["sound"]["input_device"])
self.send_message("set", tab="sound", setting="output", value=config.app["sound"]["output_device"])
def update_setting(self, section, setting, value): def update_setting(self, section, setting, value):
if section not in self.session.settings: if section not in self.session.settings:
@@ -68,10 +82,21 @@ class configurationPresenter(base.basePresenter):
def save_settings_file(self): def save_settings_file(self):
self.session.settings.write() self.session.settings.write()
def update_proxy(self, proxy_value): def update_app_setting(self, section, setting, value):
if proxy_value != config.app["app-settings"]["use_proxy"]: if section not in config.app:
config.app["app-settings"]["use_proxy"] = proxy_value raise AttributeError("The configuration section is not present in the spec file.")
config.app.write() if setting not in config.app[section]:
raise AttributeError("The setting you specified is not present in the config file.")
# check if certain settings have been changed so we'd restart the client.
# List of app settings that require a restart after being changed.
settings_needing_restart = ["language", "use_proxy", "input_device", "output_device"]
if value != config.app[section][setting] and setting in settings_needing_restart:
self.needs_restart = True
config.app[section][setting] = value
def save_app_settings_file(self):
config.app.write()
if self.needs_restart:
self.send_message("restart_program") self.send_message("restart_program")
def restart_application(self): def restart_application(self):

View File

@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from .basePost import *

View File

@@ -7,8 +7,8 @@ import output
from logging import getLogger from logging import getLogger
from pubsub import pub from pubsub import pub
from extra import SpellChecker, translator from extra import SpellChecker, translator
from .import attach from presenters import attach
from .import base from presenters import base
log = getLogger("controller.message") log = getLogger("controller.message")

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from .basePost import *
from .audio import *
from .comment import *
from .peopleList import *
from .poll import *
from .topic import *
from .topicComment import *

View File

@@ -0,0 +1,100 @@
# -*- coding: utf-8 -*-
import logging
from sessionmanager import utils
from pubsub import pub
from mysc.thread_utils import call_threaded
from presenters import base, player
log = logging.getLogger(__file__)
class displayAudioPresenter(base.basePresenter):
def __init__(self, session, postObject, view, interactor):
super(displayAudioPresenter, self).__init__(view=view, interactor=interactor, modulename="display_audio")
self.added_audios = {}
self.session = session
self.post = postObject
self.load_audios()
self.fill_information(0)
self.run()
def add_to_library(self, audio_index):
post = self.post[audio_index]
args = {}
args["audio_id"] = post["id"]
if "album_id" in post:
args["album_id"] = post["album_id"]
args["owner_id"] = post["owner_id"]
audio = self.session.vk.client.audio.add(**args)
if audio != None and int(audio) > 21:
self.added_audios[post["id"]] = audio
self.send_message("disable_control", control="add")
self.send_message("enable_control", control="remove")
def remove_from_library(self, audio_index):
post = self.post[audio_index]
args = {}
if post["id"] in self.added_audios:
args["audio_id"] = self.added_audios[post["id"]]
args["owner_id"] = self.session.user_id
else:
args["audio_id"] = post["id"]
args["owner_id"] = post["owner_id"]
result = self.session.vk.client.audio.delete(**args)
if int(result) == 1:
self.send_message("enable_control", control="add")
self.send_message("disable_control", control="remove")
if post["id"] in self.added_audios:
self.added_audios.pop(post["id"])
def fill_information(self, index):
post = self.post[index]
if "artist" in post:
self.send_message("set", control="artist", value=post["artist"])
if "title" in post:
self.send_message("set", control="title", value=post["title"])
if "duration" in post:
self.send_message("set", control="duration", value=utils.seconds_to_string(post["duration"]))
self.send_message("set_title", value="{0} - {1}".format(post["title"], post["artist"]))
call_threaded(self.get_lyrics, index)
if post["owner_id"] == self.session.user_id or (post["id"] in self.added_audios) == True:
self.send_message("enable_control", control="remove")
self.send_message("disable_control", control="add")
else:
self.send_message("enable_control", control="add")
self.send_message("disable_control", control="remove")
def get_lyrics(self, audio_index):
post = self.post[audio_index]
if "lyrics_id" in post:
l = self.session.vk.client.audio.getLyrics(lyrics_id=int(post["lyrics_id"]))
self.send_message("set", control="lyric", value=l["text"])
else:
self.send_message("disable_control", control="lyric")
def get_suggested_filename(self, audio_index):
post = self.post[audio_index]
return "{0} - {1}.mp3".format(post["title"], post["artist"])
def download(self, audio_index, path):
post = self.post[audio_index]
if path != None:
pub.sendMessage("download-file", url=post["url"], filename=path)
def play(self, audio_index):
post = self.post[audio_index]
if player.player.check_is_playing() == True:
return pub.sendMessage("stop")
pub.sendMessage("play", object=post)
def load_audios(self):
audios = []
for i in self.post:
s = "{0} - {1}. {2}".format(i["title"], i["artist"], utils.seconds_to_string(i["duration"]))
audios.append(s)
self.send_message("add_items", control="list", items=audios)
if len(self.post) == 1:
self.send_message("disable_control", control="list")
self.send_message("focus_control", control="title")
def handle_changes(self, audio_index):
self.fill_information(audio_index)

View File

@@ -0,0 +1,377 @@
# -*- coding: utf-8 -*-
import threading
import arrow
import requests
import languageHandler
import views
import interactors
import output
import webbrowser
import logging
from vk_api import upload
from sessionmanager import session, renderers, utils # We'll use some functions from there
from pubsub import pub
from extra import SpellChecker, translator
from mysc.thread_utils import call_threaded
from presenters import base
from presenters.createPosts.basePost import createPostPresenter
from . import audio, poll
log = logging.getLogger(__file__)
def get_message(status):
message = ""
if "text" in status:
message = utils.clean_text(status["text"])
return message
class displayPostPresenter(base.basePresenter):
""" Base class for post representation."""
def __init__(self, session, postObject, view, interactor):
super(displayPostPresenter, self).__init__(view=view, interactor=interactor, modulename="display_post")
self.type = "post"
self.session = session
self.post = postObject
# Posts from newsfeed contains this source_id instead from_id in walls. Also it uses post_id and walls use just id.
if "source_id" in self.post:
self.user_identifier = "source_id"
self.post_identifier = "post_id"
else:
# In wall's posts, if someone has posted in user's wall, owner_id should be used instead from_id
# This will help for retrieving comments, do likes, etc.
if "owner_id" not in self.post:
self.user_identifier = "from_id"
else:
self.user_identifier = "owner_id"
self.post_identifier = "id"
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()
# connect here the pubsub event for successful posting of comments.
pub.subscribe(self.posted, "posted")
self.run()
pub.unsubscribe(self.posted, "posted")
def posted(self, from_buffer=None):
self.clear_comments_list()
def get_comments(self):
""" Get comments and insert them in a list."""
user = self.post[self.user_identifier]
id = self.post[self.post_identifier]
comments_data = self.session.vk.client.wall.getComments(owner_id=user, post_id=id, need_likes=1, count=100, extended=1, preview_length=0, thread_items_count=10)
self.comments = dict(items=[], profiles=comments_data["profiles"])
for i in comments_data["items"]:
self.comments["items"].append(i)
if i.get("thread") != None and i["thread"].get("count") > 0:
for newI in i["thread"]["items"]:
self.comments["items"].append(newI)
comments_ = []
# Save profiles in session local storage for a future usage.
# Although community objects are returned here, we should not add those because their names are changed.
# 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_ = self.session.get_user(i["from_id"])["user1_nom"]
if "reply_to_user" in i:
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 = utils.clean_text(i["text"])
if len(fixed_text) > 140:
text = fixed_text[:141]
else:
text = fixed_text
original_date = arrow.get(i["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
likes = str(i["likes"]["count"])
comments_.append((from_, text, created_at, likes))
self.send_message("add_items", control="comments", items=comments_)
def get_post_information(self):
from_ = self.session.get_user(self.post[self.user_identifier])
if "copy_history" in self.post:
title = _("repost from {user1_nom}").format(**from_)
else:
if ("from_id" in self.post and "owner_id" in self.post) and (self.post["from_id"] != self.post["owner_id"]):
# Translators: {0} will be replaced with the user who is posting, and {1} with the wall owner.
user2 = self.session.get_user(self.post["owner_id"], "user2")
user2.update(from_)
title = _("Post from {user1_nom} in the {user2_nom}'s wall").format(**user2)
else:
title = _("Post from {user1_nom}").format(**from_)
self.send_message("set_title", value=title)
message = ""
# 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"]))
else:
self.send_message("disable_control", control="views")
if "owner_id" not in self.post:
self.user_identifier = "from_id"
else:
self.user_identifier = "owner_id"
self.post_identifier = "id"
message = get_message(self.post)
if "copy_history" in self.post:
nm = "\n"
for i in self.post["copy_history"]:
u = self.session.get_user(i["from_id"])
u.update(message=get_message(i))
nm += "{user1_nom}: {message}\n\n".format(**u)
self.get_attachments(i, get_message(i))
message += nm
self.send_message("set", control="post_view", value=message)
self.get_attachments(self.post, message)
self.check_image_load()
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.
if i["type"] == "photos_list":
continue
if i["type"] == "photo":
if self.load_images == False: self.load_images = True
self.images.append(i)
attachments.append(renderers.add_attachment(i))
self.attachments.append(i)
# Links in text are not treated like normal attachments, so we'll have to catch and add those to the list without title
# We can't get a title because title is provided by the VK API and it will not work for links as simple text.
urls = utils.find_urls_in_text(text)
if len(urls) > 0:
links = []
for i in urls:
links.append({"link": {"title": _("Untitled link"), "url": i}, "type": "link"})
for i in links:
attachments.append(renderers.add_attachment(i))
self.attachments.append(i)
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"]:
self.send_message("enable_control", control="image")
nav = False # Disable navigation controls in photos
if len(self.images) > 1:
nav = True
self.send_message("enable_photo_controls", navigation=nav)
self.set_image(0)
def set_next_image(self, *args, **kwargs):
if self.imageIndex < -1 or self.imageIndex == len(self.images)-1:
self.imageIndex = -1
if len(self.images) <= self.imageIndex+1:
self.imageIndex = 0
else:
self.imageIndex = self.imageIndex + 1
self.set_image(self.imageIndex)
def set_previous_image(self, *args, **kwargs):
if self.imageIndex <= 0:
self.imageIndex = len(self.images)
self.imageIndex = self.imageIndex - 1
self.set_image(self.imageIndex)
def set_image(self, index):
if len(self.images) < index-1:
return
# Get's photo URL.
url = self.get_photo_url(self.images[index]["photo"], "x")
if url != "":
img = requests.get(url)
self.send_message("load_image", image=img)
# Translators: {0} is the number of the current photo and {1} is the total number of photos.
output.speak(_("Loaded photo {0} of {1}").format(index+1, len(self.images)))
return
def get_photo_url(self, photo, size="x"):
url = ""
for i in photo["sizes"]:
if i["type"] == size:
url = i["url"]
break
return url
def load_all_components(self):
self.get_likes()
self.get_reposts()
self.get_comments()
if self.post["comments"]["can_post"] == 0:
self.send_message("disable_control", control="comment")
if self.post["likes"]["can_like"] == 0 and self.post["likes"]["user_likes"] == 0:
self.send_message("disable_control", "like")
elif self.post["likes"]["user_likes"] == 1:
self.send_message("set_label", control="like", label=_("&Dislike"))
if self.post["likes"]["can_publish"] == 0:
self.send_message("disable_control", control="repost")
def post_like(self):
if ("owner_id" in self.post) == False:
user = int(self.post[self.user_identifier])
else:
user = int(self.post["owner_id"])
id = int(self.post[self.post_identifier])
if "type" in self.post:
type_ = self.post["type"]
else:
type_ = self.type
if self.post["likes"]["user_likes"] == 1:
l = self.session.vk.client.likes.delete(owner_id=user, item_id=id, type=type_)
output.speak(_("You don't like this"))
self.post["likes"]["count"] = l["likes"]
self.post["likes"]["user_likes"] = 2
self.get_likes()
self.send_message("set_label", control="like", label=_("&Like"))
else:
l = self.session.vk.client.likes.add(owner_id=user, item_id=id, type=type_)
output.speak(_("You liked this"))
self.send_message("set_label", control="like", label=_("&Dislike"))
self.post["likes"]["count"] = l["likes"]
self.post["likes"]["user_likes"] = 1
self.get_likes()
def post_repost(self):
object_id = "wall{0}_{1}".format(self.post[self.user_identifier], self.post[self.post_identifier])
p = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Repost"), message=_("Add your comment here"), text="", mode="comment"))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments = dict(object=object_id, message=p.text)
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="repost", attachments_list=attachments, post_arguments=post_arguments)
def get_likes(self):
self.send_message("set_label", control="likes", label=_("{0} people like this").format(self.post["likes"]["count"],))
def get_reposts(self):
self.send_message("set_label", control="shares", label=_("Shared {0} times").format(self.post["reposts"]["count"],))
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"):
owner_id = self.post[self.user_identifier]
post_id = self.post[self.post_identifier]
post_arguments=dict(message=comment.text, owner_id=owner_id, post_id=post_id)
attachments = []
if hasattr(comment, "attachments"):
attachments = comment.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
def reply(self, comment):
c = self.comments["items"][comment]
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Reply to {user1_nom}").format(**self.session.get_user(c["from_id"])), message="", text="", mode="comment"))
if hasattr(comment, "text") or hasattr(comment, "privacy"):
post_id = self.post[self.post_identifier]
post_arguments=dict(message=comment.text, owner_id=c["owner_id"], reply_to_comment=c["id"], post_id=c["post_id"], reply_to_user=c["owner_id"])
attachments = []
if hasattr(comment, "attachments"):
attachments = comment.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
def show_comment(self, comment_index):
from . import comment
c = self.comments["items"][comment_index]
c["post_id"] = self.post[self.post_identifier]
a = comment.displayCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
def translate(self, text, language):
msg = translator.translator.translate(text, language)
self.send_message("set", control="post_view", value=msg)
self.send_message("focus_control", control="post_view")
output.speak(_("Translated"))
def spellcheck(self, text):
checker = SpellChecker.spellchecker.spellChecker(text, "")
if hasattr(checker, "fixed_text"):
self.send_message("set", control="post_view", value=checker.fixed_text)
self.send_message("focus_control", control="post_view")
checker.clean()
def open_attachment(self, index):
attachment = self.attachments[index]
if attachment["type"] == "audio":
a = audio.displayAudioPresenter(session=self.session, postObject=[attachment["audio"]], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
elif attachment["type"] == "link":
output.speak(_("Opening URL..."), True)
webbrowser.open_new_tab(attachment["link"]["url"])
elif attachment["type"] == "doc":
output.speak(_("Opening document in web browser..."))
webbrowser.open(attachment["doc"]["url"])
elif attachment["type"] == "video":
# it seems VK doesn't like to attach video links as normal URLS, so we'll have to
# get the full video object and use its "player" key which will open a webbrowser in their site with a player for the video.
# see https://vk.com/dev/attachments_w and and https://vk.com/dev/video.get
# However, the flash player isn't good for visually impaired people (when you press play you won't be able to close the window with alt+f4), so it could be good to use the HTML5 player.
# For firefox, see https://addons.mozilla.org/ru/firefox/addon/force-html5-video-player-at-vk/
# May be I could use a dialogue here for inviting people to use this addon in firefox. It seems it isn't possible to use this html5 player from the player URL.
object_id = "{0}_{1}".format(attachment["video"]["owner_id"], attachment["video"]["id"])
video_object = self.session.vk.client.video.get(owner_id=attachment["video"]["owner_id"], videos=object_id)
video_object = video_object["items"][0]
output.speak(_("Opening video in web browser..."), True)
webbrowser.open_new_tab(video_object["player"])
elif attachment["type"] == "photo":
output.speak(_("Opening photo in web browser..."), True)
# Possible photo sizes for looking in the attachment information. Try to use the biggest photo available.
possible_sizes = [1280, 604, 130, 75]
url = ""
for i in possible_sizes:
if "photo_{0}".format(i,) in attachment["photo"]:
url = attachment["photo"]["photo_{0}".format(i,)]
break
if url != "":
webbrowser.open_new_tab(url)
elif attachment["type"] == "poll":
a = poll.displayPollPresenter(session=self.session, poll=attachment, interactor=interactors.displayPollInteractor(), view=views.displayPoll())
else:
log.debug("Unhandled attachment: %r" % (attachment,))
def __del__(self):
if hasattr(self, "worker"):
self.worker.finished.set()
def clear_comments_list(self):
self.send_message("clean_list", list="comments")
self.get_comments()
def show_likes(self):
""" show likes for the specified post."""
data = dict(type="post", owner_id=self.post[self.user_identifier], item_id=self.post["id"], extended=True, count=100, skip_own=True)
result = self.session.vk.client.likes.getList(**data)
if result["count"] > 0:
post = {"source_id": self.post[self.user_identifier], "friends": {"items": result["items"]}}
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who liked this")))
def show_shares(self):
data = dict(type="post", owner_id=self.post[self.user_identifier], item_id=self.post["id"], extended=True, count=1000, skip_own=True, filter="copies")
result = self.session.vk.client.likes.getList(**data)
if result["count"] > 0:
post = {"source_id": self.post[self.user_identifier], "friends": {"items": result["items"]}}
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who shared this")))

View File

@@ -0,0 +1,89 @@
# -*- coding: utf-8 -*-
import threading
import arrow
import languageHandler
import views
import interactors
import logging
from pubsub import pub
from sessionmanager import renderers, utils # We'll use some functions from there
from mysc.thread_utils import call_threaded
from presenters import base
from presenters.createPosts.basePost import createPostPresenter
from . import basePost
log = logging.getLogger(__file__)
def get_message(status):
message = ""
if "text" in status:
message = utils.clean_text(status["text"])
return message
class displayCommentPresenter(basePost.displayPostPresenter):
def __init__(self, session, postObject, view, interactor):
self.type = "comment"
self.modulename = "display_comment"
self.interactor = interactor
self.view = view
self.interactor.install(view=view, presenter=self, modulename=self.modulename)
self.session = session
self.post = postObject
self.user_identifier = "from_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
# connect here the pubsub event for successful posting of comments.
pub.subscribe(self.posted, "posted")
self.run()
pub.unsubscribe(self.posted, "posted")
def load_all_components(self):
self.get_post_information()
self.get_likes()
self.send_message("disable_control", control="comment")
if self.post["likes"]["can_like"] == 0 and self.post["likes"]["user_likes"] == 0:
self.send_message("disable_control", "like")
elif self.post["likes"]["user_likes"] == 1:
self.send_message("set_label", control="like", label=_("&Dislike"))
def get_post_information(self):
from_ = self.session.get_user(self.post[self.user_identifier])
if ("from_id" in self.post and "owner_id" in self.post):
user2 = self.session.get_user(self.post["owner_id"], "user2")
user2.update(from_)
title = _("Comment from {user1_nom} in the {user2_nom}'s post").format(**user2)
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()
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"):
post_arguments = dict(owner_id=self.post["owner_id"], reply_to_comment=self.post["id"], post_id=self.post["post_id"], reply_to_user=self.post["owner_id"], message=comment.text)
attachments = []
if hasattr(comment, "attachments"):
attachments = comment.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
def show_likes(self):
""" show likes for the specified post."""
data = dict(type="comment", owner_id=self.post["owner_id"], item_id=self.post["id"], extended=True, count=100, skip_own=True)
result = self.session.vk.client.likes.getList(**data)
if result["count"] > 0:
post = {"source_id": self.post[self.user_identifier], "friends": {"items": result["items"]}}
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who liked this")))
def posted(self, from_buffer=None):
self.interactor.uninstall()
return

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*-
import webbrowser
import logging
from pubsub import pub
from presenters import base
log = logging.getLogger(__file__)
class displayFriendshipPresenter(base.basePresenter):
def __init__(self, session, postObject, view, interactor, caption=""):
self.session = session
self.post = postObject
super(displayFriendshipPresenter, self).__init__(view=view, interactor=interactor, modulename="display_friendship")
list_of_friends = self.get_friend_names()
from_ = self.session.get_user(self.post["source_id"])
title = caption.format(**from_)
self.send_message("set_title", value=title)
self.set_friends_list(list_of_friends)
self.run()
def get_friend_names(self):
self.friends = self.post["friends"]["items"]
friends = list()
for i in self.friends:
if "user_id" in i:
friends.append(self.session.get_user(i["user_id"])["user1_nom"])
else:
friends.append(self.session.get_user(i["id"])["user1_nom"])
return friends
def set_friends_list(self, friendslist):
self.send_message("add_items", control="friends", items=friendslist)
def view_profile(self, item):
user = self.friends[item]
if "user_id" in user:
id = user["user_id"]
else:
id = user["id"]
pub.sendMessage("user-profile", person=id)
def open_in_browser(self, item):
user = self.friends[item]
if "user_id" in user:
id = user["user_id"]
else:
id = user["id"]
url = "https://vk.com/id{user_id}".format(user_id=id)
webbrowser.open_new_tab(url)

View File

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-
import output
import logging
from presenters import base
log = logging.getLogger(__file__)
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."))

View File

@@ -0,0 +1,168 @@
# -*- coding: utf-8 -*-
import threading
import arrow
import languageHandler
import views
import interactors
import output
import logging
from pubsub import pub
from sessionmanager import utils # We'll use some functions from there
from mysc.thread_utils import call_threaded
from presenters import base
from presenters.createPosts.basePost import createPostPresenter
from . import basePost
from .topicComment import *
log = logging.getLogger(__file__)
class displayTopicPresenter(basePost.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 = []
# connect pubsub event for posted comments.
pub.subscribe(self.posted, "posted")
self.run()
pub.unsubscribe(self.posted, "posted")
def load_all_components(self):
self.get_comments()
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, sort="desc")
comments_ = []
data = dict(profiles=self.comments["profiles"], groups=[])
self.session.process_usernames(data)
self.comments["items"].reverse()
# If there are less than 100 comments in the topic we should disable the "load previous" button.
if self.comments["count"] <= 100:
self.send_message("disable_control", control="load_more_comments")
else:
left_comments = self.comments["count"]-len(self.comments["items"])
if left_comments > 100:
left_comments = 100
self.send_message("set_label", control="load_more_comments", label=_("Load {comments} previous comments").format(comments=left_comments))
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"):
post_arguments = dict(group_id=self.group_id, topic_id=self.post["id"], message=comment.text)
attachments = []
if hasattr(comment, "attachments"):
attachments = comment.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
def reply(self, comment):
c = self.comments["items"][comment]
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"]
post_arguments = dict(group_id=group_id, topic_id=topic_id, reply_to_comment=c["id"], message=comment.text)
attachments = []
if hasattr(comment, "attachments"):
attachments = comment.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="createComment", attachments_list=attachments, post_arguments=post_arguments)
def show_comment(self, comment_index):
c = self.comments["items"][comment_index]
c["post_id"] = self.post["id"]
c["group_id"] = -1*self.group_id
a = displayTopicCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
def load_more_comments(self):
offset = len(self.comments["items"])
comments = self.session.vk.client.board.getComments(group_id=self.group_id, topic_id=self.post["id"], need_likes=1, count=100, extended=1, sort="desc", offset=offset)
data = dict(profiles=comments["profiles"], groups=[])
self.session.process_usernames(data)
# If there are less than 100 comments in the topic we should disable the "load previous" button.
for i in comments["items"]:
self.comments["items"].insert(0, i)
for i in 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"])
self.send_message("add_item", control="comments", item=(from_, text, created_at, likes), reversed=True)
if len(self.comments["items"]) == self.comments["count"]:
self.send_message("disable_control", control="load_more_comments")
else:
left_comments = self.comments["count"]-len(self.comments["items"])
if left_comments > 100:
left_comments = 100
self.send_message("set_label", control="load_more_comments", label=_("Load {comments} previous comments").format(comments=left_comments))
def posted(self, from_buffer=None):
self.clear_comments_list()

View File

@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
import logging
import output
from pubsub import pub
from sessionmanager import renderers, utils # We'll use some functions from there
from presenters import base
from presenters.createPosts.basePost import createPostPresenter
from . import comment
log = logging.getLogger(__file__)
def get_message(status):
message = ""
if "text" in status:
message = utils.clean_text(status["text"])
return message
class displayTopicCommentPresenter(comment.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")
def post_like(self):
id = self.post["id"]
if self.post["likes"]["user_likes"] == 1:
l = self.session.vk.client.likes.delete(owner_id=self.post["group_id"], item_id=id, type="topic_comment")
output.speak(_("You don't like this"))
self.post["likes"]["count"] = l["likes"]
self.post["likes"]["user_likes"] = 2
self.send_message("set_label", control="like", label=_("&Like"))
else:
l = self.session.vk.client.likes.add(owner_id=self.post["group_id"], item_id=id, type="topic_comment")
output.speak(_("You liked this"))
self.send_message("set_label", control="like", label=_("&Dislike"))
self.post["likes"]["count"] = l["likes"]
self.post["likes"]["user_likes"] = 1
self.get_likes()
def show_likes(self):
""" show likes for the specified post."""
data = dict(type="topic_comment", owner_id=self.post["group_id"], item_id=self.post["id"], extended=True, count=100, skip_own=True)
result = self.session.vk.client.likes.getList(**data)
if result["count"] > 0:
post = {"source_id": self.post["group_id"], "friends": {"items": result["items"]}}
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who liked this")))

View File

@@ -1,15 +1,21 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Audio player module for socializer.
As this player does not have (still) an associated GUI, I have decided to place here the code for the interactor, which connects a bunch of pubsub events, and the presenter itself.
"""
import sys import sys
import time
import random import random
import output
import sound_lib
import logging import logging
import sound_lib
import output
import config import config
from sound_lib.config import BassConfig from sound_lib.config import BassConfig
from sound_lib.stream import URLStream from sound_lib.stream import URLStream
from sound_lib.main import BassError from sound_lib.main import BassError
from mysc.repeating_timer import RepeatingTimer
from pubsub import pub from pubsub import pub
from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded
from sessionmanager import utils
player = None player = None
log = logging.getLogger("player") log = logging.getLogger("player")
@@ -20,65 +26,127 @@ def setup():
player = audioPlayer() player = audioPlayer()
class audioPlayer(object): class audioPlayer(object):
""" A media player which will play all passed URLS."""
def __init__(self): def __init__(self):
# control variable for checking if another file has been sent to the player before,
# thus avoiding double file playback and other oddities happening in sound_lib from time to time.
self.is_playing = False self.is_playing = False
# This will be the URLStream handler
self.stream = None self.stream = None
self.message = None
self.vol = config.app["sound"]["volume"] self.vol = config.app["sound"]["volume"]
# this variable is set to true when the URLPlayer is decoding something, thus it will block other calls to the play method.
self.is_working = False self.is_working = False
# Playback queue.
self.queue = [] self.queue = []
# Index of the currently playing track.
self.playing_track = 0 self.playing_track = 0
self.playing_all = False
self.worker = RepeatingTimer(5, self.player_function)
self.worker.start()
# Status of the player.
self.stopped = True 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. # Modify some default settings present in Bass so it will increase timeout connection, thus causing less "connection timed out" errors when playing.
bassconfig = BassConfig() bassconfig = BassConfig()
# Set timeout connection to 30 seconds. # Set timeout connection to 30 seconds.
bassconfig["net_timeout"] = 30000 bassconfig["net_timeout"] = 30000
# subscribe all pubsub events.
pub.subscribe(self.play, "play")
pub.subscribe(self.play_message, "play-message")
pub.subscribe(self.play_all, "play-all")
pub.subscribe(self.pause, "pause")
pub.subscribe(self.stop, "stop")
pub.subscribe(self.play_next, "play-next")
pub.subscribe(self.play_previous, "play-previous")
pub.subscribe(self.seek, "seek")
def play(self, url, set_info=True, fresh=False): # Stopped has a special function here, hence the decorator
if self.stream != None and self.stream.is_playing == True: # when stopped will be set to True, it will send a pubsub event to inform other parts of the application about the status change.
# this is useful for changing labels between play and pause, and so on, in buttons.
@property
def stopped(self):
return self._stopped
@stopped.setter
def stopped(self, value):
self._stopped = value
pub.sendMessage("playback-changed", stopped=value)
def play(self, object, set_info=True, fresh=False):
""" Play an URl Stream.
@object dict: typically an audio object as returned by VK, with a "url" component which must be a valid URL to a media file.
@set_info bool: If true, will set information about the currently playing audio in the application status bar.
@fresh bool: If True, will remove everything playing in the queue and start this file only. otherwise it will play the new file but not remove the current queue."""
if "url" in object and object["url"] =="":
pub.sendMessage("notify", message=_("This file could not be played because it is not allowed in your country"))
return
if self.stream != None and (self.stream.is_playing == True or self.stream.is_stalled == True):
try: try:
self.stream.stop() self.stream.stop()
except BassError: except BassError:
log.exception("error when stopping the file") log.exception("error when stopping the file")
self.stream = None self.stream = None
self.stopped = True self.stopped = True
if fresh == True and hasattr(self, "worker") and self.worker != None: if fresh == True:
self.worker.cancel()
self.worker = None
self.queue = [] self.queue = []
# Make sure that there are no other sounds trying to be played. # Make sure that there are no other sounds trying to be played.
if self.is_working == False: if self.is_working == False:
self.is_working = True self.is_working = True
# Let's encode the URL as bytes if on Python 3 # Let's encode the URL as bytes if on Python 3
if sys.version[0] == "3": url_ = utils.transform_audio_url(object["url"])
url_ = bytes(url["url"], "utf-8") url_ = bytes(url_, "utf-8")
else:
url_ = url["url"]
try: try:
self.stream = URLStream(url=url_) self.stream = URLStream(url=url_)
except IndexError: except:
log.error("Unable to play URL") log.error("Unable to play URL %s" % (url_))
log.error(url_)
return return
# Translators: {0} will be replaced with a song's title and {1} with the artist. # Translators: {0} will be replaced with a song's title and {1} with the artist.
if set_info: if set_info:
msg = _("Playing {0} by {1}").format(url["title"], url["artist"]) msg = _("Playing {0} by {1}").format(object["title"], object["artist"])
pub.sendMessage("update-status-bar", status=msg) pub.sendMessage("update-status-bar", status=msg)
self.stream.volume = self.vol/100.0 self.stream.volume = self.vol/100.0
self.stream.play() self.stream.play()
self.stopped = False self.stopped = False
self.is_working = False self.is_working = False
def play_message(self, message_url):
if self.message != None and (self.message.is_playing == True or self.message.is_stalled == True):
return self.stop_message()
output.speak(_("Playing..."))
url_ = utils.transform_audio_url(message_url)
url_ = bytes(url_, "utf-8")
try:
self.message = URLStream(url=url_)
except:
log.error("Unable to play URL %s" % (url_))
return
self.message.volume = self.vol/100.0
self.message.play()
volume_percent = self.volume*0.25
volume_step = self.volume*0.15
while self.stream.volume*100 > volume_percent:
self.stream.volume = self.stream.volume-(volume_step/100)
time.sleep(0.1)
def stop(self): def stop(self):
""" Stop audio playback. """
if self.stream != None and self.stream.is_playing == True: if self.stream != None and self.stream.is_playing == True:
self.stream.stop() self.stream.stop()
self.stopped = True self.stopped = True
if hasattr(self, "worker") and self.worker != None:
self.worker.cancel()
self.worker = None
self.queue = [] self.queue = []
def stop_message(self):
if hasattr(self, "message") and self.message != None and self.message.is_playing == True:
self.message.stop()
volume_step = self.volume*0.15
while self.stream.volume*100 < self.volume:
self.stream.volume = self.stream.volume+(volume_step/100)
time.sleep(0.1)
self.message = None
def pause(self): def pause(self):
""" pause the current playback, without destroying the queue or the current stream. If the stream is already paused this function will resume the playback. """
if self.stream != None: if self.stream != None:
if self.stream.is_playing == True: if self.stream.is_playing == True:
self.stream.pause() self.stream.pause()
@@ -89,6 +157,8 @@ class audioPlayer(object):
self.stopped = False self.stopped = False
except BassError: except BassError:
pass pass
if self.playing_all == False and len(self.queue) > 0:
self.playing_all = True
@property @property
def volume(self): def volume(self):
@@ -98,52 +168,90 @@ class audioPlayer(object):
def volume(self, vol): def volume(self, vol):
if vol <= 100 and vol >= 0: if vol <= 100 and vol >= 0:
self.vol = vol self.vol = vol
elif vol < 0:
self.vol = 0
elif vol > 100:
self.vol = 100
if self.stream != None: if self.stream != None:
self.stream.volume = self.vol/100.0 if self.message != None and self.message.is_playing:
self.stream.volume = (self.vol*0.25)/100.0
self.message.volume = self.vol/100.0
else:
self.stream.volume = self.vol/100.0
def play_all(self, list_of_urls, shuffle=False): def play_all(self, list_of_songs, shuffle=False):
""" Play all passed songs and adds all of those to the queue.
@list_of_songs list: A list of audio objects returned by VK.
@shuffle bool: If True, the files will be played randomly."""
if self.is_working:
return
self.playing_track = 0 self.playing_track = 0
self.stop() self.stop()
# Skip all country restricted tracks as they are not playable here. # Skip all country restricted tracks as they are not playable here.
self.queue = [i for i in list_of_urls if i["url"] != ""] self.queue = [i for i in list_of_songs if i["url"] != ""]
if shuffle: if shuffle:
random.shuffle(self.queue) random.shuffle(self.queue)
self.play(self.queue[self.playing_track]) call_threaded(self.play, self.queue[self.playing_track])
self.worker = RepeatingTimer(5, self.player_function) self.playing_all = True
self.worker.start()
def player_function(self): def player_function(self):
""" Check if the stream has reached the end of the file so it will play the next song. """
if self.message != None and self.message.is_playing == False and len(self.message) == self.message.position:
volume_step = self.volume*0.15
while self.stream != None and self.stream.volume*100 < self.volume:
self.stream.volume = self.stream.volume+(volume_step/100)
time.sleep(0.1)
if self.stream != None and self.stream.is_playing == False and self.stopped == False and len(self.stream) == self.stream.position: if self.stream != None and self.stream.is_playing == False and self.stopped == False and len(self.stream) == self.stream.position:
if len(self.queue) == 0 or self.playing_track >= len(self.queue): if self.playing_track >= len(self.queue):
self.worker.cancel() self.stopped = True
self.playing_all = False
return return
if self.playing_track < len(self.queue): elif self.playing_all == False:
self.stopped = True
return
elif self.playing_track < len(self.queue):
self.playing_track += 1 self.playing_track += 1
self.play(self.queue[self.playing_track]) self.play(self.queue[self.playing_track])
def play_next(self): def play_next(self):
""" Play the next song in the queue. """
if len(self.queue) == 0: if len(self.queue) == 0:
return return
if self.is_working:
return
if self.playing_track < len(self.queue)-1: if self.playing_track < len(self.queue)-1:
self.playing_track += 1 self.playing_track += 1
else: else:
self.playing_track = 0 self.playing_track = 0
self.play(self.queue[self.playing_track]) call_threaded(self.play, self.queue[self.playing_track])
def play_previous(self): def play_previous(self):
""" Play the previous song in the queue. """
if len(self.queue) == 0: if len(self.queue) == 0:
return return
if self.is_working:
return
if self.playing_track <= 0: if self.playing_track <= 0:
self.playing_track = len(self.queue)-1 self.playing_track = len(self.queue)-1
else: else:
self.playing_track -= 1 self.playing_track -= 1
self.play(self.queue[self.playing_track]) call_threaded(self.play, self.queue[self.playing_track])
def seek(self, ms=0):
if self.check_is_playing():
if self.stream.position < 500000 and ms < 0:
self.stream.position = 0
else:
try:
self.stream.position = self.stream.position+ms
except:
pass
def check_is_playing(self): def check_is_playing(self):
""" check if the player is already playing a stream. """
if self.stream == None: if self.stream == None:
return False return False
if self.stream != None and self.stream.is_playing == False: if self.stream != None and self.stream.is_playing == False and self.stream.is_stalled == False:
return False return False
else: else:
return True return True

View File

@@ -1,799 +0,0 @@
# -*- coding: utf-8 -*-
import os
import six
import threading
import arrow
import requests
import languageHandler
import views
import interactors
import output
import webbrowser
import logging
from vk_api import upload
from sessionmanager import session, renderers, utils # We'll use some functions from there
from pubsub import pub
from extra import SpellChecker, translator
from mysc.thread_utils import call_threaded
from .import base
from .postCreation import createPostPresenter
log = logging.getLogger(__file__)
def get_message(status):
message = ""
if "text" in status:
message = utils.clean_text(status["text"])
return message
class displayPostPresenter(base.basePresenter):
""" Base class for post representation."""
def __init__(self, session, postObject, view, interactor):
super(displayPostPresenter, self).__init__(view=view, interactor=interactor, modulename="display_post")
self.type = "post"
self.session = session
self.post = postObject
# Posts from newsfeed contains this source_id instead from_id in walls. Also it uses post_id and walls use just id.
if "source_id" in self.post:
self.user_identifier = "source_id"
self.post_identifier = "post_id"
else:
# In wall's posts, if someone has posted in user's wall, owner_id should be used instead from_id
# This will help for retrieving comments, do likes, etc.
if "owner_id" not in self.post:
self.user_identifier = "from_id"
else:
self.user_identifier = "owner_id"
self.post_identifier = "id"
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):
""" Get comments and insert them in a list."""
user = self.post[self.user_identifier]
id = self.post[self.post_identifier]
self.comments = self.session.vk.client.wall.getComments(owner_id=user, post_id=id, need_likes=1, count=100, extended=1, preview_length=0, thread_items_count=10)
comments_ = []
# 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_ = self.session.get_user(i["from_id"])["user1_nom"]
if "reply_to_user" in i:
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 = utils.clean_text(i["text"])
if len(fixed_text) > 140:
text = fixed_text[:141]
else:
text = fixed_text
original_date = arrow.get(i["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
likes = str(i["likes"]["count"])
replies = str(i["thread"]["count"])
comments_.append((from_, text, created_at, likes, replies))
self.send_message("add_items", control="comments", items=comments_)
def get_post_information(self):
from_ = self.session.get_user(self.post[self.user_identifier])
if "copy_history" in self.post:
title = _("repost from {user1_nom}").format(**from_)
else:
if ("from_id" in self.post and "owner_id" in self.post) and (self.post["from_id"] != self.post["owner_id"]):
# Translators: {0} will be replaced with the user who is posting, and {1} with the wall owner.
user2 = self.session.get_user(self.post["owner_id"], "user2")
user2.update(from_)
title = _("Post from {user1_nom} in the {user2_nom}'s wall").format(**user2)
else:
title = _("Post from {user1_nom}").format(**from_)
self.send_message("set_title", value=title)
message = ""
# 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"]))
else:
self.send_message("disable_control", control="views")
if "owner_id" not in self.post:
self.user_identifier = "from_id"
else:
self.user_identifier = "owner_id"
self.post_identifier = "id"
message = get_message(self.post)
if "copy_history" in self.post:
nm = "\n"
for i in self.post["copy_history"]:
u = self.session.get_user(i["from_id"])
u.update(message=get_message(i))
nm += "{user1_nom}: {message}\n\n".format(**u)
self.get_attachments(i, get_message(i))
message += nm
self.send_message("set", control="post_view", value=message)
self.get_attachments(self.post, message)
self.check_image_load()
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.
if i["type"] == "photos_list":
continue
if i["type"] == "photo":
if self.load_images == False: self.load_images = True
self.images.append(i)
attachments.append(renderers.add_attachment(i))
self.attachments.append(i)
# Links in text are not treated like normal attachments, so we'll have to catch and add those to the list without title
# We can't get a title because title is provided by the VK API and it will not work for links as simple text.
urls = utils.find_urls_in_text(text)
if len(urls) > 0:
links = []
for i in urls:
links.append({"link": {"title": _("Untitled link"), "url": i}, "type": "link"})
for i in links:
attachments.append(renderers.add_attachment(i))
self.attachments.append(i)
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"]:
self.send_message("enable_control", control="image")
nav = False # Disable navigation controls in photos
if len(self.images) > 1:
nav = True
self.send_message("enable_photo_controls", navigation=nav)
self.set_image(0)
def set_next_image(self, *args, **kwargs):
if self.imageIndex < -1 or self.imageIndex == len(self.images)-1:
self.imageIndex = -1
if len(self.images) <= self.imageIndex+1:
self.imageIndex = 0
else:
self.imageIndex = self.imageIndex + 1
self.set_image(self.imageIndex)
def set_previous_image(self, *args, **kwargs):
if self.imageIndex <= 0:
self.imageIndex = len(self.images)
self.imageIndex = self.imageIndex - 1
self.set_image(self.imageIndex)
def set_image(self, index):
if len(self.images) < index-1:
return
# Get's photo URL.
url = self.get_photo_url(self.images[index]["photo"], "x")
if url != "":
img = requests.get(url)
self.send_message("load_image", image=img)
# Translators: {0} is the number of the current photo and {1} is the total number of photos.
output.speak(_("Loaded photo {0} of {1}").format(index+1, len(self.images)))
return
def get_photo_url(self, photo, size="x"):
url = ""
for i in photo["sizes"]:
if i["type"] == size:
url = i["url"]
break
return url
def load_all_components(self):
self.get_likes()
self.get_reposts()
self.get_comments()
if self.post["comments"]["can_post"] == 0:
self.send_message("disable_control", control="comment")
if self.post["likes"]["can_like"] == 0 and self.post["likes"]["user_likes"] == 0:
self.send_message("disable_control", "like")
elif self.post["likes"]["user_likes"] == 1:
self.send_message("set_label", control="like", label=_("&Dislike"))
if self.post["likes"]["can_publish"] == 0:
self.send_message("disable_control", control="repost")
def post_like(self):
if ("owner_id" in self.post) == False:
user = int(self.post[self.user_identifier])
else:
user = int(self.post["owner_id"])
id = int(self.post[self.post_identifier])
if "type" in self.post:
type_ = self.post["type"]
else:
type_ = self.type
if self.post["likes"]["user_likes"] == 1:
l = self.session.vk.client.likes.delete(owner_id=user, item_id=id, type=type_)
output.speak(_("You don't like this"))
self.post["likes"]["count"] = l["likes"]
self.post["likes"]["user_likes"] = 2
self.get_likes()
self.send_message("set_label", control="like", label=_("&Like"))
else:
l = self.session.vk.client.likes.add(owner_id=user, item_id=id, type=type_)
output.speak(_("You liked this"))
self.send_message("set_label", control="like", label=_("&Dislike"))
self.post["likes"]["count"] = l["likes"]
self.post["likes"]["user_likes"] = 1
self.get_likes()
def post_repost(self):
object_id = "wall{0}_{1}".format(self.post[self.user_identifier], self.post[self.post_identifier])
p = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Repost"), message=_("Add your comment here"), text="", mode="comment"))
if hasattr(p, "text") or hasattr(p, "privacy"):
msg = p.text
self.session.vk.client.wall.repost(object=object_id, message=msg)
def get_likes(self):
self.send_message("set_label", control="likes", label=_("{0} people like this").format(self.post["likes"]["count"],))
def get_reposts(self):
self.send_message("set_label", control="shares", label=_("Shared {0} times").format(self.post["reposts"]["count"],))
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"):
owner_id = self.post[self.user_identifier]
post_id = self.post[self.post_identifier]
call_threaded(self.do_last, comment, owner_id=owner_id, post_id=post_id)
def do_last(self, comment, **kwargs):
msg = comment.text
attachments = ""
if hasattr(comment, "attachments"):
attachments = self.upload_attachments(comment.attachments)
urls = utils.find_urls_in_text(msg)
if len(urls) != 0:
if len(attachments) == 0: attachments = urls[0]
else: attachments += urls[0]
msg = msg.replace(urls[0], "")
if msg != "":
kwargs.update(message=msg)
if attachments != "":
kwargs.update(attachments=attachments)
if "message" not in kwargs and "attachments" not in kwargs:
return # No comment made here.
try:
result = self.session.vk.client.wall.createComment(**kwargs)
comment_object = self.session.vk.client.wall.getComment(comment_id=result["comment_id"], owner_id=kwargs["owner_id"])["items"][0]
from_ = self.session.get_user(comment_object["from_id"])
if "reply_to_user" in comment_object:
extra_info = self.session.get_user(comment_object["reply_to_user"], "user2")
extra_info.update(from_)
from_ = _("{user1_nom} > {user2_nom}").format(**extra_info)
else:
from_ = from_["user1_nom"]
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
fixed_text = utils.clean_text(comment_object["text"])
if len(fixed_text) > 140:
text = fixed_text[:141]
else:
text = fixed_text
original_date = arrow.get(comment_object["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
likes = str(comment_object["likes"]["count"])
replies = ""
item = (from_, text, created_at, likes, replies)
if hasattr(self, "comments"):
self.comments["items"].append(comment_object)
else:
if "items" not in self.post["thread"]:
self.post["thread"]["items"] = []
self.post["thread"]["items"].append(comment_object)
self.send_message("add_items", control="comments", items=[item])
output.speak(_("You've posted a comment"))
except IndexError as msg:
log.error(msg)
def upload_attachments(self, attachments):
""" Upload attachments to VK before posting them.
Returns attachments formatted as string, as required by VK API.
Currently this function only supports photos and audios."""
# To do: Check the caption and description fields for this kind of attachments.
local_attachments = ""
uploader = upload.VkUpload(self.session.vk.session_object)
for i in attachments:
if i["from"] == "online":
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
elif i["from"] == "local" and i["type"] == "photo":
photos = i["file"]
description = i["description"]
r = uploader.photo_wall(photos, caption=description)
id = r[0]["id"]
owner_id = r[0]["owner_id"]
local_attachments += "photo{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "audio":
audio = i["file"]
title = "untitled"
artist = "unnamed"
if "artist" in i:
artist = i["artist"]
if "title" in i:
title = i["title"]
r = uploader.audio(audio, title=title, artist=artist)
id = r["id"]
owner_id = r["owner_id"]
local_attachments += "audio{0}_{1},".format(owner_id, id)
return local_attachments
def reply(self, comment):
c = self.comments["items"][comment]
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Reply to {user1_nom}").format(**self.session.get_user(c["from_id"])), message="", text="", mode="comment"))
if hasattr(comment, "text") or hasattr(comment, "privacy"):
call_threaded(self.do_last, comment, owner_id=c["owner_id"], reply_to_comment=c["id"], post_id=c["post_id"], reply_to_user=c["owner_id"])
def show_comment(self, comment_index):
c = self.comments["items"][comment_index]
c["post_id"] = self.post[self.post_identifier]
a = displayCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
def translate(self, text, language):
msg = translator.translator.translate(text, language)
self.send_message("set", control="post_view", value=msg)
self.send_message("focus_control", control="post_view")
output.speak(_("Translated"))
def spellcheck(self, text):
checker = SpellChecker.spellchecker.spellChecker(text, "")
if hasattr(checker, "fixed_text"):
self.send_message("set", control="post_view", value=checker.fixed_text)
self.send_message("focus_control", control="post_view")
checker.clean()
def open_attachment(self, index):
attachment = self.attachments[index]
if attachment["type"] == "audio":
a = displayAudioPresenter(session=self.session, postObject=[attachment["audio"]], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
elif attachment["type"] == "link":
output.speak(_("Opening URL..."), True)
webbrowser.open_new_tab(attachment["link"]["url"])
elif attachment["type"] == "doc":
output.speak(_("Opening document in web browser..."))
webbrowser.open(attachment["doc"]["url"])
elif attachment["type"] == "video":
# it seems VK doesn't like to attach video links as normal URLS, so we'll have to
# get the full video object and use its "player" key which will open a webbrowser in their site with a player for the video.
# see https://vk.com/dev/attachments_w and and https://vk.com/dev/video.get
# However, the flash player isn't good for visually impaired people (when you press play you won't be able to close the window with alt+f4), so it could be good to use the HTML5 player.
# For firefox, see https://addons.mozilla.org/ru/firefox/addon/force-html5-video-player-at-vk/
# May be I could use a dialogue here for inviting people to use this addon in firefox. It seems it isn't possible to use this html5 player from the player URL.
object_id = "{0}_{1}".format(attachment["video"]["owner_id"], attachment["video"]["id"])
video_object = self.session.vk.client.video.get(owner_id=attachment["video"]["owner_id"], videos=object_id)
video_object = video_object["items"][0]
output.speak(_("Opening video in web browser..."), True)
webbrowser.open_new_tab(video_object["player"])
elif attachment["type"] == "photo":
output.speak(_("Opening photo in web browser..."), True)
# Possible photo sizes for looking in the attachment information. Try to use the biggest photo available.
possible_sizes = [1280, 604, 130, 75]
url = ""
for i in possible_sizes:
if "photo_{0}".format(i,) in attachment["photo"]:
url = attachment["photo"]["photo_{0}".format(i,)]
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,))
def __del__(self):
if hasattr(self, "worker"):
self.worker.finished.set()
def clear_comments_list(self):
self.send_message("clean_list", list="comments")
self.get_comments()
class displayCommentPresenter(displayPostPresenter):
def __init__(self, session, postObject, view, interactor):
self.type = "comment"
self.modulename = "display_comment"
self.interactor = interactor
self.view = view
self.interactor.install(view=view, presenter=self, modulename=self.modulename)
self.session = session
self.post = postObject
self.user_identifier = "from_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
self.run()
def load_all_components(self):
self.get_post_information()
self.get_likes()
self.send_message("disable_control", control="comment")
self.get_comments()
if self.post["likes"]["can_like"] == 0 and self.post["likes"]["user_likes"] == 0:
self.send_message("disable_control", "like")
elif self.post["likes"]["user_likes"] == 1:
self.send_message("set_label", control="like", label=_("&Dislike"))
def get_post_information(self):
from_ = self.session.get_user(self.post[self.user_identifier])
if ("from_id" in self.post and "owner_id" in self.post):
user2 = self.session.get_user(self.post["owner_id"], "user2")
user2.update(from_)
title = _("Comment from {user1_nom} in the {user2_nom}'s post").format(**user2)
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()
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"])
def get_comments(self):
""" Get comments and insert them in a list."""
comments_ = []
if "thread" not in self.post:
return
for i in self.post["thread"]["items"]:
# If comment has a "deleted" key it should not be displayed, obviously.
if "deleted" in i:
continue
from_ = self.session.get_user(i["from_id"])
if "reply_to_user" in i:
extra_info = self.session.get_user(i["reply_to_user"], "user2")
extra_info.update(from_)
from_ = _("{user1_nom} > {user2_nom}").format(**extra_info)
else:
from_ = from_["user1_nom"]
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
fixed_text = utils.clean_text(i["text"])
if len(fixed_text) > 140:
text = fixed_text[:141]
else:
text = fixed_text
original_date = arrow.get(i["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
likes = str(i["likes"]["count"])
replies = ""
comments_.append((from_, text, created_at, likes, replies))
self.send_message("add_items", control="comments", items=comments_)
def show_comment(self, comment_index):
c = self.post["thread"]["items"][comment_index]
c["post_id"] = self.post["post_id"]
a = displayCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
self.clear_comments_list()
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")
self.added_audios = {}
self.session = session
self.post = postObject
self.load_audios()
self.fill_information(0)
self.run()
def add_to_library(self, audio_index):
post = self.post[audio_index]
args = {}
args["audio_id"] = post["id"]
if "album_id" in post:
args["album_id"] = post["album_id"]
args["owner_id"] = post["owner_id"]
audio = self.session.vk.client.audio.add(**args)
if audio != None and int(audio) > 21:
self.added_audios[post["id"]] = audio
self.send_message("disable_control", control="add")
self.send_message("enable_control", control="remove")
def remove_from_library(self, audio_index):
post = self.post[audio_index]
args = {}
if post["id"] in self.added_audios:
args["audio_id"] = self.added_audios[post["id"]]
args["owner_id"] = self.session.user_id
else:
args["audio_id"] = post["id"]
args["owner_id"] = post["owner_id"]
result = self.session.vk.client.audio.delete(**args)
if int(result) == 1:
self.send_message("enable_control", control="add")
self.send_message("disable_control", control="remove")
if post["id"] in self.added_audios:
self.added_audios.pop(post["id"])
def fill_information(self, index):
post = self.post[index]
if "artist" in post:
self.send_message("set", control="artist", value=post["artist"])
if "title" in post:
self.send_message("set", control="title", value=post["title"])
if "duration" in post:
self.send_message("set", control="duration", value=utils.seconds_to_string(post["duration"]))
self.send_message("set_title", value="{0} - {1}".format(post["title"], post["artist"]))
call_threaded(self.get_lyrics, index)
if post["owner_id"] == self.session.user_id or (post["id"] in self.added_audios) == True:
self.send_message("enable_control", control="remove")
self.send_message("disable_control", control="add")
else:
self.send_message("enable_control", control="add")
self.send_message("disable_control", control="remove")
def get_lyrics(self, audio_index):
post = self.post[audio_index]
if "lyrics_id" in post:
l = self.session.vk.client.audio.getLyrics(lyrics_id=int(post["lyrics_id"]))
self.send_message("set", control="lyric", value=l["text"])
else:
self.send_message("disable_control", control="lyric")
def get_suggested_filename(self, audio_index):
post = self.post[audio_index]
return "{0} - {1}.mp3".format(post["title"], post["artist"])
def download(self, audio_index, path):
post = self.post[audio_index]
if path != None:
pub.sendMessage("download-file", url=post["url"], filename=path)
def play(self, audio_index):
post = self.post[audio_index]
pub.sendMessage("play-audio", audio_object=post)
def load_audios(self):
audios = []
for i in self.post:
s = "{0} - {1}. {2}".format(i["title"], i["artist"], utils.seconds_to_string(i["duration"]))
audios.append(s)
self.send_message("add_items", control="list", items=audios)
if len(self.post) == 1:
self.send_message("disable_control", control="list")
self.send_message("focus_control", control="title")
def handle_changes(self, audio_index):
self.fill_information(audio_index)
class displayFriendshipPresenter(base.basePresenter):
def __init__(self, session, postObject, view, interactor):
self.session = session
self.post = postObject
super(displayFriendshipPresenter, self).__init__(view=view, interactor=interactor, modulename="display_friendship")
list_of_friends = self.get_friend_names()
from_ = self.session.get_user(self.post["source_id"])
title = _("{user1_nom} added the following friends").format(**from_)
self.send_message("set_title", value=title)
self.set_friends_list(list_of_friends)
self.run()
def get_friend_names(self):
self.friends = self.post["friends"]["items"]
return [self.session.get_user(i["user_id"])["user1_nom"] for i in self.friends]
def set_friends_list(self, friendslist):
self.send_message("add_items", control="friends", items=friendslist)

View File

@@ -38,7 +38,7 @@ class userProfilePresenter(base.basePresenter):
See https://vk.com/dev/users.get""" See https://vk.com/dev/users.get"""
# List of fields (information) to retrieve. For a list of fields available for user objects, # List of fields (information) to retrieve. For a list of fields available for user objects,
# see https://vk.com/dev/fields # see https://vk.com/dev/fields
fields = "first_name, last_name, bdate, city, country, home_town, photo_200_orig, online, site, status, last_seen, occupation, relation, relatives, personal, connections, activities, interests, music, movies, tv, books, games, about, quotes, can_write_private_message" fields = "first_name, last_name, bdate, city, country, home_town, photo_200_orig, online, site, status, last_seen, occupation, relation, relatives, personal, connections, activities, interests, music, movies, tv, books, games, about, quotes, can_write_private_message, contacts, has_mobile, universities, education, schools"
# ToDo: this method supports multiple user IDS, I'm not sure if this may be of any help for profile viewer. # ToDo: this method supports multiple user IDS, I'm not sure if this may be of any help for profile viewer.
person = self.session.vk.client.users.get(user_ids=self.user_id, fields=fields) person = self.session.vk.client.users.get(user_ids=self.user_id, fields=fields)
# If VK does not return anything it is very likely we have found a community. # If VK does not return anything it is very likely we have found a community.
@@ -50,6 +50,13 @@ class userProfilePresenter(base.basePresenter):
# From this part we will format data from VK so users will see it in the GUI control. # From this part we will format data from VK so users will see it in the GUI control.
# Format full name. # Format full name.
n = "{0} {1}".format(person["first_name"], person["last_name"]) n = "{0} {1}".format(person["first_name"], person["last_name"])
# format phones
if person.get("mobile_phone") != None and person.get("mobile_phone") != "":
self.send_message("enable_control", tab="main_info", control="mobile_phone")
self.send_message("set", tab="main_info", control="mobile_phone", value=person["mobile_phone"])
if person.get("home_phone") != None and person.get("home_phone") != "":
self.send_message("enable_control", tab="main_info", control="home_phone")
self.send_message("set", tab="main_info", control="home_phone", value=person["home_phone"])
# Format birthdate. # Format birthdate.
if "bdate" in person and person["bdate"] != "": if "bdate" in person and person["bdate"] != "":
self.send_message("enable_control", tab="main_info", control="bdate") self.send_message("enable_control", tab="main_info", control="bdate")
@@ -59,7 +66,13 @@ class userProfilePresenter(base.basePresenter):
self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D"), locale=languageHandler.curLang[:2])) self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D"), locale=languageHandler.curLang[:2]))
else: # mm.dd.yyyy else: # mm.dd.yyyy
d = arrow.get(person["bdate"], "D.M.YYYY") d = arrow.get(person["bdate"], "D.M.YYYY")
self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D, YYYY"), locale=languageHandler.curLang[:2])) # Calculate user's years.
now = arrow.get()
timedelta = now-d
years = int(timedelta.days/365)
date = d.format(_("MMMM D, YYYY"), locale=languageHandler.curLang[:2])
msg = _("{date} ({age} years)").format(date=date, age=years)
self.send_message("set", tab="main_info", control="bdate", value=msg)
# Format current city and home town # Format current city and home town
city = "" city = ""
if "home_town" in person and person["home_town"] != "": if "home_town" in person and person["home_town"] != "":

View File

@@ -13,15 +13,14 @@ load_images = boolean(default=True)
update_channel = string(default="stable") update_channel = string(default="stable")
[buffers] [buffers]
count_for_wall_buffers = integer(default=100) count_for_wall_buffers = integer(default=50)
count_for_video_buffers = integer(default=200) count_for_video_buffers = integer(default=50)
count_for_audio_buffers = integer(default=1000) count_for_audio_buffers = integer(default=1000)
count_for_chat_buffers = integer(default=50)
[chat] [chat]
notify_online = boolean(default=True) notify_online = boolean(default=True)
notify_offline = boolean(default=True) notify_offline = boolean(default=True)
open_unread_conversations = boolean(default=True)
automove_to_conversations = boolean(default=False)
notifications = string(default="custom") notifications = string(default="custom")
[load_at_startup] [load_at_startup]

View File

@@ -75,6 +75,14 @@ def add_attachment(attachment):
elif attachment["type"] == "poll": elif attachment["type"] == "poll":
tpe = _("Poll") tpe = _("Poll")
msg = attachment["poll"]["question"] msg = attachment["poll"]["question"]
elif attachment["type"] == "wall":
tpe = _("Post")
user = attachment["wall"]["from"]["name"]
if len(attachment["wall"]["text"]) > 140:
text = attachment["wall"]["text"][:145]+"..."
else:
text = attachment["wall"]["text"]
msg = _("{user}: {post}").format(user=user, post=text)
else: else:
print(attachment) print(attachment)
return [tpe, msg] return [tpe, msg]
@@ -272,4 +280,22 @@ def render_document(document, session):
size = convert_bytes(document["size"]) size = convert_bytes(document["size"])
date = arrow.get(document["date"]).humanize(locale=languageHandler.curLang[:2]) date = arrow.get(document["date"]).humanize(locale=languageHandler.curLang[:2])
doc_type = doc_types[document["type"]] doc_type = doc_types[document["type"]]
return [user["user1_nom"], title, doc_type, size, date] return [user["user1_nom"], title, doc_type, size, date]
def render_notification(notification, session):
notification.pop("hide_buttons")
print(notification["icon_type"])
# print(notification["header"])
print(notification)
date = arrow.get(notification["date"]).humanize(locale=languageHandler.curLang[:2])
msg = notification["header"]
# msg = notification["header"]
# if notification["type"] == "follow":
# if len(notification["feedback"]) == 1:
# user = session.get_user(notification["feedback"][0])
# msg = _("{user1_nom} subscribed to your account").format(**user)
# else:
# users = ["{first_name} {last_name},".format(first_name=user["first_name"], last_name=user["last_name"]) for user in notification["feedback"]]
# msg = " ".join(users)
# print(msg)
return [msg, date]

View File

@@ -4,15 +4,18 @@ from __future__ import unicode_literals
import os import os
import logging import logging
import warnings import warnings
import wx
import languageHandler import languageHandler
import paths import paths
import config import config
import sound import sound
from requests.exceptions import ProxyError, ConnectionError from requests.exceptions import ProxyError, ConnectionError
from .config_utils import Configuration, ConfigurationResetException
from . import vkSessionHandler
from pubsub import pub from pubsub import pub
from vk_api.exceptions import LoginRequired, VkApiError from vk_api.exceptions import LoginRequired, VkApiError
from vk_api import upload
from .config_utils import Configuration, ConfigurationResetException
from . import vkSessionHandler
from . import utils
log = logging.getLogger("session") log = logging.getLogger("session")
@@ -24,7 +27,7 @@ sessions = {}
identifiers = ["aid", "gid", "uid", "pid", "id", "post_id", "nid", "date"] identifiers = ["aid", "gid", "uid", "pid", "id", "post_id", "nid", "date"]
# Different VK post types, present in the newsfeed buffer. This is useful for filtering by post and remove deleted posts. # Different VK post types, present in the newsfeed buffer. This is useful for filtering by post and remove deleted posts.
post_types = dict(audio="audio", friend="friends", video="video", post="post_type", audio_playlist="audio_playlist") post_types = dict(audio="audio", friend="friends", video="files", post="post_type", audio_playlist="audio_playlist")
def find_item(list, item): def find_item(list, item):
""" Find an item in a list by taking an identifier. """ Find an item in a list by taking an identifier.
@@ -40,7 +43,8 @@ def find_item(list, item):
break break
if identifier == None: if identifier == None:
# if there are objects that can't be processed by lack of identifier, let's print keys for finding one. # if there are objects that can't be processed by lack of identifier, let's print keys for finding one.
log.exception("Can't find an identifier for the following object: %r" % (list(item.keys()),)) log.exception("Can't find an identifier for the following object: %r" % (item,))
return False
for i in list: for i in list:
if identifier in i and i[identifier] == item[identifier]: if identifier in i and i[identifier] == item[identifier]:
return True return True
@@ -53,7 +57,7 @@ class vkSession(object):
""" Put new items on the local cache database. """ Put new items on the local cache database.
@name str: The name for the buffer stored in the dictionary. @name str: The name for the buffer stored in the dictionary.
@data list: A list with items and some information about cursors. @data list: A list with items and some information about cursors.
returns the number of items that has been added in this execution""" returns the number of items that have been added in this execution"""
global post_types 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. # 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. # ToDo: It would be nice to investigate whether reusing some existing objects would be a good idea, whenever possible.
@@ -66,8 +70,11 @@ class vkSession(object):
self.db[name] = {} self.db[name] = {}
self.db[name]["items"] = [] self.db[name]["items"] = []
first_addition = True first_addition = True
# Handles chat messages case, as the buffer is inverted
if name.endswith("_messages") and show_nextpage == True:
show_nextpage = False
for i in data: for i in data:
if "type" in i and not isinstance(i["type"], int) and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"): if "type" in i and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo" or i["type"] == False or i["type"] == True):
log.debug("Skipping unsupported item... %r" % (i,)) log.debug("Skipping unsupported item... %r" % (i,))
continue continue
# for some reason, VK sends post data if the post has been deleted already. # for some reason, VK sends post data if the post has been deleted already.
@@ -98,12 +105,13 @@ class vkSession(object):
self.db = {} self.db = {}
self.db["users"] = {} self.db["users"] = {}
self.db["groups"] = {} self.db["groups"] = {}
self.db["group_info"] = {}
@property @property
def is_logged(self): def is_logged(self):
return self.logged return self.logged
def get_configuration(self): def get_configuration(self, nosound=False):
""" Gets settings for a session.""" """ Gets settings for a session."""
@@ -111,10 +119,16 @@ class vkSession(object):
# try: # try:
log.debug("Creating config file %s" % (file_,)) 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.settings = Configuration(os.path.join(paths.config_path(), file_), os.path.join(paths.app_path(), "session.defaults"))
self.soundplayer = sound.soundSystem(config.app["sound"]) if nosound == False:
self.soundplayer = sound.soundSystem(config.app["sound"])
pub.subscribe(self.play_sound, "play-sound")
pub.subscribe(self.post, "post")
# except: # except:
# log.exception("The session configuration has failed.") # log.exception("The session configuration has failed.")
def play_sound(self, sound):
self.soundplayer.play(sound)
def login(self): def login(self):
""" Logging in VK.com. This is basically the first method interacting with VK. """ """ 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 user is already logged in, we should skip this method.
@@ -124,8 +138,11 @@ class vkSession(object):
config_filename = os.path.join(paths.config_path(), self.session_id, "vkconfig.json") 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) 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)
self.settings["vk"]["token"] = self.vk.session_object.token["access_token"] self.settings["vk"]["token"] = self.vk.session_object.token["access_token"]
self.settings["vk"]["secret"] = self.vk.session_object.secret try:
self.settings["vk"]["device_id"] = self.vk.session_object.device_id self.settings["vk"]["secret"] = self.vk.session_object.secret
self.settings["vk"]["device_id"] = self.vk.session_object.device_id
except AttributeError:
pass
self.settings.write() self.settings.write()
self.logged = True self.logged = True
self.get_my_data() self.get_my_data()
@@ -173,8 +190,10 @@ class vkSession(object):
c = self.vk.client_audio c = self.vk.client_audio
else: else:
c = self.vk.client c = self.vk.client
formatted_endpoint = ""
if "parent_endpoint" in kwargs: if "parent_endpoint" in kwargs:
p = kwargs["parent_endpoint"] p = kwargs["parent_endpoint"]
formatted_endpoint = kwargs["parent_endpoint"]
if "audio" in p and self.settings["vk"]["use_alternative_tokens"]: if "audio" in p and self.settings["vk"]["use_alternative_tokens"]:
log.info("Using alternative audio methods.") log.info("Using alternative audio methods.")
c = self.vk.client_audio c = self.vk.client_audio
@@ -187,14 +206,23 @@ class vkSession(object):
kwargs.update(offset=self.db[name]["offset"]) kwargs.update(offset=self.db[name]["offset"])
else: else:
kwargs.update(offset=0) kwargs.update(offset=0)
log.debug("Calling endpoint %s with params %r" % (p, kwargs,)) formatted_endpoint = "{formatted_endpoint}.{new_path}".format(formatted_endpoint=formatted_endpoint, new_path=endpoint)
offset_deprecated = ["notifications.get"]
if formatted_endpoint in offset_deprecated:
kwargs.update(offset=None)
log.debug("Calling endpoint %s with params %r" % (formatted_endpoint, kwargs,))
data = getattr(p, endpoint)(*args, **kwargs) data = getattr(p, endpoint)(*args, **kwargs)
if data != None: if data != None:
if "count" not in kwargs: if "count" not in kwargs:
kwargs["count"] = 100 kwargs["count"] = 100
# Let's handle a little exception when dealing with conversation buffers.
# the first results of the query should be reversed before being sent to order_buffer.
if type(data) == dict and "items" in data and endpoint == "getHistory" and kwargs["offset"] == 0:
data["items"].reverse()
if type(data) == dict: if type(data) == dict:
num = self.order_buffer(name, data["items"], show_nextpage) num = self.order_buffer(name, data["items"], show_nextpage)
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"] if formatted_endpoint not in offset_deprecated:
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
if len(data["items"]) > 0 and "first_name" in data["items"][0]: if len(data["items"]) > 0 and "first_name" in data["items"][0]:
data2 = {"profiles": [], "groups": []} data2 = {"profiles": [], "groups": []}
for i in data["items"]: for i in data["items"]:
@@ -248,6 +276,10 @@ class vkSession(object):
k = "{key}_{case}".format(key=key, case=i) k = "{key}_{case}".format(key=key, case=i)
v = self.db["groups"][abs(user_id)][i] v = self.db["groups"][abs(user_id)][i]
user_data[k] = v user_data[k] = v
else:
group = self.vk.client.groups.getById(group_ids=-1*user_id)[0]
self.process_usernames(data=dict(profiles=[], groups=[group]))
return self.get_user(user_id=user_id, key=key)
return user_data return user_data
def process_usernames(self, data): def process_usernames(self, data):
@@ -280,4 +312,99 @@ class vkSession(object):
def get_my_data(self): def get_my_data(self):
log.debug("Getting user identifier...") log.debug("Getting user identifier...")
user = self.vk.client.users.get(fields="uid, first_name, last_name") user = self.vk.client.users.get(fields="uid, first_name, last_name")
self.user_id = user[0]["id"] self.user_id = user[0]["id"]
def post(self, parent_endpoint, child_endpoint, from_buffer=None, attachments_list=[], post_arguments={}):
""" Generic function to be called whenever user wants to post something to VK.
This function should be capable of uploading all attachments before posting, and send a special event in case the post has failed,
So the program can recreate the post and show it back to the user."""
# ToDo: this function will occasionally be called with attachments already set to post_arguments, example if the user could upload the files but was unable to send the post due to a connection problem.
# We should see what can be done (reuploading everything vs using the already added attachments).
attachments = ""
# Firstly, let's try to upload the attachments here. If peer_id exists in post_arguments,
# It means we are talking about private messages, whose attachment procedures have their own methods.
if len(attachments_list) > 0:
try:
attachments = self.upload_attachments(attachments_list, post_arguments.get("peer_id"))
except Exception as error:
log.error("Error calling method %s.%s with arguments: %r. Failed during loading attachments. Error: %s" % (parent_endpoint, child_endpoint, post_arguments, str(error)))
# Report a failed function here too with same arguments so the client should be able to recreate it again.
wx.CallAfter(pub.sendMessage, "postFailed", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
# VK generally defines all kind of messages under "text", "message" or "body" so let's try with all of those
possible_message_keys = ["text", "message", "body"]
for i in possible_message_keys:
if post_arguments.get(i):
urls = utils.find_urls_in_text(post_arguments[i])
if len(urls) != 0:
if len(attachments) == 0:
attachments = urls[0]
else:
attachments += urls[0]
post_arguments[i] = post_arguments[i].replace(urls[0], "")
# After modifying everything, let's update the post arguments if needed.
if len(attachments) > 0:
if parent_endpoint == "messages":
post_arguments.update(attachment=attachments)
else:
post_arguments.update(attachments=attachments)
# Determines the correct functions to call here.
endpoint = getattr(self.vk.client, parent_endpoint)
endpoint = getattr(endpoint, child_endpoint)
try:
post = endpoint(**post_arguments)
# Once the post has been send, let's report it to the interested objects.
pub.sendMessage("posted", from_buffer=from_buffer)
except Exception as error:
log.exception("Error calling method %s.%s with arguments: %r. Error: %s" % (parent_endpoint, child_endpoint, post_arguments, str(error)))
# Report a failed function here too with same arguments so the client should be able to recreate it again.
wx.CallAfter(pub.sendMessage, "postFailed", parent_endpoint=parent_endpoint, child_endpoint=child_endpoint, from_buffer=from_buffer, attachments_list=attachments_list, post_arguments=post_arguments)
def upload_attachments(self, attachments, peer_id=None):
""" Upload attachments to VK before posting them.
Returns attachments formatted as string, as required by VK API.
@ peer_id int: if this value is passed, let's assume attachments will be send in private messages.
"""
# To do: Check the caption and description fields for this kind of attachments.
local_attachments = ""
uploader = upload.VkUpload(self.vk.session_object)
for i in attachments:
if i["from"] == "online":
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
elif i["from"] == "local" and i["type"] == "photo":
photos = i["file"]
description = i["description"]
if peer_id == None:
r = uploader.photo_wall(photos, caption=description)
else:
r = uploader.photo_messages(photos)
id = r[0]["id"]
owner_id = r[0]["owner_id"]
local_attachments += "photo{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "audio":
audio = i["file"]
title = "untitled"
artist = "unnamed"
if "artist" in i:
artist = i["artist"]
if "title" in i:
title = i["title"]
r = uploader.audio(audio, title=title, artist=artist)
id = r["id"]
owner_id = r["owner_id"]
local_attachments += "audio{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "voice_message":
r = uploader.audio_message(i["file"], peer_id=peer_id)
id = r["audio_message"]["id"]
owner_id = r["audio_message"]["owner_id"]
local_attachments += "audio_message{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "document":
document = i["file"]
title = i["title"]
if peer_id == None:
r = uploader.document(document, title=title, to_wall=True)
else:
r = uploader.document(document, title=title, message_peer_id=peer_id)
id = r["doc"]["id"]
owner_id = r["doc"]["owner_id"]
local_attachments += "doc{0}_{1},".format(owner_id, id)
return local_attachments

View File

@@ -5,6 +5,7 @@ import widgetUtils
import paths import paths
import time import time
import logging import logging
import shutil
from authenticator.official import AuthenticationError from authenticator.official import AuthenticationError
from . import wxUI as view from . import wxUI as view
from . import session from . import session
@@ -13,15 +14,23 @@ from .config_utils import Configuration
log = logging.getLogger("sessionmanager.sessionManager") log = logging.getLogger("sessionmanager.sessionManager")
class sessionManagerController(object): class sessionManagerController(object):
def __init__(self): def __init__(self, starting=True):
super(sessionManagerController, self).__init__() super(sessionManagerController, self).__init__()
log.debug("Setting up the session manager.") log.debug("Setting up the session manager.")
if starting:
title=_("Select an account")
else:
title = _("Manage accounts")
self.view = view.sessionManagerWindow(starting=starting, title=title)
widgetUtils.connect_event(self.view.new, widgetUtils.BUTTON_PRESSED, self.manage_new_account)
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.remove)
self.fill_list() self.fill_list()
if not hasattr(self, "session"): if len(self.sessions) == 0:
log.debug("the session list is empty, creating a new one...") log.debug("the session list is empty, creating a new one...")
self.manage_new_account() self.manage_new_account()
def fill_list(self): def fill_list(self):
self.sessions = []
log.debug("Filling the session list...") log.debug("Filling the session list...")
for i in os.listdir(paths.config_path()): for i in os.listdir(paths.config_path()):
if os.path.isdir(os.path.join(paths.config_path(), i)): if os.path.isdir(os.path.join(paths.config_path(), i)):
@@ -29,12 +38,10 @@ class sessionManagerController(object):
config_test = Configuration(os.path.join(paths.config_path(), i, "session.conf")) config_test = Configuration(os.path.join(paths.config_path(), i, "session.conf"))
name = config_test["vk"]["user"] name = config_test["vk"]["user"]
if name != "" and config_test["vk"]["password"] != "": if name != "" and config_test["vk"]["password"] != "":
self.session = i self.sessions.append((i, name))
s = session.vkSession(self.session) self.view.list.insert_item(False, *[name])
s.get_configuration()
session.sessions[self.session] = s
def manage_new_account(self): def manage_new_account(self, *args, **kwargs):
if view.new_account_dialog() == widgetUtils.YES: if view.new_account_dialog() == widgetUtils.YES:
location = (str(time.time())[-6:]) location = (str(time.time())[-6:])
log.debug("Creating session in the %s path" % (location,)) log.debug("Creating session in the %s path" % (location,))
@@ -42,11 +49,12 @@ class sessionManagerController(object):
path = os.path.join(paths.config_path(), location) path = os.path.join(paths.config_path(), location)
if not os.path.exists(path): if not os.path.exists(path):
os.mkdir(path) os.mkdir(path)
s.get_configuration() s.get_configuration(True)
self.get_authorisation(s) self.get_authorisation(s)
session.sessions[location] = s name = s.settings["vk"]["user"]
else: self.sessions.append((location, name))
sys.exit() self.view.list.insert_item(False, *[name])
self.modified = True
def get_authorisation(self, c): def get_authorisation(self, c):
log.debug("Starting the authorisation process...") log.debug("Starting the authorisation process...")
@@ -59,4 +67,30 @@ class sessionManagerController(object):
except AuthenticationError: except AuthenticationError:
c.settings["vk"]["password"] = "" c.settings["vk"]["password"] = ""
c.settings["vk"]["user"] c.settings["vk"]["user"]
return self.get_authorisation(c) return self.get_authorisation(c)
def do_ok(self):
selected_session = self.sessions[self.view.list.get_selected()]
self.session = selected_session[0]
self.session = session.vkSession(self.session)
self.session.get_configuration()
session.sessions[selected_session[1]] = self.session
def show(self):
if len(self.sessions) > 1:
answer = self.view.get_response()
else:
answer = widgetUtils.OK
if answer == widgetUtils.OK:
self.do_ok()
else:
sys.exit()
self.view.destroy()
def remove(self, *args, **kwargs):
if self.view.remove_account_dialog() == widgetUtils.YES:
selected_session = self.sessions[self.view.list.get_selected()]
shutil.rmtree(path=os.path.join(paths.config_path(), selected_session[0]), ignore_errors=True)
self.sessions.remove(selected_session)
self.view.list.remove_item(self.view.list.get_selected())
self.modified = True

View File

@@ -72,4 +72,22 @@ def clean_text(text):
""" Clean text, removing all unneeded HTMl and converting HTML represented characters in their unicode counterparts.""" """ Clean text, removing all unneeded HTMl and converting HTML represented characters in their unicode counterparts."""
text = detect_users(text) text = detect_users(text)
text = html.unescape(text) text = html.unescape(text)
return text return text
def transform_audio_url(url):
""" Transforms the URL offered by VK to the unencrypted stream so we can still play it.
This function will be updated every time VK decides to change something in their Audio API'S.
Changelog:
30/04/2019: Re-enabled old methods as VK changed everything as how it was working on 16.04.2019.
17.04.2019: Updated function. Now it is not required to strip anything, just replacing /index.m3u8 with .mp3 should be enough.
16.04.2019: Implemented this function. For now it replaces /index.m3u8 by .mp3, also removes the path component before "/audios" if the URL contains the word /audios, or the last path component before the filename if doesn't.
"""
if "vkuseraudio.net" not in url and "index.m3u8" not in url:
return url
url = url.replace("/index.m3u8", ".mp3")
parts = url.split("/")
if "/audios" not in url:
url = url.replace("/"+parts[-2], "")
else:
url = url.replace("/"+parts[-3], "")
return url

View File

@@ -19,7 +19,7 @@ class VkApi(vk_api.VkApi):
def __init__(self, login=None, password=None, token=None, secret=None, device_id=None, def __init__(self, login=None, password=None, token=None, secret=None, device_id=None,
auth_handler=None, captcha_handler=None, auth_handler=None, captcha_handler=None,
config=jconfig.Config, config_filename='vk_config.v2.json', config=jconfig.Config, config_filename='vk_config.v2.json',
api_version='5.92', app_id=2685278, scope=DEFAULT_USER_SCOPE, api_version='5.101', app_id=2685278, scope=DEFAULT_USER_SCOPE,
client_secret='lxhD8OD7dMsqtXIm5IUY'): client_secret='lxhD8OD7dMsqtXIm5IUY'):
self.login = login self.login = login

View File

@@ -36,4 +36,39 @@ class newSessionDialog(widgetUtils.BaseDialog):
return self.email.GetValue() return self.email.GetValue()
def get_password(self): def get_password(self):
return self.passw.GetValue() return self.passw.GetValue()
class sessionManagerWindow(widgetUtils.BaseDialog):
def __init__(self, title, starting=True):
super(sessionManagerWindow, self).__init__(parent=None, title=title, size=wx.DefaultSize)
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(panel, -1, _(u"Accounts list"), size=wx.DefaultSize)
listSizer = wx.BoxSizer(wx.HORIZONTAL)
self.list = widgetUtils.list(panel, _("Account"), style=wx.LC_SINGLE_SEL|wx.LC_REPORT)
listSizer.Add(label, 0, wx.ALL, 5)
listSizer.Add(self.list.list, 0, wx.ALL, 5)
sizer.Add(listSizer, 0, wx.ALL, 5)
self.new = wx.Button(panel, -1, _("New account"), size=wx.DefaultSize)
self.remove = wx.Button(panel, -1, _(u"Remove account"))
if starting:
id_ok = wx.ID_OK
else:
id_ok = wx.ID_CANCEL
ok = wx.Button(panel, id_ok, size=wx.DefaultSize)
ok.SetDefault()
if starting:
cancel = wx.Button(panel, wx.ID_CANCEL, size=wx.DefaultSize)
self.SetAffirmativeId(id_ok)
buttons = wx.BoxSizer(wx.HORIZONTAL)
buttons.Add(self.new, 0, wx.ALL, 5)
buttons.Add(ok, 0, wx.ALL, 5)
if starting:
buttons.Add(cancel, 0, wx.ALL, 5)
sizer.Add(buttons, 0, wx.ALL, 5)
panel.SetSizer(sizer)
min = sizer.CalcMin()
self.SetClientSize(min)
def remove_account_dialog(self):
return wx.MessageDialog(self, _("Do you really want to delete this account?"), _("Remove account"), wx.YES_NO).ShowModal()

View File

@@ -17,8 +17,8 @@ from sound_lib import output, input
log = logging.getLogger("sound") log = logging.getLogger("sound")
def recode_audio(filename, quality=4.5): def recode_audio(filename, quality=10):
subprocess.call(r'"%s" -q %r "%s"' % (os.path.join(paths.app_path(), 'oggenc2.exe'), quality, filename)) subprocess.call(r'"%s" --downmix -q %r "%s"' % (os.path.join(paths.app_path(), 'oggenc2.exe'), quality, filename))
def get_recording(filename): def get_recording(filename):
# try: # try:

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import sys
import application import application
import platform import platform
import logging import logging
@@ -9,6 +10,9 @@ from .wxUpdater import *
logger = logging.getLogger("updater") logger = logging.getLogger("updater")
def do_update(update_type="stable"): def do_update(update_type="stable"):
# Updates cannot be performed in the source code version of Socializer.
if hasattr(sys, "frozen") == False:
return
if update_type == "stable": if update_type == "stable":
endpoint = application.update_stable_url endpoint = application.update_stable_url
version = application.version version = application.version

View File

@@ -5,6 +5,7 @@
""" """
from .dialogs.attach import * from .dialogs.attach import *
from .dialogs.audioRecorder import * from .dialogs.audioRecorder import *
from .dialogs.blacklist import *
from .dialogs.postCreation import * from .dialogs.postCreation import *
from .dialogs.postDisplay import * from .dialogs.postDisplay import *
from .dialogs.configuration import * from .dialogs.configuration import *

View File

@@ -41,7 +41,7 @@ class attachDialog(widgetUtils.BaseDialog):
def get_image(self): def get_image(self):
openFileDialog = wx.FileDialog(self, _("Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) openFileDialog = wx.FileDialog(self, _("Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL: if openFileDialog.ShowModal() == wx.ID_CANCEL:
return None return (None, None)
dsc = self.ask_description() dsc = self.ask_description()
return (openFileDialog.GetPath(), dsc) return (openFileDialog.GetPath(), dsc)

View File

@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import wx
import widgetUtils
class blacklistDialog(widgetUtils.BaseDialog):
def __init__(self):
super(blacklistDialog, self).__init__(parent=None, title=_("blacklist"))
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
box1 = wx.StaticBoxSizer(parent=panel, orient=wx.HORIZONTAL, label=_("blocked users"))
self.persons = widgetUtils.list(panel, _("User"), style=wx.LC_REPORT)
box1.Add(self.persons.list, 0, wx.ALL, 5)
sizer.Add(box1, 0, wx.ALL, 5)
self.unblock = wx.Button(panel, wx.NewId(), _("Unblock"))
sizer.Add(self.unblock, 0, wx.ALL, 5)
close = wx.Button(panel, wx.ID_CLOSE)
sizer.Add(close, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())

View File

@@ -4,9 +4,31 @@ import wx
import widgetUtils import widgetUtils
class general(wx.Panel, widgetUtils.BaseDialog): class general(wx.Panel, widgetUtils.BaseDialog):
def __init__(self, panel): def __init__(self, panel, languages):
super(general, self).__init__(panel) super(general, self).__init__(panel)
sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL)
langBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Language"))
self.language = wx.ListBox(langBox.GetStaticBox(), wx.NewId(), choices=languages)
self.language.SetSize(self.language.GetBestSize())
langBox.Add(self.language, 0, wx.ALL, 5)
sizer.Add(langBox, 0, wx.ALL, 5)
self.load_images = wx.CheckBox(self, wx.NewId(), _("Load images in posts"))
sizer.Add(self.load_images, 0, wx.ALL, 5)
self.use_proxy = wx.CheckBox(self, wx.NewId(), _("Use proxy"))
sizer.Add(self.use_proxy, 0, wx.ALL, 5)
lbl4 = wx.StaticText(self, wx.NewId(), _("Update channel"))
self.update_channel = wx.ComboBox(self, wx.NewId(), choices=[_("Stable"), _("Alpha")], value=_("Native"), style=wx.CB_READONLY)
box4 = wx.BoxSizer(wx.HORIZONTAL)
box4.Add(lbl4, 0, wx.ALL, 5)
box4.Add(self.update_channel, 0, wx.ALL, 5)
sizer.Add(box4, 0, wx.ALL, 5)
self.SetSizer(sizer)
class buffers(wx.Panel, widgetUtils.BaseDialog):
def __init__(self, panel):
super(buffers, self).__init__(panel)
sizer = wx.BoxSizer(wx.VERTICAL)
lbl1 = wx.StaticText(self, wx.NewId(), _("Number of items to load for newsfeed and wall buffers (maximun 100)")) lbl1 = wx.StaticText(self, wx.NewId(), _("Number of items to load for newsfeed and wall buffers (maximun 100)"))
self.wall_buffer_count = wx.SpinCtrl(self, wx.NewId()) self.wall_buffer_count = wx.SpinCtrl(self, wx.NewId())
self.wall_buffer_count.SetRange(1, 100) self.wall_buffer_count.SetRange(1, 100)
@@ -21,15 +43,12 @@ class general(wx.Panel, widgetUtils.BaseDialog):
box3.Add(lbl3, 0, wx.ALL, 5) box3.Add(lbl3, 0, wx.ALL, 5)
box3.Add(self.video_buffers_count, 0, wx.ALL, 5) box3.Add(self.video_buffers_count, 0, wx.ALL, 5)
sizer.Add(box3, 0, wx.ALL, 5) sizer.Add(box3, 0, wx.ALL, 5)
self.load_images = wx.CheckBox(self, wx.NewId(), _("Load images in posts")) lbl4 = wx.StaticText(self, wx.NewId(), _("Number of items to load in conversation buffers (maximun 200)"))
sizer.Add(self.load_images, 0, wx.ALL, 5) self.chat_buffers_count = wx.SpinCtrl(self, wx.NewId())
self.use_proxy = wx.CheckBox(self, wx.NewId(), _("Use proxy")) self.chat_buffers_count.SetRange(1, 200)
sizer.Add(self.use_proxy, 0, wx.ALL, 5)
lbl4 = wx.StaticText(self, wx.NewId(), _("Update channel"))
self.update_channel = wx.ComboBox(self, wx.NewId(), choices=[_("Stable"), _("Alpha")], value=_("Native"), style=wx.CB_READONLY)
box4 = wx.BoxSizer(wx.HORIZONTAL) box4 = wx.BoxSizer(wx.HORIZONTAL)
box4.Add(lbl4, 0, wx.ALL, 5) box4.Add(lbl4, 0, wx.ALL, 5)
box4.Add(self.update_channel, 0, wx.ALL, 5) box4.Add(self.chat_buffers_count, 0, wx.ALL, 5)
sizer.Add(box4, 0, wx.ALL, 5) sizer.Add(box4, 0, wx.ALL, 5)
self.SetSizer(sizer) self.SetSizer(sizer)
@@ -41,10 +60,6 @@ class chat(wx.Panel, widgetUtils.BaseDialog):
sizer.Add(self.notify_online, 0, wx.ALL, 5) sizer.Add(self.notify_online, 0, wx.ALL, 5)
self.notify_offline = wx.CheckBox(self, wx.NewId(), _("Show notifications when users are offline")) self.notify_offline = wx.CheckBox(self, wx.NewId(), _("Show notifications when users are offline"))
sizer.Add(self.notify_offline, 0, wx.ALL, 5) sizer.Add(self.notify_offline, 0, wx.ALL, 5)
self.open_unread_conversations = wx.CheckBox(self, wx.NewId(), _("Open unread conversations at startup"))
sizer.Add(self.open_unread_conversations, 0, wx.ALL, 5)
self.automove_to_conversations = wx.CheckBox(self, wx.NewId(), _("Move focus to new conversations"))
sizer.Add(self.automove_to_conversations, 0, wx.ALL, 5)
lbl = wx.StaticText(self, wx.NewId(), _("Notification type")) lbl = wx.StaticText(self, wx.NewId(), _("Notification type"))
self.notifications = wx.ComboBox(self, wx.NewId(), choices=[_("Native"), _("Custom"),], value=_("Native"), style=wx.CB_READONLY) self.notifications = wx.ComboBox(self, wx.NewId(), choices=[_("Native"), _("Custom"),], value=_("Native"), style=wx.CB_READONLY)
nbox = wx.BoxSizer(wx.HORIZONTAL) nbox = wx.BoxSizer(wx.HORIZONTAL)
@@ -65,6 +80,48 @@ class loadAtStartup(wx.Panel, widgetUtils.BaseDialog):
sizer.Add(self.communities, 0, wx.ALL, 5) sizer.Add(self.communities, 0, wx.ALL, 5)
self.SetSizer(sizer) self.SetSizer(sizer)
class sound(wx.Panel, widgetUtils.BaseDialog):
def __init__(self, panel, input_devices, output_devices, soundpacks):
super(sound, self).__init__(panel)
sizer = wx.BoxSizer(wx.VERTICAL)
output_label = wx.StaticText(self, wx.NewId(), _("Output device"))
self.output = wx.ComboBox(self, wx.NewId(), choices=output_devices, style=wx.CB_READONLY)
self.output.SetSize(self.output.GetBestSize())
outputBox = wx.BoxSizer(wx.HORIZONTAL)
outputBox.Add(output_label, 0, wx.ALL, 5)
outputBox.Add(self.output, 0, wx.ALL, 5)
sizer.Add(outputBox, 0, wx.ALL, 5)
input_label = wx.StaticText(self, wx.NewId(), _("Input device"))
self.input = wx.ComboBox(self, wx.NewId(), choices=input_devices, style=wx.CB_READONLY)
self.input.SetSize(self.input.GetBestSize())
inputBox = wx.BoxSizer(wx.HORIZONTAL)
inputBox.Add(input_label, 0, wx.ALL, 5)
inputBox.Add(self.input, 0, wx.ALL, 5)
sizer.Add(inputBox, 0, wx.ALL, 5)
# soundBox = wx.BoxSizer(wx.VERTICAL)
# soundpack_label = wx.StaticText(self, wx.NewId(), _(u"Sound pack"))
# self.soundpack = wx.ComboBox(self, -1, choices=soundpacks, style=wx.CB_READONLY)
# self.soundpack.SetSize(self.soundpack.GetBestSize())
# soundBox.Add(soundpack_label, 0, wx.ALL, 5)
# soundBox.Add(self.soundpack, 0, wx.ALL, 5)
# sizer.Add(soundBox, 0, wx.ALL, 5)
self.SetSizer(sizer)
def on_keypress(self, event, *args, **kwargs):
""" Invert movement of up and down arrow keys when dealing with a wX Slider.
See https://github.com/manuelcortez/TWBlue/issues/261
and http://trac.wxwidgets.org/ticket/2068
"""
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
return self.volumeCtrl.SetValue(self.volumeCtrl.GetValue()+1)
elif keycode == wx.WXK_DOWN:
return self.volumeCtrl.SetValue(self.volumeCtrl.GetValue()-1)
event.Skip()
def get(self, control):
return getattr(self, control).GetStringSelection()
class configurationDialog(widgetUtils.BaseDialog): class configurationDialog(widgetUtils.BaseDialog):
def __init__(self, title): def __init__(self, title):
@@ -73,11 +130,15 @@ class configurationDialog(widgetUtils.BaseDialog):
self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer = wx.BoxSizer(wx.VERTICAL)
self.notebook = wx.Notebook(self.panel) self.notebook = wx.Notebook(self.panel)
def create_general(self): def create_general(self, languages):
self.general = general(self.notebook) self.general = general(self.notebook, languages)
self.notebook.AddPage(self.general, _("General")) self.notebook.AddPage(self.general, _("General"))
self.general.SetFocus() self.general.SetFocus()
def create_buffers(self):
self.buffers = buffers(self.notebook)
self.notebook.AddPage(self.buffers, _("Buffer settings"))
def create_chat(self): def create_chat(self):
self.chat = chat(self.notebook) self.chat = chat(self.notebook)
self.notebook.AddPage(self.chat, _("Chat settings")) self.notebook.AddPage(self.chat, _("Chat settings"))
@@ -86,6 +147,10 @@ class configurationDialog(widgetUtils.BaseDialog):
self.startup = loadAtStartup(self.notebook) self.startup = loadAtStartup(self.notebook)
self.notebook.AddPage(self.startup, _("Optional buffers")) self.notebook.AddPage(self.startup, _("Optional buffers"))
def create_sound(self, input_devices, output_devices, soundpacks):
self.sound = sound(self.notebook, input_devices, output_devices, soundpacks)
self.notebook.AddPage(self.sound, _("Sound settings"))
def realize(self): def realize(self):
self.sizer.Add(self.notebook, 0, wx.ALL, 5) self.sizer.Add(self.notebook, 0, wx.ALL, 5)
ok_cancel_box = wx.BoxSizer(wx.HORIZONTAL) ok_cancel_box = wx.BoxSizer(wx.HORIZONTAL)

View File

@@ -91,7 +91,7 @@ class createPostDialog(createTextMessage):
self.SetClientSize(self.mainBox.CalcMin()) self.SetClientSize(self.mainBox.CalcMin())
class createCommentDialog(createTextMessage): class createCommentDialog(createTextMessage):
def createControls(self, title, message, text): def createControls(self, title, message, text, **kwargs):
self.mainBox = wx.BoxSizer(wx.VERTICAL) self.mainBox = wx.BoxSizer(wx.VERTICAL)
self.createTextArea(message, text) self.createTextArea(message, text)
self.mainBox.Add(self.textBox, 0, wx.ALL, 5) self.mainBox.Add(self.textBox, 0, wx.ALL, 5)
@@ -117,7 +117,55 @@ class createCommentDialog(createTextMessage):
self.panel.SetSizer(self.mainBox) self.panel.SetSizer(self.mainBox)
self.SetTitle(title) self.SetTitle(title)
def __init__(self, title, message, text): def __init__(self, title, message, text, *args, **kwargs):
super(createCommentDialog, self).__init__() super(createCommentDialog, self).__init__()
self.createControls(message, title, text) self.createControls(message, title, text, **kwargs)
self.SetClientSize(self.mainBox.CalcMin()) self.SetClientSize(self.mainBox.CalcMin())
self.SetTitle(title)
class createTopicDialog(createCommentDialog):
def createTextArea(self, message="", text="", topic_title=""):
self.panel = wx.Panel(self)
label = wx.StaticText(self.panel, -1, _("Title"))
self.title = wx.TextCtrl(self.panel, wx.NewId(), topic_title)
label2 = wx.StaticText(self.panel, -1, _("Message"))
self.text = wx.TextCtrl(self.panel, -1, text, size=(439, -1), style=wx.TE_MULTILINE)
self.title.SetFocus()
self.textBox = wx.BoxSizer(wx.VERTICAL)
titleb = wx.BoxSizer(wx.HORIZONTAL)
titleb.Add(label, 0, wx.ALL, 5)
titleb.Add(self.title, 0, wx.ALL, 5)
self.textBox.Add(titleb, 0, wx.ALL, 5)
textb = wx.BoxSizer(wx.HORIZONTAL)
textb.Add(label2, 0, wx.ALL, 5)
textb.Add(self.text, 0, wx.ALL, 5)
self.textBox.Add(textb, 0, wx.ALL, 5)
def createControls(self, title, message, text, topic_title):
self.mainBox = wx.BoxSizer(wx.VERTICAL)
self.createTextArea(message, text, topic_title)
self.mainBox.Add(self.textBox, 0, wx.ALL, 5)
self.attach = wx.Button(self.panel, -1, _("Attach"), size=wx.DefaultSize)
self.mention = wx.Button(self.panel, wx.NewId(), _("Tag a friend"))
self.spellcheck = wx.Button(self.panel, -1, _("Spelling &correction"), size=wx.DefaultSize)
self.translateButton = wx.Button(self.panel, -1, _("&Translate message"), size=wx.DefaultSize)
self.okButton = wx.Button(self.panel, wx.ID_OK, _("Send"), size=wx.DefaultSize)
self.okButton.SetDefault()
cancelButton = wx.Button(self.panel, wx.ID_CANCEL, _("Close"), size=wx.DefaultSize)
self.buttonsBox1 = wx.BoxSizer(wx.HORIZONTAL)
self.buttonsBox1.Add(self.attach, 0, wx.ALL, 10)
self.buttonsBox1.Add(self.mention, 0, wx.ALL, 10)
self.buttonsBox1.Add(self.spellcheck, 0, wx.ALL, 10)
self.buttonsBox1.Add(self.translateButton, 0, wx.ALL, 10)
self.mainBox.Add(self.buttonsBox1, 0, wx.ALL, 10)
self.ok_cancelSizer = wx.BoxSizer(wx.HORIZONTAL)
self.ok_cancelSizer.Add(self.okButton, 0, wx.ALL, 10)
self.ok_cancelSizer.Add(cancelButton, 0, wx.ALL, 10)
self.mainBox.Add(self.ok_cancelSizer)
selectId = wx.NewId()
self.Bind(wx.EVT_MENU, self.onSelect, id=selectId)
self.accel_tbl = wx.AcceleratorTable([
(wx.ACCEL_CTRL, ord('A'), selectId),])
self.SetAcceleratorTable(self.accel_tbl)
self.panel.SetSizer(self.mainBox)

View File

@@ -40,7 +40,7 @@ class displayBasicPost(widgetUtils.BaseDialog):
def create_comments_list(self): def create_comments_list(self):
lbl = wx.StaticText(self.panel, -1, _("Comments")) lbl = wx.StaticText(self.panel, -1, _("Comments"))
self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), _("replies"), style=wx.LC_REPORT) self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), style=wx.LC_REPORT)
self.reply = wx.Button(self.panel, -1, _("Reply to comment")) self.reply = wx.Button(self.panel, -1, _("Reply to comment"))
self.reply.Enable(False) self.reply.Enable(False)
box = wx.BoxSizer(wx.HORIZONTAL) box = wx.BoxSizer(wx.HORIZONTAL)
@@ -170,22 +170,12 @@ class displayComment(displayBasicPost):
self.sizer.Add(likes_box, 0, wx.ALL, 5) self.sizer.Add(likes_box, 0, wx.ALL, 5)
actions_box = self.create_action_buttons() actions_box = self.create_action_buttons()
self.sizer.Add(actions_box, 0, wx.ALL, 5) self.sizer.Add(actions_box, 0, wx.ALL, 5)
comments_box = self.create_comments_list()
self.sizer.Add(comments_box, 0, wx.ALL, 5)
self.sizer.Add(self.create_dialog_buttons()) self.sizer.Add(self.create_dialog_buttons())
self.done() self.done()
def create_comments_list(self):
lbl = wx.StaticText(self.panel, -1, _("Replies"))
self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), _("Replies"), style=wx.LC_REPORT)
box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl, 0, wx.ALL, 5)
box.Add(self.comments.list, 0, wx.ALL, 5)
return box
def create_action_buttons(self, comment=True): def create_action_buttons(self, comment=True):
self.like = wx.Button(self.panel, -1, _("&Like")) self.like = wx.Button(self.panel, -1, _("&Like"))
self.reply = wx.Button(self.panel, -1, _("Reply to thread")) self.reply = wx.Button(self.panel, -1, _("Reply"))
if comment: self.comment = wx.Button(self.panel, -1, _("Add comment")) if comment: self.comment = wx.Button(self.panel, -1, _("Add comment"))
box = wx.BoxSizer(wx.HORIZONTAL) box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(self.like, 0, wx.ALL, 5) box.Add(self.like, 0, wx.ALL, 5)
@@ -221,6 +211,7 @@ class displayTopic(displayBasicPost):
def create_comments_list(self): def create_comments_list(self):
lbl = wx.StaticText(self.panel, -1, _("Posts")) lbl = wx.StaticText(self.panel, -1, _("Posts"))
self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), style=wx.LC_REPORT) self.comments = widgetUtils.list(self.panel, _("User"), _("Comment"), _("Date"), _("Likes"), style=wx.LC_REPORT)
self.load_more_comments = wx.Button(self.panel, wx.NewId(), _("Load previous comments"))
self.reply = wx.Button(self.panel, -1, _("Reply")) self.reply = wx.Button(self.panel, -1, _("Reply"))
box = wx.BoxSizer(wx.HORIZONTAL) box = wx.BoxSizer(wx.HORIZONTAL)
box.Add(lbl, 0, wx.ALL, 5) box.Add(lbl, 0, wx.ALL, 5)

View File

@@ -14,7 +14,7 @@ def text_size(wxObject, chars):
(x, y) = dc.GetMultiLineTextExtent("0"*chars) (x, y) = dc.GetMultiLineTextExtent("0"*chars)
return (x, -1) return (x, -1)
class mainInfo(wx.Panel): class baseTab(wx.Panel):
""" Panel to store main user information in a profile viewer.""" """ Panel to store main user information in a profile viewer."""
def get(self, control): def get(self, control):
@@ -40,6 +40,8 @@ class mainInfo(wx.Panel):
def disable(self, control): def disable(self, control):
getattr(self, control).Enable(False) getattr(self, control).Enable(False)
class mainInfo(baseTab):
def __init__(self, panel): def __init__(self, panel):
super(mainInfo, self).__init__(panel) super(mainInfo, self).__init__(panel)
sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL)
@@ -68,6 +70,22 @@ class mainInfo(wx.Panel):
sizerLastSeen.Add(self.last_seen, 0, wx.ALL, 5) sizerLastSeen.Add(self.last_seen, 0, wx.ALL, 5)
sizer.Add(sizerLastSeen, 0, wx.ALL, 5) sizer.Add(sizerLastSeen, 0, wx.ALL, 5)
lblMobilePhone = wx.StaticText(self, wx.NewId(), _("Mobile phone"))
self.mobile_phone = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.mobile_phone.Enable(False)
sizerMobilePhone = wx.BoxSizer(wx.HORIZONTAL)
sizerMobilePhone.Add(lblMobilePhone, 0, wx.ALL, 5)
sizerMobilePhone.Add(self.mobile_phone, 0, wx.ALL, 5)
sizer.Add(sizerMobilePhone, 0, wx.ALL, 5)
lblHomePhone = wx.StaticText(self, wx.NewId(), _("Home phone"))
self.home_phone = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.home_phone.Enable(False)
sizerHomePhone = wx.BoxSizer(wx.HORIZONTAL)
sizerHomePhone.Add(lblHomePhone, 0, wx.ALL, 5)
sizerHomePhone.Add(self.home_phone, 0, wx.ALL, 5)
sizer.Add(sizerHomePhone, 0, wx.ALL, 5)
lblBDate = wx.StaticText(self, wx.NewId(), _("Birthdate")) lblBDate = wx.StaticText(self, wx.NewId(), _("Birthdate"))
self.bdate = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE) self.bdate = wx.TextCtrl(self, wx.NewId(), style=wx.TE_READONLY|wx.TE_MULTILINE)
self.bdate.Enable(False) self.bdate.Enable(False)

View File

@@ -4,7 +4,9 @@ from __future__ import unicode_literals
import languageHandler import languageHandler
import paths import paths
import wx import wx
import wx.lib.mixins.listctrl as listmix
from builtins import range from builtins import range
from pubsub import pub
toolkit = "wx" toolkit = "wx"
@@ -134,51 +136,91 @@ class mainLoopObject(wx.App):
def run(self): def run(self):
self.app.MainLoop() self.app.MainLoop()
class multiselectionBaseList(wx.ListCtrl, listmix.CheckListCtrlMixin):
def __init__(self, *args, **kwargs):
wx.ListCtrl.__init__(self, *args, **kwargs)
listmix.CheckListCtrlMixin.__init__(self)
self.Bind(wx.EVT_CHAR_HOOK, self.on_keydown)
self.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_focus)
def on_focus(self, event):
currentItem = self.GetFocusedItem()
if self.IsChecked(currentItem):
pub.sendMessage("play-sound", sound="selected.ogg")
event.Skip()
def OnCheckItem(self, index, flag):
if flag == True:
pub.sendMessage("play-sound", sound="checked.ogg")
else:
pub.sendMessage("play-sound", sound="unchecked.ogg")
def on_keydown(self, event):
if event.GetKeyCode() == wx.WXK_SPACE:
self.ToggleItem(self.GetFocusedItem())
event.Skip()
class list(object): class list(object):
def __init__(self, parent, *columns, **listArguments): def __init__(self, parent, *columns, **listArguments):
self.columns = columns self.columns = columns
self.listArguments = listArguments self.listArguments = listArguments
self.create_list(parent) self.create_list(parent)
def set_windows_size(self, column, characters_max): def set_windows_size(self, column, characters_max):
self.list.SetColumnWidth(column, characters_max*2) self.list.SetColumnWidth(column, characters_max*2)
def set_size(self): def set_size(self):
self.list.SetSize((self.list.GetBestSize()[0], 1000)) self.list.SetSize((self.list.GetBestSize()[0], 1000))
def create_list(self, parent): def create_list(self, parent):
self.list = wx.ListCtrl(parent, -1, **self.listArguments) self.list = wx.ListCtrl(parent, -1, **self.listArguments)
for i in range(0, len(self.columns)): for i in range(0, len(self.columns)):
self.list.InsertColumn(i, "%s" % (self.columns[i])) self.list.InsertColumn(i, "%s" % (self.columns[i]))
def insert_item(self, reversed, *item): def insert_item(self, reversed, *item):
""" Inserts an item on the list.""" """ Inserts an item on the list."""
if reversed == False: items = self.list.GetItemCount() if reversed == False: items = self.list.GetItemCount()
else: items = 0 else: items = 0
self.list.InsertItem(items, item[0]) self.list.InsertItem(items, item[0])
for i in range(1, len(self.columns)): for i in range(1, len(self.columns)):
self.list.SetItem(items, i, item[i]) self.list.SetItem(items, i, item[i])
def remove_item(self, pos): def remove_item(self, pos):
""" Deletes an item from the list.""" """ Deletes an item from the list."""
if pos > 0: self.list.Focus(pos-1) if pos > 0: self.list.Focus(pos-1)
self.list.DeleteItem(pos) self.list.DeleteItem(pos)
def clear(self): def clear(self):
self.list.DeleteAllItems() self.list.DeleteAllItems()
def get_selected(self): def get_selected(self):
return self.list.GetFocusedItem() return self.list.GetFocusedItem()
def select_item(self, pos): def select_item(self, pos):
self.list.Focus(pos) self.list.Focus(pos)
def get_count(self): def get_count(self):
selected = self.list.GetItemCount() selected = self.list.GetItemCount()
if selected == -1: if selected == -1:
return 0 return 0
else: else:
return selected return selected
def Enable(self, value): def Enable(self, value):
return self.list.Enable(value) return self.list.Enable(value)
class multiselectionList(list):
def create_list(self, parent):
self.list = multiselectionBaseList(parent, -1, **self.listArguments)
for i in range(0, len(self.columns)):
self.list.InsertColumn(i, "%s" % (self.columns[i]))
def get_multiple_selection(self):
selected = []
for item in range(0, self.list.GetItemCount()):
if self.list.IsChecked(item):
selected.append(item)
if len(selected) == 0 and self.list.GetFocusedItem() != -1:
selected.append(self.list.GetFocusedItem())
return selected

View File

@@ -63,4 +63,16 @@ 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() 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(): def community_no_items():
return wx.MessageDialog(None, _("There are 0 items for this community."), _("Error"), wx.ICON_ERROR).ShowModal() return wx.MessageDialog(None, _("There are 0 items for this community."), _("Error"), wx.ICON_ERROR).ShowModal()
def delete_conversation():
return wx.MessageDialog(None, _("do you really want to delete all messages of this conversation in VK?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()
def block_person(person):
return wx.MessageDialog(None, _("Are you really sure you want to block {user1_nom} from your VK account?").format(**person,), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()
def unblock_person():
return wx.MessageDialog(None, _("Are you sure you want to unblock this user?"), _("Attention"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()
def post_failed():
return wx.MessageDialog(None, _("Unfortunately, we could not send your last post or message to VK. Would you like to try again?"), _("Post failed"), style=wx.ICON_QUESTION|wx.YES_NO).ShowModal()

View File

@@ -5,22 +5,26 @@ import widgetUtils
class timelineDialog(widgetUtils.BaseDialog): class timelineDialog(widgetUtils.BaseDialog):
def __init__(self, users=[]): def __init__(self, users=[], show_selector=True):
super(timelineDialog, self).__init__(parent=None, title=_("New timeline for {0}").format(users[0],)) super(timelineDialog, self).__init__(parent=None, title=_("New timeline for {0}").format(users[0],))
panel = wx.Panel(self) panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.HORIZONTAL) sizer = wx.BoxSizer(wx.HORIZONTAL)
userLabel = wx.StaticText(panel, -1, _("User")) if show_selector:
self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0]) userLabel = wx.StaticText(panel, -1, _("User"))
self.cb.SetFocus() self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0])
userSizer = wx.BoxSizer() self.cb.SetFocus()
userSizer.Add(userLabel, 0, wx.ALL, 5) userSizer = wx.BoxSizer()
userSizer.Add(self.cb, 0, wx.ALL, 5) userSizer.Add(userLabel, 0, wx.ALL, 5)
userSizer.Add(self.cb, 0, wx.ALL, 5)
sizer.Add(userSizer, 0, wx.ALL, 5)
actionsSizer = wx.StaticBoxSizer(parent=panel, orient=wx.VERTICAL, label=_("Buffer type")) actionsSizer = wx.StaticBoxSizer(parent=panel, orient=wx.VERTICAL, label=_("Buffer type"))
self.wall = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("&Wall posts"), style=wx.RB_GROUP) self.wall = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("&Wall posts"), style=wx.RB_GROUP)
self.audio = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("Audio")) self.audio = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("Audio"))
self.video = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("Video"))
self.friends = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("Friends")) self.friends = wx.RadioButton(actionsSizer.GetStaticBox(), wx.NewId(), _("Friends"))
actionsSizer.Add(self.wall, 0, wx.ALL, 5) actionsSizer.Add(self.wall, 0, wx.ALL, 5)
actionsSizer.Add(self.audio, 0, wx.ALL, 5) actionsSizer.Add(self.audio, 0, wx.ALL, 5)
actionsSizer.Add(self.video, 0, wx.ALL, 5)
actionsSizer.Add(self.friends, 0, wx.ALL, 5) actionsSizer.Add(self.friends, 0, wx.ALL, 5)
sizer.Add(actionsSizer, 0, wx.ALL, 5) sizer.Add(actionsSizer, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _("&OK")) ok = wx.Button(panel, wx.ID_OK, _("&OK"))
@@ -39,6 +43,8 @@ class timelineDialog(widgetUtils.BaseDialog):
def get_buffer_type(self): def get_buffer_type(self):
if self.audio.GetValue() == True: if self.audio.GetValue() == True:
return "audio" return "audio"
elif self.video.GetValue() == True:
return "video"
elif self.wall.GetValue() == True: elif self.wall.GetValue() == True:
return "wall" return "wall"
elif self.friends.GetValue() == True: elif self.friends.GetValue() == True:

View File

@@ -15,6 +15,8 @@ class mainWindow(wx.Frame):
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")) self.delete_video_album = delete.Append(wx.NewId(), _("Video album"))
app_.Append(wx.NewId(), _("Delete"), delete) app_.Append(wx.NewId(), _("Delete"), delete)
self.blacklist = app_.Append(wx.NewId(), _("Blacklist"))
self.accounts = app_.Append(wx.NewId(), _("Manage accounts"))
self.settings_dialog = app_.Append(wx.NewId(), _("Preferences")) self.settings_dialog = app_.Append(wx.NewId(), _("Preferences"))
me = wx.Menu() me = wx.Menu()
profile = wx.Menu() profile = wx.Menu()
@@ -41,6 +43,8 @@ class mainWindow(wx.Frame):
self.player_previous = player.Append(wx.NewId(), _("Previous")) self.player_previous = player.Append(wx.NewId(), _("Previous"))
self.player_next = player.Append(wx.NewId(), _("Next")) self.player_next = player.Append(wx.NewId(), _("Next"))
self.player_shuffle = player.AppendCheckItem(wx.NewId(), _("Shuffle")) self.player_shuffle = player.AppendCheckItem(wx.NewId(), _("Shuffle"))
self.player_seek_left = player.Append(wx.NewId(), _("Seek backwards"))
self.player_seek_right = player.Append(wx.NewId(), _("Seek forwards"))
self.player_volume_up = player.Append(wx.NewId(), _("Volume up")) self.player_volume_up = player.Append(wx.NewId(), _("Volume up"))
self.player_volume_down = player.Append(wx.NewId(), _("Volume down")) self.player_volume_down = player.Append(wx.NewId(), _("Volume down"))
self.player_mute = player.Append(wx.NewId(), _("Mute")) self.player_mute = player.Append(wx.NewId(), _("Mute"))
@@ -65,6 +69,8 @@ class mainWindow(wx.Frame):
# 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. # 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, ord(_("P")), self.player_play.GetId()),
(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord(_("P")), self.player_play_all.GetId()), (wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord(_("P")), self.player_play_all.GetId()),
(wx.ACCEL_ALT|wx.ACCEL_SHIFT, wx.WXK_LEFT, self.player_seek_left.GetId()),
(wx.ACCEL_ALT|wx.ACCEL_SHIFT, wx.WXK_RIGHT, self.player_seek_right.GetId()),
]) ])
self.SetAcceleratorTable(self.accel_tbl) self.SetAcceleratorTable(self.accel_tbl)
@@ -129,10 +135,14 @@ class mainWindow(wx.Frame):
def advance_selection(self, forward): def advance_selection(self, forward):
self.tb.AdvanceSelection(forward) self.tb.AdvanceSelection(forward)
def about_dialog(self, *args, **kwargs): def about_dialog(self, channel="stable", *args, **kwargs):
if channel == "stable":
version = _("{version} (stable)").format(version=application.version)
else:
version = _("{version} (alpha)").format(version=application.update_next_version)
info = wx.adv.AboutDialogInfo() info = wx.adv.AboutDialogInfo()
info.SetName(application.name) info.SetName(application.name)
info.SetVersion(application.version) info.SetVersion(version)
info.SetDescription(application.description) info.SetDescription(application.description)
info.SetCopyright(application.copyright) info.SetCopyright(application.copyright)
info.SetTranslators(application.translators) info.SetTranslators(application.translators)

View File

@@ -8,112 +8,79 @@ class postMenu(wx.Menu):
def __init__(self, can_delete=False, *args, **kwargs): def __init__(self, can_delete=False, *args, **kwargs):
super(postMenu, self).__init__(*args, **kwargs) super(postMenu, self).__init__(*args, **kwargs)
self.open = wx.MenuItem(self, wx.NewId(), _("Open")) self.open = self.Append(wx.NewId(), _("Open"))
self.Append(self.open) self.like = self.Append(wx.NewId(), _("Like"))
self.like = wx.MenuItem(self, wx.NewId(), _("Like")) self.dislike = self.Append(wx.NewId(), _("Dislike"))
self.Append(self.like)
self.dislike = wx.MenuItem(self, wx.NewId(), _("Dislike"))
self.dislike.Enable(False) self.dislike.Enable(False)
self.Append(self.dislike) self.comment = self.Append(wx.NewId(), _("Add comment"))
self.comment = wx.MenuItem(self, wx.NewId(), _("Add comment"))
self.Append(self.comment)
if can_delete: if can_delete:
self.delete = wx.MenuItem(self, wx.NewId(), _("Delete")) self.delete = self.Append(wx.NewId(), _("Delete"))
self.Append(self.delete)
else: else:
self.post_in_wall = wx.MenuItem(self, wx.NewId(), _("Post to this profile")) self.post_in_wall = self.Append(wx.NewId(), _("Post to this profile"))
self.post_in_wall.Enable(False) self.post_in_wall.Enable(False)
self.Append(self.post_in_wall) self.view_profile = self.Append(wx.NewId(), _("View user profile"))
self.view_profile = wx.MenuItem(self, wx.NewId(), _("View user profile")) self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
self.Append(self.view_profile)
def create_specific_post_options(self):
self.update = wx.MenuItem(self, wx.NewId(), _("Update"))
self.Append(self.update)
self.delete = wx.MenuItem(self, wx.NewId(), _("Delete"))
self.Append(self.delete)
class audioMenu(wx.Menu): class audioMenu(wx.Menu):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(audioMenu, self).__init__(*args, **kwargs) super(audioMenu, self).__init__(*args, **kwargs)
self.open = wx.MenuItem(self, wx.NewId(), _("&Open")) self.open = self.Append(wx.NewId(), _("&Open"))
self.Append(self.open) self.play = self.Append(wx.NewId(), _("&Play"))
self.play = wx.MenuItem(self, wx.NewId(), _("&Play")) self.library = self.Append(wx.NewId(), _("&Add to library"))
self.Append(self.play) self.move = self.Append(wx.NewId(), _("Move to album"))
self.library = wx.MenuItem(self, wx.NewId(), _("&Add to library")) # self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
self.Append(self.library)
self.move = wx.MenuItem(self, wx.NewId(), _("Move to album"))
self.Append(self.move)
class peopleMenu(wx.Menu): class peopleMenu(wx.Menu):
def __init__(self, is_request=False, is_subscriber=False, *args, **kwargs): def __init__(self, is_request=False, is_subscriber=False, not_friend=False, *args, **kwargs):
super(peopleMenu, self).__init__(*args, **kwargs) super(peopleMenu, self).__init__(*args, **kwargs)
if is_request: if is_request:
self.create_request_items() self.create_request_items()
elif is_subscriber: elif is_subscriber:
self.create_subscriber_items() self.create_subscriber_items()
self.view_profile = wx.MenuItem(self, wx.NewId(), _("View profile")) self.view_profile = self.Append(wx.NewId(), _("View profile"))
self.Append(self.view_profile) self.message = self.Append(wx.NewId(), _("Send a message"))
self.message = wx.MenuItem(self, wx.NewId(), _("Send a message")) self.timeline = self.Append(wx.NewId(), _("Open timeline"))
self.Append(self.message) if not_friend == False:
self.timeline = wx.MenuItem(self, wx.NewId(), _("Open timeline")) self.common_friends = self.Append(wx.NewId(), _("View friends in common"))
self.Append(self.timeline) if is_request == False and is_subscriber == False and not_friend == False:
self.common_friends = wx.MenuItem(self, wx.NewId(), _("View friends in common")) self.decline = self.Append(wx.NewId(), _("Remove from friends"))
self.Append(self.common_friends) self.block = self.Append(wx.NewId(), _("Block"))
if is_request == False and is_subscriber == False: self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
self.decline = wx.MenuItem(self, wx.NewId(), _("Remove from friends"))
self.Append(self.decline)
def create_request_items(self): def create_request_items(self):
self.accept = wx.MenuItem(self, wx.NewId(), _("Accept")) self.accept = self.Append(wx.NewId(), _("Accept"))
self.Append(self.accept) self.decline = self.Append(wx.NewId(), _("Decline"))
self.decline = wx.MenuItem(self, wx.NewId(), _("Decline")) self.keep_as_follower = self.Append(wx.NewId(), _("Keep as follower"))
self.Append(self.decline) self.block = self.Append(wx.NewId(), _("Block"))
self.keep_as_follower = wx.MenuItem(self, wx.NewId(), _("Keep as follower"))
self.Append(self.keep_as_follower)
def create_subscriber_items(self): def create_subscriber_items(self):
self.add = wx.MenuItem(self, wx.NewId(), _("Add to friends")) self.add = self.Append(wx.NewId(), _("Add to friends"))
self.Append(self.add) self.block = self.Append(wx.NewId(), _("Block"))
class documentMenu(wx.Menu): class documentMenu(wx.Menu):
def __init__(self, added=False, *args, **kwargs): def __init__(self, added=False, *args, **kwargs):
super(documentMenu, self).__init__(*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")) self.download = self.Append(wx.NewId(), _("Download document"))
if added == True: if added == True:
self.action = self.Append(wx.NewId(), _("Remove from my documents")) self.action = self.Append(wx.NewId(), _("Remove from my documents"))
else: else:
self.action = self.Append(wx.NewId(), _("Add to my documents")) self.action = self.Append(wx.NewId(), _("Add to my documents"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
class commentMenu(wx.Menu): class commentMenu(wx.Menu):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(commentMenu, self).__init__(*args, **kwargs) super(commentMenu, self).__init__(*args, **kwargs)
self.open = wx.MenuItem(self, wx.NewId(), _("Open")) self.open = self.Append(wx.NewId(), _("Open"))
self.Append(self.open) self.like = self.Append(wx.NewId(), _("Like"))
self.like = wx.MenuItem(self, wx.NewId(), _("Like")) self.dislike = self.Append(wx.NewId(), _("Dislike"))
self.Append(self.like) self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
self.unlike = wx.MenuItem(self, -1, _("Unlike"))
self.Append(self.unlike)
def create_specific_comment_options(self):
self.delete = wx.MenuItem(self, wx.NewId(), _("Delete"))
self.Append(self.delete)
class notificationsMenu(wx.Menu):
def __init__(self):
super(notificationsMenu, self).__init__()
self.mark_as_read = wx.MenuItem(self, wx.NewId(), _("Mark as read"))
self.Append(self.mark_as_read)
class attachMenu(wx.Menu): class attachMenu(wx.Menu):
def __init__(self): def __init__(self):
super(attachMenu, self).__init__() super(attachMenu, self).__init__()
self.upload = wx.MenuItem(self, wx.NewId(), _("Upload from computer")) self.upload = self.Append(wx.NewId(), _("Upload from computer"))
self.Append(self.upload) self.add = self.Append(wx.NewId(), _("Add from VK"))
self.add = wx.MenuItem(self, wx.NewId(), _("Add from VK"))
self.Append(self.add)
class communityBufferMenu(wx.Menu): class communityBufferMenu(wx.Menu):
def __init__(self): def __init__(self):
@@ -124,4 +91,11 @@ class communityBufferMenu(wx.Menu):
self.load_audios = load.Append(wx.NewId(), _("Load audios")) self.load_audios = load.Append(wx.NewId(), _("Load audios"))
self.load_videos = load.Append(wx.NewId(), _("Load videos")) self.load_videos = load.Append(wx.NewId(), _("Load videos"))
self.load_documents = load.Append(wx.NewId(), _("Load documents")) self.load_documents = load.Append(wx.NewId(), _("Load documents"))
self.Append(wx.NewId(), _("Load"), load) self.Append(wx.NewId(), _("Load"), load)
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))
class conversationBufferMenu(wx.Menu):
def __init__(self):
super(conversationBufferMenu, self).__init__()
self.delete = self.Append(wx.NewId(), _("Delete conversation"))
self.open_in_browser = self.Append(wx.NewId(), _("Open in vk.com"))

View File

@@ -57,14 +57,14 @@ class communityTab(feedTab):
def create_post_buttons(self): def create_post_buttons(self):
self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions")) self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions"))
self.load = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Load buffer")) self.load = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Load buffer"))
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post")) self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post in group"))
self.postBox.Add(self.load, 0, wx.ALL, 5) self.postBox.Add(self.load, 0, wx.ALL, 5)
self.postBox.Add(self.post, 0, wx.ALL, 5) self.postBox.Add(self.post, 0, wx.ALL, 5)
class audioTab(homeTab): class audioTab(homeTab):
def create_list(self): def create_list(self):
self.lbl = wx.StaticText(self, wx.NewId(), _("Mu&sic")) self.lbl = wx.StaticText(self, wx.NewId(), _("Mu&sic"))
self.list = widgetUtils.list(self, *[_("Title"), _("Artist"), _("Duration")], style=wx.LC_REPORT) self.list = widgetUtils.multiselectionList(self, *[_("Title"), _("Artist"), _("Duration")], style=wx.LC_REPORT)
self.list.set_windows_size(0, 160) self.list.set_windows_size(0, 160)
self.list.set_windows_size(1, 380) self.list.set_windows_size(1, 380)
self.list.set_windows_size(2, 80) self.list.set_windows_size(2, 80)
@@ -100,9 +100,9 @@ class audioAlbumTab(audioTab):
self.postBox.Add(self.play, 0, wx.ALL, 5) self.postBox.Add(self.play, 0, wx.ALL, 5)
self.postBox.Add(self.play_all, 0, wx.ALL, 5) self.postBox.Add(self.play_all, 0, wx.ALL, 5)
class notificationsTab(homeTab): class notificationTab(homeTab):
def __init__(self, parent): def __init__(self, parent):
super(notificationsTab, self).__init__(parent=parent) super(notificationTab, self).__init__(parent=parent)
self.name = "notifications" self.name = "notifications"
def OnKeyDown(self, ev=None): def OnKeyDown(self, ev=None):
@@ -110,7 +110,8 @@ class notificationsTab(homeTab):
ev.Skip() ev.Skip()
def create_list(self): def create_list(self):
self.list = widgetUtils.list(self, *[_("Notification")], style=wx.LC_REPORT) self.lbl = wx.StaticText(self, wx.NewId(), _("Po&sts"))
self.list = widgetUtils.list(self, *[_("Notification"), _("Date")], style=wx.LC_REPORT)
self.list.set_windows_size(0, 190) self.list.set_windows_size(0, 190)
self.list.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnKeyDown) self.list.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnKeyDown)
@@ -265,7 +266,7 @@ class peopleTab(homeTab):
def create_post_buttons(self): def create_post_buttons(self):
self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions")) self.postBox = wx.StaticBoxSizer(parent=self, orient=wx.HORIZONTAL, label=_("Actions"))
self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post")) self.post = wx.Button(self.postBox.GetStaticBox(), -1, _("&Post on user's wall"))
self.new_chat = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Send message")) self.new_chat = wx.Button(self.postBox.GetStaticBox(), wx.NewId(), _("Send message"))
self.postBox.Add(self.post, 0, wx.ALL, 5) self.postBox.Add(self.post, 0, wx.ALL, 5)
self.postBox.Add(self.new_chat, 0, wx.ALL, 5) self.postBox.Add(self.new_chat, 0, wx.ALL, 5)

View File

@@ -1,4 +1,4 @@
{"current_version": "0.17", {"current_version": "0.22",
"description": ".", "description": ".",
"downloads": "downloads":
{"Windows32": "https://code.manuelcortez.net/manuelcortez/socializer/-/jobs/artifacts/v0.17/raw/socializer.zip?job=stable"}} {"Windows32": "https://code.manuelcortez.net/manuelcortez/socializer/-/jobs/artifacts/v0.22/raw/socializer.zip?job=stable"}}

View File

@@ -0,0 +1,729 @@
# this is the affix file of the de_DE Hunspell dictionary
# derived from the igerman98 dictionary
#
# Version: 20161207
#
# Copyright (C) 1998-2015 Bjoern Jacke <bjoern@j3e.de>
#
# License: GPLv2, GPLv3
# There should be a copy of both of this licenses included
# with every distribution of this dictionary. Modified
# versions using the GPL may only include the GPL
SET ISO8859-1
TRY esijanrtolcdugmphbyfvkwqxz<78><7A><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ESIJANRTOLCDUGMPHBYFVKWQXZ<58><5A><EFBFBD><EFBFBD>-.
PFX U Y 1
PFX U 0 un .
PFX V Y 1
PFX V 0 ver .
SFX F Y 35
SFX F 0 nen in
SFX F e in e
SFX F e innen e
SFX F 0 in [^i]n
SFX F 0 innen [^i]n
SFX F 0 in [^enr]
SFX F 0 innen [^enr]
SFX F 0 in [^e]r
SFX F 0 innen [^e]r
SFX F 0 in [^r]er
SFX F 0 innen [^r]er
SFX F 0 in [^e]rer
SFX F 0 innen [^e]rer
SFX F 0 in ierer
SFX F 0 innen ierer
SFX F er in [^i]erer
SFX F er innen [^i]erer
SFX F in In in
SFX F in Innen in
SFX F e In e
SFX F e Innen e
SFX F 0 In [^i]n
SFX F 0 Innen [^i]n
SFX F 0 In [^en]
SFX F 0 Innen [^en]
SFX F 0 In [^e]r
SFX F 0 Innen [^e]r
SFX F 0 In [^r]er
SFX F 0 Innen [^r]er
SFX F 0 In [^e]rer
SFX F 0 Innen [^e]rer
SFX F 0 In ierer
SFX F 0 Innen ierer
SFX F er In [^i]erer
SFX F er Innen [^i]erer
#SFX F en innen en
#SFX F en Innen en
SFX L N 12
SFX L 0 tlich n
SFX L 0 tliche n
SFX L 0 tlicher n
SFX L 0 tliches n
SFX L 0 tlichem n
SFX L 0 tlichen n
SFX L 0 lich [^n]
SFX L 0 liche [^n]
SFX L 0 licher [^n]
SFX L 0 liches [^n]
SFX L 0 lichem [^n]
SFX L 0 lichen [^n]
#SFX H N 2
#SFX H 0 heit .
#SFX H 0 heiten .
#SFX K N 2
#SFX K 0 keit .
#SFX K 0 keiten .
SFX M N 10
SFX M 0 chen [^se]
SFX M 0 chens [^se]
SFX M ass <20>sschen ass
SFX M ass <20>sschens ass
SFX M oss <20>sschen oss
SFX M oss <20>sschens oss
SFX M uss <20>sschen uss
SFX M uss <20>sschens uss
SFX M e chen e
SFX M e chens e
SFX A Y 46
SFX A 0 r e
SFX A 0 n e
SFX A 0 m e
SFX A 0 s e
SFX A 0 e [^elr]
SFX A 0 er [^elr]
SFX A 0 en [^elr]
SFX A 0 em [^elr]
SFX A 0 es [^elr]
SFX A 0 e [^e][rl]
SFX A 0 er [^e][rl]
SFX A 0 en [^e][rl]
SFX A 0 em [^e][rl]
SFX A 0 es [^e][rl]
SFX A 0 e [^u]er
SFX A 0 er [^u]er
SFX A 0 en [^u]er
SFX A 0 em [^u]er
SFX A 0 es [^u]er
SFX A er re uer
SFX A er rer uer
SFX A er ren uer
SFX A er rem uer
SFX A er res uer
SFX A 0 e [eil]el
SFX A 0 er [eil]el
SFX A 0 en [eil]el
SFX A 0 em [eil]el
SFX A 0 es [eil]el
SFX A el le [^eil]el
SFX A el ler [^eil]el
SFX A el len [^eil]el
SFX A el lem [^eil]el
SFX A el les [^eil]el
SFX A lig elig [^aeiouhlr<6C><72><EFBFBD>]lig
SFX A lig elige [^aeiouhlr<6C><72><EFBFBD>]lig
SFX A lig eliger [^aeiouhlr<6C><72><EFBFBD>]lig
SFX A lig eligen [^aeiouhlr<6C><72><EFBFBD>]lig
SFX A lig eligem [^aeiouhlr<6C><72><EFBFBD>]lig
SFX A lig eliges [^aeiouhlr<6C><72><EFBFBD>]lig
SFX A erig rig [^hi]erig
SFX A erig rige [^hi]erig
SFX A erig riger [^hi]erig
SFX A erig rigen [^hi]erig
SFX A erig rigem [^hi]erig
SFX A erig riges [^hi]erig
SFX C Y 100
SFX C 0 ere [^elr]
SFX C 0 erer [^elr]
SFX C 0 eren [^elr]
SFX C 0 erem [^elr]
SFX C 0 eres [^elr]
SFX C 0 re e
SFX C 0 rer e
SFX C 0 ren e
SFX C 0 rem e
SFX C 0 res e
SFX C 0 ere [^e][lr]
SFX C 0 erer [^e][lr]
SFX C 0 eren [^e][lr]
SFX C 0 erem [^e][lr]
SFX C 0 eres [^e][lr]
SFX C el lere el
SFX C el lerer el
SFX C el leren el
SFX C el lerem el
SFX C el leres el
SFX C er rere uer
SFX C er rerer uer
SFX C er reren uer
SFX C er rerem uer
SFX C er reres uer
SFX C 0 ere [^u]er
SFX C 0 erer [^u]er
SFX C 0 eren [^u]er
SFX C 0 erem [^u]er
SFX C 0 eres [^u]er
SFX C lig eligere [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligerer [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligeren [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligerem [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligeres [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C erig rigere [^hi]erig
SFX C erig rigerer [^hi]erig
SFX C erig rigeren [^hi]erig
SFX C erig rigerem [^hi]erig
SFX C erig rigeres [^hi]erig
SFX C 0 est [k<>suxz]
SFX C 0 este [k<>suxz]
SFX C 0 ester [k<>suxz]
SFX C 0 esten [k<>suxz]
SFX C 0 estem [k<>suxz]
SFX C 0 estes [k<>suxz]
SFX C 0 st et
SFX C 0 ste et
SFX C 0 ster et
SFX C 0 sten et
SFX C 0 stem et
SFX C 0 stes et
SFX C 0 st igt
SFX C 0 ste igt
SFX C 0 ster igt
SFX C 0 sten igt
SFX C 0 stem igt
SFX C 0 stes igt
SFX C 0 est [^i]gt
SFX C 0 este [^i]gt
SFX C 0 ester [^i]gt
SFX C 0 esten [^i]gt
SFX C 0 estem [^i]gt
SFX C 0 estes [^i]gt
SFX C 0 est [^eg]t
SFX C 0 este [^eg]t
SFX C 0 ester [^eg]t
SFX C 0 esten [^eg]t
SFX C 0 estem [^eg]t
SFX C 0 estes [^eg]t
SFX C 0 st [^k<>stxz]
SFX C 0 ste [^k<>stxz]
SFX C 0 ster [^k<>stxz]
SFX C 0 sten [^k<>stxz]
SFX C 0 stem [^k<>stxz]
SFX C 0 stes [^k<>stxz]
SFX C 0 st nd
SFX C 0 ste nd
SFX C 0 ster nd
SFX C 0 sten nd
SFX C 0 stem nd
SFX C 0 stes nd
SFX C 0 est [^n]d
SFX C 0 este [^n]d
SFX C 0 ester [^n]d
SFX C 0 esten [^n]d
SFX C 0 estem [^n]d
SFX C 0 estes [^n]d
SFX C lig eligst [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligste [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligster [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligsten [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligstem [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C lig eligstes [^aeiouhlr<6C><72><EFBFBD>]lig
SFX C erig rigst [^hi]erig
SFX C erig rigste [^hi]erig
SFX C erig rigster [^hi]erig
SFX C erig rigsten [^hi]erig
SFX C erig rigstem [^hi]erig
SFX C erig rigstes [^hi]erig
SFX E Y 1
SFX E 0 e .
SFX f Y 4
SFX f ph f ph
SFX f ph fen ph
SFX f phie fie phie
SFX f phie fien phie
SFX N Y 1
SFX N 0 n .
SFX P Y 1
SFX P 0 en .
SFX p Y 26
SFX p auf <20>ufe auf
SFX p auf <20>ufen auf
SFX p aus <20>user [hH]aus
SFX p aus <20>usern [hH]aus
SFX p arkt <20>rkte [mM]arkt
SFX p arkt <20>rkten [mM]arkt
SFX p ang <20>nge ang
SFX p ang <20>ngen ang
SFX p u<> <20><>e u<>
SFX p u<> <20><>en u<>
SFX p o<> <20><>e o<>
SFX p o<> <20><>en o<>
SFX p aum <20>ume aum
SFX p aum <20>umen aum
SFX p ag <20>ge ag
SFX p ag <20>gen ag
SFX p ug <20>ge ug
SFX p ug <20>gen ug
SFX p all <20>lle all
SFX p all <20>llen all
SFX p ass <20>sse ass
SFX p ass <20>ssen ass
SFX p uss <20>sse uss
SFX p uss <20>ssen uss
SFX p oss <20>sse oss
SFX p oss <20>ssen oss
# last ...oss rules are for swiss de_CH only - but do not affect de_DE
SFX R Y 3
SFX R 0 er [^e]
SFX R 0 ern [^e]
SFX R 0 r e
SFX S Y 1
SFX S 0 s .
SFX q Y 2
SFX q 0 se s
SFX q 0 sen s
SFX Q Y 1
SFX Q 0 ses s
#SFX Q 0 se s
#SFX Q 0 sen s
SFX T Y 1
SFX T 0 es .
SFX J Y 12
SFX J n ung [bgkp<6B>sz]eln
SFX J n ungen [bgkp<6B>sz]eln
SFX J eln lung eln
SFX J n ung ern
SFX J en ung en
SFX J eln lungen eln
SFX J n ungen ern
SFX J en ungen en
SFX J 0 ung [^n]
SFX J 0 ungen [^n]
SFX J el lung el
SFX J el lungen el
SFX B N 12
SFX B n bar e[lr]n
SFX B n bare e[lr]n
SFX B n baren e[lr]n
SFX B n barer e[lr]n
SFX B n bares e[lr]n
SFX B n barem e[lr]n
SFX B en bar en
SFX B en bare en
SFX B en baren en
SFX B en barer en
SFX B en bares en
SFX B en barem en
SFX D Y 6
SFX D 0 d n
SFX D 0 de n
SFX D 0 den n
SFX D 0 der n
SFX D 0 des n
SFX D 0 dem n
SFX W Y 5
SFX W en 0 en
SFX W n 0 [^e]n
SFX W st 0 [^s]st
SFX W t 0 sst
SFX W t 0 [^s]t
SFX I Y 16
SFX I n 0 en
SFX I eln le eln
SFX I n e eln
SFX I ern re ern
SFX I n e ern
SFX I n t e[lr]n
SFX I n t [dt]en
SFX I en t [^dimnt]en
SFX I en t eien
SFX I n t [^e]ien
SFX I n t chnen
SFX I en t [^c]h[mn]en
SFX I n t [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX I en t [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX I n e un
SFX I n t un
SFX X Y 26
SFX X n t e[lr]n
SFX X n t [dtw]en
SFX X en t eien
SFX X n t [^e]ien
SFX X en t [^ditmnw]en
SFX X n t chnen
SFX X en t [^c]h[mn]en
SFX X n t [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX X en t [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX X n t un
SFX X st 0 tst
SFX X n st e[lr]n
SFX X n st [dtw]en
SFX X en st [^dimn<6D>stwzx]en
SFX X en st eien
SFX X n st [^e]ien
SFX X n st chnen
SFX X en st [^c]h[mn]en
SFX X n st [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX X en st [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX X n st un
SFX X n st [<5B>sxz]en
SFX X n st ssen
SFX X n st schen
SFX X t st [^sz]t
SFX X t est zt
SFX Y Y 36
SFX Y n te e[lr]n
SFX Y n te [dtw]en
SFX Y en te [^dimntw]en
SFX Y en te eien
SFX Y n te [^e]ien
SFX Y n te chnen
SFX Y en te [^c]h[mn]en
SFX Y n te [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX Y en te [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX Y n test e[lr]n
SFX Y n test [dtw]en
SFX Y en test [^dimntw]en
SFX Y en test eien
SFX Y n test [^e]ien
SFX Y n test chnen
SFX Y en test [^c]h[mn]en
SFX Y n test [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX Y en test [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX Y n tet e[lr]n
SFX Y n tet [dtw]en
SFX Y en tet [^dimntw]en
SFX Y en tet eien
SFX Y n tet [^e]ien
SFX Y n tet chnen
SFX Y en tet [^c]h[mn]en
SFX Y n tet [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX Y en tet [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX Y n ten e[lr]n
SFX Y n ten [dtw]en
SFX Y en ten [^dimntw]en
SFX Y en ten eien
SFX Y n ten [^e]ien
SFX Y n ten chnen
SFX Y en ten [^c]h[mn]en
SFX Y n ten [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX Y en ten [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX Z Y 15
SFX Z 0 st [^h<>sz]
SFX Z 0 st [^c]h
SFX Z 0 st [^s]ch
SFX Z 0 est [dfkstz]
SFX Z 0 est ch
SFX Z 0 est [au]<5D>
SFX Z 0 est ie<69>
SFX Z 0 est [io]ss
SFX Z 0 t [^dt]
SFX Z 0 et [dt]
SFX Z 0 n e
SFX Z 0 en ie
SFX Z 0 en [^e]
SFX Z 0 est iess
SFX Z 0 est [au]ss
# last two ...ss rules only used for swiss de_CH - but de_DE is unaffected
SFX O Y 21
SFX O n tes e[lr]n
SFX O n tes [dtw]en
SFX O en tes [^dmntw]en
SFX O n tes chnen
SFX O en tes [^c]h[mn]en
SFX O n tes [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX O en tes [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX O n ter e[lr]n
SFX O n ter [dtw]en
SFX O en ter [^dmntw]en
SFX O n ter chnen
SFX O en ter [^c]h[mn]en
SFX O n ter [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX O en ter [a<>eilmno<6E>u<EFBFBD>r][mn]en
SFX O n tem e[lr]n
SFX O n tem [dtw]en
SFX O en tem [^dmntw]en
SFX O n tem chnen
SFX O en tem [^c]h[mn]en
SFX O n tem [^a<>ehilmno<6E>u<EFBFBD>r][mn]en
SFX O en tem [a<>eilmno<6E>u<EFBFBD>r][mn]en
REP 28
REP f ph
REP ph f
REP <20> ss
REP ss <20>
REP s ss
REP ss s
REP i ie
REP ie i
REP ee e
REP o oh
REP oh o
REP a ah
REP ah a
REP e eh
REP eh e
REP ae <20>
REP oe <20>
REP ue <20>
REP Ae <20>
REP Oe <20>
REP Ue <20>
REP d t
REP t d
REP th t
REP t th
REP r rh
REP ch k
REP k ch
#REP eee ee-E
# this one will allow "-Eltern" - Hunspell 1.1.5 bug, but CHECKSHARPS obsoletes LANG de_DE
#LANG de_DE
CHECKSHARPS
COMPOUNDBEGIN x
COMPOUNDMIDDLE y
COMPOUNDEND z
FORBIDDENWORD d
# Prefixes are allowed at the beginning of compounds,
# suffixes are allowed at the end of compounds by default:
# (prefix)?(root)+(affix)?
# Affixes with COMPOUNDPERMITFLAG may be inside of compounds.
COMPOUNDPERMITFLAG c
ONLYINCOMPOUND o
# my PSEUDOROOT h(elper) flag
NEEDAFFIX h
# forbid uppercase characters at compound word bounds
# BUT I want to take care about it myself ;-)
# CHECKCOMPOUNDCASE
KEEPCASE w
# Affixes signed with CIRCUMFIX flag may be on a word when this word also has a prefix with CIRCUMFIX flag and vice versa.
# for decapitalizing nouns with fogemorphemes
CIRCUMFIX f
# this one would make a separate dict entry "Denkmalsschutz" invalidate the
# compound of "Denkmal"+"schutz". We do not want this feature here...
# CHECKCOMPOUNDREP
# make not all possible suggestions for typos of Flicken or some rare words
NOSUGGEST n
WORDCHARS <20>-.
# - setting this to 2 decreases performance by 1/10 but is needed for "<22>l" and "ei"
# - setting this to 1 for handling Fuge-elements with dashes (Arbeits-) dash will
# be a special word but - is handled as a affix now
COMPOUNDMIN 2
# this ones are for Duden R36 (old orthography)
#CHECKCOMPOUNDPATTERN 2 #oldspell
#CHECKCOMPOUNDPATTERN ee e #oldspell
#CHECKCOMPOUNDPATTERN oo o #oldspell
# also need oo o
# this one needs to be flagable to be used for old orthography
#CHECKCOMPOUNDTRIPLE
PFX i Y 1
PFX i 0 -/coyf .
SFX j Y 3
SFX j 0 0/xoc .
SFX j 0 -/zocf .
SFX j 0 -/cz .
# Female forms for compound/Compound words:
# attention: [^e][^n] does also filter out "...er" !
SFX g Y 12
SFX g 0 innen/xyoc [^n]
SFX g en innen/xyoc en
SFX g 0 Innen/xyoc [^n]
SFX g en Innen/xyoc en
SFX g 0 innen/xyocf [^n]
SFX g en innen/xyocf en
SFX g 0 Innen/xyocf [^n]
SFX g en Innen/xyocf en
SFX g 0 innen-/cz [^n]
SFX g en innen-/cz en
SFX g 0 Innen-/cz [^n]
SFX g en Innen-/cz en
PFX k Y 2
PFX k 0 -/coxf .
PFX k 0 0/coy .
SFX e Y 2
SFX e 0 0/yoc .
SFX e 0 -/zc .
# for Uppercased end-words to prepend - and lowercase: (Tier/EPSm) (EX: Bettbez<65>ge und *-laken*)
# AND
# for lowercased end-words to prepend - and re-uppercase : (tier/EPSozm) (EX: Arbeits*-Tier*)
#PFX m A -a/co A
#PFX m a -/ a
PFX m Y 58
PFX m A -a A
PFX m B -b B
PFX m C -c C
PFX m D -d D
PFX m E -e E
PFX m F -f F
PFX m G -g G
PFX m H -h H
PFX m I -i I
PFX m J -j J
PFX m K -k K
PFX m L -l L
PFX m M -m M
PFX m N -n N
PFX m O -o O
PFX m P -p P
PFX m Q -q Q
PFX m R -r R
PFX m S -s S
PFX m T -t T
PFX m U -u U
PFX m V -v V
PFX m W -w W
PFX m X -x X
PFX m Y -y Y
PFX m Z -z Z
PFX m <20> -<2D> <20>
PFX m <20> -<2D> <20>
PFX m <20> -<2D> <20>
PFX m a -A/co a
PFX m b -B/co b
PFX m c -C/co c
PFX m d -D/co d
PFX m e -E/co e
PFX m f -F/co f
PFX m g -G/co g
PFX m h -H/co h
PFX m i -I/co i
PFX m j -J/co j
PFX m k -K/co k
PFX m l -L/co l
PFX m m -M/co m
PFX m n -N/co n
PFX m o -O/co o
PFX m p -P/co p
PFX m q -Q/co q
PFX m r -R/co r
PFX m s -S/co s
PFX m t -T/co t
PFX m u -U/co u
PFX m v -V/co v
PFX m w -W/co w
PFX m x -X/co x
PFX m y -Y/co y
PFX m z -Z/co z
PFX m <20> -<2D>/co <20>
PFX m <20> -<2D>/co <20>
PFX m <20> -<2D>/co <20>
# Decapitalizing: (not used ATM... )
# /co(f) : compound permit, in coumpount only, (decapitalizing with fogemorphemes)
#PFX l Y 29
#PFX l A a/co A
#PFX l <20> <20>/co <20>
#PFX l B b/co B
#PFX l C c/co C
#PFX l D d/co D
#PFX l E e/co E
#PFX l F f/co F
#PFX l G g/co G
#PFX l H h/co H
#PFX l I i/co I
#PFX l J j/co J
#PFX l K k/co K
#PFX l L l/co L
#PFX l M m/co M
#PFX l N n/co N
#PFX l O o/co O
#PFX l <20> <20>/co <20>
#PFX l P p/co P
#PFX l Q q/co Q
#PFX l R r/co R
#PFX l S s/co S
#PFX l T t/co T
#PFX l U u/co U
#PFX l <20> <20>/co <20>
#PFX l V v/co V
#PFX l W w/co W
#PFX l X x/co X
#PFX l Y y/co Y
#PFX l Z z/co Z
# private hunspell flags:
# --x : not for capmain (rare words)
# With "BREAK -" some wrong forms are accepted but that is needed for US-Wirtschaft etc.
# So enabling this is the lesser evil. No perfect solution found so far...
BREAK 2
BREAK -
BREAK .

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,205 @@
SET UTF-8
TRY esianrtolcdugmphbyfvkwzESIANRTOLCDUGMPHBYFVKWZ'
ICONV 1
ICONV '
NOSUGGEST !
# ordinal numbers
COMPOUNDMIN 1
# only in compounds: 1th, 2th, 3th
ONLYINCOMPOUND c
# compound rules:
# 1. [0-9]*1[0-9]th (10th, 11th, 12th, 56714th, etc.)
# 2. [0-9]*[02-9](1st|2nd|3rd|[4-9]th) (21st, 22nd, 123rd, 1234th, etc.)
COMPOUNDRULE 2
COMPOUNDRULE n*1t
COMPOUNDRULE n*mp
WORDCHARS 0123456789
PFX A Y 1
PFX A 0 re .
PFX I Y 1
PFX I 0 in .
PFX U Y 1
PFX U 0 un .
PFX C Y 1
PFX C 0 de .
PFX E Y 1
PFX E 0 dis .
PFX F Y 1
PFX F 0 con .
PFX K Y 1
PFX K 0 pro .
SFX V N 2
SFX V e ive e
SFX V 0 ive [^e]
SFX N Y 3
SFX N e ion e
SFX N y ication y
SFX N 0 en [^ey]
SFX X Y 3
SFX X e ions e
SFX X y ications y
SFX X 0 ens [^ey]
SFX H N 2
SFX H y ieth y
SFX H 0 th [^y]
SFX Y Y 1
SFX Y 0 ly .
SFX G Y 2
SFX G e ing e
SFX G 0 ing [^e]
SFX J Y 2
SFX J e ings e
SFX J 0 ings [^e]
SFX D Y 4
SFX D 0 d e
SFX D y ied [^aeiou]y
SFX D 0 ed [^ey]
SFX D 0 ed [aeiou]y
SFX T N 4
SFX T 0 st e
SFX T y iest [^aeiou]y
SFX T 0 est [aeiou]y
SFX T 0 est [^ey]
SFX R Y 4
SFX R 0 r e
SFX R y ier [^aeiou]y
SFX R 0 er [aeiou]y
SFX R 0 er [^ey]
SFX Z Y 4
SFX Z 0 rs e
SFX Z y iers [^aeiou]y
SFX Z 0 ers [aeiou]y
SFX Z 0 ers [^ey]
SFX S Y 4
SFX S y ies [^aeiou]y
SFX S 0 s [aeiou]y
SFX S 0 es [sxzh]
SFX S 0 s [^sxzhy]
SFX P Y 3
SFX P y iness [^aeiou]y
SFX P 0 ness [aeiou]y
SFX P 0 ness [^y]
SFX M Y 1
SFX M 0 's .
SFX B Y 3
SFX B 0 able [^aeiou]
SFX B 0 able ee
SFX B e able [^aeiou]e
SFX L Y 1
SFX L 0 ment .
REP 90
REP a ei
REP ei a
REP a ey
REP ey a
REP ai ie
REP ie ai
REP alot a_lot
REP are air
REP are ear
REP are eir
REP air are
REP air ere
REP ere air
REP ere ear
REP ere eir
REP ear are
REP ear air
REP ear ere
REP eir are
REP eir ere
REP ch te
REP te ch
REP ch ti
REP ti ch
REP ch tu
REP tu ch
REP ch s
REP s ch
REP ch k
REP k ch
REP f ph
REP ph f
REP gh f
REP f gh
REP i igh
REP igh i
REP i uy
REP uy i
REP i ee
REP ee i
REP j di
REP di j
REP j gg
REP gg j
REP j ge
REP ge j
REP s ti
REP ti s
REP s ci
REP ci s
REP k cc
REP cc k
REP k qu
REP qu k
REP kw qu
REP o eau
REP eau o
REP o ew
REP ew o
REP oo ew
REP ew oo
REP ew ui
REP ui ew
REP oo ui
REP ui oo
REP ew u
REP u ew
REP oo u
REP u oo
REP u oe
REP oe u
REP u ieu
REP ieu u
REP ue ew
REP ew ue
REP uff ough
REP oo ieu
REP ieu oo
REP ier ear
REP ear ier
REP ear air
REP air ear
REP w qu
REP qu w
REP z ss
REP ss z
REP shun tion
REP shun sion
REP shun cion
REP size cise

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,205 @@
SET UTF-8
TRY esianrtolcdugmphbyfvkwzESIANRTOLCDUGMPHBYFVKWZ'
ICONV 1
ICONV '
NOSUGGEST !
# ordinal numbers
COMPOUNDMIN 1
# only in compounds: 1th, 2th, 3th
ONLYINCOMPOUND c
# compound rules:
# 1. [0-9]*1[0-9]th (10th, 11th, 12th, 56714th, etc.)
# 2. [0-9]*[02-9](1st|2nd|3rd|[4-9]th) (21st, 22nd, 123rd, 1234th, etc.)
COMPOUNDRULE 2
COMPOUNDRULE n*1t
COMPOUNDRULE n*mp
WORDCHARS 0123456789
PFX A Y 1
PFX A 0 re .
PFX I Y 1
PFX I 0 in .
PFX U Y 1
PFX U 0 un .
PFX C Y 1
PFX C 0 de .
PFX E Y 1
PFX E 0 dis .
PFX F Y 1
PFX F 0 con .
PFX K Y 1
PFX K 0 pro .
SFX V N 2
SFX V e ive e
SFX V 0 ive [^e]
SFX N Y 3
SFX N e ion e
SFX N y ication y
SFX N 0 en [^ey]
SFX X Y 3
SFX X e ions e
SFX X y ications y
SFX X 0 ens [^ey]
SFX H N 2
SFX H y ieth y
SFX H 0 th [^y]
SFX Y Y 1
SFX Y 0 ly .
SFX G Y 2
SFX G e ing e
SFX G 0 ing [^e]
SFX J Y 2
SFX J e ings e
SFX J 0 ings [^e]
SFX D Y 4
SFX D 0 d e
SFX D y ied [^aeiou]y
SFX D 0 ed [^ey]
SFX D 0 ed [aeiou]y
SFX T N 4
SFX T 0 st e
SFX T y iest [^aeiou]y
SFX T 0 est [aeiou]y
SFX T 0 est [^ey]
SFX R Y 4
SFX R 0 r e
SFX R y ier [^aeiou]y
SFX R 0 er [aeiou]y
SFX R 0 er [^ey]
SFX Z Y 4
SFX Z 0 rs e
SFX Z y iers [^aeiou]y
SFX Z 0 ers [aeiou]y
SFX Z 0 ers [^ey]
SFX S Y 4
SFX S y ies [^aeiou]y
SFX S 0 s [aeiou]y
SFX S 0 es [sxzh]
SFX S 0 s [^sxzhy]
SFX P Y 3
SFX P y iness [^aeiou]y
SFX P 0 ness [aeiou]y
SFX P 0 ness [^y]
SFX M Y 1
SFX M 0 's .
SFX B Y 3
SFX B 0 able [^aeiou]
SFX B 0 able ee
SFX B e able [^aeiou]e
SFX L Y 1
SFX L 0 ment .
REP 90
REP a ei
REP ei a
REP a ey
REP ey a
REP ai ie
REP ie ai
REP alot a_lot
REP are air
REP are ear
REP are eir
REP air are
REP air ere
REP ere air
REP ere ear
REP ere eir
REP ear are
REP ear air
REP ear ere
REP eir are
REP eir ere
REP ch te
REP te ch
REP ch ti
REP ti ch
REP ch tu
REP tu ch
REP ch s
REP s ch
REP ch k
REP k ch
REP f ph
REP ph f
REP gh f
REP f gh
REP i igh
REP igh i
REP i uy
REP uy i
REP i ee
REP ee i
REP j di
REP di j
REP j gg
REP gg j
REP j ge
REP ge j
REP s ti
REP ti s
REP s ci
REP ci s
REP k cc
REP cc k
REP k qu
REP qu k
REP kw qu
REP o eau
REP eau o
REP o ew
REP ew o
REP oo ew
REP ew oo
REP ew ui
REP ui ew
REP oo ui
REP ui oo
REP ew u
REP u ew
REP oo u
REP u oo
REP u oe
REP oe u
REP u ieu
REP ieu u
REP ue ew
REP ew ue
REP uff ough
REP oo ieu
REP ieu oo
REP ier ear
REP ear ier
REP ear air
REP air ear
REP w qu
REP qu w
REP z ss
REP ss z
REP shun tion
REP shun sion
REP shun cion
REP size cise

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,106 @@
SET ISO8859-2
TRY ABCDEFGHIJKLMNOPQRSTUVWXY<58><59><EFBFBD><EFBFBD><EFBFBD>о<EFBFBD>abcdefghijklmnopqrstuvwxy
SFX A Y 13
SFX A 0 a [^aeiou]
SFX A 0 u [^aeiou]
SFX A 0 e [^aeiou]
SFX A 0 om [^aeiou]
SFX A a e a
SFX A a i a
SFX A a om a
SFX A o a o
SFX A o u o
SFX A o om o
SFX A e a e
SFX A e u e
SFX A e em e
SFX B Y 5
SFX B ti m ti
SFX B ti <20> ti
SFX B ti mo ti
SFX B ti te ti
SFX B ti u ti
SFX C Y 4
SFX C ti h ti
SFX C ti smo ti
SFX C ti ste ti
SFX C ti <20>e ti
SFX D Y 5
SFX D ti h ti
SFX D ti <20>e ti
SFX D ti smo ti
SFX D ti ste ti
SFX D ti hu ti
SFX E Y 3
SFX E ti o ti
SFX E ti li ti
SFX E ti la ti
SFX F Y 5
SFX F ti h ti
SFX F ti <20>e ti
SFX F ti smo ti
SFX F ti ste ti
SFX F iti hu ti
SFX G Y 5
SFX G ti m ti
SFX G ti <20> ti
SFX G ti mo ti
SFX G ti te ti
SFX G iti e iti
SFX H Y 6
SFX H 0 a .
SFX H 0 u .
SFX H 0 i .
SFX H 0 ih .
SFX H 0 im .
SFX H 0 e .
SFX I Y 6
SFX I 0 a .
SFX I 0 u .
SFX I 0 i .
SFX I 0 ih .
SFX I 0 ima .
SFX I 0 e .
SFX J Y 6
SFX J 0 a .
SFX J 0 u .
SFX J 0 i .
SFX J 0 ih .
SFX J 0 im .
SFX J 0 o .
SFX K Y 6
SFX K 0 a .
SFX K 0 u .
SFX K 0 i .
SFX K 0 ih .
SFX K 0 ima .
SFX K 0 o .
SFX L Y 2
SFX L 0 oj .
SFX L 0 om .
SFX M Y 4
SFX M a e a
SFX M a i a
SFX M a o a
SFX M a u a

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,28 @@
SET UTF-8
LANG sr
TRY аиоенртсвумклпјдгзбшчцхћњљжфђџАИОЕНРТСВУМКЛПЈДГЗБШЧЦХЋЊЉЖФЂЏ
KEY љњертжуиопшђж|асдфгхјклчћ|зџцвбнм|жшђ|ћшч|жчђ|ђћж|зж|љањседрфтгжхуј|јиколпч|азсџдцфвгбх|хнјмк
MAP 4
MAP цћ
MAP цч
MAP зж
MAP сш
REP 8
REP дј ђ
REP лј љ
REP нј њ
REP дж џ
REP ц с # Ако хоћу да откуцам слово „С“ могу се залетети за ознаком на тастатури и уписати „Ц“ (C)
REP п р # Ако хоћу да откуцам слово „В“ могу се залетети за ознаком и уписати „Б“ (B)
REP џ х # Ако хоћу да откуцам слово „Р“ могу се залетети за ознаком и уписати „П“ (P)
REP х н # Ако хоћу да откуцам слово „Х“ могу се залетети за ознаком и уписати „Џ“ (X)
# Ако хоћу да откуцам слово „В“ могу се залетети за ознаком и уписати „Б“ (B) (покривено KEY паром „в - б“)
ICONV 3
ICONV ҵ тц
ICONV ҥ нг
ICONV ӕ ае

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long