241 Commits

Author SHA1 Message Date
e9600fa5ec Bumped version to 0.17 2019-01-01 05:36:29 -06:00
42a5b67386 Merge branch 'master' into next 2018-12-31 11:51:33 -06:00
58e6940bad Added changes in GUI for communities 2018-12-31 11:51:13 -06:00
3b685fe164 Added rendering to audio playlists in the newsfeed buffer 2018-12-31 11:50:48 -06:00
a531e8ee19 Fixes a traceback when adding an unsupported post to db. Closes #15 2018-12-31 11:50:11 -06:00
a51a1458be Changed URL schema of issue reporter 2018-12-31 11:48:47 -06:00
f029b9034d Load communities in a buffer dedicated to them 2018-12-30 10:41:47 -06:00
7c1766825b Updated reference to latest version in readme [skip ci] 2018-12-27 13:05:04 -06:00
8ac2fa3334 Updated changelog [skip ci] 2018-12-27 12:27:51 -06:00
6c64246ca8 Fixed unresponsiveness of dialogs during updates 2018-12-27 11:30:37 -06:00
57968875f0 Modified update channel 2018-12-27 11:15:08 -06:00
009b1cddcd Fixed merge conflict 2018-12-27 11:12:48 -06:00
8f52ae6f0c Updated calls to autoupdate feature for alpha channel 2018-12-27 11:11:30 -06:00
54247b8b90 Merge branch 'next' into 'master'
Modifications to release process. Closes #14

Closes #14

See merge request manuelcortez/socializer!1
2018-12-27 18:29:46 +03:00
762fa93c23 Modifications to release process. Closes #14 2018-12-27 18:29:46 +03:00
2e025ebf20 Modify gitlab CI configuration to generate both alpha and stable versions 2018-12-27 09:19:28 -06:00
833c089a27 Added script to write data for versions in the alpha channel 2018-12-27 09:15:32 -06:00
a410c2a2f6 Removed weekly channel for now as there are no idea on how to track updates, yet 2018-12-27 09:01:07 -06:00
fae791ff71 Added update channel settings to general tab 2018-12-27 08:30:51 -06:00
729b410d63 Updater now accepts updates from the gitlab repo URL 2018-12-26 12:27:44 -06:00
b9bb17dd69 Added new update data 2018-12-26 12:24:12 -06:00
03286a44b9 Fixed a small issue in chat text controls 2018-12-25 19:08:36 -06:00
1cff350fed Added 2FA for kate's tokens, finally. Closes #13 2018-12-25 18:55:50 -06:00
f191ed42da Added oggenc2.exe to the list of requirement files 2018-12-25 17:13:38 -06:00
46ba62d346 Added support for voice messages 2018-12-24 17:54:18 -06:00
dd07501c5c Added audio recorder controller. 2018-12-24 17:53:59 -06:00
68e48205f3 Added basic interface to audio recorder dialog 2018-12-24 17:53:28 -06:00
3aaeafbfc0 Added new recording facilities to sound.py 2018-12-24 17:53:09 -06:00
a34e9637fe Chats will not be able to sent twice when pressing enter repeatedly 2018-12-24 12:52:58 -06:00
4af259ffed Added 2FA partially. #13 2018-12-24 12:32:00 -06:00
6165b80147 Updated changelog 2018-12-24 11:52:19 -06:00
33fd9c1b4d Updated requirements 2018-12-24 09:03:08 -06:00
c442aac0a9 Updated patched VK and core methods 2018-12-24 08:54:53 -06:00
081f51dfd2 Updated changelog 2018-12-24 08:53:42 -06:00
27b6d068ed Added a few comments to session 2018-12-24 08:53:28 -06:00
b4adf42644 Replaced eyed3 for mutagen for tag parsing 2018-12-24 08:52:48 -06:00
527d4670d4 Implemented two factor authentication for alternative tokens 2018-12-23 10:06:06 -06:00
17c6b7d282 Added a bug reporting feature in the help menu 2018-12-22 08:08:30 -06:00
2a729ffcc2 Avoid adding removed newsfeed posts to the database and log unhandled posts 2018-12-22 05:40:39 -06:00
3ffbf556f2 Pass user_id when retrieving video and audio albums 2018-12-22 05:39:58 -06:00
5f04ac3bee Fixed issues in get_selection() in certian buffers 2018-12-22 05:39:21 -06:00
bd05860f11 Updated changelog 2018-12-21 17:02:46 -06:00
3887dce508 Handles case when an audio object has been deleted by the user 2018-12-21 16:21:19 -06:00
651b66198f Title and artist will be taken from ID3 tags in audio files 2018-12-21 16:20:31 -06:00
77fac967bc Updated changelog 2018-12-21 08:22:18 -06:00
c8375ca138 Fixed an incorrect handling in attachments for chat messages 2018-12-21 08:18:39 -06:00
34c5824255 Started adding the new attachment dialog to chat buffers 2018-12-21 05:54:52 -06:00
abcbbe9ae2 Finished rework of attachments methods for wall posts 2018-12-21 05:27:35 -06:00
fb06df8578 Started an effort to merge the attachment dialogs in socializer. It will be possible to add both local files and files already present in VK 2018-12-20 17:46:54 -06:00
d71721ab87 Added audio uploading support in posts. Needs improvements to detect its ID3 tags 2018-12-20 17:29:23 -06:00
93e6cd36a7 Try to handle better exceptions in the chat server 2018-12-20 16:58:29 -06:00
ca3873f055 Fixed a condition that was raising a traceback when adding an audio attachment 2018-12-20 16:05:20 -06:00
ba14699dfb Updated code to handle unread messsages 2018-12-20 15:36:32 -06:00
e3dae698d9 Removed pandoc reference from Readme 2018-12-20 13:44:31 -06:00
b8eee58b01 Updated changelog 2018-12-20 13:41:42 -06:00
344d2f3dac Added very basic test 2018-12-20 11:59:35 -06:00
bc863a3345 Converts src directory in a package so unittest will work properly here 2018-12-20 11:59:10 -06:00
6ffe47b2d8 Added schedules to pipeline 2018-12-20 11:45:08 -06:00
30ecfd4370 Fixed a memory leak in the app when audio and video albums are updated 2018-12-20 08:33:16 -06:00
48e3e39514 Attempt to add two factor auth to socializer. Needs testing 2018-12-19 17:34:51 -06:00
909fd9d68c Use patched VK api only if kate tokens are enabled 2018-12-19 17:34:28 -06:00
b9ccc083ae fixed a typo 2018-12-19 17:33:40 -06:00
42549d9bb9 Re-added count for audio buffers in session settings 2018-12-19 17:31:42 -06:00
ce93a83305 Fixed localization in profiles 2018-12-19 17:31:10 -06:00
08f6e5d3d9 Updated languageHandler 2018-12-19 05:00:45 -06:00
dfa597f2d0 Added changelog as a translatable document. Copy license appropiately 2018-12-19 04:58:34 -06:00
ea917c470e attempt to add changelog and license to doc in CI built 2018-12-19 04:47:48 -06:00
945f310eae Updated changelog 2018-12-19 04:33:23 -06:00
ea005587de Chat widget now is multiline. Add new lines with shift+enter 2018-12-19 04:32:47 -06:00
eb545f3763 Reconfigure CI. Documentation now is part of the CI process 2018-12-18 17:50:02 -06:00
378d373a04 Added markdown to requirements 2018-12-18 17:45:11 -06:00
6bcbc655ed First doc integration in CI 2018-12-18 17:42:56 -06:00
8bea1859c8 Removed unneeded import 2018-12-18 17:40:37 -06:00
8b10bf7242 Improved documentation builder for integrating it in the gitlab CI proces 2018-12-18 17:36:52 -06:00
3949ae5185 Removed edit profile setting for now, as it is not implemented yet 2018-12-18 16:36:30 -06:00
ac2b9c6a1e Added set status option 2018-12-18 16:32:14 -06:00
126ec7a881 Fixed a few issues when calling update_all_buffers 2018-12-18 15:22:16 -06:00
90999fc3d6 Readded popular and suggested audios 2018-12-18 13:18:21 -06:00
9d2615c221 Added a patched version of jconfig to support non-ascii paths 2018-12-18 11:48:53 -06:00
28d5c2d5d7 Pointed out a few issues in russian translations 2018-12-18 05:53:13 -06:00
d250d3dcb6 Updated changelog 2018-12-18 05:32:41 -06:00
207e38e619 Removed old files 2018-12-18 04:23:04 -06:00
61084d6526 Update readme 2018-12-18 04:16:40 -06:00
ea15edd45c Revert CI settings to default building time 2018-12-18 04:12:14 -06:00
4c118e161b Added bs4 to the list of dependencies 2018-12-18 04:00:18 -06:00
4430aff718 Build stuff in windows servers 2018-12-18 03:55:24 -06:00
5cd8e8a834 Testing CI 2018-12-18 03:53:38 -06:00
20a01c8c52 Removes dist and build folders when done 2018-12-18 03:53:13 -06:00
0a5822e64e Added a patched version of vk_api to use kate's user agent 2018-12-17 21:55:26 -06:00
977dcb7dc3 Improvement to unread messages: Mark as unread only messages sent by another user 2018-12-17 17:47:15 -06:00
9296ef5333 authenticate properly in alternative tokens 2018-12-17 17:01:37 -06:00
49c96963f8 Build artifacts only when tags are applied 2018-12-17 01:03:25 -06:00
934744362f Change name to artifacts zip file 2018-12-17 00:59:23 -06:00
e1b79af4a5 Improved dist for CI 2018-12-17 00:56:08 -06:00
9b89612edb Fixed artifacts 2018-12-17 00:45:10 -06:00
196a965aea 3rd attempt 2018-12-17 00:39:24 -06:00
aad538ecfc Second attempt to generate artifacts 2018-12-17 00:29:12 -06:00
1c51225277 Attempt to improve artifacts 2018-12-17 00:25:28 -06:00
766879d47c Second update to CI 2018-12-17 00:13:29 -06:00
d52a7ae08c Finished CI file (needs testing) 2018-12-17 00:09:39 -06:00
803a84638e Updated CI status file 2018-12-17 00:03:36 -06:00
d163cd60f5 Updated contributions 2018-12-16 23:41:51 -06:00
ec895f3e12 Updated translation related files 2018-12-16 23:25:44 -06:00
41c9bcc6ce Updated CI config 2018-12-16 17:30:50 -06:00
325db8ab3c Added script to prepare a zipped version ofsocializer 2018-12-16 17:30:31 -06:00
f31a7b736b Added test CI file 2018-12-16 07:23:45 -06:00
c2c79ca9ec Online notification is shown onli at startup 2018-12-16 02:20:14 -06:00
0e96ed1519 Fixed actions when there are no posts in a buffer 2018-12-16 02:06:36 -06:00
d43f5f5320 Skip restricted songs from playback 2018-12-16 00:53:02 -06:00
4b51126239 Mark unread messags as read and play sound when unread messages are focused 2018-12-16 00:41:47 -06:00
a21d0f8a73 Updated changelog 2018-12-15 21:19:10 -06:00
0e83d1e39f Access to audio albums is fully restored 2018-12-15 21:11:25 -06:00
bb500779d9 Allow use of kate mobile's tokens for accessing all methods 2018-12-15 21:09:17 -06:00
815bd4b49e Updated changelog 2018-12-14 16:57:44 -06:00
619595fd65 Updated changelog 2018-12-14 16:52:46 -06:00
127207414c Added a replacement tokes as an entry point for an experiment 2018-12-14 15:31:15 -06:00
ba72e80279 Tokens will not expire in 24 hours 2018-12-14 15:30:44 -06:00
4b5d271ab4 Handles non-english charset encoding for filesystem paths 2018-12-14 15:27:20 -06:00
7f2956e47a Exclude crypt32.dll from dist 2018-12-13 17:37:13 -06:00
36a199946e Call setOnlyne every 4:40 instead of 15 minutes 2018-12-13 17:16:56 -06:00
d79f29d237 Update URL in app info 2018-12-13 17:14:14 -06:00
0d440fafa7 Minor changes 2018-12-13 16:49:30 -06:00
353a487ded fixed some issue when building a distributable file 2018-12-13 16:36:46 -06:00
a0c4ad6af4 Reads incoming chat message if the current buffer is the buffer receiving the message 2018-12-13 12:05:48 -06:00
f16576c03c Added voice messages to the list of supported attached files in chats 2018-12-13 11:48:17 -06:00
0144a5787a Reconnects the ongpoll chat server after a ReadTimeout or ConnectionError 2018-12-12 13:41:57 -06:00
ed624f5bf1 Plays a different sound when a conversation has been created 2018-12-12 12:38:01 -06:00
2699feada5 Added 'custom' notifications for chat settings 2018-12-12 12:24:05 -06:00
1affb38cd5 Replaced message_received.ogg 2018-12-12 12:23:27 -06:00
2feb5bc6ff Reverted experiment. Not working 2018-12-12 08:08:07 -06:00
2f175f5529 Added an experiment (stage 1 of 3) 2018-12-12 05:49:28 -06:00
cf4971a6c4 Started recovering the search function 2018-12-11 18:02:49 -06:00
65e253a538 Avoids trying to send a blank chat message to VK 2018-12-11 12:17:08 -06:00
5f010b68af Removed support for audio albm delete as is not supported by vk_api 2018-12-11 12:08:56 -06:00
e04d098527 Removed audio album creation as it is not supported by vk_api 2018-12-11 12:07:18 -06:00
24b5e279db Added audio albums (still not working) 2018-12-11 12:04:04 -06:00
26f4c0bcff Removed count_for_audio_buffers from config settings controller 2018-12-11 11:49:26 -06:00
b82c94bf51 Added chat settings in the config dialog 2018-12-11 11:45:38 -06:00
6f9a5ce8d2 Chat messages should be able to be send with enter in the edit box 2018-12-11 09:26:14 -06:00
e0eb0eefce Handled deleted comments properly in wall posts 2018-12-11 09:04:57 -06:00
641921537b Added 'keep as follower' for friendship requests (needs testing) 2018-12-10 17:52:01 -06:00
52f892f35f Added accepting/declining friend requests from friendship request folder by using the menu key or right mouse click 2018-12-10 17:35:36 -06:00
15e4c19f04 Removed unneeded comments 2018-12-10 14:54:54 -06:00
cca89f9260 Call to account.setOffline when closing the app to notify everyone about it 2018-12-10 13:25:30 -06:00
bbee451f2c Added support for description in photo uploading 2018-12-10 12:20:01 -06:00
51f7daba6c Updated links for readme file 2018-12-10 09:36:52 -06:00
7fa35f18e4 Clear attachments list when switching to a new message in chats 2018-12-10 02:32:57 -06:00
217765254d Updated changelog 2018-12-10 00:49:01 -06:00
c747be2743 Shows a notification when someone is onlyne or offline 2018-12-10 00:48:40 -06:00
2d60e2b461 Call to get_my_data after logging in VK 2018-12-10 00:47:25 -06:00
69cd540329 Removed count for audio buffers in config GUI 2018-12-10 00:45:56 -06:00
ad57be052e Removed audio count for buffers in config 2018-12-10 00:03:08 -06:00
5cded5f27c Updated code for the new deletion of methods in vk sessions 2018-12-09 21:41:09 -06:00
39d1663fa1 Removed login with tokens only due to vk_api login requirements 2018-12-09 21:40:25 -06:00
6ddea35dec Fixed a typo 2018-12-09 12:43:56 -06:00
f3e8a3024f generate random_id with randint 2018-12-09 11:26:21 -06:00
7d35facdaf Generate random_id as integer value 2018-12-09 10:53:50 -06:00
7ba24f7a54 Removed some unneeded code 2018-12-09 07:28:13 -06:00
feb3215745 Use methods provided in vk_api for supporting conversations 2018-12-09 07:25:30 -06:00
ba5d734a05 Restored access to audios by users 2018-12-09 05:22:37 -06:00
bb26d45f1d Replaced VK with vk_api 2018-12-09 05:21:52 -06:00
1a79e7149c Updated requirements 2018-12-09 05:20:35 -06:00
4bdd2b3894 Fixed issues related to sound unable to be played 2018-12-07 17:53:55 -06:00
5d804b2d8e Display audio attachments in chat messages properly 2018-12-06 17:56:22 -06:00
4a83edf3bc Adapted some files to changes present in renderers 2018-12-06 17:34:48 -06:00
d0de4ac677 Removed sound_lib and platform_utils and install them as external deps 2018-12-06 15:57:13 -06:00
49530b8d0c Separated rendering functions from the rest of the code 2018-12-06 15:37:16 -06:00
3aa5a27268 Updated changelog again 2018-12-05 17:34:25 -06:00
88518338f1 Updated changelog 2018-12-05 15:59:55 -06:00
965f14e249 Change date formatting for chat messages 2018-12-05 15:56:23 -06:00
c91e04b4d8 Re-enable audio playback (works with audios transferred in chats) 2018-12-05 15:55:24 -06:00
8fa8267e04 Added some comments in important parts in chat buffer 2018-12-05 15:54:24 -06:00
73fa9532b5 Improved chats focusing. Now they should work properly 2018-12-05 12:43:33 -06:00
04102677f2 Added first experiment on focus mode for chat history 2018-12-04 17:53:10 -06:00
331636b9f4 Refactored chat widget to be more manageable for screen readers. Needs improvements 2018-12-04 16:58:40 -06:00
8c1d9c3fe2 Updated readme 2018-12-03 16:49:14 -06:00
c655e23cb3 Replaced libloader and accessible_output2 for modules retrieved in requirements file 2018-12-03 15:56:57 -06:00
26b78eecf6 Added more comments 2018-12-03 15:55:55 -06:00
08484d9807 Added call to trackVisitor for helping with app statistics 2018-11-05 10:04:02 -06:00
13b19fec75 Added docstrings to attachment controllers and deprecated the previously audio attacher 2018-11-05 09:37:40 -06:00
6fb70a5b32 Added docstrings to profile viewer 2018-11-05 09:11:20 -06:00
317aea7492 Updated changelog 2018-11-04 02:18:58 -06:00
0936ae6fb6 Chats with more than 200 messages will be displayed properly 2018-11-04 01:39:06 -06:00
6bf29a45db Fixed arrow formatter when dealing with profile birthdates 2018-10-14 08:13:12 -05:00
b00668e758 Added option to open authenticated user's profile in browser 2018-09-06 13:07:55 -05:00
6941f26e97 When visiting an user's 'website', handles case where there are multiple sites listed. #7 2018-09-06 12:34:08 -05:00
71a15a24bc Mae profile viewer a tabbed window. Added photo to the dialog. Separated profile code from other post types 2018-09-06 10:47:10 -05:00
964ff00520 Fixed strange issue with chat messages 2018-09-03 13:55:27 -05:00
856b2527e3 Replaced AppendItem for Append in context menus 2018-09-03 13:22:54 -05:00
92158f2496 Replaced old translator by the new yandex powered translator 2018-09-03 10:24:59 -05:00
2a5a184662 Stopped using deprecated objects when Loading images due to WX 4 2018-09-03 10:00:23 -05:00
d45bfb0eeb Started using VK API V 5.84 2018-09-03 09:43:33 -05:00
314a615b68 Commented issue #11 2018-09-03 09:18:32 -05:00
e77276ae52 Fixed error when getting VK API error 5. Closes #11 2018-09-03 09:15:52 -05:00
72348008a2 More WX Python 4 changes 2018-09-03 08:33:05 -05:00
3e43f67ee2 Updated contributors list 2018-09-02 08:42:37 -05:00
d1fd6d1861 Removed VK module from repo. Install it via pip. Custom modules has been moved to mysc 2018-09-02 08:38:49 -05:00
c7743fccb9 Updated GUI regarding WX 4.0.3 2018-09-02 07:57:21 -05:00
ee75c6a53d Moved some dependencies to PIP. Updated Python to 2.7.15 and WX to 4.0.3 2018-09-02 07:50:00 -05:00
fc637e553c Updated WidgetUtils for WXPython 4 2018-09-02 07:33:09 -05:00
fc76b3929b Added comments to buffers.py 2018-01-14 14:55:53 -06:00
0e83c7368d Updated author information 2018-01-14 07:22:54 -06:00
0b8e1a1a0d Switched to VK API V 5.69 2018-01-14 07:18:00 -06:00
6d6a801a01 Removed unneeded prints 2018-01-14 06:58:24 -06:00
ba2ba9bc58 Removed audio elements in menus and main window 2017-09-26 05:19:30 -05:00
268138d726 Changed author information 2017-05-12 12:16:07 +04:00
7fe615a7ee Merge branch 'master' of manuelcortez.net:manuelcortez/socializer 2017-05-12 12:07:52 +04:00
d4fa723155 Disabled audio playback 2017-05-12 12:06:53 +04:00
ae5ec93b53 Added some changes 2017-04-30 16:09:11 -05:00
ead1f186f0 Update API version 2017-03-13 02:16:34 -06:00
2c6704ae9e Updated readme 2016-12-10 07:13:58 -06:00
e2a2758f6d Added support for playing voice messages in VK 2016-09-25 14:24:40 -05:00
3973b57413 Added relationship status, occupation, last seen and website to profile viewer #7 2016-09-21 13:59:31 -05:00
f1ce4b834a Enabled view profile option in the menu for items in people buffers 2016-09-21 13:54:52 -05:00
69346bfaa1 Added a very basic user profile viewer #7 2016-09-20 10:36:17 -05:00
9df49c354b Player object will not be unusable after an error 2016-09-19 17:13:40 -05:00
444d506359 Keep loading other buffers if a section cannot be loaded 2016-09-15 15:27:38 -05:00
65815113d5 Updated changelog 2016-09-05 13:15:13 -05:00
53196b5dda Fixed a bug in the user selection dialog 2016-09-05 13:13:45 -05:00
03f73564da Tag people in posts and comments. Closes #6 2016-08-19 04:25:49 -05:00
9fd845c424 Added a setting for load (or not) images in posts. Closes #9 2016-08-17 17:18:17 -05:00
f079907a9e Parse replies in comments. Start changes for #1 2016-08-17 16:25:01 -05:00
ee308fb5aa Added video search 2016-08-15 17:00:49 -05:00
4900b67882 My videos, album management, add/remove to video albums 2016-08-14 07:46:41 -05:00
4ae167e461 Chats can be sent by pressing enter in the text box 2016-08-14 02:12:49 -05:00
4491a600f3 Fixed problem with false positives in error 6: Too many requests per second 2016-08-13 20:12:18 -05:00
c8927e0b60 Using VK API Version 5.53 2016-08-13 19:50:27 -05:00
50355abdda Added pauses between calls to vk.audio.get in when loading albums 2016-08-10 17:37:36 -05:00
f190b7651e Added an experimental photo viewer in posts dialog 2016-08-10 12:58:11 -05:00
38c394581c Added friendship requests buffers inside the people buffer 2016-08-02 10:38:10 -05:00
00d7cf48af Added audio player menu in menu bar 2016-07-18 17:34:37 -05:00
740ae124f9 Version 2016.07.9 2016-07-12 05:10:57 -05:00
17977d2a88 Fixed a few bugs 2016-07-12 05:00:07 -05:00
ed29923d2e Improved play all function for slow connections 2016-07-10 22:59:59 -05:00
6228e7229b Removed print statements 2016-07-10 22:51:06 -05:00
677f92af68 Added a few translatable strings 2016-07-08 16:40:34 -05:00
ce43d8b30e Updated changelog 2016-07-08 16:37:43 -05:00
09470e85ce Remove a few bugs when users press enter in friend lists 2016-07-08 16:34:28 -05:00
bab896aba1 Get instrumental case for name in chat buffers. Remove set Offline option in VK at exit 2016-07-07 14:50:09 -05:00
519381684d Updated russian translations 2016-07-07 13:24:01 -05:00
a66b35190f Fixed a bug in the get_page function 2016-07-07 13:23:49 -05:00
208 changed files with 4768 additions and 6656 deletions

52
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,52 @@
# Jobs to build the two channels in Socializer.
alpha:
type: deploy
tags:
- windows
script:
- pip install --upgrade pip
- pip install --upgrade -r requirements.txt
- copy changelog.md doc\changelog.md
- cd doc
- python documentation_importer.py
- cd ..\src
- python ..\doc\generator.py
- python write_version_data.py
- python setup.py py2exe
- cd ..
- cd scripts
- python prepare_zipversion.py
- cd ..
- move src\socializer.zip socializer.zip
only:
- master
artifacts:
paths:
- socializer.zip
name: socializer
expire_in: 1 week
stable:
type: deploy
tags:
- windows
script:
- pip install --upgrade pip
- pip install --upgrade -r requirements.txt
- copy changelog.md doc\changelog.md
- cd doc
- python documentation_importer.py
- cd ..\src
- python ..\doc\generator.py
- python setup.py py2exe
- cd ..
- cd scripts
- python prepare_zipversion.py
- cd ..
- move src\socializer.zip socializer.zip
only:
- tags
artifacts:
paths:
- socializer.zip
name: socializer

View File

