Compare commits
311 Commits
Author | SHA1 | Date | |
---|---|---|---|
ead54fce3f | |||
ae93efb17a | |||
d95dfb18fd | |||
4e3c397ce5 | |||
4e6126405f | |||
8cdec543e1 | |||
4810cbe138 | |||
8ec7fbb49e | |||
7d52ed8802 | |||
9d44d063eb | |||
d5eb9ed478 | |||
40afb6cdc2 | |||
74234476ab | |||
82c71a3bd8 | |||
5161e1c045 | |||
40052dbf3f | |||
e73d92754e | |||
6df1b80941 | |||
a9e5963b74 | |||
95671966cd | |||
a8ce7216e1 | |||
5c6829165b | |||
91eebfd895 | |||
72cc04342f | |||
75267294f9 | |||
f81d302c9a | |||
c3ab0406e4 | |||
fdcaf4e596 | |||
ca7b3eff29 | |||
f1eb640564 | |||
194ca2d380 | |||
976e90f0a0 | |||
2c836f473d | |||
f834b6046e | |||
e6087f3818 | |||
20c3df6be2 | |||
b914e4b548 | |||
f336489609 | |||
4ce2e88568 | |||
a917a6a9cd | |||
a01eabea91 | |||
605f0da751 | |||
6bd0c10ef2 | |||
a9032602bf | |||
8c03601bd2 | |||
afc4c0ca1f | |||
e0ee8a7040 | |||
e32336aff8 | |||
0edbba5625 | |||
eec5350926 | |||
20f0b3f782 | |||
5cf4128c49 | |||
47768acf5c | |||
f88d2177c3 | |||
9373f10d68 | |||
4f3bb6ac93 | |||
5f224a077c | |||
14cdeb0b5a | |||
b02137c216 | |||
7c90103af4 | |||
903af03d15 | |||
b57ca4d207 | |||
2fe58941ea | |||
04f734bebe | |||
a0d43ebe0e | |||
6d80dce66d | |||
3d765dd701 | |||
2b42c64160 | |||
7928131112 | |||
9cb1f9647c | |||
6d6daa60b6 | |||
81a454c29c | |||
6f245d9b7f | |||
05c001067e | |||
fea57a4034 | |||
00eebf9260 | |||
cde18c8d35 | |||
0b2c3fa96e | |||
8f631cfe4b | |||
f10b25c07f | |||
77a959fe29 | |||
d8db111d30 | |||
c2811f2818 | |||
b258a3ff9c | |||
02029d22b0 | |||
1f7f1c170d | |||
a13a4a5695 | |||
0b9dcaa8f1 | |||
9c7030f80e | |||
d8112550f5 | |||
4eb662d314 | |||
8e06ffc3b1 | |||
98c5c052de | |||
95fe0c9516 | |||
2908b1449c | |||
454b461e89 | |||
0a8d2ad233 | |||
35e34e44ee | |||
b6ce1f62e0 | |||
55eaa85979 | |||
b3f5c532dd | |||
0821565a75 | |||
d187ad43f3 | |||
b5aff6a8eb | |||
a6291b3ee2 | |||
f1f86e04e6 | |||
06898ca0af | |||
305f8317fe | |||
d7d13dd523 | |||
84dd9dbcea | |||
a345fa8874 | |||
5780d3ca21 | |||
4c220cbb36 | |||
942f9296a0 | |||
fb50f2783f | |||
a50ddd25b2 | |||
4b6d5a86b2 | |||
fbada0c4be | |||
6a8459cc4e | |||
fce9e9a73f | |||
8ab3c937b6 | |||
f8e431cc2e | |||
3f7c069ce0 | |||
21895d307b | |||
38b0eec741 | |||
2496f19bee | |||
21932dc329 | |||
35fc287d55 | |||
3a3623859b | |||
f623e78bdc | |||
2bcc14888c | |||
7bee6cf1ea | |||
eea264a099 | |||
b99d872c53 | |||
f09d1b5da1 | |||
9e3ff74b98 | |||
2e64e31a8f | |||
150f9d6c08 | |||
a6565aae53 | |||
ac268c0672 | |||
94902c661f | |||
0a90e1fe4a | |||
9f1a09689f | |||
af68d9b0cf | |||
d75b7de20b | |||
f968e618ac | |||
fb9717a00f | |||
0acdf41fa3 | |||
f5fddd0369 | |||
660f801afd | |||
da66118d20 | |||
93d1de941c | |||
94106a11c0 | |||
76f0ee3ef0 | |||
712792ac9f | |||
56424cf0d1 | |||
9230bd8115 | |||
ab0d34599f | |||
0c4ee6a033 | |||
f5b80b6e63 | |||
63f4a8310e | |||
53176a9a26 | |||
8422243465 | |||
91317b7a41 | |||
cbcc6f812a | |||
a53a3d595c | |||
d741035707 | |||
bab02110b0 | |||
1db4e10dc8 | |||
d6a87bc426 | |||
d8096a3695 | |||
0927695261 | |||
97380e9833 | |||
2c64581a2c | |||
05a00e8ce0 | |||
d056bd0bd2 | |||
fa187be88a | |||
357ccca819 | |||
993f49c0a0 | |||
3b180cda83 | |||
1a877bbfa1 | |||
c3bbd75c65 | |||
03a6e537b8 | |||
401a1480d6 | |||
5c75b2cb38 | |||
2137043c8c | |||
a919f51fc0 | |||
16d85a5a41 | |||
0ccf46456a | |||
2f20961395 | |||
f3318e0dd0 | |||
7843090907 | |||
29ceca055e | |||
076f64788a | |||
b9dca52e52 | |||
2ac306ec15 | |||
999bfae344 | |||
0994743fd8 | |||
8b0070efd4 | |||
82ed352c1d | |||
2a975123fc | |||
5d6a66dcac | |||
8c1197e8e1 | |||
6db4ba7082 | |||
609bccefe1 | |||
ff35e480f2 | |||
b32ccb48be | |||
db6c6de8e9 | |||
6f69fe2545 | |||
05a4491bb2 | |||
27334858c9 | |||
a8bdfef271 | |||
b59d64682e | |||
d3d4add5a2 | |||
fa4dd48955 | |||
dce50b226f | |||
a0aa04e036 | |||
2670bb8f6d | |||
b0642aafb7 | |||
3901a2a281 | |||
2403881a7c | |||
758907a660 | |||
70a511a141 | |||
86aa453093 | |||
be6fb7bd75 | |||
0ab5b873f1 | |||
06dbc71a1d | |||
a51b25208f | |||
cb00ff7c5d | |||
43b762dd2a | |||
ba40b74230 | |||
da9425228e | |||
2ba4233ac7 | |||
1545bf39ee | |||
ff4496be24 | |||
bf7e602e4a | |||
a66430c255 | |||
689d7bf0a9 | |||
6d1417ab73 | |||
a60edfdd37 | |||
a28c088c06 | |||
acb57bffb4 | |||
35c2e07261 | |||
14a2313e5f | |||
1f75ba41cf | |||
77109fd3cc | |||
21570ea5ec | |||
2b8ed2192b | |||
1e5cf55521 | |||
87db7ddd98 | |||
09d7bd4fae | |||
38e56254ff | |||
c5246e73ca | |||
120da86904 | |||
02f1ab0e4a | |||
9465cf03ac | |||
7168b874aa | |||
67f2eec4eb | |||
50a23afe7a | |||
d57c07affd | |||
d5c975d0b6 | |||
febf9f2c3e | |||
cfadede201 | |||
9988c4daf6 | |||
6b4feb3b91 | |||
b4625335b6 | |||
0d7bae5be8 | |||
11b4aaad6e | |||
589a7da53b | |||
71ce8597e5 | |||
7ef1ba10a9 | |||
b8df7e9603 | |||
73d2d4a95d | |||
0f68d2d0fc | |||
9083fc65d4 | |||
9604869639 | |||
0c0238ee20 | |||
0763168367 | |||
9490952d6c | |||
9a576d70e4 | |||
0530b450ce | |||
17e90c4761 | |||
200d476462 | |||
e7d1044716 | |||
44df84e286 | |||
f8738c64b7 | |||
fdfeb2a90b | |||
2804400910 | |||
9d2fc5bc6e | |||
536aea6c48 | |||
c64ca0c814 | |||
86c9ac93d5 | |||
e1f25475b1 | |||
6cd4b6c549 | |||
81f7a5f25b | |||
a10064c205 | |||
f1b9be44f4 | |||
14ca2b6687 | |||
e78dacd029 | |||
87b420e21e | |||
da3374a484 | |||
b151eed4b6 | |||
f0513c19b8 | |||
ee0219b39a | |||
a93d334b1f | |||
59803d547c | |||
8dcee29952 | |||
53d5a09fb4 | |||
acdfae1608 | |||
4442931dd4 | |||
1aeab0aef5 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
*.py.bak
|
||||
*.pyc
|
||||
*~
|
||||
src/config/
|
||||
|
101
.gitlab-ci.yml
101
.gitlab-ci.yml
@@ -1,47 +1,105 @@
|
||||
# Jobs to build the two channels in Socializer.
|
||||
alpha:
|
||||
variables:
|
||||
PYTHON3: "C:\\python37\\python.exe"
|
||||
PYINSTALLER: "C:\\python37\\scripts\\pyinstaller.exe"
|
||||
PYTHON2: "C:\\python27\\python.exe"
|
||||
NSIS: "C:\\nsis\\makensis.exe"
|
||||
|
||||
test_py3:
|
||||
stage: test
|
||||
tags:
|
||||
- windows10
|
||||
before_script:
|
||||
- '%PYTHON3% -V'
|
||||
- '%PYTHON3% -m pip install --upgrade pip'
|
||||
- '%PYTHON3% -m pip install --upgrade -r requirements.txt'
|
||||
only:
|
||||
- schedules
|
||||
script:
|
||||
- cd src
|
||||
- '%PYTHON3% -m coverage run run_tests.py'
|
||||
- '%PYTHON3% -m coverage report --omit="test*"'
|
||||
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
|
||||
|
||||
documentation:
|
||||
type: deploy
|
||||
tags:
|
||||
- windows
|
||||
- windows10
|
||||
before_script:
|
||||
- '%PYTHON3% -v'
|
||||
script:
|
||||
- pip install --upgrade pip
|
||||
- pip install --upgrade -r requirements.txt
|
||||
- copy changelog.md doc\changelog.md
|
||||
- cd doc
|
||||
- python documentation_importer.py
|
||||
- '%PYTHON2% 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
|
||||
- '%PYTHON2% ..\doc\generator.py'
|
||||
- 'move documentation ..\'
|
||||
only:
|
||||
- master
|
||||
artifacts:
|
||||
paths:
|
||||
- documentation
|
||||
name: socializer_documentation
|
||||
expire_in: 1 day
|
||||
|
||||
alpha_python3:
|
||||
type: deploy
|
||||
tags:
|
||||
- windows10
|
||||
before_script:
|
||||
- '%PYTHON3% -v'
|
||||
- '%PYTHON3% -m pip install --upgrade pip'
|
||||
- '%PYTHON3% -m pip install --upgrade -r requirements.txt'
|
||||
- '%PYTHON3% -m pip uninstall enum34 -y'
|
||||
script:
|
||||
- copy changelog.md doc\changelog.md
|
||||
- cd doc
|
||||
- '%PYTHON2% documentation_importer.py'
|
||||
- cd ..\src
|
||||
- '%PYTHON2% ..\doc\generator.py'
|
||||
- '%PYTHON3% write_version_data.py'
|
||||
- '%PYINSTALLER% main.spec'
|
||||
- cd ..
|
||||
- cd scripts
|
||||
- '%PYTHON3% prepare_zipversion.py'
|
||||
- call genpot_interface.bat
|
||||
- call genpot_doc.bat
|
||||
- cd ..
|
||||
- move src\socializer.zip socializer.zip
|
||||
- move scripts\socializer.pot socializer.pot
|
||||
- move scripts\socializer-documentation.pot socializer-documentation.pot
|
||||
only:
|
||||
- schedules
|
||||
artifacts:
|
||||
paths:
|
||||
- socializer.zip
|
||||
name: socializer
|
||||
expire_in: 1 week
|
||||
- socializer.pot
|
||||
- socializer-documentation.pot
|
||||
name: socializer_py3
|
||||
expire_in: 1 day
|
||||
|
||||
stable:
|
||||
type: deploy
|
||||
tags:
|
||||
- windows
|
||||
before_script:
|
||||
- '%PYTHON3% -v'
|
||||
- '%PYTHON3% -m pip install --upgrade pip'
|
||||
- '%PYTHON3% -m pip install --upgrade -r requirements.txt'
|
||||
- '%PYTHON3% -m pip uninstall enum34 -y'
|
||||
script:
|
||||
- pip install --upgrade pip
|
||||
- pip install --upgrade -r requirements.txt
|
||||
- copy changelog.md doc\changelog.md
|
||||
- cd doc
|
||||
- python documentation_importer.py
|
||||
- '%PYTHON2% documentation_importer.py'
|
||||
- cd ..\src
|
||||
- python ..\doc\generator.py
|
||||
- python setup.py py2exe
|
||||
- '%PYTHON2% ..\doc\generator.py'
|
||||
- '%PYTHON3% write_version_data.py'
|
||||
- '%PYINSTALLER% main.spec'
|
||||
- '%NSIS% installer.nsi'
|
||||
- cd ..
|
||||
- move src\socializer* .
|
||||
- cd scripts
|
||||
- python prepare_zipversion.py
|
||||
- '%PYTHON3% prepare_zipversion.py'
|
||||
- cd ..
|
||||
- move src\socializer.zip socializer.zip
|
||||
only:
|
||||
@@ -49,4 +107,5 @@ stable:
|
||||
artifacts:
|
||||
paths:
|
||||
- socializer.zip
|
||||
- "socializer_*"
|
||||
name: socializer
|
15
README.md
15
README.md
@@ -6,24 +6,13 @@
|
||||
|
||||
A desktop application for handling [vk.com](http://vk.com) in an easy way.
|
||||
|
||||
## download the current build
|
||||
|
||||
Socializer's functionality is far to be perfect, in fact there are lots of methods of the VK API that this application doesn't support right now, but if you are curious enough, and you want to help by giving me your impressions and making tests for fixing bugs, you can download the last source code, compiled as an application. This is the snapshot build of socializer. This version is only for testing purposes, never think that it can be used for everyday use. This version does not include any documentation, Only the changelog, because it's build with an authomatic process.
|
||||
|
||||
Before downloading, take in to account the following: This source code is completely experimental. The current functionality in this application is not very useful. If you decide to use nightly build versions, take into account that this doesn't work as an application for everyday use yet.
|
||||
|
||||
Version: 0.16
|
||||
Build date: Dec 14 2018
|
||||
[Download socializer](https://code.manuelcortez.net/manuelcortez/socializer/-/jobs/artifacts/master/raw/socializer.zip?job=alpha)
|
||||
|
||||
I have started this effort as an open source project on Feb 13, 2016. Pull requests and bug reports are welcome.
|
||||
[See Socializer's website](http://socializer.su)
|
||||
|
||||
## dependencies not installed by PIP
|
||||
|
||||
For other dependencies, do pip install --upgrade -r requirements.txt
|
||||
|
||||
* [Python,](http://python.org) version 2.7.15
|
||||
* [PyEnchant,](http://pythonhosted.org/pyenchant/) version 1.6.6.
|
||||
* [Python,](http://python.org) version 3.7.2
|
||||
|
||||
## Documentation
|
||||
|
||||
|
128
changelog.md
128
changelog.md
@@ -1,6 +1,132 @@
|
||||
# Changelog
|
||||
|
||||
## changes in this version
|
||||
## News in this version
|
||||
|
||||
### New additions
|
||||
|
||||
* Added "post in groups" feature. In order to do so, you need to load the posts for the group where you want to send something. Once loaded, go to the post button in the group's wall and select whether you want to post in the group's behalf or as yourself.
|
||||
* In all audio buffers, it is possible to select individual tracks to be played together. In order to do so, you need to press space to start the selection of items. When selected, the item will emit a sound to indicate the change. Press space in all items you want to select/unselect. When you're focusing an already selected item it will play a sound to indicate that it is already selected. Once you're done with your selection, pressing enter in the list of tracks will start the playback of the list of items you have selected. This is a very experimental feature. More actions can be supported based in this selection method if it proves to be useful.
|
||||
* In conversation buffers, it is possible to display and open wall posts sent as attachments in messages.
|
||||
* In people buffers, it is possible to create a new timeline by using the context menu while focusing an user. This method will create the buffer for the selected user, as opposed to creating the buffer from the menu bar, where you have to type the username or find it in a list.
|
||||
|
||||
### bugfixes
|
||||
|
||||
* Fixed an error with two factor authentication in the recent socializer version. Now it works reliably again.
|
||||
* Fixed an error when trying to attach a photo to a wall post. The error was fixed in the [vk_api](https://github.com/python273/vk_api) module and the fix was sent to the developer of the library, so he will be able to merge it in the next version. In the meantime, socializer already includes the fix for this method, so you can upload photos to wall posts normally.
|
||||
* Fixed an error retrieving some group information for the current session.
|
||||
* When posting in a topic, links will be posted properly.
|
||||
|
||||
|
||||
### Changes
|
||||
|
||||
* the audio player module has received some improvements:
|
||||
- When there is something being played, the label of the "play" button, located in all audio buffers, will change automatically to "pause". When pressed, it will pause the song instead of starting the playback again since the beginning.
|
||||
- The last change will work also in the dialog for displaying audio information. Now it's possible to play and pause an audio from such dialog.
|
||||
- When playing a voice message, if a song is playing already socializer will decrease the volume so you can hear the voice message well enough. Some seconds after the message has finished, the song's volume will be restored.
|
||||
* In audio buffers, you will play the focused audio when pressing enter in the item, instead of opening the audio information dialog.
|
||||
* Removed some old keystrokes in socializer buffers due to better alternatives. The reason for this change is that currently you don't need to be focusing an item in a buffer for being able to use the alternative keystrokes, which makes those a better implementation.
|
||||
- Control+Enter and control+Shift+Enter: superseeded by Control+P for playing (and pausing) the currently focused audio.
|
||||
- F5 and F6: superseeded by Alt+down and up arrows for modifying volume.
|
||||
|
||||
## changes in version 0.20 (25.04.2019)
|
||||
|
||||
### New additions
|
||||
|
||||
* For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define which soundcard will be used for input and output. [#25,](https://code.manuelcortez.net/manuelcortez/socializer/issues/25)
|
||||
* the audio player can seek positions in the currently playing track. You can use the menu items (located in the main menu) or use the new available keystrokes dedicated to the actions. Seeking will be made in 5 second intervals.
|
||||
* Alt+Shift+Left arrow: Seek 5 seconds backwards.
|
||||
* Alt+Shift+Right arrow: Seek 5 seconds forwards.
|
||||
* it is possible to select the language used in socializer from the preferences dialog. When changing the language, the application must be restarted for the changes to take effect.
|
||||
* A new option, called open in vk.com, has been added in the context menu for almost all objects (items in home timeline, walls, documents, people, group topics and in buffers for conversations). This option will open the selected item in the VK website.
|
||||
* when opening the list of friends added by an user, you can display the context menu from an item on the list and view the user profile, open it in VK.com, among other actions. [#8,](https://code.manuelcortez.net/manuelcortez/socializer/issues/8)
|
||||
* When displaying a post, if you press enter in the button indicating how many people liked or shared the post, Socializer will display the listt of people who have liked or shared it. You can use the context menu in the list to do certain actions. [#38,](https://code.manuelcortez.net/manuelcortez/socializer/issues/38)
|
||||
* it is possible to retrieve more items for conversation buffers. Due to API limitations, it is possible to load up to the last 600 messages for every conversation. Take into account that the process of loading more items takes some time. You will hear a message when the process is done.
|
||||
* It is possible to delete entire conversations from the buffer's tree, by using the menu key and selecting "delete conversation". The conversation will be removed from VK.
|
||||
* When loading a topic in a group, socializer will display the latest 100 messages. In order to load more messages, you will find a button that will load the previous 100 messages present in the topic, or the amount of messages not loaded yet.
|
||||
|
||||
### bugfixes
|
||||
|
||||
* All spelling dictionaries are included by default for the following languages: Russian, English, German, French, italian, Polish, spanish and Turkish. Before, some dictionaries were missing and the spelling checker was failing.
|
||||
* Fixed an error in the default configuration template used for new sessions in the application. This error was making Socializer to fail when loading any conversation buffer.
|
||||
* Fixed an error in the algorithm to detect friends disconnecting from VK. This problem was interrupting the connection with the chat server every time it was happening, thus chat server's connection should be more reliable now.
|
||||
* The audio player should behave better in situations where a song is interrupted. Before, if you pressed "next song" while the currently playing sound was interrupted due to internet connection issues, two or more songs were played at the same time.
|
||||
* The bug reporting feature works normally again.
|
||||
|
||||
### Changes
|
||||
|
||||
* Updated method for accessing audio files due to the latest changes on VK apps.
|
||||
* When changing volume of the playing audio, it will decrease or increase the volume by 2% instead of 5%.
|
||||
* Read confirmations will be sent to VK as soon as you read the message. Before, read confirmations were being sent every 3 minutes to the social network.
|
||||
|
||||
## Changes in version 0.19 (13.03.2019)
|
||||
|
||||
* Added a new buffer called documents. When loading the buffer, it will contain all documents owned by the current user. The context menu of any item will allow you to download the document to your computer or remove it from VK.
|
||||
* A new buffer, called online, has been added in the friends section. It contains friends currently connected to VK. Items in this buffer will be added as soon as new friends are online in the social network, and will be removed when friends are offline. This buffer needs a lot of testing. Please report any possible inconsistency on this method.
|
||||
* Added new options to open the config and logs folder, these options are located in the help menu and may be useful during error reporting.
|
||||
* Added experimental support to "subscribers" buffer, inside frienship requests. This shows friend requests that have been declined by the current user.
|
||||
* the message when an user is typing in conversation buffers will be announced only if the socializer window is focused.
|
||||
* In "my audios" buffer, there is a button that allows a direct audio upload from your computer. The audio will be placed in your library.
|
||||
* Added experimental support to user and community polls:
|
||||
* If the poll is already closed or the user has send a vote to the poll previously, it will display only the results of the poll.
|
||||
* Otherwise it will display a dialog from where the user can vote in the current poll.
|
||||
* Fixed an error in Socializer that was making it unable to detect unread messages properly.
|
||||
* Socializer should save all tracebacks directly to error.log instead of displaying an error message during exit. ([#27,](https://code.manuelcortez.net/manuelcortez/socializer/issues/27))
|
||||
* When displaying user profiles, fixed an error where a married person without specifing relation partner would cause an error in the program. ([#29,](https://code.manuelcortez.net/manuelcortez/socializer/issues/29))
|
||||
* Socializer will load all conversations during startup, not only conversations with unread messages.
|
||||
* Added new global keystrokes, available in the main window.
|
||||
* Alt + up/down arrows: Increase / decrease volume.
|
||||
* Alt + Left/down arrows: Play previous and next song if playing an audios buffer.
|
||||
* Control + P: Play/pause.
|
||||
* control+Shift+P: Play all.
|
||||
* Fixed an error in the audio player that was skipping the first track if you were in the last song and pressed "play next" in the menu bar or via the keystroke.
|
||||
* Chats with unread messages will be placed at the top of the chats section. When a chat buffer receives a new message, socializer will move the buffer to the first position in the chats list. This should make easier for everyone to determine which chats contain unread items. ([#24,](https://code.manuelcortez.net/manuelcortez/socializer/issues/24))
|
||||
* In dialogs for displaying posts and comments, and also in the two edit boxes present in chat buffers, it is possible to select all by pressing Control+A.
|
||||
* Now it is possible to remove friends directly from the friends buffer. There is a new option for this purpose in the context menu for the focused friend. After being removed, the person will be placed in the subscribers buffer.
|
||||
* Deleted posts will display an error message when trying to view details about those. Before, the dialog was created and left blank.
|
||||
* Improvements in audio features present in Socializer:
|
||||
* The audio search feature has received improvements: Now it is possible to indicate wether the search will be performed by title or artist, and select to sort the results by duration, popularity or date of addition to VK.
|
||||
* Now it is possible to create and delete audio albums again.
|
||||
* Fixed errors when moving songs to albums. Now everything works as expected.
|
||||
* Added documents to the list of supported files when adding attachments to a wall post or private message.
|
||||
* It is possible to enable or disable proxy from the preferences dialog. The application must be restarted for this change to take effect.
|
||||
* Fixed an error that was making Socializer unable to display the changelog properly, when opened from the help menu. ([#21](https://code.manuelcortez.net/manuelcortez/socializer/issues/21))
|
||||
* When receiving chat messages and in some other situations, socializer will display all characters properly. Before, usernames were rendered using the internal code VK uses for them, and some unicode characters were displaying their HTML representation.
|
||||
* It is possible to retrieve previous items for the home buffer and walls (current user's wall and any other timeline):
|
||||
* For the home buffer, only a limited amount of items (around 700) can be loaded, supposedly due to VK API limits.
|
||||
* For walls, all posts should be possible to be loaded, however, testing with walls containing more than 2000 posts are not performed yet.
|
||||
* Added improvements to groups:
|
||||
* It is possible to load topics, audios, videos and documents for a group. In order to do so, you need to go to the group buffer and press the menu key, or right mouse click, in the tree item representing the group. New buffers will be created inside the current group's buffer.
|
||||
* You can create or delete all buffers for groups by pressing the menu key or right mouse click in the "communities" buffer.
|
||||
* There is support for group topics. When opening them, they will be displayed as a list of posts. You can like or reply to such posts, as well as adding new posts in the topic.
|
||||
* Authentication errors should be handled gracefully by the application:
|
||||
* When there is a password change, Socializer must be reauthorized again. An error message will indicate this if the user forgot to do that. After the error, the app will be restarted, prompting the user to introduce the new data for authorizing the application.
|
||||
* If the user introduced incorrect or invalid data, Socializer will display an error and prompt the user again for valid information.
|
||||
* If there is a connection problem when opening Socializer, it will display an error and inform the user about the issue.
|
||||
|
||||
## Changes in version 0.18 (21.01.2019)
|
||||
|
||||
* Changed authentication tokens in Socializer. It is mandatory to download a fresh copy of socializer and start a new configuration for your account.
|
||||
* Stable versions of Socializer are built with Python 3. Previous versions are built with Python 2, however support for Python 2 will be dropped very soon.
|
||||
* There is an installer file for Socializer, available in our downloads page. Installed version of Socializer will be more confortable for some people.
|
||||
* For users from countries where VK is not allowed, Socializer includes a proxy to bypass country restrictions. The first time you start socializer, it will ask you whether you need a proxy or not. It is suggested to use a proxy only if you need it.
|
||||
* Now it is possible to post in someone else's wall. When viewing a timeline of an user, the "post" button will post in his/her wall. To post in your own wall, you'll need to go to the newsfeed or your own wall and press the post button.
|
||||
* If you are not allowed to post in someone's wall, the post button will not be visible.
|
||||
* A new option for deleting wall posts has been added to the context menu in newsfeed and walls (current user's wall and timelines). This option will be visible only if the current user is allowed to delete the focused post.
|
||||
* Socializer will be able to handle all users correctly. Before, if an user that was not present in the local storage system was needed, the program was displaying "no specified user". ([#17,](https://code.manuelcortez.net/manuelcortez/socializer/issues/17))
|
||||
* It is possible to use user domains (short names for users) to create timelines. Just write @username and the program will create the needed timeline, regardless if the user is present in your friend list. ([#18,](https://code.manuelcortez.net/manuelcortez/socializer/issues/18))
|
||||
* When displaying someone's profile, the dialog should be loaded dramatically faster than before. A message will be spoken when all data of the profile is loaded.
|
||||
* When opening a timeline, if the current user is not allowed to do it, an error message should be displayed and the buffer will not be created. Before the buffer was partially created in the main window. ([#22.](https://code.manuelcortez.net/manuelcortez/socializer/issues/22))
|
||||
* Added basic support to handle group chats. At the current moment it is possible to receive and reply to chat messages only. Chat groups will be placed inside the conversations section. ([#23.](https://code.manuelcortez.net/manuelcortez/socializer/issues/23))
|
||||
* It is possible to delete a conversation buffer from the buffer menu. Deleting a conversation will only dismiss the buffer, no data is deleted at VK.
|
||||
* During the first start of Socializer, an invitation will be shown to join the Socializer's group in case the current user is not already a member.
|
||||
* It is possible to see how many people has read a wall post when showing it in the dialog. ([#28.](https://code.manuelcortez.net/manuelcortez/socializer/issues/28))
|
||||
* A new tab has been added to the preferences dialog. From the new section, it is possible to control whether socializer should create buffers for the first 1000 audio albums, video albums and communities when starting.
|
||||
* Added functionality regarding comments in wall posts:
|
||||
* when reading a post, you can press enter in any comment to display a dialog from where it is possible to view attachments, translate, check spelling or reply to the thread. If there are replies made to this comment, these will be visible in a section called replies. Pressing enter in a reply will also open the same dialog.
|
||||
* A new "replies" field has been added to the comments' list.
|
||||
* When writing a comment, it is possible to do the same actions available for a post (translate, spell checking and adding attachments).
|
||||
|
||||
## Changes in version 0.17 (01.01.2019)
|
||||
|
||||
* 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:
|
||||
|
@@ -9,7 +9,7 @@ import strings
|
||||
import changelog
|
||||
|
||||
# the list of supported language codes
|
||||
languages = ["en", "es"]
|
||||
languages = ["en", "ru", "es"]
|
||||
|
||||
def generate_document(language, document_type="documentation"):
|
||||
reload(languageHandler)
|
||||
@@ -18,14 +18,14 @@ def generate_document(language, document_type="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]
|
||||
title = strings.documentation[0][1:]
|
||||
filename = "manual.html"
|
||||
elif document_type == "changelog":
|
||||
translation_file = "socializer-changelog"
|
||||
translation_file = "socializer-documentation"
|
||||
languageHandler.setLanguage(language, translation_file)
|
||||
reload(changelog)
|
||||
markdown_file = markdown.markdown("\n".join(changelog.documentation[1:]), extensions=["markdown.extensions.toc"])
|
||||
title = changelog.documentation[0]
|
||||
title = changelog.documentation[0][1:]
|
||||
filename = "changelog.html"
|
||||
first_html_block = """<!doctype html>
|
||||
<html lang="%s">
|
||||
|
@@ -1,18 +1,17 @@
|
||||
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).
|
||||
* (limited) audio support. (*)
|
||||
* Supports two factor authentication (2FA).
|
||||
* Post creation in user and community walls.
|
||||
* audio support.
|
||||
* Post comments.
|
||||
* like, unlike and repost other's posts.
|
||||
* Open other's timelines so you could track their friends, posts or audio files.
|
||||
* Basic chat features.
|
||||
|
||||
\* Audio support in socializer is limited due to the restrictions VK has decided to apply for third party applications on december 2016.
|
||||
|
||||
## Usage
|
||||
|
||||
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.
|
||||
@@ -21,7 +20,11 @@ In order to use socializer, you must have an account in the [VK](https://vk.com)
|
||||
|
||||
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.
|
||||
If this is the first time you have launched socializer, you will see a message asking you whether socializer should connect through a proxy server, already configured in the application, or use the system network settings. This allows people from countries where VK is blocked to use the social network without having to look for a proxy server themselves. It is highly adviced to use the proxy server only if you are in need of it.
|
||||
|
||||
After the proxy message, you will see a new message dialog asking you to proceed with the account authorisation process. It consists in providing the authentication data you normally use to sign in VK. It is very important to know that this data will be stored in a folder called config, located in the same folder where the socializer files are. Your config folder is a very important storage for your authentication data, so you must be sure you never will share it with anyone, mostly because your data is stored as plain text (this will be fixed in a future release and your data will be properly encrypted). Socializer will need your authentication data for acting in your behalf and offering you a better experience that what it could do with a simple access token. You must provide your phone number or email address in the first text box, and your password in the second. When pressing OK, your data will be saved and the application will start to retrieve all the required information for showing your buffers. If you have two factor authentication configured in your account, you will see an additional dialog where you have to type the code provided by VK via SMS.
|
||||
|
||||
It is worth saying that whenever you change your password in the VK website, you will need to authorize Socializer again. When you open socializer after changing your password, you will see a message informing you of the problem and the application will be restarted, allowing you to write your new data and start the authorization again.
|
||||
|
||||
Once started, the application will start loading your data (posts, audio files, conversations, friends). When done, it will show you a notification indicating that the program is ready.
|
||||
|
||||
@@ -31,12 +34,12 @@ Before starting to describe Socializer's usage, we'll explain some concepts that
|
||||
|
||||
### Buffer
|
||||
|
||||
A buffer is a list of items that will manage the data which arrives from VK, after being processed by the application. When you configure your account on Socializer and start it, many buffers are created. Each of them may contain some of the items which this program works with: Newsfeed posts, wall posts, audio and video files, friendship requests and conversations. According to the buffer you are focusing, you will be able to do different actions with these items.
|
||||
A buffer is a list of items that will manage the data which arrives from VK, after being processed by the application. When you configure your account on Socializer and start it, many buffers are created. Each of them may contain some of the items which this program works with: Newsfeed posts, wall posts, audio and video files, documents, friendship requests and conversations. According to the buffer you are focusing, you will be able to do different actions with these items.
|
||||
|
||||
All buffers will be updated in one of the following ways:
|
||||
|
||||
* Periodically: Most buffers containing posts, audio or video files and people, will be updated periodically to reflect the new additions to them. Updates will be every 2 minutes for every buffer, so if you posted something and did not see the post in the buffer, you may need to wait a moment. There is an option, located in the buffer menu on the menu bar, which allows you to trigger a manual update in the current buffer.
|
||||
* Real time: Conversation buffers will be updated every time someone sends a message to you. When an user sends you a message, if there is not a conversation buffer created to receive the message, a new conversation buffer will be opened automatically and the message will be placed on it. If you already have an opened conversation for the user sending the message, the message will be placed at the end of the buffer. A different sound will indicate whether a new conversation has been opened or an existing buffer gets updated.
|
||||
* Real time: Conversation buffers will be updated every time someone sends a message to you. When an user sends you a message, if there is not a conversation buffer created to receive the message, a new conversation buffer will be opened automatically and the message will be placed on it. If you already have an opened conversation for the user sending the message, the message will be placed at the end of the buffer. A different sound will indicate whether a new conversation has been opened or an existing buffer gets updated. Socializer will sort conversation buffers by placing buffers with unread messages at the top of the conversations section. When a buffer gets a new message, it will be moved automatically to the first place in the conversations category.
|
||||
|
||||
### item
|
||||
|
||||
@@ -44,9 +47,9 @@ An item is an element representing some data provided by VK. Items are separated
|
||||
|
||||
The following is a brief description of the kind of items socializer can work with, and what actions are available for those.
|
||||
|
||||
* Newsfeed post: It represents a post displayed in your "home" page on VK. It may contain a variety of information based in what you or your friends do. A newsfeed item may contain information about new audios added to your friend's library, new people added to friends, wall posts, reposts and new photos added. Depending on the kind of data VK has supplied, the item can open a dialog showing information about the post, a list displaying the people added to friends, or a dialog displaying information for every audio added to library. 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.
|
||||
* Newsfeed post: It represents a post displayed in your "home" page on VK. It may contain a variety of information based in what you or your friends do. A newsfeed item may contain information about new audios added to your friend's library, new people added to friends, wall posts, reposts and new photos added. Depending on the kind of data VK has supplied, the item can open a dialog showing information about the post, a list displaying the people added to friends, or a dialog displaying information for every audio added to library. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. Available options for this item are different depending in the information the item contains. You can open or view the profile of the user that generated the item, like, dislike or add a comment to a post.
|
||||
* Wall post: Represent a post in an user's wall. This post will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. When opened (by pressing enter or the open option in the associated menu), it will show a dialogue where you can read the message, see how many times the post has been viewed by other users, interact with attachment files (by searching the list and pressing enter in the focused attachment to open it), see the photos included in the post, read information related to likes and times the post has been shared, read and reply to comments. Additionally, you can share the post, indicate you like it, or add a comment. You can cycle through every item in the dialog by pressing tab.
|
||||
* Audio: It represent an audio uploaded to the VK'S platform. Actions available for this item are opening the audio in a dialog, add or remove it from your library, move the audio to a playlist, and play it. When opened, it will be displayed in a dialog allowing you to read the title of the song, artist name, duration and a few buttons: play, add or remove from your library and download. You can control playback of audio items from the buffer by using the player menu on the menu bar or the corresponding keyboard shortcuts.
|
||||
* Video: It represent a video uploaded to the VK'S platform. Actions available for this item are opening the video in your default web browser and move it to a video album. When opened, it will open a web browser and play the video automatically due to VK limitations in access to video files.
|
||||
* person: It contains information about a VK user, this item is present in all buffers under the "people" category. Actions available for this item are view user profile, send message and create a timeline, which is a special buffer to track all posts, friends or audios owned by the user. When opened, it will display the profile of this user in a dialog and will provide actions to send a message to the user, or view other sections of her/his profile.
|
||||
* 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.
|
||||
@@ -56,8 +59,8 @@ The following is a brief description of the kind of items socializer can work wi
|
||||
The graphical user interface of Socializer consists of a window containing:
|
||||
|
||||
* a menu bar accomodating five menus (application, Me, buffer, player and help),
|
||||
* One tree view,
|
||||
* One list of items
|
||||
* One tree view, where you can press the menu key or right mouse click to display a context menu which contains actions you can apply in the selected buffer,
|
||||
* One list of items, which also accepts the menu key to display actions available for the selected item,
|
||||
* Some buttons, depending which is the focused buffer.
|
||||
|
||||
The actions that are available for every item will be described later.
|
||||
@@ -66,21 +69,22 @@ In summary, the GUI contains two core components. These are the controls you wil
|
||||
|
||||
### Buttons in the application
|
||||
|
||||
* Post: this button opens up a dialogue box to write a post in 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.
|
||||
* Post: this button opens up a dialogue box to write a post in the wall of the focused user. For example, if you are in the "my wall" buffer you will send a post to your own wall, but if you are in an user timeline the post will be sent to the owner of the timeline. You can upload an attachment by pressing the "attach" button and choosing between uploading a photo or audio file in the dialog which will appear, check spelling or translate your message by selecting one of the available buttons in the dialogue box. In addition, you can tag a friend in your post by pressing the corresponding button for that purpose. Also it is possible to configure the privacy settings for your post by allowing all users or just your friends to read it. Press the send button to send the post.
|
||||
* Load buffer: Some buffers are created but not loaded in VK. These special buffers need to be loaded manually by pressing the load button. Once loaded, this kind of buffers will behave in the same way other buffers do. Examples of these buffers are audio and video albums, community walls, and the current user's documents
|
||||
* Play: In audio buffers, plays the focused song. In video buffers, this button will open a web browser for playing the focused video, due to a limitation VK placed to third party developers with videos.
|
||||
* Play all: In audio buffers, play all songs starting from the focused buffer, until the last item in the list.
|
||||
* Send message: Send a message to a friend, which will open a conversation buffer if it does not exist already. Conversation buffers contain a full conversation, accommodating chat messages, between the current user and someone else. You can type your message in the provided box and press enter to send it to your friend. Additionally, you can 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.
|
||||
* Send message: Send a message to a friend, which will open a conversation buffer if it does not exist already. Conversation buffers contain a full conversation, accommodating chat messages, between the current user and someone else. You can type your message in the provided box and press enter to send it to your friend. Additionally, You can upload an attachment by pressing the "attach" button and choosing between uploading a photo, audio file or record a voice message in the dialog which will appear, and open attachments sent in the focused message by pressing tab and finding them in the attachments list.
|
||||
|
||||
Bear in mind that buttons will appear according to which actions are possible on the list you are browsing.
|
||||
|
||||
## Menus
|
||||
|
||||
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.
|
||||
Visually, Towards the top of the main application window, A menu bar can be found 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: opens a menu where you can create a new album. At the moment, only video albums are supported.
|
||||
* Delete: opens a menu where you can delete an already existing album owned by yourself. Only video albums are supported at this time.
|
||||
* Create: opens a menu where you can create a new album. At the moment, only audio and video albums are supported.
|
||||
* Delete: opens a menu where you can delete an already existing album owned by yourself. Only audio and video albums are supported at this time.
|
||||
* Preferences: Opens a dialogue which lets you configure settings for the entire application.
|
||||
|
||||
### Me menu
|
||||
@@ -88,6 +92,7 @@ Visually, Towards the top of the main application window, can be found a menu ba
|
||||
* 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.
|
||||
* Set status message: Opens up a dialog where you can write your status message. The status message is displayed in your profile and can contain up to 140 characters.
|
||||
|
||||
### Buffer menu
|
||||
|
||||
@@ -115,14 +120,42 @@ Visually, Towards the top of the main application window, can be found a menu ba
|
||||
* Documentation: opens up this file, where you can read some useful program concepts.
|
||||
* Check for updates: every time you open the program it automatically checks for new versions. If an update is available, it will ask you if you want to download the update. If you accept, the updating process will commence. When complete, Socializer will be restarted. This item checks for new updates without having to restart the application.
|
||||
* Changelog: opens up a document with the list of changes from the current version to the earliest.
|
||||
* Open logs directory: Opens windows explorer in the logs directory, useful to include your logs in a bug report.
|
||||
* Open config directory: Opens Windows explorer in your config directory.
|
||||
* Report an error: opens up a dialogue box to report a bug by completing a small number of fields. Pressing enter will send the report. If the operation doesn't succeed the program will display a warning.
|
||||
|
||||
## Keyboard shortcuts
|
||||
|
||||
Socializer includes some keyboard shortcuts, available from any buffer. Here you have the list of the available shortcuts:
|
||||
|
||||
* Enter: Execute the default action for the focused item. It may be opening a post, view friends added by someone else, view audio details or opening an user profile. You need to be in the items list for using this key.
|
||||
* Alt+Up/down: Increase and decrease audio volume by 5%.
|
||||
* Control+P: Play/pause. If this is the firt time you press this keystroke, it will automatically play all items present in the focused buffer or in your audios.
|
||||
* control+Shift+P: Play all audio tracks. If the currently focused buffer does not contain audio items, it will play all items present in your audios buffer.
|
||||
* Alt+Left: Play the previous song.
|
||||
* Alt+Right: Play the next song.
|
||||
|
||||
## configuration
|
||||
|
||||
### The general tab
|
||||
As described above, this application has a preferences dialogue accessible under the application menu. Here you have a brief description of the settings present in this dialogue.
|
||||
|
||||
### The chats tab
|
||||
### General tab
|
||||
|
||||
* Number of items to load for newsfeed and wall buffers: Allows you to specify how many items should be retrieved from VK in the newsfeed buffer and when opening walls for other users. Default and maximum is 100.
|
||||
* Number of items to load in video buffers: Allows you to specify how many items should be retrieved from VK in video buffers. Default and maximum is 200.
|
||||
* Load images in posts: Allows you to specify whether you want socializer to display all images when opening a post, or not. This can be useful for people with slow connections or not needing images.
|
||||
* Update channel: allows you to specify how often you will receive updates for the program. There are two update channels available: Alpha channel, which contains unstable versions of the application and gets updates almost dayly, and stable, which contain tested and more stable versions of the program, but gets updates once in a month, approximately.
|
||||
|
||||
### Chat settings tab
|
||||
|
||||
* Show notifications when users are online/offline: These two checkboxes allows you to specify if you want socializer to notify you when someone is connected or disconnected in the VK network.
|
||||
* Open unread conversations at startup: When enabled, Socializer will load any conversation with unread messages after started.
|
||||
* Move focus to new conversations: When enabled, new conversations will be focused automatically right after being created.
|
||||
* Notification type: This setting allows you to specify the notification type you prefer to use in socializer. The options are native and custom. Native notifications send a system notification every time someone is online or offline, while custom notifications play a sound and announce the notification in the screen reader only.
|
||||
|
||||
### Optional buffers tab
|
||||
|
||||
This section allows you to specify which buffers should be precreated every time socializer starts. This kind of buffers, namely audio playlists, video albums and communities, have a special way of being created. When a buffer of the previously mentioned types is created, the buffer is added to the corresponding section but no data is loaded from VK. In order to load the data for one of these buffers you have to press the load button present in the buffer. From this tab you can mark and unmark the buffers Socializer will create when it starts. By default, buffers for audio playlists, video albums and communities are not created automatically when Socializer starts.
|
||||
|
||||
## License and source code
|
||||
|
||||
@@ -132,14 +165,16 @@ The source code of the program is available at <https://code.manuelcortez.net/ma
|
||||
|
||||
## 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)
|
||||
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 team, [join the Socializer's community in VK.](https://vk.com/socializer.club) You can also visit [The project website.](http://socializer.su)
|
||||
|
||||
## Credits
|
||||
|
||||
Socializer is developed and mantained by [Manuel Cortez,](https://manuelcortez.net) with contributions by [Anibal Hernandez](https://dragodark.com)
|
||||
Socializer is developed and maintained by [Manuel Cortez,](https://manuelcortez.net) with contributions by [Anibal Hernandez](https://dragodark.com)
|
||||
|
||||
We would also like to thank the translators of Socializer, who have allowed the spreading of the application.
|
||||
|
||||
* English: Manuel Cortéz.
|
||||
* Spanish: Manuel Cortéz.
|
||||
* Russian: Valeria K.
|
||||
* Russian: Дарья Ратникова.
|
||||
|
||||
Special thanks to Дарья Ратникова, as she also manages the Socializer's community in VK, translates the website and the documentation into Russian.
|
@@ -1,18 +1,26 @@
|
||||
wxpython
|
||||
# Stay in wxPython 4.0.3 because 4.0.4 has some regressions in accessibility related components.
|
||||
wxpython==4.0.3
|
||||
pywin32
|
||||
pyenchant
|
||||
markdown
|
||||
vk_api
|
||||
# For the moment we will use the modified vk_api version that does not try to include enum34 and
|
||||
# already fixed the caption for wall uploaded photos.
|
||||
# Hopefully I can uncomment this in the near future when my changes will get merged upstream.
|
||||
#vk_api
|
||||
bs4
|
||||
configobj
|
||||
pypubsub==3.3.0
|
||||
pypubsub
|
||||
requests-oauthlib
|
||||
future
|
||||
arrow
|
||||
backports.functools_lru_cache
|
||||
yandex.translate
|
||||
mutagen
|
||||
mock
|
||||
# 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
|
||||
git+https://code.manuelcortez.net/manuelcortez/accessible_output2
|
||||
# Modified vk_api.
|
||||
git+https://github.com/manuelcortez/vk_api
|
@@ -2,6 +2,6 @@
|
||||
echo Generating file list..
|
||||
dir ..\src\*.py /L /B /S > %TEMP%\listfile.txt
|
||||
echo Generating .POT file...
|
||||
xgettext --language=Python -o socializer.pot --keyword=_ -d socializer -f %TEMP%\listfile.txt -c --no-location --no-wrap
|
||||
xgettext --language=Python --from-code=utf-8 -o socializer.pot --keyword=_ -d socializer -f %TEMP%\listfile.txt -c --no-location --no-wrap
|
||||
del %TEMP%\listfile.txt
|
||||
echo Done.
|
||||
|
@@ -1,13 +1,18 @@
|
||||
#! /usr/bin/env python# -*- coding: iso-8859-1 -*-
|
||||
import shutil
|
||||
import os
|
||||
import sys
|
||||
|
||||
def create_archive():
|
||||
os.chdir("..\\src")
|
||||
print "Creating zip archive..."
|
||||
shutil.make_archive("socializer", "zip", "dist")
|
||||
if os.path.exists("dist"):
|
||||
shutil.rmtree("dist")
|
||||
print("Creating zip archive...")
|
||||
if sys.version[0] == "3":
|
||||
folder = "dist/main"
|
||||
else:
|
||||
folder = "dist"
|
||||
shutil.make_archive("socializer", "zip", folder)
|
||||
# if os.path.exists("dist"):
|
||||
# shutil.rmtree("dist")
|
||||
if os.path.exists("build"):
|
||||
shutil.rmtree("build")
|
||||
os.chdir("..\\scripts")
|
||||
|
@@ -8,19 +8,325 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2016-06-29 13:33-0500\n"
|
||||
"POT-Creation-Date: 2019-01-19 10:28-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-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
|
||||
msgid "# Changelog"
|
||||
msgstr ""
|
||||
|
||||
msgid "## changes in this version"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Changed authentication tokens in Socializer. It is mandatory to download a fresh copy of socializer and start a new configuration for your account."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Stable versions of Socializer are built with Python 3. Previous versions are built with Python 2, however support for Python 2 will be dropped very soon."
|
||||
msgstr ""
|
||||
|
||||
msgid "* There is an installer file for Socializer, available in our downloads page. Installed version of Socializer will be more confortable for some people."
|
||||
msgstr ""
|
||||
|
||||
msgid "* For users from countries where VK is not allowed, Socializer includes a proxy to bypass country restrictions. The first time you start socializer, it will ask you whether you need a proxy or not. It is suggested to use a proxy only if you need it."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now it is possible to post in someone else's wall. When viewing a timeline of an user, the \"post\" button will post in his/her wall. To post in your own wall, you'll need to go to the newsfeed or your own wall and press the post button."
|
||||
msgstr ""
|
||||
|
||||
msgid "* If you are not allowed to post in someone's wall, the post button will not be visible."
|
||||
msgstr ""
|
||||
|
||||
msgid "* A new option for deleting wall posts has been added to the context menu in newsfeed and walls (current user's wall and timelines). This option will be visible only if the current user is allowed to delete the focused post."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Socializer will be able to handle all users correctly. Before, if an user that was not present in the local storage system was needed, the program was displaying \"no specified user\". ([#17,](https://code.manuelcortez.net/manuelcortez/socializer/issues/17))"
|
||||
msgstr ""
|
||||
|
||||
msgid "* It is possible to use user domains (short names for users) to create timelines. Just write @username and the program will create the needed timeline, regardless if the user is present in your friend list. ([#18,](https://code.manuelcortez.net/manuelcortez/socializer/issues/18))"
|
||||
msgstr ""
|
||||
|
||||
msgid "* When displaying someone's profile, the dialog should be loaded dramatically faster than before. A message will be spoken when all data of the profile is loaded."
|
||||
msgstr ""
|
||||
|
||||
msgid "* When opening a timeline, if the current user is not allowed to do it, an error message should be displayed and the buffer will not be created. Before the buffer was partially created in the main window. ([#22.](https://code.manuelcortez.net/manuelcortez/socializer/issues/22))"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added basic support to handle group chats. At the current moment it is possible to receive and reply to chat messages only. Chat groups will be placed inside the conversations section. ([#23.](https://code.manuelcortez.net/manuelcortez/socializer/issues/23))"
|
||||
msgstr ""
|
||||
|
||||
msgid "* It is possible to delete a conversation buffer from the buffer menu. Deleting a conversation will only dismiss the buffer, no data is deleted at VK."
|
||||
msgstr ""
|
||||
|
||||
msgid "* During the first start of Socializer, an invitation will be shown to join the Socializer's group in case the current user is not already a member."
|
||||
msgstr ""
|
||||
|
||||
msgid "* It is possible to see how many people has read a wall post when showing it in the dialog. ([#28.](https://code.manuelcortez.net/manuelcortez/socializer/issues/28))"
|
||||
msgstr ""
|
||||
|
||||
msgid "* A new tab has been added to the preferences dialog. From the new section, it is possible to control whether socializer should create buffers for the first 1000 audio albums, video albums and communities when starting."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added functionality regarding comments in wall posts:"
|
||||
msgstr ""
|
||||
|
||||
msgid " * when reading a post, you can press enter in any comment to display a dialog from where it is possible to view attachments, translate, check spelling or reply to the thread. If there are replies made to this comment, these will be visible in a section called replies. Pressing enter in a reply will also open the same dialog."
|
||||
msgstr ""
|
||||
|
||||
msgid " * A new \"replies\" field has been added to the comments' list."
|
||||
msgstr ""
|
||||
|
||||
msgid " * When writing a comment, it is possible to do the same actions available for a post (translate, spell checking and adding attachments)."
|
||||
msgstr ""
|
||||
|
||||
msgid "## Changes in version 0.17 (01.01.2019)"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added support for Two factor authentication (2FA). ([#13,](https://code.manuelcortez.net/manuelcortez/socializer/issues/13))"
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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:"
|
||||
msgstr ""
|
||||
|
||||
msgid " * 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."
|
||||
msgstr ""
|
||||
|
||||
msgid " * 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now it is possible to send voice messages from socializer. Voice messages are available from the \"add\" button in any conversation buffer."
|
||||
msgstr ""
|
||||
|
||||
msgid "* tokens generated by socializer will never expire. ([#3,](https://code.manuelcortez.net/manuelcortez/socializer/issues/3))"
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Audio albums are loaded correctly."
|
||||
msgstr ""
|
||||
|
||||
msgid "* It is possible to play audios added by friends appearing in the news feed."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Adding and removing an audio file to your library works."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Unread messages will play a sound when focused."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Unread messages will be marked as read when user focuses them."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now Socializer will not send a notification every 5 minutes."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added popular and suggested songs. This will not work when using alternative tokens."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now it is possible to update the status message, located in your profile."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Updated Russian translation: thanks to Дарья Ратникова."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Fixed some conditions, especially when rendering items in feeds, that were making the client to crash."
|
||||
msgstr ""
|
||||
|
||||
msgid "* new versions will include documentation and changelog."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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)"
|
||||
msgstr ""
|
||||
|
||||
msgid "## Changes in version 0.16 (13.12.2018)"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added two more buffers: \"Pending requests\" and \"I follow\", located in the people buffer, under \"friendship requests\"."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Improved the chat features present in the application. Read documentation to get a full understanding about how it works now."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added basic tagging for users in posts and comments. You can tag only people in your friends buffer."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added a basic user profile viewer."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added support for listening voice messages in chats. Currently it is not possible to send them."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* It is possible to play songs sent in a chat message by opening them from the attachments panel."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Reimplemented most of the audio playback methods (audio albums buffer still not working)."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added some notifications and chat notifications when friends are online and offline. Most notifications can be configured from settings."
|
||||
msgstr ""
|
||||
|
||||
msgid "## Changes in build 2016.07.08 (08/07/2016)"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Removed platform from \"last seen\" column in the friends list as it could cause some problems and it was being not so exact."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now deleted audios are not parsed and displayed as \"audio removed from library\". They are silently ignored."
|
||||
msgstr ""
|
||||
|
||||
msgid "* It's possible to open a friends timeline for others."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Fixed some strange bugs in the built version."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* When opened, socializer will try to create chat buffers for all unread messages."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Update some information on certain posts when an item is selected. For example, update the date of a post."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Included a brief manual in the help menu. Currently available only in English."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Included a context menu in list items. Currently there are functions not available. Menu for chat buffers is not implemented yet."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Implemented audio album load (in the music buffer), creation (in the application menu) and deletion (in the application menu, too)."
|
||||
msgstr ""
|
||||
|
||||
msgid "* audios can be moved to albums by pressing the menu key or doing a right click in the item, and selecting \"move to album\". Audios will be added to the album in the next update (there is a programmed update every 3 minutes), or you can update the buffer manually (from the buffer menu in the menu bar). This option will be available in audio buffers (searches, popular and recommended audio buffers, and audio timelines)."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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 "
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now is possible to press enter in the password or email/phone field and it'll do the action of the OK button."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Updated russian and spanish translations."
|
||||
msgstr ""
|
||||
|
||||
msgid "## Changes on build 2016.05.25"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added grouped controls in the audio searches dialogue. It will be more accessible so screen readers could detect and read the label for radio buttons."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added documents to the list of supported attachments in the post viewer. The action for this kind of attachments is to open the default web browser, pointing to the URL address of that file."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now It's possible to add photos to the wall, by uploading files to the VK servers. Check the attachments button in the new post dialogue for this. Basically it is possible to add some photos and when the post is sent, photos will start to be uploaded before. At the moment it is not possible to add descriptions to photos. Take in to account that photos will be uploaded when the send button is pressed and the post could take some time before being posted."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added a new option to the menu bar: new timeline. It allows to create a special buffer for a selected user. This buffer could be an audio or wall buffer, when created, the buffer will be updated with items for the specified user or community."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added an user selection control. In dialogues where an user must be selected, there will be an edit box with a selected name. You need to start writing for changing this name, or just press the down arrow for looking in the users' database. You can start writing and then press the down arrow, so you will see the closest result to the name you was writing. For example if you want to write manuel, you could write m, a, n, u, and press the down arrow, and you will see the full name in the edit box. Take in to account that you have to make sure that you write a valid user name in the box, otherwise you will see an error."
|
||||
msgstr ""
|
||||
|
||||
msgid ""
|
||||
"* Posts from twitter are displayed in a better way (newline characters (\n"
|
||||
") are handled properly instead being displayed)."
|
||||
msgstr ""
|
||||
|
||||
msgid "* In the play all function, everything should be cleaned before start the new playback."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now links included in text of a comment are included as attachments (links are \"untitled\" because it isn't possible to retrieve information for every link without performance issues). This is especially useful when someone posts a link from Twitter."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Chat support: There is a new kind of buffer, named chat buffer, wich allows you to have a conversation with someone of your friends. If you receive a message while socializer is opened it will create a chat buffer under chats with the last 200 messages between you and your friend. You can send a message by writing in the edit box and pressing send or enter. At the moment chats buffers can't be removed. Will be added this possibility in the near future."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added your friendlist as a buffer. You can create chats from there by using the send message button."
|
||||
msgstr ""
|
||||
|
||||
msgid "## Changes for build 2016.04.5 (5/04/2016)"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Fixed minor bugs in the likes button for posts."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Now it's possible to open wall posts by pressing enter, as newsfeeds' posts."
|
||||
msgstr ""
|
||||
|
||||
msgid "* It's possible to see reposts in the news and wall buffers, and the post displayer (when you press enter in a post) shows the full post story."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added \"load previous items\" in the main menu. It should work for wall and news feed. This feature is not available in audio buffers due to API limits."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added more options in the search audio dialog. Now users could use more parameters and searches will be more precise."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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)."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Added a changelog file which could be opened from the help menu."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
#. Translators: the label for the Windows default NVDA interface language.
|
||||
msgid "User default"
|
||||
msgstr ""
|
||||
|
||||
msgid "socializer's manual "
|
||||
msgid "# Socializer's manual "
|
||||
msgstr ""
|
||||
|
||||
msgid "## Introduction"
|
||||
@@ -29,13 +335,13 @@ msgstr ""
|
||||
msgid "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:"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Supports two factor authentication (2FA)."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Basic post creation in your wall (including photos)."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Audio addition, removal, download and search."
|
||||
msgstr ""
|
||||
|
||||
msgid "* audio albums management (create, delete and add audios)."
|
||||
msgid "* audio support."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Post comments."
|
||||
@@ -44,170 +350,317 @@ msgstr ""
|
||||
msgid "* like, unlike and repost other's posts."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Open other's timelines so you could track someone's friends, posts or audio files."
|
||||
msgid "* Open other's timelines so you could track their friends, posts or audio files."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Basic chat features."
|
||||
msgstr ""
|
||||
|
||||
msgid "Note: When new features are added to socializer they will be added to this section."
|
||||
msgid "## Usage"
|
||||
msgstr ""
|
||||
|
||||
msgid "## Running"
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgid "## authorising the application"
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "If this is the first time you have launched socializer, you will see a message asking you whether socializer should connect through a proxy server, already configured in the application, or use the system network settings. This allows people from countries where VK is blocked to use the social network without having to look for a proxy server themselves. It is highly adviced to use the proxy server only if you are in need of it."
|
||||
msgstr ""
|
||||
|
||||
msgid "After the proxy message, you will see a new message dialog asking you to proceed with the account authorisation process. It consists in providing the authentication data you normally use to sign in VK. It is very important to know that this data will be stored in a folder called config, located in the same folder where the socializer files are. Your config folder is a very important storage for your authentication data, so you must be sure you never will share it with anyone, mostly because your data is stored as plain text (this will be fixed in a future release and your data will be properly encrypted). Socializer will need your authentication data for acting in your behalf and offering you a better experience that what it could do with a simple access token. You must provide your phone number or email address in the first text box, and your password in the second. When pressing OK, your data will be saved and the application will start to retrieve all the required information for showing your buffers. If you have two factor authentication configured in your account, you will see an additional dialog where you have to type the code provided by VK via SMS."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "## General concepts"
|
||||
msgstr ""
|
||||
|
||||
msgid "Before starting to describe Socializer's usage, we'll explain some concepts that will be used extensively throughout this manual."
|
||||
msgstr ""
|
||||
|
||||
msgid "### Buffer"
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "All buffers will be updated in one of the following ways:"
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "### item"
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "The following is a brief description of the kind of items socializer can work with, and what actions are available for those."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Newsfeed post: It represents a post displayed in your \"home\" page on VK. It may contain a variety of information based in what you or your friends do. A newsfeed item may contain information about new audios added to your friend's library, new people added to friends, wall posts, reposts and new photos added. Depending on the kind of data VK has supplied, the item can open a dialog showing information about the post, a list displaying the people added to friends, or a dialog displaying information for every audio added to library. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. Available options for this item are different depending in the information the item contains. You can open or view the profile of the user that generated the item, like, dislike or add a comment to a post."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Wall post: Represent a post in an user's wall. This post will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. When opened (by pressing enter or the open option in the associated menu), it will show a dialogue where you can read the message, see how many times the post has been viewed by other users, interact with attachment files (by searching the list and pressing enter in the focused attachment to open it), see the photos included in the post, read information related to likes and times the post has been shared, read and reply to comments. Additionally, you can share the post, indicate you like it, or add a comment. You can cycle through every item in the dialog by pressing tab."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Audio: It represent an audio uploaded to the VK'S platform. Actions available for this item are opening the audio in a dialog, add or remove it from your library, move the audio to a playlist, and play it. When opened, it will be displayed in a dialog allowing you to read the title of the song, artist name, duration and a few buttons: play, add or remove from your library and download. You can control playback of audio items from the buffer by using the player menu on the menu bar or the corresponding keyboard shortcuts."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "## Main interface"
|
||||
msgstr ""
|
||||
|
||||
msgid "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:"
|
||||
msgid "The graphical user interface of Socializer consists of a window containing:"
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "* a menu bar accomodating five menus (application, Me, buffer, player and help),"
|
||||
msgstr ""
|
||||
|
||||
msgid "* A button for making a post to your wall."
|
||||
msgid "* One tree view,"
|
||||
msgstr ""
|
||||
|
||||
msgid "* In audio buffers, Two buttons: Play and play all."
|
||||
msgid "* One list of items"
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "* Some buttons, depending which is the focused buffer."
|
||||
msgstr ""
|
||||
|
||||
msgid "* A list where you will see the posts for the currently selected buffer."
|
||||
msgid "The actions that are available for every item will be described later."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* A status bar where the program will put some useful information about what it's doing at the moment."
|
||||
msgid "### Buttons in the application"
|
||||
msgstr ""
|
||||
|
||||
msgid "* And a menu bar."
|
||||
msgid "* Post: this button opens up a dialogue box to write a post in the wall of the focused user. For example, if you are in the \"my wall\" buffer you will send a post to your own wall, but if you are in an user timeline the post will be sent to the owner of the timeline. You can upload an attachment by pressing the \"attach\" button and choosing between uploading a photo or audio file in the dialog which will appear, check spelling or translate your message by selecting one of the available buttons in the dialogue box. In addition, you can tag a friend in your post by pressing the corresponding button for that purpose. Also it is possible to configure the privacy settings for your post by allowing all users or just your friends to read it. Press the send button to send the post."
|
||||
msgstr ""
|
||||
|
||||
msgid "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:"
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "* Play all: In audio buffers, play all songs starting from the focused buffer, until the last item in the list."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "* Send message: Send a message to a friend, which will open a conversation buffer if it does not exist already. Conversation buffers contain a full conversation, accommodating chat messages, between the current user and someone else. You can type your message in the provided box and press enter to send it to your friend. Additionally, You can upload an attachment by pressing the \"attach\" button and choosing between uploading a photo, audio file or record a voice message in the dialog which will appear, and open attachments sent in the focused message by pressing tab and finding them in the attachments list."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "Bear in mind that buttons will appear according to which actions are possible on the list you are browsing."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "## Menus"
|
||||
msgstr ""
|
||||
|
||||
msgid "### Making a post"
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "### Working with posts in news feed"
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "### Working with songs"
|
||||
msgstr ""
|
||||
|
||||
msgid "Note: the following applies to audio timelines too."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "You can play audio from any buffer, just press ctrl+return for making the audio playback possible."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "When the download starts, you can close the details dialogue and check the status bar in the main window for seeing the current progress."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgstr ""
|
||||
|
||||
msgid "## menu Bar"
|
||||
msgstr ""
|
||||
|
||||
msgid "You can go to the menu bar by pressing ALT. Right now, there are three menus, application, buffer and help:"
|
||||
msgid "Visually, Towards the top of the main application window, A menu bar can be found 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "### Application menu"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Create. Here you can create some things in VK. The only supported item at this moment is the audio album."
|
||||
msgid "* Create: opens a menu where you can create a new album. At the moment, only video albums are supported."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Delete: Removes items from the VK servers. The only supported item here is the audio album."
|
||||
msgid "* Delete: opens a menu where you can delete an already existing album owned by yourself. Only video albums are supported at this time."
|
||||
msgstr ""
|
||||
|
||||
msgid "* you can set your preferences by opening the preferences dialog located in this menu."
|
||||
msgid "* Preferences: Opens a dialogue which lets you configure settings for the entire application."
|
||||
msgstr ""
|
||||
|
||||
msgid "### Me menu"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Profile: Opens a menu with several options to do in your profile:"
|
||||
msgstr ""
|
||||
|
||||
msgid " * View profile: Displays your profile in a dialog in the application."
|
||||
msgstr ""
|
||||
|
||||
msgid " * Open in browser: Redirects you to your profile in vk.com."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Set status message: Opens up a dialog where you can write your status message. The status message is displayed in your profile and can contain up to 140 characters."
|
||||
msgstr ""
|
||||
|
||||
msgid "### Buffer menu"
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgid "* 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\"."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Update current buffer: perform an update operation in the selected buffer, which will retrieve the new items."
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Load previous items: Get the previous items for the currently focused buffer."
|
||||
msgid "* Load previous items: This allows more items to be loaded for the specified buffer. Bear in mind that not all buffers support this setting."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Remove buffer: Tries to remove the current buffer. Default buffers can't be removed."
|
||||
msgid "* Destroy: dismisses the list you're on, if possible."
|
||||
msgstr ""
|
||||
|
||||
msgid "The help menu is self explanatory."
|
||||
msgid "### Player menu"
|
||||
msgstr ""
|
||||
|
||||
msgid "## Contributing"
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "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)."
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "## contact"
|
||||
msgid "* Stop: Stops audio playback."
|
||||
msgstr ""
|
||||
|
||||
msgid "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."
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Shuffle: Plays all audios in the current buffer or the \"my music\" buffer shuffled."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Volume up: Increases volume by 5%."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Volume down: decreases volume by 5%."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Mute: Mutes audio playback, setting volume to 0%."
|
||||
msgstr ""
|
||||
|
||||
msgid "### help menu"
|
||||
msgstr ""
|
||||
|
||||
msgid "* About Socializer: shows the credits of the program."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Documentation: opens up this file, where you can read some useful program concepts."
|
||||
msgstr ""
|
||||
|
||||
msgid "* 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."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Changelog: opens up a document with the list of changes from the current version to the earliest."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Report an error: opens up a dialogue box to report a bug by completing a small number of fields. Pressing enter will send the report. If the operation doesn't succeed the program will display a warning."
|
||||
msgstr ""
|
||||
|
||||
msgid "## Keyboard shortcuts"
|
||||
msgstr ""
|
||||
|
||||
msgid "Socializer includes some keyboard shortcuts, available from any buffer (except empty buffers and conversations). Here you have the list of the available shortcuts:"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Enter: Execute the default action for the focused item. It may be opening a post, view friends added by someone else, view audio details or opening an user profile."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Control + Enter: Play audio."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Control + Shift+Enter: pause audio playback."
|
||||
msgstr ""
|
||||
|
||||
msgid "* F5: Decrease volume by 5%."
|
||||
msgstr ""
|
||||
|
||||
msgid "* F6: Increase volume by 5%."
|
||||
msgstr ""
|
||||
|
||||
msgid "## configuration"
|
||||
msgstr ""
|
||||
|
||||
msgid "As described above, this application has a preferences dialogue accessible under the application menu. Here you have a brief description of the settings present in this dialogue."
|
||||
msgstr ""
|
||||
|
||||
msgid "### General tab"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Number of items to load for newsfeed and wall buffers: Allows you to specify how many items should be retrieved from VK in the newsfeed buffer and when opening walls for other users. Default and maximum is 100."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Number of items to load in video buffers: Allows you to specify how many items should be retrieved from VK in video buffers. Default and maximum is 200."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Load images in posts: Allows you to specify whether you want socializer to display all images when opening a post, or not. This can be useful for people with slow connections or not needing images."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Update channel: allows you to specify how often you will receive updates for the program. There are two update channels available: Alpha channel, which contains unstable versions of the application and gets updates almost dayly, and stable, which contain tested and more stable versions of the program, but gets updates once in a month, approximately."
|
||||
msgstr ""
|
||||
|
||||
msgid "### Chat settings tab"
|
||||
msgstr ""
|
||||
|
||||
msgid "* Show notifications when users are online/offline: These two checkboxes allows you to specify if you want socializer to notify you when someone is connected or disconnected in the VK network."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Open unread conversations at startup: When enabled, Socializer will load any conversation with unread messages after started."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Move focus to new conversations: When enabled, new conversations will be focused automatically right after being created."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Notification type: This setting allows you to specify the notification type you prefer to use in socializer. The options are native and custom. Native notifications send a system notification every time someone is online or offline, while custom notifications play a sound and announce the notification in the screen reader only."
|
||||
msgstr ""
|
||||
|
||||
msgid "### Optional buffers tab"
|
||||
msgstr ""
|
||||
|
||||
msgid "This section allows you to specify which buffers should be precreated every time socializer starts. This kind of buffers, namely audio playlists, video albums and communities, have a special way of being created. When a buffer of the previously mentioned types is created, the buffer is added to the corresponding section but no data is loaded from VK. In order to load the data for one of these buffers you have to press the load button present in the buffer. From this tab you can mark and unmark the buffers Socializer will create when it starts. By default, buffers for audio playlists, video albums and communities are not created automatically when Socializer starts."
|
||||
msgstr ""
|
||||
|
||||
msgid "## License and source code"
|
||||
msgstr ""
|
||||
|
||||
msgid "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>."
|
||||
msgstr ""
|
||||
|
||||
msgid "The source code of the program is available at <https://code.manuelcortez.net/manuelcortez/socializer>."
|
||||
msgstr ""
|
||||
|
||||
msgid "## Contact"
|
||||
msgstr ""
|
||||
|
||||
msgid "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 team, [join the Socializer's community in VK.](https://vk.com/socializer.club) You can also visit [The project website.](http://socializer.su)"
|
||||
msgstr ""
|
||||
|
||||
msgid "## Credits"
|
||||
msgstr ""
|
||||
|
||||
msgid "Socializer is developed and mantained by [Manuel Cortez,](https://manuelcortez.net) with contributions by [Anibal Hernandez](https://dragodark.com)"
|
||||
msgstr ""
|
||||
|
||||
msgid "We would also like to thank the translators of Socializer, who have allowed the spreading of the application."
|
||||
msgstr ""
|
||||
|
||||
msgid "* English: Manuel Cortéz."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Spanish: Manuel Cortéz."
|
||||
msgstr ""
|
||||
|
||||
msgid "* Russian: Дарья Ратникова."
|
||||
msgstr ""
|
||||
|
||||
msgid "Special thanks to Дарья Ратникова, as she also manages the Socializer's community in VK, translates the website and the documentation into Russian."
|
||||
msgstr ""
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,11 @@
|
||||
[app-settings]
|
||||
username = string(default="")
|
||||
password = string(default="")
|
||||
language = string(default="system")
|
||||
language = string(default="system")
|
||||
use_proxy = boolean(default=False)
|
||||
first_start = boolean(default=True)
|
||||
|
||||
[sound]
|
||||
volume = integer(default=100)
|
||||
input_device = string(default="Default")
|
||||
output_device = string(default="Default")
|
||||
session_mute = boolean(default=False)
|
||||
current_soundpack = string(default="default")
|
@@ -1,14 +1,15 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
name = "Socializer"
|
||||
version = "0.17"
|
||||
author = u"Manuel Cortez"
|
||||
version = "0.20"
|
||||
author = "Manuel Cortez"
|
||||
authorEmail = "manuel@manuelcortez.net"
|
||||
copyright = u"Copyright (C) 2016-2018, Manuel Cortez"
|
||||
description = unicode(name+" Is an accessible VK client for Windows.")
|
||||
url = "https://manuelcortez.net/socializer"
|
||||
copyright = "Copyright (C) 2016-2019, Manuel Cortez"
|
||||
description = name+" Is an accessible VK client for Windows."
|
||||
url = "http://socializer.su"
|
||||
# The short name will be used for detecting translation files. See languageHandler for more details.
|
||||
short_name = "socializer"
|
||||
translators = [u"Darya Ratnikova (Russian)", u"Manuel Cortez (Spanish)"]
|
||||
translators = ["Darya Ratnikova (Russian)", "Manuel Cortez (Spanish)"]
|
||||
bts_name = "socializer"
|
||||
bts_access_token = "U29jaWFsaXplcg"
|
||||
bts_url = "https://issues.manuelcortez.net"
|
||||
|
103
src/authenticator/official.py
Normal file
103
src/authenticator/official.py
Normal file
@@ -0,0 +1,103 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" Set of methods used to retrieve access tokens by simulating the official VK application for Android. """
|
||||
import random
|
||||
import requests
|
||||
import logging
|
||||
from hashlib import md5
|
||||
from .wxUI import two_factor_auth, bad_password
|
||||
|
||||
log = logging.getLogger("authenticator.official")
|
||||
|
||||
class AuthenticationError(Exception):
|
||||
pass
|
||||
|
||||
# Data extracted from official VK android APP.
|
||||
client_id = "2274003"
|
||||
client_secret = "hHbZxrka2uZ6jB1inYsH"
|
||||
api_ver="5.93"
|
||||
scope = "nohttps,all"
|
||||
user_agent = "VKAndroidApp/5.23-2978 (Android 4.4.2; SDK 19; x86; unknown Android SDK built for x86; en; 320x240)"
|
||||
|
||||
api_url = "https://api.vk.com/method/"
|
||||
|
||||
def get_device_id():
|
||||
""" Generate a random device ID, consisting in 16 alphanumeric characters."""
|
||||
return "".join(random.choice(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "a", "b", "c", "d", "e", "f"]) for _ in range(16))
|
||||
|
||||
def get_sig(method, values, secret):
|
||||
""" Create a signature for parameters passed to VK API. """
|
||||
postdata = ""
|
||||
for key in values:
|
||||
# None values should be excluded from SIG, otherwise VK won't validate it correctly.
|
||||
if values[key] != None:
|
||||
postdata = postdata + "{key}={value}&".format(key=key, value=values[key])
|
||||
# Remove the last "&" character.
|
||||
postdata = postdata[:-1]
|
||||
sig = md5(b"/method/"+method.encode("utf-8")+b"?"+postdata.encode("utf-8")+secret.encode("utf-8"))
|
||||
return sig.hexdigest()
|
||||
|
||||
def perform_request(method, postdata, secret):
|
||||
""" Send a request to VK servers by signing the data with the 'sig' parameter."""
|
||||
url = api_url+method
|
||||
sig = get_sig(method, postdata, secret)
|
||||
postdata.update(sig=sig)
|
||||
headers = {'User-Agent': user_agent}
|
||||
r = requests.post(url, data=postdata, headers=headers)
|
||||
return r.json()
|
||||
|
||||
def get_non_refreshed(login, password, scope=scope):
|
||||
""" Retrieves a non-refreshed token, this should be the first token needed to authenticate in VK.
|
||||
returns the access_token which still needs to be refreshed, device_id, and secret code, needed to sign all petitions in VK."""
|
||||
if not (login or password):
|
||||
raise ValueError("Both user and password are required.")
|
||||
device_id = get_device_id()
|
||||
# Let's authenticate.
|
||||
url = "https://oauth.vk.com/token"
|
||||
params = dict(grant_type="password",
|
||||
client_id=client_id, client_secret=client_secret, username=login,
|
||||
password=password, v=api_ver, scope=scope, lang="en", device_id=device_id, force_sms=1)
|
||||
# Add two factor auth later due to python's syntax.
|
||||
params["2fa_supported"] = 1
|
||||
headers = {'User-Agent': user_agent}
|
||||
r = requests.get(url, params=params, headers=headers)
|
||||
log.exception(r.json())
|
||||
# If a 401 error is raised, we need to use 2FA here.
|
||||
# see https://vk.com/dev/auth_direct (switch lang to russian, english docs are very incomplete in the matter)
|
||||
# ToDo: this needs testing after implemented official VK tokens.
|
||||
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"
|
||||
params = dict(grant_type="password", lang="en",
|
||||
client_id=client_id, client_secret=client_secret, username=login,
|
||||
password=password, v=api_ver, scope=scope, device_id=device_id, code=code)
|
||||
r = requests.get(url, params=params, headers=headers)
|
||||
if r.status_code == 200 and 'access_token' in r.text:
|
||||
res = r.json()
|
||||
# Retrieve access_token and secret.
|
||||
access_token = res['access_token']
|
||||
secret = res['secret']
|
||||
return access_token, secret, device_id
|
||||
else:
|
||||
raise AuthenticationError(r.text)
|
||||
|
||||
def refresh_token(token, secret, device_id):
|
||||
method = "execute.getUserInfo"
|
||||
postdata = dict(v=api_ver, https=1, androidVersion=19, androidModel="Android SDK built for x86", info_fields="audio_ads,audio_background_limit,country,discover_design_version,discover_preload,discover_preload_not_seen,gif_autoplay,https_required,inline_comments,intro,lang,menu_intro,money_clubs_p2p,money_p2p,money_p2p_params,music_intro,audio_restrictions,profiler_settings,raise_to_record_enabled,stories,masks,subscriptions,support_url,video_autoplay,video_player,vklive_app,community_comments,webview_authorization,story_replies,animated_stickers,community_stories,live_section,playlists_download,calls,security_issue,eu_user,wallet,vkui_community_create,vkui_profile_edit,vkui_community_manage,vk_apps,stories_photo_duration,stories_reposts,live_streaming,live_masks,camera_pingpong,role,video_discover", device_id=device_id, lang="en", func_v=11, androidManufacturer="unknown", fields="photo_100,photo_50,exports,country,sex,status,bdate,first_name_gen,last_name_gen,verified,trending", access_token=token)
|
||||
perform_request(method, postdata, secret)
|
||||
method = "auth.refreshToken"
|
||||
postdata = dict(v=api_ver, https=1, timestamp=0, receipt2="", device_id=device_id, receipt="", lang="en", nonce="", access_token=token)
|
||||
return perform_request(method, postdata, secret)
|
||||
|
||||
def login(user, password):
|
||||
try:
|
||||
access_token, secret, device_id = get_non_refreshed(user, password)
|
||||
response = refresh_token(access_token, secret, device_id)
|
||||
except AuthenticationError:
|
||||
bad_password()
|
||||
raise AuthenticationError("")
|
||||
try:
|
||||
return response["response"]["token"], secret, device_id
|
||||
except KeyError:
|
||||
log.exception("An exception has occurred while attempting to authenticate. Printing response returned by vk...")
|
||||
log.exception(response)
|
17
src/authenticator/wxUI.py
Normal file
17
src/authenticator/wxUI.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import time
|
||||
import wx
|
||||
import widgetUtils
|
||||
|
||||
def two_factor_auth():
|
||||
code = None
|
||||
dlg = wx.TextEntryDialog(None, _("Please provide the authentication code you have received from VK."), _("Two factor authentication code"))
|
||||
response = dlg.ShowModal()
|
||||
if response == widgetUtils.OK:
|
||||
code = dlg.GetValue()
|
||||
dlg.Destroy()
|
||||
return (code, True)
|
||||
|
||||
def bad_password():
|
||||
return wx.MessageDialog(None, _("Your password or email address are incorrect. Please fix the mistakes and try it again."), _("Wrong data"), wx.ICON_ERROR).ShowModal()
|
@@ -45,7 +45,7 @@ def hist(keys):
|
||||
def find_problems(hist):
|
||||
"Takes a histogram and returns a list of items occurring more than once."
|
||||
res=[]
|
||||
for k,v in hist.items():
|
||||
for k,v in list(hist.items()):
|
||||
if v>1:
|
||||
res.append(k)
|
||||
return res
|
||||
|
@@ -1,134 +0,0 @@
|
||||
# -*- 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 logging
|
||||
import widgetUtils
|
||||
import audioRecorder
|
||||
from mutagen.id3 import ID3
|
||||
from sessionmanager.utils import seconds_to_string
|
||||
from wxUI.dialogs import attach as gui
|
||||
from wxUI.dialogs import selector
|
||||
from wxUI.menus import attachMenu
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
class attach(object):
|
||||
""" 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(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)
|
||||
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:
|
||||
# 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"), 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
|
||||
self.attachments.pop(current_item)
|
||||
self.dialog.attachments.remove_item(current_item)
|
||||
self.check_remove_status()
|
||||
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)
|
@@ -1,131 +0,0 @@
|
||||
# -*- 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)
|
File diff suppressed because it is too large
Load Diff
@@ -1,75 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import widgetUtils
|
||||
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"))
|
||||
self.create_config()
|
||||
|
||||
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", "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_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()
|
File diff suppressed because it is too large
Load Diff
@@ -1,80 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
import widgetUtils
|
||||
import output
|
||||
from pubsub import pub
|
||||
import attach
|
||||
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, 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)
|
||||
|
||||
def get_privacy_options(self):
|
||||
p = self.message.get("privacy")
|
||||
if p == _(u"Friends of friends"):
|
||||
privacy = 0
|
||||
elif p == _(u"All users"):
|
||||
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()
|
||||
dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
|
||||
msg = translator.translator.translate(text_to_translate, dest)
|
||||
self.message.set_text(msg)
|
||||
self.message.text_focus()
|
||||
output.speak(_(u"Translated"))
|
||||
dlg.Destroy()
|
||||
|
||||
def spellcheck(self, event=None):
|
||||
text = self.message.get_text()
|
||||
checker = SpellChecker.spellchecker.spellChecker(text, "")
|
||||
if hasattr(checker, "fixed_text"):
|
||||
self.message.set_text(checker.fixed_text)
|
||||
checker.clean()
|
||||
|
||||
def show_attach_dialog(self, *args, **kwargs):
|
||||
a = attach.attach(self.session)
|
||||
if len(a.attachments) != 0:
|
||||
self.attachments = a.attachments
|
||||
|
||||
class comment(post):
|
||||
def __init__(self, session, title, caption, text):
|
||||
super(comment, self).__init__(session, title, caption, text, "comment")
|
||||
self.message.set_title(_(u"New comment"))
|
@@ -1,118 +0,0 @@
|
||||
# -*- 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
|
||||
if player == None:
|
||||
player = audioPlayer()
|
||||
|
||||
class audioPlayer(object):
|
||||
|
||||
def __init__(self):
|
||||
self.is_playing = False
|
||||
self.stream = None
|
||||
self.vol = 100
|
||||
self.is_working = False
|
||||
self.queue = []
|
||||
self.stopped = True
|
||||
|
||||
def play(self, url, set_info=True):
|
||||
if self.stream != None and self.stream.is_playing == True:
|
||||
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()
|
||||
self.worker = None
|
||||
self.queue = []
|
||||
# Make sure that there are no other sounds trying to be played.
|
||||
if self.is_working == False:
|
||||
self.is_working = True
|
||||
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.
|
||||
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
|
||||
self.is_working = False
|
||||
|
||||
def stop(self):
|
||||
if self.stream != None and self.stream.is_playing == True:
|
||||
self.stream.stop()
|
||||
self.stopped = True
|
||||
if hasattr(self, "worker") and self.worker != None:
|
||||
self.worker.cancel()
|
||||
self.worker = None
|
||||
self.queue = []
|
||||
|
||||
def pause(self):
|
||||
if self.stream != None:
|
||||
if self.stream.is_playing == True:
|
||||
self.stream.pause()
|
||||
self.stopped = True
|
||||
else:
|
||||
try:
|
||||
self.stream.play()
|
||||
self.stopped = False
|
||||
except BassError:
|
||||
pass
|
||||
|
||||
@property
|
||||
def volume(self):
|
||||
if self.stream != None:
|
||||
return self.vol
|
||||
|
||||
@volume.setter
|
||||
def volume(self, vol):
|
||||
if vol <= 100 and vol >= 0:
|
||||
self.vol = vol
|
||||
if self.stream != None:
|
||||
self.stream.volume = self.vol/100.0
|
||||
|
||||
def play_all(self, list_of_urls, shuffle=False):
|
||||
self.stop()
|
||||
# Skip all country restricted tracks as they are not playable here.
|
||||
self.queue = [i for i in list_of_urls if i["url"] != ""]
|
||||
if shuffle:
|
||||
random.shuffle(self.queue)
|
||||
self.play(self.queue[0])
|
||||
self.queue.remove(self.queue[0])
|
||||
self.worker = RepeatingTimer(5, self.player_function)
|
||||
self.worker.start()
|
||||
|
||||
def player_function(self):
|
||||
if self.stream != None and self.stream.is_playing == False and self.stopped == False and len(self.stream) == self.stream.position:
|
||||
if len(self.queue) == 0:
|
||||
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
|
||||
|
@@ -1,613 +0,0 @@
|
||||
# -*- 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 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, profiles
|
||||
from extra import SpellChecker, translator
|
||||
from mysc.thread_utils import call_threaded
|
||||
from wxUI import menus
|
||||
|
||||
log = logging.getLogger("controller.post")
|
||||
|
||||
def get_user(id, profiles):
|
||||
""" Returns an user name and last name based in the id receibed."""
|
||||
for i in profiles:
|
||||
if i["id"] == id:
|
||||
return u"{0} {1}".format(i["first_name"], i["last_name"])
|
||||
# Translators: This string is used when socializer can't find the right user information.
|
||||
return _(u"Unknown username")
|
||||
|
||||
def get_message(status):
|
||||
message = ""
|
||||
if status.has_key("text"):
|
||||
message = utils.clean_text(status["text"])
|
||||
return message
|
||||
|
||||
class postController(object):
|
||||
""" Base class for post representation."""
|
||||
|
||||
def __init__(self, session, postObject):
|
||||
super(postController, self).__init__()
|
||||
self.session = session
|
||||
self.post = postObject
|
||||
# Posts from newsfeed contains this source_id instead from_id in walls. Also it uses post_id and walls use just id.
|
||||
if self.post.has_key("source_id"):
|
||||
self.user_identifier = "source_id"
|
||||
self.post_identifier = "post_id"
|
||||
else:
|
||||
# In wall's posts, if someone has posted in user's wall, owner_id should be used instead from_id
|
||||
# This will help for retrieving comments, do likes, etc.
|
||||
if not self.post.has_key("owner_id"):
|
||||
self.user_identifier = "from_id"
|
||||
else:
|
||||
self.user_identifier = "owner_id"
|
||||
self.post_identifier = "id"
|
||||
self.dialog = postDialogs.post()
|
||||
# self.dialog.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.show_comment)
|
||||
widgetUtils.connect_event(self.dialog.like, widgetUtils.BUTTON_PRESSED, self.post_like)
|
||||
widgetUtils.connect_event(self.dialog.comment, widgetUtils.BUTTON_PRESSED, self.add_comment)
|
||||
widgetUtils.connect_event(self.dialog.tools, widgetUtils.BUTTON_PRESSED, self.show_tools_menu)
|
||||
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)
|
||||
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} > {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 = 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))
|
||||
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])
|
||||
if self.post.has_key("copy_history"):
|
||||
# Translators: {0} will be replaced with an user.
|
||||
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 {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_,)
|
||||
self.dialog.set_title(title)
|
||||
message = u""
|
||||
message = get_message(self.post)
|
||||
if self.post.has_key("copy_history"):
|
||||
nm = u"\n"
|
||||
for i in self.post["copy_history"]:
|
||||
nm += u"{0}: {1}\n\n".format(self.session.get_user_name(i["from_id"]), get_message(i))
|
||||
self.get_attachments(i)
|
||||
message += nm
|
||||
self.dialog.set_post(message)
|
||||
self.get_attachments(self.post)
|
||||
self.check_image_load()
|
||||
|
||||
def get_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
|
||||
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"))
|
||||
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(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()
|
||||
self.get_reposts()
|
||||
self.get_comments()
|
||||
if self.post["comments"]["can_post"] == 0:
|
||||
self.dialog.disable("comment")
|
||||
if self.post["likes"]["can_like"] == 0 and self.post["likes"]["user_likes"] == 0:
|
||||
self.dialog.disable("like")
|
||||
elif self.post["likes"]["user_likes"] == 1:
|
||||
self.dialog.set("like", _(u"&Dislike"))
|
||||
if self.post["likes"]["can_publish"] == 0:
|
||||
self.dialog.disable("repost")
|
||||
|
||||
def post_like(self, *args, **kwargs):
|
||||
if self.post.has_key("owner_id") == False:
|
||||
user = int(self.post[self.user_identifier])
|
||||
else:
|
||||
user = int(self.post["owner_id"])
|
||||
id = int(self.post[self.post_identifier])
|
||||
if self.post.has_key("type"):
|
||||
type_ = self.post["type"]
|
||||
else:
|
||||
type_ = "post"
|
||||
if self.dialog.get("like") == _(u"&Dislike"):
|
||||
l = self.session.vk.client.likes.delete(owner_id=user, item_id=id, type=type_)
|
||||
output.speak(_(u"You don't like this"))
|
||||
self.post["likes"]["count"] = l["likes"]
|
||||
self.post["likes"]["user_likes"] = 2
|
||||
self.get_likes()
|
||||
self.dialog.set("like", _(u"&Like"))
|
||||
else:
|
||||
l = self.session.vk.client.likes.add(owner_id=user, item_id=id, type=type_)
|
||||
output.speak(_(u"You liked this"))
|
||||
self.dialog.set("like", _(u"&Dislike"))
|
||||
self.post["likes"]["count"] = l["likes"]
|
||||
self.post["likes"]["user_likes"] = 1
|
||||
self.get_likes()
|
||||
|
||||
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(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):
|
||||
try:
|
||||
self.dialog.set_likes(self.post["likes"]["count"])
|
||||
except wx.PyDeadObjectError:
|
||||
pass
|
||||
|
||||
def get_reposts(self):
|
||||
try:
|
||||
self.dialog.set_shares(self.post["reposts"]["count"])
|
||||
except wx.PyDeadObjectError:
|
||||
pass
|
||||
|
||||
def add_comment(self, *args, **kwargs):
|
||||
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:
|
||||
user = self.post[self.user_identifier]
|
||||
id = self.post[self.post_identifier]
|
||||
self.session.vk.client.wall.addComment(owner_id=user, post_id=id, text=msg)
|
||||
output.speak(_(u"You've posted a comment"))
|
||||
if self.comments["count"] < 100:
|
||||
self.clear_comments_list()
|
||||
self.get_comments()
|
||||
except Exception as msg:
|
||||
log.error(msg)
|
||||
|
||||
def clear_comments_list(self):
|
||||
self.dialog.comments.clear()
|
||||
|
||||
def show_comment(self, *args, **kwargs):
|
||||
c = comment(self.session, self.comments["data"][self.dialog.comments.get_selected()])
|
||||
c.dialog.get_response()
|
||||
|
||||
def show_menu(self, *args, **kwargs):
|
||||
if self.dialog.comments.get_count() == 0: return
|
||||
menu = menus.commentMenu()
|
||||
widgetUtils.connect_event(self.dialog, widgetUtils.MENU, self.show_comment, menuitem=menu.open)
|
||||
widgetUtils.connect_event(self.dialog, widgetUtils.MENU, self.comment_like, menuitem=menu.like)
|
||||
widgetUtils.connect_event(self.dialog, widgetUtils.MENU, self.comment_unlike, menuitem=menu.unlike)
|
||||
self.dialog.PopupMenu(menu, self.dialog.comments.list.GetPosition())
|
||||
|
||||
def show_menu_by_key(self, ev):
|
||||
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
|
||||
self.show_menu()
|
||||
|
||||
def show_tools_menu(self, *args, **kwargs):
|
||||
menu = menus.toolsMenu()
|
||||
widgetUtils.connect_event(self.dialog, widgetUtils.MENU, self.open_url, menuitem=menu.url)
|
||||
widgetUtils.connect_event(self.dialog, widgetUtils.MENU, self.translate, menuitem=menu.translate)
|
||||
widgetUtils.connect_event(self.dialog, widgetUtils.MENU, self.spellcheck, menuitem=menu.CheckSpelling)
|
||||
self.dialog.PopupMenu(menu, self.dialog.tools.GetPosition())
|
||||
|
||||
def comment_like(self, *args, **kwargs):
|
||||
comment_id = self.comments["data"][self.dialog.comments.get_selected()]["id"]
|
||||
self.session.like(comment_id)
|
||||
output.speak(_(u"You do like this comment"))
|
||||
|
||||
def comment_unlike(self, *args, **kwargs):
|
||||
comment_id = self.comments["data"][self.dialog.comments.get_selected()]["id"]
|
||||
self.session.unlike(comment_id)
|
||||
output.speak(_(u"You don't like this comment"))
|
||||
|
||||
def translate(self, *args, **kwargs):
|
||||
dlg = translator.gui.translateDialog()
|
||||
if dlg.get_response() == widgetUtils.OK:
|
||||
text_to_translate = self.dialog.post_view.GetValue().encode("utf-8")
|
||||
dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
|
||||
msg = translator.translator.translate(text_to_translate, target=dest)
|
||||
self.dialog.post_view.ChangeValue(msg)
|
||||
output.speak(_(u"Translated"))
|
||||
else:
|
||||
return
|
||||
|
||||
def spellcheck(self, *args, **kwargs):
|
||||
text = self.dialog.post_view.GetValue()
|
||||
checker = SpellChecker.spellchecker.spellChecker(text, "")
|
||||
if hasattr(checker, "fixed_text"):
|
||||
self.dialog.post_view.ChangeValue(checker.fixed_text)
|
||||
|
||||
def open_attachment(self, *args, **kwargs):
|
||||
index = self.dialog.attachments.get_selected()
|
||||
attachment = self.attachments[index]
|
||||
if attachment["type"] == "audio":
|
||||
a = audio(session=self.session, postObject=[attachment["audio"]])
|
||||
a.dialog.get_response()
|
||||
a.dialog.Destroy()
|
||||
if 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 __del__(self):
|
||||
if hasattr(self, "worker"):
|
||||
self.worker.finished.set()
|
||||
|
||||
class comment(object):
|
||||
def __init__(self, session, comment_object):
|
||||
super(comment, self).__init__()
|
||||
self.session = session
|
||||
self.comment = comment_object
|
||||
self.dialog = postDialogs.comment()
|
||||
from_ = self.comment["from"]["name"]
|
||||
message = self.comment["message"]
|
||||
original_date = arrow.get(self.comment["created_time"], "YYYY-MM-DTHH:m:sZ", locale="en")
|
||||
created_at = original_date.humanize(locale=languageHandler.getLanguage())
|
||||
self.dialog.set_post(message)
|
||||
self.dialog.set_title(_(u"Comment from {0}").format(from_,))
|
||||
widgetUtils.connect_event(self.dialog.like, widgetUtils.BUTTON_PRESSED, self.post_like)
|
||||
call_threaded(self.get_likes)
|
||||
|
||||
def get_likes(self):
|
||||
self.likes = self.session.fb.client.get_connections(id=self.comment["id"], connection_name="likes", summary=True)
|
||||
self.dialog.set_likes(self.likes["summary"]["total_count"])
|
||||
|
||||
def post_like(self, *args, **kwargs):
|
||||
lk = self.session.like(self.comment["id"])
|
||||
self.get_likes()
|
||||
|
||||
class audio(postController):
|
||||
def __init__(self, session, postObject):
|
||||
self.added_audios = {}
|
||||
self.session = session
|
||||
self.post = postObject
|
||||
self.dialog = postDialogs.audio()
|
||||
widgetUtils.connect_event(self.dialog.list, widgetUtils.LISTBOX_CHANGED, self.handle_changes)
|
||||
self.load_audios()
|
||||
self.fill_information(0)
|
||||
widgetUtils.connect_event(self.dialog.download, widgetUtils.BUTTON_PRESSED, self.download)
|
||||
widgetUtils.connect_event(self.dialog.play, widgetUtils.BUTTON_PRESSED, self.play)
|
||||
widgetUtils.connect_event(self.dialog.add, widgetUtils.BUTTON_PRESSED, self.add_to_library)
|
||||
widgetUtils.connect_event(self.dialog.remove, widgetUtils.BUTTON_PRESSED, self.remove_from_library)
|
||||
|
||||
def add_to_library(self, *args, **kwargs):
|
||||
post = self.post[self.dialog.get_audio()]
|
||||
args = {}
|
||||
args["audio_id"] = post["id"]
|
||||
if post.has_key("album_id"):
|
||||
args["album_id"] = post["album_id"]
|
||||
args["owner_id"] = post["owner_id"]
|
||||
audio = self.session.vk.client.audio.add(**args)
|
||||
if audio != None and int(audio) > 21:
|
||||
self.added_audios[post["id"]] = audio
|
||||
self.dialog.change_state("add", False)
|
||||
self.dialog.change_state("remove", True)
|
||||
|
||||
def remove_from_library(self, *args, **kwargs):
|
||||
post = self.post[self.dialog.get_audio()]
|
||||
args = {}
|
||||
if self.added_audios.has_key(post["id"]):
|
||||
args["audio_id"] = self.added_audios[post["id"]]
|
||||
args["owner_id"] = self.session.user_id
|
||||
else:
|
||||
args["audio_id"] = post["id"]
|
||||
args["owner_id"] = post["owner_id"]
|
||||
result = self.session.vk.client.audio.delete(**args)
|
||||
if int(result) == 1:
|
||||
self.dialog.change_state("add", True)
|
||||
self.dialog.change_state("remove", False)
|
||||
if self.added_audios.has_key(post["id"]):
|
||||
self.added_audios.pop(post["id"])
|
||||
|
||||
def fill_information(self, index):
|
||||
post = self.post[index]
|
||||
if post.has_key("artist"):
|
||||
self.dialog.set("artist", post["artist"])
|
||||
if post.has_key("title"):
|
||||
self.dialog.set("title", post["title"])
|
||||
if post.has_key("duration"):
|
||||
self.dialog.set("duration", utils.seconds_to_string(post["duration"]))
|
||||
self.dialog.set_title(u"{0} - {1}".format(post["title"], post["artist"]))
|
||||
call_threaded(self.get_lyrics)
|
||||
if post["owner_id"] == self.session.user_id or self.added_audios.has_key(post["id"]) == True:
|
||||
self.dialog.change_state("remove", True)
|
||||
self.dialog.change_state("add", False)
|
||||
else:
|
||||
self.dialog.change_state("add", True)
|
||||
self.dialog.change_state("remove", False)
|
||||
|
||||
def get_lyrics(self):
|
||||
post = self.post[self.dialog.get_audio()]
|
||||
if post.has_key("lyrics_id"):
|
||||
l = self.session.vk.client.audio.getLyrics(lyrics_id=int(post["lyrics_id"]))
|
||||
self.dialog.set("lyric", l["text"])
|
||||
else:
|
||||
self.dialog.change_state("lyric", False)
|
||||
|
||||
def download(self, *args, **kwargs):
|
||||
post = self.post[self.dialog.get_audio()]
|
||||
f = u"{0} - {1}.mp3".format(post["title"], post["artist"])
|
||||
path = self.dialog.get_destination_path(f)
|
||||
if path != None:
|
||||
pub.sendMessage("download-file", url=post["url"], filename=path)
|
||||
|
||||
def play(self, *args, **kwargs):
|
||||
post = self.post[self.dialog.get_audio()]
|
||||
pub.sendMessage("play-audio", audio_object=post)
|
||||
|
||||
def load_audios(self):
|
||||
for i in self.post:
|
||||
s = u"{0} - {1}. {2}".format(i["title"], i["artist"], utils.seconds_to_string(i["duration"]))
|
||||
self.dialog.insert_audio(s)
|
||||
self.dialog.list.SetSelection(0)
|
||||
if len(self.post) == 1:
|
||||
self.dialog.list.Enable(False)
|
||||
self.dialog.title.SetFocus()
|
||||
|
||||
def handle_changes(self, *args, **kwargs):
|
||||
p = self.dialog.get_audio()
|
||||
self.fill_information(p)
|
||||
|
||||
class friendship(object):
|
||||
|
||||
def __init__(self, session, post):
|
||||
self.session = session
|
||||
self.post = post
|
||||
self.dialog = postDialogs.friendship()
|
||||
list_of_friends = self.get_friend_names()
|
||||
from_ = self.session.get_user_name(self.post["source_id"])
|
||||
title = _(u"{0} added the following friends").format(from_,)
|
||||
self.dialog.set_title(title)
|
||||
self.set_friends_list(list_of_friends)
|
||||
|
||||
def get_friend_names(self):
|
||||
self.friends = self.post["friends"]["items"]
|
||||
return [self.session.get_user_name(i["user_id"]) for i in self.friends]
|
||||
|
||||
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"])
|
@@ -1,161 +0,0 @@
|
||||
# -*- 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)
|
@@ -1,4 +1,4 @@
|
||||
import spellchecker
|
||||
from . import spellchecker
|
||||
import platform
|
||||
if platform.system() == "Windows":
|
||||
from wx_ui import *
|
||||
from .wx_ui import *
|
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import logging
|
||||
import wx_ui
|
||||
import widgetUtils
|
||||
import output
|
||||
import config
|
||||
@@ -8,6 +8,7 @@ import languageHandler
|
||||
from enchant.checker import SpellChecker
|
||||
from enchant.errors import DictNotFoundError
|
||||
from enchant import tokenize
|
||||
from . import wx_ui
|
||||
|
||||
log = logging.getLogger("extra.SpellChecker.spellChecker")
|
||||
|
||||
@@ -25,7 +26,7 @@ class spellChecker(object):
|
||||
self.checker = SpellChecker(languageHandler.curLang, filters=[tokenize.EmailFilter, tokenize.URLFilter])
|
||||
self.checker.set_text(text)
|
||||
except DictNotFoundError:
|
||||
print "no dict"
|
||||
print("no dict")
|
||||
log.exception("Dictionary for language %s not found." % (dictionary,))
|
||||
wx_ui.dict_not_found_error()
|
||||
self.active = False
|
||||
@@ -42,9 +43,9 @@ class spellChecker(object):
|
||||
|
||||
def check(self):
|
||||
try:
|
||||
self.checker.next()
|
||||
textToSay = _(u"Misspelled word: %s") % (self.checker.word,)
|
||||
context = u"... %s %s %s" % (self.checker.leading_context(10), self.checker.word, self.checker.trailing_context(10))
|
||||
next(self.checker)
|
||||
textToSay = _("Misspelled word: %s") % (self.checker.word,)
|
||||
context = "... %s %s %s" % (self.checker.leading_context(10), self.checker.word, self.checker.trailing_context(10))
|
||||
self.dialog.set_title(textToSay)
|
||||
output.speak(textToSay)
|
||||
self.dialog.set_word_and_suggestions(word=self.checker.word, context=context, suggestions=self.checker.suggest())
|
||||
|
@@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import application
|
||||
|
||||
@@ -24,25 +25,25 @@ class spellCheckerDialog(wx.Dialog):
|
||||
super(spellCheckerDialog, self).__init__(None, 1)
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
word = wx.StaticText(panel, -1, _(u"&Misspelled word"))
|
||||
word = wx.StaticText(panel, -1, _("&Misspelled word"))
|
||||
self.word = wx.TextCtrl(panel, -1)
|
||||
wordBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
wordBox.Add(word, 0, wx.ALL, 5)
|
||||
wordBox.Add(self.word, 0, wx.ALL, 5)
|
||||
context = wx.StaticText(panel, -1, _(u"Con&text"))
|
||||
context = wx.StaticText(panel, -1, _("Con&text"))
|
||||
self.context = wx.TextCtrl(panel, -1)
|
||||
contextBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
contextBox.Add(context, 0, wx.ALL, 5)
|
||||
contextBox.Add(self.context, 0, wx.ALL, 5)
|
||||
suggest = wx.StaticText(panel, -1, _(u"&Suggestions"))
|
||||
suggest = wx.StaticText(panel, -1, _("&Suggestions"))
|
||||
self.suggestions = wx.ListBox(panel, -1, choices=[], style=wx.LB_SINGLE)
|
||||
suggestionsBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
suggestionsBox.Add(suggest, 0, wx.ALL, 5)
|
||||
suggestionsBox.Add(self.suggestions, 0, wx.ALL, 5)
|
||||
self.ignore = wx.Button(panel, -1, _(u"&Ignore"))
|
||||
self.ignoreAll = wx.Button(panel, -1, _(u"Ignore &all"))
|
||||
self.replace = wx.Button(panel, -1, _(u"&Replace"))
|
||||
self.replaceAll = wx.Button(panel, -1, _(u"Replace a&ll"))
|
||||
self.ignore = wx.Button(panel, -1, _("&Ignore"))
|
||||
self.ignoreAll = wx.Button(panel, -1, _("Ignore &all"))
|
||||
self.replace = wx.Button(panel, -1, _("&Replace"))
|
||||
self.replaceAll = wx.Button(panel, -1, _("Replace a&ll"))
|
||||
close = wx.Button(panel, wx.ID_CANCEL)
|
||||
btnBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
btnBox.Add(self.ignore, 0, wx.ALL, 5)
|
||||
@@ -73,7 +74,7 @@ class spellCheckerDialog(wx.Dialog):
|
||||
return self.suggestions.GetStringSelection()
|
||||
|
||||
def dict_not_found_error():
|
||||
wx.MessageDialog(None, _(u"An error has occurred. There are no dictionaries available for the selected language in {0}").format(application.name,), _(u"Error"), wx.ICON_ERROR).ShowModal()
|
||||
wx.MessageDialog(None, _("An error has occurred. There are no dictionaries available for the selected language in {0}").format(application.name,), _("Error"), wx.ICON_ERROR).ShowModal()
|
||||
|
||||
def finished():
|
||||
wx.MessageDialog(None, _(u"Spell check complete."), application.name, style=wx.OK).ShowModal()
|
||||
wx.MessageDialog(None, _("Spell check complete."), application.name, style=wx.OK).ShowModal()
|
||||
|
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import translator
|
||||
import platform
|
||||
from . import translator
|
||||
if platform.system() == "Windows":
|
||||
import wx_ui as gui
|
||||
from . import wx_ui as gui
|
||||
|
@@ -1,4 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from builtins import zip
|
||||
from yandex_translate import YandexTranslate
|
||||
|
||||
def translate(text="", target="en"):
|
||||
@@ -9,97 +11,97 @@ def translate(text="", target="en"):
|
||||
supported_langs = None
|
||||
d = None
|
||||
languages = {
|
||||
"af": _(u"Afrikaans"),
|
||||
"sq": _(u"Albanian"),
|
||||
"am": _(u"Amharic"),
|
||||
"ar": _(u"Arabic"),
|
||||
"hy": _(u"Armenian"),
|
||||
"az": _(u"Azerbaijani"),
|
||||
"eu": _(u"Basque"),
|
||||
"be": _(u"Belarusian"),
|
||||
"bn": _(u"Bengali"),
|
||||
"bh": _(u"Bihari"),
|
||||
"bg": _(u"Bulgarian"),
|
||||
"my": _(u"Burmese"),
|
||||
"ca": _(u"Catalan"),
|
||||
"chr": _(u"Cherokee"),
|
||||
"zh": _(u"Chinese"),
|
||||
"zh-CN": _(u"Chinese_simplified"),
|
||||
"zh-TW": _(u"Chinese_traditional"),
|
||||
"hr": _(u"Croatian"),
|
||||
"cs": _(u"Czech"),
|
||||
"da": _(u"Danish"),
|
||||
"dv": _(u"Dhivehi"),
|
||||
"nl": _(u"Dutch"),
|
||||
"en": _(u"English"),
|
||||
"eo": _(u"Esperanto"),
|
||||
"et": _(u"Estonian"),
|
||||
"tl": _(u"Filipino"),
|
||||
"fi": _(u"Finnish"),
|
||||
"fr": _(u"French"),
|
||||
"gl": _(u"Galician"),
|
||||
"ka": _(u"Georgian"),
|
||||
"de": _(u"German"),
|
||||
"el": _(u"Greek"),
|
||||
"gn": _(u"Guarani"),
|
||||
"gu": _(u"Gujarati"),
|
||||
"iw": _(u"Hebrew"),
|
||||
"hi": _(u"Hindi"),
|
||||
"hu": _(u"Hungarian"),
|
||||
"is": _(u"Icelandic"),
|
||||
"id": _(u"Indonesian"),
|
||||
"iu": _(u"Inuktitut"),
|
||||
"ga": _(u"Irish"),
|
||||
"it": _(u"Italian"),
|
||||
"ja": _(u"Japanese"),
|
||||
"kn": _(u"Kannada"),
|
||||
"kk": _(u"Kazakh"),
|
||||
"km": _(u"Khmer"),
|
||||
"ko": _(u"Korean"),
|
||||
"ku": _(u"Kurdish"),
|
||||
"ky": _(u"Kyrgyz"),
|
||||
"lo": _(u"Laothian"),
|
||||
"lv": _(u"Latvian"),
|
||||
"lt": _(u"Lithuanian"),
|
||||
"mk": _(u"Macedonian"),
|
||||
"ms": _(u"Malay"),
|
||||
"ml": _(u"Malayalam"),
|
||||
"mt": _(u"Maltese"),
|
||||
"mr": _(u"Marathi"),
|
||||
"mn": _(u"Mongolian"),
|
||||
"ne": _(u"Nepali"),
|
||||
"no": _(u"Norwegian"),
|
||||
"or": _(u"Oriya"),
|
||||
"ps": _(u"Pashto"),
|
||||
"fa": _(u"Persian"),
|
||||
"pl": _(u"Polish"),
|
||||
"pt": _(u"Portuguese"),
|
||||
"pa": _(u"Punjabi"),
|
||||
"ro": _(u"Romanian"),
|
||||
"ru": _(u"Russian"),
|
||||
"sa": _(u"Sanskrit"),
|
||||
"sr": _(u"Serbian"),
|
||||
"sd": _(u"Sindhi"),
|
||||
"si": _(u"Sinhalese"),
|
||||
"sk": _(u"Slovak"),
|
||||
"sl": _(u"Slovenian"),
|
||||
"es": _(u"Spanish"),
|
||||
"sw": _(u"Swahili"),
|
||||
"sv": _(u"Swedish"),
|
||||
"tg": _(u"Tajik"),
|
||||
"ta": _(u"Tamil"),
|
||||
"tl": _(u"Tagalog"),
|
||||
"te": _(u"Telugu"),
|
||||
"th": _(u"Thai"),
|
||||
"bo": _(u"Tibetan"),
|
||||
"tr": _(u"Turkish"),
|
||||
"uk": _(u"Ukrainian"),
|
||||
"ur": _(u"Urdu"),
|
||||
"uz": _(u"Uzbek"),
|
||||
"ug": _(u"Uighur"),
|
||||
"vi": _(u"Vietnamese"),
|
||||
"cy": _(u"Welsh"),
|
||||
"yi": _(u"Yiddish")
|
||||
"af": _("Afrikaans"),
|
||||
"sq": _("Albanian"),
|
||||
"am": _("Amharic"),
|
||||
"ar": _("Arabic"),
|
||||
"hy": _("Armenian"),
|
||||
"az": _("Azerbaijani"),
|
||||
"eu": _("Basque"),
|
||||
"be": _("Belarusian"),
|
||||
"bn": _("Bengali"),
|
||||
"bh": _("Bihari"),
|
||||
"bg": _("Bulgarian"),
|
||||
"my": _("Burmese"),
|
||||
"ca": _("Catalan"),
|
||||
"chr": _("Cherokee"),
|
||||
"zh": _("Chinese"),
|
||||
"zh-CN": _("Chinese_simplified"),
|
||||
"zh-TW": _("Chinese_traditional"),
|
||||
"hr": _("Croatian"),
|
||||
"cs": _("Czech"),
|
||||
"da": _("Danish"),
|
||||
"dv": _("Dhivehi"),
|
||||
"nl": _("Dutch"),
|
||||
"en": _("English"),
|
||||
"eo": _("Esperanto"),
|
||||
"et": _("Estonian"),
|
||||
"tl": _("Filipino"),
|
||||
"fi": _("Finnish"),
|
||||
"fr": _("French"),
|
||||
"gl": _("Galician"),
|
||||
"ka": _("Georgian"),
|
||||
"de": _("German"),
|
||||
"el": _("Greek"),
|
||||
"gn": _("Guarani"),
|
||||
"gu": _("Gujarati"),
|
||||
"iw": _("Hebrew"),
|
||||
"hi": _("Hindi"),
|
||||
"hu": _("Hungarian"),
|
||||
"is": _("Icelandic"),
|
||||
"id": _("Indonesian"),
|
||||
"iu": _("Inuktitut"),
|
||||
"ga": _("Irish"),
|
||||
"it": _("Italian"),
|
||||
"ja": _("Japanese"),
|
||||
"kn": _("Kannada"),
|
||||
"kk": _("Kazakh"),
|
||||
"km": _("Khmer"),
|
||||
"ko": _("Korean"),
|
||||
"ku": _("Kurdish"),
|
||||
"ky": _("Kyrgyz"),
|
||||
"lo": _("Laothian"),
|
||||
"lv": _("Latvian"),
|
||||
"lt": _("Lithuanian"),
|
||||
"mk": _("Macedonian"),
|
||||
"ms": _("Malay"),
|
||||
"ml": _("Malayalam"),
|
||||
"mt": _("Maltese"),
|
||||
"mr": _("Marathi"),
|
||||
"mn": _("Mongolian"),
|
||||
"ne": _("Nepali"),
|
||||
"no": _("Norwegian"),
|
||||
"or": _("Oriya"),
|
||||
"ps": _("Pashto"),
|
||||
"fa": _("Persian"),
|
||||
"pl": _("Polish"),
|
||||
"pt": _("Portuguese"),
|
||||
"pa": _("Punjabi"),
|
||||
"ro": _("Romanian"),
|
||||
"ru": _("Russian"),
|
||||
"sa": _("Sanskrit"),
|
||||
"sr": _("Serbian"),
|
||||
"sd": _("Sindhi"),
|
||||
"si": _("Sinhalese"),
|
||||
"sk": _("Slovak"),
|
||||
"sl": _("Slovenian"),
|
||||
"es": _("Spanish"),
|
||||
"sw": _("Swahili"),
|
||||
"sv": _("Swedish"),
|
||||
"tg": _("Tajik"),
|
||||
"ta": _("Tamil"),
|
||||
"tl": _("Tagalog"),
|
||||
"te": _("Telugu"),
|
||||
"th": _("Thai"),
|
||||
"bo": _("Tibetan"),
|
||||
"tr": _("Turkish"),
|
||||
"uk": _("Ukrainian"),
|
||||
"ur": _("Urdu"),
|
||||
"uz": _("Uzbek"),
|
||||
"ug": _("Uighur"),
|
||||
"vi": _("Vietnamese"),
|
||||
"cy": _("Welsh"),
|
||||
"yi": _("Yiddish")
|
||||
}
|
||||
|
||||
def available_languages():
|
||||
|
@@ -16,15 +16,16 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################
|
||||
import translator
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
from . import translator
|
||||
|
||||
class translateDialog(wx.Dialog):
|
||||
def __init__(self):
|
||||
super(translateDialog, self).__init__(None, -1, title=_(u"Translate message"))
|
||||
super(translateDialog, self).__init__(None, -1, title=_("Translate message"))
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
staticDest = wx.StaticText(panel, -1, _(u"Target language"))
|
||||
staticDest = wx.StaticText(panel, -1, _("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)
|
||||
|
@@ -1,13 +1,14 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import sys
|
||||
from . import fix_requests
|
||||
|
||||
if hasattr(sys, "frozen"):
|
||||
from . import fix_win32com
|
||||
from . import fix_libloader
|
||||
#if hasattr(sys, "frozen"):
|
||||
from . import fix_win32com
|
||||
from . import fix_libloader
|
||||
|
||||
def setup():
|
||||
fix_requests.fix()
|
||||
if hasattr(sys, "frozen"):
|
||||
fix_libloader.fix()
|
||||
fix_win32com.fix()
|
||||
# if hasattr(sys, "frozen"):
|
||||
fix_libloader.fix()
|
||||
fix_win32com.fix()
|
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import win32com
|
||||
import paths
|
||||
win32com.__gen_path__=paths.com_path()
|
||||
win32com.__build_path__=paths.com_path()
|
||||
import sys
|
||||
import os
|
||||
sys.path.append(os.path.join(win32com.__gen_path__, "."))
|
||||
|
@@ -1,4 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import requests
|
||||
import paths
|
||||
import os
|
||||
@@ -7,5 +8,5 @@ log = logging.getLogger("fixes.fix_requests")
|
||||
|
||||
def fix():
|
||||
log.debug("Applying fix for requests...")
|
||||
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)))
|
||||
os.environ["REQUESTS_CA_BUNDLE"] = os.path.join(paths.app_path(), "cacert.pem")#.encode(paths.fsencoding)
|
||||
# log.debug("Changed CA path to %s" % (os.environ["REQUESTS_CA_BUNDLE"]))#.decode(paths.fsencoding)))
|
@@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
import win32com.client
|
||||
def fix():
|
||||
if win32com.client.gencache.is_readonly == True:
|
||||
|
70
src/installer.nsi
Normal file
70
src/installer.nsi
Normal file
@@ -0,0 +1,70 @@
|
||||
!include "MUI2.nsh"
|
||||
!include "LogicLib.nsh"
|
||||
Unicode true
|
||||
CRCCheck on
|
||||
ManifestSupportedOS all
|
||||
XPStyle on
|
||||
Name "Socializer"
|
||||
OutFile "socializer_0.20_setup.exe"
|
||||
InstallDir "$PROGRAMFILES\socializer"
|
||||
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "InstallLocation"
|
||||
RequestExecutionLevel admin
|
||||
SetCompress auto
|
||||
SetCompressor /solid lzma
|
||||
SetDatablockOptimize on
|
||||
VIAddVersionKey ProductName "Socializer"
|
||||
VIAddVersionKey LegalCopyright "Copyright 2019 Manuel Cortez."
|
||||
VIAddVersionKey ProductVersion "0.20"
|
||||
VIAddVersionKey FileVersion "0.20"
|
||||
VIProductVersion "0.20.0.0"
|
||||
VIFileVersion "0.20.0.0"
|
||||
!insertmacro MUI_PAGE_WELCOME
|
||||
!insertmacro MUI_PAGE_DIRECTORY
|
||||
var StartMenuFolder
|
||||
!insertmacro MUI_PAGE_STARTMENU startmenu $StartMenuFolder
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
!define MUI_FINISHPAGE_LINK "Visit Socializer website"
|
||||
!define MUI_FINISHPAGE_LINK_LOCATION "http://socializer.su"
|
||||
!define MUI_FINISHPAGE_RUN "$INSTDIR\socializer.exe"
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
!insertmacro MUI_LANGUAGE "Russian"
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
!insertmacro MUI_LANGUAGE "Spanish"
|
||||
|
||||
!insertmacro MUI_RESERVEFILE_LANGDLL
|
||||
Section
|
||||
SetShellVarContext All
|
||||
SetOutPath "$INSTDIR"
|
||||
File /r dist\main\*
|
||||
CreateShortCut "$DESKTOP\socializer.lnk" "$INSTDIR\socializer.exe"
|
||||
!insertmacro MUI_STARTMENU_WRITE_BEGIN startmenu
|
||||
CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
|
||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\socializer.lnk" "$INSTDIR\socializer.exe"
|
||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Socializer on the web.lnk" "http://socializer.su"
|
||||
CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
||||
!insertmacro MUI_STARTMENU_WRITE_END
|
||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayName" "Socializer"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "UninstallString" '"$INSTDIR\uninstall.exe"'
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "Publisher" "Manuel Cortez"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayVersion" "0.20"
|
||||
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "URLInfoAbout" "http://socializer.su"
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMajor" 0
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMinor" 19
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "NoModify" 1
|
||||
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "NoRepair" 1
|
||||
SectionEnd
|
||||
Section "Uninstall"
|
||||
SetShellVarContext All
|
||||
DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer"
|
||||
RMDir /r /REBOOTOK $INSTDIR
|
||||
Delete "$DESKTOP\socializer.lnk"
|
||||
!insertmacro MUI_STARTMENU_GETFOLDER startmenu $StartMenuFolder
|
||||
RMDir /r "$SMPROGRAMS\$StartMenuFolder"
|
||||
SectionEnd
|
||||
Function .onInit
|
||||
!insertmacro MUI_LANGDLL_DISPLAY
|
||||
FunctionEnd
|
6
src/interactors/__init__.py
Normal file
6
src/interactors/__init__.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from .attach import *
|
||||
from . audioRecorder import *
|
||||
from .configuration import *
|
||||
from .postCreation import *
|
||||
from .postDisplayer import *
|
||||
from .profiles import *
|
93
src/interactors/attach.py
Normal file
93
src/interactors/attach.py
Normal file
@@ -0,0 +1,93 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import widgetUtils
|
||||
from pubsub import pub
|
||||
from wxUI.dialogs import selector
|
||||
from wxUI.menus import attachMenu
|
||||
from . import base
|
||||
|
||||
class attachInteractor(base.baseInteractor):
|
||||
|
||||
def insert_attachment(self, attachment):
|
||||
self.view.attachments.insert_item(False, *attachment)
|
||||
|
||||
def remove_attachment(self, attachment):
|
||||
self.view.attachments.remove_item(attachment)
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(attachInteractor, self).install(*args, **kwargs)
|
||||
widgetUtils.connect_event(self.view.photo, widgetUtils.BUTTON_PRESSED, self.on_image)
|
||||
widgetUtils.connect_event(self.view.audio, widgetUtils.BUTTON_PRESSED, self.on_audio)
|
||||
widgetUtils.connect_event(self.view.document, widgetUtils.BUTTON_PRESSED, self.on_document)
|
||||
if hasattr(self.view, "voice_message"):
|
||||
widgetUtils.connect_event(self.view.voice_message, widgetUtils.BUTTON_PRESSED, self.on_upload_voice_message)
|
||||
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_attachment)
|
||||
pub.subscribe(self.insert_attachment, self.modulename+"_insert_attachment")
|
||||
pub.subscribe(self.remove_attachment, self.modulename+"_remove_attachment")
|
||||
|
||||
def uninstall(self):
|
||||
super(attachInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.insert_attachment, self.modulename+"_insert_attachment")
|
||||
pub.unsubscribe(self.remove_attachment, self.modulename+"_remove_attachment")
|
||||
|
||||
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.on_upload_image, menuitem=m.upload)
|
||||
self.view.PopupMenu(m, self.view.photo.GetPosition())
|
||||
|
||||
def on_audio(self, *args, **kwargs):
|
||||
""" display menu to add audio attachments."""
|
||||
m = attachMenu()
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.on_upload_audio, menuitem=m.upload)
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.on_add_audio, menuitem=m.add)
|
||||
self.view.PopupMenu(m, self.view.audio.GetPosition())
|
||||
|
||||
def on_document(self, *args, **kwargs):
|
||||
""" display menu for adding document attachments. """
|
||||
m = attachMenu()
|
||||
# disable add from VK as it is not supported in documents, yet.
|
||||
m.add.Enable(False)
|
||||
widgetUtils.connect_event(m, widgetUtils.MENU, self.on_upload_document, menuitem=m.upload)
|
||||
self.view.PopupMenu(m, self.view.photo.GetPosition())
|
||||
|
||||
def on_upload_image(self, *args, **kwargs):
|
||||
""" allows uploading an image from the computer.
|
||||
"""
|
||||
image, description = self.view.get_image()
|
||||
if image != None:
|
||||
self.presenter.upload_image(image, description)
|
||||
|
||||
def on_upload_audio(self, *args, **kwargs):
|
||||
""" Allows uploading an audio file from the computer. Only mp3 files are supported. """
|
||||
audio = self.view.get_audio()
|
||||
if audio != None:
|
||||
self.presenter.upload_audio(audio)
|
||||
|
||||
def on_upload_document(self, *args, **kwargs):
|
||||
""" allows uploading a document from the computer.
|
||||
"""
|
||||
document = self.view.get_document()
|
||||
if document != None:
|
||||
if document.endswith(".mp3") or document.endswith(".exe"):
|
||||
self.view.invalid_attachment()
|
||||
return
|
||||
self.presenter.upload_document(document)
|
||||
|
||||
def on_upload_voice_message(self, *args, **kwargs):
|
||||
self.presenter.upload_voice_message()
|
||||
|
||||
def on_add_audio(self, *args, **kwargs):
|
||||
""" Allow adding an audio directly from the user's audio library."""
|
||||
audios = self.presenter.get_available_audios()
|
||||
select = selector.selectAttachment(_("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()
|
||||
self.presenter.take_audios(attachments)
|
||||
|
||||
def on_remove_attachment(self, *args, **kwargs):
|
||||
""" Remove the currently focused item from the attachments list."""
|
||||
current_item = self.view.attachments.get_selected()
|
||||
self.presenter.remove_attachment(current_item)
|
29
src/interactors/audioRecorder.py
Normal file
29
src/interactors/audioRecorder.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import widgetUtils
|
||||
from pubsub import pub
|
||||
from . import base
|
||||
|
||||
class audioRecorderInteractor(base.baseInteractor):
|
||||
def install(self, presenter, view, modulename="audiorecorder"):
|
||||
super(audioRecorderInteractor, self).install(view=view, presenter=presenter, modulename=modulename)
|
||||
widgetUtils.connect_event(view.play, widgetUtils.BUTTON_PRESSED, self.on_play)
|
||||
widgetUtils.connect_event(view.record, widgetUtils.BUTTON_PRESSED, self.on_record)
|
||||
widgetUtils.connect_event(view.discard, widgetUtils.BUTTON_PRESSED, self.on_discard)
|
||||
|
||||
def start(self):
|
||||
result = self.view.get_response()
|
||||
if result == widgetUtils.OK:
|
||||
self.on_postprocess()
|
||||
|
||||
def on_record(self, *args, **kwargs):
|
||||
self.presenter.toggle_recording()
|
||||
|
||||
def on_discard(self, *args, **kwargs):
|
||||
self.presenter.discard_recording()
|
||||
|
||||
def on_play(self, *args, **kwargs):
|
||||
self.presenter.play()
|
||||
|
||||
def on_postprocess(self):
|
||||
self.presenter.postprocess()
|
40
src/interactors/base.py
Normal file
40
src/interactors/base.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from pubsub import pub
|
||||
|
||||
class baseInteractor(object):
|
||||
|
||||
def install(self, view, presenter, modulename):
|
||||
self.modulename = modulename
|
||||
self.view = view
|
||||
self.presenter = presenter
|
||||
pub.subscribe(self.disable_control, "{modulename}_disable_control".format(modulename=modulename))
|
||||
pub.subscribe(self.enable_control, "{modulename}_enable_control".format(modulename=modulename))
|
||||
pub.subscribe(self.set_label, "{modulename}_set_label".format(modulename=modulename))
|
||||
pub.subscribe(self.focus_control, "{modulename}_focus_control".format(modulename=modulename))
|
||||
pub.subscribe(self.set_title, "{modulename}_set_title".format(modulename=modulename))
|
||||
|
||||
def uninstall(self):
|
||||
pub.unsubscribe(self.disable_control, "{modulename}_disable_control".format(modulename=self.modulename))
|
||||
pub.unsubscribe(self.enable_control, "{modulename}_enable_control".format(modulename=self.modulename))
|
||||
pub.unsubscribe(self.set_label, "{modulename}_set_label".format(modulename=self.modulename))
|
||||
pub.unsubscribe(self.focus_control, "{modulename}_focus_control".format(modulename=self.modulename))
|
||||
pub.unsubscribe(self.set_title, "{modulename}_set_title".format(modulename=self.modulename))
|
||||
self.view.Destroy()
|
||||
|
||||
def start(self):
|
||||
self.result = self.view.get_response()
|
||||
|
||||
def disable_control(self, control):
|
||||
self.view.disable(control)
|
||||
|
||||
def enable_control(self, control):
|
||||
self.view.enable(control)
|
||||
|
||||
def focus_control(self, control):
|
||||
getattr(self.view, control).SetFocus()
|
||||
|
||||
def set_label(self, control, label):
|
||||
self.view.set(control, label)
|
||||
|
||||
def set_title(self, value):
|
||||
self.view.SetTitle(value)
|
71
src/interactors/configuration.py
Normal file
71
src/interactors/configuration.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import widgetUtils
|
||||
from pubsub import pub
|
||||
from wxUI.commonMessages import restart_program as restart_program_dialog
|
||||
from . import base
|
||||
|
||||
class configurationInteractor(base.baseInteractor):
|
||||
|
||||
def create_tab(self, tab, arglist=dict()):
|
||||
getattr(self.view, "create_"+tab)(**arglist)
|
||||
|
||||
def set_setting(self, tab, setting, value):
|
||||
self.view.set_value(tab, setting, value)
|
||||
|
||||
def restart(self):
|
||||
dlg = restart_program_dialog()
|
||||
if dlg == widgetUtils.YES:
|
||||
self.presenter.restart_application()
|
||||
|
||||
def set_language(self, language):
|
||||
self.view.general.language.SetSelection(language)
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(configurationInteractor, self).install(*args, **kwargs)
|
||||
pub.subscribe(self.create_tab, self.modulename+"_create_tab")
|
||||
pub.subscribe(self.set_setting, self.modulename+"_set")
|
||||
pub.subscribe(self.restart, self.modulename+"_restart_program")
|
||||
pub.subscribe(self.set_language, self.modulename+"_set_language")
|
||||
|
||||
def uninstall(self):
|
||||
super(configurationInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.create_tab, self.modulename+"_create_tab")
|
||||
pub.unsubscribe(self.set_setting, self.modulename+"_set")
|
||||
pub.unsubscribe(self.restart, self.modulename+"_restart_program")
|
||||
pub.unsubscribe(self.set_language, self.modulename+"_set_language")
|
||||
|
||||
def start(self):
|
||||
self.view.realize()
|
||||
result = self.view.get_response()
|
||||
if result == widgetUtils.OK:
|
||||
self.on_save_settings()
|
||||
|
||||
def on_save_settings(self, *args, **kwargs):
|
||||
self.presenter.update_setting(section="buffers", setting="count_for_wall_buffers", value=self.view.get_value("general", "wall_buffer_count"))
|
||||
self.presenter.update_setting(section="buffers", setting="count_for_video_buffers", value=self.view.get_value("general", "video_buffers_count"))
|
||||
self.presenter.update_setting(section="general", setting="load_images", value=self.view.get_value("general", "load_images"))
|
||||
update_channel = self.presenter.get_update_channel_type(self.view.get_value("general", "update_channel"))
|
||||
if update_channel != self.presenter.session.settings["general"]["update_channel"]:
|
||||
if update_channel == "stable":
|
||||
self.presenter.update_setting(section="general", setting="update_channel", value=update_channel)
|
||||
elif update_channel == "weekly":
|
||||
dialog = self.view.weekly_channel()
|
||||
if dialog == widgetUtils.YES:
|
||||
self.presenter.update_setting(section="general", setting="update_channel", value=update_channel)
|
||||
elif update_channel == "alpha":
|
||||
dialog = self.view.alpha_channel()
|
||||
if dialog == widgetUtils.YES:
|
||||
self.presenter.update_setting(section="general", setting="update_channel", value=update_channel)
|
||||
self.presenter.update_setting(section="chat", setting="notify_online", value=self.view.get_value("chat", "notify_online"))
|
||||
self.presenter.update_setting(section="chat", setting="notify_offline", value=self.view.get_value("chat", "notify_offline"))
|
||||
self.presenter.update_setting(section="chat", setting="notifications", value=self.presenter.get_notification_type(self.view.get_value("chat", "notifications")))
|
||||
self.presenter.update_setting(section="load_at_startup", setting="audio_albums", value=self.view.get_value("startup", "audio_albums"))
|
||||
self.presenter.update_setting(section="load_at_startup", setting="video_albums", value=self.view.get_value("startup", "video_albums"))
|
||||
self.presenter.update_setting(section="load_at_startup", setting="communities", value=self.view.get_value("startup", "communities"))
|
||||
self.presenter.update_app_setting(section="app-settings", setting="language", value=self.presenter.codes[self.view.general.language.GetSelection()])
|
||||
self.presenter.update_app_setting(section="sound", setting="input_device", value=self.view.get_value("sound", "input"))
|
||||
self.presenter.update_app_setting(section="sound", setting="output_device", value=self.view.get_value("sound", "output"))
|
||||
self.presenter.update_app_setting(section="app-settings", setting="use_proxy", value=self.view.get_value("general", "use_proxy"))
|
||||
self.presenter.save_app_settings_file()
|
||||
self.presenter.save_settings_file()
|
71
src/interactors/postCreation.py
Normal file
71
src/interactors/postCreation.py
Normal file
@@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import widgetUtils
|
||||
from wxUI.dialogs import selector
|
||||
from pubsub import pub
|
||||
from extra import translator
|
||||
from .import base
|
||||
|
||||
class createPostInteractor(base.baseInteractor):
|
||||
|
||||
def set(self, control, value):
|
||||
if not hasattr(self.view, control):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
getattr(self.view, control).SetValue(value)
|
||||
|
||||
def add_tagged_users(self, users):
|
||||
self.view.text.SetValue(self.view.text.GetValue()+", ".join(users))
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(createPostInteractor, self).install(*args, **kwargs)
|
||||
widgetUtils.connect_event(self.view.spellcheck, widgetUtils.BUTTON_PRESSED, self.on_spellcheck)
|
||||
widgetUtils.connect_event(self.view.translateButton, widgetUtils.BUTTON_PRESSED, self.on_translate)
|
||||
widgetUtils.connect_event(self.view.mention, widgetUtils.BUTTON_PRESSED, self.on_mention)
|
||||
if hasattr(self.view, "attach"):
|
||||
widgetUtils.connect_event(self.view.attach, widgetUtils.BUTTON_PRESSED, self.on_add_attachments)
|
||||
pub.subscribe(self.set, self.modulename+"_set")
|
||||
pub.subscribe(self.add_tagged_users, self.modulename+"_add_tagged_users")
|
||||
|
||||
def uninstall(self):
|
||||
super(createPostInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.set, self.modulename+"_set")
|
||||
pub.unsubscribe(self.add_tagged_users, self.modulename+"_add_tagged_users")
|
||||
|
||||
def start(self):
|
||||
self.result = self.view.get_response()
|
||||
if self.result == widgetUtils.OK:
|
||||
self.presenter.text = self.view.get_text()
|
||||
if hasattr(self.view, "privacy"):
|
||||
self.presenter.privacy = self.get_privacy_options()
|
||||
else:
|
||||
self.presenter.privacy = 0
|
||||
|
||||
def get_privacy_options(self):
|
||||
p = self.view.get("privacy")
|
||||
if p == _("Friends of friends"):
|
||||
privacy = 0
|
||||
elif p == _("All users"):
|
||||
privacy = 1
|
||||
return privacy
|
||||
|
||||
def on_mention(self, *args, **kwargs):
|
||||
users = self.presenter.get_friends()
|
||||
select = selector.selectPeople(users)
|
||||
if select.get_response() == widgetUtils.OK and select.users.GetCount() > 0:
|
||||
tagged_users = select.get_all_users()
|
||||
self.presenter.add_tagged_users(tagged_users)
|
||||
|
||||
def on_translate(self, *args, **kwargs):
|
||||
dlg = translator.gui.translateDialog()
|
||||
if dlg.get_response() == widgetUtils.OK:
|
||||
text_to_translate = self.view.get_text()
|
||||
dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
|
||||
self.presenter.translate(text_to_translate, dest)
|
||||
dlg.Destroy()
|
||||
|
||||
def on_spellcheck(self, event=None):
|
||||
text = self.view.get_text()
|
||||
self.presenter.spellcheck(text)
|
||||
|
||||
def on_add_attachments(self, *args, **kwargs):
|
||||
self.presenter.add_attachments()
|
285
src/interactors/postDisplayer.py
Normal file
285
src/interactors/postDisplayer.py
Normal file
@@ -0,0 +1,285 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import six
|
||||
import widgetUtils
|
||||
import wx
|
||||
from pubsub import pub
|
||||
from wxUI import menus
|
||||
from wxUI import commonMessages
|
||||
from .import base
|
||||
|
||||
class displayPostInteractor(base.baseInteractor):
|
||||
|
||||
def set(self, control, value):
|
||||
if not hasattr(self.view, control):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
getattr(self.view, control).SetValue(value)
|
||||
|
||||
def load_image(self, image):
|
||||
image = wx.Image(stream=six.BytesIO(image.content))
|
||||
try:
|
||||
self.view.image.SetBitmap(wx.Bitmap(image))
|
||||
except ValueError:
|
||||
return
|
||||
self.view.panel.Layout()
|
||||
|
||||
def add_items(self, control, items):
|
||||
if not hasattr(self.view, control):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
for i in items:
|
||||
getattr(self.view, control).insert_item(False, *i)
|
||||
|
||||
def add_item(self, control, item, reversed=False):
|
||||
if not hasattr(self.view, control):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
getattr(self.view, control).insert_item(reversed, *item)
|
||||
|
||||
def enable_attachments(self):
|
||||
self.view.attachments.list.Enable(True)
|
||||
|
||||
def enable_photo_controls(self, navigation):
|
||||
self.view.enable_photo_controls(navigation)
|
||||
|
||||
def clean_list(self, list):
|
||||
if not hasattr(self.view, list):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
getattr(self.view, list).clear()
|
||||
|
||||
def post_deleted(self):
|
||||
msg = commonMessages.post_deleted()
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(displayPostInteractor, self).install(*args, **kwargs)
|
||||
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_show_comment)
|
||||
self.view.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_open_attachment)
|
||||
widgetUtils.connect_event(self.view.like, widgetUtils.BUTTON_PRESSED, self.on_like)
|
||||
widgetUtils.connect_event(self.view.comment, widgetUtils.BUTTON_PRESSED, self.on_add_comment)
|
||||
widgetUtils.connect_event(self.view.tools, widgetUtils.BUTTON_PRESSED, self.on_show_tools_menu)
|
||||
if hasattr(self.view, "likes"):
|
||||
widgetUtils.connect_event(self.view.likes, widgetUtils.BUTTON_PRESSED, self.on_show_likes_menu)
|
||||
if hasattr(self.view, "shares"):
|
||||
widgetUtils.connect_event(self.view.shares, widgetUtils.BUTTON_PRESSED, self.on_show_shares_menu)
|
||||
if hasattr(self.view, "repost"):
|
||||
widgetUtils.connect_event(self.view.repost, widgetUtils.BUTTON_PRESSED, self.on_repost)
|
||||
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_focus)
|
||||
if hasattr(self.view, "reply"):
|
||||
widgetUtils.connect_event(self.view.reply, widgetUtils.BUTTON_PRESSED, self.on_reply)
|
||||
if hasattr(self.view, "load_more_comments"):
|
||||
widgetUtils.connect_event(self.view.load_more_comments, widgetUtils.BUTTON_PRESSED, self.on_load_more_comments)
|
||||
# self.view.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_show_menu, self.view.comments.list)
|
||||
# self.view.Bind(wx.EVT_LIST_KEY_DOWN, self.on_show_menu_by_key, self.view.comments.list)
|
||||
pub.subscribe(self.set, self.modulename+"_set")
|
||||
pub.subscribe(self.load_image, self.modulename+"_load_image")
|
||||
pub.subscribe(self.add_items, self.modulename+"_add_items")
|
||||
pub.subscribe(self.add_item, self.modulename+"_add_item")
|
||||
pub.subscribe(self.enable_attachments, self.modulename+"_enable_attachments")
|
||||
pub.subscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls")
|
||||
pub.subscribe(self.post_deleted, self.modulename+"_post_deleted")
|
||||
pub.subscribe(self.clean_list, self.modulename+"_clean_list")
|
||||
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_comment_changed)
|
||||
|
||||
def uninstall(self):
|
||||
super(displayPostInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.set, self.modulename+"_set")
|
||||
pub.unsubscribe(self.load_image, self.modulename+"_load_image")
|
||||
pub.unsubscribe(self.add_items, self.modulename+"_add_items")
|
||||
pub.unsubscribe(self.add_item, self.modulename+"_add_item")
|
||||
pub.unsubscribe(self.enable_attachments, self.modulename+"_enable_attachments")
|
||||
pub.unsubscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls")
|
||||
pub.unsubscribe(self.post_deleted, self.modulename+"_post_deleted")
|
||||
pub.unsubscribe(self.clean_list, self.modulename+"_clean_list")
|
||||
|
||||
def on_focus(self, *args, **kwargs):
|
||||
item = self.view.comments.get_selected()
|
||||
if item == -1:
|
||||
self.view.reply.Enable(False)
|
||||
else:
|
||||
self.view.reply.Enable(True)
|
||||
|
||||
def on_like(self, *args, **kwargs):
|
||||
self.presenter.post_like()
|
||||
|
||||
def on_repost(self, *args, **kwargs):
|
||||
self.presenter.post_repost()
|
||||
|
||||
def on_reply(self, *args, **kwargs):
|
||||
if hasattr(self.view, "repost") or not hasattr(self, "post_view"):
|
||||
comment = self.view.comments.get_selected()
|
||||
self.presenter.reply(comment)
|
||||
else:
|
||||
self.presenter.reply()
|
||||
|
||||
def on_add_comment(self, *args, **kwargs):
|
||||
self.presenter.add_comment()
|
||||
|
||||
def on_load_more_comments(self, *args, **kwargs):
|
||||
if hasattr(self.presenter, "load_more_comments"):
|
||||
self.presenter.load_more_comments()
|
||||
|
||||
def on_show_tools_menu(self, *args, **kwargs):
|
||||
menu = menus.toolsMenu()
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_open_url, menuitem=menu.url)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_translate, menuitem=menu.translate)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_spellcheck, menuitem=menu.CheckSpelling)
|
||||
self.view.PopupMenu(menu, self.view.tools.GetPosition())
|
||||
|
||||
def on_open_url(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def on_open_attachment(self, *args, **kwargs):
|
||||
attachment = self.view.attachments.get_selected()
|
||||
self.presenter.open_attachment(attachment)
|
||||
|
||||
def on_translate(self, *args, **kwargs):
|
||||
dlg = translator.gui.translateDialog()
|
||||
if dlg.get_response() == widgetUtils.OK:
|
||||
text_to_translate = self.view.get("post_view")
|
||||
dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
|
||||
self.presenter.translate(text_to_translate, dest)
|
||||
dlg.Destroy()
|
||||
|
||||
def on_spellcheck(self, event=None):
|
||||
text = self.view.get("post_view")
|
||||
self.presenter.spellcheck(text)
|
||||
|
||||
def on_show_comment(self, *args, **kwargs):
|
||||
comment = self.view.comments.get_selected()
|
||||
self.presenter.show_comment(comment)
|
||||
|
||||
def on_comment_changed(self, *args, **kwargs):
|
||||
if hasattr(self.presenter, "change_comment"):
|
||||
comment = self.view.comments.get_selected()
|
||||
self.presenter.change_comment(comment)
|
||||
|
||||
def on_show_likes_menu(self, *args, **kwargs):
|
||||
self.presenter.show_likes()
|
||||
|
||||
def on_show_shares_menu(self, *args, **kwargs):
|
||||
self.presenter.show_shares()
|
||||
|
||||
class displayAudioInteractor(base.baseInteractor):
|
||||
|
||||
def set(self, control, value):
|
||||
if not hasattr(self.view, control):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
getattr(self.view, control).SetValue(value)
|
||||
|
||||
def add_items(self, control, items):
|
||||
if not hasattr(self.view, control):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
for i in items:
|
||||
getattr(self.view, control).Append(i)
|
||||
getattr(self.view, control).SetSelection(0)
|
||||
|
||||
def change_label(self, stopped):
|
||||
|
||||
if stopped == False:
|
||||
self.view.play.SetLabel(_("P&ause"))
|
||||
else:
|
||||
self.view.play.SetLabel(_("P&lay"))
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(displayAudioInteractor, self).install(*args, **kwargs)
|
||||
widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_CHANGED, self.on_change)
|
||||
widgetUtils.connect_event(self.view.download, widgetUtils.BUTTON_PRESSED, self.on_download)
|
||||
widgetUtils.connect_event(self.view.play, widgetUtils.BUTTON_PRESSED, self.on_play)
|
||||
widgetUtils.connect_event(self.view.add, widgetUtils.BUTTON_PRESSED, self.on_add_to_library)
|
||||
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_from_library)
|
||||
pub.subscribe(self.set, self.modulename+"_set")
|
||||
pub.subscribe(self.add_items, self.modulename+"_add_items")
|
||||
pub.subscribe(self.change_label, "playback-changed")
|
||||
|
||||
def uninstall(self):
|
||||
super(displayAudioInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.set, self.modulename+"_set")
|
||||
pub.unsubscribe(self.add_items, self.modulename+"_add_items")
|
||||
pub.unsubscribe(self.change_label, "playback-changed")
|
||||
|
||||
def on_change(self, *args, **kwargs):
|
||||
post = self.view.get_audio()
|
||||
self.presenter.handle_changes(post)
|
||||
|
||||
def on_download(self, *args, **kwargs):
|
||||
post = self.view.get_audio()
|
||||
suggested_filename = self.presenter.get_suggested_filename(post)
|
||||
path = self.view.get_destination_path(suggested_filename)
|
||||
self.presenter.download(post, path)
|
||||
|
||||
def on_play(self, *args, **kwargs):
|
||||
post = self.view.get_audio()
|
||||
self.presenter.play(post)
|
||||
|
||||
def on_add_to_library(self, *args, **kwargs):
|
||||
post = self.view.get_audio()
|
||||
self.presenter.add_to_library(post)
|
||||
|
||||
def on_remove_from_library(self, *args, **kwargs):
|
||||
post = self.view.get_audio()
|
||||
self.presenter.remove_from_library(post)
|
||||
|
||||
class displayPollInteractor(base.baseInteractor):
|
||||
|
||||
def set(self, control, value):
|
||||
if not hasattr(self.view, control):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
getattr(self.view, control).SetValue(value)
|
||||
|
||||
def done(self):
|
||||
self.view.done()
|
||||
|
||||
def add_options(self, options, multiple):
|
||||
self.view.add_options(options, multiple)
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(displayPollInteractor, self).install(*args, **kwargs)
|
||||
pub.subscribe(self.set, self.modulename+"_set")
|
||||
pub.subscribe(self.done, self.modulename+"_done")
|
||||
pub.subscribe(self.add_options, self.modulename+"_add_options")
|
||||
|
||||
def uninstall(self):
|
||||
super(displayPollInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.set, self.modulename+"_set")
|
||||
pub.unsubscribe(self.done, self.modulename+"_done")
|
||||
pub.unsubscribe(self.add_options, self.modulename+"_add_options")
|
||||
|
||||
def start(self, *args, **kwargs):
|
||||
super(displayPollInteractor, self).start(*args, **kwargs)
|
||||
if self.result == widgetUtils.OK: # USer votd.
|
||||
answers = self.view.get_answers()
|
||||
self.presenter.vote(answers)
|
||||
|
||||
class displayFriendshipInteractor(base.baseInteractor):
|
||||
|
||||
def add_items(self, control, items):
|
||||
if not hasattr(self.view, control):
|
||||
raise AttributeError("The control is not present in the view.")
|
||||
for i in items:
|
||||
getattr(self.view, control).insert_item(False, *[i])
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(displayFriendshipInteractor, self).install(*args, **kwargs)
|
||||
pub.subscribe(self.add_items, self.modulename+"_add_items")
|
||||
self.view.friends.list.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu)
|
||||
|
||||
def uninstall(self):
|
||||
super(displayFriendshipInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.add_items, self.modulename+"_add_items")
|
||||
|
||||
def on_context_menu(self, *args, **kwargs):
|
||||
item = self.view.friends.get_selected()
|
||||
if item < 0:
|
||||
return
|
||||
menu = menus.peopleMenu(False, False, True)
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.on_view_profile, menuitem=menu.view_profile)
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.on_open_in_browser, menuitem=menu.open_in_browser)
|
||||
# Generally message sending is blocked.
|
||||
menu.message.Enable(False)
|
||||
self.view.PopupMenu(menu, self.view.friends.list.GetPosition())
|
||||
|
||||
def on_view_profile(self, *args, **kwargs):
|
||||
item = self.view.friends.get_selected()
|
||||
self.presenter.view_profile(item)
|
||||
|
||||
def on_open_in_browser(self, *args, **kwargs):
|
||||
item = self.view.friends.get_selected()
|
||||
self.presenter.open_in_browser(item)
|
70
src/interactors/profiles.py
Normal file
70
src/interactors/profiles.py
Normal file
@@ -0,0 +1,70 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import six
|
||||
import wx
|
||||
import widgetUtils
|
||||
from pubsub import pub
|
||||
from views.dialogs import urlList
|
||||
from . import base
|
||||
|
||||
class userProfileInteractor(base.baseInteractor):
|
||||
|
||||
def enable_control(self, tab, control):
|
||||
if not hasattr(self.view, tab):
|
||||
raise AttributeError("The viw does not contain the specified tab.")
|
||||
tab = getattr(self.view, tab)
|
||||
if not hasattr(tab, control):
|
||||
raise AttributeError("The control is not present in the tab.")
|
||||
getattr(tab, control).Enable(True)
|
||||
|
||||
def set(self, tab, control, value):
|
||||
if not hasattr(self.view, tab):
|
||||
raise AttributeError("The view does not contain the specified tab.")
|
||||
tab = getattr(self.view, tab)
|
||||
if not hasattr(tab, control):
|
||||
raise AttributeError("The control is not present in the tab.")
|
||||
control = getattr(tab, control)
|
||||
control.SetValue(value)
|
||||
|
||||
def set_label(self, tab, control, value):
|
||||
if not hasattr(self.view, tab):
|
||||
raise AttributeError("The viw does not contain the specified tab.")
|
||||
tab = getattr(self.view, tab)
|
||||
if not hasattr(tab, control):
|
||||
raise AttributeError("The control is not present in the tab.")
|
||||
control = getattr(tab, control)
|
||||
control.SetLabel(value)
|
||||
|
||||
def load_image(self, image):
|
||||
image = wx.Image(stream=six.BytesIO(image.content))
|
||||
try:
|
||||
self.view.image.SetBitmap(wx.Bitmap(image))
|
||||
except ValueError:
|
||||
return
|
||||
self.view.panel.Layout()
|
||||
|
||||
def install(self, *args, **kwargs):
|
||||
super(userProfileInteractor, self).install(*args, **kwargs)
|
||||
pub.subscribe(self.set, self.modulename+"_set")
|
||||
pub.subscribe(self.load_image, self.modulename+"_load_image")
|
||||
self.view.create_controls("main_info")
|
||||
self.view.realice()
|
||||
widgetUtils.connect_event(self.view.main_info.go_site, widgetUtils.BUTTON_PRESSED, self.on_visit_website)
|
||||
|
||||
def uninstall(self):
|
||||
super(userProfileInteractor, self).uninstall()
|
||||
pub.unsubscribe(self.set, self.modulename+"_set")
|
||||
pub.unsubscribe(self.load_image, self.modulename+"_load_image")
|
||||
|
||||
|
||||
def on_visit_website(self, *args, **kwargs):
|
||||
urls = self.presenter.get_urls()
|
||||
if len(urls) == 1:
|
||||
self.presenter.visit_url(urls[0])
|
||||
else:
|
||||
dialog = urlList.urlList()
|
||||
dialog.populate_list(urls)
|
||||
if dialog.get_response() != widgetUtils.OK:
|
||||
return
|
||||
selected_url = urls[dialog.get_item()]
|
||||
self.presenter.visit_url(selected_url)
|
@@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import platform
|
||||
import requests
|
||||
@@ -51,7 +52,7 @@ class reportBug(object):
|
||||
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_name = "{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()
|
||||
|
@@ -16,6 +16,7 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
############################################################
|
||||
from __future__ import unicode_literals
|
||||
import wx
|
||||
import widgetUtils
|
||||
import application
|
||||
@@ -23,11 +24,11 @@ import application
|
||||
class reportBugDialog(widgetUtils.BaseDialog):
|
||||
def __init__(self):
|
||||
super(reportBugDialog, self).__init__(parent=None, id=wx.NewId())
|
||||
self.SetTitle(_(u"Report an error"))
|
||||
self.SetTitle(_("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)
|
||||
summaryLabel = wx.StaticText(panel, -1, _("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())
|
||||
@@ -37,7 +38,7 @@ class reportBugDialog(widgetUtils.BaseDialog):
|
||||
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)
|
||||
first_nameLabel = wx.StaticText(panel, -1, _("First Name"), size=wx.DefaultSize)
|
||||
self.first_name = wx.TextCtrl(panel, -1)
|
||||
dc = wx.WindowDC(self.first_name)
|
||||
dc.SetFont(self.first_name.GetFont())
|
||||
@@ -47,7 +48,7 @@ class reportBugDialog(widgetUtils.BaseDialog):
|
||||
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)
|
||||
last_nameLabel = wx.StaticText(panel, -1, _("Last Name"), size=wx.DefaultSize)
|
||||
self.last_name = wx.TextCtrl(panel, -1)
|
||||
dc = wx.WindowDC(self.last_name)
|
||||
dc.SetFont(self.last_name.GetFont())
|
||||
@@ -57,7 +58,7 @@ class reportBugDialog(widgetUtils.BaseDialog):
|
||||
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)
|
||||
emailLabel = wx.StaticText(panel, -1, _("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())
|
||||
@@ -67,7 +68,7 @@ class reportBugDialog(widgetUtils.BaseDialog):
|
||||
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)
|
||||
descriptionLabel = wx.StaticText(panel, -1, _("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())
|
||||
@@ -77,12 +78,12 @@ class reportBugDialog(widgetUtils.BaseDialog):
|
||||
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 = wx.CheckBox(panel, -1, _("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 = wx.Button(panel, wx.ID_OK, _("Send report"))
|
||||
self.ok.SetDefault()
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, _("Cancel"))
|
||||
btnBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
btnBox.Add(self.ok, 0, wx.ALL, 5)
|
||||
btnBox.Add(cancel, 0, wx.ALL, 5)
|
||||
@@ -91,19 +92,19 @@ class reportBugDialog(widgetUtils.BaseDialog):
|
||||
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()
|
||||
wx.MessageDialog(self, _("You must fill out the following fields: first name, last name, email address and issue information."), _("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()
|
||||
wx.MessageDialog(self, _("You need to mark the checkbox to provide us your email address to contact you if it is necessary."), _("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()
|
||||
wx.MessageDialog(self, _("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), _("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()
|
||||
wx.MessageDialog(self, _("Something unexpected occurred while trying to report the bug. Please, try again later"), _("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 = wx.ProgressDialog(title=_("Sending report..."), message=_("Please wait while your report is being send."), maximum=100, parent=self)
|
||||
self.progress.ShowModal()
|
@@ -1,4 +1,9 @@
|
||||
import __builtin__
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
from builtins import zip
|
||||
from builtins import str
|
||||
import builtins
|
||||
import os
|
||||
import sys
|
||||
import ctypes
|
||||
@@ -25,12 +30,12 @@ def localeNameToWindowsLCID(localeName):
|
||||
func_LocaleNameToLCID=getattr(ctypes.windll.kernel32,'LocaleNameToLCID',None)
|
||||
if func_LocaleNameToLCID is not None:
|
||||
localeName=localeName.replace('_','-')
|
||||
LCID=func_LocaleNameToLCID(unicode(localeName),0)
|
||||
LCID=func_LocaleNameToLCID(str(localeName),0)
|
||||
else: #Windows doesn't have this functionality, manually search Python's windows_locale dictionary for the LCID
|
||||
localeName=locale.normalize(localeName)
|
||||
if '.' in localeName:
|
||||
localeName=localeName.split('.')[0]
|
||||
LCList=[x[0] for x in locale.windows_locale.iteritems() if x[1]==localeName]
|
||||
LCList=[x[0] for x in locale.windows_locale.items() if x[1]==localeName]
|
||||
if len(LCList)>0:
|
||||
LCID=LCList[0]
|
||||
else:
|
||||
@@ -77,7 +82,7 @@ def getAvailableLanguages():
|
||||
"""
|
||||
#Make a list of all the locales found in NVDA's locale dir
|
||||
l=[x for x in os.listdir(paths.locale_path()) if not x.startswith('.')]
|
||||
l=[x for x in l if os.path.isfile(paths.locale_path('%s/LC_MESSAGES/%s.po' % (x, application.short_name)))]
|
||||
l=[x for x in l if os.path.isfile(os.path.join(paths.locale_path(), '%s/LC_MESSAGES/%s.po' % (x, application.short_name)))]
|
||||
#Make sure that en (english) is in the list as it may not have any locale files, but is default
|
||||
if 'en' not in l:
|
||||
l.append('en')
|
||||
@@ -93,7 +98,7 @@ def getAvailableLanguages():
|
||||
# Translators: the label for the Windows default NVDA interface language.
|
||||
d.append(_("User default"))
|
||||
#return a zipped up version of both the lists (a list with tuples of locale,label)
|
||||
return zip(l,d)
|
||||
return list(zip(l,d))
|
||||
|
||||
def makePgettext(translations):
|
||||
"""Obtaina pgettext function for use with a gettext translations instance.
|
||||
@@ -103,15 +108,15 @@ def makePgettext(translations):
|
||||
"""
|
||||
if isinstance(translations, gettext.GNUTranslations):
|
||||
def pgettext(context, message):
|
||||
message = unicode(message)
|
||||
message = str(message)
|
||||
try:
|
||||
# Look up the message with its context.
|
||||
return translations._catalog[u"%s\x04%s" % (context, message)]
|
||||
return translations._catalog["%s\x04%s" % (context, message)]
|
||||
except KeyError:
|
||||
return message
|
||||
else:
|
||||
def pgettext(context, message):
|
||||
return unicode(message)
|
||||
return str(message)
|
||||
return pgettext
|
||||
|
||||
def setLanguage(lang):
|
||||
@@ -161,7 +166,10 @@ def setLanguage(lang):
|
||||
except IOError:
|
||||
trans=gettext.translation(application.short_name, fallback=True)
|
||||
curLang="en"
|
||||
trans.install(unicode=True)
|
||||
if sys.version[0] == "3":
|
||||
trans.install()
|
||||
else:
|
||||
trans.install(unicode=True)
|
||||
# Install our pgettext function.
|
||||
# __builtin__.__dict__["pgettext"] = makePgettext(trans)
|
||||
|
||||
|
BIN
src/locales/es/LC_MESSAGES/wxstd.mo
Normal file
BIN
src/locales/es/LC_MESSAGES/wxstd.mo
Normal file
Binary file not shown.
BIN
src/locales/ru/LC_MESSAGES/socializer-documentation.mo
Normal file
BIN
src/locales/ru/LC_MESSAGES/socializer-documentation.mo
Normal file
Binary file not shown.
2265
src/locales/ru/LC_MESSAGES/socializer-documentation.po
Normal file
2265
src/locales/ru/LC_MESSAGES/socializer-documentation.po
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
BIN
src/locales/ru/LC_MESSAGES/wxstd.mo
Normal file
BIN
src/locales/ru/LC_MESSAGES/wxstd.mo
Normal file
Binary file not shown.
@@ -1,5 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import os
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
@@ -8,10 +7,10 @@ import sys
|
||||
|
||||
APP_LOG_FILE = 'debug.log'
|
||||
ERROR_LOG_FILE = "error.log"
|
||||
MESSAGE_FORMAT = u"%(asctime)s %(name)s %(levelname)s: %(message)s"
|
||||
DATE_FORMAT = u"%d/%m/%Y %H:%M:%S"
|
||||
MESSAGE_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s"
|
||||
DATE_FORMAT = "%d/%m/%Y %H:%M:%S"
|
||||
|
||||
formatter = logging.Formatter(MESSAGE_FORMAT.decode("utf-8"), datefmt=DATE_FORMAT)
|
||||
formatter = logging.Formatter(MESSAGE_FORMAT, datefmt=DATE_FORMAT)
|
||||
|
||||
requests_log = logging.getLogger("requests")
|
||||
requests_log.setLevel(logging.WARNING)
|
||||
@@ -21,12 +20,12 @@ logger.setLevel(logging.DEBUG)
|
||||
|
||||
#handlers
|
||||
|
||||
app_handler = RotatingFileHandler(os.path.join(paths.logs_path(), APP_LOG_FILE), mode="w")
|
||||
app_handler = RotatingFileHandler(os.path.join(paths.logs_path(), APP_LOG_FILE), mode="w", encoding="utf-8")
|
||||
app_handler.setFormatter(formatter)
|
||||
app_handler.setLevel(logging.DEBUG)
|
||||
logger.addHandler(app_handler)
|
||||
|
||||
error_handler = logging.FileHandler(os.path.join(paths.logs_path(), ERROR_LOG_FILE), mode="w")
|
||||
error_handler = logging.FileHandler(os.path.join(paths.logs_path(), ERROR_LOG_FILE), mode="w", encoding="utf-8")
|
||||
error_handler.setFormatter(formatter)
|
||||
error_handler.setLevel(logging.ERROR)
|
||||
logger.addHandler(error_handler)
|
||||
|
34
src/main.py
34
src/main.py
@@ -2,8 +2,9 @@
|
||||
import logger
|
||||
import sys
|
||||
import fixes
|
||||
if hasattr(sys, "frozen"):
|
||||
fixes.setup()
|
||||
import traceback
|
||||
#if hasattr(sys, "frozen"):
|
||||
fixes.setup()
|
||||
import platform
|
||||
import languageHandler
|
||||
import widgetUtils
|
||||
@@ -13,23 +14,42 @@ import output
|
||||
import logging
|
||||
import keys
|
||||
import application
|
||||
if hasattr(sys, "frozen"):
|
||||
sys.excepthook = lambda x, y, z: logging.critical(''.join(traceback.format_exception(x, y, z)))
|
||||
from mysc.thread_utils import call_threaded
|
||||
from wxUI import commonMessages
|
||||
|
||||
log = logging.getLogger("main")
|
||||
|
||||
orig_session_init = None
|
||||
|
||||
def setup():
|
||||
global orig_session_init
|
||||
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().decode(paths.fsencoding),))
|
||||
log.debug("Application path is %s" % (paths.app_path(),))
|
||||
log.debug("config path is %s" % (paths.config_path(),))
|
||||
output.setup()
|
||||
languageHandler.setLanguage(config.app["app-settings"]["language"])
|
||||
log.debug("Language set to %s" % (languageHandler.getLanguage()))
|
||||
keys.setup()
|
||||
app = widgetUtils.mainLoopObject()
|
||||
if config.app["app-settings"]["first_start"]:
|
||||
proxy_option = commonMessages.proxy_question()
|
||||
if proxy_option == widgetUtils.YES:
|
||||
config.app["app-settings"]["use_proxy"] = True
|
||||
config.app["app-settings"]["first_start"] = False
|
||||
config.app.write()
|
||||
if config.app["app-settings"]["use_proxy"]:
|
||||
log.debug("Enabling proxy support... ")
|
||||
import requests
|
||||
orig_session_init=requests.sessions.Session.__init__
|
||||
requests.sessions.Session.__init__=patched_session_init
|
||||
requests.Session.__init__=patched_session_init
|
||||
from controller import mainController
|
||||
from sessionmanager import sessionManager
|
||||
app = widgetUtils.mainLoopObject()
|
||||
|
||||
log.debug("Created Application mainloop object")
|
||||
sm = sessionManager.sessionManagerController()
|
||||
del sm
|
||||
@@ -37,4 +57,10 @@ def setup():
|
||||
call_threaded(r.login)
|
||||
app.run()
|
||||
|
||||
def patched_session_init(self):
|
||||
global orig_session_init
|
||||
orig_session_init(self)
|
||||
self.proxies={"http": "http://socializer:socializer@socializer.su:3128",
|
||||
"https": "http://socializer:socializer@socializer.su:3128"}
|
||||
|
||||
setup()
|
||||
|
41
src/main.spec
Normal file
41
src/main.spec
Normal file
@@ -0,0 +1,41 @@
|
||||
# -*- mode: python -*-
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(['main.py'],
|
||||
pathex=['.'],
|
||||
binaries=[("sounds", "sounds"),
|
||||
("documentation", "documentation"),
|
||||
("locales", "locales"),
|
||||
("..\\windows-dependencies\\dictionaries", "enchant\\share\\enchant\\myspell"),
|
||||
("..\\windows-dependencies\\x86\\oggenc2.exe", "."),
|
||||
("..\\windows-dependencies\\x86\\bootstrap.exe", "."),
|
||||
("app-configuration.defaults", "."),
|
||||
("session.defaults", "."),
|
||||
("cacert.pem", "."),
|
||||
],
|
||||
datas=[],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher)
|
||||
pyz = PYZ(a.pure, a.zipped_data,
|
||||
cipher=block_cipher)
|
||||
exe = EXE(pyz,
|
||||
a.scripts,
|
||||
exclude_binaries=True,
|
||||
name='socializer',
|
||||
debug=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
console=False )
|
||||
coll = COLLECT(exe,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
strip=False,
|
||||
upx=True,
|
||||
name='main')
|
@@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
import os
|
||||
import languageHandler
|
||||
import logging
|
||||
|
@@ -1,152 +0,0 @@
|
||||
# encoding: utf-8
|
||||
import requests
|
||||
|
||||
class LongPoll(object):
|
||||
def __init__(self, vk, wait=25, use_ssl=True, mode=34):
|
||||
self.vk = vk
|
||||
self.wait = wait
|
||||
self.use_ssl = use_ssl
|
||||
self.mode = mode
|
||||
self.get_longpoll_server()
|
||||
self.url = 'https' if use_ssl else 'http'
|
||||
self.url += '://' + self.server
|
||||
|
||||
def get_longpoll_server(self, update_ts=True):
|
||||
values = {
|
||||
'use_ssl': '1' if self.use_ssl else '0',
|
||||
'need_pts': '1'
|
||||
}
|
||||
response = self.vk.messages.getLongPollServer(**values)
|
||||
self.key = response['key']
|
||||
self.server = response['server']
|
||||
if update_ts:
|
||||
self.ts = response['ts']
|
||||
self.pts = response['pts']
|
||||
|
||||
def check(self):
|
||||
values = {
|
||||
'act': 'a_check',
|
||||
'key': self.key,
|
||||
'ts': self.ts,
|
||||
'wait': self.wait,
|
||||
'mode': self.mode
|
||||
}
|
||||
response = requests.get(self.url, params=values,
|
||||
timeout=self.wait + 10).json()
|
||||
events = []
|
||||
|
||||
if 'failed' not in response:
|
||||
self.ts = response['ts']
|
||||
self.pts = response['pts']
|
||||
|
||||
for raw_event in response['updates']:
|
||||
events.append(Event(raw_event))
|
||||
# http://vk.com/dev/using_longpoll
|
||||
else:
|
||||
self.get_longpoll_server(update_ts=False)
|
||||
|
||||
return events
|
||||
|
||||
|
||||
CHAT_START_ID = int(2E9)
|
||||
|
||||
EVENT_TYPES = {
|
||||
0: 'message_delete',
|
||||
1: 'message_flags_replace',
|
||||
2: 'message_flags_put',
|
||||
3: 'message_flags_reset',
|
||||
4: 'message_new',
|
||||
|
||||
8: 'user_online',
|
||||
9: 'user_offline',
|
||||
|
||||
51: 'chat_new',
|
||||
61: 'user_typing',
|
||||
62: 'user_typing_in_chat',
|
||||
|
||||
70: 'user_call',
|
||||
}
|
||||
|
||||
ASSOCIATIVES = {
|
||||
0: ['message_id'],
|
||||
1: ['message_id', 'flags'],
|
||||
2: ['message_id', 'mask', 'user_id'],
|
||||
3: ['message_id', 'mask', 'user_id', 'timestamp', 'subject',
|
||||
'text', 'attachments'],
|
||||
4: ['message_id', 'flags', 'from_id', 'timestamp', 'subject',
|
||||
'text', 'attachments'],
|
||||
|
||||
8: ['user_id', 'flags'],
|
||||
9: ['user_id', 'flags'],
|
||||
|
||||
51: ['chat_id', 'byself'],
|
||||
61: ['user_id', 'flags'],
|
||||
62: ['user_id', 'chat_id'],
|
||||
|
||||
70: ['user_id', 'call_id'],
|
||||
}
|
||||
|
||||
MESSAGE_FLAGS = [
|
||||
'unread', 'outbox', 'replied', 'important', 'chat', 'friends', 'spam',
|
||||
'deleted', 'fixed', 'media'
|
||||
]
|
||||
|
||||
|
||||
class Event(object):
|
||||
def __init__(self, raw):
|
||||
self.raw = raw
|
||||
|
||||
self.message_id = None
|
||||
self.flags = None
|
||||
self.mask = None
|
||||
self.user_id = None
|
||||
self.from_id = None
|
||||
self.timestamp = None
|
||||
self.subject = None
|
||||
self.text = None
|
||||
self.attachments = None
|
||||
self.call_id = None
|
||||
self.chat_id = None
|
||||
self.byself = None
|
||||
|
||||
cmd = raw[0]
|
||||
|
||||
self.message_flags = {}
|
||||
self.type = EVENT_TYPES.get(cmd)
|
||||
self._list_to_attr(raw[1:], ASSOCIATIVES.get(cmd))
|
||||
|
||||
if cmd == 4:
|
||||
self._parse_message_flags()
|
||||
self.text = self.text.replace('<br>', '\n')
|
||||
|
||||
if self.from_id > CHAT_START_ID:
|
||||
self.chat_id = self.from_id - CHAT_START_ID
|
||||
self.from_id = self.attachments['from']
|
||||
elif cmd in [2, 3]:
|
||||
if self.user_id > CHAT_START_ID:
|
||||
self.chat_id = self.user_id - CHAT_START_ID
|
||||
self.user_id = None
|
||||
elif cmd in [8, 9]:
|
||||
self.user_id = abs(self.user_id)
|
||||
|
||||
def _parse_message_flags(self):
|
||||
x = 1
|
||||
for i in MESSAGE_FLAGS:
|
||||
|
||||
if self.flags & x:
|
||||
self.message_flags.update({i: True})
|
||||
|
||||
x *= 2
|
||||
|
||||
def _list_to_attr(self, l, associative):
|
||||
if not associative:
|
||||
return
|
||||
|
||||
for i in range(len(l)):
|
||||
try:
|
||||
name = associative[i]
|
||||
except IndexError:
|
||||
return True
|
||||
|
||||
value = l[i]
|
||||
self.__setattr__(name, value)
|
@@ -1,3 +1,4 @@
|
||||
from __future__ import unicode_literals
|
||||
import threading
|
||||
import logging
|
||||
log = logging.getLogger("mysc.repeating_timer")
|
||||
|
@@ -1,4 +1,5 @@
|
||||
# -*- coding: cp1252
|
||||
from __future__ import unicode_literals
|
||||
import sys, os
|
||||
|
||||
def restart_program():
|
||||
|
@@ -1,4 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
import threading
|
||||
|
||||
def call_threaded(func, *args, **kwargs):
|
||||
|
26
src/paths.py
26
src/paths.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
|
||||
import sys
|
||||
import platform
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
#import logging
|
||||
from platform_utils import paths as paths_
|
||||
|
||||
@@ -14,6 +14,8 @@ directory = None
|
||||
fsencoding = sys.getfilesystemencoding()
|
||||
|
||||
#log = logging.getLogger("paths")
|
||||
if len(glob.glob("Uninstall.exe")) > 0: # installed copy
|
||||
mode= "installed"
|
||||
|
||||
def app_path():
|
||||
return paths_.app_path()
|
||||
@@ -21,10 +23,10 @@ def app_path():
|
||||
def config_path():
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
if directory != None: path = os.path.join(directory.decode(fsencoding), "config")
|
||||
elif directory == None: path = os.path.join(app_path().decode(fsencoding), "config")
|
||||
if directory != None: path = os.path.join(directory, "config")
|
||||
elif directory == None: path = os.path.join(app_path(), "config")
|
||||
elif mode == "installed":
|
||||
path = os.path.join(data_path().decode(fsencoding), "config")
|
||||
path = os.path.join(data_path(), "config")
|
||||
if not os.path.exists(path):
|
||||
# log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
@@ -33,10 +35,10 @@ def config_path():
|
||||
def logs_path():
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
if directory != None: path = os.path.join(directory.decode(fsencoding), "logs")
|
||||
elif directory == None: path = os.path.join(app_path().decode(fsencoding), "logs")
|
||||
if directory != None: path = os.path.join(directory, "logs")
|
||||
elif directory == None: path = os.path.join(app_path(), "logs")
|
||||
elif mode == "installed":
|
||||
path = os.path.join(data_path().decode(fsencoding), "logs")
|
||||
path = os.path.join(data_path(), "logs")
|
||||
if not os.path.exists(path):
|
||||
# log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
@@ -52,18 +54,18 @@ def data_path(app_name='socializer'):
|
||||
return data_path
|
||||
|
||||
def locale_path():
|
||||
return os.path.join(app_path().decode(fsencoding), "locales")
|
||||
return os.path.join(app_path(), "locales")
|
||||
|
||||
def sound_path():
|
||||
return os.path.join(app_path().decode(fsencoding), "sounds")
|
||||
return os.path.join(app_path(), "sounds")
|
||||
|
||||
def com_path():
|
||||
global mode, directory
|
||||
if mode == "portable":
|
||||
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")
|
||||
if directory != None: path = os.path.join(directory, "com_cache")
|
||||
elif directory == None: path = os.path.join(app_path(), "com_cache")
|
||||
elif mode == "installed":
|
||||
path = os.path.join(data_path().decode(fsencoding), "com_cache")
|
||||
path = os.path.join(data_path(), "com_cache")
|
||||
if not os.path.exists(path):
|
||||
# log.debug("%s path does not exist, creating..." % (path,))
|
||||
os.mkdir(path)
|
||||
|
19
src/presenters/__init__.py
Normal file
19
src/presenters/__init__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" A "presenter" in the socializer's terminology is a module that handles business logic in the application's workflow.
|
||||
All presenter classes should derive from base.basePresenter and will be completely abstracted from views (the GUI elements). It means presenters and views don't know anything about the each other.
|
||||
Both Presenters and views can communicate through the interactors. Interactors are responsible to receive user input and send requests to the presenters, aswell as receiving presenter requests and render those in the view.
|
||||
So, in a tipical user interaction made in socializer, the following could happen when someone decides to do something:
|
||||
1. A new presenter is created, with two mandatory arguments: The corresponding view and interactor.
|
||||
2. The presenter will call to the install() method in the interactor, to connect all GUI events to their corresponding methods. All of these functions will be present in the interactor only.
|
||||
3. After install(), the presenter will run the View, which will display the graphical user interface that users can see and interact with. The view is the only layer directly accessible from the user world and does not handle any kind of logic.
|
||||
4. If the user presses a button or generates an event connected to a function in the interactor side, the function will be executed in the interactor. The interactor is aware of the View, and holds a reference to the presenter. The interactor should call other GUI elements if necessary and handle some logic (related to GUI, like yes/no dialogs). The interactor can call the presenter to retrieve some information, though the interactor cannot perform any business logic (like altering the cache database, retrieving usernames and so on).
|
||||
5. If the interactor calls something in the presenter, it will be executed. The presenter knows everything about VK and the session object, so it will fetch data, save it in the cache, call other methods from VK and what not. If the presenter wants to change something in the GUI elements (for example, hiding a control or displaying something else), it will send a pubsub event that the interactor will receive and act on accordingly.
|
||||
|
||||
By using this design pattern it allows more decoupled code, easier testing (as we don't need to instantiate the views) and easy to switch (or add) a new graphical user interface by replacing interactors and views.
|
||||
"""
|
||||
from .attach import *
|
||||
from .audioRecorder import *
|
||||
from .createPosts import *
|
||||
from .displayPosts import *
|
||||
from .configuration import *
|
||||
from .profiles import *
|
19
src/presenters/__pycache__/__init__.py
Normal file
19
src/presenters/__pycache__/__init__.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" A "presenter" in the socializer's terminology is a module that handles business logic in the application's workflow.
|
||||
All presenter classes should derive from base.basePresenter and will be completely abstracted from views (the GUI elements). It means presenters and views don't know anything about the each other.
|
||||
Both Presenters and views can communicate through the interactors. Interactors are responsible to receive user input and send requests to the presenters, aswell as receiving presenter requests and render those in the view.
|
||||
So, in a tipical user interaction made in socializer, the following could happen when someone decides to do something:
|
||||
1. A new presenter is created, with two mandatory arguments: The corresponding view and interactor.
|
||||
2. The presenter will call to the install() method in the interactor, to connect all GUI events to their corresponding methods. All of these functions will be present in the interactor only.
|
||||
3. After install(), the presenter will run the View, which will display the graphical user interface that users can see and interact with. The view is the only layer directly accessible from the user world and does not handle any kind of logic.
|
||||
4. If the user presses a button or generates an event connected to a function in the interactor side, the function will be executed in the interactor. The interactor is aware of the View, and holds a reference to the presenter. The interactor should call other GUI elements if necessary and handle some logic (related to GUI, like yes/no dialogs). The interactor can call the presenter to retrieve some information, though the interactor cannot perform any business logic (like altering the cache database, retrieving usernames and so on).
|
||||
5. If the interactor calls something in the presenter, it will be executed. The presenter knows everything about VK and the session object, so it will fetch data, save it in the cache, call other methods from VK and what not. If the presenter wants to change something in the GUI elements (for example, hiding a control or displaying something else), it will send a pubsub event that the interactor will receive and act on accordingly.
|
||||
|
||||
By using this design pattern it allows more decoupled code, easier testing (as we don't need to instantiate the views) and easy to switch (or add) a new graphical user interface by replacing interactors and views.
|
||||
"""
|
||||
from .attach import *
|
||||
from .audioRecorder import *
|
||||
from .postCreation import *
|
||||
from .postDisplayer import *
|
||||
from .configuration import *
|
||||
from .profiles import *
|
118
src/presenters/attach.py
Normal file
118
src/presenters/attach.py
Normal file
@@ -0,0 +1,118 @@
|
||||
# -*- 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.
|
||||
"""
|
||||
from __future__ import unicode_literals
|
||||
import os
|
||||
import logging
|
||||
import interactors
|
||||
import views
|
||||
from mutagen.id3 import ID3
|
||||
from sessionmanager.utils import seconds_to_string
|
||||
from . import audioRecorder, base
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
class attachPresenter(base.basePresenter):
|
||||
""" 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 attachments, so this controller will add both local and online files in the same dialog.
|
||||
"""
|
||||
|
||||
def __init__(self, session, view, interactor, voice_messages=False):
|
||||
""" Constructor.
|
||||
@ session sessionmanager.session object: an object capable of calling all VK methods and accessing the session database.
|
||||
@voice_messages bool: If True, will add a button for sending voice messages. Functionality for this button has not been added yet.
|
||||
"""
|
||||
super(attachPresenter, self).__init__(view=view, interactor=interactor, modulename="attach")
|
||||
self.session = session
|
||||
# Self.attachments will hold a reference to all attachments added to the dialog.
|
||||
self.attachments = list()
|
||||
self.run()
|
||||
|
||||
def upload_image(self, image, description):
|
||||
""" allows uploading an image from the computer.
|
||||
"""
|
||||
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 = [_("Photo"), description]
|
||||
self.send_message("insert_attachment", attachment=info)
|
||||
self.send_message("enable_control", control="remove")
|
||||
|
||||
def upload_audio(self, audio):
|
||||
""" Allows uploading an audio file from the computer. Only mp3 files are supported. """
|
||||
if audio != None:
|
||||
# Define data structure for this attachment, as will be required by VK API later.
|
||||
# Let's extract the ID3 tags to show them in the list and send them to VK, too.
|
||||
audio_tags = ID3(audio)
|
||||
if "TIT2" in audio_tags:
|
||||
title = audio_tags["TIT2"].text[0]
|
||||
else:
|
||||
title = _("Untitled")
|
||||
if "TPE1" in audio_tags:
|
||||
artist = audio_tags["TPE1"].text[0]
|
||||
else:
|
||||
artist = _("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 = [_("Audio file"), "{title} - {artist}".format(title=title, artist=artist)]
|
||||
self.send_message("insert_attachment", attachment=info)
|
||||
self.send_message("enable_control", control="remove")
|
||||
|
||||
def upload_document(self, document):
|
||||
""" allows uploading a document from the computer.
|
||||
"""
|
||||
doc_info = {"type": "document", "file": document, "from": "local", "title": os.path.basename(os.path.splitext(document)[0])}
|
||||
self.attachments.append(doc_info)
|
||||
# Translators: This is the text displayed in the attachments dialog, when the user adds a document.
|
||||
info = [_("Document"), os.path.basename(document)]
|
||||
self.send_message("insert_attachment", attachment=info)
|
||||
self.send_message("enable_control", control="remove")
|
||||
|
||||
def upload_voice_message(self):
|
||||
a = audioRecorder.audioRecorderPresenter(view=views.audioRecorderDialog(), interactor=interactors.audioRecorderInteractor())
|
||||
if a.file != None and a.duration != 0:
|
||||
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 = [_("Voice message"), seconds_to_string(a.duration,)]
|
||||
self.send_message("insert_attachment", attachment=info)
|
||||
self.send_message("enable_control", control="remove")
|
||||
|
||||
####### ToDo: replace this with selector presenter when finished.
|
||||
def get_available_audios(self):
|
||||
# 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("{0}, {1}".format(i["title"], i["artist"]))
|
||||
return audios
|
||||
|
||||
def take_audios(self, audios_list):
|
||||
list_of_audios = self.session.db["me_audio"]["items"]
|
||||
for i in audios_list:
|
||||
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 = [_("Audio file"), "{0} - {1}".format(list_of_audios[i]["title"], list_of_audios[i]["artist"])]
|
||||
self.send_message("insert_attachment", attachment=info2)
|
||||
self.check_remove_status()
|
||||
|
||||
def remove_attachment(self, item_index):
|
||||
""" Remove the currently focused item from the attachments list."""
|
||||
log.debug("Removing item %d" % (item_index,))
|
||||
if item_index == -1: item_index = 0
|
||||
self.attachments.pop(item_index)
|
||||
self.send_message("remove_attachment", attachment=item_index)
|
||||
self.check_remove_status()
|
||||
log.debug("Removed")
|
||||
|
||||
def check_remove_status(self):
|
||||
""" Checks whether the remove button should remain enabled."""
|
||||
if len(self.attachments) == 0:
|
||||
self.send_message("disable_control", control="remove")
|
111
src/presenters/audioRecorder.py
Normal file
111
src/presenters/audioRecorder.py
Normal file
@@ -0,0 +1,111 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import time
|
||||
import os
|
||||
import tempfile
|
||||
import sound_lib
|
||||
import sound
|
||||
import output
|
||||
from mysc.thread_utils import call_threaded
|
||||
from . import base
|
||||
|
||||
class audioRecorderPresenter(base.basePresenter):
|
||||
def __init__(self, view, interactor):
|
||||
super(audioRecorderPresenter, self).__init__(view=view, interactor=interactor, modulename="audiorecorder")
|
||||
self.recorded = False
|
||||
self.recording = None
|
||||
self.duration = 0
|
||||
self.playing = None
|
||||
self.file = None
|
||||
self.run()
|
||||
|
||||
def toggle_recording(self, *args, **kwargs):
|
||||
if self.recording != None:
|
||||
self.stop_recording()
|
||||
else:
|
||||
self.start_recording()
|
||||
|
||||
def start_recording(self):
|
||||
self.file = tempfile.mktemp(suffix='.wav')
|
||||
self.recording = sound.get_recording(self.file)
|
||||
self.duration = time.time()
|
||||
self.recording.play()
|
||||
self.send_message("set_label", control="record", label=_("&Stop"))
|
||||
output.speak(_("Recording"))
|
||||
self.send_message("disable_control", control="ok")
|
||||
|
||||
def stop_recording(self):
|
||||
self.recording.stop()
|
||||
self.duration = int(time.time()-self.duration)
|
||||
self.recording.free()
|
||||
output.speak(_("Stopped"))
|
||||
self.recorded = True
|
||||
self.send_message("set_label", control="record", label=_("&Record"))
|
||||
self.send_message("disable_control", control="record")
|
||||
self.send_message("enable_control", control="play")
|
||||
self.send_message("enable_control", control="discard")
|
||||
self.send_message("enable_control", control="ok")
|
||||
self.send_message("focus_control", control="play")
|
||||
|
||||
def discard_recording(self, *args, **kwargs):
|
||||
if self.playing:
|
||||
self._stop()
|
||||
if self.recording != None:
|
||||
self.cleanup()
|
||||
self.send_message("disable_control", control="play")
|
||||
self.send_message("disable_control", control="ok")
|
||||
self.file = None
|
||||
self.send_message("enable_control", control="record")
|
||||
self.send_message("focus_control", control="record")
|
||||
self.send_message("disable_control", control="discard")
|
||||
self.recording = None
|
||||
output.speak(_("Discarded"))
|
||||
|
||||
def play(self, *args, **kwargs):
|
||||
if not self.playing:
|
||||
call_threaded(self._play)
|
||||
else:
|
||||
self._stop()
|
||||
|
||||
def _play(self):
|
||||
output.speak(_("Playing..."))
|
||||
# try:
|
||||
self.playing = sound_lib.stream.FileStream(file=str(self.file), flags=sound_lib.stream.BASS_UNICODE)
|
||||
self.playing.play()
|
||||
self.send_message("set_label", control="play", label=_("&Stop"))
|
||||
try:
|
||||
while self.playing.is_playing:
|
||||
pass
|
||||
self.send_message("set_label", control="play", label=_("&Play"))
|
||||
self.playing.free()
|
||||
self.playing = None
|
||||
except:
|
||||
pass
|
||||
|
||||
def _stop(self):
|
||||
output.speak(_("Stopped"))
|
||||
self.playing.stop()
|
||||
self.playing.free()
|
||||
self.send_message("set_label", control="play", label=_("&Play"))
|
||||
self.playing = None
|
||||
|
||||
def postprocess(self):
|
||||
if self.file.lower().endswith('.wav'):
|
||||
output.speak(_("Recoding audio..."))
|
||||
sound.recode_audio(self.file)
|
||||
self.wav_file = self.file
|
||||
self.file = '%s.ogg' % self.file[:-4]
|
||||
self.cleanup()
|
||||
|
||||
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
|
||||
if hasattr(self, 'wav_file'):
|
||||
os.remove(self.wav_file)
|
19
src/presenters/base.py
Normal file
19
src/presenters/base.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
from pubsub import pub
|
||||
from interactors import configuration as interactor
|
||||
|
||||
class basePresenter(object):
|
||||
|
||||
def __init__(self, view, interactor, modulename):
|
||||
self.modulename = modulename
|
||||
self.interactor = interactor
|
||||
self.view = view
|
||||
self.interactor.install(view=view, presenter=self, modulename=modulename)
|
||||
|
||||
def run(self):
|
||||
self.interactor.start()
|
||||
self.interactor.uninstall()
|
||||
|
||||
def send_message(self, msg, *args, **kwargs):
|
||||
pub.sendMessage(self.modulename+"_"+msg, *args, **kwargs)
|
101
src/presenters/configuration.py
Normal file
101
src/presenters/configuration.py
Normal file
@@ -0,0 +1,101 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import sound_lib.input, sound_lib.output
|
||||
import config
|
||||
import languageHandler
|
||||
from mysc import restart
|
||||
from . import base
|
||||
|
||||
class configurationPresenter(base.basePresenter):
|
||||
|
||||
def __init__(self, session, view, interactor):
|
||||
self.session = session
|
||||
super(configurationPresenter, self).__init__(view=view, interactor=interactor, modulename="configuration")
|
||||
# Control requirement for a restart of the application.
|
||||
self.needs_restart = False
|
||||
self.create_config()
|
||||
self.run()
|
||||
|
||||
def get_notification_label(self, value):
|
||||
if value == "native":
|
||||
return _("Native")
|
||||
else:
|
||||
return _("Custom")
|
||||
|
||||
def get_update_channel_label(self, value):
|
||||
if value == "stable":
|
||||
return _("Stable")
|
||||
elif value == "weekly":
|
||||
return _("Weekly")
|
||||
else:
|
||||
return _("Alpha")
|
||||
|
||||
def get_notification_type(self, value):
|
||||
if value == _("Native"):
|
||||
return "native"
|
||||
else:
|
||||
return "custom"
|
||||
|
||||
def get_update_channel_type(self, value):
|
||||
if value == _("Stable"):
|
||||
return "stable"
|
||||
elif value == _("Weekly"):
|
||||
return "weekly"
|
||||
else:
|
||||
return "alpha"
|
||||
|
||||
def create_config(self):
|
||||
self.langs = languageHandler.getAvailableLanguages()
|
||||
langs = [i[1] for i in self.langs]
|
||||
self.codes = [i[0] for i in self.langs]
|
||||
id = self.codes.index(config.app["app-settings"]["language"])
|
||||
self.send_message("create_tab", tab="general", arglist=dict(languages=langs))
|
||||
self.send_message("set_language", language=id)
|
||||
self.send_message("set", tab="general", setting="wall_buffer_count", value=self.session.settings["buffers"]["count_for_wall_buffers"])
|
||||
self.send_message("set", tab="general", setting="video_buffers_count", value=self.session.settings["buffers"]["count_for_video_buffers"])
|
||||
self.send_message("set", tab="general", setting="load_images", value=self.session.settings["general"]["load_images"])
|
||||
self.send_message("set", tab="general", setting="use_proxy", value=config.app["app-settings"]["use_proxy"])
|
||||
self.send_message("set", tab="general", setting="update_channel", value=self.get_update_channel_label(self.session.settings["general"]["update_channel"]))
|
||||
self.send_message("create_tab", tab="chat")
|
||||
self.send_message("set", tab="chat", setting="notify_online", value=self.session.settings["chat"]["notify_online"])
|
||||
self.send_message("set", tab="chat", setting="notify_offline", value=self.session.settings["chat"]["notify_offline"])
|
||||
self.send_message("set", tab="chat", setting="notifications", value=self.get_notification_label(self.session.settings["chat"]["notifications"]))
|
||||
self.send_message("create_tab", tab="startup_options")
|
||||
self.send_message("set", tab="startup", setting="audio_albums", value=self.session.settings["load_at_startup"]["audio_albums"])
|
||||
self.send_message("set", tab="startup", setting="video_albums", value=self.session.settings["load_at_startup"]["video_albums"])
|
||||
self.send_message("set", tab="startup", setting="communities", value=self.session.settings["load_at_startup"]["communities"])
|
||||
self.input_devices = sound_lib.input.Input.get_device_names()
|
||||
self.output_devices = sound_lib.output.Output.get_device_names()
|
||||
self.send_message("create_tab", tab="sound", arglist=dict(input_devices=self.input_devices, output_devices=self.output_devices, soundpacks=[]))
|
||||
self.send_message("set", tab="sound", setting="input", value=config.app["sound"]["input_device"])
|
||||
self.send_message("set", tab="sound", setting="output", value=config.app["sound"]["output_device"])
|
||||
|
||||
def update_setting(self, section, setting, value):
|
||||
if section not in self.session.settings:
|
||||
raise AttributeError("The configuration section is not present in the spec file.")
|
||||
if setting not in self.session.settings[section]:
|
||||
raise AttributeError("The setting you specified is not present in the config file.")
|
||||
self.session.settings[section][setting] = value
|
||||
|
||||
def save_settings_file(self):
|
||||
self.session.settings.write()
|
||||
|
||||
def update_app_setting(self, section, setting, value):
|
||||
if section not in config.app:
|
||||
raise AttributeError("The configuration section is not present in the spec file.")
|
||||
if setting not in config.app[section]:
|
||||
raise AttributeError("The setting you specified is not present in the config file.")
|
||||
# check if certain settings have been changed so we'd restart the client.
|
||||
# List of app settings that require a restart after being changed.
|
||||
settings_needing_restart = ["language", "use_proxy", "input_device", "output_device"]
|
||||
if value != config.app[section][setting] and setting in settings_needing_restart:
|
||||
self.needs_restart = True
|
||||
config.app[section][setting] = value
|
||||
|
||||
def save_app_settings_file(self):
|
||||
config.app.write()
|
||||
if self.needs_restart:
|
||||
self.send_message("restart_program")
|
||||
|
||||
def restart_application(self):
|
||||
restart.restart_program()
|
2
src/presenters/createPosts/__init__.py
Normal file
2
src/presenters/createPosts/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from .basePost import *
|
59
src/presenters/createPosts/basePost.py
Normal file
59
src/presenters/createPosts/basePost.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
import time
|
||||
import views
|
||||
import interactors
|
||||
import output
|
||||
from logging import getLogger
|
||||
from pubsub import pub
|
||||
from extra import SpellChecker, translator
|
||||
from presenters import attach
|
||||
from presenters import base
|
||||
|
||||
log = getLogger("controller.message")
|
||||
|
||||
class createPostPresenter(base.basePresenter):
|
||||
|
||||
def __init__(self, session, view, interactor):
|
||||
super(createPostPresenter, self).__init__(view=view, interactor=interactor, modulename="create_post")
|
||||
self.session = session
|
||||
self.images = []
|
||||
self.tagged_people = []
|
||||
self.run()
|
||||
|
||||
def get_friends(self):
|
||||
try:
|
||||
fields = "id, first_name, last_name"
|
||||
self.friends = self.session.vk.client.friends.get(count=5000, fields=fields)
|
||||
except AttributeError:
|
||||
time.sleep(2)
|
||||
log.exception("Error retrieving friends...")
|
||||
return []
|
||||
self.users = []
|
||||
for i in self.friends["items"]:
|
||||
self.users.append("{0} {1}".format(i["first_name"], i["last_name"]))
|
||||
return self.users
|
||||
|
||||
def add_tagged_users(self, tagged_users):
|
||||
self.tagged_people = []
|
||||
for i in tagged_users:
|
||||
self.tagged_people.append("[id%s|%s]" % (str(self.friends["items"][i]["id"]), self.friends["items"][i]["first_name"]))
|
||||
self.send_message("add_tagged_users", users=self.tagged_people)
|
||||
|
||||
def translate(self, text, language):
|
||||
msg = translator.translator.translate(text, language)
|
||||
self.send_message("set", control="text", value=msg)
|
||||
self.send_message("focus_control", control="text")
|
||||
output.speak(_("Translated"))
|
||||
|
||||
def spellcheck(self, text):
|
||||
checker = SpellChecker.spellchecker.spellChecker(text, "")
|
||||
if hasattr(checker, "fixed_text"):
|
||||
self.send_message("set", control="text", value=checker.fixed_text)
|
||||
self.send_message("focus_control", control="text")
|
||||
checker.clean()
|
||||
|
||||
def add_attachments(self):
|
||||
a = attach.attachPresenter(session=self.session, view=views.attachDialog(), interactor=interactors.attachInteractor())
|
||||
if len(a.attachments) != 0:
|
||||
self.attachments = a.attachments
|
8
src/presenters/displayPosts/__init__.py
Normal file
8
src/presenters/displayPosts/__init__.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from .basePost import *
|
||||
from .audio import *
|
||||
from .comment import *
|
||||
from .peopleList import *
|
||||
from .poll import *
|
||||
from .topic import *
|
||||
from .topicComment import *
|
100
src/presenters/displayPosts/audio.py
Normal file
100
src/presenters/displayPosts/audio.py
Normal file
@@ -0,0 +1,100 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
from sessionmanager import utils
|
||||
from pubsub import pub
|
||||
from mysc.thread_utils import call_threaded
|
||||
from presenters import base, player
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
class displayAudioPresenter(base.basePresenter):
|
||||
def __init__(self, session, postObject, view, interactor):
|
||||
super(displayAudioPresenter, self).__init__(view=view, interactor=interactor, modulename="display_audio")
|
||||
self.added_audios = {}
|
||||
self.session = session
|
||||
self.post = postObject
|
||||
self.load_audios()
|
||||
self.fill_information(0)
|
||||
self.run()
|
||||
|
||||
def add_to_library(self, audio_index):
|
||||
post = self.post[audio_index]
|
||||
args = {}
|
||||
args["audio_id"] = post["id"]
|
||||
if "album_id" in post:
|
||||
args["album_id"] = post["album_id"]
|
||||
args["owner_id"] = post["owner_id"]
|
||||
audio = self.session.vk.client.audio.add(**args)
|
||||
if audio != None and int(audio) > 21:
|
||||
self.added_audios[post["id"]] = audio
|
||||
self.send_message("disable_control", control="add")
|
||||
self.send_message("enable_control", control="remove")
|
||||
|
||||
def remove_from_library(self, audio_index):
|
||||
post = self.post[audio_index]
|
||||
args = {}
|
||||
if post["id"] in self.added_audios:
|
||||
args["audio_id"] = self.added_audios[post["id"]]
|
||||
args["owner_id"] = self.session.user_id
|
||||
else:
|
||||
args["audio_id"] = post["id"]
|
||||
args["owner_id"] = post["owner_id"]
|
||||
result = self.session.vk.client.audio.delete(**args)
|
||||
if int(result) == 1:
|
||||
self.send_message("enable_control", control="add")
|
||||
self.send_message("disable_control", control="remove")
|
||||
if post["id"] in self.added_audios:
|
||||
self.added_audios.pop(post["id"])
|
||||
|
||||
def fill_information(self, index):
|
||||
post = self.post[index]
|
||||
if "artist" in post:
|
||||
self.send_message("set", control="artist", value=post["artist"])
|
||||
if "title" in post:
|
||||
self.send_message("set", control="title", value=post["title"])
|
||||
if "duration" in post:
|
||||
self.send_message("set", control="duration", value=utils.seconds_to_string(post["duration"]))
|
||||
self.send_message("set_title", value="{0} - {1}".format(post["title"], post["artist"]))
|
||||
call_threaded(self.get_lyrics, index)
|
||||
if post["owner_id"] == self.session.user_id or (post["id"] in self.added_audios) == True:
|
||||
self.send_message("enable_control", control="remove")
|
||||
self.send_message("disable_control", control="add")
|
||||
else:
|
||||
self.send_message("enable_control", control="add")
|
||||
self.send_message("disable_control", control="remove")
|
||||
|
||||
def get_lyrics(self, audio_index):
|
||||
post = self.post[audio_index]
|
||||
if "lyrics_id" in post:
|
||||
l = self.session.vk.client.audio.getLyrics(lyrics_id=int(post["lyrics_id"]))
|
||||
self.send_message("set", control="lyric", value=l["text"])
|
||||
else:
|
||||
self.send_message("disable_control", control="lyric")
|
||||
|
||||
def get_suggested_filename(self, audio_index):
|
||||
post = self.post[audio_index]
|
||||
return "{0} - {1}.mp3".format(post["title"], post["artist"])
|
||||
|
||||
def download(self, audio_index, path):
|
||||
post = self.post[audio_index]
|
||||
if path != None:
|
||||
pub.sendMessage("download-file", url=post["url"], filename=path)
|
||||
|
||||
def play(self, audio_index):
|
||||
post = self.post[audio_index]
|
||||
if player.player.check_is_playing() == True:
|
||||
return pub.sendMessage("stop")
|
||||
pub.sendMessage("play", object=post)
|
||||
|
||||
def load_audios(self):
|
||||
audios = []
|
||||
for i in self.post:
|
||||
s = "{0} - {1}. {2}".format(i["title"], i["artist"], utils.seconds_to_string(i["duration"]))
|
||||
audios.append(s)
|
||||
self.send_message("add_items", control="list", items=audios)
|
||||
if len(self.post) == 1:
|
||||
self.send_message("disable_control", control="list")
|
||||
self.send_message("focus_control", control="title")
|
||||
|
||||
def handle_changes(self, audio_index):
|
||||
self.fill_information(audio_index)
|
433
src/presenters/displayPosts/basePost.py
Normal file
433
src/presenters/displayPosts/basePost.py
Normal file
@@ -0,0 +1,433 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import threading
|
||||
import arrow
|
||||
import requests
|
||||
import languageHandler
|
||||
import views
|
||||
import interactors
|
||||
import output
|
||||
import webbrowser
|
||||
import logging
|
||||
from vk_api import upload
|
||||
from sessionmanager import session, renderers, utils # We'll use some functions from there
|
||||
from pubsub import pub
|
||||
from extra import SpellChecker, translator
|
||||
from mysc.thread_utils import call_threaded
|
||||
from presenters import base
|
||||
from presenters.createPosts.basePost import createPostPresenter
|
||||
from . import audio, poll
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
def get_message(status):
|
||||
message = ""
|
||||
if "text" in status:
|
||||
message = utils.clean_text(status["text"])
|
||||
return message
|
||||
|
||||
class displayPostPresenter(base.basePresenter):
|
||||
""" Base class for post representation."""
|
||||
|
||||
def __init__(self, session, postObject, view, interactor):
|
||||
super(displayPostPresenter, self).__init__(view=view, interactor=interactor, modulename="display_post")
|
||||
self.type = "post"
|
||||
self.session = session
|
||||
self.post = postObject
|
||||
# Posts from newsfeed contains this source_id instead from_id in walls. Also it uses post_id and walls use just id.
|
||||
if "source_id" in self.post:
|
||||
self.user_identifier = "source_id"
|
||||
self.post_identifier = "post_id"
|
||||
else:
|
||||
# In wall's posts, if someone has posted in user's wall, owner_id should be used instead from_id
|
||||
# This will help for retrieving comments, do likes, etc.
|
||||
if "owner_id" not in self.post:
|
||||
self.user_identifier = "from_id"
|
||||
else:
|
||||
self.user_identifier = "owner_id"
|
||||
self.post_identifier = "id"
|
||||
self.attachments = []
|
||||
self.load_images = False
|
||||
# We'll put images here, so it will be easier to work with them.
|
||||
self.images = []
|
||||
self.imageIndex = 0
|
||||
result = self.get_post_information()
|
||||
# Stop loading everything else if post was deleted.
|
||||
if result == False:
|
||||
self.interactor.uninstall()
|
||||
return
|
||||
self.worker = threading.Thread(target=self.load_all_components)
|
||||
self.worker.finished = threading.Event()
|
||||
self.worker.start()
|
||||
self.run()
|
||||
|
||||
def get_comments(self):
|
||||
""" Get comments and insert them in a list."""
|
||||
user = self.post[self.user_identifier]
|
||||
id = self.post[self.post_identifier]
|
||||
self.comments = self.session.vk.client.wall.getComments(owner_id=user, post_id=id, need_likes=1, count=100, extended=1, preview_length=0, thread_items_count=10)
|
||||
comments_ = []
|
||||
# Save profiles in session local storage for a future usage.
|
||||
# Although community objects are returned here, we should not add those because their names are changed.
|
||||
# For example, self reference to a group is marked as "Administrator", which would ruin this profile to be rendered somewhere else.
|
||||
data = dict(groups=[], profiles=self.comments["profiles"])
|
||||
self.session.process_usernames(data)
|
||||
for i in self.comments["items"]:
|
||||
# If comment has a "deleted" key it should not be displayed, obviously.
|
||||
if "deleted" in i:
|
||||
continue
|
||||
from_ = self.session.get_user(i["from_id"])["user1_nom"]
|
||||
if "reply_to_user" in i:
|
||||
extra_info = self.session.get_user(i["reply_to_user"])["user1_nom"]
|
||||
from_ = _("{0} > {1}").format(from_, extra_info)
|
||||
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
|
||||
fixed_text = utils.clean_text(i["text"])
|
||||
if len(fixed_text) > 140:
|
||||
text = fixed_text[:141]
|
||||
else:
|
||||
text = fixed_text
|
||||
original_date = arrow.get(i["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
likes = str(i["likes"]["count"])
|
||||
replies = str(i["thread"]["count"])
|
||||
comments_.append((from_, text, created_at, likes, replies))
|
||||
self.send_message("add_items", control="comments", items=comments_)
|
||||
|
||||
def get_post_information(self):
|
||||
from_ = self.session.get_user(self.post[self.user_identifier])
|
||||
if "copy_history" in self.post:
|
||||
title = _("repost from {user1_nom}").format(**from_)
|
||||
else:
|
||||
if ("from_id" in self.post and "owner_id" in self.post) and (self.post["from_id"] != self.post["owner_id"]):
|
||||
# Translators: {0} will be replaced with the user who is posting, and {1} with the wall owner.
|
||||
user2 = self.session.get_user(self.post["owner_id"], "user2")
|
||||
user2.update(from_)
|
||||
title = _("Post from {user1_nom} in the {user2_nom}'s wall").format(**user2)
|
||||
else:
|
||||
title = _("Post from {user1_nom}").format(**from_)
|
||||
self.send_message("set_title", value=title)
|
||||
message = ""
|
||||
# Retrieve again the post, so we'll make sure to get the most up to date information.
|
||||
# And we add a counter for views.
|
||||
post = self.session.vk.client.wall.getById(posts="{owner_id}_{post_id}".format(owner_id=self.post[self.user_identifier], post_id=self.post[self.post_identifier]))
|
||||
# If this post has been deleted, let's send an event to the interactor so it won't be displayed.
|
||||
if len(post) == 0:
|
||||
self.send_message("post_deleted")
|
||||
return False
|
||||
self.post = post[0]
|
||||
if "views" in self.post and self.post["views"]["count"] > 0:
|
||||
self.send_message("set", control="views", value=str(self.post["views"]["count"]))
|
||||
else:
|
||||
self.send_message("disable_control", control="views")
|
||||
if "owner_id" not in self.post:
|
||||
self.user_identifier = "from_id"
|
||||
else:
|
||||
self.user_identifier = "owner_id"
|
||||
self.post_identifier = "id"
|
||||
message = get_message(self.post)
|
||||
if "copy_history" in self.post:
|
||||
nm = "\n"
|
||||
for i in self.post["copy_history"]:
|
||||
u = self.session.get_user(i["from_id"])
|
||||
u.update(message=get_message(i))
|
||||
nm += "{user1_nom}: {message}\n\n".format(**u)
|
||||
self.get_attachments(i, get_message(i))
|
||||
message += nm
|
||||
self.send_message("set", control="post_view", value=message)
|
||||
self.get_attachments(self.post, message)
|
||||
self.check_image_load()
|
||||
|
||||
def get_attachments(self, post, text):
|
||||
attachments = []
|
||||
self.attachments = []
|
||||
if "attachments" in post:
|
||||
for i in post["attachments"]:
|
||||
# We don't need the photos_list attachment, so skip it.
|
||||
if i["type"] == "photos_list":
|
||||
continue
|
||||
if i["type"] == "photo":
|
||||
if self.load_images == False: self.load_images = True
|
||||
self.images.append(i)
|
||||
attachments.append(renderers.add_attachment(i))
|
||||
self.attachments.append(i)
|
||||
# Links in text are not treated like normal attachments, so we'll have to catch and add those to the list without title
|
||||
# We can't get a title because title is provided by the VK API and it will not work for links as simple text.
|
||||
urls = utils.find_urls_in_text(text)
|
||||
if len(urls) > 0:
|
||||
links = []
|
||||
for i in urls:
|
||||
links.append({"link": {"title": _("Untitled link"), "url": i}, "type": "link"})
|
||||
for i in links:
|
||||
attachments.append(renderers.add_attachment(i))
|
||||
self.attachments.append(i)
|
||||
if len(self.attachments) > 0:
|
||||
self.send_message("enable_attachments")
|
||||
self.send_message("add_items", control="attachments", items=attachments)
|
||||
else:
|
||||
self.interactor.view.attachments.list.Enable(False)
|
||||
|
||||
def check_image_load(self):
|
||||
if self.load_images and len(self.images) > 0 and self.session.settings["general"]["load_images"]:
|
||||
self.send_message("enable_control", control="image")
|
||||
nav = False # Disable navigation controls in photos
|
||||
if len(self.images) > 1:
|
||||
nav = True
|
||||
self.send_message("enable_photo_controls", navigation=nav)
|
||||
self.set_image(0)
|
||||
|
||||
def set_next_image(self, *args, **kwargs):
|
||||
if self.imageIndex < -1 or self.imageIndex == len(self.images)-1:
|
||||
self.imageIndex = -1
|
||||
if len(self.images) <= self.imageIndex+1:
|
||||
self.imageIndex = 0
|
||||
else:
|
||||
self.imageIndex = self.imageIndex + 1
|
||||
self.set_image(self.imageIndex)
|
||||
|
||||
def set_previous_image(self, *args, **kwargs):
|
||||
if self.imageIndex <= 0:
|
||||
self.imageIndex = len(self.images)
|
||||
self.imageIndex = self.imageIndex - 1
|
||||
self.set_image(self.imageIndex)
|
||||
|
||||
def set_image(self, index):
|
||||
if len(self.images) < index-1:
|
||||
return
|
||||
# Get's photo URL.
|
||||
url = self.get_photo_url(self.images[index]["photo"], "x")
|
||||
if url != "":
|
||||
img = requests.get(url)
|
||||
self.send_message("load_image", image=img)
|
||||
# Translators: {0} is the number of the current photo and {1} is the total number of photos.
|
||||
output.speak(_("Loaded photo {0} of {1}").format(index+1, len(self.images)))
|
||||
return
|
||||
|
||||
def get_photo_url(self, photo, size="x"):
|
||||
url = ""
|
||||
for i in photo["sizes"]:
|
||||
if i["type"] == size:
|
||||
url = i["url"]
|
||||
break
|
||||
return url
|
||||
|
||||
def load_all_components(self):
|
||||
self.get_likes()
|
||||
self.get_reposts()
|
||||
self.get_comments()
|
||||
if self.post["comments"]["can_post"] == 0:
|
||||
self.send_message("disable_control", control="comment")
|
||||
if self.post["likes"]["can_like"] == 0 and self.post["likes"]["user_likes"] == 0:
|
||||
self.send_message("disable_control", "like")
|
||||
elif self.post["likes"]["user_likes"] == 1:
|
||||
self.send_message("set_label", control="like", label=_("&Dislike"))
|
||||
if self.post["likes"]["can_publish"] == 0:
|
||||
self.send_message("disable_control", control="repost")
|
||||
|
||||
def post_like(self):
|
||||
if ("owner_id" in self.post) == False:
|
||||
user = int(self.post[self.user_identifier])
|
||||
else:
|
||||
user = int(self.post["owner_id"])
|
||||
id = int(self.post[self.post_identifier])
|
||||
if "type" in self.post:
|
||||
type_ = self.post["type"]
|
||||
else:
|
||||
type_ = self.type
|
||||
if self.post["likes"]["user_likes"] == 1:
|
||||
l = self.session.vk.client.likes.delete(owner_id=user, item_id=id, type=type_)
|
||||
output.speak(_("You don't like this"))
|
||||
self.post["likes"]["count"] = l["likes"]
|
||||
self.post["likes"]["user_likes"] = 2
|
||||
self.get_likes()
|
||||
self.send_message("set_label", control="like", label=_("&Like"))
|
||||
else:
|
||||
l = self.session.vk.client.likes.add(owner_id=user, item_id=id, type=type_)
|
||||
output.speak(_("You liked this"))
|
||||
self.send_message("set_label", control="like", label=_("&Dislike"))
|
||||
self.post["likes"]["count"] = l["likes"]
|
||||
self.post["likes"]["user_likes"] = 1
|
||||
self.get_likes()
|
||||
|
||||
def post_repost(self):
|
||||
object_id = "wall{0}_{1}".format(self.post[self.user_identifier], self.post[self.post_identifier])
|
||||
p = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Repost"), message=_("Add your comment here"), text="", mode="comment"))
|
||||
if hasattr(p, "text") or hasattr(p, "privacy"):
|
||||
msg = p.text
|
||||
self.session.vk.client.wall.repost(object=object_id, message=msg)
|
||||
|
||||
def get_likes(self):
|
||||
self.send_message("set_label", control="likes", label=_("{0} people like this").format(self.post["likes"]["count"],))
|
||||
|
||||
def get_reposts(self):
|
||||
self.send_message("set_label", control="shares", label=_("Shared {0} times").format(self.post["reposts"]["count"],))
|
||||
|
||||
def add_comment(self):
|
||||
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Add a comment"), message="", text="", mode="comment"))
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
owner_id = self.post[self.user_identifier]
|
||||
post_id = self.post[self.post_identifier]
|
||||
call_threaded(self.do_last, comment, owner_id=owner_id, post_id=post_id)
|
||||
|
||||
def do_last(self, comment, **kwargs):
|
||||
msg = comment.text
|
||||
attachments = ""
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = self.upload_attachments(comment.attachments)
|
||||
urls = utils.find_urls_in_text(msg)
|
||||
if len(urls) != 0:
|
||||
if len(attachments) == 0: attachments = urls[0]
|
||||
else: attachments += urls[0]
|
||||
msg = msg.replace(urls[0], "")
|
||||
if msg != "":
|
||||
kwargs.update(message=msg)
|
||||
if attachments != "":
|
||||
kwargs.update(attachments=attachments)
|
||||
if "message" not in kwargs and "attachments" not in kwargs:
|
||||
return # No comment made here.
|
||||
try:
|
||||
result = self.session.vk.client.wall.createComment(**kwargs)
|
||||
comment_object = self.session.vk.client.wall.getComment(comment_id=result["comment_id"], owner_id=kwargs["owner_id"])["items"][0]
|
||||
from_ = self.session.get_user(comment_object["from_id"])
|
||||
if "reply_to_user" in comment_object:
|
||||
extra_info = self.session.get_user(comment_object["reply_to_user"], "user2")
|
||||
extra_info.update(from_)
|
||||
from_ = _("{user1_nom} > {user2_nom}").format(**extra_info)
|
||||
else:
|
||||
from_ = from_["user1_nom"]
|
||||
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
|
||||
fixed_text = utils.clean_text(comment_object["text"])
|
||||
if len(fixed_text) > 140:
|
||||
text = fixed_text[:141]
|
||||
else:
|
||||
text = fixed_text
|
||||
original_date = arrow.get(comment_object["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
likes = str(comment_object["likes"]["count"])
|
||||
replies = ""
|
||||
item = (from_, text, created_at, likes, replies)
|
||||
if hasattr(self, "comments"):
|
||||
self.comments["items"].append(comment_object)
|
||||
else:
|
||||
if "items" not in self.post["thread"]:
|
||||
self.post["thread"]["items"] = []
|
||||
self.post["thread"]["items"].append(comment_object)
|
||||
self.send_message("add_items", control="comments", items=[item])
|
||||
output.speak(_("You've posted a comment"))
|
||||
except IndexError as msg:
|
||||
log.error(msg)
|
||||
|
||||
def upload_attachments(self, attachments):
|
||||
""" Upload attachments to VK before posting them.
|
||||
Returns attachments formatted as string, as required by VK API.
|
||||
Currently this function only supports photos and audios."""
|
||||
# To do: Check the caption and description fields for this kind of attachments.
|
||||
local_attachments = ""
|
||||
uploader = upload.VkUpload(self.session.vk.session_object)
|
||||
for i in attachments:
|
||||
if i["from"] == "online":
|
||||
local_attachments += "{0}{1}_{2},".format(i["type"], i["owner_id"], i["id"])
|
||||
elif i["from"] == "local" and i["type"] == "photo":
|
||||
photos = i["file"]
|
||||
description = i["description"]
|
||||
r = uploader.photo_wall(photos, caption=description)
|
||||
id = r[0]["id"]
|
||||
owner_id = r[0]["owner_id"]
|
||||
local_attachments += "photo{0}_{1},".format(owner_id, id)
|
||||
elif i["from"] == "local" and i["type"] == "audio":
|
||||
audio = i["file"]
|
||||
title = "untitled"
|
||||
artist = "unnamed"
|
||||
if "artist" in i:
|
||||
artist = i["artist"]
|
||||
if "title" in i:
|
||||
title = i["title"]
|
||||
r = uploader.audio(audio, title=title, artist=artist)
|
||||
id = r["id"]
|
||||
owner_id = r["owner_id"]
|
||||
local_attachments += "audio{0}_{1},".format(owner_id, id)
|
||||
return local_attachments
|
||||
|
||||
def reply(self, comment):
|
||||
c = self.comments["items"][comment]
|
||||
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Reply to {user1_nom}").format(**self.session.get_user(c["from_id"])), message="", text="", mode="comment"))
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
call_threaded(self.do_last, comment, owner_id=c["owner_id"], reply_to_comment=c["id"], post_id=c["post_id"], reply_to_user=c["owner_id"])
|
||||
|
||||
def show_comment(self, comment_index):
|
||||
from . import comment
|
||||
c = self.comments["items"][comment_index]
|
||||
c["post_id"] = self.post[self.post_identifier]
|
||||
a = comment.displayCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
|
||||
|
||||
def translate(self, text, language):
|
||||
msg = translator.translator.translate(text, language)
|
||||
self.send_message("set", control="post_view", value=msg)
|
||||
self.send_message("focus_control", control="post_view")
|
||||
output.speak(_("Translated"))
|
||||
|
||||
def spellcheck(self, text):
|
||||
checker = SpellChecker.spellchecker.spellChecker(text, "")
|
||||
if hasattr(checker, "fixed_text"):
|
||||
self.send_message("set", control="post_view", value=checker.fixed_text)
|
||||
self.send_message("focus_control", control="post_view")
|
||||
checker.clean()
|
||||
|
||||
def open_attachment(self, index):
|
||||
attachment = self.attachments[index]
|
||||
if attachment["type"] == "audio":
|
||||
a = audio.displayAudioPresenter(session=self.session, postObject=[attachment["audio"]], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
|
||||
elif attachment["type"] == "link":
|
||||
output.speak(_("Opening URL..."), True)
|
||||
webbrowser.open_new_tab(attachment["link"]["url"])
|
||||
elif attachment["type"] == "doc":
|
||||
output.speak(_("Opening document in web browser..."))
|
||||
webbrowser.open(attachment["doc"]["url"])
|
||||
elif attachment["type"] == "video":
|
||||
# it seems VK doesn't like to attach video links as normal URLS, so we'll have to
|
||||
# get the full video object and use its "player" key which will open a webbrowser in their site with a player for the video.
|
||||
# see https://vk.com/dev/attachments_w and and https://vk.com/dev/video.get
|
||||
# However, the flash player isn't good for visually impaired people (when you press play you won't be able to close the window with alt+f4), so it could be good to use the HTML5 player.
|
||||
# For firefox, see https://addons.mozilla.org/ru/firefox/addon/force-html5-video-player-at-vk/
|
||||
# May be I could use a dialogue here for inviting people to use this addon in firefox. It seems it isn't possible to use this html5 player from the player URL.
|
||||
object_id = "{0}_{1}".format(attachment["video"]["owner_id"], attachment["video"]["id"])
|
||||
video_object = self.session.vk.client.video.get(owner_id=attachment["video"]["owner_id"], videos=object_id)
|
||||
video_object = video_object["items"][0]
|
||||
output.speak(_("Opening video in web browser..."), True)
|
||||
webbrowser.open_new_tab(video_object["player"])
|
||||
elif attachment["type"] == "photo":
|
||||
output.speak(_("Opening photo in web browser..."), True)
|
||||
# Possible photo sizes for looking in the attachment information. Try to use the biggest photo available.
|
||||
possible_sizes = [1280, 604, 130, 75]
|
||||
url = ""
|
||||
for i in possible_sizes:
|
||||
if "photo_{0}".format(i,) in attachment["photo"]:
|
||||
url = attachment["photo"]["photo_{0}".format(i,)]
|
||||
break
|
||||
if url != "":
|
||||
webbrowser.open_new_tab(url)
|
||||
elif attachment["type"] == "poll":
|
||||
a = poll.displayPollPresenter(session=self.session, poll=attachment, interactor=interactors.displayPollInteractor(), view=views.displayPoll())
|
||||
else:
|
||||
log.debug("Unhandled attachment: %r" % (attachment,))
|
||||
|
||||
def __del__(self):
|
||||
if hasattr(self, "worker"):
|
||||
self.worker.finished.set()
|
||||
|
||||
def clear_comments_list(self):
|
||||
self.send_message("clean_list", list="comments")
|
||||
self.get_comments()
|
||||
|
||||
def show_likes(self):
|
||||
""" show likes for the specified post."""
|
||||
data = dict(type="post", owner_id=self.post[self.user_identifier], item_id=self.post["id"], extended=True, count=1000, skip_own=True)
|
||||
result = self.session.vk.client.likes.getList(**data)
|
||||
if result["count"] > 0:
|
||||
post = {"source_id": self.post[self.user_identifier], "friends": {"items": result["items"]}}
|
||||
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who liked this")))
|
||||
|
||||
def show_shares(self):
|
||||
data = dict(type="post", owner_id=self.post[self.user_identifier], item_id=self.post["id"], extended=True, count=1000, skip_own=True, filter="copies")
|
||||
result = self.session.vk.client.likes.getList(**data)
|
||||
if result["count"] > 0:
|
||||
post = {"source_id": self.post[self.user_identifier], "friends": {"items": result["items"]}}
|
||||
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("people who shared this")))
|
105
src/presenters/displayPosts/comment.py
Normal file
105
src/presenters/displayPosts/comment.py
Normal file
@@ -0,0 +1,105 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import threading
|
||||
import arrow
|
||||
import languageHandler
|
||||
import views
|
||||
import interactors
|
||||
import logging
|
||||
from sessionmanager import renderers, utils # We'll use some functions from there
|
||||
from mysc.thread_utils import call_threaded
|
||||
from presenters import base
|
||||
from presenters.createPosts.basePost import createPostPresenter
|
||||
from . import basePost
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
def get_message(status):
|
||||
message = ""
|
||||
if "text" in status:
|
||||
message = utils.clean_text(status["text"])
|
||||
return message
|
||||
|
||||
class displayCommentPresenter(basePost.displayPostPresenter):
|
||||
|
||||
def __init__(self, session, postObject, view, interactor):
|
||||
self.type = "comment"
|
||||
self.modulename = "display_comment"
|
||||
self.interactor = interactor
|
||||
self.view = view
|
||||
self.interactor.install(view=view, presenter=self, modulename=self.modulename)
|
||||
self.session = session
|
||||
self.post = postObject
|
||||
self.user_identifier = "from_id"
|
||||
self.post_identifier = "id"
|
||||
self.worker = threading.Thread(target=self.load_all_components)
|
||||
self.worker.finished = threading.Event()
|
||||
self.worker.start()
|
||||
self.attachments = []
|
||||
self.load_images = False
|
||||
# We'll put images here, so it will be easier to work with them.
|
||||
self.images = []
|
||||
self.imageIndex = 0
|
||||
self.run()
|
||||
|
||||
def load_all_components(self):
|
||||
self.get_post_information()
|
||||
self.get_likes()
|
||||
self.send_message("disable_control", control="comment")
|
||||
self.get_comments()
|
||||
if self.post["likes"]["can_like"] == 0 and self.post["likes"]["user_likes"] == 0:
|
||||
self.send_message("disable_control", "like")
|
||||
elif self.post["likes"]["user_likes"] == 1:
|
||||
self.send_message("set_label", control="like", label=_("&Dislike"))
|
||||
|
||||
def get_post_information(self):
|
||||
from_ = self.session.get_user(self.post[self.user_identifier])
|
||||
if ("from_id" in self.post and "owner_id" in self.post):
|
||||
user2 = self.session.get_user(self.post["owner_id"], "user2")
|
||||
user2.update(from_)
|
||||
title = _("Comment from {user1_nom} in the {user2_nom}'s post").format(**user2)
|
||||
self.send_message("set_title", value=title)
|
||||
message = ""
|
||||
message = get_message(self.post)
|
||||
self.send_message("set", control="post_view", value=message)
|
||||
self.get_attachments(self.post, message)
|
||||
self.check_image_load()
|
||||
|
||||
def reply(self, *args, **kwargs):
|
||||
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Reply to {user1_nom}").format(**self.session.get_user(self.post["from_id"])), message="", text="", mode="comment"))
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
call_threaded(self.do_last, comment, owner_id=self.post["owner_id"], reply_to_comment=self.post["id"], post_id=self.post["post_id"], reply_to_user=self.post["owner_id"])
|
||||
|
||||
def get_comments(self):
|
||||
""" Get comments and insert them in a list."""
|
||||
comments_ = []
|
||||
if "thread" not in self.post:
|
||||
return
|
||||
for i in self.post["thread"]["items"]:
|
||||
# If comment has a "deleted" key it should not be displayed, obviously.
|
||||
if "deleted" in i:
|
||||
continue
|
||||
from_ = self.session.get_user(i["from_id"])
|
||||
if "reply_to_user" in i:
|
||||
extra_info = self.session.get_user(i["reply_to_user"], "user2")
|
||||
extra_info.update(from_)
|
||||
from_ = _("{user1_nom} > {user2_nom}").format(**extra_info)
|
||||
else:
|
||||
from_ = from_["user1_nom"]
|
||||
# As we set the comment reply properly in the from_ field, let's remove the first username from here if it exists.
|
||||
fixed_text = utils.clean_text(i["text"])
|
||||
if len(fixed_text) > 140:
|
||||
text = fixed_text[:141]
|
||||
else:
|
||||
text = fixed_text
|
||||
original_date = arrow.get(i["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
likes = str(i["likes"]["count"])
|
||||
replies = ""
|
||||
comments_.append((from_, text, created_at, likes, replies))
|
||||
self.send_message("add_items", control="comments", items=comments_)
|
||||
|
||||
def show_comment(self, comment_index):
|
||||
c = self.post["thread"]["items"][comment_index]
|
||||
c["post_id"] = self.post["post_id"]
|
||||
a = displayCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
|
||||
self.clear_comments_list()
|
50
src/presenters/displayPosts/peopleList.py
Normal file
50
src/presenters/displayPosts/peopleList.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import webbrowser
|
||||
import logging
|
||||
from pubsub import pub
|
||||
from presenters import base
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
class displayFriendshipPresenter(base.basePresenter):
|
||||
|
||||
def __init__(self, session, postObject, view, interactor, caption=""):
|
||||
self.session = session
|
||||
self.post = postObject
|
||||
super(displayFriendshipPresenter, self).__init__(view=view, interactor=interactor, modulename="display_friendship")
|
||||
list_of_friends = self.get_friend_names()
|
||||
from_ = self.session.get_user(self.post["source_id"])
|
||||
title = caption.format(**from_)
|
||||
self.send_message("set_title", value=title)
|
||||
self.set_friends_list(list_of_friends)
|
||||
self.run()
|
||||
|
||||
def get_friend_names(self):
|
||||
self.friends = self.post["friends"]["items"]
|
||||
friends = list()
|
||||
for i in self.friends:
|
||||
if "user_id" in i:
|
||||
friends.append(self.session.get_user(i["user_id"])["user1_nom"])
|
||||
else:
|
||||
friends.append(self.session.get_user(i["id"])["user1_nom"])
|
||||
return friends
|
||||
|
||||
def set_friends_list(self, friendslist):
|
||||
self.send_message("add_items", control="friends", items=friendslist)
|
||||
|
||||
def view_profile(self, item):
|
||||
user = self.friends[item]
|
||||
if "user_id" in user:
|
||||
id = user["user_id"]
|
||||
else:
|
||||
id = user["id"]
|
||||
pub.sendMessage("user-profile", person=id)
|
||||
|
||||
def open_in_browser(self, item):
|
||||
user = self.friends[item]
|
||||
if "user_id" in user:
|
||||
id = user["user_id"]
|
||||
else:
|
||||
id = user["id"]
|
||||
url = "https://vk.com/id{user_id}".format(user_id=id)
|
||||
webbrowser.open_new_tab(url)
|
55
src/presenters/displayPosts/poll.py
Normal file
55
src/presenters/displayPosts/poll.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import output
|
||||
import logging
|
||||
from presenters import base
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
class displayPollPresenter(base.basePresenter):
|
||||
|
||||
def __init__(self, session, poll, view, interactor, show_results=False):
|
||||
super(displayPollPresenter, self).__init__(view=view, interactor=interactor, modulename="display_poll")
|
||||
self.poll = poll["poll"]
|
||||
self.session = session
|
||||
self.get_poll()
|
||||
self.load_poll(show_results)
|
||||
self.run()
|
||||
|
||||
def get_poll(self):
|
||||
# Retrieve the poll again so we will have a fresh and updated object.
|
||||
data = dict(owner_id=self.poll["owner_id"], is_board=int(self.poll["is_board"]), poll_id=self.poll["id"])
|
||||
self.poll = self.session.vk.client.polls.getById(**data)
|
||||
|
||||
def load_poll(self, load_results=False):
|
||||
user = self.session.get_user(self.poll["author_id"])
|
||||
title = _("Poll from {user1_nom}").format(**user)
|
||||
self.send_message("set_title", value=title)
|
||||
self.send_message("set", control="question", value=self.poll["question"])
|
||||
if len(self.poll["answer_ids"]) > 0 or ("is_closed" in self.poll and self.poll["is_closed"] == True) or load_results == True or ("can_vote" in self.poll and self.poll["can_vote"] == False):
|
||||
options = []
|
||||
for i in self.poll["answers"]:
|
||||
options.append((i["text"], i["votes"], i["rate"]))
|
||||
self.send_message("add_options", options=options, multiple=self.poll["multiple"])
|
||||
self.send_message("done")
|
||||
self.send_message("disable_control", control="ok")
|
||||
else:
|
||||
options = []
|
||||
for i in self.poll["answers"]:
|
||||
options.append(i["text"])
|
||||
self.send_message("add_options", options=options, multiple=self.poll["multiple"])
|
||||
self.send_message("done")
|
||||
|
||||
def vote(self, answers):
|
||||
ids = ""
|
||||
for i in range(0, len(self.poll["answers"])):
|
||||
if answers[i] == True:
|
||||
ids = ids+"{answer_id},".format(answer_id=self.poll["answers"][i]["id"])
|
||||
if self.poll["multiple"] == False:
|
||||
break
|
||||
if ids == "":
|
||||
log.exception("An error occurred when retrieving answer IDS for the following poll: %r. Provided answer list: %r" % (self.poll, answers))
|
||||
return
|
||||
data = dict(owner_id=self.poll["owner_id"], poll_id=self.poll["id"], answer_ids=ids, is_board=int(self.poll["is_board"]))
|
||||
result = self.session.vk.client.polls.addVote(**data)
|
||||
if result == 1:
|
||||
output.speak(_("Your vote has been added to this poll."))
|
168
src/presenters/displayPosts/topic.py
Normal file
168
src/presenters/displayPosts/topic.py
Normal file
@@ -0,0 +1,168 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import threading
|
||||
import arrow
|
||||
import languageHandler
|
||||
import views
|
||||
import interactors
|
||||
import output
|
||||
import logging
|
||||
from sessionmanager import utils # We'll use some functions from there
|
||||
from mysc.thread_utils import call_threaded
|
||||
from presenters import base
|
||||
from presenters.createPosts.basePost import createPostPresenter
|
||||
from . import basePost
|
||||
from .topicComment import *
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
class displayTopicPresenter(basePost.displayPostPresenter):
|
||||
|
||||
def __init__(self, session, postObject, group_id, view, interactor):
|
||||
self.type = "topic"
|
||||
self.modulename = "display_topic"
|
||||
self.interactor = interactor
|
||||
self.view = view
|
||||
self.interactor.install(view=view, presenter=self, modulename=self.modulename)
|
||||
self.session = session
|
||||
self.post = postObject
|
||||
self.group_id = group_id
|
||||
self.load_images = False
|
||||
# We'll put images here, so it will be easier to work with them.
|
||||
self.images = []
|
||||
self.imageIndex = 0
|
||||
result = self.get_post_information()
|
||||
# Stop loading everything else if post was deleted.
|
||||
if result == False:
|
||||
self.interactor.uninstall()
|
||||
return
|
||||
self.worker = threading.Thread(target=self.load_all_components)
|
||||
self.worker.finished = threading.Event()
|
||||
self.worker.start()
|
||||
self.attachments = []
|
||||
self.run()
|
||||
|
||||
def load_all_components(self):
|
||||
self.get_comments()
|
||||
|
||||
def get_post_information(self):
|
||||
title = self.post["title"]
|
||||
self.send_message("set_title", value=title)
|
||||
return True
|
||||
|
||||
def get_comments(self):
|
||||
""" Get comments and insert them in a list."""
|
||||
self.comments = self.session.vk.client.board.getComments(group_id=self.group_id, topic_id=self.post["id"], need_likes=1, count=100, extended=1, sort="desc")
|
||||
comments_ = []
|
||||
data = dict(profiles=self.comments["profiles"], groups=[])
|
||||
self.session.process_usernames(data)
|
||||
self.comments["items"].reverse()
|
||||
# If there are less than 100 comments in the topic we should disable the "load previous" button.
|
||||
if self.comments["count"] <= 100:
|
||||
self.send_message("disable_control", control="load_more_comments")
|
||||
else:
|
||||
left_comments = self.comments["count"]-len(self.comments["items"])
|
||||
if left_comments > 100:
|
||||
left_comments = 100
|
||||
self.send_message("set_label", control="load_more_comments", label=_("Load {comments} previous comments").format(comments=left_comments))
|
||||
for i in self.comments["items"]:
|
||||
# If comment has a "deleted" key it should not be displayed, obviously.
|
||||
if "deleted" in i:
|
||||
continue
|
||||
from_ = self.session.get_user(i["from_id"])["user1_nom"]
|
||||
# match user mentions inside text comment.
|
||||
original_date = arrow.get(i["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
likes = str(i["likes"]["count"])
|
||||
text = utils.clean_text(text=i["text"])
|
||||
comments_.append((from_, text, created_at, likes))
|
||||
self.send_message("add_items", control="comments", items=comments_)
|
||||
|
||||
def post_like(self):
|
||||
c = self.interactor.view.comments.get_selected()
|
||||
id = self.comments["items"][c]["id"]
|
||||
if self.comments["items"][c]["likes"]["user_likes"] == 1:
|
||||
l = self.session.vk.client.likes.delete(owner_id=-1*self.group_id, item_id=id, type="topic_comment")
|
||||
output.speak(_("You don't like this"))
|
||||
self.comments["items"][c]["likes"]["count"] = l["likes"]
|
||||
self.comments["items"][c]["likes"]["user_likes"] = 2
|
||||
self.send_message("set_label", control="like", label=_("&Like"))
|
||||
else:
|
||||
l = self.session.vk.client.likes.add(owner_id=-1*self.group_id, item_id=id, type="topic_comment")
|
||||
output.speak(_("You liked this"))
|
||||
self.send_message("set_label", control="like", label=_("&Dislike"))
|
||||
self.comments["items"][c]["likes"]["count"] = l["likes"]
|
||||
self.comments["items"][c]["likes"]["user_likes"] = 1
|
||||
self.clear_comments_list()
|
||||
|
||||
def change_comment(self, comment):
|
||||
comment = self.comments["items"][comment]
|
||||
self.send_message("clean_list", list="attachments")
|
||||
self.get_attachments(comment, "")
|
||||
if comment["likes"]["user_likes"] == 1:
|
||||
self.send_message("set_label", control="like", label=_("&Dislike"))
|
||||
else:
|
||||
self.send_message("set_label", control="like", label=_("&Like"))
|
||||
|
||||
def add_comment(self):
|
||||
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Add a comment"), message="", text="", mode="comment"))
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
group_id = self.group_id
|
||||
topic_id = self.post["id"]
|
||||
call_threaded(self.do_last, comment, group_id=group_id, topic_id=topic_id)
|
||||
|
||||
def do_last(self, comment, **kwargs):
|
||||
msg = comment.text
|
||||
attachments = ""
|
||||
if hasattr(comment, "attachments"):
|
||||
attachments = self.upload_attachments(comment.attachments)
|
||||
if msg != "":
|
||||
kwargs.update(message=msg)
|
||||
if attachments != "":
|
||||
kwargs.update(attachments=attachments)
|
||||
if "message" not in kwargs and "attachments" not in kwargs:
|
||||
return # No comment made here.
|
||||
result = self.session.vk.client.board.createComment(**kwargs)
|
||||
self.clear_comments_list()
|
||||
|
||||
def reply(self, comment):
|
||||
c = self.comments["items"][comment]
|
||||
comment = createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Reply to {user1_nom}").format(**self.session.get_user(c["from_id"])), message="", text="", mode="comment"))
|
||||
if hasattr(comment, "text") or hasattr(comment, "privacy"):
|
||||
user = self.session.get_user(c["from_id"])
|
||||
name = user["user1_nom"].split(" ")[0]
|
||||
comment.text = "[post{post_id}|{name}], {text}".format(post_id=c["id"], text=comment.text, name=name)
|
||||
group_id = self.group_id
|
||||
topic_id = self.post["id"]
|
||||
call_threaded(self.do_last, comment, group_id=group_id, topic_id=topic_id, reply_to_comment=c["id"])
|
||||
|
||||
def show_comment(self, comment_index):
|
||||
c = self.comments["items"][comment_index]
|
||||
c["post_id"] = self.post["id"]
|
||||
a = displayTopicCommentPresenter(session=self.session, postObject=c, interactor=interactors.displayPostInteractor(), view=views.displayComment())
|
||||
|
||||
def load_more_comments(self):
|
||||
offset = len(self.comments["items"])
|
||||
comments = self.session.vk.client.board.getComments(group_id=self.group_id, topic_id=self.post["id"], need_likes=1, count=100, extended=1, sort="desc", offset=offset)
|
||||
data = dict(profiles=comments["profiles"], groups=[])
|
||||
self.session.process_usernames(data)
|
||||
# If there are less than 100 comments in the topic we should disable the "load previous" button.
|
||||
for i in comments["items"]:
|
||||
self.comments["items"].insert(0, i)
|
||||
for i in comments["items"]:
|
||||
# If comment has a "deleted" key it should not be displayed, obviously.
|
||||
if "deleted" in i:
|
||||
continue
|
||||
from_ = self.session.get_user(i["from_id"])["user1_nom"]
|
||||
# match user mentions inside text comment.
|
||||
original_date = arrow.get(i["date"])
|
||||
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
|
||||
likes = str(i["likes"]["count"])
|
||||
text = utils.clean_text(text=i["text"])
|
||||
self.send_message("add_item", control="comments", item=(from_, text, created_at, likes), reversed=True)
|
||||
if len(self.comments["items"]) == self.comments["count"]:
|
||||
self.send_message("disable_control", control="load_more_comments")
|
||||
else:
|
||||
left_comments = self.comments["count"]-len(self.comments["items"])
|
||||
if left_comments > 100:
|
||||
left_comments = 100
|
||||
self.send_message("set_label", control="load_more_comments", label=_("Load {comments} previous comments").format(comments=left_comments))
|
28
src/presenters/displayPosts/topicComment.py
Normal file
28
src/presenters/displayPosts/topicComment.py
Normal file
@@ -0,0 +1,28 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
from sessionmanager import renderers, utils # We'll use some functions from there
|
||||
from presenters import base
|
||||
from presenters.createPosts.basePost import createPostPresenter
|
||||
from . import comment
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
def get_message(status):
|
||||
message = ""
|
||||
if "text" in status:
|
||||
message = utils.clean_text(status["text"])
|
||||
return message
|
||||
|
||||
class displayTopicCommentPresenter(comment.displayCommentPresenter):
|
||||
|
||||
def get_post_information(self):
|
||||
from_ = self.session.get_user(self.post[self.user_identifier])
|
||||
title = from_["user1_nom"]
|
||||
self.send_message("set_title", value=title)
|
||||
message = ""
|
||||
message = get_message(self.post)
|
||||
self.send_message("set", control="post_view", value=message)
|
||||
self.get_attachments(self.post, message)
|
||||
self.check_image_load()
|
||||
self.send_message("disable_control", control="reply")
|
||||
self.send_message("disable_control", control="comments")
|
@@ -23,5 +23,7 @@ class worker(threading.Thread):
|
||||
pub.sendMessage("user-online", event=event)
|
||||
elif event.type == VkEventType.USER_OFFLINE:
|
||||
pub.sendMessage("user-offline", event=event)
|
||||
elif event.type == VkEventType.USER_TYPING:
|
||||
pub.sendMessage("user-typing", obj=event)
|
||||
except:
|
||||
pub.sendMessage("longpoll-read-timeout")
|
836
src/presenters/main.py
Normal file
836
src/presenters/main.py
Normal file
@@ -0,0 +1,836 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
import os
|
||||
import webbrowser
|
||||
import logging
|
||||
import output
|
||||
import interactors
|
||||
import views
|
||||
import config
|
||||
from vk_api.exceptions import LoginRequired, VkApiError
|
||||
from requests.exceptions import ConnectionError
|
||||
from pubsub import pub
|
||||
from mysc.repeating_timer import RepeatingTimer
|
||||
from mysc.thread_utils import call_threaded
|
||||
from mysc import localization
|
||||
from sessionmanager import session, utils, renderers
|
||||
from update import updater
|
||||
from issueReporter import issueReporter
|
||||
from controller import buffers, selector
|
||||
from . import player, longpollthread
|
||||
from . import base
|
||||
|
||||
log = logging.getLogger("controller.main")
|
||||
|
||||
class Controller(base.basePresenter):
|
||||
|
||||
def search(self, tab_name):
|
||||
for i in range(0, len(self.buffers)):
|
||||
if self.buffers[i].name == tab_name:
|
||||
return self.buffers[i]
|
||||
return False
|
||||
|
||||
def get_all_buffers(self, contains):
|
||||
results = []
|
||||
for i in self.buffers:
|
||||
if contains in i.name:
|
||||
results.append(i)
|
||||
return results
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Controller, self).__init__(*args, **kwargs)
|
||||
log.debug("Starting main controller...")
|
||||
self.buffers = []
|
||||
player.setup()
|
||||
self.session = session.sessions[list(session.sessions.keys())[0]]
|
||||
self.create_controls()
|
||||
call_threaded(updater.do_update, update_type=self.session.settings["general"]["update_channel"])
|
||||
|
||||
def create_buffer(self, buffer_type="baseBuffer", buffer_title="", parent_tab=None, loadable=False, get_items=False, kwargs={}):
|
||||
if not hasattr(buffers, buffer_type):
|
||||
raise AttributeError("Specified buffer type does not exist.")
|
||||
buffer = getattr(buffers, buffer_type)(**kwargs)
|
||||
if loadable:
|
||||
buffer.can_get_items = False
|
||||
self.buffers.append(buffer)
|
||||
if parent_tab == None:
|
||||
self.send_message("add_buffer", widget=buffer.tab, title=buffer_title)
|
||||
else:
|
||||
self.send_message("insert_buffer", widget=buffer.tab, title=buffer_title, parent=parent_tab)
|
||||
if get_items:
|
||||
call_threaded(buffer.get_items)
|
||||
|
||||
def create_empty_buffer(self, buffer_type="empty", buffer_title="", parent_tab=None, kwargs={}):
|
||||
if not hasattr(buffers, buffer_type):
|
||||
raise AttributeError("Specified buffer type does not exist.")
|
||||
buffer = getattr(buffers, buffer_type)(**kwargs)
|
||||
self.buffers.append(buffer)
|
||||
if parent_tab == None:
|
||||
self.window.add_buffer(buffer.tab, buffer_title)
|
||||
else:
|
||||
self.window.insert_buffer(buffer.tab, buffer_title, self.window.search(parent_tab))
|
||||
|
||||
def create_controls(self):
|
||||
log.debug("Creating controls for the window...")
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("Posts"), kwargs=dict(parent=self.window.tb, name="posts"))
|
||||
pub.sendMessage("create_buffer", buffer_type="baseBuffer", buffer_title=_("Home"), parent_tab="posts", kwargs=dict(parent=self.window.tb, name="home_timeline", session=self.session, composefunc="render_newsfeed_item", endpoint="newsfeed", count=self.session.settings["buffers"]["count_for_wall_buffers"]))
|
||||
pub.sendMessage("create_buffer", buffer_type="feedBuffer", buffer_title=_("My wall"), parent_tab="posts", kwargs=dict(parent=self.window.tb, name="me_feed", composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"]))
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("Music"), kwargs=dict(parent=self.window.tb, name="audios"))
|
||||
pub.sendMessage("create_buffer", buffer_type="audioBuffer", buffer_title=_("My audios"), parent_tab="audios", kwargs=dict(parent=self.window.tb, name="me_audio", composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio"))
|
||||
if self.session.settings["vk"]["use_alternative_tokens"] == False:
|
||||
pub.sendMessage("create_buffer", buffer_type="audioBuffer", buffer_title=_("Populars"), parent_tab="audios", kwargs=dict(parent=self.window.tb, name="popular_audio", composefunc="render_audio", session=self.session, endpoint="getPopular", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"]))
|
||||
pub.sendMessage("create_buffer", buffer_type="audioBuffer", buffer_title=_("Recommendations"), parent_tab="audios", kwargs=dict(parent=self.window.tb, name="recommended_audio", composefunc="render_audio", session=self.session, endpoint="getRecommendations", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"]))
|
||||
pub.sendMessage("create_empty_buffer", buffer_type="empty", buffer_title=_("Albums"), parent_tab="audios", kwargs=dict(parent=self.window.tb, name="albums"))
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("Video"), kwargs=dict(parent=self.window.tb, name="videos"))
|
||||
pub.sendMessage("create_buffer", buffer_type="videoBuffer", buffer_title=_("My videos"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="me_video", composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"]))
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("Albums"), parent_tab="videos", kwargs=dict(parent=self.window.tb, name="video_albums"))
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("People"), kwargs=dict(parent=self.window.tb, name="people"))
|
||||
pub.sendMessage("create_buffer", buffer_type="peopleBuffer", buffer_title=_("Friends"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="friends_", composefunc="render_person", session=self.session, endpoint="get", parent_endpoint="friends", count=5000, order="hints", fields="uid, first_name, last_name, last_seen"))
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("Friendship requests"), parent_tab="people", kwargs=dict(parent=self.window.tb, name="requests"))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Pending requests"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests", composefunc="render_person", session=self.session, count=1000))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("I follow"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="friend_requests_sent", composefunc="render_person", session=self.session, count=1000, out=1))
|
||||
pub.sendMessage("create_buffer", buffer_type="requestsBuffer", buffer_title=_("Subscribers"), parent_tab="requests", kwargs=dict(parent=self.window.tb, name="subscribers", composefunc="render_person", session=self.session, count=1000, need_viewed=1))
|
||||
pub.sendMessage("create_buffer", buffer_type="documentBuffer", buffer_title=_("Documents"), parent_tab=None, loadable=True, kwargs=dict(parent=self.window.tb, name="documents", composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs"))
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("Communities"), kwargs=dict(parent=self.window.tb, name="communities"))
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("Chats"), kwargs=dict(parent=self.window.tb, name="chats"))
|
||||
pub.sendMessage("create_empty_buffer", buffer_title=_("Timelines"), kwargs=dict(parent=self.window.tb, name="timelines"))
|
||||
self.window.realize()
|
||||
self.repeatedUpdate = RepeatingTimer(120, self.update_all_buffers)
|
||||
self.repeatedUpdate.start()
|
||||
self.readMarker = RepeatingTimer(60, self.mark_as_read)
|
||||
self.readMarker.start()
|
||||
|
||||
def connect_events(self):
|
||||
log.debug("Connecting events to responses...")
|
||||
pub.subscribe(self.in_post, "posted")
|
||||
pub.subscribe(self.download, "download-file")
|
||||
pub.subscribe(self.play_audio, "play-audio")
|
||||
pub.subscribe(self.play_audios, "play-audios")
|
||||
pub.subscribe(self.view_post, "open-post")
|
||||
pub.subscribe(self.update_status_bar, "update-status-bar")
|
||||
pub.subscribe(self.chat_from_id, "new-chat")
|
||||
pub.subscribe(self.authorisation_failed, "authorisation-failed")
|
||||
pub.subscribe(self.user_profile, "user-profile")
|
||||
pub.subscribe(self.user_online, "user-online")
|
||||
pub.subscribe(self.user_offline, "user-offline")
|
||||
pub.subscribe(self.notify, "notify")
|
||||
pub.subscribe(self.handle_longpoll_read_timeout, "longpoll-read-timeout")
|
||||
pub.subscribe(self.create_buffer, "create_buffer")
|
||||
pub.subscribe(self.create_empty_buffer, "create_empty_buffer")
|
||||
pub.subscribe(self.user_typing, "user-typing")
|
||||
widgetUtils.connect_event(self.window, widgetUtils.CLOSE_EVENT, self.exit)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.update_buffer, menuitem=self.window.update_buffer)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_for_updates, menuitem=self.window.check_for_updates)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.window.about_dialog, menuitem=self.window.about)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_audios, menuitem=self.window.search_audios)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.search_videos, menuitem=self.window.search_videos)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU,self.remove_buffer, menuitem=self.window.remove_buffer_)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.get_more_items, menuitem=self.window.load_previous_items)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.changelog, menuitem=self.window.changelog)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.configuration, menuitem=self.window.settings_dialog)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.new_timeline, menuitem=self.window.timeline)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_audio_album, menuitem=self.window.audio_album)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_audio_album, menuitem=self.window.delete_audio_album)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.create_video_album, menuitem=self.window.video_album)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.delete_video_album, menuitem=self.window.delete_video_album)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.check_documentation, menuitem=self.window.documentation)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_pause, menuitem=self.window.player_play)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_next, menuitem=self.window.player_next)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_previous, menuitem=self.window.player_previous)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_play_all, menuitem=self.window.player_play_all)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_down, menuitem=self.window.player_volume_down)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_volume_up, menuitem=self.window.player_volume_up)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.menu_mute, menuitem=self.window.player_mute)
|
||||
pub.subscribe(self.get_chat, "order-sent-message")
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile, menuitem=self.window.view_profile)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.view_my_profile_in_browser, menuitem=self.window.open_in_browser)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.set_status, menuitem=self.window.set_status)
|
||||
widgetUtils.connect_event(self.window, widgetUtils.MENU, self.on_report_error, menuitem=self.window.report)
|
||||
self.window.tb.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu)
|
||||
|
||||
def disconnect_events(self):
|
||||
log.debug("Disconnecting some events...")
|
||||
pub.unsubscribe(self.in_post, "posted")
|
||||
pub.unsubscribe(self.download, "download-file")
|
||||
pub.unsubscribe(self.play_audio, "play-audio")
|
||||
pub.unsubscribe(self.authorisation_failed, "authorisation-failed")
|
||||
pub.unsubscribe(self.play_audios, "play-audios")
|
||||
pub.unsubscribe(self.view_post, "open-post")
|
||||
pub.unsubscribe(self.update_status_bar, "update-status-bar")
|
||||
pub.unsubscribe(self.user_online, "user-online")
|
||||
pub.unsubscribe(self.user_offline, "user-offline")
|
||||
pub.unsubscribe(self.notify, "notify")
|
||||
|
||||
def on_context_menu(self, event, *args, **kwargs):
|
||||
""" Handles context menu event in the tree buffers."""
|
||||
# If the focus is not in the TreeCtrl of the Treebook, then we should not display any menu.
|
||||
if isinstance(self.window.FindFocus(), wx.TreeCtrl) == False:
|
||||
event.Skip()
|
||||
return
|
||||
menu = None
|
||||
# Get the current buffer and let's choose a different menu depending on the selected buffer.
|
||||
current_buffer = self.get_current_buffer()
|
||||
# Deal with menu for community buffers.
|
||||
if current_buffer.name.endswith("_community"):
|
||||
menu = menus.communityBufferMenu()
|
||||
# disable post loading if the community has already loaded posts.
|
||||
if current_buffer.can_get_items:
|
||||
menu.load_posts.Enable(False)
|
||||
# Disable loading of audios, videos, documents or topics depending in two conditions.
|
||||
# 1. If the buffer already exists, which means they are already loaded, or
|
||||
# 2. If the group_info does not have counters for such items, which would indicate there are no items posted yet.
|
||||
if self.search(current_buffer.name+"_audios") != False:
|
||||
menu.load_audios.Enable(False)
|
||||
elif hasattr(current_buffer, "group_info") and "audios" not in current_buffer.group_info["counters"]:
|
||||
menu.load_audios.Enable(False)
|
||||
if self.search(current_buffer.name+"_videos") != False:
|
||||
menu.load_videos.Enable(False)
|
||||
elif hasattr(current_buffer, "group_info") and "videos" not in current_buffer.group_info["counters"]:
|
||||
menu.load_videos.Enable(False)
|
||||
if self.search(current_buffer.name+"_topics") != False:
|
||||
menu.load_topics.Enable(False)
|
||||
elif hasattr(current_buffer, "group_info") and "topics" not in current_buffer.group_info["counters"]:
|
||||
menu.load_topics.Enable(False)
|
||||
|
||||
if self.search(current_buffer.name+"_documents") != False:
|
||||
menu.load_documents.Enable(False)
|
||||
elif hasattr(current_buffer, "group_info") and "docs" not in current_buffer.group_info["counters"]:
|
||||
menu.load_documents.Enable(False)
|
||||
# Connect the rest of the functions.
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_posts, menuitem=menu.load_posts)
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_topics, menuitem=menu.load_topics)
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_audios, menuitem=menu.load_audios)
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_videos, menuitem=menu.load_videos)
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_documents, menuitem=menu.load_documents)
|
||||
# Deal with the communities section itself.
|
||||
if current_buffer.name == "communities":
|
||||
menu = wx.Menu()
|
||||
# Insert a different option depending if group buffers are loaded or scheduled to be loaded or not.
|
||||
if self.session.settings["load_at_startup"]["communities"] == False and not hasattr(self.session, "groups"):
|
||||
option = menu.Append(wx.NewId(), _("Load groups"))
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.load_community_buffers, menuitem=option)
|
||||
else:
|
||||
option = menu.Append(wx.NewId(), _("Discard groups"))
|
||||
widgetUtils.connect_event(menu, widgetUtils.MENU, self.unload_community_buffers, menuitem=option)
|
||||
if menu != None:
|
||||
self.window.PopupMenu(menu, self.window.FindFocus().GetPosition())
|
||||
# If there are no available menus, let's indicate it.
|
||||
else:
|
||||
output.speak(_("menu unavailable for this buffer."))
|
||||
|
||||
def authorisation_failed(self):
|
||||
commonMessages.bad_authorisation()
|
||||
|
||||
def login(self):
|
||||
self.window.change_status(_("Logging in VK"))
|
||||
self.session.login()
|
||||
self.window.change_status(_("Ready"))
|
||||
for i in self.buffers:
|
||||
if hasattr(i, "get_items"):
|
||||
# Translators: {0} will be replaced with the name of a buffer.
|
||||
self.window.change_status(_("Loading items for {0}").format(i.name,))
|
||||
i.get_items()
|
||||
self.window.change_status(_("Ready"))
|
||||
self.create_unread_messages()
|
||||
self.status_setter = RepeatingTimer(280, self.set_online)
|
||||
self.status_setter.start()
|
||||
self.set_online(notify=True)
|
||||
self.get_audio_albums(self.session.user_id)
|
||||
self.get_video_albums(self.session.user_id)
|
||||
self.get_communities(self.session.user_id)
|
||||
self.create_longpoll_thread()
|
||||
|
||||
def create_longpoll_thread(self, notify=False):
|
||||
try:
|
||||
self.longpoll = longpollthread.worker(self.session)
|
||||
self.longpoll.start()
|
||||
if notify:
|
||||
self.notify(message=_("Chat server reconnected"))
|
||||
except ConnectionError:
|
||||
pub.sendMessage("longpoll-read-timeout")
|
||||
|
||||
def in_post(self, buffer):
|
||||
buffer = self.search(buffer)
|
||||
buffer.get_items()
|
||||
buffer = self.search("home_timeline")
|
||||
buffer.get_items()
|
||||
|
||||
def update_all_buffers(self):
|
||||
log.debug("Updating buffers...")
|
||||
self.get_audio_albums(self.session.user_id, create_buffers=False)
|
||||
self.get_video_albums(self.session.user_id, create_buffers=False)
|
||||
for i in self.buffers:
|
||||
if hasattr(i, "get_items"):
|
||||
i.get_items()
|
||||
log.debug("Updated %s" % (i.name))
|
||||
|
||||
def download(self, url, filename):
|
||||
log.debug("downloading %s URL to %s filename" % (url, filename,))
|
||||
call_threaded(utils.download_file, url, filename, self.window)
|
||||
|
||||
def play_audio(self, audio_object):
|
||||
# Restricted audios don't include an URL paramether.
|
||||
# Restriction can be due to licensed content to unauthorized countries.
|
||||
if "url" in audio_object and audio_object["url"] =="":
|
||||
self.notify(message=_("This file could not be played because it is not allowed in your country"))
|
||||
return
|
||||
call_threaded(player.player.play, audio_object, fresh=True)
|
||||
|
||||
def play_audios(self, audios):
|
||||
player.player.play_all(audios, shuffle=self.window.player_shuffle.IsChecked())
|
||||
|
||||
def view_post(self, post_object, controller_):
|
||||
p = getattr(presenters, controller_+"Presenter")(session=self.session, postObject=post_object, interactor=getattr(interactors, controller_+"Interactor")(), view=getattr(views, controller_)())
|
||||
|
||||
def exit(self, *args, **kwargs):
|
||||
log.debug("Receibed an exit signal. closing...")
|
||||
self.set_offline()
|
||||
self.disconnect_events()
|
||||
volume = player.player.volume
|
||||
config.app["sound"]["volume"] = volume
|
||||
config.app.write()
|
||||
self.window.Destroy()
|
||||
wx.GetApp().ExitMainLoop()
|
||||
|
||||
def update_buffer(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
b.get_items()
|
||||
|
||||
def get_more_items(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
b.get_more_items()
|
||||
|
||||
def check_for_updates(self, *args, **kwargs):
|
||||
update = updater.do_update(update_type=self.session.settings["general"]["update_channel"])
|
||||
if update == False:
|
||||
commonMessages.no_update_available()
|
||||
|
||||
def search_audios(self, *args, **kwargs):
|
||||
dlg = searchDialogs.searchAudioDialog()
|
||||
if dlg.get_response() == widgetUtils.OK:
|
||||
q = dlg.get("term")
|
||||
auto_complete = True
|
||||
count = 300
|
||||
performer_only = dlg.get_state("title")
|
||||
sort = dlg.get_sort_order()
|
||||
newbuff = buffers.audioBuffer(parent=self.window.tb, name="{0}_audiosearch".format(q,), session=self.session, composefunc="render_audio", parent_endpoint="audio", endpoint="search", q=q, auto_complete=auto_complete, count=count, performer_only=performer_only, sort=sort)
|
||||
self.buffers.append(newbuff)
|
||||
call_threaded(newbuff.get_items)
|
||||
# Translators: {0} will be replaced with the search term.
|
||||
self.window.insert_buffer(newbuff.tab, _("Search for {0}").format(q,), self.window.search("audios"))
|
||||
|
||||
def search_videos(self, *args, **kwargs):
|
||||
dlg = searchDialogs.searchVideoDialog()
|
||||
if dlg.get_response() == widgetUtils.OK:
|
||||
params = {}
|
||||
params["q"] = dlg.get("term")
|
||||
params["count"] = 200
|
||||
hd = dlg.get_checkable("hd")
|
||||
if hd != 0:
|
||||
params["hd"] = 1
|
||||
params["adult"] = dlg.get_checkable("safe_search")
|
||||
params["sort"] = dlg.get_sort_order()
|
||||
# params["filters"] = "youtube, vimeo, short, long, mp4"
|
||||
print(params)
|
||||
newbuff = buffers.videoBuffer(parent=self.window.tb, name="{0}_videosearch".format(params["q"],), session=self.session, composefunc="render_video", parent_endpoint="video", endpoint="search", **params)
|
||||
self.buffers.append(newbuff)
|
||||
call_threaded(newbuff.get_items)
|
||||
# Translators: {0} will be replaced with the search term.
|
||||
self.window.insert_buffer(newbuff.tab, _("Search for {0}").format(params["q"],), self.window.search("videos"))
|
||||
|
||||
def update_status_bar(self, status):
|
||||
self.window.change_status(status)
|
||||
|
||||
def remove_buffer(self, event, mandatory=False, *args, **kwargs):
|
||||
buffer = self.get_current_buffer()
|
||||
buff = self.window.search(buffer.name)
|
||||
answer = buffer.remove_buffer(mandatory)
|
||||
if answer == False:
|
||||
return
|
||||
self.window.remove_buffer(buff)
|
||||
self.buffers.remove(buffer)
|
||||
del buffer
|
||||
|
||||
def changelog(self, *args, **kwargs):
|
||||
lang = localization.get("documentation")
|
||||
os.chdir("documentation/%s" % (lang,))
|
||||
webbrowser.open("changelog.html")
|
||||
os.chdir("../../")
|
||||
|
||||
def configuration(self, *args, **kwargs):
|
||||
""" Opens the global settings dialogue."""
|
||||
presenter = presenters.configurationPresenter(session=self.session, view=views.configurationDialog(title=_("Preferences")), interactor=interactors.configurationInteractor())
|
||||
|
||||
def new_timeline(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
# If executing this method from an empty buffer we should get the newsfeed buffer.
|
||||
if not hasattr(b, "get_users"):
|
||||
b = self.search("home_timeline")
|
||||
# Get a list of (id, user) objects.
|
||||
d = []
|
||||
for i in self.session.db["users"]:
|
||||
d.append((i, self.session.get_user(i)["user1_gen"]))
|
||||
# Do the same for communities.
|
||||
for i in self.session.db["groups"]:
|
||||
d.append((-i, self.session.get_user(-i)["user1_nom"]))
|
||||
a = timeline.timelineDialog([i[1] for i in d])
|
||||
if a.get_response() == widgetUtils.OK:
|
||||
user = a.get_user()
|
||||
buffertype = a.get_buffer_type()
|
||||
user_id = ""
|
||||
for i in d:
|
||||
if i[1] == user:
|
||||
user_id = i[0]
|
||||
if user_id == "":
|
||||
user_data = self.session.vk.client.utils.resolveScreenName(screen_name=user)
|
||||
if type(user_data) == list:
|
||||
commonMessages.no_user_exist()
|
||||
return
|
||||
user_id = user_data["object_id"]
|
||||
if buffertype == "audio":
|
||||
buffer = buffers.audioBuffer(parent=self.window.tb, name="{0}_audio".format(user_id,), composefunc="render_audio", session=self.session, create_tab=False, endpoint="get", parent_endpoint="audio", owner_id=user_id)
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
name_ = _("{user1_nom}'s audios").format(**user)
|
||||
elif buffertype == "wall":
|
||||
buffer = buffers.feedBuffer(parent=self.window.tb, name="{0}_feed".format(user_id,), composefunc="render_status", session=self.session, create_tab=False, endpoint="get", parent_endpoint="wall", extended=1, count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=user_id)
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
name_ = _("{user1_nom}'s posts").format(**user)
|
||||
elif buffertype == "friends":
|
||||
buffer = buffers.peopleBuffer(parent=self.window.tb, name="friends_{0}".format(user_id,), composefunc="render_person", session=self.session, create_tab=False, endpoint="get", parent_endpoint="friends", count=5000, fields="uid, first_name, last_name, last_seen", user_id=user_id)
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
name_ = _("{user1_nom}'s friends").format(**user)
|
||||
wx.CallAfter(self.complete_buffer_creation, buffer=buffer, name_=name_, position=self.window.search("timelines"))
|
||||
|
||||
def complete_buffer_creation(self, buffer, name_, position):
|
||||
answer = buffer.get_items()
|
||||
if answer is not True:
|
||||
commonMessages.show_error_code(answer)
|
||||
return
|
||||
self.buffers.append(buffer)
|
||||
self.window.insert_buffer(buffer.tab, name_, position)
|
||||
|
||||
def search_chat_buffer(self, user_id):
|
||||
for i in self.buffers:
|
||||
if "_messages" in i.name:
|
||||
if "peer_id" in i.kwargs and i.kwargs["peer_id"] == user_id: return i
|
||||
return None
|
||||
|
||||
def chat_from_id(self, user_id, setfocus=True, unread=False):
|
||||
b = self.search_chat_buffer(user_id)
|
||||
if b != None:
|
||||
pos = self.window.search(b.name)
|
||||
if setfocus:
|
||||
self.window.change_buffer(pos)
|
||||
return b.tab.text.SetFocus()
|
||||
return
|
||||
# Get name based in the ID.
|
||||
# for users.
|
||||
if user_id > 0 and user_id < 2000000000:
|
||||
user = self.session.get_user(user_id, key="user1")
|
||||
name = user["user1_nom"]
|
||||
elif user_id > 2000000000:
|
||||
chat = self.session.vk.client.messages.getChat(chat_id=user_id-2000000000)
|
||||
name = chat["title"]
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="chatBuffer", buffer_title=name, parent_tab="chats", get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_messages".format(user_id,), composefunc="render_message", session=self.session, unread=unread, count=200, peer_id=user_id, rev=0, extended=True, fields="id, user_id, date, read_state, out, body, attachments, deleted"))
|
||||
# if setfocus:
|
||||
# pos = self.window.search(buffer.name)
|
||||
# self.window.change_buffer(pos)
|
||||
# call_threaded(buffer.get_items, unread=unread)
|
||||
# if setfocus: buffer.tab.text.SetFocus()
|
||||
# return True
|
||||
|
||||
def user_online(self, event):
|
||||
if self.session.settings["chat"]["notify_online"] == False:
|
||||
return
|
||||
user_name = self.session.get_user(event.user_id)
|
||||
msg = _("{user1_nom} is online.").format(**user_name)
|
||||
sound = "friend_online.ogg"
|
||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
||||
|
||||
def user_offline(self, event):
|
||||
if self.session.settings["chat"]["notify_offline"] == False:
|
||||
return
|
||||
user_name = self.session.get_user(event.user_id)
|
||||
msg = _("{user1_nom} is offline.").format(**user_name)
|
||||
sound = "friend_offline.ogg"
|
||||
self.notify(msg, sound, self.session.settings["chat"]["notifications"])
|
||||
|
||||
def user_typing(self, obj):
|
||||
buffer = self.search_chat_buffer(obj.user_id)
|
||||
if buffer != None and buffer == self.get_current_buffer():
|
||||
user = self.session.get_user(obj.user_id)
|
||||
output.speak(_("{user1_nom} is typing...").format(**user))
|
||||
|
||||
def get_chat(self, obj=None):
|
||||
""" Searches or creates a chat buffer with the id of the user that is sending or receiving a message.
|
||||
obj vk_api.longpoll.EventType: an event wich defines some data from the vk's long poll server."""
|
||||
message = {}
|
||||
uid = obj.peer_id
|
||||
buffer = self.search_chat_buffer(uid)
|
||||
if obj.from_me:
|
||||
message.update(out=0)
|
||||
# If there is no buffer, we must create one in a wxThread so it will not crash.
|
||||
if buffer == None:
|
||||
wx.CallAfter(self.chat_from_id, uid, setfocus=self.session.settings["chat"]["automove_to_conversations"], unread=True)
|
||||
self.session.soundplayer.play("conversation_opened.ogg")
|
||||
return
|
||||
# If the chat already exists, let's create a dictionary wich will contains data of the received message.
|
||||
message.update(id=obj.message_id, user_id=uid, date=obj.timestamp, body=utils.clean_text(obj.text), attachments=obj.attachments)
|
||||
# if attachments is true, let's request for the full message with attachments formatted in a better way.
|
||||
# ToDo: code improvements. We shouldn't need to request the same message again just for these attachments.
|
||||
if len(message["attachments"]) != 0:
|
||||
message_ids = message["id"]
|
||||
results = self.session.vk.client.messages.getById(message_ids=message_ids)
|
||||
message = results["items"][0]
|
||||
if obj.from_me:
|
||||
message["from_id"] = self.session.user_id
|
||||
else:
|
||||
message.update(read_state=0, out=0)
|
||||
message["from_id"] = obj.user_id
|
||||
data = [message]
|
||||
# Let's add this to the buffer.
|
||||
# ToDo: Clean this code and test how is the database working with this set to True.
|
||||
num = self.session.order_buffer(buffer.name, data, True)
|
||||
buffer.insert(self.session.db[buffer.name]["items"][-1], False)
|
||||
self.session.soundplayer.play("message_received.ogg")
|
||||
wx.CallAfter(self.reorder_buffer, buffer)
|
||||
# Check if we have to read the message aloud
|
||||
if buffer == self.get_current_buffer():
|
||||
rendered_message = renderers.render_message(message, self.session)
|
||||
output.speak(rendered_message[0])
|
||||
|
||||
def set_online(self, notify=False):
|
||||
try:
|
||||
r = self.session.vk.client.account.setOnline()
|
||||
except:
|
||||
log.error("Error in setting online for the current user")
|
||||
if notify:
|
||||
self.window.notify("Socializer", "online now!")
|
||||
|
||||
def set_offline(self):
|
||||
try:
|
||||
r = self.session.vk.client.account.setOffline()
|
||||
except:
|
||||
log.error("Error in setting offline status for the current user")
|
||||
|
||||
def create_unread_messages(self):
|
||||
if self.session.settings["chat"]["open_unread_conversations"] == False:
|
||||
return
|
||||
try:
|
||||
log.debug("Getting possible unread messages.")
|
||||
msgs = self.session.vk.client.messages.getConversations(count=200)
|
||||
except VkApiError as ex:
|
||||
if ex.code == 6:
|
||||
log.exception("Something went wrong when getting messages. Waiting a second to retry")
|
||||
for i in msgs["items"]:
|
||||
call_threaded(self.chat_from_id, i["last_message"]["peer_id"], setfocus=False, unread=False)
|
||||
time.sleep(0.6)
|
||||
|
||||
def mark_as_read(self):
|
||||
for i in self.buffers:
|
||||
if hasattr(i, "reads") and len(i.reads) != 0:
|
||||
response = self.session.vk.client.messages.markAsRead(peer_id=i.kwargs["peer_id"])
|
||||
i.clear_reads()
|
||||
i.reads = []
|
||||
time.sleep(1)
|
||||
|
||||
def get_audio_albums(self, user_id=None, create_buffers=True):
|
||||
if self.session.settings["load_at_startup"]["audio_albums"] == False:
|
||||
return
|
||||
log.debug("Create audio albums...")
|
||||
if self.session.settings["vk"]["use_alternative_tokens"]:
|
||||
albums = self.session.vk.client_audio.get_albums(owner_id=user_id)
|
||||
else:
|
||||
albums = self.session.vk.client.audio.getPlaylists(owner_id=user_id)
|
||||
albums = albums["items"]
|
||||
self.session.audio_albums = albums
|
||||
if create_buffers:
|
||||
for i in albums:
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="audioAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_audio_album".format(i["id"],), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=user_id, album_id=i["id"]))
|
||||
time.sleep(0.6)
|
||||
|
||||
def get_video_albums(self, user_id=None, create_buffers=True):
|
||||
if self.session.settings["load_at_startup"]["video_albums"] == False:
|
||||
return
|
||||
log.debug("Create video albums...")
|
||||
albums = self.session.vk.client.video.getAlbums(owner_id=user_id)
|
||||
self.session.video_albums = albums["items"]
|
||||
if create_buffers:
|
||||
for i in albums["items"]:
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="videoAlbum", buffer_title=_("Album: {0}").format(i["title"],), parent_tab="video_albums", loadable=True, kwargs=dict(parent=self.window.tb, name="{0}_video_album".format(i["id"],), composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], user_id=user_id, album_id=i["id"]))
|
||||
time.sleep(0.15)
|
||||
|
||||
def get_communities(self, user_id=None, create_buffers=True, force_action=False):
|
||||
if self.session.settings["vk"]["invited_to_group"] == False:
|
||||
self.session.settings["vk"]["invited_to_group"] = True
|
||||
self.session.settings.write()
|
||||
socializer_group = self.session.vk.client.groups.getById(group_ids="175825000")[0]
|
||||
if socializer_group["is_member"] ==False:
|
||||
d = commonMessages.join_group()
|
||||
self.session.settings["vk"]["invited_to_group"] = True
|
||||
self.session.settings.write()
|
||||
if d == widgetUtils.YES:
|
||||
result = self.session.vk.client.groups.join(group_id=socializer_group["id"])
|
||||
if result == 1:
|
||||
commonMessages.group_joined()
|
||||
else:
|
||||
log.error("Invalid result when joining the Socializer's group: %d" % (result))
|
||||
if self.session.settings["load_at_startup"]["communities"] == False and force_action == False:
|
||||
return
|
||||
log.debug("Create community buffers...")
|
||||
groups= self.session.vk.client.groups.get(user_id=user_id, extended=1, count=1000)
|
||||
self.session.groups=groups["items"]
|
||||
# Let's feed the local database cache with new groups coming from here.
|
||||
data= dict(profiles=[], groups=self.session.groups)
|
||||
self.session.process_usernames(data)
|
||||
if create_buffers:
|
||||
for i in self.session.groups:
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="communityBuffer", buffer_title=i["name"], parent_tab="communities", loadable=True, get_items=True, kwargs=dict(parent=self.window.tb, name="{0}_community".format(i["id"],), composefunc="render_status", session=self.session, endpoint="get", parent_endpoint="wall", count=self.session.settings["buffers"]["count_for_wall_buffers"], owner_id=-1*i["id"]))
|
||||
time.sleep(0.15)
|
||||
|
||||
def create_audio_album(self, *args, **kwargs):
|
||||
d = creation.audio_album()
|
||||
if d.get_response() == widgetUtils.OK and d.get("title") != "":
|
||||
response = self.session.vk.client.audio.createPlaylist(owner_id=self.session.user_id, title=d.get("title"))
|
||||
if "id" not in response:
|
||||
return
|
||||
album_id = response["id"]
|
||||
buffer = buffers.audioAlbum(parent=self.window.tb, name="{0}_audio_album".format(album_id,), composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", full_list=True, count=self.session.settings["buffers"]["count_for_audio_buffers"], user_id=self.session.user_id, album_id=album_id)
|
||||
buffer.can_get_items = False
|
||||
# Translators: {0} will be replaced with an audio album's title.
|
||||
name_ = _("Album: {0}").format(d.get("title"),)
|
||||
self.buffers.append(buffer)
|
||||
self.window.insert_buffer(buffer.tab, name_, self.window.search("albums"))
|
||||
buffer.get_items()
|
||||
self.get_audio_albums(user_id=self.session.user_id, create_buffers=False)
|
||||
|
||||
def delete_audio_album(self, *args, **kwargs):
|
||||
if len(self.session.audio_albums) == 0:
|
||||
return commonMessages.no_audio_albums()
|
||||
answer = selector.album(_("Select the album you want to delete"), self.session)
|
||||
if answer.item == None:
|
||||
return
|
||||
response = commonMessages.delete_audio_album()
|
||||
if response != widgetUtils.YES: return
|
||||
removal = self.session.vk.client.audio.deletePlaylist(playlist_id=answer.item, owner_id=self.session.user_id)
|
||||
if removal == 1:
|
||||
buffer = self.search("{0}_audio_album".format(answer.item,))
|
||||
buff = self.window.search(buffer.name)
|
||||
self.window.remove_buffer(buff)
|
||||
self.buffers.remove(buffer)
|
||||
del buffer
|
||||
self.get_audio_albums(user_id=self.session.user_id, create_buffers=False)
|
||||
|
||||
def create_video_album(self, *args, **kwargs):
|
||||
d = creation.audio_album()
|
||||
if d.get_response() == widgetUtils.OK and d.get("title") != "":
|
||||
response = self.session.vk.client.video.addAlbum(title=d.get("title"))
|
||||
if ("album_id" in response) == False: return
|
||||
album_id = response["album_id"]
|
||||
buffer = buffers.videoAlbum(parent=self.window.tb, name="{0}_video_album".format(album_id,), composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], user_id=self.session.user_id, album_id=album_id)
|
||||
buffer.can_get_items = False
|
||||
# Translators: {0} will be replaced with a video album's title.
|
||||
name_ = _("Album: {0}").format(d.get("title"),)
|
||||
self.buffers.append(buffer)
|
||||
self.window.insert_buffer(buffer.tab, name_, self.window.search("video_albums"))
|
||||
buffer.get_items()
|
||||
self.session.video_albums = self.session.vk.client.video.getAlbums(owner_id=self.session.user_id)["items"]
|
||||
|
||||
def delete_video_album(self, *args, **kwargs):
|
||||
if len(self.session.video_albums) == 0:
|
||||
return commonMessages.no_video_albums()
|
||||
answer = selector.album(_("Select the album you want to delete"), self.session, "video_albums")
|
||||
if answer.item == None:
|
||||
return
|
||||
response = commonMessages.delete_audio_album()
|
||||
if response != widgetUtils.YES: return
|
||||
removal = self.session.vk.client.video.deleteAlbum(album_id=answer.item)
|
||||
buffer = self.search("{0}_video_album".format(answer.item,))
|
||||
buff = self.window.search(buffer.name)
|
||||
self.window.remove_buffer(buff)
|
||||
self.buffers.remove(buffer)
|
||||
del buffer
|
||||
self.session.video_albums = self.session.vk.client.video.getAlbums(owner_id=self.session.user_id)["items"]
|
||||
|
||||
def check_documentation(self, *args, **kwargs):
|
||||
lang = localization.get("documentation")
|
||||
os.chdir("documentation/%s" % (lang,))
|
||||
webbrowser.open("manual.html")
|
||||
os.chdir("../../")
|
||||
|
||||
def menu_play_pause(self, *args, **kwargs):
|
||||
if player.player.stream != None:
|
||||
return player.player.pause()
|
||||
else:
|
||||
b = self.get_current_buffer()
|
||||
if hasattr(b, "play_all"):
|
||||
b.play_all()
|
||||
else:
|
||||
self.search("me_audio").play_all()
|
||||
|
||||
def menu_play_next(self, *args, **kwargs):
|
||||
return player.player.play_next()
|
||||
# b = self.get_current_buffer()
|
||||
# if hasattr(b, "play_next"):
|
||||
# b.play_next()
|
||||
# else:
|
||||
# self.search("me_audio").play_next()
|
||||
|
||||
def menu_play_previous(self, *args, **kwargs):
|
||||
return player.player.play_previous()
|
||||
# b = self.get_current_buffer()
|
||||
# if hasattr(b, "play_previous"):
|
||||
# b.play_previous()
|
||||
# else:
|
||||
# self.search("me_audio").play_previous()
|
||||
|
||||
def menu_play_all(self, *args, **kwargs):
|
||||
b = self.get_current_buffer()
|
||||
if hasattr(b, "play_all"):
|
||||
b.play_all()
|
||||
else:
|
||||
self.search("me_audio").play_all()
|
||||
|
||||
def menu_volume_down(self, *args, **kwargs):
|
||||
player.player.volume = player.player.volume-5
|
||||
|
||||
def menu_volume_up(self, *args, **kwargs):
|
||||
player.player.volume = player.player.volume+5
|
||||
|
||||
def menu_mute(self, *args, **kwargs):
|
||||
player.player.volume = 0
|
||||
|
||||
def user_profile(self, person):
|
||||
p = presenters.userProfilePresenter(session=self.session, user_id=person, view=views.userProfileDialog(), interactor=interactors.userProfileInteractor())
|
||||
|
||||
def view_my_profile(self, *args, **kwargs):
|
||||
self.user_profile(self.session.user_id)
|
||||
|
||||
def view_my_profile_in_browser(self, *args, **kwargs):
|
||||
webbrowser.open_new_tab("https://vk.com/id{id}".format(id=self.session.user_id,))
|
||||
|
||||
def notify(self, message="", sound="", type="native"):
|
||||
if type == "native":
|
||||
self.window.notify(_("Socializer"), message)
|
||||
else:
|
||||
if sound != "":
|
||||
self.session.soundplayer.play(sound)
|
||||
if message != "":
|
||||
output.speak(message)
|
||||
|
||||
def handle_longpoll_read_timeout(self):
|
||||
if hasattr(self, "longpoll"):
|
||||
self.notify(message=_("Chat disconnected. Trying to connect in 60 seconds"))
|
||||
time.sleep(60)
|
||||
if hasattr(self, "longpoll"):
|
||||
del self.longpoll
|
||||
self.create_longpoll_thread(notify=True)
|
||||
|
||||
def set_status(self, *args, **kwargs):
|
||||
dlg = wx.TextEntryDialog(self.window, _("Write your status message"), _("Set status"))
|
||||
if dlg.ShowModal() == widgetUtils.OK:
|
||||
result = dlg.GetValue()
|
||||
info = self.session.vk.client.account.saveProfileInfo(status=result)
|
||||
commonMessages.updated_status()
|
||||
dlg.Destroy()
|
||||
|
||||
def on_report_error(self, *args, **kwargs):
|
||||
r = issueReporter.reportBug()
|
||||
|
||||
def reorder_buffer(self, buffer):
|
||||
""" this puts the chat buffers at the top of the list when there are new incoming messages.
|
||||
In order to do so, we search for the current buffer's tab, remove the page from the TreeCtrl (without destroying the associated tab)
|
||||
and reinsert it as a new child of the chat buffer.
|
||||
Lastly we ensure the user is focused in the same buffer than before."""
|
||||
buffer_window = self.window.search(buffer.name)
|
||||
# If buffer window is already in the first position after chat, we should not do anything here because calculations for moving buffers are expensive.
|
||||
if buffer_window == self.window.search("chats")+1:
|
||||
return
|
||||
# Gets buffer title so we don't have to generate it again in future.
|
||||
buffer_title = self.window.get_buffer_text(buffer_window)
|
||||
# Determine if the current buffer is the buffer receiving a new message.
|
||||
if buffer == self.get_current_buffer():
|
||||
focused_buffer = True
|
||||
else:
|
||||
focused_buffer = False
|
||||
# This call will not destroy the associated tab for the chat buffer, thus allowing us to readd it in other position.
|
||||
self.window.remove_buffer_from_position(buffer_window)
|
||||
self.window.insert_chat_buffer(buffer.tab, buffer_title, self.window.search("chats")+1)
|
||||
# Let's manipulate focus so users will not notice the change in buffers.
|
||||
if focused_buffer:
|
||||
new_position = self.window.search(buffer.name)
|
||||
self.window.change_buffer(new_position)
|
||||
else:
|
||||
new_position = self.window.search(self.get_current_buffer().name)
|
||||
self.window.change_buffer(new_position)
|
||||
|
||||
def load_community_posts(self, *args, **kwargs):
|
||||
""" Load community posts. It just calls to the needed method in the community buffer."""
|
||||
current_buffer = self.get_current_buffer()
|
||||
if current_buffer.name.endswith("_community"):
|
||||
current_buffer.load_community()
|
||||
|
||||
def load_community_audios(self, *args, **kwargs):
|
||||
""" Load community audios if they are not loaded already."""
|
||||
current_buffer = self.get_current_buffer()
|
||||
# Get group_info if the community buffer does not have it already, so future menus will be able to use it.
|
||||
if not hasattr(current_buffer, "group_info"):
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0]
|
||||
current_buffer.group_info = group_info
|
||||
if "audios" not in current_buffer.group_info["counters"]:
|
||||
commonMessages.community_no_items()
|
||||
return
|
||||
new_name = current_buffer.name+"_audios"
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="audioBuffer", buffer_title=_("Audios"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_audio", session=self.session, endpoint="get", parent_endpoint="audio", owner_id=current_buffer.kwargs["owner_id"]))
|
||||
|
||||
def load_community_videos(self, *args, **kwargs):
|
||||
""" Load community videos if they are not loaded already."""
|
||||
current_buffer = self.get_current_buffer()
|
||||
# Get group_info if the community buffer does not have it already, so future menus will be able to use it.
|
||||
if not hasattr(current_buffer, "group_info"):
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0]
|
||||
current_buffer.group_info = group_info
|
||||
if "videos" not in current_buffer.group_info["counters"]:
|
||||
commonMessages.community_no_items()
|
||||
return
|
||||
new_name = current_buffer.name+"_videos"
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="videoBuffer", buffer_title=_("Videos"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_video", session=self.session, endpoint="get", parent_endpoint="video", count=self.session.settings["buffers"]["count_for_video_buffers"], owner_id=current_buffer.kwargs["owner_id"]))
|
||||
|
||||
def load_community_topics(self, *args, **kwargs):
|
||||
""" Load community topics."""
|
||||
current_buffer = self.get_current_buffer()
|
||||
# Get group_info if the community buffer does not have it already, so future menus will be able to use it.
|
||||
if not hasattr(current_buffer, "group_info"):
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0]
|
||||
current_buffer.group_info = group_info
|
||||
if "topics" not in current_buffer.group_info["counters"]:
|
||||
commonMessages.community_no_items()
|
||||
return
|
||||
new_name = current_buffer.name+"_topics"
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="topicBuffer", buffer_title=_("Topics"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_topic", session=self.session, endpoint="getTopics", parent_endpoint="board", count=100, group_id=-1*current_buffer.kwargs["owner_id"], extended=1))
|
||||
|
||||
def load_community_documents(self, *args, **kwargs):
|
||||
current_buffer = self.get_current_buffer()
|
||||
# Get group_info if the community buffer does not have it already, so future menus will be able to use it.
|
||||
if not hasattr(current_buffer, "group_info"):
|
||||
group_info = self.session.vk.client.groups.getById(group_ids=-1*current_buffer.kwargs["owner_id"], fields="counters")[0]
|
||||
current_buffer.group_info = group_info
|
||||
if "docs" not in current_buffer.group_info["counters"]:
|
||||
commonMessages.community_no_items()
|
||||
return
|
||||
new_name = current_buffer.name+"_documents"
|
||||
wx.CallAfter(pub.sendMessage, "create_buffer", buffer_type="documentCommunityBuffer", buffer_title=_("Documents"), parent_tab=current_buffer.tab.name, get_items=True, kwargs=dict(parent=self.window.tb, name=new_name, composefunc="render_document", session=self.session, endpoint="get", parent_endpoint="docs", owner_id=current_buffer.kwargs["owner_id"]))
|
||||
|
||||
def load_community_buffers(self, *args, **kwargs):
|
||||
""" Load all community buffers regardless of the setting present in optional buffers tab of the preferences dialog."""
|
||||
call_threaded(self.get_communities, self.session.user_id, force_action=True)
|
||||
|
||||
def unload_community_buffers(self, *args, **kwargs):
|
||||
""" Delete all buffers belonging to groups."""
|
||||
communities = self.get_all_buffers("_community")
|
||||
for buffer in communities:
|
||||
buff = self.window.search(buffer.name)
|
||||
self.window.remove_buffer(buff)
|
||||
self.buffers.remove(buffer)
|
||||
del self.session.groups
|
||||
|
257
src/presenters/player.py
Normal file
257
src/presenters/player.py
Normal file
@@ -0,0 +1,257 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" Audio player module for socializer.
|
||||
As this player does not have (still) an associated GUI, I have decided to place here the code for the interactor, which connects a bunch of pubsub events, and the presenter itself.
|
||||
"""
|
||||
import sys
|
||||
import time
|
||||
import random
|
||||
import logging
|
||||
import sound_lib
|
||||
import output
|
||||
import config
|
||||
from sound_lib.config import BassConfig
|
||||
from sound_lib.stream import URLStream
|
||||
from sound_lib.main import BassError
|
||||
from pubsub import pub
|
||||
from mysc.repeating_timer import RepeatingTimer
|
||||
from mysc.thread_utils import call_threaded
|
||||
from sessionmanager import utils
|
||||
|
||||
player = None
|
||||
log = logging.getLogger("player")
|
||||
|
||||
def setup():
|
||||
global player
|
||||
if player == None:
|
||||
player = audioPlayer()
|
||||
|
||||
class audioPlayer(object):
|
||||
""" A media player which will play all passed URLS."""
|
||||
|
||||
def __init__(self):
|
||||
# control variable for checking if another file has been sent to the player before,
|
||||
# thus avoiding double file playback and other oddities happening in sound_lib from time to time.
|
||||
self.is_playing = False
|
||||
# This will be the URLStream handler
|
||||
self.stream = None
|
||||
self.message = None
|
||||
self.vol = config.app["sound"]["volume"]
|
||||
# this variable is set to true when the URLPlayer is decoding something, thus it will block other calls to the play method.
|
||||
self.is_working = False
|
||||
# Playback queue.
|
||||
self.queue = []
|
||||
# Index of the currently playing track.
|
||||
self.playing_track = 0
|
||||
self.playing_all = False
|
||||
self.worker = RepeatingTimer(5, self.player_function)
|
||||
self.worker.start()
|
||||
# Status of the player.
|
||||
self.stopped = True
|
||||
# Modify some default settings present in Bass so it will increase timeout connection, thus causing less "connection timed out" errors when playing.
|
||||
bassconfig = BassConfig()
|
||||
# Set timeout connection to 30 seconds.
|
||||
bassconfig["net_timeout"] = 30000
|
||||
# subscribe all pubsub events.
|
||||
pub.subscribe(self.play, "play")
|
||||
pub.subscribe(self.play_message, "play-message")
|
||||
pub.subscribe(self.play_all, "play-all")
|
||||
pub.subscribe(self.pause, "pause")
|
||||
pub.subscribe(self.stop, "stop")
|
||||
pub.subscribe(self.play_next, "play-next")
|
||||
pub.subscribe(self.play_previous, "play-previous")
|
||||
pub.subscribe(self.seek, "seek")
|
||||
|
||||
# Stopped has a special function here, hence the decorator
|
||||
# when stopped will be set to True, it will send a pubsub event to inform other parts of the application about the status change.
|
||||
# this is useful for changing labels between play and pause, and so on, in buttons.
|
||||
@property
|
||||
def stopped(self):
|
||||
return self._stopped
|
||||
|
||||
@stopped.setter
|
||||
def stopped(self, value):
|
||||
self._stopped = value
|
||||
pub.sendMessage("playback-changed", stopped=value)
|
||||
|
||||
def play(self, object, set_info=True, fresh=False):
|
||||
""" Play an URl Stream.
|
||||
@object dict: typically an audio object as returned by VK, with a "url" component which must be a valid URL to a media file.
|
||||
@set_info bool: If true, will set information about the currently playing audio in the application status bar.
|
||||
@fresh bool: If True, will remove everything playing in the queue and start this file only. otherwise it will play the new file but not remove the current queue."""
|
||||
if "url" in object and object["url"] =="":
|
||||
pub.sendMessage("notify", message=_("This file could not be played because it is not allowed in your country"))
|
||||
return
|
||||
if self.stream != None and (self.stream.is_playing == True or self.stream.is_stalled == True):
|
||||
try:
|
||||
self.stream.stop()
|
||||
except BassError:
|
||||
log.exception("error when stopping the file")
|
||||
self.stream = None
|
||||
self.stopped = True
|
||||
if fresh == True:
|
||||
self.queue = []
|
||||
# Make sure that there are no other sounds trying to be played.
|
||||
if self.is_working == False:
|
||||
self.is_working = True
|
||||
# Let's encode the URL as bytes if on Python 3
|
||||
url_ = utils.transform_audio_url(object["url"])
|
||||
url_ = bytes(url_, "utf-8")
|
||||
try:
|
||||
self.stream = URLStream(url=url_)
|
||||
except:
|
||||
log.error("Unable to play URL %s" % (url_))
|
||||
return
|
||||
# Translators: {0} will be replaced with a song's title and {1} with the artist.
|
||||
if set_info:
|
||||
msg = _("Playing {0} by {1}").format(object["title"], object["artist"])
|
||||
pub.sendMessage("update-status-bar", status=msg)
|
||||
self.stream.volume = self.vol/100.0
|
||||
self.stream.play()
|
||||
self.stopped = False
|
||||
self.is_working = False
|
||||
|
||||
def play_message(self, message_url):
|
||||
if self.message != None and (self.message.is_playing == True or self.message.is_stalled == True):
|
||||
return self.stop_message()
|
||||
output.speak(_("Playing..."))
|
||||
url_ = utils.transform_audio_url(message_url)
|
||||
url_ = bytes(url_, "utf-8")
|
||||
try:
|
||||
self.message = URLStream(url=url_)
|
||||
except:
|
||||
log.error("Unable to play URL %s" % (url_))
|
||||
return
|
||||
self.message.volume = self.vol/100.0
|
||||
self.message.play()
|
||||
volume_percent = self.volume*0.25
|
||||
volume_step = self.volume*0.15
|
||||
while self.stream.volume*100 > volume_percent:
|
||||
self.stream.volume = self.stream.volume-(volume_step/100)
|
||||
time.sleep(0.1)
|
||||
|
||||
def stop(self):
|
||||
""" Stop audio playback. """
|
||||
if self.stream != None and self.stream.is_playing == True:
|
||||
self.stream.stop()
|
||||
self.stopped = True
|
||||
self.queue = []
|
||||
|
||||
def stop_message(self):
|
||||
if hasattr(self, "message") and self.message != None and self.message.is_playing == True:
|
||||
self.message.stop()
|
||||
volume_step = self.volume*0.15
|
||||
while self.stream.volume*100 < self.volume:
|
||||
self.stream.volume = self.stream.volume+(volume_step/100)
|
||||
time.sleep(0.1)
|
||||
self.message = None
|
||||
|
||||
def pause(self):
|
||||
""" pause the current playback, without destroying the queue or the current stream. If the stream is already paused this function will resume the playback. """
|
||||
if self.stream != None:
|
||||
if self.stream.is_playing == True:
|
||||
self.stream.pause()
|
||||
self.stopped = True
|
||||
else:
|
||||
try:
|
||||
self.stream.play()
|
||||
self.stopped = False
|
||||
except BassError:
|
||||
pass
|
||||
if self.playing_all == False and len(self.queue) > 0:
|
||||
self.playing_all = True
|
||||
|
||||
@property
|
||||
def volume(self):
|
||||
return self.vol
|
||||
|
||||
@volume.setter
|
||||
def volume(self, vol):
|
||||
if vol <= 100 and vol >= 0:
|
||||
self.vol = vol
|
||||
elif vol < 0:
|
||||
self.vol = 0
|
||||
elif vol > 100:
|
||||
self.vol = 100
|
||||
if self.stream != None:
|
||||
if self.message != None and self.message.is_playing:
|
||||
self.stream.volume = (self.vol*0.25)/100.0
|
||||
self.message.volume = self.vol/100.0
|
||||
else:
|
||||
self.stream.volume = self.vol/100.0
|
||||
|
||||
def play_all(self, list_of_songs, shuffle=False):
|
||||
""" Play all passed songs and adds all of those to the queue.
|
||||
@list_of_songs list: A list of audio objects returned by VK.
|
||||
@shuffle bool: If True, the files will be played randomly."""
|
||||
if self.is_working:
|
||||
return
|
||||
self.playing_track = 0
|
||||
self.stop()
|
||||
# Skip all country restricted tracks as they are not playable here.
|
||||
self.queue = [i for i in list_of_songs if i["url"] != ""]
|
||||
if shuffle:
|
||||
random.shuffle(self.queue)
|
||||
call_threaded(self.play, self.queue[self.playing_track])
|
||||
self.playing_all = True
|
||||
|
||||
def player_function(self):
|
||||
""" Check if the stream has reached the end of the file so it will play the next song. """
|
||||
if self.message != None and self.message.is_playing == False and len(self.message) == self.message.position:
|
||||
volume_step = self.volume*0.15
|
||||
while self.stream.volume*100 < self.volume:
|
||||
self.stream.volume = self.stream.volume+(volume_step/100)
|
||||
time.sleep(0.1)
|
||||
if self.stream != None and self.stream.is_playing == False and self.stopped == False and len(self.stream) == self.stream.position:
|
||||
if self.playing_track >= len(self.queue):
|
||||
self.stopped = True
|
||||
self.playing_all = False
|
||||
return
|
||||
elif self.playing_all == False:
|
||||
self.stopped = True
|
||||
return
|
||||
elif self.playing_track < len(self.queue):
|
||||
self.playing_track += 1
|
||||
self.play(self.queue[self.playing_track])
|
||||
|
||||
def play_next(self):
|
||||
""" Play the next song in the queue. """
|
||||
if len(self.queue) == 0:
|
||||
return
|
||||
if self.is_working:
|
||||
return
|
||||
if self.playing_track < len(self.queue)-1:
|
||||
self.playing_track += 1
|
||||
else:
|
||||
self.playing_track = 0
|
||||
call_threaded(self.play, self.queue[self.playing_track])
|
||||
|
||||
def play_previous(self):
|
||||
""" Play the previous song in the queue. """
|
||||
if len(self.queue) == 0:
|
||||
return
|
||||
if self.is_working:
|
||||
return
|
||||
if self.playing_track <= 0:
|
||||
self.playing_track = len(self.queue)-1
|
||||
else:
|
||||
self.playing_track -= 1
|
||||
call_threaded(self.play, self.queue[self.playing_track])
|
||||
|
||||
def seek(self, ms=0):
|
||||
if self.check_is_playing():
|
||||
if self.stream.position < 500000 and ms < 0:
|
||||
self.stream.position = 0
|
||||
else:
|
||||
try:
|
||||
self.stream.position = self.stream.position+ms
|
||||
except:
|
||||
pass
|
||||
|
||||
def check_is_playing(self):
|
||||
""" check if the player is already playing a stream. """
|
||||
if self.stream == None:
|
||||
return False
|
||||
if self.stream != None and self.stream.is_playing == False and self.stream.is_stalled == False:
|
||||
return False
|
||||
else:
|
||||
return True
|
155
src/presenters/profiles.py
Normal file
155
src/presenters/profiles.py
Normal file
@@ -0,0 +1,155 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" A profile viewer and editor for VK user objects."""
|
||||
from __future__ import unicode_literals
|
||||
import webbrowser
|
||||
import logging
|
||||
import arrow
|
||||
import requests
|
||||
import languageHandler
|
||||
import output
|
||||
from mysc.thread_utils import call_threaded
|
||||
from sessionmanager import utils
|
||||
from . import base
|
||||
|
||||
log = logging.getLogger("controller.profiles")
|
||||
|
||||
class userProfilePresenter(base.basePresenter):
|
||||
|
||||
def __init__(self, session, user_id, view, interactor):
|
||||
""" 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.
|
||||
"""
|
||||
super(userProfilePresenter, self).__init__(view=view, interactor=interactor, modulename="user_profile")
|
||||
# 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
|
||||
# Get information in a threaded way here.
|
||||
# Note: We do not handle any race condition here because due to the presenter only sending pubsub messages,
|
||||
# Nothing happens if the pubsub send messages to the interactor after the latter has been destroyed.
|
||||
# Pubsub messages are just skipped if there are no listeners for them.
|
||||
call_threaded(self.get_basic_information)
|
||||
self.run()
|
||||
|
||||
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(_("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 = "{0} {1}".format(person["first_name"], person["last_name"])
|
||||
# Format birthdate.
|
||||
if "bdate" in person and person["bdate"] != "":
|
||||
self.send_message("enable_control", tab="main_info", control="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.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D"), locale=languageHandler.curLang[:2]))
|
||||
else: # mm.dd.yyyy
|
||||
d = arrow.get(person["bdate"], "D.M.YYYY")
|
||||
self.send_message("set", tab="main_info", control="bdate", value=d.format(_("MMMM D, YYYY"), locale=languageHandler.curLang[:2]))
|
||||
# Format current city and home town
|
||||
city = ""
|
||||
if "home_town" in person and person["home_town"] != "":
|
||||
home_town = person["home_town"]
|
||||
self.send_message("enable_control", tab="main_info", control="home_town")
|
||||
self.send_message("set", tab="main_info", control="home_town", value=home_town)
|
||||
if "city" in person and len(person["city"]) > 0:
|
||||
city = person["city"]["title"]
|
||||
if "country" in person and person["country"] != "":
|
||||
if city != "":
|
||||
city = city+", {0}".format(person["country"]["title"])
|
||||
else:
|
||||
city = person["country"]["title"]
|
||||
self.send_message("enable_control", tab="main_info", control="city")
|
||||
self.send_message("set", tab="main_info", control="city", value=city)
|
||||
self.send_message("set", tab="main_info", control="name", value=n)
|
||||
# Format title
|
||||
user = self.session.get_user(person["id"])
|
||||
self.send_message("set_title", value=_("{user1_nom}'s profile").format(**user))
|
||||
# Format website (or websites, if there are multiple of them).
|
||||
if "site" in person and person["site"] != "":
|
||||
self.send_message("enable_control", tab="main_info", control="website")
|
||||
self.send_message("set", tab="main_info", control="website", value=person["site"])
|
||||
self.send_message("enable_control", tab="main_info", control="go_site")
|
||||
# Format status message.
|
||||
if "status" in person and person["status"] != "":
|
||||
self.send_message("enable_control", tab="main_info", control="status")
|
||||
self.send_message("set", tab="main_info", control="status", value=person["status"])
|
||||
# Format occupation.
|
||||
# toDo: Research in this field is needed. Sometimes it returns university information even if users have active work places.
|
||||
if "occupation" in person and person["occupation"] != None:
|
||||
if person["occupation"]["type"] == "work": c1 = _("Work ")
|
||||
elif person["occupation"]["type"] == "school": c1 = _("Student ")
|
||||
elif person["occupation"]["type"] == "university": c1 = _("Student ")
|
||||
if "name" in person["occupation"] and person["occupation"]["name"] != "":
|
||||
c2 = _("In {0}").format(person["occupation"]["name"],)
|
||||
else:
|
||||
c2 = ""
|
||||
self.send_message("enable_control", tab="main_info", control="occupation")
|
||||
self.send_message("set", tab="main_info", control="occupation", value=c1+c2)
|
||||
# format relationship status.
|
||||
# ToDo: When dating someone, the button associated to the information should point to the profile of the user.
|
||||
if "relation" in person and person["relation"] != 0:
|
||||
if person["relation"] == 1:
|
||||
r = _("Single")
|
||||
elif person["relation"] == 2:
|
||||
if "relation_partner" in person:
|
||||
r = _("Dating with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
|
||||
else:
|
||||
r = _("Dating")
|
||||
elif person["relation"] == 3:
|
||||
r = _("Engaged with {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
|
||||
elif person["relation"] == 4:
|
||||
if "relation_partner" in person:
|
||||
r = _("Married to {0} {1}").format(person["relation_partner"]["first_name"], person["relation_partner"]["last_name"])
|
||||
else:
|
||||
r = _("Married")
|
||||
elif person["relation"] == 5:
|
||||
r = _("It's complicated")
|
||||
elif person["relation"] == 6:
|
||||
r = _("Actively searching")
|
||||
elif person["relation"] == 7:
|
||||
r = _("In love")
|
||||
self.send_message("enable_control", tab="main_info", control="relation")
|
||||
self.send_message("set_label", tab="main_info", control="relation", value=_("Relationship: ")+r)
|
||||
# format last seen.
|
||||
if "last_seen" in person and person["last_seen"] != False:
|
||||
original_date = arrow.get(person["last_seen"]["time"])
|
||||
# Translators: This is the date of last seen
|
||||
last_seen = _("{0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
|
||||
self.send_message("enable_control", tab="main_info", control="last_seen")
|
||||
self.send_message("set", tab="main_info", control="last_seen", value=last_seen)
|
||||
self.person = person
|
||||
# Adds photo to the dialog.
|
||||
# ToDo: Need to ask if this has a visible effect in the dialog.
|
||||
if "photo_200_orig" in person:
|
||||
img = requests.get(person["photo_200_orig"])
|
||||
self.send_message("load_image", image=requests.get(person["photo_200_orig"]))
|
||||
output.speak(_("Profile loaded"))
|
||||
|
||||
def get_urls(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(_("No URL addresses were detected."))
|
||||
return
|
||||
return urls
|
||||
|
||||
def visit_url(self, url):
|
||||
output.speak(_("Opening URL..."))
|
||||
webbrowser.open_new_tab(url)
|
22
src/run_tests.py
Normal file
22
src/run_tests.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import unittest
|
||||
import languageHandler
|
||||
|
||||
languageHandler.setLanguage("en")
|
||||
|
||||
|
||||
testmodules = ["test.test_setup_py2exe", "test.test_base_interactor", "test.test_audiorecorder", "test.test_renderers"]
|
||||
|
||||
suite = unittest.TestSuite()
|
||||
|
||||
for t in testmodules:
|
||||
try:
|
||||
# If the module defines a suite() function, call it to get the suite.
|
||||
mod = __import__(t, globals(), locals(), ['suite'])
|
||||
suitefn = getattr(mod, 'suite')
|
||||
suite.addTest(suitefn())
|
||||
except (ImportError, AttributeError):
|
||||
# else, just load all the test cases from the module.
|
||||
suite.addTest(unittest.defaultTestLoader.loadTestsFromName(t))
|
||||
|
||||
unittest.TextTestRunner(verbosity=2).run(suite)
|
@@ -2,7 +2,10 @@
|
||||
user = string(default="")
|
||||
password = string(default="")
|
||||
token = string(default="")
|
||||
secret = string(default="")
|
||||
device_id = string(default="")
|
||||
use_alternative_tokens = boolean(default=False)
|
||||
invited_to_group = boolean(default=False)
|
||||
|
||||
[general]
|
||||
reverse_timelines = boolean(default=False)
|
||||
@@ -14,16 +17,12 @@ count_for_wall_buffers = integer(default=100)
|
||||
count_for_video_buffers = integer(default=200)
|
||||
count_for_audio_buffers = integer(default=1000)
|
||||
|
||||
[sound]
|
||||
volume = float(default=1.0)
|
||||
input_device = string(default="Default")
|
||||
output_device = string(default="Default")
|
||||
session_mute = boolean(default=False)
|
||||
current_soundpack = string(default="default")
|
||||
|
||||
[chat]
|
||||
notify_online = boolean(default=True)
|
||||
notify_offline = boolean(default=True)
|
||||
open_unread_conversations = boolean(default=True)
|
||||
automove_to_conversations = boolean(default=True)
|
||||
notifications = string(default="custom")
|
||||
notifications = string(default="custom")
|
||||
|
||||
[load_at_startup]
|
||||
audio_albums = boolean(default=False)
|
||||
video_albums = boolean(default=False)
|
||||
communities = boolean(default=False)
|
@@ -1,16 +0,0 @@
|
||||
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
|
@@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from UserDict import UserDict
|
||||
from collections import UserDict
|
||||
from configobj import ConfigObj, ParseError
|
||||
from validate import Validator, VdtValueError
|
||||
import os
|
||||
|
@@ -1,101 +0,0 @@
|
||||
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)
|
@@ -4,7 +4,8 @@ Chat messages, audios, videos, photos, comments in posts, etc)"""
|
||||
import arrow
|
||||
import languageHandler
|
||||
import logging
|
||||
import utils
|
||||
from update.utils import convert_bytes
|
||||
from . utils import seconds_to_string, clean_text
|
||||
|
||||
log = logging.getLogger(__file__)
|
||||
|
||||
@@ -15,29 +16,29 @@ def extract_attachment(attachment):
|
||||
This will produce a result like:
|
||||
'website: http://url.com'.
|
||||
'photo: A forest'."""
|
||||
msg = u""
|
||||
msg = ""
|
||||
if attachment["type"] == "link":
|
||||
msg = u"{0}: {1}".format(attachment["link"]["title"], attachment["link"]["url"])
|
||||
msg = "{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")
|
||||
return _("photo with no description available")
|
||||
elif attachment["type"] == "video":
|
||||
msg = _(u"video: {0}").format(attachment["video"]["title"],)
|
||||
msg = _("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"):
|
||||
if "copy_history" in status:
|
||||
txt = status["copy_history"][0]["text"]
|
||||
else:
|
||||
txt = status["text"]
|
||||
if len(txt) < 140:
|
||||
message = utils.clean_text(txt)
|
||||
message = clean_text(txt)
|
||||
else:
|
||||
message = utils.clean_text(txt[:139])
|
||||
message = clean_text(txt[:139])
|
||||
return message
|
||||
|
||||
def clean_audio(audio):
|
||||
@@ -48,20 +49,64 @@ def clean_audio(audio):
|
||||
audio["count"] = audio["count"] -1
|
||||
return audio
|
||||
|
||||
def add_attachment(attachment):
|
||||
msg = ""
|
||||
tpe = ""
|
||||
if attachment["type"] == "link":
|
||||
msg = "{0}: {1}".format(attachment["link"]["title"], attachment["link"]["url"])
|
||||
tpe = _("Link")
|
||||
elif attachment["type"] == "photo":
|
||||
tpe = _("Photo")
|
||||
msg = attachment["photo"]["text"]
|
||||
if msg == "":
|
||||
msg = _("no description available")
|
||||
elif attachment["type"] == "video":
|
||||
msg = "{0}".format(attachment["video"]["title"],)
|
||||
tpe = _("Video")
|
||||
elif attachment["type"] == "audio":
|
||||
msg = "{0}".format(" ".join(render_audio(attachment["audio"])))
|
||||
tpe = _("Audio")
|
||||
elif attachment["type"] == "doc":
|
||||
msg = "{0}".format(attachment["doc"]["title"])
|
||||
tpe = _("{0} file").format(attachment["doc"]["ext"])
|
||||
elif attachment["type"] == "audio_message":
|
||||
msg = "{0}".format(" ".join(render_audio_message(attachment["audio_message"])))
|
||||
tpe = _("Voice message")
|
||||
elif attachment["type"] == "poll":
|
||||
tpe = _("Poll")
|
||||
msg = attachment["poll"]["question"]
|
||||
elif attachment["type"] == "wall":
|
||||
tpe = _("Post")
|
||||
user = attachment["wall"]["from"]["name"]
|
||||
if len(attachment["wall"]["text"]) > 140:
|
||||
text = attachment["wall"]["text"][:145]+"..."
|
||||
else:
|
||||
text = attachment["wall"]["text"]
|
||||
msg = _("{user}: {post}").format(user=user, post=text)
|
||||
else:
|
||||
print(attachment)
|
||||
return [tpe, msg]
|
||||
|
||||
### 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"):
|
||||
if "last_seen" in status:
|
||||
original_date = arrow.get(status["last_seen"]["time"])
|
||||
now = arrow.now()
|
||||
original_date.to(now.tzinfo)
|
||||
diffdate = now-original_date
|
||||
if diffdate.days == 0 and diffdate.seconds <= 360:
|
||||
online_status = _("Online")
|
||||
else:
|
||||
# Translators: This is the date of last seen
|
||||
last_seen = _(u"{0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
|
||||
online_status = _("Last seen {0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
|
||||
# Account suspended or deleted.
|
||||
elif 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]
|
||||
elif ("last_seen" in status) == False and "deactivated" in status:
|
||||
online_status = _("Account deactivated")
|
||||
return ["{0} {1}".format(status["first_name"], status["last_name"]), online_status]
|
||||
|
||||
def render_newsfeed_item(status, session):
|
||||
""" This me☻thod is used to render an item of the news feed.
|
||||
@@ -70,17 +115,21 @@ def render_newsfeed_item(status, session):
|
||||
https://vk.com/dev/post_source
|
||||
https://vk.com/dev/post
|
||||
"""
|
||||
user = session.get_user_name(status["source_id"], case_name="nom")
|
||||
user = session.get_user(status["source_id"], key="user1")
|
||||
# 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"]))
|
||||
if "copy_history" in status:
|
||||
# Get the second user (whose post is been shared).
|
||||
user2 = session.get_user(status["copy_history"][0]["owner_id"], key="user2")
|
||||
# Add contents of poster to the new dict, it will create both user1_nom and user2_nom.
|
||||
user2.update(user)
|
||||
user = dict(user1_nom=_("{user1_nom} has shared the {user2_nom}'s post").format(**user2))
|
||||
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:
|
||||
if "attachment" in status 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.
|
||||
@@ -91,90 +140,109 @@ def render_newsfeed_item(status, session):
|
||||
# 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)),)
|
||||
data = dict(audio_file=", ".join(render_audio(status["audio"]["items"][0], session)))
|
||||
data.update(user)
|
||||
message = _("{user1_nom} has added an audio: {audio_file}").format(**data)
|
||||
else:
|
||||
prem = ""
|
||||
for i in xrange(0, status["audio"]["count"]):
|
||||
for i in range(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)
|
||||
prem += "{0} - {1}, ".format(composed_audio[0], composed_audio[1])
|
||||
data = dict(audio_files=prem, total_audio_files=status["audio"]["count"])
|
||||
data.update(user)
|
||||
message = _("{user1_nom} has added {total_audio_files} audios: {audio_files}").format(**data)
|
||||
# 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"])
|
||||
data = dict(audio_album=status["audio_playlist"]["items"][0]["title"], audio_album_description=status["audio_playlist"]["items"][0]["description"])
|
||||
data.update(user)
|
||||
message = _("{user1_nom} has added an audio album: {audio_album}, {audio_album_description}").format(**data)
|
||||
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)
|
||||
|
||||
for i in range(0, status["audio_playlist"]["count"]):
|
||||
prestring += "{0} - {1}, ".format(status["audio_playlist"]["items"][i]["title"], status["audio_playlist"]["items"][i]["description"])
|
||||
data = dict(audio_albums=prestring, total_audio_albums=status["audio_playlist"]["count"])
|
||||
data.update(user)
|
||||
message = _("{user1_nom} has added {total_audio_albums} audio albums: {audio_albums}").format(**data)
|
||||
# handle new friends for people in the news buffer.
|
||||
elif status["type"] == "friend":
|
||||
msg_users = u""
|
||||
if status.has_key("friends"):
|
||||
msg_users = ""
|
||||
if "friends" in status:
|
||||
for i in status["friends"]["items"]:
|
||||
msg_users = msg_users + u"{0}, ".format(session.get_user_name(i["user_id"], "nom"))
|
||||
msg_users = msg_users + "{0}, ".format(session.get_user(i["user_id"])["user1_nom"])
|
||||
else:
|
||||
print status.keys()
|
||||
message = _(u"{0} added friends: {1}").format(user, msg_users)
|
||||
print(list(status.keys()))
|
||||
data = dict(friends=msg_users)
|
||||
data.update(user)
|
||||
message = _("{user1_nom} added friends: {friends}").format(**data)
|
||||
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)),)
|
||||
data = dict(video=", ".join(render_video(status["video"]["items"][0], session)))
|
||||
data.update(user)
|
||||
message = _("{user1_nom} has added a video: {video}").format(**data)
|
||||
else:
|
||||
prem = ""
|
||||
for i in xrange(0, status["video"]["count"]):
|
||||
for i in range(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)
|
||||
prem += "{0} - {1}, ".format(composed_video[0], composed_video[1])
|
||||
data = dict(videos=prem, total_videos=status["video"]["count"])
|
||||
data.update(user)
|
||||
message = _("{user1_nom} has added {total_videos} videos: {videos}").format(**data)
|
||||
else:
|
||||
if status["type"] != "post": print status
|
||||
return [user, message, created_at]
|
||||
if status["type"] != "post": print(status)
|
||||
return [user["user1_nom"], 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")
|
||||
user = session.get_user(message["from_id"], key="user1")
|
||||
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])
|
||||
created_at = original_date.format(_("H:mm."), locale=languageHandler.curLang[:2])
|
||||
else:
|
||||
created_at = original_date.format(_(u"H:mm. dddd, MMMM D, YYYY"), locale=languageHandler.curLang[:2])
|
||||
created_at = original_date.format(_("H:mm. dddd, MMMM D, YYYY"), locale=languageHandler.curLang[:2])
|
||||
# No idea why some messages send "text" instead "body"
|
||||
if message.has_key("body"):
|
||||
if "body" in message:
|
||||
body = message["body"]
|
||||
else:
|
||||
body = message["text"]
|
||||
return [u"{2}, {0} {1}".format(body, created_at, user)]
|
||||
data = dict(body=body, created_at=created_at)
|
||||
data.update(user)
|
||||
return ["{user1_nom}, {body} {created_at}".format(**data)]
|
||||
|
||||
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"]))
|
||||
user = session.get_user(status["from_id"], key="user1")
|
||||
if "copy_history" in status:
|
||||
user2 = session.get_user(status["copy_history"][0]["owner_id"], key="user2")
|
||||
user2.update(user)
|
||||
user = dict(user1_nom=_("{user1_nom} has shared the {user2_nom}'s post").format(**user2))
|
||||
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 "copy_owner_id" in status:
|
||||
user2 = session.get_user(status["copy_owner_id"], key="user2")
|
||||
user2.update(user)
|
||||
user = _("{user1_nom} has shared the {user2_nom}'s post").format(**user2)
|
||||
if status["post_type"] == "post" or status["post_type"] == "copy":
|
||||
message += short_text(status)
|
||||
if status.has_key("attachment") and len(status["attachment"]) > 0:
|
||||
if "attachment" in status and len(status["attachment"]) > 0:
|
||||
message += extract_attachment(status["attachment"])
|
||||
if message == "":
|
||||
message = "no description available"
|
||||
return [user, message, created_at]
|
||||
return [user["user1_nom"], 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"])]
|
||||
if audio == False: return [_("Audio removed from library"), "", ""]
|
||||
return [audio["title"], audio["artist"], seconds_to_string(audio["duration"])]
|
||||
|
||||
def render_video(video, session=None):
|
||||
""" Render a video file from VK.
|
||||
@@ -182,13 +250,34 @@ def render_video(video, session=None):
|
||||
["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"])]
|
||||
return [_("Video not available"), "", ""]
|
||||
return [video["title"], video["description"], 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"])]
|
||||
return [_("Voice message not available"), "", ""]
|
||||
return [seconds_to_string(audio_message["duration"])]
|
||||
|
||||
def render_topic(topic, session):
|
||||
""" Render topics for a community.
|
||||
Reference: https://vk.com/dev/objects/topic"""
|
||||
user = session.get_user(topic["created_by"])
|
||||
title = topic["title"]
|
||||
comments = topic["comments"]
|
||||
last_commenter = session.get_user(topic["updated_by"])
|
||||
last_update = arrow.get(topic["updated"]).humanize(locale=languageHandler.curLang[:2])
|
||||
last_commenter.update(date=last_update)
|
||||
lastupdate = _("Last post by {user1_nom} {date}").format(**last_commenter)
|
||||
return [user["user1_nom"], title, str(comments), lastupdate]
|
||||
|
||||
def render_document(document, session):
|
||||
doc_types = {1: _("Text document"), 2: _("Archive"), 3: _("Gif"), 4: _("Image"), 5: _("Audio"), 6: _("Video"), 7: _("Ebook"), 8: _("Unknown document")}
|
||||
user = session.get_user(document["owner_id"])
|
||||
title = document["title"]
|
||||
size = convert_bytes(document["size"])
|
||||
date = arrow.get(document["date"]).humanize(locale=languageHandler.curLang[:2])
|
||||
doc_type = doc_types[document["type"]]
|
||||
return [user["user1_nom"], title, doc_type, size, date]
|
@@ -1,12 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" 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. """
|
||||
from __future__ import unicode_literals
|
||||
import os
|
||||
import logging
|
||||
import warnings
|
||||
import languageHandler
|
||||
import paths
|
||||
import vkSessionHandler
|
||||
import config
|
||||
import sound
|
||||
from config_utils import Configuration, ConfigurationResetException
|
||||
from requests.exceptions import ProxyError, ConnectionError
|
||||
from .config_utils import Configuration, ConfigurationResetException
|
||||
from . import vkSessionHandler
|
||||
from pubsub import pub
|
||||
from vk_api.exceptions import LoginRequired, VkApiError
|
||||
|
||||
@@ -31,14 +35,15 @@ def find_item(list, item):
|
||||
global identifiers
|
||||
identifier = None
|
||||
for i in identifiers:
|
||||
if item.has_key(i):
|
||||
if i in item:
|
||||
identifier = i
|
||||
break
|
||||
if identifier == None:
|
||||
# if there are objects that can't be processed by lack of identifier, let's print keys for finding one.
|
||||
log.exception("Can't find an identifier for the following object: %r" % (item.keys(),))
|
||||
return False
|
||||
for i in list:
|
||||
if i.has_key(identifier) and i[identifier] == item[identifier]:
|
||||
if identifier in i and i[identifier] == item[identifier]:
|
||||
return True
|
||||
return False
|
||||
|
||||
@@ -49,23 +54,31 @@ class vkSession(object):
|
||||
""" Put new items on the local cache database.
|
||||
@name str: The name for the buffer stored in the dictionary.
|
||||
@data list: A list with items and some information about cursors.
|
||||
returns the number of items that has been added in this execution"""
|
||||
returns the number of items that have been added in this execution"""
|
||||
global post_types
|
||||
# When this method is called by friends.getOnlyne, it gives only friend IDS so we need to retrieve full objects from VK.
|
||||
# ToDo: It would be nice to investigate whether reusing some existing objects would be a good idea, whenever possible.
|
||||
if name == "online_friends":
|
||||
newdata = self.vk.client.users.get(user_ids=",".join([str(z) for z in data]), fields="last_seen")
|
||||
data = newdata
|
||||
first_addition = False
|
||||
num = 0
|
||||
if self.db.has_key(name) == False:
|
||||
if (name in self.db) == False:
|
||||
self.db[name] = {}
|
||||
self.db[name]["items"] = []
|
||||
first_addition = True
|
||||
# Handles chat messages case, as the buffer is inverted
|
||||
if name.endswith("_messages") and show_nextpage == True:
|
||||
show_nextpage = False
|
||||
for i in data:
|
||||
if i.has_key("type") and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
|
||||
if "type" in i and not isinstance(i["type"], int) and (i["type"] == "wall_photo" or i["type"] == "photo_tag" or i["type"] == "photo"):
|
||||
log.debug("Skipping unsupported item... %r" % (i,))
|
||||
continue
|
||||
# for some reason, VK sends post data if the post has been deleted already.
|
||||
# Example of this behaviour is when you upload an audio and inmediately delete the audio, VK still sends the post stating that you uploaded an audio file,
|
||||
# But without the audio data, making socializer to render an empty post.
|
||||
# Here we check if the post contains data of the type it advertises.
|
||||
if i.get("type") != None and post_types.get(i["type"]) not in i:
|
||||
if i.get("type") != None and isinstance(i["type"], str) and post_types.get(i["type"]) not in i:
|
||||
log.error("Detected invalid or unsupported post. Skipping...")
|
||||
log.error(i)
|
||||
continue
|
||||
@@ -89,6 +102,7 @@ class vkSession(object):
|
||||
self.db = {}
|
||||
self.db["users"] = {}
|
||||
self.db["groups"] = {}
|
||||
self.db["group_info"] = {}
|
||||
|
||||
@property
|
||||
def is_logged(self):
|
||||
@@ -102,23 +116,46 @@ class vkSession(object):
|
||||
# try:
|
||||
log.debug("Creating config file %s" % (file_,))
|
||||
self.settings = Configuration(os.path.join(paths.config_path(), file_), os.path.join(paths.app_path(), "session.defaults"))
|
||||
self.soundplayer = sound.soundSystem(self.settings["sound"])
|
||||
self.soundplayer = sound.soundSystem(config.app["sound"])
|
||||
pub.subscribe(self.play_sound, "play-sound")
|
||||
# except:
|
||||
# log.exception("The session configuration has failed.")
|
||||
|
||||
def play_sound(self, sound):
|
||||
self.soundplayer.play(sound)
|
||||
|
||||
def login(self):
|
||||
""" Logging in VK.com. This is basically the first method interacting with VK. """
|
||||
# If user is already logged in, we should skip this method.
|
||||
if self.logged == True:
|
||||
return
|
||||
try:
|
||||
config_filename = os.path.join(paths.config_path(), self.session_id, "vkconfig.json")
|
||||
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"], token=self.settings["vk"]["token"], alt_token=self.settings["vk"]["use_alternative_tokens"], filename=config_filename)
|
||||
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"], token=self.settings["vk"]["token"], secret=self.settings["vk"]["secret"], device_id=self.settings["vk"]["device_id"], alt_token=self.settings["vk"]["use_alternative_tokens"], filename=config_filename)
|
||||
self.settings["vk"]["token"] = self.vk.session_object.token["access_token"]
|
||||
try:
|
||||
self.settings["vk"]["secret"] = self.vk.session_object.secret
|
||||
self.settings["vk"]["device_id"] = self.vk.session_object.device_id
|
||||
except AttributeError:
|
||||
pass
|
||||
self.settings.write()
|
||||
self.logged = True
|
||||
self.get_my_data()
|
||||
except ValueError:
|
||||
self.settings["vk"]["user"] = ""
|
||||
self.settings["vk"]["password"] = ""
|
||||
self.settings.write()
|
||||
pub.sendMessage("authorisation-failed")
|
||||
except VkApiError as error:
|
||||
if error.code == 5: # this means invalid access token.
|
||||
self.settings["vk"]["user"] = ""
|
||||
self.settings["vk"]["password"] = ""
|
||||
self.settings["vk"]["token"] = ""
|
||||
self.settings["vk"]["secret"] = ""
|
||||
self.settings["vk"]["device_id"] = ""
|
||||
self.settings.write()
|
||||
pub.sendMessage("authorisation-failed")
|
||||
else: # print out error so we we will handle it in future versions.
|
||||
log.exception("Fatal error when authenticating the application.")
|
||||
log.exception(error.code)
|
||||
log.exception(error.message)
|
||||
except (ProxyError, ConnectionError):
|
||||
pub.sendMessage("connection_error")
|
||||
|
||||
def post_wall_status(self, message, *args, **kwargs):
|
||||
""" Sends a post to an user, group or community wall."""
|
||||
@@ -127,20 +164,18 @@ class vkSession(object):
|
||||
|
||||
def get_newsfeed(self, name="newsfeed", show_nextpage=False, endpoint="", *args, **kwargs):
|
||||
log.debug("Updating news feed...")
|
||||
if show_nextpage == True and self.db[name].has_key("cursor"):
|
||||
if show_nextpage == True and "cursor" in self.db[name]:
|
||||
log.debug("user has requested previous items")
|
||||
kwargs["start_from"] = self.db[name]["cursor"]
|
||||
log.debug("Params for sending to vk: %r" % (kwargs,))
|
||||
data = getattr(self.vk.client.newsfeed, "get")(*args, **kwargs)
|
||||
if data != None:
|
||||
if show_nextpage == False:
|
||||
self.process_usernames(data)
|
||||
# else:
|
||||
# print data.keys(), len(data["items"]), data["next_from"]
|
||||
self.process_usernames(data)
|
||||
num = self.order_buffer(name, data["items"], show_nextpage)
|
||||
log.debug("Keys of the returned data for debug purposes: %r" % (data.keys(),))
|
||||
if data.has_key("next_from"):
|
||||
log.debug("Keys of the returned data for debug purposes: %r" % (list(data.keys()),))
|
||||
if "next_from" in data:
|
||||
self.db[name]["cursor"] = data["next_from"]
|
||||
log.debug("Next cursor saved for data: {cursor}".format(cursor=data["next_from"]))
|
||||
return num
|
||||
|
||||
def get_page(self, name="", show_nextpage=False, endpoint="", *args, **kwargs):
|
||||
@@ -150,7 +185,7 @@ class vkSession(object):
|
||||
c = self.vk.client_audio
|
||||
else:
|
||||
c = self.vk.client
|
||||
if kwargs.has_key("parent_endpoint"):
|
||||
if "parent_endpoint" in kwargs:
|
||||
p = kwargs["parent_endpoint"]
|
||||
if "audio" in p and self.settings["vk"]["use_alternative_tokens"]:
|
||||
log.info("Using alternative audio methods.")
|
||||
@@ -160,20 +195,32 @@ class vkSession(object):
|
||||
p = getattr(c, p)
|
||||
except AttributeError:
|
||||
p = c
|
||||
if name in self.db and "offset" in self.db[name] and show_nextpage == True:
|
||||
kwargs.update(offset=self.db[name]["offset"])
|
||||
else:
|
||||
kwargs.update(offset=0)
|
||||
log.debug("Calling endpoint %s with params %r" % (p, kwargs,))
|
||||
data = getattr(p, endpoint)(*args, **kwargs)
|
||||
if data != None:
|
||||
if "count" not in kwargs:
|
||||
kwargs["count"] = 100
|
||||
# Let's handle a little exception when dealing with conversation buffers.
|
||||
# the first results of the query should be reversed before being sent to order_buffer.
|
||||
if type(data) == dict and "items" in data and endpoint == "getHistory" and kwargs["offset"] == 0:
|
||||
data["items"].reverse()
|
||||
if type(data) == dict:
|
||||
num = self.order_buffer(name, data["items"], show_nextpage)
|
||||
if len(data["items"]) > 0 and data["items"][0].has_key("first_name"):
|
||||
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
|
||||
if len(data["items"]) > 0 and "first_name" in data["items"][0]:
|
||||
data2 = {"profiles": [], "groups": []}
|
||||
for i in data["items"]:
|
||||
data2["profiles"].append(i)
|
||||
self.process_usernames(data2)
|
||||
if data.has_key("profiles") and data.has_key("groups"):
|
||||
if "profiles" in data and "groups" in data:
|
||||
self.process_usernames(data)
|
||||
else:
|
||||
num = self.order_buffer(name, data, show_nextpage)
|
||||
self.db[name]["offset"] = kwargs["offset"]+kwargs["count"]
|
||||
return num
|
||||
|
||||
def get_messages(self, name="", *args, **kwargs):
|
||||
@@ -183,58 +230,72 @@ class vkSession(object):
|
||||
num = self.order_buffer(name, data["items"], False)
|
||||
return num
|
||||
|
||||
def get_user_name(self, user_id, case_name="gen"):
|
||||
if user_id > 0:
|
||||
if self.db["users"].has_key(user_id):
|
||||
if self.db["users"][user_id].has_key(case_name):
|
||||
return self.db["users"][user_id][case_name]
|
||||
else:
|
||||
return self.db["users"][user_id]["nom"]
|
||||
else:
|
||||
return "no specified user"
|
||||
else:
|
||||
if self.db["groups"].has_key(abs(user_id)):
|
||||
return self.db["groups"][abs(user_id)]["nom"]
|
||||
else:
|
||||
return "no specified community"
|
||||
|
||||
def get_users(self, user_ids=None, group_ids=None):
|
||||
log.debug("Getting user information from the VK servers")
|
||||
if user_ids != None:
|
||||
u = self.vk.client.users.get(user_ids=user_ids, fields="uid, first_name, last_name")
|
||||
for i in u:
|
||||
self.db["users"][i["id"]] = u"{0} {1}".format(i["first_name"], i["last_name"])
|
||||
self.db["users"][i["id"]] = dict(nom="{0} {1}".format(i["first_name"], i["last_name"]))
|
||||
if group_ids != None:
|
||||
g = self.vk.client.groups.getById(group_ids=group_ids, fields="name")
|
||||
for i in g:
|
||||
self.db["groups"][i["id"]] = i["name"]
|
||||
self.db["groups"][i["id"]] = dict(nom=i["name"], gen=i["name"], dat=i["name"], acc=i["name"], ins=i["name"], abl=i["name"])
|
||||
|
||||
def get_user(self, user_id, key="user1"):
|
||||
if user_id > 0:
|
||||
if user_id in self.db["users"]:
|
||||
user_data = {}
|
||||
user_fields = "nom, gen, ins, dat, abl, acc".split(", ")
|
||||
for i in user_fields:
|
||||
k = "{key}_{case}".format(key=key, case=i)
|
||||
v = "{first_name} {last_name}".format(first_name=self.db["users"][user_id]["first_name_"+i], last_name=self.db["users"][user_id]["last_name_"+i])
|
||||
user_data[k] = v
|
||||
return user_data
|
||||
# if User_id is not present in db.
|
||||
else:
|
||||
user = dict(id=user_id)
|
||||
self.process_usernames(data=dict(profiles=[user], groups=[]))
|
||||
return self.get_user(user_id)
|
||||
else:
|
||||
if abs(user_id) in self.db["groups"]:
|
||||
user_data = {}
|
||||
user_fields = "nom, gen, ins, dat, abl, acc".split(", ")
|
||||
for i in user_fields:
|
||||
k = "{key}_{case}".format(key=key, case=i)
|
||||
v = self.db["groups"][abs(user_id)][i]
|
||||
user_data[k] = v
|
||||
else:
|
||||
group = self.vk.client.groups.getById(group_ids=-1*user_id)[0]
|
||||
self.process_usernames(data=dict(profiles=[], groups=[group]))
|
||||
return self.get_user(user_id=user_id, key=key)
|
||||
return user_data
|
||||
|
||||
def process_usernames(self, data):
|
||||
""" processes user IDS and saves them in a local storage system.
|
||||
Every function wich needs to convert from an ID to user or community name will have to call the get_user_name function in this session object.
|
||||
Every function that needs to save a set ot user ids for a future use needs to pass a data dictionary with a profiles key being a list of user objects.
|
||||
For russian, it gets the genitive case of every name for future use."""
|
||||
It gets first and last name for people in the 6 russian cases and saves them for future reference."""
|
||||
log.debug("Adding usernames to the local database...")
|
||||
ids = ""
|
||||
for i in data["profiles"]:
|
||||
if self.db["users"].has_key(i["id"]) == False:
|
||||
self.db["users"][i["id"]] = dict(nom=u"{0} {1}".format(i["first_name"], i["last_name"]))
|
||||
if (i["id"] in self.db["users"]) == False:
|
||||
ids = ids + "{0},".format(i["id"],)
|
||||
gids = ""
|
||||
for i in data["groups"]:
|
||||
self.db["groups"][i["id"]] = dict(nom=i["name"])
|
||||
gids = "{0},".format(i["id"],)
|
||||
if not "ru" in languageHandler.getLanguage():
|
||||
return
|
||||
if i["id"] not in self.db["groups"]:
|
||||
self.db["groups"][i["id"]] = dict(nom=i["name"], gen=i["name"], dat=i["name"], acc=i["name"], ins=i["name"], abl=i["name"])
|
||||
gids = "{0},".format(i["id"],)
|
||||
user_fields = "first_name_nom, last_name_nom, first_name_gen, last_name_gen, first_name_ins, last_name_ins, first_name_dat, last_name_dat, first_name_abl, last_name_abl, first_name_acc, last_name_acc, sex"
|
||||
user_fields_list = user_fields.split(", ")
|
||||
if ids != "":
|
||||
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"])
|
||||
users = self.vk.client.users.get(user_ids=ids, fields=user_fields)
|
||||
for i in users:
|
||||
if i["id"] not in self.db["users"]:
|
||||
userdata = {}
|
||||
for field in user_fields_list:
|
||||
if field in i:
|
||||
userdata[field] = i[field]
|
||||
self.db["users"][i["id"]] = userdata
|
||||
|
||||
def get_my_data(self):
|
||||
log.debug("Getting user identifier...")
|
||||
|
@@ -2,12 +2,13 @@
|
||||
import os
|
||||
import sys
|
||||
import widgetUtils
|
||||
import wxUI as view
|
||||
import paths
|
||||
import time
|
||||
import logging
|
||||
import session
|
||||
from config_utils import Configuration
|
||||
from authenticator.official import AuthenticationError
|
||||
from . import wxUI as view
|
||||
from . import session
|
||||
from .config_utils import Configuration
|
||||
|
||||
log = logging.getLogger("sessionmanager.sessionManager")
|
||||
|
||||
@@ -53,4 +54,9 @@ class sessionManagerController(object):
|
||||
if dl.ShowModal() == widgetUtils.OK:
|
||||
c.settings["vk"]["user"] = dl.get_email()
|
||||
c.settings["vk"]["password"] = dl.get_password()
|
||||
c.settings.write()
|
||||
try:
|
||||
c.login()
|
||||
except AuthenticationError:
|
||||
c.settings["vk"]["password"] = ""
|
||||
c.settings["vk"]["user"]
|
||||
return self.get_authorisation(c)
|
@@ -1,15 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" Some utilities. I no have idea how I should put these, so..."""
|
||||
import os
|
||||
import requests
|
||||
import re
|
||||
import html
|
||||
import logging
|
||||
from sessionmanager import renderers
|
||||
import requests
|
||||
|
||||
log = logging.getLogger("utils")
|
||||
url_re = re.compile("(?:\w+://|www\.)[^ ,.?!#%=+][^ ]*")
|
||||
bad_chars = '\'\\.,[](){}:;"'
|
||||
|
||||
def seconds_to_string(seconds, precision=0):
|
||||
""" convert a number of seconds in a string representation."""
|
||||
# ToDo: Improve it to handle properly Russian plurals.
|
||||
day = seconds // 86400
|
||||
hour = seconds // 3600
|
||||
min = (seconds // 60) % 60
|
||||
@@ -18,21 +21,21 @@ def seconds_to_string(seconds, precision=0):
|
||||
sec_string = sec.__format__(sec_spec)
|
||||
string = ""
|
||||
if day == 1:
|
||||
string += _(u"%d day, ") % day
|
||||
string += _("%d day, ") % day
|
||||
elif day >= 2:
|
||||
string += _(u"%d days, ") % day
|
||||
string += _("%d days, ") % day
|
||||
if (hour == 1):
|
||||
string += _(u"%d hour, ") % hour
|
||||
string += _("%d hour, ") % hour
|
||||
elif (hour >= 2):
|
||||
string += _("%d hours, ") % hour
|
||||
if (min == 1):
|
||||
string += _(u"%d minute, ") % min
|
||||
string += _("%d minute, ") % min
|
||||
elif (min >= 2):
|
||||
string += _(u"%d minutes, ") % min
|
||||
string += _("%d minutes, ") % min
|
||||
if sec >= 0 and sec <= 2:
|
||||
string += _(u"%s second") % sec_string
|
||||
string += _("%s second") % sec_string
|
||||
else:
|
||||
string += _(u"%s seconds") % sec_string
|
||||
string += _("%s seconds") % sec_string
|
||||
return string
|
||||
|
||||
def find_urls_in_text(text):
|
||||
@@ -40,7 +43,7 @@ def find_urls_in_text(text):
|
||||
|
||||
def download_file(url, local_filename, window):
|
||||
r = requests.get(url, stream=True)
|
||||
window.change_status(_(u"Downloading {0}").format(local_filename,))
|
||||
window.change_status(_("Downloading {0}").format(local_filename,))
|
||||
total_length = r.headers.get("content-length")
|
||||
dl = 0
|
||||
total_length = int(total_length)
|
||||
@@ -49,42 +52,42 @@ def download_file(url, local_filename, window):
|
||||
if chunk: # filter out keep-alive new chunks
|
||||
dl += len(chunk)
|
||||
f.write(chunk)
|
||||
done = int(100 * dl / total_length)
|
||||
msg = _(u"Downloading {0} ({1}%)").format(os.path.basename(local_filename), done)
|
||||
done = int(100 * dl/total_length)
|
||||
msg = _("Downloading {0} ({1}%)").format(os.path.basename(local_filename), done)
|
||||
window.change_status(msg)
|
||||
window.change_status(_(u"Ready"))
|
||||
window.change_status(_("Ready"))
|
||||
return local_filename
|
||||
|
||||
def detect_users(text):
|
||||
""" Detect all users and communities mentionned in any text posted in VK."""
|
||||
# This regexp gets group and users mentionned in topic comments.
|
||||
for matched_data in re.finditer("(\[)(id|club)(\d+:bp-\d+_\d+\|)(\D+)(\])", text):
|
||||
text = re.sub("\[(id|club)\d+:bp-\d+_\d+\|\D+\]", matched_data.groups()[3]+", ", text, count=1)
|
||||
# This is for users and communities just mentionned in wall comments or posts.
|
||||
for matched_data in re.finditer("(\[)(id|club)(\d+\|)(\D+)(\])", text):
|
||||
text = re.sub("\[(id|club)\d+\|\D+\]", matched_data.groups()[3]+", ", text, count=1)
|
||||
return text
|
||||
|
||||
def clean_text(text):
|
||||
""" 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
|
||||
""" Clean text, removing all unneeded HTMl and converting HTML represented characters in their unicode counterparts."""
|
||||
text = detect_users(text)
|
||||
text = html.unescape(text)
|
||||
return text
|
||||
|
||||
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")
|
||||
def transform_audio_url(url):
|
||||
""" Transforms the URL offered by VK to the unencrypted stream so we can still play it.
|
||||
This function will be updated every time VK decides to change something in their Audio API'S.
|
||||
Changelog:
|
||||
30/04/2019: Re-enabled old methods as VK changed everything as how it was working on 16.04.2019.
|
||||
17.04.2019: Updated function. Now it is not required to strip anything, just replacing /index.m3u8 with .mp3 should be enough.
|
||||
16.04.2019: Implemented this function. For now it replaces /index.m3u8 by .mp3, also removes the path component before "/audios" if the URL contains the word /audios, or the last path component before the filename if doesn't.
|
||||
"""
|
||||
if "vkuseraudio.net" not in url and "index.m3u8" not in url:
|
||||
return url
|
||||
url = url.replace("/index.m3u8", ".mp3")
|
||||
parts = url.split("/")
|
||||
if "/audios" not in url:
|
||||
url = url.replace("/"+parts[-2], "")
|
||||
else:
|
||||
print attachment
|
||||
return [tpe, msg]
|
||||
|
||||
url = url.replace("/"+parts[-3], "")
|
||||
return url
|
@@ -1,9 +1,9 @@
|
||||
#!/usr/bin/python
|
||||
import keys
|
||||
import logging
|
||||
import core
|
||||
from authenticator import official
|
||||
from vk_api.audio import VkAudio
|
||||
from wxUI import two_factor_auth
|
||||
from authenticator.wxUI import two_factor_auth
|
||||
|
||||
log = logging.getLogger("vkSessionHandler")
|
||||
|
||||
@@ -12,19 +12,19 @@ class vkObject(object):
|
||||
def __init__(self):
|
||||
self.api_key = keys.keyring.get_api_key()
|
||||
|
||||
def login(self, user, password, token, alt_token, filename):
|
||||
def login(self, user, password, token, secret, device_id, 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
|
||||
from . 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)
|
||||
original_token = official.login(user, password)
|
||||
token = original_token[0]
|
||||
secret = original_token[1]
|
||||
device_id = original_token[2]
|
||||
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)
|
||||
self.session_object = vk_api.VkApi(app_id=self.api_key, login=user, password=password, token=token, secret=secret, device_id=device_id, 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)
|
||||
|
@@ -1,11 +1,14 @@
|
||||
# -*- 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 time
|
||||
import hashlib
|
||||
import logging
|
||||
import vk_api
|
||||
import threading
|
||||
import requests
|
||||
import jconfig_patched as jconfig
|
||||
from authenticator.official import get_sig
|
||||
from . import jconfig_patched as jconfig
|
||||
from vk_api.enums import VkUserPermissions
|
||||
from vk_api.exceptions import *
|
||||
|
||||
@@ -13,7 +16,7 @@ DEFAULT_USER_SCOPE = sum(VkUserPermissions)
|
||||
|
||||
class VkApi(vk_api.VkApi):
|
||||
|
||||
def __init__(self, login=None, password=None, token=None,
|
||||
def __init__(self, login=None, password=None, token=None, secret=None, device_id=None,
|
||||
auth_handler=None, captcha_handler=None,
|
||||
config=jconfig.Config, config_filename='vk_config.v2.json',
|
||||
api_version='5.92', app_id=2685278, scope=DEFAULT_USER_SCOPE,
|
||||
@@ -23,7 +26,8 @@ class VkApi(vk_api.VkApi):
|
||||
self.password = password
|
||||
|
||||
self.token = {'access_token': token}
|
||||
|
||||
self.secret = secret
|
||||
self.device_id = device_id
|
||||
self.api_version = api_version
|
||||
self.app_id = app_id
|
||||
self.scope = scope
|
||||
@@ -32,7 +36,7 @@ class VkApi(vk_api.VkApi):
|
||||
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.http.headers.update({'User-agent': 'VKAndroidApp/5.23-2978 (Android 4.4.2; SDK 19; x86; unknown Android SDK built for x86; en; 320x240)'})
|
||||
|
||||
self.last_request = 0.0
|
||||
|
||||
@@ -46,4 +50,88 @@ class VkApi(vk_api.VkApi):
|
||||
self.lock = threading.Lock()
|
||||
|
||||
self.logger = logging.getLogger('vk_api_patched')
|
||||
self.logger.info('Started patched VK API client...')
|
||||
self.logger.info('Started patched VK API client...')
|
||||
|
||||
def method(self, method, values=None, captcha_sid=None, captcha_key=None,
|
||||
raw=False):
|
||||
""" Вызов метода API
|
||||
|
||||
:param method: название метода
|
||||
:type method: str
|
||||
|
||||
:param values: параметры
|
||||
:type values: dict
|
||||
|
||||
:param captcha_sid: id капчи
|
||||
:type captcha_key: int or str
|
||||
|
||||
:param captcha_key: ответ капчи
|
||||
:type captcha_key: str
|
||||
|
||||
:param raw: при False возвращает `response['response']`
|
||||
при True возвращает `response`
|
||||
(может понадобиться для метода execute для получения
|
||||
execute_errors)
|
||||
:type raw: bool
|
||||
"""
|
||||
|
||||
values = values.copy() if values else {}
|
||||
|
||||
if 'v' not in values:
|
||||
values['v'] = self.api_version
|
||||
|
||||
if self.token:
|
||||
values['access_token'] = self.token['access_token']
|
||||
|
||||
if captcha_sid and captcha_key:
|
||||
values['captcha_sid'] = captcha_sid
|
||||
values['captcha_key'] = captcha_key
|
||||
|
||||
with self.lock:
|
||||
# Ограничение 3 запроса в секунду
|
||||
delay = self.RPS_DELAY - (time.time() - self.last_request)
|
||||
|
||||
if delay > 0:
|
||||
time.sleep(delay)
|
||||
values.update(https=1, device_id=self.device_id)
|
||||
sig = get_sig(method, values, self.secret)
|
||||
values.update(sig=sig)
|
||||
response = self.http.post(
|
||||
'https://api.vk.com/method/' + method,
|
||||
values
|
||||
)
|
||||
self.last_request = time.time()
|
||||
|
||||
if response.ok:
|
||||
response = response.json()
|
||||
else:
|
||||
error = ApiHttpError(self, method, values, raw, response)
|
||||
response = self.http_handler(error)
|
||||
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
raise error
|
||||
|
||||
if 'error' in response:
|
||||
error = ApiError(self, method, values, raw, response['error'])
|
||||
|
||||
if error.code in self.error_handlers:
|
||||
if error.code == CAPTCHA_ERROR_CODE:
|
||||
error = Captcha(
|
||||
self,
|
||||
error.error['captcha_sid'],
|
||||
self.method,
|
||||
(method,),
|
||||
{'values': values, 'raw': raw},
|
||||
error.error['captcha_img']
|
||||
)
|
||||
|
||||
response = self.error_handlers[error.code](error)
|
||||
|
||||
if response is not None:
|
||||
return response
|
||||
|
||||
raise error
|
||||
|
||||
return response if raw else response['response']
|
||||
|
@@ -1,37 +1,18 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
from __future__ import unicode_literals
|
||||
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()
|
||||
return wx.MessageDialog(None, _("In order to continue, you need to configure your VK account before. Would you like to autorhise a new account now?"), _("Authorisation"), wx.YES_NO).ShowModal()
|
||||
|
||||
class newSessionDialog(widgetUtils.BaseDialog):
|
||||
def __init__(self):
|
||||
super(newSessionDialog, self).__init__(parent=None, id=wx.NewId(), title=_(u"Authorise VK"))
|
||||
super(newSessionDialog, self).__init__(parent=None, id=wx.NewId(), title=_("Authorise VK"))
|
||||
panel = wx.Panel(self)
|
||||
lbl1 = wx.StaticText(panel, -1, _(u"&Email or phone number"))
|
||||
lbl1 = wx.StaticText(panel, -1, _("&Email or phone number"))
|
||||
self.email = wx.TextCtrl(panel, -1)
|
||||
lbl2 = wx.StaticText(panel, -1, _(u"&Password"))
|
||||
lbl2 = wx.StaticText(panel, -1, _("&Password"))
|
||||
self.passw = wx.TextCtrl(panel, -1, style=wx.TE_PASSWORD)
|
||||
sizer = wx.BoxSizer()
|
||||
b1 = wx.BoxSizer(wx.HORIZONTAL)
|
||||
|
@@ -87,8 +87,8 @@ data_files = get_data(),
|
||||
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", "CRYPT32.dll"],
|
||||
'packages': ["pubsub", "pubsub.core", "pubsub.core.kwargs", "future"],
|
||||
'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-l2-1-0.dll", "api-ms-win-core-string-obsolete-l1-1-0.dll", "WLDAP32.dll", "MSVCP90.dll", "CRYPT32.dll", "api-ms-win-core-memory-l1-1-2.dll", "api-ms-win-core-psapi-l1-1-0.dll", "api-ms-win-core-libraryloader-l1-2-2.dll", "api-ms-win-core-string-l2-1-0.dll", "api-ms-win-core-string-l1-1-0.dll", "api-ms-win-core-processthreads-l1-1-2.dll", "api-ms-win-core-atoms-l1-1-0.dll", "api-ms-win-core-heap-l2-1-0.dll", "api-ms-win-core-com-midlproxystub-l1-1-0.dll", "api-ms-win-core-libraryloader-l1-2-0.dll", "api-ms-win-core-localization-l1-2-1.dll", "api-ms-win-core-sysinfo-l1-2-1.dll"],
|
||||
# 'skip_archive': False
|
||||
},
|
||||
},
|
||||
|
15
src/sound.py
15
src/sound.py
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
""" Sound utilities for socializer."""
|
||||
from __future__ import unicode_literals
|
||||
from builtins import range
|
||||
import sys
|
||||
import os
|
||||
import glob
|
||||
@@ -9,6 +9,7 @@ import logging
|
||||
import paths
|
||||
import sound_lib
|
||||
import output
|
||||
import config
|
||||
from sound_lib import recording
|
||||
from mysc.repeating_timer import RepeatingTimer
|
||||
from mysc.thread_utils import call_threaded
|
||||
@@ -16,8 +17,8 @@ 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 recode_audio(filename, quality=10):
|
||||
subprocess.call(r'"%s" --downmix -q %r "%s"' % (os.path.join(paths.app_path(), 'oggenc2.exe'), quality, filename))
|
||||
|
||||
def get_recording(filename):
|
||||
# try:
|
||||
@@ -61,7 +62,9 @@ class soundSystem(object):
|
||||
log.error("Error in input or output devices, using defaults...")
|
||||
self.config["output_device"] = "Default"
|
||||
self.config["input_device"] = "Default"
|
||||
|
||||
# Set proxy for audio.
|
||||
if config.app["app-settings"]["use_proxy"]:
|
||||
self.output.set_proxy(b"socializer:socializer@socializer.su:3128")
|
||||
self.files = []
|
||||
self.cleaner = RepeatingTimer(60, self.clear_list)
|
||||
self.cleaner.start()
|
||||
@@ -70,7 +73,7 @@ class soundSystem(object):
|
||||
def clear_list(self):
|
||||
if len(self.files) == 0: return
|
||||
try:
|
||||
for i in xrange(0, len(self.files)):
|
||||
for i in range(0, len(self.files)):
|
||||
if self.files[i].is_playing == False:
|
||||
self.files[i].free()
|
||||
self.files.pop(i)
|
||||
@@ -81,6 +84,6 @@ class soundSystem(object):
|
||||
if self.soundpack_OK == False: return
|
||||
if self.config["session_mute"] == True: return
|
||||
sound_object = sound_lib.stream.FileStream(file="%s/%s" % (self.path, sound))
|
||||
sound_object.volume = float(self.config["volume"])
|
||||
# sound_object.volume = self.config["volume"]/100
|
||||
self.files.append(sound_object)
|
||||
sound_object.play()
|
||||
|
BIN
src/sounds/default/checked.ogg
Normal file
BIN
src/sounds/default/checked.ogg
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user