@@ -1,43 +1,39 @@
# socializer
[![pipeline status](https://code.manuelcortez.net/manuelcortez/socializer/badges/master/pipeline.svg)](https://code.manuelcortez.net/manuelcortez/socializer/commits/master)
> Note: this project has two different main repositories. [Here is the official repository, hosted in my Gitlab Instance,](https://code.manuelcortez.net/manuelcortez/socializer) [Here is a mirror repository hosted in GitHub.](https://github.com/manuelcortez/socializer) Github repository will accept pull requests and issues reported by github users, while Gitlab's repository will provide the wiki, documentation, and support for user reported issues.
A desktop application for handling [vk.com](http://vk.com) in an easy way.
## weekly builds
## download the current build
Socializer's functionality is far to be perfect, in fact there are lots of methods of the VK API that this application doesn't support right now, but if you are curious enough, and you want to help by giving me your impressions and making tests for fixing bugs, you can download the last source code, compiled as an application. This is the weekly build of socializer. This version is only for testing purposes, never think that it can be used for everyday use. This version does not include any documentation, Only the changelog, because it's build with an authomatic process. This weekly build is built every week, depending in the updates that the repository has receibed.
Socializer's functionality is far to be perfect, in fact there are lots of methods of the VK API that this application doesn't support right now, but if you are curious enough, and you want to help by giving me your impressions and making tests for fixing bugs, you can download the last source code, compiled as an application. This is the snapshot build of socializer. This version is only for testing purposes, never think that it can be used for everyday use. This version does not include any documentation, Only the changelog, because it's build with an authomatic process.
Before downloading, take in to account the following: This source code is completely experimental. The current functionality in this application is not very useful. If you decide to use nightly build versions, take into account that this doesn't work as an application for everyday use yet.
Version: 2016.05.25
Build date: May 25 2016
[Download socializer weekly build](https://github.com/manuelcortez/socializer/blob/master/nightly/socializer-nightly-build.zip?raw=true)
Version: 0.16
Build date: Dec 14 2018
[Download socializer](https://code.manuelcortez.net/manuelcortez/socializer/-/jobs/artifacts/master/raw/socializer.zip?job=alpha)
I have started this effort as an open source project on Feb 13, 2016. Pull requests and bug reports are welcome. Socializer is not a definitive name for this project, it could be changed in future.
I have started this effort as an open source project on Feb 13, 2016. Pull requests and bug reports are welcome.
## dependencies
## dependencies not installed by PIP
* [Python,](http://python.org) version 2.7.11
* [wxPython](http://www.wxpython.org) for Python 2.7, version 3.0.2.0
* [Python windows extensions (pywin32)](http://www.sourceforge.net/projects/pywin32/) for python 2.7, build 220
For other dependencies, do pip install --upgrade -r requirements.txt
* [Python,](http://python.org) version 2.7.15
* [PyEnchant,](http://pythonhosted.org/pyenchant/) version 1.6.6.
* [VK API bindings for Python](https://github.com/dimka665/vk) (already included in the SRC directory)
* pypubsub
* configobj
* requests-oauthlib
* future
* arrow==0.6
* microsofttranslator
* [Pandoc](http://pandoc.org/installing.html) for generating the changelog.
## Documentation
I am trying to write an updated manual for socializer. It can be found in the documentation folder once the program zip file is uncompressed, or in the manual.md file (in markdown). The idea of this manual is to be updated as socializer receives new features or improvements.
A copy of the English version of the manual can be read here: [Manual in the socializer's wiki](https://github.com/manuelcortez/socializer/wiki/manual)
A copy of the English version of the manual can be read here: [Manual in the socializer's wiki](https://code.manuelcortez.net/manuelcortez/socializer/wikis/manual)
## Contributing
If you are interested in this project, you can help it by [translating this program](https://github.com/manuelcortez/socializer/wiki/translate) into your native language and give more people the possibility of using it. Thank you in advance!
If you are interested in this project, you can help it by [translating this program](https://code.manuelcortez.net/manuelcortez/socializer/wikis/translate) into your native language and give more people the possibility of using it. Thank you in advance!
## contact

View File

@@ -1,13 +1,57 @@
% Changelog
# Changelog
## Changes for the current build ()
## changes in this version
* Added support for Two factor authentication (2FA). ([#13,](https://code.manuelcortez.net/manuelcortez/socializer/issues/13))
* Added update channels in socializer. You can subscribe to the "stable" or "alpha" channel from the preferences dialog and you will receive updates published for those:
* The stable channel will have releases every month, approximately, and is the channel where the code will be more tested and with less bugs. All support and help will be provided for the stable versions only.
* The alpha channel will have releases every time a change is added to socializer, it may even include several releases in the same day, but we will try to release only a new version every day. Support will not be provided for alpha versions, as they will be used to test the latest code in the application.
* Now it is possible to send voice messages from socializer. Voice messages are available from the "add" button in any conversation buffer.
* tokens generated by socializer will never expire. ([#3,](https://code.manuelcortez.net/manuelcortez/socializer/issues/3))
* In order to use all methods available in VK, socializer will use tokens of kate mobile for Android. It means you may receive an email by saying that you've authorised Kate for accessing your account from an Android device.
* Audio albums are loaded correctly.
* It is possible to play audios added by friends appearing in the news feed.
* Adding and removing an audio file to your library works.
* Unread messages will play a sound when focused.
* Unread messages will be marked as read when user focuses them.
* Socializer will handle restricted audio tracks. Restricted songs are not allowed to be played in the user's country. Before, playing a restricted track was generating an exception and playback could not resume. Now, playing an audio track will display an error notification.
* Fixed an error when people were trying to open a post in an empty buffer, or accessing the menu when there are no posts in the buffer.
* Now Socializer will not send a notification every 5 minutes.
* the chat widget now is a multiline text control. It means it is possible to add a new line by pressing shift+Enter, and send the message by pressing enter.
* Socializer should handle connection errors when loading items in buffers and retry in 2 minutes. Also, connection errors in the chat server are handled and chat should be able to reconnect by itself.
* When trying to add an audio or video to an album, if the current user does not have any album, it will display an error instead of a traceback.
* Added popular and suggested songs. This will not work when using alternative tokens.
* Now it is possible to update the status message, located in your profile.
* Now it is possible to upload an audio from your computer when adding attachments in a wall post. When adding attachments to a post or message in a conversation, you will have two options: upload from your computer and add a file from your VK profile.
* Updated Russian translation: thanks to Дарья Ратникова.
* Fixed some conditions, especially when rendering items in feeds, that were making the client to crash.
* new versions will include documentation and changelog.
* A new option for reporting issues directly from the help menu has been added. Issues will be publicly available in the [Project Issues page](https://code.manuelcortez.net/manuelcortez/socializer/issues)
## Changes in version 0.16 (13.12.2018)
* Added two more buffers: "Pending requests" and "I follow", located in the people buffer, under "friendship requests".
* Added an experimental photo viewer. Will show options for displaying the next and previous photo if the current post contains multiple images. Fullscreen button still doesn't work.
* Improved the chat features present in the application. Read documentation to get a full understanding about how it works now.
* Added video management (my videos, video albums and video search). For playing videos, you will be redirected to a website in your browser due to the VK'S policy.
* Added a setting that allows you to specify if you want socializer to load images when you are opening posts. It could be useful for slow connections or those who don't want images to be loaded.
* Added basic tagging for users in posts and comments. You can tag only people in your friends buffer.
* Added a basic user profile viewer.
* Added support for listening voice messages in chats. Currently it is not possible to send them.
* Fixed an error that was making Socializer unable to display chat history properly. It was showing the first 200 items in a conversation instead the last 200 items. Now chat will be displayed accordingly.
* Changed the chat history widget from list of items to a read only text box, similar to how it was displayed in skype. Now the widget should be fully visible and messages will work in the same way.
* It is possible to play songs sent in a chat message by opening them from the attachments panel.
* Reimplemented most of the audio playback methods (audio albums buffer still not working).
* Added some notifications and chat notifications when friends are online and offline. Most notifications can be configured from settings.
## Changes in build 2016.07.08 (08/07/2016)
* Removed platform from "last seen" column in the friends list as it could cause some problems and it was being not so exact.
* Now deleted audios are not parsed and displayed as "audio removed from library". They are silently ignored.
* It's possible to open a friends timeline for others.
* Fixed some strange bugs in the built version.
* Deactivated accounts will not cause problems in friends lists. They will be displayed as deactivated, wich means that it'll be impossible to interact with those accounts.
* When opened, the client will set online for the user account, it'll inform VK that this user is currently online. This parameter will be updated every 15 minutes, as stated in the API documentation. When exiting, Socializer will try to set the account as offline. Friends and other people could use this parameter to see if you are using VK in the moment.
* When opened, the client will set online for the user account, it'll inform VK that this user is currently online. This parameter will be updated every 15 minutes, as stated in the API documentation.
* When opened, socializer will try to create chat buffers for all unread messages.
* Update some information on certain posts when an item is selected. For example, update the date of a post.
* Read messages will be marked as read in the social network, so it'll cause that your friends could see that you have read the message and socializer will not load chat buffers with read messages at startup.
@@ -18,6 +62,8 @@
* Albums will be empty at startup. In order to get the album's audios, you'll have to navigate to the album and press the button "load". It'll load the needed information for displaying and playing the added songs
* If the config is invalid (for example you changed email or phone in the VK site and didn't changed that in Socializer, or just entered invalid credentials), the program will display an error with instructions for fixing the problem.
* Now is possible to press enter in the password or email/phone field and it'll do the action of the OK button.
* If you have set russian as the main language in the VK site, you'll see names in genitive and instrumental cases in certain phrases.
* Updated russian and spanish translations.
## Changes on build 2016.05.25
@@ -42,7 +88,4 @@
* Added more options in the search audio dialog. Now users could use more parameters and searches will be more precise.
* Added a new attachments' list. When a post is opened, this list will show up if there are attachments in the current post (attachments are audio, photos, video and links). You will be able to interact with the supported data (at the moment only photos, videos, audio and links are supported, more will be added in future).
* Added a changelog file which could be opened from the help menu.
* Added a preferences dialogue and a new application menu in the menu bar. From this dialogue you can change the number of items to be loaded for every buffer.
---
© 2016, manuel cortéz.
* Added a preferences dialogue and a new application menu in the menu bar. From this dialogue you can change the number of items to be loaded for every buffer.

View File

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

View File

@@ -2,7 +2,7 @@
""" This script converts the hold documentation (saved in markdown files) in a python file with a list of strings to translate it using gettext."""
def prepare_documentation_in_file(fileSource, fileDest):
""" This takes documentation written in a markdown file and put all the contents in a python file, to create a internationalized documentation.
""" This takes documentation written in a markdown file and put all the contents in a python file, to create a translatable documentation.
@fileSource str: A markdown(.md) file.
@fileDest str: A file where this will put the new strings"""
@@ -18,11 +18,10 @@ def prepare_documentation_in_file(fileSource, fileDest):
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i[:-1])
else:
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i)
# print i[-1:]
f2.write(newvar)
f1.close()
f2.write("]")
f2.close()
prepare_documentation_in_file("manual.md", "strings.py")
prepare_documentation_in_file("manual.md", "strings.py")
prepare_documentation_in_file("changelog.md", "changelog.py")

View File

@@ -1,20 +1,32 @@
# -*- coding: utf-8 -*-
import markdown
import os
import shutil
from codecs import open as _open
import languageHandler
languageHandler.setLanguage("en")
import documentation_importer
import strings
import changelog
# the list of supported language codes of TW Blue
# the list of supported language codes
languages = ["en", "es"]
def generate_document(language):
import strings
def generate_document(language, document_type="documentation"):
reload(languageHandler)
languageHandler.setLanguage(language)
reload(strings)
markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"])
if document_type == "documentation":
translation_file = "socializer-documentation"
languageHandler.setLanguage(language, translation_file)
reload(strings)
markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"])
title = strings.documentation[0]
filename = "manual.html"
elif document_type == "changelog":
translation_file = "socializer-changelog"
languageHandler.setLanguage(language, translation_file)
reload(changelog)
markdown_file = markdown.markdown("\n".join(changelog.documentation[1:]), extensions=["markdown.extensions.toc"])
title = changelog.documentation[0]
filename = "changelog.html"
first_html_block = """<!doctype html>
<html lang="%s">
<head>
@@ -23,20 +35,25 @@ def generate_document(language):
</head>
<body>
<header><h1>%s</h1></header>
""" % (language, strings.documentation[0], strings.documentation[0])
""" % (language, title, title)
first_html_block = first_html_block+ markdown_file
first_html_block = first_html_block + "\n</body>\n</html>"
if not os.path.exists(language):
os.mkdir(language)
mdfile = _open("%s/manual.html" % language, "w", encoding="utf-8")
if not os.path.exists(os.path.join("documentation", language)):
os.mkdir(os.path.join("documentation", language))
mdfile = _open(os.path.join("documentation", language, filename), "w", encoding="utf-8")
mdfile.write(first_html_block)
mdfile.close()
def create_documentation():
print("Creating documentation in the supported languages...\n")
if not os.path.exists("documentation"):
os.mkdir("documentation")
if os.path.exists(os.path.join("documentation", "license.txt")) == False:
shutil.copy(os.path.join("..", "license.txt"), os.path.join("documentation", "license.txt"))
for i in languages:
print("Creating documentation for: %s" % (i,))
generate_document(i)
generate_document(i, "changelog")
print("Done")
create_documentation()

View File

@@ -80,7 +80,7 @@ def getAvailableLanguages():
"""
#Make a list of all the locales found in NVDA's locale dir
l=[x for x in os.listdir("locales") if not x.startswith('.')]
l=[x for x in l if os.path.isfile('locales/%s/LC_MESSAGES/socializer-doc.mo' % x)]
l=[x for x in l if os.path.isfile('locales/%s/LC_MESSAGES/twblue-documentation.mo' % x)]
#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:
l.append('en')
@@ -117,7 +117,7 @@ def makePgettext(translations):
return unicode(message)
return pgettext
def setLanguage(lang):
def setLanguage(lang, translation_file="socializer-documentation"):
system = platform.system()
global curLang
try:
@@ -127,10 +127,10 @@ def setLanguage(lang):
localeName=locale.windows_locale[windowsLCID]
else:
localeName=locale.getlocale()[0]
trans=gettext.translation('socializer-doc', localedir="locales", languages=[localeName])
trans=gettext.translation(translation_file, localedir="locales", languages=[localeName])
curLang=localeName
else:
trans=gettext.translation("socializer-doc", localedir="locales", languages=[lang])
trans=gettext.translation(translation_file, localedir="locales", languages=[lang])
curLang=lang
localeChanged=False
#Try setting Python's locale to lang
@@ -150,7 +150,7 @@ def setLanguage(lang):
LCID=localeNameToWindowsLCID(lang)
ctypes.windll.kernel32.SetThreadLocale(LCID)
except IOError:
trans=gettext.translation("socializer-doc",fallback=True)
trans=gettext.translation(translation_file,fallback=True)
curLang="en"
trans.install(unicode=True)
# Install our pgettext function.

View File

@@ -1,105 +1,145 @@
socializer's manual
Socializer's manual
## Introduction
Socializer is an application to use [VK.com](https://vk.com) in an easy and accessible way with minimal CPU resource usage. Socializer will allow you to interact with the VK social network by giving you access to the most relevant features such as:
* Basic post creation in your wall (including photos).
* Audio addition, removal, download and search.
* audio albums management (create, delete and add audios).
* (limited) audio support. (*)
* Post comments.
* like, unlike and repost other's posts.
* Open other's timelines so you could track someone's friends, posts or audio files.
* Open other's timelines so you could track their friends, posts or audio files.
* Basic chat features.
Note: When new features are added to socializer they will be added to this section.
\* Audio support in socializer is limited due to the restrictions VK has decided to apply for third party applications on december 2016.
## Running
## Usage
If you are using a built version, unzip the file in a new directory with no special characters, and open the socializer.exe file. If you haven't configured your VK account, you will see a dialogue, just press yes and a new dialogue will prompt for an user email or phone number and the password for your account. Take into account that the provided information will be saved in a config file as plain text. This application will need your information for renegotiating the access token when it expires.
In order to use socializer, you must have an account in the [VK](https://vk.com) website. The process for registering an account is very accessible and is not covered in this manual. In the documentation, it is assumed you have a registered account on VK and you are able to sign in in the website by providing your phone number or email address, and a password. You will require this data for signing in the application later.
Note: Every time you grant access to socializer, probably You will receive an email from VK by telling you that someone has accessed to your account. It means that a new token has been negotiated between VK and socializer by using an authomatic process, you should ignore those advices, unless you receive an email when you are not logged in VK with socializer or other application. You can see your authorised applications in the configuration section in the VK website. New tokens are renegotiated every 24 hours.
## authorising the application
First of all, it's necessary to authorise the application so it can access your VK account and act on your behalf. The authorisation process is quite simple, and will be required only once. In order to start the authorisation process, you just need to run the executable file called "socializer.exe" (on some computers it will appear only as socializer, depending if windows explorer is set to display file extensions or not). You may like to place a Windows shortcut in your desktop for an easier access to the application.
If this is the first time you have launched socializer, you will see a message dialog asking you to proceed with the account authorisation process. It consists in providing the authentication data you normally use to sign in VK. It is very important to know that this data will be stored in a folder called config, located in the same folder where are the socializer files. Your config folder is a very important storage for your authentication data, so you must be sure you never will share it with anyone, mostly because your data is stored as plain text (this will be fixed in a future release and your data will be properly encrypted). Socializer will need your authentication data for acting in your behalf and offering you a better experience that what it could do with a simple access token. You must provide your phone number or email address in the first text box, and your password in the second. When pressing OK, your data will be saved and the application will start to retrieve all the required information for showing your buffers.
Once started, the application will start loading your data (posts, audio files, conversations, friends). When done, it will show you a notification indicating that the program is ready.
## General concepts
Before starting to describe Socializer's usage, we'll explain some concepts that will be used extensively throughout this manual.
### Buffer
A buffer is a list of items that will manage the data which arrives from VK, after being processed by the application. When you configure your account on Socializer and start it, many buffers are created. Each of them may contain some of the items which this program works with: Newsfeed posts, wall posts, audio and video files, friendship requests and conversations. According to the buffer you are focusing, you will be able to do different actions with these items.
All buffers will be updated in one of the following ways:
* Periodically: Most buffers containing posts, audio or video files and people, will be updated periodically to reflect the new additions to them. Updates will be every 2 minutes for every buffer, so if you posted something and did not see the post in the buffer, you may need to wait a moment. There is an option, located in the buffer menu on the menu bar, which allows you to trigger a manual update in the current buffer.
* Real time: Conversation buffers will be updated every time someone sends a message to you. When an user sends you a message, if there is not a conversation buffer created to receive the message, a new conversation buffer will be opened automatically and the message will be placed on it. If you already have an opened conversation for the user sending the message, the message will be placed at the end of the buffer. A different sound will indicate whether a new conversation has been opened or an existing buffer gets updated.
### item
An item is an element representing some data provided by VK. Items are separated in buffers which stores items of the same type: Audio buffers will contain only audio files, wall buffers will be full of wall posts. The only exception to this rule is the newsfeed buffer, which can contain different kind of items. Actions are available in a per-item basis, allowing certain items to be treated differently than others and showing different dialogs, depending in the kind of data VK sends for them. All items show a menu with their available actions by focusing them in the list and pressing the menu key or a right mouse click.
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. Take into account that it is not possible to play an audio item from the newsfeed buffer due to limits placed by VK, however, you may add it to your library and play it from your "my music" folder. If a wall post contains a long message, the first 140 characters will be displayed only. 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 posts will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, the first 140 characters will be displayed only. 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 and 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, and read all 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 only opening the audio in a dialog and play it due to limitations in access to audio features. 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 and download. You can control playback of audio items from the buffer by using the player menu on the menu bar.
* Video: It represent a video uploaded to the VK'S platform. Actions available for this item are opening the video in your default web browser and move it to a video album. When opened, it will open a web browser and play the video automatically due to VK limitations in access to video files.
* person: It contains information about a VK user, this item is present in all buffers under the "people" category. Actions available for this item are view user profile, send message and create a timeline, which is a special buffer to track all posts, friends or audios owned by the user. When opened, it will display the profile of this user in a dialog and will provide actions to send a message to the user, or view other sections of her/his profile.
* 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
If you have used [TWBlue](https://github.com/manuelcortez/twblue) before, the socializer's interface is quite similar. Once you have authorised your account, you will see a window with the following elements:
The graphical user interface of Socializer consists of a window containing:
* A tree view at the left of the window, where you will see the list of buffers. These buffers are divided in three categories, posts, music and people. You could expand each category for seeing the child buffers. There are some additional buffers, timelines and chats, wich will be filled with timelines for your friends or with chats, when you start or receive a chat session.
* A button for making a post to your wall.
* In audio buffers, Two buttons: Play and play all.
* In audio album buffers, a button for loading music. By default, albums are empty, you have to press the load button for getting the album's items.
* A list where you will see the posts for the currently selected buffer.
* In people buffers, like the friends buffer, a button for sending a message to your friends. Pressing that button will cause a chat buffer to be created.
* A status bar where the program will put some useful information about what it's doing at the moment.
* And a menu bar.
* a menu bar accomodating five menus (application, Me, buffer, player and help),
* One tree view,
* One list of items
* Some buttons, depending which is the focused buffer.
When socializer starts, it will try to load your news items, wall, audios (your audios, recommended and populars) and friends. At the moment there are only a few supported actions for these items:
The actions that are available for every item will be described later.
* Audio files: You can play the currently selected song, view the song's details (including lyrics, if available), add or remove from your library, and download it to a desired place in your hard drive. You can find audio files in your news feed or in your own audios buffers. You can find audios as post's attachments. You can create an audios timeline for displaying other's audios.
* News feed's post: In your news feed buffer, you can press return in any post and socializer will open a new dialogue which can be different, depending in the kind of post you are when the return key was pressed. For example it will open the post if you are focusing a "normal" post, a list of people if you are in a post wich indicates that someone has added friends, an audio displayer if you are in a post wich indicates that someone has added an audio, etc.
* Wall posts: It will show the post in a dialogue so you could interact with its attachments, view and post comments, or like/unlike/share the post.
* You can send a message to someone by pressing the send message button in the buffer where you are, if available. Deactivated accounts cannot receive messages.
In summary, the GUI contains two core components. These are the controls you will find while pressing the Tab key within the program's interface, and the different elements present on the menu bar.
### Making a post
### Buttons in the application
When you press the post button, a new dialogue will show up. This dialogue allows you to post something in your wall. In this dialogue you have to write a message. You can translate your message and fix your spelling mistakes. Also you can post an URL address, socializer will try to add it as an attachment, so you will not have to worry about this. When you're ready, just press the send button and it'll be done.
* Post: this button opens up a dialogue box to write a post in your wall. For the moment, only posting in your own wall is supported. You can upload a picture by pressing the "attach" button and the photo button 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.
* Play: In audio buffers, plays the focused song. In video buffers, this button will open a web browser for playing the focused video, due to a limitation VK placed to third party developers with videos.
* Play all: In audio buffers, play all songs starting from the focused buffer, until the last item in the list.
* Send message: Send a message to a friend, which will open a conversation buffer if it does not exist already. Conversation buffers contain a full conversation, accommodating chat messages, between the current user and someone else. You can type your message in the provided box and press enter to send it to your friend. Additionally, you can add an attachment (for the moment, only attaching an audio file from your library is supported) and open attachments sent in the focused message by pressing tab and finding them in the attachments list.
If you want to add some photos, you can press the attach button, then press the kind of attachment you want to add. After this, select the file you want to add and you will see it in the list, once processed. When you are done with attachments, press the OK button, and continue with your post. When you are ready, press the send button. Your post could take some time to be published, depending in the amount of files you have added, but it should be displayed in your wall and newsfeed as soon as it is posted.
Bear in mind that buttons will appear according to which actions are possible on the list you are browsing.
### Working with posts in news feed
## Menus
You can press the return key in any post in your news feed for opening a new dialogue with some information. The information and dialogue will be different if you are viewing a friendship's notification (when someone has added some friends), an audio file, or a regular post.
If you open a regular post in your newsfeed, you will be able to see the comments in a list, indicate if you do like or dislike the post, repost or add a new comment. If the post has some attachments, you'll find a list populated with them, you can press return in an attachment to execute its default action, wich will be different depending on the kind of attachment that you are viewing.
For friend notifications, you can only view the new added friends in a list and there are some kind of posts that aren't handled. It should be improved.
Additionally, you can press the menu Key or the right click for displaying a menu with some quick actions available for the post you are focusing. These actions are different for every post type.
### Working with songs
Note: the following applies to audio timelines too.
If you want to play or view audio's details, you'll have to navigate to the tree view, and, using the down arrow, look for "my audios", "populars" or "Recommendations". You will see two more buttons, play and play all. The play button will play the currently selected audio, and the play all button will play audios in the current buffer, starting with the current selected item. You can go to the song's list, look for a desired song and press the play button, or Ctrl+return, which is a keyboard shorcut. Take in to account that there are some keyboard shorcuts that only work in the list of items.
You can play audio from any buffer, just press ctrl+return for making the audio playback possible.
If someone has added multiple audios at once to his library, you will see something like this in your newsfeed: "(friend) has added 4 audios: audio 1, audio2, audio3 and audio4". You can press return in the post for opening the audio's details dialogue, where you will be able to see a list with these audios. By default the first detected song is selected, which means that you could read its details by pressing tab, download or add it to your library. If you change the audio in the list, the information will be updated and you will see details and actions will take effect in the new selected audio.
When an audio file is playing, you can press f5 and f6 for decreasing and increasing volume, respectively, or control+shift+return for play/pause.
If you want to see some details for the selected audio file, you can do it by pressing the return key. You will be able to read some useful information (title, artist, duration and the lyric, if available). Also you will be able to download the song to your hard drive, you have to press the download button in the details' dialogue.
When the download starts, you can close the details dialogue and check the status bar in the main window for seeing the current progress.
Additionally, you can search for audios by using the menu bar, in the buffer menu, select search, then audio. It will display a dialog where you have to set your search preferences.
If you press the menu key, you will see a menu where you will be able to do some actions, for example, add the audio to an album, or add/remove the song from your library.
## menu Bar
You can go to the menu bar by pressing ALT. Right now, there are three menus, application, buffer and help:
Visually, Towards the top of the main application window, can be found a menu bar which contains many of the same functions as listed in the previous section, together with some additional items. To access the menu bar, press the alt key. You will find five menus listed: application, Me, buffer, player and help. This section describes the items on each one of them.
### Application menu
* Create. Here you can create some things in VK. The only supported item at this moment is the audio album.
* Delete: Removes items from the VK servers. The only supported item here is the audio album.
* you can set your preferences by opening the preferences dialog located in this menu.
* Create: opens a menu where you can create a new album. At the moment, only video albums are supported.
* Delete: opens a menu where you can delete an already existing album owned by yourself. Only video albums are supported at this time.
* Preferences: Opens a dialogue which lets you configure settings for the entire application.
### Me menu
* Profile: Opens a menu with several options to do in your profile:
* View profile: Displays your profile in a dialog in the application.
* Open in browser: Redirects you to your profile in vk.com.
### Buffer menu
* new timeline: This option allows you to create a new timeline. This kind of buffers is capable of download all posts in an user's profile.
* search: This submenu allows you to create a new buffer, at the moment, you can create only a kind of buffer, an audio search. The audio search will be located in the music category and will have the last 299 results of your query.
* Update current buffer: perform an update operation in the selected buffer, which will retrieve the new items.
* Load previous items: Get the previous items for the currently focused buffer.
* Remove buffer: Tries to remove the current buffer. Default buffers can't be removed.
* 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.
* Search: Shows a menu where you can search for audios or videos on VK. Search results will be created in a new buffer inside "music" or "videos".
* Update buffer: Performs a manual update operation in the buffer, which will retrieve all new items present in the social network since the last update.
* Load previous items: This allows more items to be loaded for the specified buffer. Bear in mind that not all buffers support this setting.
* Destroy: dismisses the list you're on, if possible.
The help menu is self explanatory.
### Player menu
## Contributing
* Play: Plays the currently focused audio item, if the current buffer contains audio files. If not, plays the focused audio in the "my music" buffer.
* Play all: Plays all audio items in the current buffer or the "my music" buffer, starting by the currently focused audio item until the last audio in the list.
* Stop: Stops audio playback.
* Previous: Plays the previous audio in the buffer or the last item in the list, if the current audio was the first on the buffer.
* Next: Plays the Next audio in the buffer or the first item in the list, if the current audio was the last on the buffer.
* Shuffle: Plays all audios in the current buffer or the "my music" buffer shuffled.
* Volume up: Increases volume by 5%.
* Volume down: decreases volume by 5%.
* Mute: Mutes audio playback, setting volume to 0%.
If you notice some errors in this document, or features that are not documented yet, you can suggest those changes by contacting me (more information can be find in the following section).
### help menu
## contact
* About Socializer: shows the credits of the program.
* Documentation: opens up this file, where you can read some useful program concepts.
* Check for updates: every time you open the program it automatically checks for new versions. If an update is available, it will ask you if you want to download the update. If you accept, the updating process will commence. When complete, Socializer will be restarted. This item checks for new updates without having to restart the application.
* Changelog: opens up a document with the list of changes from the current version to the earliest.
If you have questions, don't esitate to contact me in [Twitter,](https://twitter.com/manuelcortez00) or sending me an email to manuel(at)manuelcortez(dot)net. Just replace the words in parentheses with the original signs.
## Keyboard shortcuts
## configuration
### The general tab
### The chats tab
## License and source code
Socializer is free software, licensed under the GNU GPL license, either version 2 or, at your option, any later version. You can view the license in the file named license.txt, or online at <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>.
The source code of the program is available at <https://code.manuelcortez.net/manuelcortez/socializer>.
## Contact
If you still have questions after reading this document, if you wish to collaborate to the project in some other way, or if you simply want to get in touch with the application developer, follow the VK account of [Manuel Cortez.](https://vk.com/manuelcortez) You can also visit [The project website.](https://manuelcortez.net/socializer)
## Credits
Socializer is developed and mantained by [Manuel Cortez,](https://manuelcortez.net) with contributions by [Anibal Hernandez](https://dragodark.com)
We would also like to thank the translators of Socializer, who have allowed the spreading of the application.
* English: Manuel Cortéz.
* Spanish: Manuel Cortéz.
* Russian: Valeria K.

View File

@@ -1,67 +1,95 @@
# -*- coding: utf-8 -*-
documentation = [
_(u"""socializer's manual """),
_(u"""Socializer's manual """),
"",_(u"""## Introduction"""),
"",_(u"""Socializer is an application to use [VK.com](https://vk.com) in an easy and accessible way with minimal CPU resource usage. Socializer will allow you to interact with the VK social network by giving you access to the most relevant features such as:"""),
"",_(u"""* Basic post creation in your wall (including photos)."""),
_(u"""* Audio addition, removal, download and search."""),
_(u"""* audio albums management (create, delete and add audios)."""),
_(u"""* (limited) audio support. (*)"""),
_(u"""* Post comments."""),
_(u"""* like, unlike and repost other's posts."""),
_(u"""* Open other's timelines so you could track someone's friends, posts or audio files."""),
_(u"""* Open other's timelines so you could track their friends, posts or audio files."""),
_(u"""* Basic chat features."""),
"",_(u"""Note: When new features are added to socializer they will be added to this section."""),
"",_(u"""## Running"""),
"",_(u"""If you are using a built version, unzip the file in a new directory with no special characters, and open the socializer.exe file. If you haven't configured your VK account, you will see a dialogue, just press yes and a new dialogue will prompt for an user email or phone number and the password for your account. Take into account that the provided information will be saved in a config file as plain text. This application will need your information for renegotiating the access token when it expires."""),
"",_(u"""Note: Every time you grant access to socializer, probably You will receive an email from VK by telling you that someone has accessed to your account. It means that a new token has been negotiated between VK and socializer by using an authomatic process, you should ignore those advices, unless you receive an email when you are not logged in VK with socializer or other application. You can see your authorised applications in the configuration section in the VK website. New tokens are renegotiated every 24 hours."""),
"",_(u"""\* Audio support in socializer is limited due to the restrictions VK has decided to apply for third party applications on december 2016."""),
"",_(u"""## Usage"""),
"",_(u"""In order to use socializer, you must have an account in the [VK](https://vk.com) website. The process for registering an account is very accessible and is not covered in this manual. In the documentation, it is assumed you have a registered account on VK and you are able to sign in in the website by providing your phone number or email address, and a password. You will require this data for signing in the application later."""),
"",_(u"""## authorising the application"""),
"",_(u"""First of all, it's necessary to authorise the application so it can access your VK account and act on your behalf. The authorisation process is quite simple, and will be required only once. In order to start the authorisation process, you just need to run the executable file called "socializer.exe" (on some computers it will appear only as socializer, depending if windows explorer is set to display file extensions or not). You may like to place a Windows shortcut in your desktop for an easier access to the application."""),
"",_(u"""If this is the first time you have launched socializer, you will see a message dialog asking you to proceed with the account authorisation process. It consists in providing the authentication data you normally use to sign in VK. It is very important to know that this data will be stored in a folder called config, located in the same folder where are the socializer files. Your config folder is a very important storage for your authentication data, so you must be sure you never will share it with anyone, mostly because your data is stored as plain text (this will be fixed in a future release and your data will be properly encrypted). Socializer will need your authentication data for acting in your behalf and offering you a better experience that what it could do with a simple access token. You must provide your phone number or email address in the first text box, and your password in the second. When pressing OK, your data will be saved and the application will start to retrieve all the required information for showing your buffers."""),
"",_(u"""Once started, the application will start loading your data (posts, audio files, conversations, friends). When done, it will show you a notification indicating that the program is ready."""),
"",_(u"""## General concepts"""),
"",_(u"""Before starting to describe Socializer's usage, we'll explain some concepts that will be used extensively throughout this manual."""),
"",_(u"""### Buffer"""),
"",_(u"""A buffer is a list of items that will manage the data which arrives from VK, after being processed by the application. When you configure your account on Socializer and start it, many buffers are created. Each of them may contain some of the items which this program works with: Newsfeed posts, wall posts, audio and video files, friendship requests and conversations. According to the buffer you are focusing, you will be able to do different actions with these items."""),
"",_(u"""All buffers will be updated in one of the following ways:"""),
"",_(u"""* Periodically: Most buffers containing posts, audio or video files and people, will be updated periodically to reflect the new additions to them. Updates will be every 2 minutes for every buffer, so if you posted something and did not see the post in the buffer, you may need to wait a moment. There is an option, located in the buffer menu on the menu bar, which allows you to trigger a manual update in the current buffer."""),
_(u"""* Real time: Conversation buffers will be updated every time someone sends a message to you. When an user sends you a message, if there is not a conversation buffer created to receive the message, a new conversation buffer will be opened automatically and the message will be placed on it. If you already have an opened conversation for the user sending the message, the message will be placed at the end of the buffer. A different sound will indicate whether a new conversation has been opened or an existing buffer gets updated."""),
"",_(u"""### item"""),
"",_(u"""An item is an element representing some data provided by VK. Items are separated in buffers which stores items of the same type: Audio buffers will contain only audio files, wall buffers will be full of wall posts. The only exception to this rule is the newsfeed buffer, which can contain different kind of items. Actions are available in a per-item basis, allowing certain items to be treated differently than others and showing different dialogs, depending in the kind of data VK sends for them. All items show a menu with their available actions by focusing them in the list and pressing the menu key or a right mouse click."""),
"",_(u"""The following is a brief description of the kind of items socializer can work with, and what actions are available for those."""),
"",_(u"""* 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. Take into account that it is not possible to play an audio item from the newsfeed buffer due to limits placed by VK, however, you may add it to your library and play it from your "my music" folder. If a wall post contains a long message, the first 140 characters will be displayed only. 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."""),
_(u"""* Wall post: Represent a post in an user's wall. This posts will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, the first 140 characters will be displayed only. 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 and 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, and read all 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."""),
_(u"""* Audio: It represent an audio uploaded to the VK'S platform. Actions available for this item are only opening the audio in a dialog and play it due to limitations in access to audio features. 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 and download. You can control playback of audio items from the buffer by using the player menu on the menu bar."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
"",_(u"""## Main interface"""),
"",_(u"""If you have used [TWBlue](https://github.com/manuelcortez/twblue) before, the socializer's interface is quite similar. Once you have authorised your account, you will see a window with the following elements:"""),
"",_(u"""* A tree view at the left of the window, where you will see the list of buffers. These buffers are divided in three categories, posts, music and people. You could expand each category for seeing the child buffers. There are some additional buffers, timelines and chats, wich will be filled with timelines for your friends or with chats, when you start or receive a chat session."""),
_(u"""* A button for making a post to your wall."""),
_(u"""* In audio buffers, Two buttons: Play and play all."""),
_(u"""* In audio album buffers, a button for loading music. By default, albums are empty, you have to press the load button for getting the album's items."""),
_(u"""* A list where you will see the posts for the currently selected buffer."""),
_(u"""* In people buffers, like the friends buffer, a button for sending a message to your friends. Pressing that button will cause a chat buffer to be created."""),
_(u"""* A status bar where the program will put some useful information about what it's doing at the moment."""),
_(u"""* And a menu bar."""),
"",_(u"""When socializer starts, it will try to load your news items, wall, audios (your audios, recommended and populars) and friends. At the moment there are only a few supported actions for these items:"""),
"",_(u"""* Audio files: You can play the currently selected song, view the song's details (including lyrics, if available), add or remove from your library, and download it to a desired place in your hard drive. You can find audio files in your news feed or in your own audios buffers. You can find audios as post's attachments. You can create an audios timeline for displaying other's audios."""),
_(u"""* News feed's post: In your news feed buffer, you can press return in any post and socializer will open a new dialogue which can be different, depending in the kind of post you are when the return key was pressed. For example it will open the post if you are focusing a "normal" post, a list of people if you are in a post wich indicates that someone has added friends, an audio displayer if you are in a post wich indicates that someone has added an audio, etc."""),
_(u"""* Wall posts: It will show the post in a dialogue so you could interact with its attachments, view and post comments, or like/unlike/share the post."""),
_(u"""* You can send a message to someone by pressing the send message button in the buffer where you are, if available. Deactivated accounts cannot receive messages."""),
"",_(u"""### Making a post"""),
"",_(u"""When you press the post button, a new dialogue will show up. This dialogue allows you to post something in your wall. In this dialogue you have to write a message. You can translate your message and fix your spelling mistakes. Also you can post an URL address, socializer will try to add it as an attachment, so you will not have to worry about this. When you're ready, just press the send button and it'll be done."""),
"",_(u"""If you want to add some photos, you can press the attach button, then press the kind of attachment you want to add. After this, select the file you want to add and you will see it in the list, once processed. When you are done with attachments, press the OK button, and continue with your post. When you are ready, press the send button. Your post could take some time to be published, depending in the amount of files you have added, but it should be displayed in your wall and newsfeed as soon as it is posted."""),
"",_(u"""### Working with posts in news feed"""),
"",_(u"""You can press the return key in any post in your news feed for opening a new dialogue with some information. The information and dialogue will be different if you are viewing a friendship's notification (when someone has added some friends), an audio file, or a regular post."""),
"",_(u"""If you open a regular post in your newsfeed, you will be able to see the comments in a list, indicate if you do like or dislike the post, repost or add a new comment. If the post has some attachments, you'll find a list populated with them, you can press return in an attachment to execute its default action, wich will be different depending on the kind of attachment that you are viewing."""),
"",_(u"""For friend notifications, you can only view the new added friends in a list and there are some kind of posts that aren't handled. It should be improved."""),
"",_(u"""Additionally, you can press the menu Key or the right click for displaying a menu with some quick actions available for the post you are focusing. These actions are different for every post type."""),
"",_(u"""### Working with songs"""),
"",_(u"""Note: the following applies to audio timelines too."""),
"",_(u"""If you want to play or view audio's details, you'll have to navigate to the tree view, and, using the down arrow, look for "my audios", "populars" or "Recommendations". You will see two more buttons, play and play all. The play button will play the currently selected audio, and the play all button will play audios in the current buffer, starting with the current selected item. You can go to the song's list, look for a desired song and press the play button, or Ctrl+return, which is a keyboard shorcut. Take in to account that there are some keyboard shorcuts that only work in the list of items."""),
"",_(u"""You can play audio from any buffer, just press ctrl+return for making the audio playback possible."""),
"",_(u"""If someone has added multiple audios at once to his library, you will see something like this in your newsfeed: "(friend) has added 4 audios: audio 1, audio2, audio3 and audio4". You can press return in the post for opening the audio's details dialogue, where you will be able to see a list with these audios. By default the first detected song is selected, which means that you could read its details by pressing tab, download or add it to your library. If you change the audio in the list, the information will be updated and you will see details and actions will take effect in the new selected audio."""),
"",_(u"""When an audio file is playing, you can press f5 and f6 for decreasing and increasing volume, respectively, or control+shift+return for play/pause."""),
"",_(u"""If you want to see some details for the selected audio file, you can do it by pressing the return key. You will be able to read some useful information (title, artist, duration and the lyric, if available). Also you will be able to download the song to your hard drive, you have to press the download button in the details' dialogue."""),
"",_(u"""When the download starts, you can close the details dialogue and check the status bar in the main window for seeing the current progress."""),
"",_(u"""Additionally, you can search for audios by using the menu bar, in the buffer menu, select search, then audio. It will display a dialog where you have to set your search preferences."""),
"",_(u"""If you press the menu key, you will see a menu where you will be able to do some actions, for example, add the audio to an album, or add/remove the song from your library."""),
"",_(u"""## menu Bar"""),
"",_(u"""You can go to the menu bar by pressing ALT. Right now, there are three menus, application, buffer and help:"""),
"",_(u"""The graphical user interface of Socializer consists of a window containing:"""),
"",_(u"""* a menu bar accomodating five menus (application, Me, buffer, player and help),"""),
_(u"""* One tree view,"""),
_(u"""* One list of items"""),
_(u"""* Some buttons, depending which is the focused buffer."""),
"",_(u"""The actions that are available for every item will be described later."""),
"",_(u"""In summary, the GUI contains two core components. These are the controls you will find while pressing the Tab key within the program's interface, and the different elements present on the menu bar."""),
"",_(u"""### Buttons in the application"""),
"",_(u"""* Post: this button opens up a dialogue box to write a post in your wall. For the moment, only posting in your own wall is supported. You can upload a picture by pressing the "attach" button and the photo button 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."""),
_(u"""* 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."""),
_(u"""* Play all: In audio buffers, play all songs starting from the focused buffer, until the last item in the list."""),
_(u"""* Send message: Send a message to a friend, which will open a conversation buffer if it does not exist already. Conversation buffers contain a full conversation, accommodating chat messages, between the current user and someone else. You can type your message in the provided box and press enter to send it to your friend. Additionally, you can add an attachment (for the moment, only attaching an audio file from your library is supported) and open attachments sent in the focused message by pressing tab and finding them in the attachments list."""),
"",_(u"""Bear in mind that buttons will appear according to which actions are possible on the list you are browsing."""),
"",_(u"""## Menus"""),
"",_(u"""Visually, Towards the top of the main application window, can be found a menu bar which contains many of the same functions as listed in the previous section, together with some additional items. To access the menu bar, press the alt key. You will find five menus listed: application, Me, buffer, player and help. This section describes the items on each one of them."""),
"",_(u"""### Application menu"""),
"",_(u"""* Create. Here you can create some things in VK. The only supported item at this moment is the audio album."""),
_(u"""* Delete: Removes items from the VK servers. The only supported item here is the audio album."""),
_(u"""* you can set your preferences by opening the preferences dialog located in this menu."""),
"",_(u"""* Create: opens a menu where you can create a new album. At the moment, only video albums are supported."""),
_(u"""* Delete: opens a menu where you can delete an already existing album owned by yourself. Only video albums are supported at this time."""),
_(u"""* Preferences: Opens a dialogue which lets you configure settings for the entire application."""),
"",_(u"""### Me menu"""),
"",_(u"""* Profile: Opens a menu with several options to do in your profile:"""),
_(u""" * View profile: Displays your profile in a dialog in the application."""),
_(u""" * Open in browser: Redirects you to your profile in vk.com."""),
"",_(u"""### Buffer menu"""),
"",_(u"""* new timeline: This option allows you to create a new timeline. This kind of buffers is capable of download all posts in an user's profile."""),
_(u"""* search: This submenu allows you to create a new buffer, at the moment, you can create only a kind of buffer, an audio search. The audio search will be located in the music category and will have the last 299 results of your query."""),
_(u"""* Update current buffer: perform an update operation in the selected buffer, which will retrieve the new items."""),
_(u"""* Load previous items: Get the previous items for the currently focused buffer."""),
_(u"""* Remove buffer: Tries to remove the current buffer. Default buffers can't be removed."""),
"",_(u"""The help menu is self explanatory."""),
"",_(u"""## Contributing"""),
"",_(u"""If you notice some errors in this document, or features that are not documented yet, you can suggest those changes by contacting me (more information can be find in the following section)."""),
"",_(u"""## contact"""),
"",_(u"""If you have questions, don't esitate to contact me in [Twitter,](https://twitter.com/manuelcortez00) or sending me an email to manuel(at)manuelcortez(dot)net. Just replace the words in parentheses with the original signs."""),
"",_(u"""* 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."""),
_(u"""* 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"."""),
_(u"""* 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."""),
_(u"""* Load previous items: This allows more items to be loaded for the specified buffer. Bear in mind that not all buffers support this setting."""),
_(u"""* Destroy: dismisses the list you're on, if possible."""),
"",_(u"""### Player menu"""),
"",_(u"""* Play: Plays the currently focused audio item, if the current buffer contains audio files. If not, plays the focused audio in the "my music" buffer."""),
_(u"""* Play all: Plays all audio items in the current buffer or the "my music" buffer, starting by the currently focused audio item until the last audio in the list."""),
_(u"""* Stop: Stops audio playback."""),
_(u"""* Previous: Plays the previous audio in the buffer or the last item in the list, if the current audio was the first on the buffer."""),
_(u"""* Next: Plays the Next audio in the buffer or the first item in the list, if the current audio was the last on the buffer."""),
_(u"""* Shuffle: Plays all audios in the current buffer or the "my music" buffer shuffled."""),
_(u"""* Volume up: Increases volume by 5%."""),
_(u"""* Volume down: decreases volume by 5%."""),
_(u"""* Mute: Mutes audio playback, setting volume to 0%."""),
"",_(u"""### help menu"""),
"",_(u"""* About Socializer: shows the credits of the program."""),
_(u"""* Documentation: opens up this file, where you can read some useful program concepts."""),
_(u"""* Check for updates: every time you open the program it automatically checks for new versions. If an update is available, it will ask you if you want to download the update. If you accept, the updating process will commence. When complete, Socializer will be restarted. This item checks for new updates without having to restart the application."""),
_(u"""* Changelog: opens up a document with the list of changes from the current version to the earliest."""),
"",_(u"""## Keyboard shortcuts"""),
"",_(u"""## configuration"""),
"",_(u"""### The general tab"""),
"",_(u"""### The chats tab"""),
"",_(u"""## License and source code"""),
"",_(u"""Socializer is free software, licensed under the GNU GPL license, either version 2 or, at your option, any later version. You can view the license in the file named license.txt, or online at <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>."""),
"",_(u"""The source code of the program is available at <https://code.manuelcortez.net/manuelcortez/socializer>."""),
"",_(u"""## Contact"""),
"",_(u"""If you still have questions after reading this document, if you wish to collaborate to the project in some other way, or if you simply want to get in touch with the application developer, follow the VK account of [Manuel Cortez.](https://vk.com/manuelcortez) You can also visit [The project website.](https://manuelcortez.net/socializer)"""),
"",_(u"""## Credits"""),
"",_(u"""Socializer is developed and mantained by [Manuel Cortez,](https://manuelcortez.net) with contributions by [Anibal Hernandez](https://dragodark.com)"""),
"",_(u"""We would also like to thank the translators of Socializer, who have allowed the spreading of the application."""),
"",_(u"""* English: Manuel Cortéz."""),
_(u"""* Spanish: Manuel Cortéz."""),
_(u"""* Russian: Valeria K."""),
]

View File

@@ -1,14 +0,0 @@
#! /usr/bin/env python# -*- coding: iso-8859-1 -*-
import shutil
def create_build():
os.chdir("../src")
print "Current path is {0}".format(os.getcwd())
subprocess.call(["C:\python27x86\python.exe", "setup.py", "py2exe"])
def create_archive():
print "Creating zip archive..."
shutil.make_archive("socializer-nightly-build", "zip", "socializer")
shutil.rmtree("socializer")
create_archive()

Binary file not shown.

18
requirements.txt Normal file
View File

@@ -0,0 +1,18 @@
wxpython
pywin32
markdown
vk_api
bs4
configobj
pypubsub==3.3.0
requests-oauthlib
future
arrow
backports.functools_lru_cache
yandex.translate
mutagen
# forked repositories previously found at http://q-continuum.net
git+https://code.manuelcortez.net/manuelcortez/libloader
git+https://code.manuelcortez.net/manuelcortez/platform_utils
git+https://github.com/chrisnorman7/sound_lib
git+https://code.manuelcortez.net/manuelcortez/accessible_output2

View File

@@ -0,0 +1,15 @@
#! /usr/bin/env python# -*- coding: iso-8859-1 -*-
import shutil
import os
def create_archive():
os.chdir("..\\src")
print "Creating zip archive..."
shutil.make_archive("socializer", "zip", "dist")
if os.path.exists("dist"):
shutil.rmtree("dist")
if os.path.exists("build"):
shutil.rmtree("build")
os.chdir("..\\scripts")
create_archive()

View File

@@ -8,10 +8,11 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-29 13:16-0500\n"
"POT-Creation-Date: 2018-12-16 06:25-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -20,51 +21,13 @@ msgstr ""
msgid "User default"
msgstr ""
#, python-format
msgid "%d day, "
msgstr ""
#, python-format
msgid "%d days, "
msgstr ""
#, python-format
msgid "%d hour, "
msgstr ""
#, python-format
msgid "%d hours, "
msgstr ""
#, python-format
msgid "%d minute, "
msgstr ""
#, python-format
msgid "%d minutes, "
msgstr ""
#, python-format
msgid "%s second"
msgstr ""
#, python-format
msgid "%s seconds"
msgstr ""
msgid "Downloading {0}"
msgstr ""
msgid "Downloading {0} ({1}%)"
msgstr ""
msgid "Ready"
msgstr ""
#. Translators: This is the text displayed in the attachments dialog, when the user adds a photo.
msgid "Photo"
msgstr ""
msgid "Select the audio files you want to send"
msgstr ""
msgid "Write your post"
msgstr ""
@@ -99,6 +62,7 @@ msgid "Select the album where you want to move this song"
msgstr ""
#. Translators: Used when the user has moved an audio to an album.
#. Translators: Used when the user has moved an video to an album.
msgid "Moved"
msgstr ""
@@ -108,9 +72,64 @@ msgstr ""
msgid "Loading album..."
msgstr ""
msgid "Opening video in webbrowser..."
msgstr ""
msgid "Video added to your library"
msgstr ""
msgid "Removed video from library"
msgstr ""
msgid "Select the album where you want to move this video"
msgstr ""
msgid "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."
msgstr ""
msgid "Playing..."
msgstr ""
msgid "Opening URL..."
msgstr ""
msgid "Opening document in web browser..."
msgstr ""
msgid "Opening video in web browser..."
msgstr ""
msgid "Opening photo in web browser..."
msgstr ""
#, python-brace-format
msgid "{0} {1} now is your friend."
msgstr ""
#, python-brace-format
msgid "You've deleted the friends request to {0} {1}."
msgstr ""
#, python-brace-format
msgid "You've declined the friend request of {0} {1}."
msgstr ""
#, python-brace-format
msgid "{0} {1} is following you."
msgstr ""
msgid "Native"
msgstr ""
msgid "Custom"
msgstr ""
msgid "Preferences"
msgstr ""
msgid "Ready"
msgstr ""
#. Translators: Name for the posts tab in the tree view.
msgid "Posts"
msgstr ""
@@ -130,21 +149,31 @@ msgstr ""
msgid "My audios"
msgstr ""
msgid "Populars"
msgstr ""
msgid "Recommendations"
msgstr ""
msgid "Albums"
msgstr ""
#. Translators: name for the videos category in the tree view.
msgid "Video"
msgstr ""
msgid "My videos"
msgstr ""
msgid "People"
msgstr ""
msgid "Friends"
msgstr ""
msgid "Friendship requests"
msgstr ""
msgid "Pending requests"
msgstr ""
msgid "I follow"
msgstr ""
msgid "Chats"
msgstr ""
@@ -155,37 +184,66 @@ msgid "Logging in VK"
msgstr ""
#. Translators: {0} will be replaced with the name of a buffer.
#, python-brace-format
msgid "Loading items for {0}"
msgstr ""
msgid "Chat server reconnected"
msgstr ""
msgid "This file could not be played because it is not allowed in your country"
msgstr ""
#. Translators: {0} will be replaced with the search term.
#, python-brace-format
msgid "Search for {0}"
msgstr ""
#. Translators: {0} will be replaced with an user.
#, python-brace-format
msgid "{0}'s audios"
msgstr ""
#. Translators: {0} will be replaced with an user.
#, python-brace-format
msgid "{0}'s wall posts"
msgstr ""
#. Translators: {0} will be replaced with an user.
#, python-brace-format
msgid "{0}'s friends"
msgstr ""
#. Translators: {0} will be replaced with an user.
#, python-brace-format
msgid "Chat with {0}"
msgstr ""
#, python-brace-format
msgid "{0} is online."
msgstr ""
#, python-brace-format
msgid "{0} is offline."
msgstr ""
#. Translators: {0} Will be replaced with an audio album's title.
#. Translators: {0} Will be replaced with a video album's title.
#. Translators: {0} will be replaced with an audio album's title.
#. Translators: {0} will be replaced with a video album's title.
#, python-brace-format
msgid "Album: {0}"
msgstr ""
msgid "Select the album you want to delete"
msgstr ""
msgid "Socializer"
msgstr ""
msgid "Chat disconnected. Trying to connect in 60 seconds"
msgstr ""
msgid "Friends of friends"
msgstr ""
@@ -198,43 +256,40 @@ msgstr ""
msgid "New comment"
msgstr ""
#. Translators: {0} will be replaced with a song's title and {1} with the artist.
#, python-brace-format
msgid "Playing {0} by {1}"
msgstr ""
#. Translators: This string is user when socializer can't find the right user information.
#. Translators: This string is used when socializer can't find the right user information.
msgid "Unknown username"
msgstr ""
msgid "Link"
msgstr ""
msgid "no description available"
msgstr ""
msgid "Video"
msgstr ""
msgid "Audio"
msgstr ""
msgid "{0} file"
#, python-brace-format
msgid "{0} > {1}"
msgstr ""
#. Translators: {0} will be replaced with an user.
#, python-brace-format
msgid "repost from {0}"
msgstr ""
#. Translators: {0} will be replaced with the user who is posting, and {2} with the wall owner.
#. Translators: {0} will be replaced with the user who is posting, and {1} with the wall owner.
#, python-brace-format
msgid "Post from {0} in the {1}'s wall"
msgstr ""
#, python-brace-format
msgid "Post from {0}"
msgstr ""
msgid "Untitled link"
msgstr ""
#. Translators: {0} is the number of the current photo and {1} is the total number of photos.
#, python-brace-format
msgid "Loaded photo {0} of {1}"
msgstr ""
msgid "&Dislike"
msgstr ""
@@ -253,24 +308,81 @@ msgstr ""
msgid "You don't like this comment"
msgstr ""
msgid "Opening URL..."
msgstr ""
msgid "Opening document in web browser..."
msgstr ""
msgid "Opening video in web browser..."
msgstr ""
msgid "Opening photo in web browser..."
msgstr ""
#, python-brace-format
msgid "Comment from {0}"
msgstr ""
#, python-brace-format
msgid "{0} added the following friends"
msgstr ""
msgid "Profile"
msgstr ""
msgid "Information for groups is not supported, yet."
msgstr ""
msgid "MMMM D"
msgstr ""
msgid "MMMM D, YYYY"
msgstr ""
#, python-brace-format
msgid "{name}'s profile"
msgstr ""
msgid "Work "
msgstr ""
msgid "Student "
msgstr ""
#, python-brace-format
msgid "In {0}"
msgstr ""
msgid "Single"
msgstr ""
#, python-brace-format
msgid "Dating with {0} {1}"
msgstr ""
msgid "Dating"
msgstr ""
#, python-brace-format
msgid "Engaged with {0} {1}"
msgstr ""
#, python-brace-format
msgid "Married with {0} {1}"
msgstr ""
msgid "It's complicated"
msgstr ""
msgid "Actively searching"
msgstr ""
msgid "In love"
msgstr ""
msgid "Relationship: "
msgstr ""
#. Translators: This is the date of last seen
#, python-brace-format
msgid "{0}"
msgstr ""
msgid "Opening website..."
msgstr ""
msgid "No URL addresses were detected."
msgstr ""
#, python-format
msgid "Misspelled word: %s"
msgstr ""
@@ -296,6 +408,7 @@ msgstr ""
msgid "Replace a&ll"
msgstr ""
#, python-brace-format
msgid "An error has occurred. There are no dictionaries available for the selected language in {0}"
msgstr ""
@@ -578,49 +691,117 @@ msgstr ""
msgid "Yiddish"
msgstr ""
msgid "autodetect"
msgstr ""
msgid "Translate message"
msgstr ""
msgid "&Source language"
msgid "Target language"
msgstr ""
msgid "&Target language"
msgid "photo with no description available"
msgstr ""
#. Translators: This is the date of last seen
msgid "{0}"
#, python-brace-format
msgid "video: {0}"
msgstr ""
msgid "Account deactivated"
msgstr ""
#, python-brace-format
msgid "{0} has shared the {1}'s post"
msgstr ""
#, python-brace-format
msgid "{0} has added an audio: {1}"
msgstr ""
#, python-brace-format
msgid "{0} has added {1} audios: {2}"
msgstr ""
msgid "{0} hadded friends: {1}"
#, python-brace-format
msgid "{0} added friends: {1}"
msgstr ""
#, python-brace-format
msgid "{0} has added a video: {1}"
msgstr ""
#, python-brace-format
msgid "{0} has added {1} videos: {2}"
msgstr ""
msgid "dddd, MMMM D, YYYY H:m:s"
msgid "H:mm."
msgstr ""
msgid "H:mm. dddd, MMMM D, YYYY"
msgstr ""
msgid "Audio removed from library"
msgstr ""
msgid "Video not available"
msgstr ""
msgid "Voice message not available"
msgstr ""
#, python-format
msgid "%d day, "
msgstr ""
#, python-format
msgid "%d days, "
msgstr ""
#, python-format
msgid "%d hour, "
msgstr ""
#, python-format
msgid "%d hours, "
msgstr ""
#, python-format
msgid "%d minute, "
msgstr ""
#, python-format
msgid "%d minutes, "
msgstr ""
#, python-format
msgid "%s second"
msgstr ""
#, python-format
msgid "%s seconds"
msgstr ""
#, python-brace-format
msgid "Downloading {0}"
msgstr ""
#, python-brace-format
msgid "Downloading {0} ({1}%)"
msgstr ""
msgid "Link"
msgstr ""
msgid "no description available"
msgstr ""
msgid "Audio"
msgstr ""
#, python-brace-format
msgid "{0} file"
msgstr ""
msgid "Voice message"
msgstr ""
msgid "In order to continue, you need to configure your VK account before. Would you like to autorhise a new account now?"
msgstr ""
@@ -672,6 +853,7 @@ msgstr ""
msgid "Information needed"
msgstr ""
#, python-brace-format
msgid "Your {0} version is up to date"
msgstr ""
@@ -690,6 +872,7 @@ msgstr ""
msgid "Restricted access"
msgstr ""
#, python-brace-format
msgid "Access to user's audio is denied by the owner. Error code {0}"
msgstr ""
@@ -699,7 +882,9 @@ msgstr ""
msgid "Do you really want to delete this Album? this will be deleted from VK too."
msgstr ""
msgid "Audio album"
#. self.audio_album = create.Append(wx.NewId(), _(u"Audio album"))
#. self.delete_audio_album = delete.Append(wx.NewId(), _(u"Audio album"))
msgid "Video album"
msgstr ""
msgid "Create"
@@ -708,6 +893,18 @@ msgstr ""
msgid "Delete"
msgstr ""
msgid "View profile"
msgstr ""
msgid "Edit profile"
msgstr ""
msgid "Open in browser"
msgstr ""
msgid "Set status message"
msgstr ""
msgid "&New timeline"
msgstr ""
@@ -726,9 +923,40 @@ msgstr ""
msgid "Application"
msgstr ""
msgid "Me"
msgstr ""
msgid "Buffer"
msgstr ""
msgid "Play"
msgstr ""
msgid "Play all"
msgstr ""
msgid "Stop"
msgstr ""
msgid "Previous"
msgstr ""
msgid "Next"
msgstr ""
msgid "Shuffle"
msgstr ""
msgid "Volume up"
msgstr ""
msgid "Volume down"
msgstr ""
msgid "Mute"
msgstr ""
#, python-brace-format
msgid "About {0}"
msgstr ""
@@ -741,6 +969,9 @@ msgstr ""
msgid "Chan&gelog"
msgstr ""
msgid "Audio player"
msgstr ""
msgid "Help"
msgstr ""
@@ -765,6 +996,9 @@ msgstr ""
msgid "Post to this profile"
msgstr ""
msgid "View user profile"
msgstr ""
msgid "&Open"
msgstr ""
@@ -777,15 +1011,24 @@ msgstr ""
msgid "Move to album"
msgstr ""
msgid "View profile"
msgstr ""
msgid "Send a message"
msgstr ""
msgid "Open timeline"
msgstr ""
msgid "View friends in common"
msgstr ""
msgid "Accept"
msgstr ""
msgid "Decline"
msgstr ""
msgid "Keep as follower"
msgstr ""
msgid "Unlike"
msgstr ""
@@ -810,6 +1053,9 @@ msgstr ""
msgid "&Photo"
msgstr ""
msgid "Audio file"
msgstr ""
msgid "Remove attachment"
msgstr ""
@@ -828,12 +1074,33 @@ msgstr ""
msgid "Number of items to load for newsfeed and wall buffers (maximun 100)"
msgstr ""
msgid "Number of items to load in audio buffers (maximun 1000)"
msgid "Number of items to load in video buffers (maximun 200)"
msgstr ""
msgid "Load images in posts"
msgstr ""
msgid "Show notifications when users are online"
msgstr ""
msgid "Show notifications when users are offline"
msgstr ""
msgid "Open unread conversations at startup"
msgstr ""
msgid "Move focus to new conversations"
msgstr ""
msgid "Notification type"
msgstr ""
msgid "General"
msgstr ""
msgid "Chat settings"
msgstr ""
msgid "Save"
msgstr ""
@@ -858,6 +1125,9 @@ msgstr ""
msgid "Attach"
msgstr ""
msgid "Tag a friend"
msgstr ""
msgid "Spelling &correction"
msgstr ""
@@ -870,9 +1140,6 @@ msgstr ""
msgid "Spelling correction"
msgstr ""
msgid "Audio player"
msgstr ""
msgid "Message"
msgstr ""
@@ -891,15 +1158,26 @@ msgstr ""
msgid "Likes"
msgstr ""
msgid "Previous photo"
msgstr ""
msgid "View in full screen"
msgstr ""
msgid "Next photo"
msgstr ""
msgid "Loading data..."
msgstr ""
msgid "Actions"
msgstr ""
#, python-brace-format
msgid "{0} people like this"
msgstr ""
#, python-brace-format
msgid "Shared {0} times"
msgstr ""
@@ -936,22 +1214,43 @@ msgstr ""
msgid "Friend"
msgstr ""
msgid "Name"
msgstr ""
msgid "Status"
msgstr ""
msgid "Last seen"
msgstr ""
msgid "Birthdate"
msgstr ""
msgid "Current city"
msgstr ""
msgid "Home Town"
msgstr ""
msgid "Website"
msgstr ""
msgid "Visit website"
msgstr ""
msgid "Occupation"
msgstr ""
msgid "Basic information"
msgstr ""
msgid "audio Search"
msgstr ""
msgid "&Search"
msgstr ""
msgid "Try to &correct for mistakes in the search term"
msgstr ""
msgid "Search only songs with associated &lyrics"
msgstr ""
msgid "Search by"
msgstr ""
msgid "&artist"
msgid "video Search"
msgstr ""
msgid "&Sort order by: "
@@ -966,6 +1265,34 @@ msgstr ""
msgid "Popularity"
msgstr ""
msgid "Search only for videos in &High definition"
msgstr ""
msgid "S&afe search"
msgstr ""
msgid "Tag friends"
msgstr ""
msgid "All friends"
msgstr ""
msgid "Select"
msgstr ""
msgid "Tagged users"
msgstr ""
msgid "Remove"
msgstr ""
msgid "Available attachments"
msgstr ""
msgid "Selected attachments"
msgstr ""
#, python-brace-format
msgid "New timeline for {0}"
msgstr ""
@@ -1005,26 +1332,23 @@ msgstr ""
msgid "Notification"
msgstr ""
msgid "Name"
msgstr ""
msgid "Photos"
msgstr ""
msgid "Created at"
msgstr ""
msgid "History"
msgid "Add"
msgstr ""
msgid "post"
msgid "History"
msgstr ""
msgid "Write a message"
msgstr ""
msgid "Last seen"
msgstr ""
msgid "Send message"
msgstr ""
msgid "Video&s"
msgstr ""

View File

@@ -1,33 +0,0 @@
from __future__ import absolute_import
import ctypes
import os
import types
from platform_utils import paths
def load_library(libname, cdll=False):
if paths.is_frozen():
libfile = os.path.join(paths.embedded_data_path(), 'accessible_output2', 'lib', libname)
else:
libfile = os.path.join(paths.module_path(), 'lib', libname)
if cdll:
return ctypes.cdll[libfile]
else:
return ctypes.windll[libfile]
def get_output_classes():
from . import outputs
module_type = types.ModuleType
classes = [m.output_class for m in outputs.__dict__.values() if type(m) == module_type and hasattr(m, 'output_class')]
return sorted(classes, key=lambda c: c.priority)
def find_datafiles():
import os
import platform
from glob import glob
import accessible_output2
if platform.system() != 'Windows':
return []
path = os.path.join(accessible_output2.__path__[0], 'lib', '*.dll')
results = glob(path)
dest_dir = os.path.join('accessible_output2', 'lib')
return [(dest_dir, results)]

View File

@@ -1,20 +0,0 @@
from __future__ import absolute_import
import platform
if platform.system() == 'Windows':
from . import nvda
from . import jaws
from . import sapi5
from . import window_eyes
from . import system_access
from . import dolphin
from . import pc_talker
#import sapi4
if platform.system() == 'Darwin':
from . import voiceover
from . import say
if platform.system() == 'Linux':
from . import e_speak
from . import auto

View File

@@ -1,40 +0,0 @@
from __future__ import absolute_import
import accessible_output2
from .base import Output, OutputError
class Auto(Output):
def __init__(self):
output_classes = accessible_output2.get_output_classes()
self.outputs = []
for output in output_classes:
try:
self.outputs.append(output())
except OutputError:
pass
def get_first_available_output(self):
for output in self.outputs:
if output.is_active():
return output
return None
def speak(self, *args, **kwargs):
output = self.get_first_available_output()
if output:
output.speak(*args, **kwargs)
def braille(self, *args, **kwargs):
output = self.get_first_available_output()
if output:
output.braille(*args, **kwargs)
def output(self, *args, **kwargs):
output = self.get_first_available_output()
if output:
output.speak(*args, **kwargs)
def is_system_output(self):
output = self.get_first_available_output()
if output:
return output.is_system_output()

View File

@@ -1,47 +0,0 @@
from accessible_output2 import load_library
import platform
class OutputError(Exception):
pass
class Output(object):
name = "Unnamed Output"
lib32 = None
lib64 = None
argtypes = {}
cdll = False
priority = 100
system_output = False
def __init__(self):
self.is_32bit = platform.architecture()[0] == "32bit"
if self.lib32 and self.is_32bit:
self.lib = load_library(self.lib32, cdll=self.cdll)
elif self.lib64:
self.lib = load_library(self.lib64, cdll=self.cdll)
else:
self.lib = None
if self.lib is not None:
for func in self.argtypes:
try:
getattr(self.lib, func).argtypes = self.argtypes[func]
except AttributeError:
pass
def output(self, text, **options):
output = False
if self.speak(text, **options):
output = True
if self.braille(text, **options):
output = True
if not output:
raise RuntimeError("Output %r does not have any method defined to output" % self)
def is_system_output(self):
return self.system_output
def speak(self, **optiont):
return False
def braille(self, *args, **options):
return False

View File

@@ -1,33 +0,0 @@
from __future__ import absolute_import
import os
import ctypes
from .base import Output
class Dolphin (Output):
"""Supports dolphin products."""
name = 'Dolphin'
lib32 = 'dolapi.dll'
argtypes = {
'DolAccess_Command': (ctypes.c_wchar_p, ctypes.c_int, ctypes.c_int),
'DolAccess_Action': (ctypes.c_int,),
}
def speak(self, text, interrupt=0):
if interrupt:
self.silence()
#If we don't call this, the API won't let us speak.
if self.is_active():
self.lib.DolAccess_Command(text, (len(text)*2)+2, 1)
def silence(self):
self.lib.DolAccess_Action(141)
def is_active(self):
try:
return self.lib.DolAccess_GetSystem() in (1, 4, 8)
except:
return False
output_class = Dolphin

View File

@@ -1,31 +0,0 @@
from __future__ import absolute_import
from .base import Output
try:
import espeak.core
except:
raise RuntimeError("Cannot find espeak.core. Please install python-espeak")
class ESpeak(Output):
"""Speech output supporting ESpeak on Linux
Note this requires python-espeak to be installed
This can be done on Debian distros by using apt-get install python-espeak
Or through this tarball: https://launchpad.net/python-espeak
"""
name = "Linux ESpeak"
def is_active(self):
try:
import espeak.core
except:
return False
return True
def speak(self, text, interrupt = 0):
if interrupt:
self.silence()
espeak.core.synth(text)
def silence(self):
espeak.core.cancel()
output_class = ESpeak

View File

@@ -1,34 +0,0 @@
from __future__ import absolute_import
import win32gui
from libloader.com import load_com
import pywintypes
from .base import Output, OutputError
class Jaws (Output):
"""Output supporting the Jaws for Windows screen reader."""
name = 'jaws'
def __init__(self, *args, **kwargs):
super (Jaws, self).__init__(*args, **kwargs)
try:
self.object = load_com("FreedomSci.JawsApi", "jfwapi")
except pywintypes.com_error:
raise OutputError
def braille(self, text, **options):
# HACK: replace " with ', Jaws doesn't seem to understand escaping them with \
text = text.replace('"', "'")
self.object.RunFunction("BrailleString(\"%s\")" % text)
def speak(self, text, interrupt=False):
self.object.SayString(' %s' % text, interrupt)
def is_active(self):
try:
return self.object.SayString('',0) == True or win32gui.FindWindow("JFWUI2", "JAWS") != 0
except:
return False
output_class = Jaws

View File

@@ -1,37 +0,0 @@
from __future__ import absolute_import
import os
import platform
import ctypes
from platform_utils import paths
from libloader import load_library
from .base import Output
class NVDA(Output):
"""Supports The NVDA screen reader"""
name = "NVDA"
lib32 = 'nvdaControllerClient32.dll'
lib64 = 'nvdaControllerClient64.dll'
argtypes = {
'nvdaController_brailleMessage': (ctypes.c_wchar_p,),
'nvdaController_speakText': (ctypes.c_wchar_p,),
}
def is_active(self):
try:
return self.lib.nvdaController_testIfRunning() == 0
except:
return False
def braille(self, text, **options):
self.lib.nvdaController_brailleMessage(text)
def speak(self, text, interrupt=False):
if interrupt:
self.silence()
self.lib.nvdaController_speakText(text)
def silence(self):
self.lib.nvdaController_cancelSpeech()
output_class = NVDA

View File

@@ -1,24 +0,0 @@
from __future__ import absolute_import
import ctypes
from .base import Output
class PCTalker(Output):
lib32 = 'pctkusr.dll'
lib64 = 'pctkusr64.dll'
cdll = True
argtypes = {
'PCTKPRead': (ctypes.c_char_p, ctypes.c_int, ctypes.c_int)
}
def speak(self, text, interrupt=False):
if interrupt:
self.silence()
self.lib.PCTKPRead(text.encode('cp932', 'replace'), 0, 1)
def silence(self):
self.lib.PCTKVReset()
def is_active(self):
return self.lib.PCTKStatus() != 0
output_class = PCTalker

View File

@@ -1,143 +0,0 @@
from __future__ import absolute_import
from builtins import range
from libloader.com import load_com
from .base import Output
import logging
log = logging.getLogger(__name__)
class Sapi4(Output):
name = 'sapi4'
priority = 102
def __init__(self):
sapi4 = load_com("{EEE78591-FE22-11D0-8BEF-0060081841DE}")
self._voiceNo = sapi4.Find(0)
sapi4.Select(self._voiceNo)
sapi4.Speak(" ")
self.__object = sapi4
self._voice_list = self._available_voices()
def _set_capabilities(self):
sapi4 = self.__object
try:
sapi4.Pitch = sapi4.Pitch
self._min_pitch = sapi4.MinPitch
self._max_pitch = sapi4.MaxPitch
self._has_pitch = True
except:
self._min_pitch = 0
self._max_pitch = 0
self._has_pitch = False
try:
sapi4.Speed = sapi4.Speed
self._min_rate = sapi4.MinSpeed
self._max_rate = sapi4.MaxSpeed
self._has_rate = True
except:
self._min_rate = 0
self._max_rate = 0
self._has_rate = False
try:
sapi4.VolumeLeft = sapi4.VolumeLeft
self._min_volume = sapi4.MinVolumeLeft
self._max_volume = sapi4.MaxVolumeLeft
self._has_volume = True
except:
self._min_volume = 0
self._max_volume = 0
self._has_volume = False
def _available_voices(self):
voice_list = []
for voice_no in range(1, self.__object.CountEngines):
voice_list.append(self.__object.ModeName(voice_no))
return voice_list
@property
def available_voices(self):
return self._voice_list
def list_voices(self):
return self.available_voices
def get_voice(self):
return self.__object.ModeName(self._voice_no)
def set_voice(self, value):
self._voice_no = self.list_voices().index(value) + 1
self.__object.Select(self._voice_no)
self.silence()
self.__object.Speak(" ")
self._set_capabilities()
def get_pitch(self):
if self.has_pitch:
return self.__object.Pitch
def set_pitch(self, value):
if self.has_pitch:
self.__object.Pitch = value
def get_rate(self):
if self.has_rate:
return self.__object.Speed
def set_rate(self, value):
if self.has_rate:
self.__object.Speed = value
def get_volume(self):
if self.has_volume:
return self.__object.VolumeLeft
def set_volume(self, value):
if self.has_volume:
self.__object.VolumeLeft = value
@property
def has_pitch(self):
return self._has_pitch
@property
def has_rate(self):
return self._has_rate
@property
def has_volume(self):
return self._has_volume
@property
def min_pitch(self):
return self._min_pitch
@property
def max_pitch(self):
return self._max_pitch
@property
def min_rate(self):
return self._min_rate
@property
def max_rate(self):
return self._max_rate
@property
def min_volume(self):
return self._min_volume
@property
def max_volume(self):
return self._max_volume
def speak(self, text, interrupt=False):
if interrupt:
self.silence()
self.__object.Speak(text)
def silence(self):
self.__object.AudioReset()
output_class = Sapi4

View File

@@ -1,95 +0,0 @@
from __future__ import absolute_import
from collections import OrderedDict
from libloader.com import load_com
from .base import Output, OutputError
import pywintypes
import logging
log = logging.getLogger(__name__)
SVSFDefault = 0
SVSFlagsAsync = 1
SVSFPurgeBeforeSpeak = 2
SVSFIsFilename = 4
SVSFIsXML = 8
SVSFIsNotXML = 16
SVSFPersistXML = 32
class SAPI5(Output):
has_volume = True
has_rate = True
has_pitch = True
min_pitch = -10
max_pitch = 10
min_rate = -10
max_rate = 10
min_volume = 0
max_volume = 100
name = "sapi5"
priority = 101
system_output = True
def __init__(self):
try:
self.object = load_com("SAPI.SPVoice")
self._voices = self._available_voices()
except pywintypes.com_error:
raise OutputError
self._pitch = 0
def _available_voices(self):
_voices = OrderedDict()
for v in self.object.GetVoices():
_voices[v.GetDescription()] = v
return _voices
def list_voices(self):
return list(self._voices.keys())
def get_voice(self):
return self.object.Voice.GetDescription()
def set_voice(self, value):
log.debug("Setting SAPI5 voice to \"%s\"" % value)
self.object.Voice = self._voices[value]
# For some reason SAPI5 does not reset audio after changing the voice
# By setting the audio device after changing voices seems to fix this
# This was noted from information at:
# http://lists.nvaccess.org/pipermail/nvda-dev/2011-November/022464.html
self.object.AudioOutput = self.object.AudioOutput
def get_pitch(self):
return self._pitch
def set_pitch(self, value):
log.debug("Setting pitch to %d" % value)
self._pitch = value
def get_rate(self):
return self.object.Rate
def set_rate(self, value):
log.debug("Setting rate to %d" % value)
self.object.Rate = value
def get_volume(self):
return self.object.Volume
def set_volume(self, value):
self.object.Volume = value
def speak(self, text, interrupt=False):
if interrupt:
self.silence()
# We need to do the pitch in XML here
textOutput = "<pitch absmiddle=\"%d\">%s</pitch>" % (round(self._pitch), text.replace("<", "&lt;"))
self.object.Speak(textOutput, SVSFlagsAsync | SVSFIsXML)
def silence(self):
self.object.Speak("", SVSFlagsAsync | SVSFPurgeBeforeSpeak)
def is_active(self):
if self.object:
return True
return False
output_class = SAPI5

View File

@@ -1,21 +0,0 @@
from __future__ import absolute_import
import os
from .base import Output
class AppleSay(Output):
"""Speech output supporting the Apple Say subsystem."""
name = 'Apple Say'
def __init__(self, voice = 'Alex', rate = '300'):
self.voice = voice
self.rate = rate
super(AppleSay, self).__init__()
def is_active(self):
return not os.system('which say')
def speak(self, text, interrupt = 0):
if interrupt:
self.silence()
os.system('say -v %s -r %s "%s" &' % (self.voice, self.rate, text))
def silence(self):
os.system('killall say')
output_class = AppleSay

View File

@@ -1,29 +0,0 @@
from __future__ import absolute_import
import ctypes
from .base import Output
class SystemAccess (Output):
"""Supports System Access and System Access Mobile"""
name = "System Access"
lib32 = 'saapi32.dll'
argtypes = {
'SA_BrlShowTextW': (ctypes.c_wchar_p,),
'SA_SayW': (ctypes.c_wchar_p,),
}
priority = 99
def braille(self, text, **options):
self.lib.SA_BrlShowTextW(text)
def speak(self, text, interrupt=False):
if self.is_active():
self.dll.SA_SayW(str(text))
def is_active(self):
try:
return self.dll.SA_IsRunning()
except:
return False
output_class = SystemAccess

View File

@@ -1 +0,0 @@
from __future__ import absolute_import

View File

@@ -1,33 +0,0 @@
from __future__ import absolute_import
import win32gui
from libloader.com import load_com
from .base import Output, OutputError
import pywintypes
class WindowEyes (Output):
"""Speech output supporting the WindowEyes screen reader"""
name = 'Window-Eyes'
def __init__(self, *args, **kwargs):
super(WindowEyes, self).__init__(*args, **kwargs)
try:
self.object = load_com("gwspeak.speak")
except pywintypes.com_error:
raise OutputError
def speak(self, text, interrupt=0):
if interrupt:
self.silence()
self.object.SpeakString(text)
def silence (self):
self.object.Silence()
def is_active(self):
try:
return win32gui.FindWindow("GWMExternalControl", "External Control") != 0
except:
return False
output_class = WindowEyes

View File

@@ -1,12 +1,22 @@
# -*- coding: utf-8 -*-
name = "Socializer"
version = "0.13"
author = u"Manuel Cortéz"
version = "0.17"
author = u"Manuel Cortez"
authorEmail = "manuel@manuelcortez.net"
copyright = u"Copyright (C) 2016, Manuel cortéz."
copyright = u"Copyright (C) 2016-2018, Manuel Cortez"
description = unicode(name+" Is an accessible VK client for Windows.")
url = "https://github.com/manuelcortez/socializer"
update_url = "https://raw.githubusercontent.com/manuelcortez/socializer/master/update-files/socializer.json"
url = "https://manuelcortez.net/socializer"
# The short name will be used for detecting translation files. See languageHandler for more details.
short_name = "socializer"
translators = [u"Valeria K (Russian)", u"Manuel Cortez (Spanish)"]
translators = [u"Darya Ratnikova (Russian)", u"Manuel Cortez (Spanish)"]
bts_name = "socializer"
bts_access_token = "U29jaWFsaXplcg"
bts_url = "https://issues.manuelcortez.net"
### Update information
# URL to retrieve the latest updates for the stable branch.
update_stable_url = "https://code.manuelcortez.net/manuelcortez/socializer/raw/master/update-files/socializer.json"
# URL to retrieve update information for the "next" branch. This is a channel made for alpha versions.
# Every commit will trigger an update, so users wanting to have the bleeding edge code will get it as soon as it is committed here and build by a runner.
update_next_url = "https://code.manuelcortez.net/api/v4/projects/4/repository/commits/master"
# Short_id of the last commit, this is set to none here because it will be set manually by the building tools.
update_next_version = "03286a44"

View File

@@ -1,4 +1,5 @@
# -*- coding: cp1252 -*-
import os
import config_utils
import paths
import logging
@@ -12,5 +13,5 @@ app = None
def setup ():
global app
log.debug("Loading global app settings...")
app = config_utils.load_config(paths.config_path(MAINFILE), paths.app_path(MAINSPEC))
app = config_utils.load_config(os.path.join(paths.config_path(), MAINFILE), os.path.join(paths.app_path(), MAINSPEC))

View File

@@ -1,31 +1,125 @@
# -*- coding: utf-8 -*-
""" Attachment controller for different kind of posts in VK.
this controller will take care of preparing data structures to be uploaded later, when the user decides to start the upload process by sending the post.
"""
import os
import widgetUtils
import logging
import widgetUtils
import audioRecorder
from mutagen.id3 import ID3
from sessionmanager.utils import seconds_to_string
from wxUI.dialogs import attach as gui
log = logging.getLogger("controller.attach")
from wxUI.dialogs import selector
from wxUI.menus import attachMenu
log = logging.getLogger(__file__)
class attach(object):
def __init__(self):
""" Controller used in some sections of the application, it can do the following:
* Handle all user input related to adding local or online files (online files are those already uploaded in vk).
* Prepare local files to be uploaded once a post will be sent (no uploading work is done here, but structured dicts will be generated).
* Parse online files and allow addition of them as attachment, so this controller will add both local and online files in the same dialog.
"""
def __init__(self, session, voice_messages=False):
""" Constructor.
@ session sessionmanager.session object: an object capable of calling all VK methods and accessing the session database.
@voice_messages bool: If True, will add a button for sending voice messages. Functionality for this button has not been added yet.
"""
self.session = session
# Self.attachments will hold a reference to all attachments added to the dialog.
self.attachments = list()
self.dialog = gui.attachDialog()
widgetUtils.connect_event(self.dialog.photo, widgetUtils.BUTTON_PRESSED, self.upload_image)
self.dialog = gui.attachDialog(voice_messages)
widgetUtils.connect_event(self.dialog.photo, widgetUtils.BUTTON_PRESSED, self.on_image)
widgetUtils.connect_event(self.dialog.audio, widgetUtils.BUTTON_PRESSED, self.on_audio)
if voice_messages:
widgetUtils.connect_event(self.dialog.voice_message, widgetUtils.BUTTON_PRESSED, self.upload_voice_message)
widgetUtils.connect_event(self.dialog.remove, widgetUtils.BUTTON_PRESSED, self.remove_attachment)
self.dialog.get_response()
log.debug("Attachments controller started.")
self.dialog.get_response()
def on_image(self, *args, **kwargs):
""" display menu for adding image attachments. """
m = attachMenu()
# disable add from VK as it is not supported in images, yet.
m.add.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.upload_image, menuitem=m.upload)
self.dialog.PopupMenu(m, self.dialog.photo.GetPosition())
def on_audio(self, *args, **kwargs):
""" display menu to add audio attachments."""
m = attachMenu()
widgetUtils.connect_event(m, widgetUtils.MENU, self.upload_audio, menuitem=m.upload)
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_audio, menuitem=m.add)
self.dialog.PopupMenu(m, self.dialog.audio.GetPosition())
def upload_image(self, *args, **kwargs):
""" allows uploading an image from the computer.
"""
image, description = self.dialog.get_image()
if image != None:
imageInfo = {"type": "photo", "file": image, "description": os.path.basename(image)}
log.debug("Image data to upload: %r" % (imageInfo,))
# Define data structure for this attachment, as will be required by VK API later.
imageInfo = {"type": "photo", "file": image, "description": description, "from": "local"}
self.attachments.append(imageInfo)
# Translators: This is the text displayed in the attachments dialog, when the user adds a photo.
info = [_(u"Photo"), os.path.basename(image)]
info = [_(u"Photo"), description]
self.dialog.attachments.insert_item(False, *info)
self.dialog.remove.Enable(True)
def upload_audio(self, *args, **kwargs):
""" Allows uploading an audio file from the computer. Only mp3 files are supported. """
audio = self.dialog.get_audio()
if audio != None:
# Define data structure for this attachment, as will be required by VK API later.
# Let's extract the ID3 tags to show them in the list and send them to VK, too.
audio_tags = ID3(audio)
if "TIT2" in audio_tags:
title = audio_tags["TIT2"].text[0]
else:
title = _(u"Untitled")
if "TPE1" in audio_tags:
artist = audio_tags["TPE1"].text[0]
else:
artist = _(u"Unknown artist")
audioInfo = {"type": "audio", "file": audio, "from": "local", "title": title, "artist": artist}
self.attachments.append(audioInfo)
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.
info = [_(u"Audio file"), u"{title} - {artist}".format(title=title, artist=artist)]
self.dialog.attachments.insert_item(False, *info)
self.dialog.remove.Enable(True)
def upload_voice_message(self, *args, **kwargs):
a = audioRecorder.audioRecorder()
if a.file != None and a.duration != 0:
audioInfo = {"type": "voice_message", "file": a.file, "from": "local"}
self.attachments.append(audioInfo)
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.
info = [_(u"Voice message"), seconds_to_string(a.duration,)]
self.dialog.attachments.insert_item(False, *info)
self.dialog.remove.Enable(True)
def add_audio(self, *args, **kwargs):
""" Allow adding an audio directly from the user's audio library."""
# Let's reuse the already downloaded audios.
list_of_audios = self.session.db["me_audio"]["items"]
audios = []
for i in list_of_audios:
audios.append(u"{0}, {1}".format(i["title"], i["artist"]))
select = selector.selectAttachment(_(u"Select the audio files you want to send"), audios)
if select.get_response() == widgetUtils.OK and select.attachments.GetCount() > 0:
attachments = select.get_all_attachments()
for i in attachments:
info = dict(type="audio", id=list_of_audios[i]["id"], owner_id=list_of_audios[i]["owner_id"])
info["from"] = "online"
self.attachments.append(info)
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.
info2 = [_(u"Audio file"), u"{0} - {1}".format(list_of_audios[i]["title"], list_of_audios[i]["artist"])]
self.dialog.attachments.insert_item(False, *info2)
self.check_remove_status()
def remove_attachment(self, *args, **kwargs):
""" Remove the currently focused item from the attachments list."""
current_item = self.dialog.attachments.get_selected()
log.debug("Removing item %d" % (current_item,))
if current_item == -1: current_item = 0
@@ -35,5 +129,6 @@ class attach(object):
log.debug("Removed")
def check_remove_status(self):
""" Checks whether the remove button should remain enabled."""
if len(self.attachments) == 0 and self.dialog.attachments.get_count() == 0:
self.dialog.remove.Enable(False)

View File

@@ -0,0 +1,131 @@
# -*- coding: utf-8 -*-
import time
import os
import tempfile
import sound_lib
import widgetUtils
import sound
import output
from wxUI.dialogs import audioRecorder as gui
from mysc.thread_utils import call_threaded
class audioRecorder(object):
def __init__(self):
self.dialog = gui.audioRecorderDialog()
self.recorded = False
self.recording = None
self.duration = 0
self.playing = None
widgetUtils.connect_event(self.dialog.play, widgetUtils.BUTTON_PRESSED, self.on_play)
widgetUtils.connect_event(self.dialog.pause, widgetUtils.BUTTON_PRESSED, self.on_pause)
widgetUtils.connect_event(self.dialog.record, widgetUtils.BUTTON_PRESSED, self.on_record)
widgetUtils.connect_event(self.dialog.discard, widgetUtils.BUTTON_PRESSED, self.on_discard)
if self.dialog.get_response() == widgetUtils.OK:
self.postprocess()
def on_pause(self, *args, **kwargs):
if self.dialog.get("pause") == _(u"Pause"):
self.recording.pause()
self.dialog.set("pause", _(u"&Resume"))
elif self.dialog.get("pause") == _(u"Resume"):
self.recording.play()
self.dialog.set("pause", _(U"&Pause"))
def on_record(self, *args, **kwargs):
if self.recording != None:
self.stop_recording()
self.dialog.disable_control("pause")
else:
self.start_recording()
self.dialog.enable_control("pause")
def start_recording(self):
self.dialog.disable_control("attach_exists")
self.file = tempfile.mktemp(suffix='.wav')
self.recording = sound.get_recording(self.file)
self.duration = time.time()
self.recording.play()
self.dialog.set("record", _(u"&Stop"))
output.speak(_(u"Recording"))
def stop_recording(self):
self.recording.stop()
self.duration = int(time.time()-self.duration)
self.recording.free()
output.speak(_(u"Stopped"))
self.recorded = True
self.dialog.set("record", _(u"&Record"))
self.file_attached()
def file_attached(self):
self.dialog.set("pause", _(u"&Pause"))
self.dialog.disable_control("record")
self.dialog.enable_control("play")
self.dialog.enable_control("discard")
self.dialog.disable_control("attach_exists")
self.dialog.enable_control("attach")
self.dialog.play.SetFocus()
def on_discard(self, *args, **kwargs):
if self.playing:
self._stop()
if self.recording != None:
self.cleanup()
self.dialog.disable_control("attach")
self.dialog.disable_control("play")
self.file = None
self.dialog.enable_control("record")
self.dialog.enable_control("attach_exists")
self.dialog.record.SetFocus()
self.dialog.disable_control("discard")
self.recording = None
output.speak(_(u"Discarded"))
def on_play(self, *args, **kwargs):
if not self.playing:
call_threaded(self._play)
else:
self._stop()
def _play(self):
output.speak(_(u"Playing..."))
# try:
self.playing = sound_lib.stream.FileStream(file=unicode(self.file), flags=sound_lib.stream.BASS_UNICODE)
self.playing.play()
self.dialog.set("play", _(u"&Stop"))
try:
while self.playing.is_playing:
pass
self.dialog.set("play", _(u"&Play"))
self.playing.free()
self.playing = None
except:
pass
def _stop(self):
output.speak(_(u"Stopped"))
self.playing.stop()
self.playing.free()
self.dialog.set("play", _(u"&Play"))
self.playing = None
def postprocess(self):
if self.file.lower().endswith('.wav'):
output.speak(_(u"Recoding audio..."))
sound.recode_audio(self.file)
self.wav_file = self.file
self.file = '%s.ogg' % self.file[:-4]
def cleanup(self):
if self.playing and self.playing.is_playing:
self.playing.stop()
if self.recording != None:
if self.recording.is_playing:
self.recording.stop()
try:
self.recording.free()
except:
pass
os.remove(self.file)
if hasattr(self, 'wav_file'):
os.remove(self.wav_file)

View File

@@ -1,76 +1,98 @@
# -*- coding: utf-8 -*-
import languageHandler
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
import random
import logging
import webbrowser
import arrow
import wx
import languageHandler
import widgetUtils
import messages
import utils
import posts
import player
import output
import logging
import selector
from wxUI.tabs import home
import posts
import attach
from pubsub import pub
from sessionmanager import session
from vk_api.exceptions import VkApiError
from vk_api import upload
from requests.exceptions import ReadTimeout, ConnectionError
from wxUI.tabs import home
from sessionmanager import session, renderers, utils
from mysc.thread_utils import call_threaded
from wxUI import commonMessages, menus
from vk import upload
from vk.exceptions import VkAPIMethodError
from sessionmanager.utils import add_attachment
log = logging.getLogger("controller.buffers")
class baseBuffer(object):
""" a basic representation of a buffer. Other buffers should be derived from this class"""
""" a basic representation of a buffer. Other buffers should be derived from this class. This buffer represents the "news feed" """
def get_post(self):
""" Return the currently focused post."""
# Handle case where there are no items in the buffer.
if self.tab.list.get_count() == 0:
wx.Bell()
return None
return self.session.db[self.name]["items"][self.tab.list.get_selected()]
def __init__(self, parent=None, name="", session=None, composefunc=None, *args, **kwargs):
""" parent wx.Treebook: parent for the buffer panel,
name str: Name for saving this buffer's data in the local storage variable,
session sessionmanager.session.vkSession: Session for performing operations in the Vk API. This session should be logged in when this class is instanciated.
composefunc str: This function will be called for composing the result which will be put in the listCtrl. Composefunc should existss in the sessionmanager.session module.
args and kwargs will be passed to get_items()"""
""" Constructor:
@parent wx.Treebook: parent for the buffer panel,
@name str: Name for saving this buffer's data in the local storage variable,
@session sessionmanager.session.vkSession: Session for performing operations in the Vk API. This session should be logged in when this class is instanciated.
@composefunc str: This function will be called for composing the result which will be put in the listCtrl. Composefunc should exist in the sessionmanager.renderers module.
args and kwargs will be passed to get_items() without any filtering. Be careful there.
"""
super(baseBuffer, self).__init__()
self.args = args
self.kwargs = kwargs
# Create GUI associated to this buffer.
self.create_tab(parent)
# Add the 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 = name
self.session = session
self.compose_function = composefunc
#Update_function will be called every 3 minutes and it should be able to
# Get all new items in the buffer and sort them properly in the CtrlList.
# ToDo: Shall we allow dinamically set for update_function?
self.update_function = "get_page"
self.name = name
# Bind local events (they will respond to events happened in the buffer).
self.connect_events()
# source_key and post_key will point to the keys for sender and posts in VK API objects.
# They can be changed in the future for other item types in different buffers.
self.user_key = "source_id"
self.post_key = "post_id"
# When set to False, update_function won't be executed here.
self.can_get_items = True
def create_tab(self, parent):
""" Creates the Wx panel."""
""" Create the Wx panel."""
self.tab = home.homeTab(parent)
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."""
item_ = getattr(session, self.compose_function)(item, self.session)
""" Add a new item to the list. Uses renderers.composefunc for parsing the dictionary and create a valid result for putting it in the list."""
item_ = getattr(renderers, self.compose_function)(item, self.session)
self.tab.list.insert_item(reversed, *item_)
def get_items(self, show_nextpage=False):
""" Retrieves 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.
show_nextpage boolean: If it's true, it will try to load previous results.
""" 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.
@show_nextpage boolean: If it's true, it will try to load previous results.
"""
if self.can_get_items == False: return
retrieved = True # Control variable for handling unauthorised/connection errors.
try:
num = getattr(self.session, "get_newsfeed")(show_nextpage=show_nextpage, name=self.name, *self.args, **self.kwargs)
except VkAPIMethodError as err:
print(u"Error {0}: {1}".format(err.code, err.message))
except VkApiError as err:
log.error(u"Error {0}: {1}".format(err.code, err.message))
retrieved = err.code
return retrieved
except ReadTimeout, ConnectionError:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if show_nextpage == False:
if self.tab.list.get_count() > 0 and num > 0:
print "inserting a value"
v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse()
[self.insert(i, True) for i in v]
@@ -82,14 +104,19 @@ class baseBuffer(object):
return retrieved
def get_more_items(self):
""" Returns previous items in the buffer."""
self.get_items(show_nextpage=True)
def post(self, *args, **kwargs):
p = messages.post(title=_(u"Write your post"), caption="", text="")
""" Create a post in the current user's wall.
This process is handled in two parts. This is the first part, where the GUI is created and user can send the post.
During the second part (threaded), the post will be sent to the API."""
p = messages.post(session=self.session, title=_(u"Write your post"), caption="", text="")
if p.message.get_response() == widgetUtils.OK:
call_threaded(self.do_last, p=p)
def do_last(self, p):
""" Second part of post function. Here everything is going to be sent to the API"""
msg = p.message.get_text().encode("utf-8")
privacy_opts = p.get_privacy_options()
attachments = ""
@@ -105,21 +132,38 @@ class baseBuffer(object):
p.message.Destroy()
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.client)
uploader = upload.VkUpload(self.session.vk.session_object)
for i in attachments:
if i["type"] == "photo":
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"]
# self.session.vk.client.photos.edit(photo_id=id, owner_id=owner_id, caption=description)
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 connect_events(self):
""" Bind all events to this buffer"""
widgetUtils.connect_event(self.tab.post, widgetUtils.BUTTON_PRESSED, self.post)
widgetUtils.connect_event(self.tab.list.list, widgetUtils.KEYPRESS, self.get_event)
widgetUtils.connect_event(self.tab.list.list, wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu)
@@ -127,22 +171,27 @@ class baseBuffer(object):
self.tab.set_focus_function(self.onFocus)
def show_menu(self, ev, pos=0, *args, **kwargs):
""" Show contextual menu when pressing menu key or right mouse click in a list item."""
if self.tab.list.get_count() == 0: return
menu = self.get_menu()
if pos != 0:
self.tab.PopupMenu(menu, pos)
else:
self.tab.PopupMenu(menu, ev.GetPosition())
self.tab.PopupMenu(menu, self.tab.list.list.GetPosition())
def show_menu_by_key(self, ev):
""" Show contextual menu when menu key is pressed"""
if self.tab.list.get_count() == 0:
return
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
self.show_menu(widgetUtils.MENU, pos=self.tab.list.list.GetPosition())
def get_menu(self):
""" Returns contextual menu options. They will change according to the focused item"""
m = menus.postMenu()
p = self.get_post()
if p == None:
return
if p.has_key("likes") == False:
m.like.Enable(False)
elif p["likes"]["user_likes"] == 1:
@@ -154,10 +203,14 @@ class baseBuffer(object):
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_comment, menuitem=m.comment)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
return m
def do_like(self, *args, **kwargs):
""" Set like in the currently focused post."""
post = self.get_post()
if post == None:
return
user = post[self.user_key]
id = post[self.post_key]
if post.has_key("type"):
@@ -171,7 +224,10 @@ class baseBuffer(object):
output.speak(_(u"You liked this"))
def do_dislike(self, *args, **kwargs):
""" Set dislike (undo like) in the currently focused post."""
post = self.get_post()
if post == None:
return
user = post[self.user_key]
id = post[self.post_key]
if post.has_key("type"):
@@ -185,19 +241,23 @@ class baseBuffer(object):
output.speak(_(u"You don't like this"))
def do_comment(self, *args, **kwargs):
""" Make a comment into the currently focused post."""
post = self.get_post()
if post == None:
return
comment = messages.comment(title=_(u"Add a comment"), caption="", text="")
if comment.message.get_response() == widgetUtils.OK:
msg = comment.message.get_text().encode("utf-8")
post = self.get_post()
try:
user = post[self.user_key]
id = post[self.post_key]
self.session.vk.client.wall.addComment(owner_id=user, post_id=id, text=msg)
output.speak(_(u"You've posted a comment"))
except Exception as msg:
print msg
log.error(msg)
def get_event(self, ev):
""" Parses keyboard input in the ListCtrl and executes the event associated with user keypresses."""
if ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown() and ev.ShiftDown(): event = "pause_audio"
elif ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown(): event = "play_audio"
elif ev.GetKeyCode() == wx.WXK_RETURN: event = "open_post"
@@ -213,18 +273,38 @@ class baseBuffer(object):
pass
def volume_down(self):
""" Decreases player volume by 5%"""
player.player.volume = player.player.volume-5
def volume_up(self):
""" Increases player volume by 5%"""
player.player.volume = player.player.volume+5
def play_audio(self, *args, **kwargs):
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
""" Play audio in currently focused buffer, if possible."""
post = self.get_post()
if post == None:
return
if post.has_key("type") and post["type"] == "audio":
pub.sendMessage("play-audio", audio_object=post["audio"]["items"][0])
return True
def open_person_profile(self, *args, **kwargs):
""" Views someone's profile."""
selected = self.get_post()
if selected == None:
return
# Check all possible keys for an user object in VK API.
keys = ["from_id", "source_id", "id"]
for i in keys:
if selected.has_key(i):
pub.sendMessage("user-profile", person=selected[i])
def open_post(self, *args, **kwargs):
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
""" Opens the currently focused post."""
post = self.get_post()
if post == None:
return
if post.has_key("type") and post["type"] == "audio":
a = posts.audio(self.session, post["audio"]["items"])
a.dialog.get_response()
@@ -235,12 +315,18 @@ class baseBuffer(object):
pub.sendMessage("open-post", post_object=post, controller_="postController")
def pause_audio(self, *args, **kwargs):
""" pauses audio playback."""
player.player.pause()
def remove_buffer(self, mandatory): return False
def remove_buffer(self, mandatory):
""" Function for removing a buffer. Returns True if removal is successful, False otherwise"""
return False
def get_users(self):
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
""" Returns source user in the post."""
post = self.get_post()
if post == None:
return
if post.has_key("type") == False:
return [post["from_id"]]
else:
@@ -249,27 +335,31 @@ class baseBuffer(object):
def onFocus(self, *args,**kwargs):
""" Function executed when the item in a list is selected.
For this buffer it updates the date of posts in the list."""
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
post = self.get_post()
if post == None:
return
original_date = arrow.get(post["date"])
created_at = original_date.humanize(locale=languageHandler.getLanguage())
self.tab.list.list.SetStringItem(self.tab.list.get_selected(), 2, created_at)
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
self.tab.list.list.SetItem(self.tab.list.get_selected(), 2, created_at)
class feedBuffer(baseBuffer):
""" This buffer represents an user's wall. It may be used either for the current user or someone else."""
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
retrieved = True
try:
num = getattr(self.session, "get_page")(show_nextpage=show_nextpage, name=self.name, *self.args, **self.kwargs)
print num
except VkAPIMethodError as err:
print(u"Error {0}: {1}".format(err.code, err.message))
except VkApiError as err:
log.error(u"Error {0}: {1}".format(err.code, err.message))
retrieved = err.code
return retrieved
except ReadTimeout, ConnectionError:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if show_nextpage == False:
if self.tab.list.get_count() > 0 and num > 0:
print "inserting a value"
v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse()
[self.insert(i, True) for i in v]
@@ -278,6 +368,7 @@ class feedBuffer(baseBuffer):
return retrieved
def remove_buffer(self, mandatory=False):
""" Remove buffer if the current buffer is not the logged user's wall."""
if "me_feed" == self.name:
output.speak(_(u"This buffer can't be deleted"))
return False
@@ -297,7 +388,25 @@ class feedBuffer(baseBuffer):
self.user_key = "from_id"
self.post_key = "id"
class communityBuffer(feedBuffer):
def create_tab(self, parent):
self.tab = home.communityTab(parent)
def connect_events(self):
super(communityBuffer, self).connect_events()
widgetUtils.connect_event(self.tab.load, widgetUtils.BUTTON_PRESSED, self.load_community)
def load_community(self, *args, **kwargs):
output.speak(_(u"Loading community..."))
self.can_get_items = True
self.tab.load.Enable(False)
wx.CallAfter(self.get_items)
class audioBuffer(feedBuffer):
""" this buffer was supposed to be used with audio elements
but is deprecated as VK removed its audio support for third party apps."""
def create_tab(self, parent):
self.tab = home.audioTab(parent)
@@ -308,10 +417,34 @@ class audioBuffer(feedBuffer):
def play_audio(self, *args, **kwargs):
selected = self.tab.list.get_selected()
if selected == -1:
selected = 0
pub.sendMessage("play-audio", audio_object=self.session.db[self.name]["items"][selected])
return True
def play_next(self, *args, **kwargs):
selected = self.tab.list.get_selected()
if selected < 0 or selected == self.tab.list.get_count()-1:
selected = 0
if self.tab.list.get_count() <= selected+1:
newpos = 0
else:
newpos = selected+1
self.tab.list.select_item(newpos)
self.play_audio()
def play_previous(self, *args, **kwargs):
selected = self.tab.list.get_selected()
if selected <= 0:
selected = self.tab.list.get_count()
newpos = selected-1
self.tab.list.select_item(newpos)
self.play_audio()
def open_post(self, *args, **kwargs):
selected = self.tab.list.get_selected()
if selected == -1:
return
audios = [self.session.db[self.name]["items"][selected]]
a = posts.audio(self.session, audios)
a.dialog.get_response()
@@ -321,8 +454,11 @@ class audioBuffer(feedBuffer):
selected = self.tab.list.get_selected()
if selected == -1:
selected = 0
if self.name not in self.session.db:
return
audios = [i for i in self.session.db[self.name]["items"][selected:]]
pub.sendMessage("play-audios", audios=audios)
return True
def remove_buffer(self, mandatory=False):
if "me_audio" == self.name or "popular_audio" == self.name or "recommended_audio" == self.name:
@@ -348,6 +484,8 @@ class audioBuffer(feedBuffer):
def add_to_library(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
args = {}
args["audio_id"] = post["id"]
if post.has_key("album_id"):
@@ -359,17 +497,25 @@ class audioBuffer(feedBuffer):
def remove_from_library(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
args = {}
args["audio_id"] = post["id"]
args["owner_id"] = self.session.user_id
result = self.session.vk.client.audio.delete(**args)
if int(result) == 1:
output.speak(_(u"Removed audio from library"))
self.tab.list.remove_item(self.tab.list.get_selected())
def move_to_album(self, *args, **kwargs):
album = selector.audioAlbum(_(u"Select the album where you want to move this song"), self.session)
if len(self.session.audio_albums) == 0:
return commonMessages.no_audio_albums()
post = self.get_post()
if post == None:
return
album = selector.album(_(u"Select the album where you want to move this song"), self.session)
if album.item == None: return
id = self.get_post()["id"]
id = post["id"]
response = self.session.vk.client.audio.moveToAlbum(album_id=album.item, audio_ids=id)
if response == 1:
# Translators: Used when the user has moved an audio to an album.
@@ -377,6 +523,8 @@ class audioBuffer(feedBuffer):
def get_menu(self):
p = self.get_post()
if p == None:
return
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)
@@ -390,6 +538,8 @@ class audioBuffer(feedBuffer):
return m
class audioAlbum(audioBuffer):
""" this buffer was supposed to be used with audio albums
but is deprecated as VK removed its audio support for third party apps."""
def create_tab(self, parent):
self.tab = home.audioAlbumTab(parent)
@@ -408,6 +558,127 @@ class audioAlbum(audioBuffer):
self.tab.play.Enable(True)
self.tab.play_all.Enable(True)
class videoBuffer(feedBuffer):
""" This buffer represents video elements, and it can be used for showing videos for the logged user or someone else."""
def create_tab(self, parent):
self.tab = home.videoTab(parent)
def connect_events(self):
widgetUtils.connect_event(self.tab.play, widgetUtils.BUTTON_PRESSED, self.play_audio)
super(videoBuffer, self).connect_events()
def play_audio(self, *args, **kwargs):
""" Due to inheritance this method should be called play_audio, but play the currently focused video.
Opens a webbrowser pointing to the video's URL."""
selected = self.tab.list.get_selected()
if self.tab.list.get_count() == 0:
return
if selected == -1:
selected = 0
output.speak(_(u"Opening video in webbrowser..."))
webbrowser.open_new_tab(self.session.db[self.name]["items"][selected]["player"])
# print self.session.db[self.name]["items"][selected]
return True
def open_post(self, *args, **kwargs):
pass
def remove_buffer(self, mandatory=False):
if "me_video" == self.name:
output.speak(_(u"This buffer can't be deleted"))
return False
else:
if mandatory == False:
dlg = commonMessages.remove_buffer()
else:
dlg = widgetUtils.YES
if dlg == widgetUtils.YES:
self.session.db.pop(self.name)
return True
else:
return False
def get_more_items(self, *args, **kwargs):
# Translators: Some buffers can't use the get previous item feature due to API limitations.
output.speak(_(u"This buffer doesn't support getting more items."))
def onFocus(self, *args, **kwargs):
pass
def add_to_library(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
args = {}
args["video_id"] = post["id"]
if post.has_key("album_id"):
args["album_id"] = post["album_id"]
args["owner_id"] = post["owner_id"]
video = self.session.vk.client.video.add(**args)
if video != None and int(video) > 21:
output.speak(_(u"Video added to your library"))
def remove_from_library(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
args = {}
args["video_id"] = post["id"]
args["owner_id"] = self.session.user_id
result = self.session.vk.client.video.delete(**args)
if int(result) == 1:
output.speak(_(u"Removed video from library"))
self.tab.list.remove_item(self.tab.list.get_selected())
def move_to_album(self, *args, **kwargs):
if len(self.session.video_albums) == 0:
return commonMessages.no_video_albums()
post= self.get_post()
if post == None:
return
album = selector.album(_(u"Select the album where you want to move this video"), self.session, "video_albums")
if album.item == None: return
id = post["id"]
response = self.session.vk.client.video.addToAlbum(album_ids=album.item, video_id=id, target_id=self.session.user_id, owner_id=self.get_post()["owner_id"])
if response == 1:
# Translators: Used when the user has moved an video to an album.
output.speak(_(u"Moved"))
def get_menu(self):
""" We'll use the same menu that is used for audio items, as the options are exactly the same"""
p = self.get_post()
if p == None:
return
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)
# if owner_id is the current user, the audio is added to the user's audios.
if p["owner_id"] == self.session.user_id:
m.library.SetItemLabel(_(u"&Remove from library"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library)
else:
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
return m
class videoAlbum(videoBuffer):
def create_tab(self, parent):
self.tab = home.videoAlbumTab(parent)
self.tab.play.Enable(False)
def connect_events(self):
super(videoAlbum, self).connect_events()
widgetUtils.connect_event(self.tab.load, widgetUtils.BUTTON_PRESSED, self.load_album)
def load_album(self, *args, **kwargs):
output.speak(_(u"Loading album..."))
self.can_get_items = True
self.tab.load.Enable(False)
wx.CallAfter(self.get_items)
self.tab.play.Enable(True)
class empty(object):
def __init__(self, name=None, parent=None, *args, **kwargs):
@@ -424,50 +695,231 @@ class empty(object):
class chatBuffer(baseBuffer):
def onFocus(self, *args, **kwargs):
msg = self.session.db[self.name]["items"][-1]
if msg["read_state"] == 0 and msg["id"] not in self.reads:
self.reads.append(msg["id"])
self.session.db[self.name]["items"][-1]["read_state"] = 1
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."""
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.
# Here we will get first and last line of a chat message appended to the history.
values = self.tab.add_message(item_[0])
self.chats[values] = item["id"]
def get_focused_post(self):
""" Gets chat message currently in focus"""
# this function replaces self.get_post for normal buffers, as we rely in a TextCtrl control for getting chats.
# Instead of the traditional method to do the trick.
# Get text position here.
position = self.tab.history.PositionToXY(self.tab.history.GetInsertionPoint())
id_ = None
for i in self.chats.keys():
# Check if position[2] (line position) matches with something in self.chats
# (All messages, except the last one, should be able to be matched here).
# 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]:
id_ = self.chats[i]
# print i
break
# Retrieve here the object based in id_
if id_ != None:
for i in self.session.db[self.name]["items"]:
if i["id"] == id_:
return i
return False
get_post = get_focused_post
def onFocus(self, event, *args, **kwargs):
if event.GetKeyCode() == wx.WXK_UP or event.GetKeyCode() == wx.WXK_DOWN or event.GetKeyCode() == wx.WXK_START or event.GetKeyCode() == wx.WXK_PAGEUP or event.GetKeyCode() == wx.WXK_PAGEDOWN or event.GetKeyCode() == wx.WXK_END:
msg = self.get_focused_post()
if msg == False: # Handle the case where the last line of the control cannot be matched to anything.
return
if msg.has_key("read_state") and msg["read_state"] == 0 and msg["id"] not in self.reads and msg.has_key("out") and msg["out"] == 0:
self.session.soundplayer.play("message_unread.ogg")
self.reads.append(msg["id"])
self.session.db[self.name]["items"][-1]["read_state"] = 1
# print msg
if msg.has_key("attachments") and len(msg["attachments"]) > 0:
self.tab.attachments.list.Enable(True)
self.attachments = list()
self.tab.attachments.clear()
self.parse_attachments(msg)
else:
self.tab.attachments.list.Enable(False)
self.tab.attachments.clear()
event.Skip()
def create_tab(self, parent):
self.tab = home.chatTab(parent)
self.attachments = list()
def connect_events(self):
widgetUtils.connect_event(self.tab.send, widgetUtils.BUTTON_PRESSED, self.send_chat_to_user)
widgetUtils.connect_event(self.tab.attachment, widgetUtils.BUTTON_PRESSED, self.add_attachment)
widgetUtils.connect_event(self.tab.text, widgetUtils.KEYPRESS, self.catch_enter)
self.tab.set_focus_function(self.onFocus)
def get_items(self, show_nextpage=False):
def catch_enter(self, event, *args, **kwargs):
shift=event.ShiftDown()
if event.GetKeyCode() == wx.WXK_RETURN and shift == False:
return self.send_chat_to_user()
event.Skip()
def get_items(self, show_nextpage=False, unread=False):
if self.can_get_items == False: return
retrieved = True # Control variable for handling unauthorised/connection errors.
try:
num = getattr(self.session, "get_messages")(name=self.name, *self.args, **self.kwargs)
except VkAPIMethodError as err:
print(u"Error {0}: {1}".format(err.code, err.message))
except VkApiError as err:
log.error(u"Error {0}: {1}".format(err.code, err.message))
retrieved = err.code
return retrieved
except ReadTimeout, ConnectionError:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if show_nextpage == False:
if self.tab.list.get_count() > 0 and num > 0:
print "inserting a value"
if self.tab.history.GetValue() != "" and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse()
[self.insert(i, True) for i in v]
# v.reverse()
[self.insert(i, False) for i in v]
else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]]
else:
if num > 0:
[self.insert(i, False) for i in self.session.db[self.name]["items"][:num]]
if unread:
self.session.db[self.name]["items"][-1].update(read_state=0)
return retrieved
def add_attachment(self, *args, **kwargs):
a = attach.attach(self.session, True)
if len(a.attachments) != 0:
self.attachments_to_be_sent = a.attachments
def send_chat_to_user(self, *args, **kwargs):
text = self.tab.text.GetValue()
if text == "": return
response = self.session.vk.client.messages.send(user_id=self.kwargs["user_id"], message=text)
if text == "" and not hasattr(self, "attachments_to_be_sent"):
wx.Bell()
return
self.tab.text.SetValue("")
call_threaded(self._send_message, text=text)
def upload_attachments(self, attachments):
""" Upload attachments to VK before posting them.
Returns attachments formatted as string, as required by VK API.
"""
local_attachments = ""
uploader = upload.VkUpload(self.session.vk.session_object)
for i in attachments:
if i["from"] == "online":
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
elif i["from"] == "local" and i["type"] == "photo":
photos = i["file"]
description = i["description"]
r = uploader.photo_messages(photos)
id = r[0]["id"]
owner_id = r[0]["owner_id"]
local_attachments += "photo{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "audio":
audio = i["file"]
title = "untitled"
artist = "unnamed"
if "artist" in i:
artist = i["artist"]
if "title" in i:
title = i["title"]
r = uploader.audio(audio, title=title, artist=artist)
id = r["id"]
owner_id = r["owner_id"]
local_attachments += "audio{0}_{1},".format(owner_id, id)
elif i["from"] == "local" and i["type"] == "voice_message":
r = uploader.audio_message(i["file"], peer_id=self.kwargs["user_id"])
id = r["audio_message"]["id"]
owner_id = r["audio_message"]["owner_id"]
local_attachments += "audio_message{0}_{1},".format(owner_id, id)
return local_attachments
def _send_message(self, text, attachments=[]):
if hasattr(self, "attachments_to_be_sent"):
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(user_id=self.kwargs["user_id"], message=text, attachment=self.attachments_to_be_sent, random_id=random_id)
else:
response = self.session.vk.client.messages.send(user_id=self.kwargs["user_id"], message=text, random_id=random_id)
except ValueError as ex:
if ex.code == 9:
output.speak(_(u"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."))
def __init__(self, *args, **kwargs):
super(chatBuffer, self).__init__(*args, **kwargs)
self.reads = []
self.chats = dict()
def parse_attachments(self, post):
attachments = []
if post.has_key("attachments"):
for i in post["attachments"]:
# We don't need the photos_list attachment, so skip it.
if i["type"] == "photos_list":
continue
attachments.append(add_attachment(i))
self.attachments.append(i)
self.tab.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_attachment)
self.tab.insert_attachments(attachments)
def open_attachment(self, *args, **kwargs):
index = self.tab.attachments.get_selected()
attachment = self.attachments[index]
if attachment["type"] == "audio":
a = posts.audio(session=self.session, postObject=[attachment["audio"]])
a.dialog.get_response()
a.dialog.Destroy()
elif attachment["type"] == "audio_message":
link = attachment["audio_message"]["link_mp3"]
output.speak(_(u"Playing..."))
player.player.play(url=dict(url=link), set_info=False)
elif attachment["type"] == "link":
output.speak(_(u"Opening URL..."), True)
webbrowser.open_new_tab(attachment["link"]["url"])
elif attachment["type"] == "doc":
output.speak(_(u"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(_(u"Opening video in web browser..."), True)
webbrowser.open_new_tab(video_object["player"])
elif attachment["type"] == "photo":
output.speak(_(u"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 attachment["photo"].has_key("photo_{0}".format(i,)):
url = attachment["photo"]["photo_{0}".format(i,)]
break
if url != "":
webbrowser.open_new_tab(url)
else:
log.debug("Unhandled attachment: %r" % (attachment,))
def clear_reads(self):
for i in self.session.db[self.name]["items"]:
if "read_state" in i and i["read_state"] == 0:
i["read_state"] = 1
class peopleBuffer(feedBuffer):
@@ -479,21 +931,123 @@ class peopleBuffer(feedBuffer):
widgetUtils.connect_event(self.tab.new_chat, widgetUtils.BUTTON_PRESSED, self.new_chat)
def new_chat(self, *args, **kwargs):
user_id = self.session.db[self.name]["items"][self.tab.list.get_selected()]["id"]
user = self.get_post()
if user == None:
return
user_id = user["id"]
pub.sendMessage("new-chat", user_id=user_id)
def onFocus(self, *args, **kwargs):
post = self.session.db[self.name]["items"][self.tab.list.get_selected()]
post = self.get_post()
if post == None:
return
if post.has_key("last_seen") == False: return
original_date = arrow.get(post["last_seen"]["time"])
created_at = original_date.humanize(locale=languageHandler.getLanguage())
self.tab.list.list.SetStringItem(self.tab.list.get_selected(), 1, created_at)
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, created_at)
def open_timeline(self, *args, **kwargs):
pass
def get_menu(self, *args, **kwargs):
m = menus.peopleMenu()
""" display menu for people buffers (friends and requests)"""
# If this is an incoming requests buffer, there is a flag in the peopleMenu that shows a few new options.
# So let's make sure we call it accordingly.
if self.name == "friend_requests":
m = menus.peopleMenu(is_request=True)
# Connect the accept and decline methods from here.
widgetUtils.connect_event(m, widgetUtils.MENU, self.accept_friendship, menuitem=m.accept)
widgetUtils.connect_event(m, widgetUtils.MENU, self.decline_friendship, menuitem=m.decline)
widgetUtils.connect_event(m, widgetUtils.MENU, self.keep_as_follower, menuitem=m.keep_as_follower)
else:
m = menus.peopleMenu(is_request=False)
# It is not allowed to send messages to people who is not your friends, so let's disble it if we're in a pending or outgoing requests folder.
if "friend_requests" in self.name:
m.message.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.new_chat, menuitem=m.message)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_timeline, menuitem=m.timeline)
return m
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
return m
def open_post(self, *args, **kwargs): pass
def play_audio(self, *args, **kwargs): return False
def pause_audio(self, *args, **kwargs): pass
def accept_friendship(self, *args, **kwargs):
pass
def decline_friendship(self, *args, **kwargs):
pass
def keep_as_follower(self, *args, **kwargs):
pass
class requestsBuffer(peopleBuffer):
def get_items(self, show_nextpage=False):
if self.can_get_items == False: return
retrieved = True
try:
ids = self.session.vk.client.friends.getRequests(*self.args, **self.kwargs)
except VkApiError as err:
log.error(u"Error {0}: {1}".format(err.code, err.message))
retrieved = err.code
return retrieved
except ReadTimeout, ConnectionError:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
num = self.session.get_page(name=self.name, show_nextpage=show_nextpage, endpoint="get", parent_endpoint="users", count=1000, user_ids=", ".join([str(i) for i in ids["items"]]), fields="uid, first_name, last_name, last_seen")
if show_nextpage == False:
if self.tab.list.get_count() > 0 and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse()
[self.insert(i, True) for i in v]
else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]]
return retrieved
def accept_friendship(self, *args, **kwargs):
""" Adds a person to a list of friends. This method is done for accepting someone else's friend request.
https://vk.com/dev/friends.add
"""
person = self.get_post()
if person == None:
return
result = self.session.vk.client.friends.add(user_id=person["id"])
if result == 2:
msg = _(u"{0} {1} now is your friend.").format(person["first_name"], person["last_name"])
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
def decline_friendship(self, *args, **kwargs):
""" Declines a freind request.
https://vk.com/dev/friends.delete
"""
person = self.get_post()
if person == None:
return
result = self.session.vk.client.friends.delete(user_id=person["id"])
if "out_request_deleted" in result:
msg = _(u"You've deleted the friends request to {0} {1}.").format(person["first_name"], person["last_name"])
elif "in_request_deleted" in result:
msg = _(u"You've declined the friend request of {0} {1}.").format(person["first_name"], person["last_name"])
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
def keep_as_follower(self, *args, **kwargs):
""" Adds a person to The followers list of the current user.
https://vk.com/dev/friends.add
"""
person = self.get_post()
if person == None:
return
result = self.session.vk.client.friends.add(user_id=person["id"], follow=1)
if result == 2:
msg = _(u"{0} {1} is following you.").format(person["first_name"], person["last_name"])
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())

View File

@@ -4,6 +4,34 @@ from wxUI.dialogs import configuration as configurationUI
class configuration(object):
def get_notification_type(self, value):
if value == _(u"Native"):
return "native"
else:
return "custom"
def get_notification_label(self, value):
if value == "native":
return _(u"Native")
else:
return _(u"Custom")
def get_update_channel_type(self, value):
if value == _(u"Stable"):
return "stable"
elif value == _(u"Weekly"):
return "weekly"
else:
return "alpha"
def get_update_channel_label(self, value):
if value == "stable":
return _(u"Stable")
elif value == "weekly":
return _(u"Weekly")
else:
return _(u"Alpha")
def __init__(self, session):
self.session = session
self.dialog = configurationUI.configurationDialog(_(u"Preferences"))
@@ -12,11 +40,36 @@ class configuration(object):
def create_config(self):
self.dialog.create_general()
self.dialog.set_value("general", "wall_buffer_count", self.session.settings["buffers"]["count_for_wall_buffers"])
self.dialog.set_value("general", "audio_buffers_count", self.session.settings["buffers"]["count_for_audio_buffers"])
self.dialog.set_value("general", "video_buffers_count", self.session.settings["buffers"]["count_for_video_buffers"])
self.dialog.set_value("general", "load_images", self.session.settings["general"]["load_images"])
self.dialog.set_value("general", "update_channel", self.get_update_channel_label(self.session.settings["general"]["update_channel"]))
self.dialog.create_chat()
self.dialog.set_value("chat", "notify_online", self.session.settings["chat"]["notify_online"])
self.dialog.set_value("chat", "notify_offline", self.session.settings["chat"]["notify_offline"])
self.dialog.set_value("chat", "open_unread_conversations", self.session.settings["chat"]["open_unread_conversations"])
self.dialog.set_value("chat", "automove_to_conversations", self.session.settings["chat"]["automove_to_conversations"])
self.dialog.set_value("chat", "notifications", self.get_notification_label(self.session.settings["chat"]["notifications"]))
self.dialog.realize()
self.response = self.dialog.get_response()
def save_configuration(self):
self.session.settings["buffers"]["count_for_audio_buffers"] = self.dialog.get_value("general", "wall_buffer_count")
self.session.settings["buffers"]["count_for_audio_buffers"] = self.dialog.get_value("general", "audio_buffers_count")
self.session.settings["buffers"]["count_for_video_buffers"] = self.dialog.get_value("general", "video_buffers_count")
self.session.settings["general"]["load_images"] = self.dialog.get_value("general", "load_images")
update_channel = self.get_update_channel_type(self.dialog.get_value("general", "update_channel"))
if update_channel != self.session.settings["general"]["update_channel"]:
if update_channel == "stable":
self.session.settings["general"]["update_channel"] = update_channel
elif update_channel == "weekly":
dialog = configurationUI.weekly_channel()
if dialog == widgetUtils.YES:
self.session.settings["general"]["update_channel"] = update_channel
elif update_channel == "alpha":
dialog = configurationUI.alpha_channel()
if dialog == widgetUtils.YES:
self.session.settings["general"]["update_channel"] = update_channel
self.session.settings["chat"]["notify_online"] = self.dialog.get_value("chat", "notify_online")
self.session.settings["chat"]["notify_offline"] = self.dialog.get_value("chat", "notify_offline")
self.session.settings["chat"]["open_unread_conversations"] = self.dialog.get_value("chat", "open_unread_conversations")
self.session.settings["chat"]["automove_to_conversations"] = self.dialog.get_value("chat", "automove_to_conversations")
self.session.settings["chat"]["notifications"] = self.get_notification_type(self.dialog.get_value("chat", "notifications"))
self.session.settings.write()

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
import threading
from vk_api.longpoll import VkLongPoll, VkEventType
from pubsub import pub
from requests.exceptions import ReadTimeout, ConnectionError
from logging import getLogger
log = getLogger("controller.longpolThread")
class worker(threading.Thread):
def __init__(self, session):
super(worker, self).__init__()
log.debug("Instantiating longPoll server")
self.session = session
self.longpoll = VkLongPoll(self.session.vk.session_object)
def run(self):
try:
for event in self.longpoll.listen():
if event.type == VkEventType.MESSAGE_NEW:
pub.sendMessage("order-sent-message", obj=event)
elif event.type == VkEventType.USER_ONLINE:
pub.sendMessage("user-online", event=event)
elif event.type == VkEventType.USER_OFFLINE:
pub.sendMessage("user-offline", event=event)
except:
pub.sendMessage("longpoll-read-timeout")

View File

@@ -1,22 +0,0 @@
# -*- coding: utf-8 -*-
import threading
from vk import longpool
from pubsub import pub
class worker(threading.Thread):
def __init__(self, session):
super(worker, self).__init__()
self.session = session
self.l = longpool.LongPoll(self.session.vk.client)
def run(self):
while self.session.is_logged == True:
p = self.l.check()
for i in p:
# print i.message_id, i.flags, i.from_id, i.user_id, i.mask, i.byself, i.message_flags
# if i.flags == 4 or i.flags == 51 or i.flags == 49:
if i.text != None and i.from_id != None and i.flags != None and i.message_flags != None:
# print i.message_id, i.flags, i.from_id, i.user_id, i.mask, i.byself, i.message_flags
# if i.from_id != None:
# print "ordering sent stuff"
pub.sendMessage("order-sent-message", obj=i)

View File

@@ -2,27 +2,30 @@
import time
import os
import wx
import utils
import widgetUtils
import messages
import buffers
import configuration
import player
import posts
import profiles
import webbrowser
import logging
import longpoolthread
import output
import longpollthread
import selector
from vk.exceptions import VkAuthError
from vk_api.exceptions import LoginRequired, VkApiError
from requests.exceptions import ConnectionError
from pubsub import pub
from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded
from mysc import localization
from sessionmanager import session
from sessionmanager import session, utils, renderers
from wxUI import (mainWindow, commonMessages)
from wxUI.dialogs import search as searchDialogs
from wxUI.dialogs import timeline, creation
from update import updater
from issueReporter import issueReporter
log = logging.getLogger("controller.main")
@@ -53,7 +56,7 @@ class Controller(object):
self.create_controls()
self.window.Show()
self.connect_events()
call_threaded(updater.do_update)
call_threaded(updater.do_update, update_type=self.session.settings["general"]["update_channel"])
def create_controls(self):
log.debug("Creating controls for the window...")
@@ -61,17 +64,15 @@ class Controller(object):
self.buffers.append(posts_)
# Translators: Name for the posts tab in the tree view.
self.window.add_buffer(posts_.tab, _(u"Posts"))
home = buffers.baseBuffer(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="compose_new", endpoint="newsfeed", count=self.session.settings["buffers"]["count_for_wall_buffers"])
home = buffers.baseBuffer(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="render_newsfeed_item", endpoint="newsfeed", count=self.session.settings["buffers"]["count_for_wall_buffers"])
self.buffers.append(home)
# Translators: Newsfeed's name in the tree view.
self.window.insert_buffer(home.tab, _(u"Home"), self.window.search("posts"))
self.repeatedUpdate = RepeatingTimer(180, self.update_all_buffers)
self.repeatedUpdate = RepeatingTimer(120, self.update_all_buffers)
self.repeatedUpdate.start()
self.readMarker = RepeatingTimer(120, self.mark_as_read)
self.readMarker = RepeatingTimer(60, self.mark_as_read)
self.readMarker.start()
feed = buffers.feedBuffer(parent=self.window.tb, name="me_feed", composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"])
feed = buffers.feedBuffer(parent=self.window.tb, name="me_feed", composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"])
self.buffers.append(feed)
# Translators: Own user's wall name in the tree view.
self.window.insert_buffer(feed.tab, _(u"My wall"), self.window.search("posts"))
@@ -80,24 +81,48 @@ class Controller(object):
# Translators: name for the music category in the tree view.
self.window.add_buffer(audios.tab, _(u"Music"))
audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
audio = buffers.audioBuffer(parent=self.window.tb, name="me_audio", composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio")
self.buffers.append(audio)
self.window.insert_buffer(audio.tab, _(u"My audios"), self.window.search("audios"))
p_audio = buffers.audioBuffer(parent=self.window.tb, name="popular_audio", composefunc="compose_audio", session=self.session, endpoint="getPopular", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
self.buffers.append(p_audio)
self.window.insert_buffer(p_audio.tab, _(u"Populars"), self.window.search("audios"))
r_audio = buffers.audioBuffer(parent=self.window.tb, name="recommended_audio", composefunc="compose_audio", session=self.session, endpoint="getRecommendations", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
self.buffers.append(r_audio)
self.window.insert_buffer(r_audio.tab, _(u"Recommendations"), self.window.search("audios"))
if self.session.settings["vk"]["use_alternative_tokens"] == False:
p_audio = buffers.audioBuffer(parent=self.window.tb, name="popular_audio", composefunc="render_audio", session=self.session, endpoint="getPopular", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
self.buffers.append(p_audio)
self.window.insert_buffer(p_audio.tab, _(u"Populars"), self.window.search("audios"))
r_audio = buffers.audioBuffer(parent=self.window.tb, name="recommended_audio", composefunc="render_audio", session=self.session, endpoint="getRecommendations", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"])
self.buffers.append(r_audio)
self.window.insert_buffer(r_audio.tab, _(u"Recommendations"), self.window.search("audios"))
albums = buffers.empty(parent=self.window.tb, name="albums")
self.buffers.append(albums)
self.window.insert_buffer(albums.tab, _(u"Albums"), self.window.search("audios"))
videos = buffers.empty(parent=self.window.tb, name="videos")
self.buffers.append(videos)
# Translators: name for the videos category in the tree view.
self.window.add_buffer(videos.tab, _(u"Video"))
my_videos = buffers.videoBuffer(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"])
self.buffers.append(my_videos)
self.window.insert_buffer(my_videos.tab, _(u"My videos"), self.window.search("videos"))
video_albums = buffers.empty(parent=self.window.tb, name="video_albums")
self.buffers.append(video_albums)
self.window.insert_buffer(video_albums.tab, _(u"Albums"), self.window.search("videos"))
people = buffers.empty(parent=self.window.tb, name="people")
self.buffers.append(people)
self.window.add_buffer(people.tab, _(u"People"))
friends = buffers.peopleBuffer(parent=self.window.tb, name="friends_", composefunc="compose_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen")
friends = buffers.peopleBuffer(parent=self.window.tb, name="friends_", composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen")
self.buffers.append(friends)
self.window.insert_buffer(friends.tab, _(u"Friends"), self.window.search("people"))
requests_ = buffers.empty(parent=self.window.tb, name="requests")
self.buffers.append(requests_)
self.window.insert_buffer(requests_.tab, _(u"Friendship requests"), self.window.search("people"))
incoming_requests = buffers.requestsBuffer(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000)
self.buffers.append(incoming_requests)
self.window.insert_buffer(incoming_requests.tab, _(u"Pending requests"), self.window.search("requests"))
outgoing_requests = buffers.requestsBuffer(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1)
self.buffers.append(outgoing_requests)
self.window.insert_buffer(outgoing_requests.tab, _(u"I follow"), self.window.search("requests"))
# communities= buffers.empty(parent=self.window.tb, name="communities")
# self.buffers.append(communities)
# Translators: name for the videos category in the tree view.
# self.window.add_buffer(communities.tab, _(u"Communities"))
chats = buffers.empty(parent=self.window.tb, name="chats")
self.buffers.append(chats)
self.window.add_buffer(chats.tab, _(u"Chats"))
@@ -116,20 +141,40 @@ class Controller(object):
pub.subscribe(self.update_status_bar, "update-status-bar")
pub.subscribe(self.chat_from_id, "new-chat")
pub.subscribe(self.authorisation_failed, "authorisation-failed")
pub.subscribe(self.user_profile, "user-profile")
pub.subscribe(self.user_online, "user-online")
pub.subscribe(self.user_offline, "user-offline")
pub.subscribe(self.notify, "notify")
pub.subscribe(self.handle_longpoll_read_timeout, "longpoll-read-timeout")
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.window.about_dialog, menuitem=self.window.about)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_audios, menuitem=self.window.search_audios)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_videos, menuitem=self.window.search_videos)
widgetUtils.connect_event(self.window, widgetUtils.MENU,self.remove_buffer, menuitem=self.window.remove_buffer_)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.get_more_items, menuitem=self.window.load_previous_items)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.configuration, menuitem=self.window.settings_dialog)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_audio_album, menuitem=self.window.audio_album)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_audio_album, menuitem=self.window.delete_audio_album)
# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_audio_album, menuitem=self.window.audio_album)
# widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_audio_album, menuitem=self.window.delete_audio_album)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_video_album, menuitem=self.window.video_album)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_video_album, menuitem=self.window.delete_video_album)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_documentation, menuitem=self.window.documentation)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_pause, menuitem=self.window.player_play)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_next, menuitem=self.window.player_next)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_previous, menuitem=self.window.player_previous)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_all, menuitem=self.window.player_play_all)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_stop, menuitem=self.window.player_stop)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_down, menuitem=self.window.player_volume_down)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_up, menuitem=self.window.player_volume_up)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute)
pub.subscribe(self.get_chat, "order-sent-message")
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile, menuitem=self.window.view_profile)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile_in_browser, menuitem=self.window.open_in_browser)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.set_status, menuitem=self.window.set_status)
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_report_error, menuitem=self.window.report)
def disconnect_events(self):
log.debug("Disconnecting some events...")
@@ -140,6 +185,9 @@ class Controller(object):
pub.unsubscribe(self.play_audios, "play-audios")
pub.unsubscribe(self.view_post, "open-post")
pub.unsubscribe(self.update_status_bar, "update-status-bar")
pub.unsubscribe(self.user_online, "user-online")
pub.unsubscribe(self.user_offline, "user-offline")
pub.unsubscribe(self.notify, "notify")
def authorisation_failed(self):
commonMessages.bad_authorisation()
@@ -154,13 +202,23 @@ class Controller(object):
self.window.change_status(_(u"Loading items for {0}").format(i.name,))
i.get_items()
self.window.change_status(_(u"Ready"))
self.longpool = longpoolthread.worker(self.session)
self.longpool.start()
self.status_setter = RepeatingTimer(900, self.set_online)
self.create_longpoll_thread()
self.status_setter = RepeatingTimer(280, self.set_online)
self.status_setter.start()
self.set_online()
self.create_unread_messages()
call_threaded(self.set_online, notify=True)
call_threaded(self.create_unread_messages)
wx.CallAfter(self.get_audio_albums, self.session.user_id)
wx.CallAfter(self.get_video_albums, self.session.user_id)
# wx.CallAfter(self.get_communities, self.session.user_id)
def create_longpoll_thread(self, notify=False):
try:
self.longpoll = longpollthread.worker(self.session)
self.longpoll.start()
if notify:
self.notify(message=_(u"Chat server reconnected"))
except ConnectionError:
pub.sendMessage("longpoll-read-timeout")
def in_post(self, buffer):
buffer = self.search(buffer)
@@ -170,7 +228,8 @@ class Controller(object):
def update_all_buffers(self):
log.debug("Updating buffers...")
self.session.audio_albums = self.session.vk.client.audio.getAlbums(owner_id=self.session.user_id)["items"]
self.get_audio_albums(self.session.user_id, create_buffers=False)
self.get_video_albums(self.session.user_id, create_buffers=False)
for i in self.buffers:
if hasattr(i, "get_items"):
i.get_items()
@@ -181,10 +240,15 @@ class Controller(object):
call_threaded(utils.download_file, url, filename, self.window)
def play_audio(self, audio_object):
# Restricted audios does not 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=_(u"This file could not be played because it is not allowed in your country"))
return
call_threaded(player.player.play, audio_object)
def play_audios(self, audios):
player.player.play_all(audios)
player.player.play_all(audios, shuffle=self.window.player_shuffle.IsChecked())
def view_post(self, post_object, controller_):
p = getattr(posts, controller_)(self.session, post_object)
@@ -193,10 +257,7 @@ class Controller(object):
def exit(self, *args, **kwargs):
log.debug("Receibed an exit signal. closing...")
try:
self.session.vk.client.account.setOffline()
except VkAuthError:
pass
self.set_offline()
self.disconnect_events()
self.window.Destroy()
wx.GetApp().ExitMainLoop()
@@ -210,7 +271,7 @@ class Controller(object):
b.get_more_items()
def check_for_updates(self, *args, **kwargs):
update = updater.do_update()
update = updater.do_update(update_type=self.session.settings["general"]["update_channel"])
if update == False:
commonMessages.no_update_available()
@@ -218,17 +279,30 @@ class Controller(object):
dlg = searchDialogs.searchAudioDialog()
if dlg.get_response() == widgetUtils.OK:
q = dlg.get("term").encode("utf-8")
count = 300
auto_complete = dlg.get_checkable("auto_complete")
lyrics = dlg.get_checkable("lyrics")
performer_only = dlg.get_checkable("artist_only")
sort = dlg.get_sort_order()
newbuff = buffers.audioBuffer(parent=self.window.tb, name=u"{0}_audiosearch".format(q.decode("utf-8"),), session=self.session, composefunc="compose_audio", parent_endpoint="audio", endpoint="search", q=q, count=count, auto_complete=auto_complete, lyrics=lyrics, performer_only=performer_only, sort=sort)
newbuff = buffers.audioBuffer(parent=self.window.tb, name=u"{0}_audiosearch".format(q.decode("utf-8"),), session=self.session, composefunc="render_audio", parent_endpoint="audio", endpoint="search", q=q)
self.buffers.append(newbuff)
call_threaded(newbuff.get_items)
# Translators: {0} will be replaced with the search term.
self.window.insert_buffer(newbuff.tab, _(u"Search for {0}").format(q.decode("utf-8"),), self.window.search("audios"))
def search_videos(self, *args, **kwargs):
dlg = searchDialogs.searchVideoDialog()
if dlg.get_response() == widgetUtils.OK:
params = {}
params["q"] = dlg.get("term").encode("utf-8")
params["count"] = 200
hd = dlg.get_checkable("hd")
if hd != 0:
params["hd"] = 1
params["adult"] = dlg.get_checkable("safe_search")
params["sort"] = dlg.get_sort_order()
params["filters"] = "youtube, vimeo, short, long"
newbuff = buffers.videoBuffer(parent=self.window.tb, name=u"{0}_videosearch".format(params["q"].decode("utf-8"),), session=self.session, composefunc="render_video", parent_endpoint="video", endpoint="search", **params)
self.buffers.append(newbuff)
call_threaded(newbuff.get_items)
# Translators: {0} will be replaced with the search term.
self.window.insert_buffer(newbuff.tab, _(u"Search for {0}").format(params["q"].decode("utf-8"),), self.window.search("videos"))
def update_status_bar(self, status):
self.window.change_status(status)
@@ -273,17 +347,16 @@ class Controller(object):
if user_id == None:
commonMessages.no_user_exist()
return
print user_id
if buffertype == "audio":
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], owner_id=user_id)
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id)
# Translators: {0} will be replaced with an user.
name_ = _(u"{0}'s audios").format(self.session.get_user_name(user_id, "gen"),)
elif buffertype == "wall":
buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_id,), composefunc="compose_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=user_id)
buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_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=user_id)
# Translators: {0} will be replaced with an user.
name_ = _(u"{0}'s wall posts").format(self.session.get_user_name(user_id, "gen"),)
elif buffertype == "friends":
buffer = buffers.peopleBuffer(parent=self.window.tb, name="friends_{0}".format(user_id,), composefunc="compose_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen", user_id=user_id)
buffer = buffers.peopleBuffer(parent=self.window.tb, name="friends_{0}".format(user_id,), composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen", user_id=user_id)
# Translators: {0} will be replaced with an user.
name_ = _(u"{0}'s friends").format(self.session.get_user_name(user_id, "friends"),)
self.buffers.append(buffer)
@@ -304,7 +377,7 @@ class Controller(object):
if i.kwargs.has_key("user_id") and i.kwargs["user_id"] == user_id: return i
return None
def chat_from_id(self, user_id, setfocus=True):
def chat_from_id(self, user_id, setfocus=True, unread=False):
b = self.search_chat_buffer(user_id)
if b != None:
pos = self.window.search(b.name)
@@ -312,71 +385,167 @@ class Controller(object):
self.window.change_buffer(pos)
return b.tab.text.SetFocus()
return
buffer = buffers.chatBuffer(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="compose_message", session=self.session, count=200, user_id=user_id, rev=1)
buffer = buffers.chatBuffer(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="render_message", session=self.session, count=200, user_id=user_id, rev=0, extended=True, fields="id, user_id, date, read_state, out, body, attachments, deleted")
self.buffers.append(buffer)
# Translators: {0} will be replaced with an user.
self.window.insert_buffer(buffer.tab, _(u"Chat with {0}").format(self.session.get_user_name(user_id,)), self.window.search("chats"))
self.window.insert_buffer(buffer.tab, _(u"Chat with {0}").format(self.session.get_user_name(user_id, "ins")), self.window.search("chats"))
if setfocus:
pos = self.window.search(buffer.name)
self.window.change_buffer(pos)
wx.CallAfter(buffer.get_items)
wx.CallAfter(buffer.get_items, unread=unread)
if setfocus: buffer.tab.text.SetFocus()
return True
def user_online(self, event):
if self.session.settings["chat"]["notify_online"] == False:
return
user_name = self.session.get_user_name(event.user_id, "nom")
msg = _(u"{0} is online.").format(user_name,)
sound = "friend_online.ogg"
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
def user_offline(self, event):
if self.session.settings["chat"]["notify_offline"] == False:
return
user_name = self.session.get_user_name(event.user_id, "nom")
msg = _(u"{0} is offline.").format(user_name,)
sound = "friend_offline.ogg"
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
def get_chat(self, obj=None):
""" Searches or creates a chat buffer with the id of the user that is sending or receiving a message.
obj vk.longpool.event: an event wich defines some data from the vk's longpool server."""
# Set user_id to the id of the friend wich is receiving or sending the message.
obj.user_id = obj.from_id
buffer = self.search_chat_buffer(obj.user_id)
obj vk_api.longpoll.EventType: an event wich defines some data from the vk's long poll server."""
message = {}
# If someone else sends a message to the current user.
if obj.to_me:
buffer = self.search_chat_buffer(obj.user_id)
uid = obj.user_id
message.update(out=0)
# If the current user sends a message to someone else.
else:
buffer = self.search_chat_buffer(obj.peer_id)
uid = obj.peer_id
# If there is no buffer, we must create one in a wxThread so it will not crash.
if buffer == None:
wx.CallAfter(self.chat_from_id, obj.user_id)
self.session.soundplayer.play("chat.ogg")
wx.CallAfter(self.chat_from_id, uid, setfocus=self.session.settings["chat"]["automove_to_conversations"], unread=True)
self.session.soundplayer.play("conversation_opened.ogg")
return
# If the chat already exists, let's create a dictionary wich will contains data of the received message.
message = {"id": obj.message_id, "user_id": obj.user_id, "date": obj.timestamp, "body": obj.text, "attachments": obj.attachments}
# If outbox it's true, it means that message["from_id"] should be the current user. If not, the obj.user_id should be taken.
if obj.message_flags.has_key("outbox") == True:
message.update(id=obj.message_id, user_id=uid, date=obj.timestamp, body=obj.text, attachments=obj.attachments, read_state=0)
# if attachments is true, let's request for the full message with attachments formatted in a better way.
# Todo: code improvements. We shouldn't need to request the same message again just for these attachments.
if len(message["attachments"]) != 0:
message_ids = message["id"]
results = self.session.vk.client.messages.getById(message_ids=message_ids)
message = results["items"][0]
message.update(read_state=0)
if obj.from_me:
message["from_id"] = self.session.user_id
else:
message["from_id"] = obj.from_id
message["from_id"] = obj.user_id
data = [message]
# Let's add this to the buffer.
# ToDo: Clean this code and test how is the database working with this set to True.
num = self.session.order_buffer(buffer.name, data, True)
buffer.insert(self.session.db[buffer.name]["items"][-1], False)
self.session.soundplayer.play("chat.ogg")
self.session.soundplayer.play("message_received.ogg")
# Check if we have to read the message aloud
if buffer == self.get_current_buffer():
rendered_message = renderers.render_message(message, self.session)
output.speak(rendered_message[0])
def set_online(self):
r = self.session.vk.client.account.setOnline()
def set_online(self, notify=False):
try:
r = self.session.vk.client.account.setOnline()
except:
log.error("Error in setting online for the current user")
if notify:
self.window.notify("Socializer", "online now!")
def set_offline(self):
try:
r = self.session.vk.client.account.setOffline()
except:
log.error("Error in setting offline status for the current user")
def create_unread_messages(self):
msgs = self.session.vk.client.messages.getDialogs(count=200, unread=1)
if self.session.settings["chat"]["open_unread_conversations"] == False:
return
try:
log.debug("Getting possible unread messages.")
msgs = self.session.vk.client.messages.getDialogs(count=200, unread=1)
except VkApiError as ex:
if ex.code == 6:
log.exception("Something went wrong when getting messages. Waiting a second to retry")
time.sleep(2)
return self.create_unread_messages()
for i in msgs["items"]:
wx.CallAfter(self.chat_from_id, i["message"]["user_id"], setfocus=False)
wx.CallAfter(self.chat_from_id, i["message"]["user_id"], setfocus=False, unread=True)
def mark_as_read(self):
ids = ""
for i in self.buffers:
if hasattr(i, "reads"):
for z in i.reads:
ids = ids+"%d," % (z,)
if hasattr(i, "reads") and len(i.reads) != 0:
response = self.session.vk.client.messages.markAsRead(peer_id=i.kwargs["user_id"])
i.clear_reads()
i.reads = []
if ids != "":
response = self.session.vk.client.messages.markAsRead(message_ids=ids)
time.sleep(1)
def get_audio_albums(self, user_id=None):
albums = self.session.vk.client.audio.getAlbums(owner_id=user_id)
self.session.audio_albums = albums["items"]
for i in albums["items"]:
buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=user_id, album_id=i["id"])
buffer.can_get_items = False
# Translators: {0} Will be replaced with an audio album's title.
name_ = _(u"Album: {0}").format(i["title"],)
self.buffers.append(buffer)
self.window.insert_buffer(buffer.tab, name_, self.window.search("albums"))
buffer.get_items()
# inserts a pause of 1 second here, so we'll avoid errors 6 in VK.
def get_audio_albums(self, user_id=None, create_buffers=True):
log.debug("Create audio albums...")
if self.session.settings["vk"]["use_alternative_tokens"]:
albums = self.session.vk.client_audio.get_albums(owner_id=user_id)
else:
albums = self.session.vk.client.audio.getPlaylists(owner_id=user_id)
albums = albums["items"]
self.session.audio_albums = albums
if create_buffers:
for i in albums:
buffer = buffers.audioAlbum(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"])
buffer.can_get_items = False
# Translators: {0} Will be replaced with an audio album's title.
name_ = _(u"Album: {0}").format(i["title"],)
self.buffers.append(buffer)
self.window.insert_buffer(buffer.tab, name_, self.window.search("albums"))
# buffer.get_items()
# inserts a pause of 1 second here, so we'll avoid errors 6 in VK.
# time.sleep(0.3)
def get_video_albums(self, user_id=None, create_buffers=True):
log.debug("Create video albums...")
albums = self.session.vk.client.video.getAlbums(owner_id=user_id)
self.session.video_albums = albums["items"]
if create_buffers:
for i in albums["items"]:
buffer = buffers.videoAlbum(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"])
buffer.can_get_items = False
# Translators: {0} Will be replaced with a video album's title.
name_ = _(u"Album: {0}").format(i["title"],)
self.buffers.append(buffer)
self.window.insert_buffer(buffer.tab, name_, self.window.search("video_albums"))
# buffer.get_items()
# inserts a pause of 1 second here, so we'll avoid errors 6 in VK.
# time.sleep(0.3)
def get_communities(self, user_id=None, create_buffers=True):
log.debug("Create community buffers...")
groups= self.session.vk.client.groups.get(user_id=user_id, extended=1, fields="city, country, place, description, wiki_page, members_count, counters, start_date, finish_date, can_post, can_see_all_posts, activity, status, contacts, links, fixed_post, verified, site, can_create_topic")
print groups.keys()
self.session.groups=groups["items"]
# Let's feed the local database cache with new groups coming from here.
data= dict(profiles=[], groups=groups["items"])
self.session.process_usernames(data)
if create_buffers:
for i in groups["items"]:
print i.keys()
buffer = buffers.communityBuffer(parent=self.window.tb, name="{0}_community".format(i["id"],), composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"])
buffer.can_get_items = False
# Translators: {0} Will be replaced with a video album's title.
name_ =i["name"]
self.buffers.append(buffer)
self.window.insert_buffer(buffer.tab, name_, self.window.search("communities"))
# buffer.get_items()
# inserts a pause of 1 second here, so we'll avoid errors 6 in VK.
# time.sleep(0.3)
def create_audio_album(self, *args, **kwargs):
d = creation.audio_album()
@@ -384,7 +553,7 @@ class Controller(object):
response = self.session.vk.client.audio.addAlbum(title=d.get("title"))
if response.has_key("album_id") == False: return
album_id = response["album_id"]
buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(album_id,), composefunc="compose_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=self.session.user_id, album_id=album_id)
buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(album_id,), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=self.session.user_id, album_id=album_id)
buffer.can_get_items = False
# Translators: {0} will be replaced with an audio album's title.
name_ = _(u"Album: {0}").format(d.get("title"),)
@@ -394,7 +563,7 @@ class Controller(object):
self.session.audio_albums = self.session.vk.client.audio.getAlbums(owner_id=self.session.user_id)["items"]
def delete_audio_album(self, *args, **kwargs):
answer = selector.audioAlbum(_(u"Select the album you want to delete"), self.session)
answer = selector.album(_(u"Select the album you want to delete"), self.session)
if answer.item == None:
return
response = commonMessages.delete_audio_album()
@@ -407,8 +576,117 @@ class Controller(object):
del buffer
self.session.audio_albums = self.session.vk.client.audio.getAlbums(owner_id=self.session.user_id)["items"]
def create_video_album(self, *args, **kwargs):
d = creation.audio_album()
if d.get_response() == widgetUtils.OK and d.get("title") != "":
response = self.session.vk.client.video.addAlbum(title=d.get("title"))
if response.has_key("album_id") == False: return
album_id = response["album_id"]
buffer = buffers.videoAlbum(parent=self.window.tb, name="{0}_video_album".format(album_id,), composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], user_id=self.session.user_id, album_id=album_id)
buffer.can_get_items = False
# Translators: {0} will be replaced with a video album's title.
name_ = _(u"Album: {0}").format(d.get("title"),)
self.buffers.append(buffer)
self.window.insert_buffer(buffer.tab, name_, self.window.search("video_albums"))
buffer.get_items()
self.session.video_albums = self.session.vk.client.video.getAlbums(owner_id=self.session.user_id)["items"]
def delete_video_album(self, *args, **kwargs):
answer = selector.album(_(u"Select the album you want to delete"), self.session, "video_albums")
if answer.item == None:
return
response = commonMessages.delete_audio_album()
if response != widgetUtils.YES: return
removal = self.session.vk.client.video.deleteAlbum(album_id=answer.item)
buffer = self.search("{0}_video_album".format(answer.item,))
buff = self.window.search(buffer.name)
self.window.remove_buffer(buff)
self.buffers.remove(buffer)
del buffer
self.session.video_albums = self.session.vk.client.video.getAlbums(owner_id=self.session.user_id)["items"]
def check_documentation(self, *args, **kwargs):
lang = localization.get("documentation")
os.chdir("documentation/%s" % (lang,))
webbrowser.open("manual.html")
os.chdir("../../")
def menu_play_pause(self, *args, **kwargs):
if player.player.check_is_playing() != False:
return player.player.pause()
b = self.get_current_buffer()
if hasattr(b, "play_next"):
b.play_audio()
else:
b = self.search("me_audio")
b.play_audio()
def menu_play_next(self, *args, **kwargs):
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):
b = self.get_current_buffer()
if hasattr(b, "play_previous"):
b.play_previous()
else:
self.search("me_audio").play_previous()
def menu_play_all(self, *args, **kwargs):
b = self.get_current_buffer()
if hasattr(b, "play_all"):
b.play_all()
else:
self.search("me_audio").play_all()
def menu_stop(self, *args, **kwargs):
player.player.stop()
def menu_volume_down(self, *args, **kwargs):
player.player.volume = player.player.volume-5
def menu_volume_up(self, *args, **kwargs):
player.player.volume = player.player.volume+5
def menu_mute(self, *args, **kwargs):
player.player.volume = 0
def user_profile(self, person):
p = profiles.userProfile(self.session, person)
def view_my_profile(self, *args, **kwargs):
self.user_profile(self.session.user_id)
def view_my_profile_in_browser(self, *args, **kwargs):
webbrowser.open_new_tab("https://vk.com/id{id}".format(id=self.session.user_id,))
def notify(self, message="", sound="", type="native"):
if type == "native":
self.window.notify(_("Socializer"), message)
else:
if sound != "":
self.session.soundplayer.play(sound)
if message != "":
output.speak(message)
def handle_longpoll_read_timeout(self):
if hasattr(self, "longpoll"):
self.notify(message=_(u"Chat disconnected. Trying to connect in 60 seconds"))
time.sleep(60)
if hasattr(self, "longpoll"):
del self.longpoll
self.create_longpoll_thread(notify=True)
def set_status(self, *args, **kwargs):
dlg = wx.TextEntryDialog(self.window, _(u"Write your status message"), _(u"Set status"))
if dlg.ShowModal() == widgetUtils.OK:
result = dlg.GetValue()
info = self.session.vk.client.account.saveProfileInfo(status=result)
commonMessages.updated_status()
dlg.Destroy()
def on_report_error(self, *args, **kwargs):
r = issueReporter.reportBug()

View File

@@ -1,19 +1,25 @@
# -*- coding: utf-8 -*-
import time
import widgetUtils
import output
from pubsub import pub
import attach
from wxUI.dialogs import message
from wxUI.dialogs import message, selector
from extra import SpellChecker, translator
from logging import getLogger
log = getLogger("controller.message")
class post(object):
def __init__(self, title, caption, text, post_type="post"):
def __init__(self, session, title, caption, text, post_type="post"):
super(post, self).__init__()
self.session = session
self.title = title
self.message = getattr(message, post_type)(title, caption, text)
self.message.set_title(title)
widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck)
widgetUtils.connect_event(self.message.translateButton, widgetUtils.BUTTON_PRESSED, self.translate)
widgetUtils.connect_event(self.message.mention, widgetUtils.BUTTON_PRESSED, self.mention)
self.images = []
if hasattr(self.message, "attach"):
widgetUtils.connect_event(self.message.attach, widgetUtils.BUTTON_PRESSED, self.show_attach_dialog)
@@ -26,13 +32,31 @@ class post(object):
privacy = 1
return privacy
def mention(self, *args, **kwargs):
try:
fields = "id, first_name, last_name"
friends = self.session.vk.client.friends.get(count=5000, fields=fields)
except AttributeError:
time.sleep(2)
log.exception("Error retrieving friends...")
return self.mention(*args, **kwargs)
users = []
for i in friends["items"]:
users.append(u"{0} {1}".format(i["first_name"], i["last_name"]))
select = selector.selectPeople(users)
if select.get_response() == widgetUtils.OK and select.users.GetCount() > 0:
self.tagged_people = []
tagged_users = select.get_all_users()
for i in tagged_users:
self.tagged_people.append(u"[id%s|%s]" % (str(friends["items"][i]["id"]), friends["items"][i]["first_name"]))
self.message.text.SetValue(self.message.text.GetValue()+ u", ".join(self.tagged_people))
def translate(self, *args, **kwargs):
dlg = translator.gui.translateDialog()
if dlg.get_response() == widgetUtils.OK:
text_to_translate = self.message.get_text()
source = [x[0] for x in translator.translator.available_languages()][dlg.get("source_lang")]
dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
msg = translator.translator.translate(text_to_translate, source, dest)
msg = translator.translator.translate(text_to_translate, dest)
self.message.set_text(msg)
self.message.text_focus()
output.speak(_(u"Translated"))
@@ -46,11 +70,11 @@ class post(object):
checker.clean()
def show_attach_dialog(self, *args, **kwargs):
a = attach.attach()
a = attach.attach(self.session)
if len(a.attachments) != 0:
self.attachments = a.attachments
class comment(post):
def __init__(self, title, caption, text):
super(comment, self).__init__(title, caption, text, "comment")
def __init__(self, session, title, caption, text):
super(comment, self).__init__(session, title, caption, text, "comment")
self.message.set_title(_(u"New comment"))

View File

@@ -1,11 +1,16 @@
# -*- coding: utf-8 -*-
import random
import output
import sound_lib
import logging
from sound_lib.stream import URLStream
from sound_lib.main import BassError
from mysc.repeating_timer import RepeatingTimer
from pubsub import pub
player = None
log = logging.getLogger("player")
def setup():
global player
@@ -22,9 +27,13 @@ class audioPlayer(object):
self.queue = []
self.stopped = True
def play(self, url):
def play(self, url, set_info=True):
if self.stream != None and self.stream.is_playing == True:
self.stream.stop()
try:
self.stream.stop()
except BassError:
log.exception("error when stopping the file")
self.stream = None
self.stopped = True
if hasattr(self, "worker") and self.worker != None:
self.worker.cancel()
@@ -33,10 +42,15 @@ class audioPlayer(object):
# Make sure that there are no other sounds trying to be played.
if self.is_working == False:
self.is_working = True
self.stream = URLStream(url=url["url"])
try:
self.stream = URLStream(url=url["url"])
except BassError:
log.debug("Error when playing the file %r") % (url,)
return
# Translators: {0} will be replaced with a song's title and {1} with the artist.
msg = _(u"Playing {0} by {1}").format(url["title"], url["artist"])
pub.sendMessage("update-status-bar", status=msg)
if set_info:
msg = _(u"Playing {0} by {1}").format(url["title"], url["artist"])
pub.sendMessage("update-status-bar", status=msg)
self.stream.volume = self.vol/100.0
self.stream.play()
self.stopped = False
@@ -57,8 +71,11 @@ class audioPlayer(object):
self.stream.pause()
self.stopped = True
else:
self.stream.play()
self.stopped = False
try:
self.stream.play()
self.stopped = False
except BassError:
pass
@property
def volume(self):
@@ -72,18 +89,30 @@ class audioPlayer(object):
if self.stream != None:
self.stream.volume = self.vol/100.0
def play_all(self, list_of_urls):
def play_all(self, list_of_urls, shuffle=False):
self.stop()
self.queue = list_of_urls
# Skip all country restricted tracks as they are not playable here.
self.queue = [i for i in list_of_urls if i["url"] != ""]
if shuffle:
random.shuffle(self.queue)
self.play(self.queue[0])
self.queue.remove(self.queue[0])
self.worker = RepeatingTimer(5, self.player_function)
self.worker.start()
def player_function(self):
if self.stream != None and self.stream.is_playing == False and self.stopped == False:
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:
self.worker.cancel()
return
self.play(self.queue[0])
self.queue.remove(self.queue[0])
def check_is_playing(self):
if self.stream == None:
return False
if self.stream != None and self.stream.is_playing == False:
return False
else:
return True

View File

@@ -1,17 +1,21 @@
# -*- coding: utf-8 -*-
import re
import os
import cStringIO
import threading
import arrow
import messages
import requests
import languageHandler
import widgetUtils
import output
import wx
import webbrowser
import utils
import logging
from sessionmanager import session # We'll use some functions from there
from sessionmanager import utils
from pubsub import pub
from wxUI.dialogs import postDialogs, urlList
from wxUI.dialogs import postDialogs, urlList, profiles
from extra import SpellChecker, translator
from mysc.thread_utils import call_threaded
from wxUI import menus
@@ -23,31 +27,9 @@ def get_user(id, profiles):
for i in profiles:
if i["id"] == id:
return u"{0} {1}".format(i["first_name"], i["last_name"])
# Translators: This string is user when socializer can't find the right user information.
# Translators: This string is used when socializer can't find the right user information.
return _(u"Unknown username")
def add_attachment(attachment):
msg = u""
tpe = ""
if attachment["type"] == "link":
msg = u"{0}: {1}".format(attachment["link"]["title"], attachment["link"]["url"])
tpe = _(u"Link")
elif attachment["type"] == "photo":
tpe = _(u"Photo")
msg = attachment["photo"]["text"]
if msg == "":
msg = _(u"no description available")
elif attachment["type"] == "video":
msg = u"{0}".format(attachment["video"]["title"],)
tpe = _(u"Video")
elif attachment["type"] == "audio":
msg = u"{0}".format(" ".join(session.compose_audio(attachment["audio"])))
tpe = _(u"Audio")
elif attachment["type"] == "doc":
msg = u"{0}".format(attachment["doc"]["title"])
tpe = _(u"{0} file").format(attachment["doc"]["ext"])
return [tpe, msg]
def get_message(status):
message = ""
if status.has_key("text"):
@@ -55,6 +37,8 @@ def get_message(status):
return message
class postController(object):
""" Base class for post representation."""
def __init__(self, session, postObject):
super(postController, self).__init__()
self.session = session
@@ -79,29 +63,43 @@ class postController(object):
widgetUtils.connect_event(self.dialog.repost, widgetUtils.BUTTON_PRESSED, self.post_repost)
# self.dialog.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.show_menu, self.dialog.comments.list)
# self.dialog.Bind(wx.EVT_LIST_KEY_DOWN, self.show_menu_by_key, self.dialog.comments.list)
call_threaded(self.load_all_components)
# if self.post.has_key("attachments"): print self.post["attachments"]
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
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)
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_ = get_user(i["from_id"], self.comments["profiles"])
if i.has_key("reply_to_user"):
extra_info = get_user(i["reply_to_user"], self.comments["profiles"])
from_ = _(u"{0} Has replied to {1}").format(from_, extra_info)
if len(i["text"]) > 140:
text = i["text"][:141]
from_ = _(u"{0} > {1}").format(from_, extra_info)
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
fixed_text = re.sub("^\[id\d+\|\D+\], ", "", i["text"])
if len(fixed_text) > 140:
text = fixed_text[:141]
else:
text = i["text"]
text = fixed_text
original_date = arrow.get(i["date"])
created_at = original_date.humanize(locale=languageHandler.getLanguage())
likes = str(i["likes"]["count"])
comments_.append((from_, text, created_at, likes))
self.dialog.insert_comments(comments_)
try:
self.dialog.insert_comments(comments_)
except wx.PyDeadObjectError:
pass
def get_post_information(self):
from_ = self.session.get_user_name(self.post[self.user_identifier])
@@ -110,7 +108,7 @@ class postController(object):
title = _(u"repost from {0}").format(from_,)
else:
if self.post.has_key("from_id") and self.post.has_key("owner_id"):
# Translators: {0} will be replaced with the user who is posting, and {2} with the wall owner.
# Translators: {0} will be replaced with the user who is posting, and {1} with the wall owner.
title = _(u"Post from {0} in the {1}'s wall").format(self.session.get_user_name(self.post["from_id"]), self.session.get_user_name(self.post["owner_id"]))
else:
title = _(u"Post from {0}").format(from_,)
@@ -125,6 +123,7 @@ class postController(object):
message += nm
self.dialog.set_post(message)
self.get_attachments(self.post)
self.check_image_load()
def get_attachments(self, post):
attachments = []
@@ -133,24 +132,78 @@ class postController(object):
# We don't need the photos_list attachment, so skip it.
if i["type"] == "photos_list":
continue
attachments.append(add_attachment(i))
if i["type"] == "photo":
if self.load_images == False: self.load_images = True
self.images.append(i)
attachments.append(utils.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(self.dialog.get("post_view"))
print urls
if len(urls) > 0:
links = []
for i in urls:
links.append({"link": {"title": _(U"Untitled link"), "url": i}, "type": "link"})
for i in links:
attachments.append(add_attachment(i))
attachments.append(utils.add_attachment(i))
self.attachments.append(i)
if len(self.attachments) > 0:
self.dialog.attachments.list.Enable(True)
self.dialog.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_attachment)
self.dialog.insert_attachments(attachments)
def check_image_load(self):
if self.load_images and len(self.images) > 0 and self.session.settings["general"]["load_images"]:
self.dialog.image.Enable(True)
nav = False # Disable navigation controls in photos
if len(self.images) > 1:
nav = True
widgetUtils.connect_event(self.dialog.previous_photo, widgetUtils.BUTTON_PRESSED, self.set_previous_image)
widgetUtils.connect_event(self.dialog.next_photo, widgetUtils.BUTTON_PRESSED, self.set_next_image)
self.dialog.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:
log.exception("Error in loading image {0} in a list with {1} images".format(index, len(self.images)))
return
# Get's photo URL.
url = self.get_photo_url(self.images[index]["photo"], "x")
if url != "":
img = requests.get(url)
image = wx.Image(stream=cStringIO.StringIO(requests.get(url).content))
try:
self.dialog.image.SetBitmap(wx.Bitmap(image))
except NameError:
return
self.dialog.SetClientSize(self.dialog.sizer.CalcMin())
# Translators: {0} is the number of the current photo and {1} is the total number of photos.
output.speak(_(u"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_post_information()
self.get_likes()
@@ -192,19 +245,25 @@ class postController(object):
def post_repost(self, *args, **kwargs):
object_id = "wall{0}_{1}".format(self.post[self.user_identifier], self.post[self.post_identifier])
p = messages.post(title=_(u"Repost"), caption=_(u"Add your comment here"), text="")
p = messages.post(session=self.session, title=_(u"Repost"), caption=_(u"Add your comment here"), text="")
if p.message.get_response() == widgetUtils.OK:
msg = p.message.get_text().encode("utf-8")
self.session.vk.client.wall.repost(object=object_id, message=msg)
def get_likes(self):
self.dialog.set_likes(self.post["likes"]["count"])
try:
self.dialog.set_likes(self.post["likes"]["count"])
except wx.PyDeadObjectError:
pass
def get_reposts(self):
self.dialog.set_shares(self.post["reposts"]["count"])
try:
self.dialog.set_shares(self.post["reposts"]["count"])
except wx.PyDeadObjectError:
pass
def add_comment(self, *args, **kwargs):
comment = messages.comment(title=_(u"Add a comment"), caption="", text="")
comment = messages.comment(session=self.session, title=_(u"Add a comment"), caption="", text="")
if comment.message.get_response() == widgetUtils.OK:
msg = comment.message.get_text().encode("utf-8")
try:
@@ -216,7 +275,7 @@ class postController(object):
self.clear_comments_list()
self.get_comments()
except Exception as msg:
print msg
log.error(msg)
def clear_comments_list(self):
self.dialog.comments.clear()
@@ -258,9 +317,8 @@ class postController(object):
dlg = translator.gui.translateDialog()
if dlg.get_response() == widgetUtils.OK:
text_to_translate = self.dialog.post_view.GetValue().encode("utf-8")
source = [x[0] for x in translator.translator.available_languages()][dlg.get("source_lang")]
dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
msg = translator.translator.translate(text_to_translate, source, dest)
msg = translator.translator.translate(text_to_translate, target=dest)
self.dialog.post_view.ChangeValue(msg)
output.speak(_(u"Translated"))
else:
@@ -272,22 +330,6 @@ class postController(object):
if hasattr(checker, "fixed_text"):
self.dialog.post_view.ChangeValue(checker.fixed_text)
def open_url(self, *args, **kwargs):
text = self.dialog.post_view.GetValue()
urls = find_urls(text)
url = None
if len(urls) == 0: return
if len(urls) == 1:
url = urls[0]
elif len(urls) > 1:
url_list = urlList.urlList()
url_list.populate_list(urls)
if url_list.get_response() == widgetUtils.OK:
url = urls[url_list.get_item()]
if url != None:
output.speak(_(u"Opening URL..."), True)
webbrowser.open_new_tab(url)
def open_attachment(self, *args, **kwargs):
index = self.dialog.attachments.get_selected()
attachment = self.attachments[index]
@@ -321,13 +363,16 @@ class postController(object):
for i in possible_sizes:
if attachment["photo"].has_key("photo_{0}".format(i,)):
url = attachment["photo"]["photo_{0}".format(i,)]
break
if url != "":
webbrowser.open_new_tab(url)
else:
print attachment["photo"].keys()
else:
log.debug("Unhandled attachment: %r" % (attachment,))
def __del__(self):
if hasattr(self, "worker"):
self.worker.finished.set()
class comment(object):
def __init__(self, session, comment_object):
super(comment, self).__init__()
@@ -462,3 +507,107 @@ class friendship(object):
def set_friends_list(self, friendslist):
for i in friendslist:
self.dialog.friends.insert_item(False, *[i])
class userProfile(object):
def __init__(self, session, user_id):
self.person = None
self.session = session
self.user_id = user_id
self.dialog = profiles.userProfile(title=_(u"Profile"))
self.dialog.create_controls("main_info")
self.dialog.realice()
self.get_basic_information()
if self.person != None:
self.dialog.get_response()
def get_basic_information(self):
""" Gets and inserts basic user information.
See https://vk.com/dev/users.get"""
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"
person = self.session.vk.client.users.get(user_ids=self.user_id, fields=fields)
if len(person) == 0:
return output.speak(_(u"Information for groups is not supported, yet."))
person = person[0]
print person
# Gets full name.
n = u"{0} {1}".format(person["first_name"], person["last_name"])
# Gets birthdate.
if person.has_key("bdate") and person["bdate"] != "":
self.dialog.main_info.enable("bdate")
if len(person["bdate"]) <= 5:
d = arrow.get(person["bdate"], "D.m")
self.dialog.main_info.set("bdate", d.format(_(u"MMMM D"), locale=languageHandler.getLanguage()))
else:
d = arrow.get(person["bdate"], "D.M.YYYY")
self.dialog.main_info.set("bdate", d.format(_(u"MMMM D, YYYY"), locale=languageHandler.getLanguage()))
# Gets current city and home town
city = ""
if person.has_key("home_town") and person["home_town"] != "":
home_town = person["home_town"]
self.dialog.main_info.enable("home_town")
self.dialog.main_info.set("home_town", home_town)
if person.has_key("city") and len(person["city"]) > 0:
city = person["city"]["title"]
if person.has_key("country") and person["country"] != "":
if city != "":
city = city+u", {0}".format(person["country"]["title"])
else:
city = person["country"]["title"]
self.dialog.main_info.enable("city")
self.dialog.main_info.set("city", city)
self.dialog.main_info.set("name", n)
self.dialog.SetTitle(_(u"{name}'s profile").format(name=n,))
# Gets website
if person.has_key("site") and person["site"] != "":
self.dialog.main_info.enable("website")
self.dialog.main_info.set("website", person["site"])
self.dialog.main_info.enable("go_site")
widgetUtils.connect_event(self.dialog.main_info.go_site, widgetUtils.BUTTON_PRESSED, self.visit_website)
if person.has_key("status") and person["status"] != "":
self.dialog.main_info.enable("status")
self.dialog.main_info.set("status", person["status"])
if person.has_key("occupation") and person["occupation"] != None:
if person["occupation"]["type"] == "work": c1 = _(u"Work ")
elif person["occupation"]["type"] == "school": c1 = _(u"Student ")
elif person["occupation"]["type"] == "university": c1 = _(u"Student ")
if person["occupation"].has_key("name") and person["occupation"]["name"] != "":
c2 = _(u"In {0}").format(person["occupation"]["name"],)
else:
c2 = ""
self.dialog.main_info.enable("occupation")
self.dialog.main_info.set("occupation", c1+c2)
if person.has_key("relation") and person["relation"] != 0:
print person["relation"]
if person["relation"] == 1:
r = _(u"Single")
elif person["relation"] == 2:
if person.has_key("relation_partner"):
r = _(u"Dating with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
else:
r = _(u"Dating")
elif person["relation"] == 3:
r = _(u"Engaged with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
elif person["relation"] == 4:
r = _(u"Married with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
elif person["relation"] == 5:
r = _(u"It's complicated")
elif person["relation"] == 6:
r = _(u"Actively searching")
elif person["relation"] == 7:
r = _(u"In love")
self.dialog.main_info.enable("relation")
self.dialog.main_info.relation.SetLabel(_(u"Relationship: ")+r)
if person.has_key("last_seen") and person["last_seen"] != False:
original_date = arrow.get(person["last_seen"]["time"])
# Translators: This is the date of last seen
last_seen = _(u"{0}").format(original_date.humanize(locale=languageHandler.getLanguage()),)
self.dialog.main_info.enable("last_seen")
self.dialog.main_info.set("last_seen", last_seen)
log.info("getting info...")
self.person = person
self.dialog.SetClientSize(self.dialog.sizer.CalcMin())
def visit_website(self, *args, **kwargs):
output.speak(_(u"Opening website..."))
webbrowser.open_new_tab(self.person["site"])

161
src/controller/profiles.py Normal file
View File

@@ -0,0 +1,161 @@
# -*- coding: utf-8 -*-
""" A profile viewer and editor for VK user objects."""
import cStringIO
import webbrowser
import logging
import arrow
import requests
import languageHandler
import widgetUtils
import output
import wx
from wxUI.dialogs import urlList, profiles
from sessionmanager import utils
log = logging.getLogger("controller.profiles")
class userProfile(object):
""" Main controller to view an user profile. This controller will retrieve needed data from the VK website and display it appropiately."""
def __init__(self, session, user_id):
""" Default constructor:
@session vk.session: The main session object, capable of calling VK methods.
@user_id integer: User ID to retrieve information of.
At the current time, only users (and not communities) are supported.
"""
# self.person will hold a reference to the user object when retrieved from VK.
self.person = None
self.session = session
self.user_id = user_id
self.dialog = profiles.userProfile(title=_(u"Profile"))
self.dialog.create_controls("main_info")
self.dialog.realice()
self.get_basic_information()
if self.person != None:
self.dialog.get_response()
def get_basic_information(self):
""" Gets and inserts basic user information.
See https://vk.com/dev/users.get"""
# List of fields (information) to retrieve. For a list of fields available for user objects,
# see https://vk.com/dev/fields
fields = "first_name, last_name, bdate, city, country, home_town, photo_200_orig, online, site, status, last_seen, occupation, relation, relatives, personal, connections, activities, interests, music, movies, tv, books, games, about, quotes, can_write_private_message"
# ToDo: this method supports multiple user IDS, I'm not sure if this may be of any help for profile viewer.
person = self.session.vk.client.users.get(user_ids=self.user_id, fields=fields)
# If VK does not return anything it is very likely we have found a community.
if len(person) == 0:
return output.speak(_(u"Information for groups is not supported, yet."))
person = person[0]
# toDo: remove this print when I will be done with creation of profile viewer logic.
print(person)
# From this part we will format data from VK so users will see it in the GUI control.
# Format full name.
n = u"{0} {1}".format(person["first_name"], person["last_name"])
# Format birthdate.
if person.has_key("bdate") and person["bdate"] != "":
self.dialog.main_info.enable("bdate")
# VK can display dd.mm or dd.mm.yyyy birthdates. So let's compare the string lenght to handle both cases accordingly.
if len(person["bdate"]) <= 5: # dd.mm
d = arrow.get(person["bdate"], "D.M")
self.dialog.main_info.set("bdate", d.format(_(u"MMMM D"), locale=languageHandler.curLang[:2]))
else: # mm.dd.yyyy
d = arrow.get(person["bdate"], "D.M.YYYY")
self.dialog.main_info.set("bdate", d.format(_(u"MMMM D, YYYY"), locale=languageHandler.curLang[:2]))
# Format current city and home town
city = ""
if person.has_key("home_town") and person["home_town"] != "":
home_town = person["home_town"]
self.dialog.main_info.enable("home_town")
self.dialog.main_info.set("home_town", home_town)
if person.has_key("city") and len(person["city"]) > 0:
city = person["city"]["title"]
if person.has_key("country") and person["country"] != "":
if city != "":
city = city+u", {0}".format(person["country"]["title"])
else:
city = person["country"]["title"]
self.dialog.main_info.enable("city")
self.dialog.main_info.set("city", city)
self.dialog.main_info.set("name", n)
self.dialog.SetTitle(_(u"{name}'s profile").format(name=n,))
# Format website (or websites, if there are multiple of them).
if person.has_key("site") and person["site"] != "":
self.dialog.main_info.enable("website")
self.dialog.main_info.set("website", person["site"])
self.dialog.main_info.enable("go_site")
widgetUtils.connect_event(self.dialog.main_info.go_site, widgetUtils.BUTTON_PRESSED, self.visit_website)
# Format status message.
if person.has_key("status") and person["status"] != "":
self.dialog.main_info.enable("status")
self.dialog.main_info.set("status", person["status"])
# Format occupation.
# toDo: Research in this field is needed. Sometimes it returns university information even if users have active work places.
if person.has_key("occupation") and person["occupation"] != None:
if person["occupation"]["type"] == "work": c1 = _(u"Work ")
elif person["occupation"]["type"] == "school": c1 = _(u"Student ")
elif person["occupation"]["type"] == "university": c1 = _(u"Student ")
if person["occupation"].has_key("name") and person["occupation"]["name"] != "":
c2 = _(u"In {0}").format(person["occupation"]["name"],)
else:
c2 = ""
self.dialog.main_info.enable("occupation")
self.dialog.main_info.set("occupation", c1+c2)
# format relationship status.
# ToDo: When dating someone, the button associated to the information should point to the profile of the user.
if person.has_key("relation") and person["relation"] != 0:
if person["relation"] == 1:
r = _(u"Single")
elif person["relation"] == 2:
if person.has_key("relation_partner"):
r = _(u"Dating with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
else:
r = _(u"Dating")
elif person["relation"] == 3:
r = _(u"Engaged with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
elif person["relation"] == 4:
r = _(u"Married with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
elif person["relation"] == 5:
r = _(u"It's complicated")
elif person["relation"] == 6:
r = _(u"Actively searching")
elif person["relation"] == 7:
r = _(u"In love")
self.dialog.main_info.enable("relation")
self.dialog.main_info.relation.SetLabel(_(u"Relationship: ")+r)
# format last seen.
if person.has_key("last_seen") and person["last_seen"] != False:
original_date = arrow.get(person["last_seen"]["time"])
# Translators: This is the date of last seen
last_seen = _(u"{0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
self.dialog.main_info.enable("last_seen")
self.dialog.main_info.set("last_seen", last_seen)
self.person = person
# Adds photo to the dialog.
# ToDo: Need to ask if this has a visible effect in the dialog.
if person.has_key("photo_200_orig"):
img = requests.get(person["photo_200_orig"])
image = wx.Image(stream=cStringIO.StringIO(requests.get(person["photo_200_orig"]).content))
try:
self.dialog.image.SetBitmap(wx.Bitmap(image))
except ValueError:
return
self.dialog.panel.Layout()
def visit_website(self, *args, **kwargs):
""" Allows to visit an user's website. """
text = self.person["site"]
# Let's search for URLS with a regexp, as there are users with multiple websites in their profiles.
urls = utils.find_urls_in_text(text)
if len(urls) == 0:
output.speak(_(u"No URL addresses were detected."))
return
elif len(urls) == 1:
selected_url = urls[0]
else:
dialog = urlList.urlList()
dialog.populate_list(urls)
if dialog.get_response() != widgetUtils.OK:
return
selected_url = urls[dialog.get_item()]
output.speak(_(u"Opening URL..."))
webbrowser.open_new_tab(selected_url)

View File

@@ -2,22 +2,26 @@
import widgetUtils
from wxUI.dialogs import selector as gui
class audioAlbum(object):
class album(object):
def __init__(self, title, session):
super(audioAlbum, self).__init__()
def __init__(self, title, session, album_type="audio_albums"):
super(album, self).__init__()
self.item = None
self.session = session
if not hasattr(self.session, album_type):
return
self.albums = getattr(self.session, album_type)
self.dialog = gui.selectAlbum(title=title, albums=self.get_albums_as_string())
response = self.dialog.get_response()
if response == widgetUtils.OK:
self.item = self.search_item(self.dialog.get_string())
def get_albums_as_string(self):
return [i["title"] for i in self.session.audio_albums]
return [i["title"] for i in self.albums]
def search_item(self, item):
for i in self.session.audio_albums:
for i in self.albums:
if i["title"] == item:
return i["id"]
return None

View File

@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
from microsofttranslator import Translator
def translate(text="", source="auto", target="en"):
t = Translator("twblue", "4KZA26GYIfmVAqQA/z16Hlucbg64hVSDTIpRjT2FqIU=")
return t.translate(text, target)
from yandex_translate import YandexTranslate
def translate(text="", target="en"):
t = YandexTranslate("trnsl.1.1.20161012T134532Z.d01b9c75fc39aa74.7d1be75a5166a80583eeb020e10f584168da6bf7")
vars = dict(text=text, lang=target)
return t.translate(**vars)["text"][0]
supported_langs = None
d = None
languages = {
"af": _(u"Afrikaans"),
"sq": _(u"Albanian"),
@@ -71,7 +73,7 @@ languages = {
"ps": _(u"Pashto"),
"fa": _(u"Persian"),
"pl": _(u"Polish"),
"pt-PT": _(u"Portuguese"),
"pt": _(u"Portuguese"),
"pa": _(u"Punjabi"),
"ro": _(u"Romanian"),
"ru": _(u"Russian"),
@@ -101,8 +103,11 @@ languages = {
}
def available_languages():
l = languages.keys()
d = languages.values()
l.insert(0, '')
d.insert(0, _(u"autodetect"))
return sorted(zip(l, d))
global supported_langs, d
if supported_langs == None and d == None:
t = YandexTranslate("trnsl.1.1.20161012T134532Z.d01b9c75fc39aa74.7d1be75a5166a80583eeb020e10f584168da6bf7")
supported_langs = t.langs
d = []
for i in supported_langs:
d.append(languages[i])
return sorted(zip(supported_langs, d))

View File

@@ -18,28 +18,26 @@
############################################################
import translator
import wx
import widgetUtils
class translateDialog(widgetUtils.BaseDialog):
def __init__(self):
super(translateDialog, self).__init__(None, -1, title=_(u"Translate message"))
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
staticSource = wx.StaticText(panel, -1, _(u"&Source language"))
self.source_lang = wx.ComboBox(panel, -1, choices=[x[1] for x in translator.available_languages()], style = wx.CB_READONLY)
self.source_lang.SetFocus()
staticDest = wx.StaticText(panel, -1, _(u"&Target language"))
self.source_lang.SetSelection(0)
self.dest_lang = wx.ComboBox(panel, -1, choices=[x[1] for x in translator.available_languages()], style = wx.CB_READONLY)
listSizer = wx.BoxSizer(wx.HORIZONTAL)
listSizer.Add(staticSource)
listSizer.Add(self.source_lang)
listSizer.Add(staticDest)
listSizer.Add(self.dest_lang)
ok = wx.Button(panel, wx.ID_OK)
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL)
self.SetEscapeId(wx.ID_CANCEL)
class translateDialog(wx.Dialog):
def __init__(self):
super(translateDialog, self).__init__(None, -1, title=_(u"Translate message"))
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
staticDest = wx.StaticText(panel, -1, _(u"Target language"))
self.dest_lang = wx.ComboBox(panel, -1, choices=[x[1] for x in translator.available_languages()], style = wx.CB_READONLY)
self.dest_lang.SetFocus()
self.dest_lang.SetSelection(0)
listSizer = wx.BoxSizer(wx.HORIZONTAL)
listSizer.Add(staticDest)
listSizer.Add(self.dest_lang)
ok = wx.Button(panel, wx.ID_OK)
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL)
self.SetEscapeId(wx.ID_CANCEL)
def get(self, control):
return getattr(self, control).GetSelection()
def get(self, control):
return getattr(self, control).GetSelection()
def get_response(self):
return self.ShowModal()

View File

@@ -1,9 +1,13 @@
# -*- coding: utf-8 -*-
import sys
import fix_requests
import fix_win32com
from . import fix_requests
if hasattr(sys, "frozen"):
from . import fix_win32com
from . import fix_libloader
def setup():
fix_requests.fix()
if hasattr(sys, "frozen"):
fix_win32com.fix()
fix_libloader.fix()
fix_win32com.fix()

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*-
import win32com
import paths
win32com.__gen_path__=paths.com_path()
import sys
import os
sys.path.append(os.path.join(win32com.__gen_path__, "."))
from win32com.client import gencache
from pywintypes import com_error
from libloader import com
fixed=False
def patched_getmodule(modname):
mod=__import__(modname)
return sys.modules[modname]
def load_com(*names):
global fixed
if fixed==False:
gencache._GetModule=patched_getmodule
com.prepare_gencache()
fixed=True
result = None
for name in names:
try:
result = gencache.EnsureDispatch(name)
break
except com_error:
continue
if result is None:
raise com_error("Unable to load any of the provided com objects.")
return result
def fix():
com.load_com = load_com

View File

@@ -7,5 +7,5 @@ log = logging.getLogger("fixes.fix_requests")
def fix():
log.debug("Applying fix for requests...")
os.environ["REQUESTS_CA_BUNDLE"] = paths.app_path("cacert.pem")
log.debug("Changed CA path to %s" % (paths.app_path("cacert.pem"),))
os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(paths.app_path().decode(paths.fsencoding), "cacert.pem").encode(paths.fsencoding)
log.debug("Changed CA path to %s" % (os.environ["REQUESTS_CA_BUNDLE"].decode(paths.fsencoding)))

View File

@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
############################################################
# Copyright (c) 2018 Manuel Cortez <manuel@manuelcortez.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
############################################################
import wx
import platform
import requests
import widgetUtils
import application
import paths
from requests.auth import HTTPBasicAuth
from mysc.thread_utils import call_threaded
from . import wx_ui
class reportBug(object):
def __init__(self):
self.dialog = wx_ui.reportBugDialog()
widgetUtils.connect_event(self.dialog.ok, widgetUtils.BUTTON_PRESSED, self.send)
self.dialog.get_response()
def do_report(self, *args, **kwargs):
r = requests.post(*args, **kwargs)
if r.status_code > 300:
wx.CallAfter(self.dialog.error)
wx.CallAfter(self.dialog.progress.Destroy)
wx.CallAfter(self.dialog.success, r.json()["data"]["issue"]["id"])
def send(self, *args, **kwargs):
if self.dialog.get("summary") == "" or self.dialog.get("description") == "" or self.dialog.get("first_name") == "" or self.dialog.get("last_name") == "":
self.dialog.no_filled()
return
if self.dialog.get("agree") == False:
self.dialog.no_checkbox()
return
title = self.dialog.get("summary")
body = self.dialog.get("description")
issue_type = "issue" # for now just have issue
app_type = paths.mode
app_version = application.version
reporter_name = u"{first_name} {last_name}".format(first_name=self.dialog.get("first_name"), last_name=self.dialog.get("last_name"))
reporter_contact_type = "email" # For now just email is supported in the issue reporter
reporter_contact_handle = self.dialog.get("email")
operating_system = platform.platform()
json = dict(title=title, issue_type=issue_type, body=body, operating_system=operating_system, app_type=app_type, app_version=app_version, reporter_name=reporter_name, reporter_contact_handle=reporter_contact_handle, reporter_contact_type=reporter_contact_type)
auth=HTTPBasicAuth(application.bts_name, application.bts_access_token)
url = "{bts_url}/issue/new".format(bts_url=application.bts_url)
call_threaded(self.do_report, url, json=json, auth=auth)
self.dialog.show_progress()
self.dialog.EndModal(wx.ID_OK)

109
src/issueReporter/wx_ui.py Normal file
View File

@@ -0,0 +1,109 @@
# -*- coding: utf-8 -*-
############################################################
# Copyright (c) 2018 Manuel cortez <manuel@manuelcortez.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
############################################################
import wx
import widgetUtils
import application
class reportBugDialog(widgetUtils.BaseDialog):
def __init__(self):
super(reportBugDialog, self).__init__(parent=None, id=wx.NewId())
self.SetTitle(_(u"Report an error"))
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
summaryLabel = wx.StaticText(panel, -1, _(u"Briefly describe what happened. You will be able to thoroughly explain it later"), size=wx.DefaultSize)
self.summary = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.summary)
dc.SetFont(self.summary.GetFont())
self.summary.SetSize(dc.GetTextExtent("a"*80))
summaryB = wx.BoxSizer(wx.HORIZONTAL)
summaryB.Add(summaryLabel, 0, wx.ALL, 5)
summaryB.Add(self.summary, 0, wx.ALL, 5)
sizer.Add(summaryB, 0, wx.ALL, 5)
first_nameLabel = wx.StaticText(panel, -1, _(u"First Name"), size=wx.DefaultSize)
self.first_name = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.first_name)
dc.SetFont(self.first_name.GetFont())
self.first_name.SetSize(dc.GetTextExtent("a"*40))
first_nameB = wx.BoxSizer(wx.HORIZONTAL)
first_nameB.Add(first_nameLabel, 0, wx.ALL, 5)
first_nameB.Add(self.first_name, 0, wx.ALL, 5)
sizer.Add(first_nameB, 0, wx.ALL, 5)
last_nameLabel = wx.StaticText(panel, -1, _(u"Last Name"), size=wx.DefaultSize)
self.last_name = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.last_name)
dc.SetFont(self.last_name.GetFont())
self.last_name.SetSize(dc.GetTextExtent("a"*40))
last_nameB = wx.BoxSizer(wx.HORIZONTAL)
last_nameB.Add(last_nameLabel, 0, wx.ALL, 5)
last_nameB.Add(self.last_name, 0, wx.ALL, 5)
sizer.Add(last_nameB, 0, wx.ALL, 5)
emailLabel = wx.StaticText(panel, -1, _(u"Email address (Will not be public)"), size=wx.DefaultSize)
self.email = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.email)
dc.SetFont(self.email.GetFont())
self.email.SetSize(dc.GetTextExtent("a"*30))
emailB = wx.BoxSizer(wx.HORIZONTAL)
emailB.Add(emailLabel, 0, wx.ALL, 5)
emailB.Add(self.email, 0, wx.ALL, 5)
sizer.Add(emailB, 0, wx.ALL, 5)
descriptionLabel = wx.StaticText(panel, -1, _(u"Here, you can describe the bug in detail"), size=wx.DefaultSize)
self.description = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE)
dc = wx.WindowDC(self.description)
dc.SetFont(self.description.GetFont())
(x, y) = dc.GetMultiLineTextExtent("0"*2000)
self.description.SetSize((x, y))
descBox = wx.BoxSizer(wx.HORIZONTAL)
descBox.Add(descriptionLabel, 0, wx.ALL, 5)
descBox.Add(self.description, 0, wx.ALL, 5)
sizer.Add(descBox, 0, wx.ALL, 5)
self.agree = wx.CheckBox(panel, -1, _(u"I know that the {0} bug system will get my email address to contact me and fix the bug quickly").format(application.name,))
self.agree.SetValue(False)
sizer.Add(self.agree, 0, wx.ALL, 5)
self.ok = wx.Button(panel, wx.ID_OK, _(u"Send report"))
self.ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
btnBox = wx.BoxSizer(wx.HORIZONTAL)
btnBox.Add(self.ok, 0, wx.ALL, 5)
btnBox.Add(cancel, 0, wx.ALL, 5)
sizer.Add(btnBox, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def no_filled(self):
wx.MessageDialog(self, _(u"You must fill out the following fields: first name, last name, email address and issue information."), _(u"Error"), wx.OK|wx.ICON_ERROR).ShowModal()
def no_checkbox(self):
wx.MessageDialog(self, _(u"You need to mark the checkbox to provide us your email address to contact you if it is necessary."), _(u"Error"), wx.ICON_ERROR).ShowModal()
def success(self, id):
wx.MessageDialog(self, _(u"Thanks for reporting this bug! In future versions, you may be able to find it in the changes list. You have received an email with more information regarding your report. You've reported the bug number %i") % (id), _(u"reported"), wx.OK).ShowModal()
self.Destroy()
def error(self):
wx.MessageDialog(self, _(u"Something unexpected occurred while trying to report the bug. Please, try again later"), _(u"Error while reporting"), wx.ICON_ERROR|wx.OK).ShowModal()
self.Destroy()
def show_progress(self):
self.progress = wx.ProgressDialog(title=_(u"Sending report..."), message=_(u"Please wait while your report is being send."), maximum=100, parent=self)
self.progress.ShowModal()

View File

@@ -1,7 +0,0 @@
from .libloader import *
__version__ = 0.1
__author__ = 'Christopher Toth <q@q-continuum.net>'
__doc__ = """
Quickly and easily load shared libraries from various platforms. Also includes a libloader.com module for loading com modules on Windows.
"""

View File

@@ -1,40 +0,0 @@
from pywintypes import com_error
import win32com
import paths
win32com.__gen_path__=paths.com_path()
import sys
import os
sys.path.append(os.path.join(win32com.__gen_path__, "."))
from win32com.client import gencache
fixed=False
def prepare_gencache():
gencache.is_readonly = False
gencache.GetGeneratePath()
def patched_getmodule(modname):
mod=__import__(modname)
return sys.modules[modname]
def load_com(*names):
global fixed
if fixed==False:
gencache._GetModule=patched_getmodule
fixed=True
result = None
for name in names:
try:
result = gencache.EnsureDispatch(name)
break
except com_error:
continue
if result is None:
raise com_error("Unable to load any of the provided com objects.")
return result
def preexec():
global fixed
if fixed==False:
gencache._GetModule=patched_getmodule
fixed=True

View File

@@ -1,56 +0,0 @@
import ctypes
import collections
import platform
import os
TYPES = {
'Linux': {
'loader': ctypes.CDLL,
'functype': ctypes.CFUNCTYPE,
'prefix': 'lib',
'extension': '.so'
},
'Darwin': {
'loader': ctypes.CDLL,
'functype': ctypes.CFUNCTYPE,
'prefix': 'lib',
'extension': '.dylib'
},
}
if platform.system() == 'Windows':
TYPES['Windows'] = {
'loader': ctypes.WinDLL,
'functype': ctypes.WINFUNCTYPE,
'prefix': "",
'extension': '.dll'
}
class LibraryLoadError(OSError): pass
def load_library(library, x86_path='.', x64_path='.', *args, **kwargs):
lib = find_library_path(library, x86_path=x86_path, x64_path=x64_path)
loaded = _do_load(lib, *args, **kwargs)
if loaded is not None:
return loaded
raise LibraryLoadError('unable to load %r. Provided library path: %r' % (library, lib))
def _do_load(file, *args, **kwargs):
loader = TYPES[platform.system()]['loader']
return loader(file, *args, **kwargs)
def find_library_path(libname, x86_path='.', x64_path='.'):
libname = '%s%s' % (TYPES[platform.system()]['prefix'], libname)
if platform.architecture()[0] == '64bit':
path = os.path.join(x64_path, libname)
else:
path = os.path.join(x86_path, libname)
ext = get_library_extension()
path = '%s%s' % (path, ext)
return os.path.abspath(path)
def get_functype():
return TYPES[platform.system()]['functype']
def get_library_extension():
return TYPES[platform.system()]['extension']

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import logging
from logging.handlers import RotatingFileHandler
import paths
@@ -19,12 +21,12 @@ logger.setLevel(logging.DEBUG)
#handlers
app_handler = RotatingFileHandler(paths.logs_path(APP_LOG_FILE), mode="w")
app_handler = RotatingFileHandler(os.path.join(paths.logs_path(), APP_LOG_FILE), mode="w")
app_handler.setFormatter(formatter)
app_handler.setLevel(logging.DEBUG)
logger.addHandler(app_handler)
error_handler = logging.FileHandler(paths.logs_path(ERROR_LOG_FILE), mode="w")
error_handler = logging.FileHandler(os.path.join(paths.logs_path(), ERROR_LOG_FILE), mode="w")
error_handler.setFormatter(formatter)
error_handler.setLevel(logging.ERROR)
logger.addHandler(error_handler)

View File

@@ -21,7 +21,7 @@ def setup():
log.debug("Starting Socializer %s" % (application.version,))
config.setup()
log.debug("Using %s %s" % (platform.system(), platform.architecture()[0]))
log.debug("Application path is %s" % (paths.app_path(),))
log.debug("Application path is %s" % (paths.app_path().decode(paths.fsencoding),))
log.debug("config path is %s" % (paths.config_path(),))
output.setup()
languageHandler.setLanguage(config.app["app-settings"]["language"])
@@ -37,4 +37,4 @@ def setup():
call_threaded(r.login)
app.run()
setup()
setup()

View File

@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sys
import platform
import os
import sys
@@ -9,47 +11,38 @@ from functools import wraps
mode = "portable"
directory = None
fsencoding = sys.getfilesystemencoding()
#log = logging.getLogger("paths")
def merge_paths(func):
@wraps(func)
def merge_paths_wrapper(*a):
return unicode(os.path.join(func(), *a))
return merge_paths_wrapper
@merge_paths
def app_path():
return paths_.app_path()
@merge_paths
def config_path():
global mode, directory
if mode == "portable":
if directory != None: path = os.path.join(directory, "config")
elif directory == None: path = app_path(u"config")
if directory != None: path = os.path.join(directory.decode(fsencoding), "config")
elif directory == None: path = os.path.join(app_path().decode(fsencoding), "config")
elif mode == "installed":
path = data_path("config")
path = os.path.join(data_path().decode(fsencoding), "config")
if not os.path.exists(path):
# log.debug("%s path does not exist, creating..." % (path,))
os.mkdir(path)
return path
@merge_paths
def logs_path():
global mode, directory
if mode == "portable":
if directory != None: path = os.path.join(directory, "logs")
elif directory == None: path = app_path(u"logs")
if directory != None: path = os.path.join(directory.decode(fsencoding), "logs")
elif directory == None: path = os.path.join(app_path().decode(fsencoding), "logs")
elif mode == "installed":
path = data_path("logs")
path = os.path.join(data_path().decode(fsencoding), "logs")
if not os.path.exists(path):
# log.debug("%s path does not exist, creating..." % (path,))
os.mkdir(path)
return path
@merge_paths
def data_path(app_name='TW blue'):
def data_path(app_name='socializer'):
if platform.system() == "Windows":
data_path = os.path.join(os.getenv("AppData"), app_name)
else:
@@ -58,22 +51,19 @@ def data_path(app_name='TW blue'):
os.mkdir(data_path)
return data_path
@merge_paths
def locale_path():
return app_path(u"locales")
return os.path.join(app_path().decode(fsencoding), "locales")
@merge_paths
def sound_path():
return app_path(u"sounds")
return os.path.join(app_path().decode(fsencoding), "sounds")
@merge_paths
def com_path():
global mode, directory
if mode == "portable":
if directory != None: path = os.path.join(directory, "com_cache")
elif directory == None: path = app_path(u"com_cache")
if directory != None: path = os.path.join(directory.decode(fsencoding), "com_cache")
elif directory == None: path = os.path.join(app_path().decode(fsencoding), "com_cache")
elif mode == "installed":
path = data_path(u"com_cache")
path = os.path.join(data_path().decode(fsencoding), "com_cache")
if not os.path.exists(path):
# log.debug("%s path does not exist, creating..." % (path,))
os.mkdir(path)

View File

@@ -1,41 +0,0 @@
import _winreg
import os
import sys
from platform_utils import paths
RUN_REGKEY = ur"SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
def is_installed(app_subkey):
"""Checks if the currently running copy is installed or portable variant. Requires the name of the application subkey found under the uninstall section in Windows registry."""
try:
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\%s" % app_subkey)
inst_dir = _winreg.QueryValueEx(key,"InstallLocation")[0]
except WindowsError:
return False
_winreg.CloseKey(key)
try:
return os.stat(inst_dir) == os.stat(paths.app_path())
except WindowsError:
return False
def getAutoStart(app_name):
"""Queries if the automatic startup should be set for the application or not, depending on it's current state."""
try:
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, RUN_REGKEY)
val = _winreg.QueryValueEx(key, unicode(app_name))[0]
return os.stat(val) == os.stat(sys.argv[0])
except (WindowsError, OSError):
return False
def setAutoStart(app_name, enable=True):
"""Configures automatic startup for the application, if the enable argument is set to True. If set to False, deletes the application AutoStart value."""
if getAutoStart(app_name) == enable:
return
key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, RUN_REGKEY, 0, _winreg.KEY_WRITE)
if enable:
_winreg.SetValueEx(key, unicode(app_name), None, _winreg.REG_SZ, sys.argv[0])
else:
_winreg.DeleteValue(key, unicode(app_name))

View File

@@ -1,16 +0,0 @@
# Replacement for py2exe distributed module
# Avoids the use of the standard py2exe console.
# Just import this file and it should go away
import sys
if hasattr(sys,"frozen"): # true only if we are running as a py2exe app
class Blackhole(object):
def write(self,text):
pass
def flush(self):
pass
sys.stdout = Blackhole()
sys.stderr = Blackhole()
del Blackhole
del sys

View File

@@ -1,51 +0,0 @@
import ctypes
import collections
import platform
import os
TYPES = {
'Linux': {
'loader': ctypes.CDLL,
'functype': ctypes.CFUNCTYPE,
'prefix': 'lib',
'extension': '.so'
},
'Darwin': {
'loader': ctypes.CDLL,
'functype': ctypes.CFUNCTYPE,
'prefix': 'lib',
'extension': '.dylib'
},
}
if platform.system() == 'Windows':
TYPES['Windows'] = {
'loader': ctypes.WinDLL,
'functype': ctypes.WINFUNCTYPE,
'prefix': "",
'extension': '.dll'
}
class LibraryLoadError(Exception): pass
def load_library(library, x86_path='.', x64_path='.', *args, **kwargs):
lib = find_library_path(library, x86_path=x86_path, x64_path=x64_path)
loaded = _do_load(lib, *args, **kwargs)
if loaded is not None:
return loaded
raise LibraryLoadError('unable to load %r. Provided library path: %r' % (library, path))
def _do_load(file, *args, **kwargs):
loader = TYPES[platform.system()]['loader']
return loader(file, *args, **kwargs)
def find_library_path(libname, x86_path='.', x64_path='.'):
libname = '%s%s' % (TYPES[platform.system()]['prefix'], libname)
if platform.machine() == 'x86_64':
path = os.path.join(x64_path, libname)
else:
path = os.path.join(x86_path, libname)
ext = TYPES[platform.system()]['extension']
return '%s%s' % (path, ext)
def get_functype():
return TYPES[platform.system()]['functype']

View File

@@ -1,114 +0,0 @@
import inspect
import platform
import os
import subprocess
import sys
import string
import unicodedata
def app_data_path(app_name=None):
"""Cross-platform method for determining where to put application data."""
"""Requires the name of the application"""
plat = platform.system()
if plat == 'Windows':
import winpaths
path = winpaths.get_appdata()
elif plat == 'Darwin':
path = os.path.join(os.path.expanduser('~'), 'Library', 'Application Support')
elif plat == 'Linux':
path = os.path.expanduser('~')
app_name = '.%s' % app_name.replace(' ', '_')
return os.path.join(path, app_name)
def prepare_app_data_path(app_name):
"""Creates the application's data directory, given its name."""
dir = app_data_path(app_name)
return ensure_path(dir)
def embedded_data_path():
if platform.system() == 'Darwin' and is_frozen():
return os.path.abspath(os.path.join(executable_directory(), '..', 'Resources'))
return app_path()
def is_frozen():
"""Return a bool indicating if application is compressed"""
import imp
return hasattr(sys, 'frozen') or imp.is_frozen("__main__")
def get_executable():
"""Returns the full executable path/name if frozen, or the full path/name of the main module if not."""
if is_frozen():
if platform.system() != 'Darwin':
return sys.executable
#On darwin, sys.executable points to python. We want the full path to the exe we ran.
exedir = os.path.abspath(os.path.dirname(sys.executable))
items = os.listdir(exedir)
items.remove('python')
return os.path.join(exedir, items[0])
#Not frozen
try:
import __main__
return os.path.abspath(__main__.__file__)
except AttributeError:
return sys.argv[0]
def get_module(level=2):
"""Hacky method for deriving the caller of this function's module."""
return inspect.getmodule(inspect.stack()[level][0]).__file__
def executable_directory():
"""Always determine the directory of the executable, even when run with py2exe or otherwise frozen"""
executable = get_executable()
path = os.path.abspath(os.path.dirname(executable))
return path
def app_path():
"""Return the root of the application's directory"""
path = executable_directory()
if is_frozen() and platform.system() == 'Darwin':
path = os.path.abspath(os.path.join(path, '..', '..'))
return path
def module_path(level=2):
return os.path.abspath(os.path.dirname(get_module(level)))
def documents_path():
"""On windows, returns the path to My Documents. On OSX, returns the user's Documents folder. For anything else, returns the user's home directory."""
plat = platform.system()
if plat == 'Windows':
import winpaths
path = winpaths.get_my_documents()
elif plat == 'Darwin':
path = os.path.join(os.path.expanduser('~'), 'Documents')
else:
path = os.path.expanduser('~')
return path
def safe_filename(filename):
"""Given a filename, returns a safe version with no characters that would not work on different platforms."""
SAFE_FILE_CHARS = "'-_.()[]{}!@#$%^&+=`~ "
filename = unicode(filename)
new_filename = ''.join(c for c in filename if c in SAFE_FILE_CHARS or c.isalnum())
#Windows doesn't like directory names ending in space, macs consider filenames beginning with a dot as hidden, and windows removes dots at the ends of filenames.
return new_filename.strip(' .')
def ensure_path(path):
if not os.path.exists(path):
os.makedirs(path)
return path
def start_file(path):
if platform.system() == 'Windows':
os.startfile(path)
else:
subprocess.Popen(['open', path])
def get_applications_path():
"""Return the directory where applications are commonly installed on the system."""
plat = platform.system()
if plat == 'Windows':
import winpaths
return winpaths.get_program_files()
elif plat == 'Darwin':
return '/Applications'

View File

@@ -1,27 +0,0 @@
import platform
import ctypes
import os
import signal
def kill_windows_process(pid):
PROCESS_TERMINATE = 1
SYNCHRONIZE=1048576
handle = ctypes.windll.kernel32.OpenProcess(PROCESS_TERMINATE | SYNCHRONIZE, False, pid)
ctypes.windll.kernel32.TerminateProcess(handle, -1)
ctypes.windll.kernel32.WaitForSingleObject(handle, 1000)
ctypes.windll.kernel32.CloseHandle(handle)
def kill_unix_process(pid):
try:
os.kill(pid, signal.SIGKILL)
except OSError:
pass
def kill_process(pid):
if pid < 0:
return
if platform.system() == 'Windows':
kill_windows_process(pid)
else:
kill_unix_process(pid)

View File

@@ -1,10 +0,0 @@
import _winreg
SHELL_REGKEY = ur"Directory\shell"
def context_menu_integrate(item_key_name, item_display_text, item_command):
app_menu_key = _winreg.OpenKey(_winreg.HKEY_CLASSES_ROOT, SHELL_REGKEY, 0, _winreg.KEY_WRITE)
menu_item_key = _winreg.CreateKey(app_menu_key, item_key_name)
_winreg.SetValueEx(menu_item_key, None, None, _winreg.REG_SZ, item_display_text)
item_command_key = _winreg.CreateKey(menu_item_key, 'command')
_winreg.SetValueEx(item_command_key, None, None, _winreg.REG_SZ, item_command)

View File

@@ -1,9 +0,0 @@
import platform
import webbrowser
def open(url):
if platform.system() == 'Windows':
browser = webbrowser.get('windows-default')
else:
browser = webbrowser
browser.open_new_tab(url)

View File

@@ -2,16 +2,28 @@
user = string(default="")
password = string(default="")
token = string(default="")
use_alternative_tokens = boolean(default=False)
[general]
reverse_timelines = boolean(default=False)
load_images = boolean(default=True)
update_channel = string(default="stable")
[buffers]
count_for_audio_buffers = integer(default=100)
count_for_wall_buffers = integer(default=100)
count_for_video_buffers = integer(default=200)
count_for_audio_buffers = integer(default=1000)
[sound]
volume = float(default=1.0)
input_device = string(default="Default")
output_device = string(default="Default")
session_mute = boolean(default=False)
current_soundpack = string(default="default")
current_soundpack = string(default="default")
[chat]
notify_online = boolean(default=True)
notify_offline = boolean(default=True)
open_unread_conversations = boolean(default=True)
automove_to_conversations = boolean(default=True)
notifications = string(default="custom")

View File

@@ -0,0 +1,16 @@
import os
import ssl
import utils
try:
context = ssl.create_default_context()
der_certs = context.get_ca_certs(binary_form=True)
pem_certs = [ssl.DER_cert_to_PEM_cert(der) for der in der_certs]
path = os.path.join(utils.getBundleDir(), 'nativecacerts.pem')
with open(path, 'w') as outfile:
for pem in pem_certs:
outfile.write(pem + '\n')
os.environ['REQUESTS_CA_BUNDLE'] = path
except:
pass

101
src/sessionmanager/core.py Normal file
View File

@@ -0,0 +1,101 @@
import _sslfixer
import webbrowser
import random
import requests
import string
from wxUI import two_factor_auth
class AuthenticationError(Exception):
pass
class ValidationError(Exception):
pass
class C2DMError(Exception):
pass
client_id = '2685278'
client_secret = 'lxhD8OD7dMsqtXIm5IUY'
api_ver='5.92'
scope = 'all'
user_agent = 'KateMobileAndroid/47-427 (Android 6.0.1; SDK 23; armeabi-v7a; samsung SM-G900F; ru)'
android_id = '4119748609680577006'
android_token = '5228540069896927210'
api_url = 'https://api.vk.com/method/'
def requestAuth(login, password, scope=scope):
if not (login or password):
raise ValueError
url = 'https://oauth.vk.com/token?grant_type=password&2fa_supported=1&force_sms=1&client_id='+client_id+'&client_secret='+client_secret+'&username='+login+'&password='+password+'&v='+api_ver+'&scope='+scope
headers = {
'User-Agent': user_agent
}
r = requests.get(url, headers=headers)
# 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)
if r.status_code == 401 and "phone_mask" in r.text:
t = r.json()
code, remember = two_factor_auth()
url = 'https://oauth.vk.com/token?grant_type=password&client_id='+client_id+'&client_secret='+client_secret+'&username='+login+'&password='+password+'&v='+api_ver+'&scope='+scope+'&code='+code
r = requests.get(url, headers=headers)
if r.status_code == 200 and 'access_token' in r.text:
res = r.json()
access_token = res['access_token']
user_id = str(res['user_id'])
return access_token, user_id
else:
raise AuthenticationError(r.text)
def getReceipt(user_id):
if not user_id:
raise ValueError
url = 'https://android.clients.google.com/c2dm/register3'
headers = {
'Authorization': 'AidLogin {0}:{1}'.format(android_id, android_token),
'app': 'com.perm.kate',
'Gcm-ver': '11951438',
'Gcm-cert': 'ca7036ce4c5abe56b9f4439ea275171ceb0d35a4',
#'User-Agent': 'Android-GCM/1.5 (klte NJH47F)',
'content-type': 'application/x-www-form-urlencoded',
}
data = {
'X-subtype': '54740537194',
'X-X-subscription': '54740537194',
'X-X-subtype': '54740537194',
'X-app_ver': '427',
'X-kid': '|ID|1|',
#'X-osv': '23',
'X-cliv': 'iid-9452000',
'X-gmsv': '11951438',
'X-X-kid': '|ID|1|',
'X-appid': ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(11)),
'X-scope': 'id'+user_id,
'X-subscription': '54740537194',
'X-app_ver_name': '47',
'app': 'com.perm.kate',
'sender': '54740537194',
'device': android_id,
'cert': 'ca7036ce4c5abe56b9f4439ea275171ceb0d35a4',
'app_ver': '427',
'gcm_ver': '11951438'
}
r = requests.post(url, headers=headers, data=data)
if r.status_code == 200 and 'token' in r.text:
return r.text[13:]
else:
raise C2DMError(r.text)
def validateToken(token, receipt):
if not (token or receipt):
raise ValueError
url = api_url+'auth.refreshToken?access_token='+token+'&receipt='+receipt+'&v='+api_ver
headers = {'User-Agent': user_agent}
r = requests.get(url, headers=headers)
if r.status_code == 200 and 'token' in r.text:
res = r.json()
received_token = res['response']['token']
if token == received_token or received_token is None :
raise ValidationError(r.text)
else:
return received_token
else:
raise ValidationError(r.text)

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
""" Modified Jconfig base class """
import logging
import json
from codecs import open
from jconfig import jconfig
log = logging.getLogger('jconfig_patched')
class Config(jconfig.Config):
log.info("Instantiated patched jconfig instance")
def load(self, filename, **kwargs):
try:
with open(filename, 'r', encoding="utf-8") as f:
settings = json.load(f)
except (IOError, ValueError):
settings = {}
settings.setdefault(self.section_name, {})
return settings
def save(self):
with open(self._filename, 'w', encoding="utf-8") as f:
json.dump(self._settings, f, indent=2, sort_keys=True)

View File

@@ -0,0 +1,194 @@
# -*- coding: utf-8 -*-
""" this module contains everything used to render different kind of posts (posts in the home buffer,
Chat messages, audios, videos, photos, comments in posts, etc)"""
import arrow
import languageHandler
import logging
import utils
log = logging.getLogger(__file__)
### Some util funtions
def extract_attachment(attachment):
""" Adds information about attachment files in posts. It only adds the text, I mean, no attachment file is added here.
This will produce a result like:
'website: http://url.com'.
'photo: A forest'."""
msg = u""
if attachment["type"] == "link":
msg = u"{0}: {1}".format(attachment["link"]["title"], attachment["link"]["url"])
elif attachment["type"] == "photo":
msg = attachment["photo"]["text"]
if msg == "":
return _(u"photo with no description available")
elif attachment["type"] == "video":
msg = _(u"video: {0}").format(attachment["video"]["title"],)
return msg
def short_text(status):
""" This shorts the text to 140 characters for displaying it in the list control of buffers."""
message = ""
# copy_story indicates that the post is a shared repost.
if status.has_key("copy_history"):
txt = status["copy_history"][0]["text"]
else:
txt = status["text"]
if len(txt) < 140:
message = utils.clean_text(txt)
else:
message = utils.clean_text(txt[:139])
return message
def clean_audio(audio):
""" Remove unavailable songs due to different reasons. This is used to clean the audio list when people adds audios and need to be displayed in the buffer."""
for i in audio["items"][:]:
if type(i) == bool:
audio["items"].remove(i)
audio["count"] = audio["count"] -1
return audio
### Render functions
def render_person(status, session):
""" Render users in people buffers such as everything related to friendships or buffers created with only people.
Example result: ["John Doe", "An hour ago"]
Reference: https://vk.com/dev/fields"""
if status.has_key("last_seen"):
original_date = arrow.get(status["last_seen"]["time"])
# Translators: This is the date of last seen
last_seen = _(u"{0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
# Account suspended or deleted.
elif status.has_key("last_seen") == False and status.has_key("deactivated"):
last_seen = _(u"Account deactivated")
return [u"{0} {1}".format(status["first_name"], status["last_name"]), last_seen]
def render_newsfeed_item(status, session):
""" This me☻thod is used to render an item of the news feed.
References:
https://vk.com/dev/newsfeed.get
https://vk.com/dev/post_source
https://vk.com/dev/post
"""
user = session.get_user_name(status["source_id"], case_name="nom")
# See if this is a post or repost.
if status.has_key("copy_history"):
user = _(u"{0} has shared the {1}'s post").format(user, session.get_user_name(status["copy_history"][0]["owner_id"]))
message = ""
original_date = arrow.get(status["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
# handle status updates.
if status["type"] == "post":
message += short_text(status)
if status.has_key("attachment") and len(status["attachment"]) > 0:
message += extract_attachment(status["attachment"])
# If there is no message after adding text, it's because a pphoto with no description has been found.
# so let's manually add the "no description" tag here.
if message == "":
message = "no description available"
# Handle audio rendering.
elif status["type"] == "audio" and "audio" in status:
# removes deleted audios.
status["audio"] = clean_audio(status["audio"])
if status["audio"]["count"] == 1:
message = _(u"{0} has added an audio: {1}").format(user, u", ".join(render_audio(status["audio"]["items"][0], session)),)
else:
prem = ""
for i in xrange(0, status["audio"]["count"]):
composed_audio = render_audio(status["audio"]["items"][i], session)
prem += u"{0} - {1}, ".format(composed_audio[0], composed_audio[1])
message = _(u"{0} has added {1} audios: {2}").format(user, status["audio"]["count"], prem)
# Handle audio playlists
elif status["type"] == "audio_playlist":
if status["audio_playlist"]["count"] == 1:
message = _(u"{0} has added an audio album: {1}, {2}").format(user, status["audio_playlist"]["items"][0]["title"], status["audio_playlist"]["items"][0]["description"])
else:
prestring = ""
for i in xrange(0, status["audio_playlist"]["count"]):
prestring += u"{0} - {1}, ".format(status["audio_playlist"]["items"][i]["title"], status["audio_playlist"]["items"][i]["description"])
message = _(u"{0} has added {1} audio albums: {2}").format(user, status["audio_playlist"]["count"], prestring)
# handle new friends for people in the news buffer.
elif status["type"] == "friend":
msg_users = u""
if status.has_key("friends"):
for i in status["friends"]["items"]:
msg_users = msg_users + u"{0}, ".format(session.get_user_name(i["user_id"], "nom"))
else:
print status.keys()
message = _(u"{0} added friends: {1}").format(user, msg_users)
elif status["type"] == "video":
if status["video"]["count"] == 1:
message = _(u"{0} has added a video: {1}").format(user, u", ".join(render_video(status["video"]["items"][0], session)),)
else:
prem = ""
for i in xrange(0, status["video"]["count"]):
composed_video = render_video(status["video"]["items"][i], session)
prem += u"{0} - {1}, ".format(composed_video[0], composed_video[1])
message = _(u"{0} has added {1} videos: {2}").format(user, status["video"]["count"], prem)
else:
if status["type"] != "post": print status
return [user, message, created_at]
def render_message(message, session):
""" Render a message posted in a private conversation.
Reference: https://vk.com/dev/message"""
user = session.get_user_name(message["from_id"], "nom")
original_date = arrow.get(message["date"])
now = arrow.now()
original_date = original_date.to(now.tzinfo)
# Format the date here differently depending in if this is the same day for both dates or not.
if original_date.day == now.day:
created_at = original_date.format(_(u"H:mm."), locale=languageHandler.curLang[:2])
else:
created_at = original_date.format(_(u"H:mm. dddd, MMMM D, YYYY"), locale=languageHandler.curLang[:2])
# No idea why some messages send "text" instead "body"
if message.has_key("body"):
body = message["body"]
else:
body = message["text"]
return [u"{2}, {0} {1}".format(body, created_at, user)]
def render_status(status, session):
""" Render a wall post (shown in user's wall, not in newsfeed).
Reference: https://vk.com/dev/post"""
user = session.get_user_name(status["from_id"], "nom")
if status.has_key("copy_history"):
user = _(u"{0} has shared the {1}'s post").format(user, session.get_user_name(status["copy_history"][0]["owner_id"]))
message = ""
original_date = arrow.get(status["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
if status.has_key("copy_owner_id"):
user = _(u"{0} has shared the {1}'s post").format(user, session.get_user_name(status["copy_owner_id"]))
if status["post_type"] == "post" or status["post_type"] == "copy":
message += short_text(status)
if status.has_key("attachment") and len(status["attachment"]) > 0:
message += extract_attachment(status["attachment"])
if message == "":
message = "no description available"
return [user, message, created_at]
def render_audio(audio, session=None):
""" Render audio files added to VK.
Example result:
["Song title", "Artist", "03:15"]
reference: https://vk.com/dev/audio_object"""
if audio == False: return [_(u"Audio removed from library"), "", ""]
return [audio["title"], audio["artist"], utils.seconds_to_string(audio["duration"])]
def render_video(video, session=None):
""" Render a video file from VK.
Example result:
["Video title", "Video description", "01:30:28"]
Reference: https://vk.com/dev/video_object"""
if video == False:
return [_(u"Video not available"), "", ""]
return [video["title"], video["description"], utils.seconds_to_string(video["duration"])]
def render_audio_message(audio_message, session=None):
""" Render a voice message from VK
Example result:
["Voice message", "01:30:28"]"""
if audio_message == False:
return [_(u"Voice message not available"), "", ""]
return [utils.seconds_to_string(audio_message["duration"])]

View File

@@ -1,27 +1,33 @@
# -*- coding: utf-8 -*-
import time
import arrow
""" Session object for Socializer. A session is the only object to call VK API methods, save settings and access to the cache database and sound playback mechanisms. """
import os
import logging
import languageHandler
import paths
import vkSessionHandler
import logging
import utils
import sound
from config_utils import Configuration, ConfigurationResetException
from pubsub import pub
from vk_api.exceptions import LoginRequired, VkApiError
log = logging.getLogger("session")
sessions = {}
# Saves possible set of identifier keys for VK'S data types
# Save possible set of identifier keys for VK'S data types
# see https://vk.com/dev/datatypes for more information.
# I've added the Date identifier (this is a field in unix time format), for special objects (like friendship indicators) because these objects doesn't have an own identifier.
# I've added the Date identifier (this is a field in unix time format), for special objects (like friendship indicators) because these objects don't have an own identifier.
identifiers = ["aid", "gid", "uid", "pid", "id", "post_id", "nid", "date"]
# Different VK post types, present in the newsfeed buffer. This is useful for filtering by post and remove deleted posts.
post_types = dict(audio="audio", friend="friends", video="video", post="post_type", audio_playlist="audio_playlist")
def find_item(list, item):
""" Finds an item in a list by taking an identifier"""
# determines the kind of identifier that we are using
""" Find an item in a list by taking an identifier.
@list list: A list of dict objects.
@ item dict: A dictionary containing at least an identifier.
"""
# determine the kind of identifier that we are using
global identifiers
identifier = None
for i in identifiers:
@@ -36,132 +42,15 @@ def find_item(list, item):
return True
return False
def add_attachment(attachment):
""" Adds information about attachment files in posts. It only adds the text, I mean, no attachment file is added here.
This will produce a result like 'Title of a web page: http://url.xxx', etc."""
msg = u""
if attachment["type"] == "link":
msg = u"{0}: {1}".format(attachment["link"]["title"], attachment["link"]["url"])
elif attachment["type"] == "photo":
msg = attachment["photo"]["text"]
if msg == "":
return "photo with no description available"
elif attachment["type"] == "video":
msg = u"video: {0}".format(attachment["video"]["title"],)
return msg
def add_text(status):
""" This shorts the text to 140 characters for displaying it in the list control."""
message = ""
if status.has_key("copy_history"):
txt = status["copy_history"][0]["text"]
else:
txt = status["text"]
if len(txt) < 140:
message = utils.clean_text(txt)
else:
message = utils.clean_text(txt[:139])
return message
def compose_person(status, session):
if status.has_key("last_seen"):
original_date = arrow.get(status["last_seen"]["time"])
# Translators: This is the date of last seen
last_seen = _(u"{0}").format(original_date.humanize(locale=languageHandler.getLanguage()),)
elif status.has_key("last_seen") == False and status.has_key("deactivated"):
last_seen = _(u"Account deactivated")
return [u"{0} {1}".format(status["first_name"], status["last_name"]), last_seen]
def compose_new(status, session):
""" This method is used to compose an item of the news feed."""
user = session.get_user_name(status["source_id"], case_name="nom")
if status.has_key("copy_history"):
user = _(u"{0} has shared the {1}'s post").format(user, session.get_user_name(status["copy_history"][0]["owner_id"]))
message = ""
original_date = arrow.get(status["date"])
created_at = original_date.humanize(locale=languageHandler.getLanguage())
if status["type"] == "post":
message += add_text(status)
if status.has_key("attachment") and len(status["attachment"]) > 0:
message += add_attachment(status["attachment"])
if message == "":
message = "no description available"
elif status["type"] == "audio":
# removes deleted audios.
status["audio"] = clean_audio(status["audio"])
if status["audio"]["count"] == 1:
message = _(u"{0} has added an audio: {1}").format(user, u", ".join(compose_audio(status["audio"]["items"][0], session)),)
else:
prem = ""
for i in xrange(0, status["audio"]["count"]):
composed_audio = compose_audio(status["audio"]["items"][i], session)
prem += u"{0} - {1}, ".format(composed_audio[0], composed_audio[1])
message = _(u"{0} has added {1} audios: {2}").format(user, status["audio"]["count"], prem)
elif status["type"] == "friend":
msg_users = u""
for i in status["friends"]["items"]:
msg_users = msg_users + u"{0}, ".format(session.get_user_name(i["user_id"], "nom"))
message = _(u"{0} hadded friends: {1}").format(user, msg_users)
elif status["type"] == "video":
if status["video"]["count"] == 1:
message = _(u"{0} has added a video: {1}").format(user, u", ".join(compose_video(status["video"]["items"][0], session)),)
else:
prem = ""
for i in xrange(0, status["video"]["count"]):
composed_video = compose_video(status["video"]["items"][i], session)
prem += u"{0} - {1}, ".format(composed_video[0], composed_video[1])
message = _(u"{0} has added {1} videos: {2}").format(user, status["video"]["count"], prem)
else:
if status["type"] != "post": print status
return [user, message, created_at]
def clean_audio(audio):
for i in audio["items"][:]:
if type(i) == bool:
audio["items"].remove(i)
audio["count"] = audio["count"] -1
return audio
def compose_message(message, session):
user = session.get_user_name(message["from_id"], "nom")
original_date = arrow.get(message["date"])
created_at = original_date.format(_(u"dddd, MMMM D, YYYY H:m:s"), locale=languageHandler.getLanguage())
body = message["body"]
return [u"{2}, {0} {1}".format(body, created_at, user)]
def compose_status(status, session):
user = session.get_user_name(status["from_id"], "nom")
if status.has_key("copy_history"):
user = _(u"{0} has shared the {1}'s post").format(user, session.get_user_name(status["copy_history"][0]["owner_id"]))
message = ""
original_date = arrow.get(status["date"])
created_at = original_date.humanize(locale=languageHandler.getLanguage())
if status.has_key("copy_owner_id"):
user = _(u"{0} has shared the {1}'s post").format(user, session.get_user_name(status["copy_owner_id"]))
if status["post_type"] == "post" or status["post_type"] == "copy":
message += add_text(status)
if status.has_key("attachment") and len(status["attachment"]) > 0:
message += add_attachment(status["attachment"])
if message == "":
message = "no description available"
return [user, message, created_at]
def compose_audio(audio, session=None):
if audio == False: return [_(u"Audio removed from library"), "", ""]
return [audio["title"], audio["artist"], utils.seconds_to_string(audio["duration"])]
def compose_video(video, session=None):
if video == False: return [_(u"Audio removed from library"), "", ""]
return [video["title"], utils.seconds_to_string(video["duration"])]
class vkSession(object):
""" The only session available in socializer. Manages everything related to a model in an MVC app: calls to VK, sound handling, settings and a cache database."""
def order_buffer(self, name, data, show_nextpage):
""" Put new items on the local database. Useful for cursored buffers
name str: The name for the buffer stored in the dictionary.
data list: A list with items and some information about cursors.
""" Put new items on the local cache database.
@name str: The name for the buffer stored in the dictionary.
@data list: A list with items and some information about cursors.
returns the number of items that has been added in this execution"""
global post_types
first_addition = False
num = 0
if self.db.has_key(name) == False:
@@ -172,6 +61,14 @@ class vkSession(object):
if i.has_key("type") and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
log.debug("Skipping unsupported item... %r" % (i,))
continue
# for some reason, VK sends post data if the post has been deleted already.
# Example of this behaviour is when you upload an audio and inmediately delete the audio, VK still sends the post stating that you uploaded an audio file,
# But without the audio data, making socializer to render an empty post.
# Here we check if the post contains data of the type it advertises.
if i.get("type") != None and post_types.get(i["type"]) not in i:
log.error("Detected invalid or unsupported post. Skipping...")
log.error(i)
continue
if find_item(self.db[name]["items"], i) == False:
# if i not in self.db[name]["items"]:
if first_addition == True or show_nextpage == True:
@@ -204,32 +101,20 @@ class vkSession(object):
file_ = "%s/session.conf" % (self.session_id,)
# try:
log.debug("Creating config file %s" % (file_,))
self.settings = Configuration(paths.config_path(file_), 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(self.settings["sound"])
# except:
# log.exception("The session configuration has failed.")
def login(self):
""" Login using credentials from settings.
if the user account isn't authorised, it'll call self.authorise() before login.
If the access_token has expired, it will call authorise() too, for getting a new access token."""
if self.settings["vk"]["token"] != None:
result = self.vk.login_access_token(self.settings["vk"]["token"])
self.logged = True
log.debug("Logged.")
if result == False:
self.authorise()
else:
self.authorise()
self.get_my_data()
def authorise(self):
try:
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"])
self.settings["vk"]["token"] = self.vk.client._session.access_token
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"], alt_token=self.settings["vk"]["use_alternative_tokens"], filename=config_filename)
self.settings["vk"]["token"] = self.vk.session_object.token["access_token"]
self.settings.write()
except:
self.logged = True
self.get_my_data()
except ValueError:
self.settings["vk"]["user"] = ""
self.settings["vk"]["password"] = ""
self.settings.write()
@@ -260,10 +145,21 @@ class vkSession(object):
def get_page(self, name="", show_nextpage=False, endpoint="", *args, **kwargs):
data = None
if "audio" in endpoint and self.settings["vk"]["use_alternative_tokens"]:
log.info("Using alternative audio methods.")
c = self.vk.client_audio
else:
c = self.vk.client
if kwargs.has_key("parent_endpoint"):
p = kwargs["parent_endpoint"]
if "audio" in p and self.settings["vk"]["use_alternative_tokens"]:
log.info("Using alternative audio methods.")
c = self.vk.client_audio
kwargs.pop("parent_endpoint")
p = getattr(self.vk.client, p)
try:
p = getattr(c, p)
except AttributeError:
p = c
log.debug("Calling endpoint %s with params %r" % (p, kwargs,))
data = getattr(p, endpoint)(*args, **kwargs)
if data != None:
@@ -273,7 +169,7 @@ class vkSession(object):
data2 = {"profiles": [], "groups": []}
for i in data["items"]:
data2["profiles"].append(i)
self.process_usernames(data2)
self.process_usernames(data2)
if data.has_key("profiles") and data.has_key("groups"):
self.process_usernames(data)
else:
@@ -282,6 +178,7 @@ class vkSession(object):
def get_messages(self, name="", *args, **kwargs):
data = self.vk.client.messages.getHistory(*args, **kwargs)
data["items"].reverse()
if data != None:
num = self.order_buffer(name, data["items"], False)
return num
@@ -289,11 +186,9 @@ class vkSession(object):
def get_user_name(self, user_id, case_name="gen"):
if user_id > 0:
if self.db["users"].has_key(user_id):
# print self.db["users"][user_id]
if self.db["users"][user_id].has_key(case_name):
return self.db["users"][user_id][case_name]
else:
print self.db["users"][user_id], self.db["users"][user_id].keys()
return self.db["users"][user_id]["nom"]
else:
return "no specified user"
@@ -331,13 +226,17 @@ class vkSession(object):
gids = "{0},".format(i["id"],)
if not "ru" in languageHandler.getLanguage():
return
users = self.vk.client.users.get(user_ids=ids, fields="first_name, last_name", name_case="gen")
for i in users:
if self.db["users"].has_key(i["id"]):
self.db["users"][i["id"]]["gen"] = u"{0} {1}".format(i["first_name"], i["last_name"])
if ids != "":
users_genitive = self.vk.client.users.get(user_ids=ids, fields="first_name, last_name", name_case="gen")
users_instrumental = self.vk.client.users.get(user_ids=ids, fields="first_name, last_name", name_case="ins")
for i in users_genitive:
if self.db["users"].has_key(i["id"]):
self.db["users"][i["id"]]["gen"] = u"{0} {1}".format(i["first_name"], i["last_name"])
for i in users_instrumental:
if self.db["users"].has_key(i["id"]):
self.db["users"][i["id"]]["ins"] = u"{0} {1}".format(i["first_name"], i["last_name"])
def get_my_data(self):
log.debug("Getting user identifier...")
user = self.vk.client.users.get(fields="uid, first_name, last_name")
self.user_id = user[0]["id"]
# self.db["users"][self.user_id] = u"{0} {1}".format(user[0]["first_name"], user[0]["last_name"])
self.user_id = user[0]["id"]

View File

@@ -23,10 +23,9 @@ class sessionManagerController(object):
def fill_list(self):
log.debug("Filling the session list...")
for i in os.listdir(paths.config_path()):
if os.path.isdir(paths.config_path(i)):
if os.path.isdir(os.path.join(paths.config_path(), i)):
log.debug("Adding session %s" % (i,))
strconfig = "%s/session.conf" % (paths.config_path(i))
config_test = Configuration(strconfig)
config_test = Configuration(os.path.join(paths.config_path(), i, "session.conf"))
name = config_test["vk"]["user"]
if name != "" and config_test["vk"]["password"] != "":
self.session = i
@@ -39,9 +38,8 @@ class sessionManagerController(object):
location = (str(time.time())[-6:])
log.debug("Creating session in the %s path" % (location,))
s = session.vkSession(location)
path = paths.config_path(location)
path = os.path.join(paths.config_path(), location)
if not os.path.exists(path):
log.debug("Creating %s path" % (paths.config_path(path),))
os.mkdir(path)
s.get_configuration()
self.get_authorisation(s)

View File

@@ -4,6 +4,7 @@ import os
import requests
import re
import logging
from sessionmanager import renderers
log = logging.getLogger("utils")
url_re = re.compile("(?:\w+://|www\.)[^ ,.?!#%=+][^ ]*")
bad_chars = '\'\\.,[](){}:;"'
@@ -58,4 +59,32 @@ def clean_text(text):
""" Replaces all HTML entities and put the plain text equivalent if it's possible."""
text = text.replace("<br>", "\n")
text = text.replace("\\n", "\n")
return text
return text
def add_attachment(attachment):
msg = u""
tpe = ""
if attachment["type"] == "link":
msg = u"{0}: {1}".format(attachment["link"]["title"], attachment["link"]["url"])
tpe = _(u"Link")
elif attachment["type"] == "photo":
tpe = _(u"Photo")
msg = attachment["photo"]["text"]
if msg == "":
msg = _(u"no description available")
elif attachment["type"] == "video":
msg = u"{0}".format(attachment["video"]["title"],)
tpe = _(u"Video")
elif attachment["type"] == "audio":
msg = u"{0}".format(" ".join(renderers.render_audio(attachment["audio"])))
tpe = _(u"Audio")
elif attachment["type"] == "doc":
msg = u"{0}".format(attachment["doc"]["title"])
tpe = _(u"{0} file").format(attachment["doc"]["ext"])
elif attachment["type"] == "audio_message":
msg = u"{0}".format(" ".join(renderers.render_audio_message(attachment["audio_message"])))
tpe = _(u"Voice message")
else:
print attachment
return [tpe, msg]

View File

@@ -1,25 +1,38 @@
#!/usr/bin/python
import keys
import logging
from vk import API, AuthSession, Session
import core
from vk_api.audio import VkAudio
from wxUI import two_factor_auth
log = logging.getLogger("vkSessionHandler")
class vkObject(object):
def __init__(self):
self.api_key = keys.keyring.get_api_key()
self.api_version = 5.52
log.debug("Created vkSession using VK API Version %s" % (self.api_version,))
def login(self, user, password):
log.debug("Logging in vk using user/password authentication")
s = AuthSession(app_id=self.api_key, user_login=user, user_password=password, scope="wall, notify, friends, photos, audio, video, docs, notes, pages, status, groups, messages, notifications, stats")
self.client = API(s, v=self.api_version)
def login(self, user, password, token, alt_token, filename):
if alt_token == False:
log.info("Using kate's token...")
# Let's import the patched vk_api module for using a different user agent
import vk_api_patched as vk_api
if token == "" or token == None:
log.info("Token is not valid. Generating one...")
token = core.requestAuth(user, password)
token = token[0]
receipt = core.getReceipt(token)
token = core.validateToken(token, receipt)
log.info("Token validated...")
self.session_object = vk_api.VkApi(app_id=self.api_key, login=user, password=password, token=token, scope="offline, wall, notify, friends, photos, audio, video, docs, notes, pages, status, groups, messages, notifications, stats", config_filename=filename)
else:
import vk_api
self.session_object = vk_api.VkApi(app_id=self.api_key, login=user, password=password, scope="offline, wall, notify, friends, photos, audio, video, docs, notes, pages, status, groups, messages, notifications, stats", config_filename=filename, auth_handler=two_factor_auth)
self.session_object.auth()
self.client = self.session_object.get_api()
# print self.client.audio.get()
log.debug("Getting tokens for 24 hours...")
self.client.account.getProfileInfo()
def login_access_token(self, token):
log.debug("Logging in VK using stored tokens...")
s = Session(access_token=token)
self.client = API(s, v=self.api_version)
return self.client.account.getProfileInfo()
# info = self.client.account.getProfileInfo()
# Add session data to the application statistics.
self.client.stats.trackVisitor()
self.client_audio = VkAudio(self.session_object)

View File

@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
""" this is a patched version of vk_api to use a different user agent for authenticating against VK.
Everything else looks the same, the only change in the module is the new user agent, emulating a kate mobile session."""
import logging
import vk_api
import threading
import requests
import jconfig_patched as jconfig
from vk_api.enums import VkUserPermissions
from vk_api.exceptions import *
DEFAULT_USER_SCOPE = sum(VkUserPermissions)
class VkApi(vk_api.VkApi):
def __init__(self, login=None, password=None, token=None,
auth_handler=None, captcha_handler=None,
config=jconfig.Config, config_filename='vk_config.v2.json',
api_version='5.92', app_id=2685278, scope=DEFAULT_USER_SCOPE,
client_secret='lxhD8OD7dMsqtXIm5IUY'):
self.login = login
self.password = password
self.token = {'access_token': token}
self.api_version = api_version
self.app_id = app_id
self.scope = scope
self.client_secret = client_secret
self.storage = config(self.login, filename=config_filename)
self.http = requests.Session()
self.http.headers.update({'User-agent': 'KateMobileAndroid/47-427 (Android 6.0.1; SDK 23; armeabi-v7a; samsung SM-G900F; ru)'})
self.last_request = 0.0
self.error_handlers = {
NEED_VALIDATION_CODE: self.need_validation_handler,
CAPTCHA_ERROR_CODE: captcha_handler or self.captcha_handler,
TOO_MANY_RPS_CODE: self.too_many_rps_handler,
TWOFACTOR_CODE: auth_handler or self.auth_handler
}
self.lock = threading.Lock()
self.logger = logging.getLogger('vk_api_patched')
self.logger.info('Started patched VK API client...')

View File

@@ -1,10 +1,30 @@
# -*- coding: utf-8 -*-
import time
import wx
import widgetUtils
code = None
remember = True
def new_account_dialog():
return wx.MessageDialog(None, _(u"In order to continue, you need to configure your VK account before. Would you like to autorhise a new account now?"), _(u"Authorisation"), wx.YES_NO).ShowModal()
def two_factor_auth():
global code, remember
wx.CallAfter(get_code)
while code == None:
time.sleep(0.5)
return (code, remember)
def get_code():
global code, remember
dlg = wx.TextEntryDialog(None, _(u"Please provide the authentication code you have received from VK."), _(u"Two factor authentication code"))
response = dlg.ShowModal()
if response == widgetUtils.OK:
code = dlg.GetValue()
dlg.Destroy()
dlg.Destroy()
class newSessionDialog(widgetUtils.BaseDialog):
def __init__(self):
super(newSessionDialog, self).__init__(parent=None, id=wx.NewId(), title=_(u"Authorise VK"))

View File

@@ -1,4 +1,4 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
""" Setup file to create executables and distribute the source code of this application. Don't forget this file! """
############################################################
# Copyright (c) 2016 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
@@ -27,7 +27,7 @@ from glob import glob
def get_architecture_files():
if platform.architecture()[0][:2] == "32":
return [
("", ["../windows-dependencies/x86/bootstrap.exe"]),
("", ["../windows-dependencies/x86/oggenc2.exe", "../windows-dependencies/x86/bootstrap.exe"]),
("Microsoft.VC90.CRT", glob("../windows-dependencies/x86/Microsoft.VC90.CRT/*")),
("Microsoft.VC90.MFC", glob("../windows-dependencies/x86/Microsoft.VC90.MFC/*")),]
elif platform.architecture()[0][:2] == "64":
@@ -47,7 +47,7 @@ def get_data():
]+get_sounds()+get_locales()+get_documentation()+accessible_output2.find_datafiles()+enchant.utils.win32_data_files()+get_architecture_files()+sound_lib.find_datafiles()
def get_documentation ():
answer = []
answer = [("documentation", ["documentation/license.txt"])]
depth = 6
for root, dirs, files in os.walk('documentation'):
if depth == 0:
@@ -88,7 +88,7 @@ options = {
'py2exe': {
'optimize':2,
'packages': ["pubsub", "pubsub.core", "pubsub.core.kwargs"],
'dll_excludes': ["MPR.dll", "api-ms-win-core-apiquery-l1-1-0.dll", "api-ms-win-core-console-l1-1-0.dll", "api-ms-win-core-delayload-l1-1-1.dll", "api-ms-win-core-errorhandling-l1-1-1.dll", "api-ms-win-core-file-l1-2-0.dll", "api-ms-win-core-handle-l1-1-0.dll", "api-ms-win-core-heap-obsolete-l1-1-0.dll", "api-ms-win-core-libraryloader-l1-1-1.dll", "api-ms-win-core-localization-l1-2-0.dll", "api-ms-win-core-processenvironment-l1-2-0.dll", "api-ms-win-core-processthreads-l1-1-1.dll", "api-ms-win-core-profile-l1-1-0.dll", "api-ms-win-core-registry-l1-1-0.dll", "api-ms-win-core-synch-l1-2-0.dll", "api-ms-win-core-sysinfo-l1-2-0.dll", "api-ms-win-security-base-l1-2-0.dll", "api-ms-win-core-heap-l1-2-0.dll", "api-ms-win-core-interlocked-l1-2-0.dll", "api-ms-win-core-localization-obsolete-l1-1-0.dll", "api-ms-win-core-string-l1-1-0.dll", "api-ms-win-core-string-obsolete-l1-1-0.dll", "WLDAP32.dll", "MSVCP90.dll"],
'dll_excludes': ["MPR.dll", "api-ms-win-core-apiquery-l1-1-0.dll", "api-ms-win-core-console-l1-1-0.dll", "api-ms-win-core-delayload-l1-1-1.dll", "api-ms-win-core-errorhandling-l1-1-1.dll", "api-ms-win-core-file-l1-2-0.dll", "api-ms-win-core-handle-l1-1-0.dll", "api-ms-win-core-heap-obsolete-l1-1-0.dll", "api-ms-win-core-libraryloader-l1-1-1.dll", "api-ms-win-core-localization-l1-2-0.dll", "api-ms-win-core-processenvironment-l1-2-0.dll", "api-ms-win-core-processthreads-l1-1-1.dll", "api-ms-win-core-profile-l1-1-0.dll", "api-ms-win-core-registry-l1-1-0.dll", "api-ms-win-core-synch-l1-2-0.dll", "api-ms-win-core-sysinfo-l1-2-0.dll", "api-ms-win-security-base-l1-2-0.dll", "api-ms-win-core-heap-l1-2-0.dll", "api-ms-win-core-interlocked-l1-2-0.dll", "api-ms-win-core-localization-obsolete-l1-1-0.dll", "api-ms-win-core-string-l1-1-0.dll", "api-ms-win-core-string-obsolete-l1-1-0.dll", "WLDAP32.dll", "MSVCP90.dll", "CRYPT32.dll"],
# 'skip_archive': False
},
},

View File

@@ -1,27 +1,43 @@
# -*- coding: utf-8 -*-
""" Sound utilities for socialized."""
""" Sound utilities for socializer."""
from __future__ import unicode_literals
import sys
import os
import logging as original_logger
log = original_logger.getLogger("sound")
import glob
import subprocess
import logging
import paths
import sound_lib
import output
from sound_lib import recording
from mysc.repeating_timer import RepeatingTimer
from mysc.thread_utils import call_threaded
import glob
from sound_lib import output, input
log = logging.getLogger("sound")
def recode_audio(filename, quality=4.5):
subprocess.call(r'"%s" -q %r "%s"' % (os.path.join(paths.app_path(), 'oggenc2.exe'), quality, filename))
def get_recording(filename):
# try:
val = recording.WaveRecording(filename=filename)
# except sound_lib.main.BassError:
# sound_lib.input.Input()
# val = sound_lib.recording.WaveRecording(filename=filename)
return val
class soundSystem(object):
def check_soundpack(self):
""" Checks if the folder where live the current soundpack exists."""
self.soundpack_OK = False
if os.path.exists(paths.sound_path(self.config["current_soundpack"])):
self.path = paths.sound_path(self.config["current_soundpack"])
if os.path.exists(os.path.join(paths.sound_path(), self.config["current_soundpack"])):
self.path = os.path.join(paths.sound_path(), self.config["current_soundpack"])
self.soundpack_OK = True
elif os.path.exists(paths.sound_path("default")):
elif os.path.exists(os.path.join(paths.sound_path(), "default")):
log.error("The soundpack does not exist, using default...")
self.path = paths.sound_path("default")
self.path = os.path.join(paths.sound_path(), "default")
self.soundpack_OK = True
else:
log.error("The current soundpack could not be found and the default soundpack has been deleted, Socializer will not play sounds.")
@@ -32,8 +48,8 @@ class soundSystem(object):
self.config = soundConfig
# Set the output and input default devices.
try:
self.output = sound_lib.output.Output()
self.input = sound_lib.input.Input()
self.output = output.Output()
self.input = input.Input()
except:
pass
# Try to use the selected device from the configuration. It can fail if the machine does not has a mic.

View File

@@ -1,25 +0,0 @@
import output, input, recording, stream
__author__ = 'Christopher Toth'
__version__ = 0.73
def find_datafiles():
from glob import glob
import os
import platform
import sound_lib
path = os.path.join(sound_lib.__path__[0], 'lib')
system = platform.system()
if system == 'Windows':
file_ext = '*.dll'
elif system == 'Darwin':
file_ext = '*.dylib'
else:
file_ext = '*.so'
if platform.architecture()[0] == '32bit' or platform.system() == 'Darwin':
arch = 'x86'
else:
arch = 'x64'
dest_dir = os.path.join('sound_lib', 'lib', arch)
source = glob(os.path.join(path, arch, file_ext))
return [(dest_dir, source)]

View File

@@ -1,285 +0,0 @@
from __future__ import absolute_import
from .external.pybass import *
from .main import bass_call, bass_call_0, BassError, update_3d_system, FlagObject
from ctypes import pointer, c_float, c_long, c_ulong, c_buffer
class Channel (FlagObject):
"""A "channel" can be a sample playback channel (HCHANNEL), a sample stream (HSTREAM), a MOD music (HMUSIC), or a recording (HRECORD). Each "Channel" function can be used with one or more of these channel types."""
def __init__ (self, handle):
self.handle = handle
self.attribute_mapping = {
'eaxmix': BASS_ATTRIB_EAXMIX,
'frequency': BASS_ATTRIB_FREQ,
'pan': BASS_ATTRIB_PAN,
'volume': BASS_ATTRIB_VOL
}
def add_attributes_to_mapping(self, **attrs):
self.attribute_mapping.update(**attrs)
def play (self, restart=False):
"""Starts (or resumes) playback of a sample, stream, MOD music, or recording."""
return bass_call(BASS_ChannelPlay, self.handle, restart)
def play_blocking(self, restart=False):
self.play(restart=restart)
while self.is_playing:
pass
def pause (self):
return bass_call(BASS_ChannelPause, self.handle)
def is_active (self):
"Checks if a sample, stream, or MOD music is active (playing) or stalled. Can also check if a recording is in progress."""
return bass_call_0(BASS_ChannelIsActive, self.handle)
@property
def is_playing(self):
return self.is_active() == BASS_ACTIVE_PLAYING
@property
def is_paused(self):
return self.is_active() == BASS_ACTIVE_PAUSED
@property
def is_stopped(self):
return self.is_active() == BASS_ACTIVE_STOPPED
@property
def is_stalled(self):
return self.is_active() == BASS_ACTIVE_STALLED
def get_position (self, mode=BASS_POS_BYTE):
"""Retrieves the playback position of a sample, stream, or MOD music. Can also be used with a recording channel."""
return bass_call_0(BASS_ChannelGetPosition, self.handle, mode)
def set_position (self, pos, mode=BASS_POS_BYTE):
"""Sets the playback position of a sample, MOD music, or stream."""
return bass_call(BASS_ChannelSetPosition, self.handle, pos, mode)
position = property(get_position, set_position)
def stop (self):
"""Stops a sample, stream, MOD music, or recording."""
return bass_call(BASS_ChannelStop, self.handle)
def update (self, length=0):
"""Updates the playback buffer of a stream or MOD music."""
return bass_call(BASS_ChannelUpdate, self.handle, length)
def get_length (self, mode=BASS_POS_BYTE):
return bass_call_0(BASS_ChannelGetLength, self.handle, mode)
__len__ = get_length
def __bool__(self):
return True
def get_device(self):
"""Retrieves the device that a channel is using."""
return bass_call_0( BASS_ChannelGetDevice, self.handle)
def set_device (self, device):
"""Changes the device that a stream, MOD music or sample is using."""
bass_call(BASS_ChannelSetDevice, self.handle, device)
device = property(get_device, set_device)
def set_fx(self, type, priority=0):
"""Sets an effect on a stream, MOD music, or recording channel."""
return SoundEffect(bass_call(BASS_ChannelSetFX, type, priority))
def bytes_to_seconds(self, position=None):
"""Translates a byte position into time (seconds), based on a channel's format."""
position = position or self.position
return bass_call_0(BASS_ChannelBytes2Seconds, self.handle, position)
def length_in_seconds(self):
return self.bytes_to_seconds(self.get_length())
def seconds_to_bytes(self, position):
"""Translates a time (seconds) position into bytes, based on a channel's format."""
return bass_call_0(BASS_ChannelSeconds2Bytes, self.handle, position)
def get_attribute(self, attribute):
"""Retrieves the value of a channel's attribute."""
value = pointer(c_float())
if attribute in self.attribute_mapping:
attribute = self.attribute_mapping[attribute]
bass_call(BASS_ChannelGetAttribute, self.handle, attribute, value)
return value.contents.value
def set_attribute(self, attribute, value):
"""Sets the value of a channel's attribute."""
if attribute in self.attribute_mapping:
attribute = self.attribute_mapping[attribute]
return bass_call(BASS_ChannelSetAttribute, self.handle, attribute, value)
def slide_attribute(self, attribute, value, time):
"""Slides a channel's attribute from its current value to a new value."""
if attribute in self.attribute_mapping:
attribute = self.attribute_mapping[attribute]
return bass_call(BASS_ChannelSlideAttribute, self.handle, attribute, value, time*1000)
def is_sliding (self, attribute=None):
"""Checks if an attribute (or any attribute) of a sample, stream, or MOD music is sliding."""
return bass_call_0(BASS_ChannelIsSliding, self.handle, attribute)
def get_info(self):
"""Retrieves information on a channel."""
value = pointer(BASS_CHANNELINFO())
bass_call(BASS_ChannelGetInfo, self.handle, value)
return value[0]
def get_level(self):
"""Retrieves the level (peak amplitude) of a stream, MOD music or recording channel."""
return bass_call_0(BASS_ChannelGetLevel, self.handle)
def lock(self):
"""Locks a stream, MOD music or recording channel to the current thread."""
return bass_call(BASS_ChannelLock, self.handle, True)
def unlock(self):
"""Unlocks a stream, MOD music or recording channel from the current thread."""
return bass_call(BASS_ChannelLock, self.handle, False)
def get_3d_attributes(self):
"""Retrieves the 3D attributes of a sample, stream, or MOD music channel with 3D functionality."""
answer = dict(mode=c_ulong(), min=c_float(), max=c_float(), iangle=c_ulong(), oangle=c_ulong(), outvol=c_float())
bass_call(BASS_ChannelGet3DAttributes, self.handle, pointer(answer['mode']), pointer(answer['min']), pointer(answer['max']), pointer(answer['iangle']), pointer(answer['oangle']), pointer(answer['outvol']))
for k in answer:
answer[k] = answer[k].value()
return answer
@update_3d_system
def set_3d_attributes(self, mode=-1, min=0.0, max=0.0, iangle=-1, oangle=-1, outvol=-1):
"""Sets the 3D attributes of a sample, stream, or MOD music channel with 3D functionality."""
return bass_call(BASS_ChannelSet3DAttributes, self.handle, mode, min, max, iangle, oangle, outvol)
def get_3d_position(self):
"""Retrieves the 3D position of a sample, stream, or MOD music channel with 3D functionality."""
answer = dict(position=BASS_3DVECTOR(), orientation=BASS_3DVECTOR(), velocity=BASS_3DVECTOR())
bass_call(BASS_ChannelGet3DPosition, self.handle, pointer(answer['position']), pointer(answer['orientation']), pointer(answer['velocity']))
return answer
@update_3d_system
def set_3d_position(self, position=None, orientation=None, velocity=None):
"""Sets the 3D position of a sample, stream, or MOD music channel with 3D functionality."""
if position:
position = pointer(position)
if orientation:
orientation = pointer(orientation)
if velocity:
velocity = pointer(velocity)
return bass_call(BASS_ChannelSet3DPosition, self.handle, position, orientation, velocity)
def set_link(self, handle):
"""Links two MOD music or stream channels together."""
bass_call(BASS_ChannelSetLink, self.handle, handle)
def remove_link(self, handle):
"""Removes a link between two MOD music or stream channels."""
return bass_call(BASS_ChannelRemoveLink, self.handle, handle)
def __iadd__(self, other):
"""Convenience method to link this channel to another. Calls set_link on the passed in item's handle"""
self.set_link(other.handle)
return self
def __isub__(self, other):
"""Convenience method to unlink this channel from another. Calls remove_link on the passed in item's handle"""
self.remove_link(other.handle)
return self
def get_frequency(self):
return self.get_attribute(BASS_ATTRIB_FREQ )
def set_frequency(self, frequency):
self.set_attribute(BASS_ATTRIB_FREQ, frequency)
frequency = property(fget=get_frequency, fset=set_frequency)
def get_pan(self):
return self.get_attribute(BASS_ATTRIB_PAN)
def set_pan(self, pan):
return self.set_attribute(BASS_ATTRIB_PAN, pan)
pan = property(fget=get_pan, fset=set_pan)
def get_volume(self):
return self.get_attribute(BASS_ATTRIB_VOL)
def set_volume(self, volume):
self.set_attribute(BASS_ATTRIB_VOL, volume)
volume = property(fget=get_volume, fset=set_volume)
def get_data(self, length=16384):
buf = c_buffer(length)
bass_call_0(BASS_ChannelGetData, self.handle, pointer(buf), length)
return buf
#This is less and less of a one-to-one mapping,
#But I feel that it's better to be consistent with ourselves
#Than with the library. We won't punish ourselves
#For their bad decisions
def get_looping(self):
return bass_call_0(BASS_ChannelFlags, self.handle, BASS_SAMPLE_LOOP, 0) == 20
def set_looping(self, looping):
if looping:
return bass_call_0(BASS_ChannelFlags, self.handle, BASS_SAMPLE_LOOP, BASS_SAMPLE_LOOP)
return bass_call_0(BASS_ChannelFlags, self.handle, 0, BASS_SAMPLE_LOOP)
looping = property(fget=get_looping, fset=set_looping)
def __del__(self):
try:
self.free()
except:
pass
def get_x(self):
return self.get_3d_position()['position'].x
def set_x(self, val):
pos = self.get_3d_position()
pos['position'].x = val
self.set_3d_position(**pos)
x = property(fget=get_x, fset=set_x)
def get_y(self):
return self.get_3d_position()['position'].y
def set_y(self, val):
pos = self.get_3d_position()
pos['position'].y = val
self.set_3d_position(**pos)
y = property(fget=get_y, fset=set_y)
def get_z(self):
return self.get_3d_position()['position'].z
def set_z(self, val):
pos = self.get_3d_position()
pos['position'].z = val
self.set_3d_position(**pos)
z = property(fget=get_z, fset=set_z)
def get_attributes(self):
"""Retrieves all values of all attributes from this object and displays them in a dictionary whose keys are determined by this object's attribute_mapping"""
res = {}
for k in self.attribute_mapping:
try:
res[k] = self.get_attribute(k)
except BassError:
pass
return res

View File

@@ -1,57 +0,0 @@
import collections
import ctypes
from sound_lib.external import pybass
from sound_lib.main import bass_call, bass_call_0
class BassConfig(collections.Mapping):
config_map = {
'3d_algorithm': pybass.BASS_CONFIG_3DALGORITHM,
'buffer': pybass.BASS_CONFIG_BUFFER ,
'curve_vol': pybass.BASS_CONFIG_CURVE_VOL,
'curve_pan': pybass.BASS_CONFIG_CURVE_PAN,
'dev_buffer': pybass.BASS_CONFIG_DEV_BUFFER,
'dev_default': pybass.BASS_CONFIG_DEV_DEFAULT,
'float_dsp': pybass.BASS_CONFIG_FLOATDSP,
'gvol_music': pybass.BASS_CONFIG_GVOL_MUSIC,
'gvol_sample': pybass.BASS_CONFIG_GVOL_SAMPLE,
'gvol_stream': pybass.BASS_CONFIG_GVOL_STREAM,
'music_virtual': pybass.BASS_CONFIG_MUSIC_VIRTUAL,
'net_agent': pybass.BASS_CONFIG_NET_AGENT,
'net_buffer': pybass.BASS_CONFIG_NET_BUFFER,
'net_passive': pybass.BASS_CONFIG_NET_PASSIVE,
'net_playlist': pybass.BASS_CONFIG_NET_PLAYLIST,
'net_prebuf': pybass.BASS_CONFIG_NET_PREBUF,
'net_proxy': pybass.BASS_CONFIG_NET_PROXY,
'net_read_timeout': pybass.BASS_CONFIG_NET_READTIMEOUT,
'net_timeout': pybass.BASS_CONFIG_NET_TIMEOUT,
'pause_no_play': pybass.BASS_CONFIG_PAUSE_NOPLAY,
'rec_buffer': pybass.BASS_CONFIG_REC_BUFFER,
'src': pybass.BASS_CONFIG_SRC,
'src_sample': pybass.BASS_CONFIG_SRC_SAMPLE,
'unicode': pybass.BASS_CONFIG_UNICODE,
'update_period': pybass.BASS_CONFIG_UPDATEPERIOD,
'update_threads': pybass.BASS_CONFIG_UPDATETHREADS,
'verify': pybass.BASS_CONFIG_VERIFY,
'vista_speakers': pybass.BASS_CONFIG_VISTA_SPEAKERS,
}
ptr_config = (pybass.BASS_CONFIG_NET_AGENT, pybass.BASS_CONFIG_NET_PROXY)
def __getitem__(self, key):
key = self.config_map.get(key, key)
if key in self.ptr_config:
return ctypes.string_at(bass_call(pybass.BASS_GetConfigPtr, key))
return bass_call_0(pybass.BASS_GetConfig, key)
def __setitem__(self, key, val):
key = self.config_map.get(key, key)
if key in self.ptr_config:
return bass_call(pybass.BASS_SetConfigPtr, key, ctypes.create_string_buffer(val))
return bass_call(pybass.BASS_SetConfig, key, val)
def __iter__(self):
for key in self.config_map.keys():
yield key
def __len__(self):
return len(self.config_map)

View File

@@ -1 +0,0 @@
from .tempo import Tempo

View File

@@ -1,39 +0,0 @@
from __future__ import absolute_import
from sound_lib.external import pybass
from .effect import SoundEffect
class Chorus(SoundEffect):
effect_type = pybass.BASS_FX_DX8_CHORUS
struct = pybass.BASS_DX8_CHORUS
class Echo(SoundEffect):
effect_type = pybass.BASS_FX_DX8_ECHO
struct = pybass.BASS_DX8_ECHO
class Compressor(SoundEffect):
effect_type = pybass.BASS_FX_DX8_COMPRESSOR
struct = pybass.BASS_DX8_COMPRESSOR
class Reverb(SoundEffect):
effect_type = pybass.BASS_FX_DX8_REVERB
struct = pybass.BASS_DX8_REVERB
class Distortion(SoundEffect):
effect_type = pybass.BASS_FX_DX8_DISTORTION
struct = pybass.BASS_DX8_DISTORTION
class Flanger(SoundEffect):
effect_type = pybass.BASS_FX_DX8_FLANGER
struct = pybass.BASS_DX8_FLANGER
class Gargle(SoundEffect):
effect_type = pybass.BASS_FX_DX8_GARGLE
struct = pybass.BASS_DX8_GARGLE
class I3DL2Reverb(SoundEffect):
effect_type = pybass.BASS_FX_DX8_I3DL2REVERB
struct = pybass.BASS_DX8_I3DL2REVERB
class ParamEq(SoundEffect):
effect_type = pybass.BASS_FX_DX8_PARAMEQ
struct = pybass.BASS_DX8_PARAMEQ

View File

@@ -1,14 +0,0 @@
from __future__ import absolute_import
from sound_lib.external import pybass_fx
from .effect import SoundEffect
class Volume(SoundEffect):
effect_type = pybass_fx.BASS_FX_BFX_VOLUME
struct = pybass_fx.BASS_BFX_VOLUME
class PeakEq(SoundEffect):
effect_type = pybass_fx.BASS_FX_BFX_PEAKEQ
struct = pybass_fx.BASS_BFX_PEAKEQ
class DAmp(SoundEffect):
effect_type = pybass_fx.BASS_FX_BFX_DAMP
struct = pybass_fx.BASS_BFX_DAMP

View File

@@ -1,71 +0,0 @@
from future.builtins import object
from sound_lib.main import bass_call
import ctypes
from sound_lib.external import pybass
import string #for the alphabet!
class SoundEffect(object):
def __init__(self, channel, type=None, priority=0):
self.original_channel = channel
if hasattr(channel, 'handle'):
channel = channel.handle
if type is None:
type = self.effect_type
self.effect_type = type
self.priority = priority
self.handle = bass_call(pybass.BASS_ChannelSetFX, channel, type, priority)
def get_parameters(self):
"""Retrieves the parameters of an effect."""
res = {}
params = self.struct()
bass_call(pybass.BASS_FXGetParameters, self.handle, ctypes.pointer(params))
for f in params._fields_:
res[f[0]] = getattr(params, f[0])
return res
def set_parameters(self, parameters):
params = self.struct()
for p, v in parameters.items():
setattr(params, p, v)
bass_call(pybass.BASS_FXSetParameters, self.handle, ctypes.pointer(params))
def __dir__(self):
res = dir(self.__class__)
return res + self._get_pythonic_effect_fields()
def _get_effect_fields(self):
return [i[0] for i in self.struct._fields_]
def _get_pythonic_effect_fields(self):
return [self._bass_to_python(i) for i in self._get_effect_fields() if not i.startswith('_') ]
def _bass_to_python(self, func):
for c in string.ascii_lowercase:
func = func.replace(c.upper(), '_%s' % c)
if func.startswith('_'):
func = func[1:]
return func[2:]
def _python_to_bass(self, func):
for c in string.ascii_lowercase:
func = func.replace('_%s' % c, c.upper())
func = '%s%s' % (func[0].upper(), func[1:])
for f in self._get_effect_fields():
if f.endswith(func):
func = f
return func
def __getattr__(self, attr):
return self.get_parameters()[self._python_to_bass(attr)]
def __setattr__(self, attr, val):
if attr not in self._get_pythonic_effect_fields():
return super(SoundEffect, self).__setattr__(attr, val)
params = self.get_parameters()
key = self._python_to_bass(attr)
if key not in params:
raise AttributeError('Unable to set attribute, suspect issue with base name-munging code')
params[key] = val
self.set_parameters(params)

View File

@@ -1,65 +0,0 @@
import ctypes
from sound_lib.external import pybass, pybass_fx
from sound_lib.stream import BaseStream
from sound_lib.channel import Channel
from sound_lib.main import bass_call, bass_call_0
class Tempo(BaseStream):
def __init__(self, channel, flags=0, loop=False, software=False, three_d=False, sample_fx=False, autofree=False, decode=False, free_source=False):
flags = flags | self.flags_for(loop=False, software=False, three_d=False, sample_fx=False, autofree=False, decode=False, free_source=False)
self.channel = channel
if isinstance(channel, Channel):
channel = channel.handle
handle = bass_call(pybass_fx.BASS_FX_TempoCreate, channel, flags)
super(Tempo, self).__init__(handle)
self.add_attributes_to_mapping(
tempo=pybass_fx.BASS_ATTRIB_TEMPO,
tempo_pitch=pybass_fx.BASS_ATTRIB_TEMPO_PITCH,
tempo_freq=pybass_fx.BASS_ATTRIB_TEMPO_FREQ,
)
@property
def tempo(self):
"""The tempo of a channel."""
return self.get_attribute(pybass_fx.BASS_ATTRIB_TEMPO)
@tempo.setter
def tempo(self, val):
self.set_attribute('tempo', val)
@property
def tempo_pitch(self):
return self.get_attribute('tempo_pitch')
@tempo_pitch.setter
def tempo_pitch(self, val):
self.set_attribute('tempo_pitch', val)
@property
def tempo_freq(self):
return self.get_attribute('tempo_freq')
@tempo_freq.setter
def tempo_freq(self, val):
self.set_attribute('tempo_freq', val)
def setup_flag_mapping(self):
super(Tempo, self).setup_flag_mapping()
self.flag_mapping.update({
'free_source': pybass_fx.BASS_FX_FREESOURCE,
})
def get_source(self):
source = pybass_fx.BASS_FX_TempoGetSource(self.handle)
if source == self.channel.handle:
source = self.channel
return source
source = property(fget=get_source)
def get_rate_ratio(self):
return bass_call(pybass_fx.BASS_FX_TempoGetRateRatio, self.handle)
rate_ratio = property(fget=get_rate_ratio)

View File

@@ -1,81 +0,0 @@
from __future__ import absolute_import
from .external import pybass, pybassenc
from .main import bass_call, bass_call_0, FlagObject
class Encoder(FlagObject):
def setup_flag_mapping(self):
#super(Encoder, self).setup_flag_mapping()
self.flag_mapping = {
'pcm': pybassenc.BASS_ENCODE_PCM,
'no_header': pybassenc.BASS_ENCODE_NOHEAD,
'rf64': pybassenc.BASS_ENCODE_RF64,
'big_endian': pybassenc.BASS_ENCODE_BIGEND,
'fp_8bit': pybassenc.BASS_ENCODE_FP_8BIT,
'fp_16bit': pybassenc.BASS_ENCODE_FP_16BIT,
'fp_24bit': pybassenc.BASS_ENCODE_FP_24BIT,
'fp_32bit': pybassenc.BASS_ENCODE_FP_32BIT,
'queue': pybassenc.BASS_ENCODE_QUEUE,
'limit': pybassenc.BASS_ENCODE_LIMIT,
'no_limit': pybassenc.BASS_ENCODE_CAST_NOLIMIT,
'pause': pybassenc.BASS_ENCODE_PAUSE,
'autofree': pybassenc.BASS_ENCODE_AUTOFREE,
'unicode': pybass.BASS_UNICODE,
}
def __init__(self, source, command_line, pcm=False, no_header=False, rf64=False, big_endian=False, fp_8bit=False, fp_16bit=False, fp_24bit=False, fp_32bit=False, queue=False, limit=False, no_limit=False, pause=True, autofree=False, callback=None, user=None):
self.setup_flag_mapping()
flags = self.flags_for(pcm=pcm, no_header=no_header, rf64=rf64, big_endian=big_endian, fp_8bit=fp_8bit, fp_16bit=fp_16bit, fp_24bit=fp_24bit, fp_32bit=fp_32bit, queue=queue, limit=limit, no_limit=no_limit, pause=pause, autofree=autofree) #fwiw!
self.source = source
source_handle = source.handle
if callback is None:
callback = lambda *a: None
callback = pybassenc.ENCODEPROC(callback)
self.callback = callback
self.handle = bass_call(pybassenc.BASS_Encode_Start, source_handle, command_line, flags, callback, user)
@property
def paused(self):
return bass_call_0(pybassenc.BASS_Encode_IsActive, self.handle) == pybass.BASS_ACTIVE_PAUSED
@paused.setter
def paused(self, paused):
return bass_call(pybassenc.BASS_Encode_SetPaused, self.handle, paused)
def is_stopped(self):
return bass_call_0(pybassenc.BASS_Encode_IsActive, self.handle) == pybass.BASS_ACTIVE_STOPPED
def stop(self):
return bass_call(pybassenc.BASS_Encode_Stop, self.handle)
class BroadcastEncoder(Encoder):
def __init__(self, source_encoder, server, password, content, name=None, url=None, genre=None, description=None, headers=None, bitrate=0, public=False):
contents = {
'mp3': pybassenc.BASS_ENCODE_TYPE_MP3,
'ogg': pybassenc.BASS_ENCODE_TYPE_OGG,
'aac': pybassenc.BASS_ENCODE_TYPE_AAC
}
if content in contents:
content = contents[content]
self.source_encoder = source_encoder
handle = source_encoder.handle
self.server = server
self.password = password
self.status = bass_call(pybassenc.BASS_Encode_CastInit, handle, server, password, content, name, url, genre, description, headers, bitrate, public)
def set_title(self, title=None, url=None):
return bass_call(pybassenc.BASS_Encode_CastSetTitle, self.source_encoder.handle, title, url)
def get_stats(self, type, password=None):
types = {
'shoutcast': pybassenc.BASS_ENCODE_STATS_SHOUT,
'icecast': pybassenc.BASS_ENCODE_STATS_ICE,
'icecast_server': pybassenc.BASS_ENCODE_STATS_ICESERV,
}
if type in types:
type = types[type]
if password is None:
password = self.password
return bass_call(pybassenc.BASS_Encode_CastGetStats, self.handle, type, password)

View File

@@ -1,9 +0,0 @@
import platform
#if platform.system() == 'Windows':
# import sound_lib.external.pybasswma
if platform.system() != 'Darwin':
import sound_lib.external.pybass_aac
import sound_lib.external.pybass_alac
import sound_lib.external.pybassopus
import sound_lib.external.pybassflac
import sound_lib.external.pybassmidi

View File

@@ -1,9 +0,0 @@
import os
from platform_utils.paths import module_path, is_frozen, embedded_data_path
if is_frozen():
x86_path = os.path.join(embedded_data_path(), 'sound_lib', 'lib', 'x86')
x64_path = os.path.join(embedded_data_path(), 'sound_lib', 'lib', 'x64')
else:
x86_path = os.path.join(module_path(), '..', 'lib', 'x86')
x64_path = os.path.join(module_path(), '..', 'lib', 'x64')

File diff suppressed because it is too large Load Diff

View File

@@ -1,54 +0,0 @@
from __future__ import absolute_import
# Copyright(c) Max Kolosov 2009 maxkolosov@inbox.ru
# http://vosolok2008.narod.ru
# BSD license
__version__ = '0.1'
__versionTime__ = '2009-11-15'
__author__ = 'Max Kolosov <maxkolosov@inbox.ru>'
__doc__ = '''
pybass_aac.py - is ctypes python module for
BASS_AAC - extension to the BASS audio library that enables the playback
of Advanced Audio Coding and MPEG-4 streams (http://www.maresweb.de).
'''
import os, sys, ctypes
from . import pybass
from .paths import x86_path, x64_path
import libloader
bass_aac_module = libloader.load_library('bass_aac', x86_path=x86_path, x64_path=x64_path)
func_type = libloader.get_functype()
#Register the plugin with the Bass plugin system.
pybass.BASS_PluginLoad(libloader.find_library_path('bass_aac', x86_path=x86_path, x64_path=x64_path), 0)
QWORD = pybass.QWORD
HSTREAM = pybass.HSTREAM
DOWNLOADPROC = pybass.DOWNLOADPROC
BASS_FILEPROCS = pybass.BASS_FILEPROCS
# Additional BASS_SetConfig options
BASS_CONFIG_MP4_VIDEO = 0x10700 # play the audio from MP4 videos
# Additional tags available from BASS_StreamGetTags (for MP4 files)
BASS_TAG_MP4 = 7 # MP4/iTunes metadata
BASS_AAC_STEREO = 0x400000 # downmatrix to stereo
# BASS_CHANNELINFO type
BASS_CTYPE_STREAM_AAC = 0x10b00 # AAC
BASS_CTYPE_STREAM_MP4 = 0x10b01 # MP4
#HSTREAM BASSAACDEF(BASS_AAC_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
BASS_AAC_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_AAC_StreamCreateFile', bass_aac_module))
#HSTREAM BASSAACDEF(BASS_AAC_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user);
BASS_AAC_StreamCreateURL = func_type(HSTREAM, ctypes.c_char_p, ctypes.c_ulong, ctypes.c_ulong, DOWNLOADPROC, ctypes.c_void_p)(('BASS_AAC_StreamCreateURL', bass_aac_module))
#HSTREAM BASSAACDEF(BASS_AAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_AAC_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_AAC_StreamCreateFileUser', bass_aac_module))
#HSTREAM BASSAACDEF(BASS_MP4_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
BASS_MP4_StreamCreateFile = func_type(HSTREAM, ctypes.c_byte, ctypes.c_void_p, QWORD, QWORD, ctypes.c_ulong)(('BASS_MP4_StreamCreateFile', bass_aac_module))
#HSTREAM BASSAACDEF(BASS_MP4_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);
BASS_MP4_StreamCreateFileUser = func_type(HSTREAM, ctypes.c_ulong, ctypes.c_ulong, ctypes.POINTER(BASS_FILEPROCS), ctypes.c_void_p)(('BASS_MP4_StreamCreateFileUser', bass_aac_module))

Some files were not shown because too many files have changed in this diff Show More