Compare commits

..

No commits in common. "master" and "notifications" have entirely different histories.

264 changed files with 1229800 additions and 186746 deletions

View File

@ -1,129 +1,111 @@
stages: # Jobs to build the two channels in Socializer.
- generate_doc variables:
- build PYTHON3: "C:\\python37\\python.exe"
- generate_versions PYINSTALLER: "C:\\python37\\scripts\\pyinstaller.exe"
- upload PYTHON2: "C:\\python27\\python.exe"
NSIS: "C:\\nsis\\makensis.exe"
pages: test_py3:
image: python:latest stage: test
tags:
- docker
interruptible: true
only:
- master
stage: generate_doc
script:
- 'pip install --upgrade markdown babel'
- 'cp changelog.md doc/changelog.md'
- 'cd doc'
- 'python documentation_importer.py'
- 'python generator.py'
- 'mv -f documentation ../public'
artifacts:
expire_in: 1 day
paths:
- public
socializer64:
stage: build
interruptible: true
variables:
PYTHON: "C:\\python37\\python.exe"
tags: tags:
- windows10 - windows10
only:
- master
- tags
script:
- '&$env:PYTHON -V'
- '&$env:PYTHON -m venv env'
- 'env\Scripts\Activate.ps1'
- 'python -m pip install --upgrade pip'
- 'python -m pip install --upgrade -r requirements.txt'
- 'python -m pip uninstall enum34 -y'
- 'cd src'
- 'python write_version_data.py'
- 'python -m nuitka --mingw64 --standalone --enable-plugin=anti-bloat --noinclude-pytest-mode=nofollow --noinclude-setuptools-mode=nofollow --nofollow-import-to=numpy --nofollow-import-to=babel --nofollow-import-to=cx_freeze --nofollow-import-to=pil --include-data-file=../windows-dependencies/x64/oggenc2.exe=oggenc2.exe --include-data-file=../windows-dependencies/x64/bootstrap.exe=bootstrap.exe --include-data-file=app-configuration.defaults=app-configuration.defaults --include-data-dir=locales=locales --include-data-dir=../public=documentation --include-data-dir=sounds=sounds --include-data-file=session.defaults=session.defaults --windows-disable-console --windows-file-description="Accessible VK Client for Windows" --windows-product-version=2021.12.14.0 --windows-file-version=2021.12.14.0 --windows-product-name="Socializer" --windows-company-name="MCV Software" --python-flag=no_site --assume-yes-for-downloads --remove-output "socializer.py"'
- 'python ..\scripts\copy_missing_files.py'
- 'cd ..'
- 'mkdir artifacts'
- 'cd scripts'
- 'python prepare_zipversion.py'
- 'cd ..'
- 'move src\socializer.zip artifacts\socializer_x64.zip'
- 'mv src/socializer.dist artifacts/program64'
- 'move src/installer.nsi artifacts'
- 'python scripts/generate_update_file.py'
- 'move *.json artifacts'
artifacts:
expire_in: 1 day
paths:
- artifacts
socializer32:
stage: build
interruptible: true
variables:
PYTHON: "C:\\python37-32\\python.exe"
tags:
- windows10
only:
- master
- tags
script:
- '&$env:PYTHON -V'
- '&$env:PYTHON -m venv env'
- 'env\Scripts\Activate.ps1'
- 'python -m pip install --upgrade pip'
- 'python -m pip install --upgrade -r requirements.txt'
- 'python -m pip uninstall enum34 -y'
- 'cd src'
- 'python write_version_data.py'
- 'python -m nuitka --mingw64 --standalone --enable-plugin=anti-bloat --noinclude-pytest-mode=nofollow --noinclude-setuptools-mode=nofollow --nofollow-import-to=numpy --nofollow-import-to=babel --nofollow-import-to=cx_freeze --nofollow-import-to=pil --include-data-file=../windows-dependencies/x86/oggenc2.exe=oggenc2.exe --include-data-file=../windows-dependencies/x86/bootstrap.exe=bootstrap.exe --include-data-file=app-configuration.defaults=app-configuration.defaults --include-data-dir=locales=locales --include-data-dir=../public=documentation --include-data-dir=sounds=sounds --include-data-file=session.defaults=session.defaults --windows-disable-console --windows-file-description="Accessible VK Client for Windows" --windows-product-version=2021.12.14.0 --windows-file-version=2021.12.14.0 --windows-product-name="Socializer" --windows-company-name="MCV Software" --python-flag=no_site --assume-yes-for-downloads --remove-output "socializer.py"'
- 'python ..\scripts\copy_missing_files.py'
- 'cd ..'
- 'mkdir artifacts'
- 'cd scripts'
- 'python prepare_zipversion.py'
- 'cd ..'
- 'move src\socializer.zip artifacts\socializer_x86.zip'
- 'mv src/socializer.dist artifacts/program32'
artifacts:
expire_in: 1 day
paths:
- artifacts
make_installer:
stage: generate_versions
interruptible: true
tags:
- windows10
only:
- tags
- schedule
- master
variables:
NSIS: "C:\\program files (x86)\\nsis\\makensis.exe"
before_script: before_script:
- 'choco upgrade all' - '%PYTHON3% -V'
- '%PYTHON3% -m pip install --upgrade pip'
- '%PYTHON3% -m pip install --upgrade -r requirements.txt'
only:
- schedules
script: script:
- cd artifacts - cd src
- '&$env:NSIS installer.nsi' - '%PYTHON3% -m coverage run run_tests.py'
- '%PYTHON3% -m coverage report --omit="test*"'
coverage: '/TOTAL.+ ([0-9]{1,3}%)/'
documentation:
type: deploy
tags:
- windows10
before_script:
- '%PYTHON3% -v'
script:
- copy changelog.md doc\changelog.md
- cd doc
- '%PYTHON2% documentation_importer.py'
- cd ..\src
- '%PYTHON2% ..\doc\generator.py'
- 'move documentation ..\'
only:
- master
artifacts: artifacts:
paths: paths:
- artifacts - documentation
name: socializer_documentation
expire_in: 1 day expire_in: 1 day
upload: alpha_python3:
stage: upload type: deploy
tags: tags:
- docker - windows10
image: python before_script:
interruptible: true - '%PYTHON3% -v'
- '%PYTHON3% -m pip install --upgrade pip'
- '%PYTHON3% -m pip install --upgrade -r requirements.txt'
- '%PYTHON3% -m pip uninstall enum34 -y'
script: script:
- cd artifacts - copy changelog.md doc\changelog.md
- python ../scripts/upload.py - 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
- 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:
- 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'
- '%NSIS% installer.nsi'
- cd ..
- move src\socializer* .
- cd scripts
- '%PYTHON3% prepare_zipversion.py'
- cd ..
- move src\socializer.zip socializer.zip
only: only:
- tags - tags
- schedules artifacts:
- master paths:
- socializer.zip
- "socializer_*"
name: socializer

View File

@ -1,90 +1,24 @@
# socializer # socializer
[![pipeline status](https://gitlab.com/socializer1/socializer/badges/master/pipeline.svg)](https://gitlab.com/socializer1/socializer/commits/master) [![pipeline status](https://code.manuelcortez.net/manuelcortez/socializer/badges/master/pipeline.svg)](https://code.manuelcortez.net/manuelcortez/socializer/commits/master)
> Note: this project has two different main repositories. [Here is the official repository, hosted in our GitLab instance,](https://gitlab.mcvsoftware.com/socializer/socializer) [Here is a mirror repository hosted in GitHub.](https://github.com/manuelcortez/socializer) Github repository will accept pull requests and issues reported by github users, while Gitlab's repository will provide the wiki, documentation, and support for user reported issues. > Note: this project has two different main repositories. [Here is the official repository, hosted in my Gitlab Instance,](https://code.manuelcortez.net/manuelcortez/socializer) [Here is a mirror repository hosted in GitHub.](https://github.com/manuelcortez/socializer) Github repository will accept pull requests and issues reported by github users, while Gitlab's repository will provide the wiki, documentation, and support for user reported issues.
A desktop application for handling [vk.com](https://vk.com) in an easy way. A desktop application for handling [vk.com](http://vk.com) in an easy way.
[See Socializer's website](https://socializer.su) [See Socializer's website](http://socializer.su)
> Note: this is the developer oriented documentation. If you want to read the user manual of socializer, [read the manual in the project's website](https://socializer.su/en/documentation) ## dependencies not installed by PIP
## running For other dependencies, do pip install --upgrade -r requirements.txt
This document describes how to run Socializer from source and how to build a binary version which doesn't need Python and the other dependencies to run. * [Python,](http://python.org) version 3.7.2
### Required dependencies ## Documentation
Although most dependencies (except Python) can be found in the windows-dependencies directory, we provide links to their official websites. I am trying to write an updated manual for socializer. It can be found in the documentation folder once the program zip file is uncompressed, or in the manual.md file (in markdown). The idea of this manual is to be updated as socializer receives new features or improvements.
* [Python,](http://python.org) version 3.7.9 A copy of the English version of the manual can be read here: [Manual in the socializer's wiki](https://code.manuelcortez.net/manuelcortez/socializer/wikis/manual)
#### Dependencies that must be installed using pip
Python installs a tool called Pip that allows to install packages in a simple way. You can find it in the python scripts directory. To install packages using Pip, you have to navigate to the scripts directory using a command prompt, for example:
cd C:\python37\scripts
You can also add the scripts folder to your path environment variable or choose the corresponding option when installing Python.
Pip is able to install packages listed in a special text file, called the requirements file. To install all remaining dependencies, perform the following command:
pip install -r requirements.txt
Note that if you perform the command from the path where Pip is located, you need to specify the path to your Socializer root folder where the requirements file is located, for example:
pip install -r D:\repos\socializer\requirements.txt
Pip will automatically get the additional libraries that the listed packages need to work properly.
If you need to update your dependencies, perform the following command:
pip install --upgrade -r requirements.txt
#### Other dependencies
These dependencies are located in the windows-dependencies directory. You don't need to install or modify them.
* Bootstrap 1.2.1: included in dependencies directory.
This dependency has been built using pure basic 4.61. Its source can be found at http://hg.q-continuum.net/updater
* [oggenc2.exe,](http://www.rarewares.org/ogg-oggenc.php) version 2.87
* Microsoft Visual c++ 2017 redistributable dlls.
#### Dependencies required to build the installer
* [NSIS,](http://nsis.sourceforge.net/) version 3.04
### Running Socializer from source
Now that you have installed all these packages, you can run Socializer from source using a command prompt. Navigate to the repo's `src` directory, and type the following command:
python main.py
If necessary, change the first part of the command to reflect the location of your python executable.
### Generating the documentation
To generate the documentation in html format, ensure you are in the doc folder inside this repo. After that, run these commands:
copy ..\changelog.md .
python document_importer.py
cd ..\src
python ..\doc\generator.py
The documentation will be generated, placing each language in a separate folder in the doc directory.
### Building a binary version
A binary version doesn't need python and the other dependencies to run, it's the same version that you will find on the Socializer's website if you download the zip files or the Alpha versions.
To build it, run the following command from the src folder:
python setup.py build
You will find the binaries in the dist directory.
### Building an installer
If you want to install Socializer on your computer, you must create the installer first. Follow these steps:
* Navigate to the src directory, and Write the latest alpha version in the application file, so this version will be able to check updates and get the alpha channel: c:\python37\python.exe write_version_data.py
* create a binary version: C:\python37\python setup.py build
* run the installer script: C:\nsis\makensis.exe installer.nsi
## Contributing ## Contributing

View File

@ -1,59 +1,7 @@
Changelog # Changelog
## News in this version ## News in this version
### new additions
* Now socializer can load the list of members for a community. You have to use the context menu in the community in order to load all members. For community administrators and moderators, it will display also a new buffer with invites that have been sent to the group. You can use the context menu in those buffers to perform common actions to those user. Take into account, though, that available actions from those buffers depend in the focused user's privacy settings.
* Added an actions button that allows you to perform several tasks from the parts of the application where it appears. For now, the action button is shown in any displayed post or repost, and also in chat messages. When pressed, it opens a menu from where you can translate texts or do spelling correction on the message.
* It is now possible to read an article from a wall post. The article will be opened in a new dialog. This might work better in countries where VK is blocked as users no longer need to open the web browser. Unfortunately, as articles are mainly undocumented in the API, it is not possible to perform other actions besides reading them from Socializer.
* the spelling correction module is able to add words to the dictionary so it will learn which words should start to ignore.
* Added a new setting, in the preferences dialog, that allows you to turn on the debug logging feature. With this feature Enabled, Socializer will log more information regarding what is doing while an error occurs. This feature must be enabled when you want to report an issue and send us your logs.
### bugfixes
* Now it is possible to select or unselect audios in a list by pressing space again. This was not possible earlier due to an unexpected issue when migrating to the latest version of socializer's components.
* Fixed an issue when focusing chat messages. Sometimes, socializer was not precise enough to focus the right message. Now all messages should be getting the focus as expected.
* Fixed a small issue that was making impossible to close the blacklist dialog by pressing escape.
* Now it is possible to perform authentication in accounts using two factor verification again. This issue was caused due to a recent change in the VK workflow for two factor verification processes.
* Users who have chosen to not show their online activity (specifically the last seen field in VK) will be added in people buffers. Before, those people were making socializer to raise an exception and the whole buffer was unable to be loaded.
* It is possible to translate texts again, thanks to the Google Translate implementation added in the application.
### Changes
* The spelling correction module has been rewritten to take advantage of the newest enchant Python module which is more stable and can be added properly to the distribution, as opposed to the first enchant module we have tried.
* Better performance on Socializer should be noticed for users with many conversations opened. Before, socializer could freeze while loading all messages in conversations. Now that should work more efficiently and the application should not stop responding.
* Socializer now uses Google Translate services instead of yandex.translate.
* When displaying people buffers (such as those shown in the current user's account), socializer shows the buttons for sending private messages or post in user's wall only if the focused user has enabled those options.
## News in Version 0.24
### New additions
* Socializer will ask for confirmation before closing the application.
* In all audio buffers, there is a new item in the context menu that allows downloading of the audio directly from the buffer. If there are multiple audios selected, socializer will ask for a folder where all audios should be placed. When downloading multiple audios, socializer will name those automatically by following the template "song title - artist".
* In all audio buffers, there are two new menu items for selecting and deselecting all items in the buffer.
* Added displaying of articles as attachments in wall posts. When opened, Socializer will open the article in the web browser.
* Starting from Version 0.24, there will be an installer for the Alpha version of socializer, always available from our downloads page.
### bugfixes
* Fixed an error that was making socializer unable to render correctly certain Links containing uppercase letters (such as yandex.disk shared links). Before, those links were giving 404 errors when pressed, now they should work normally. This error was present in wall posts, comments, topics and chat messages.
* Fixed an error related to chat notifications in Socializer. Before, the "online now" notification could break the Socializer interface, making it unable to load the chat in real time.
* Fixed a small inconsistency when marking a conversation as read. Before, if two messages were sent by the recipient, only the last message was marked as read and the previous was making the unread sound all the time. Now that issue should be handled properly.
### Changes
* Socializer will not be marked as Virus by most antivirus softwares due to a new build tool which is cleaner and less prone to be flagged by antivirus.
* Socializer is distributed with the Microsoft C++ redistributable package, so everyone will be able to use the software without needing to install any extra package.
* Replaced the underlying library we were using for spelling correction as is no longer in development. Instead, we started to use a new approach in socializer, which, in theory, should allow us to switch language for spelling correction and other benefits a bit later. For now, available languages are Russian, Ukranian, English, Polish and Spanish, but more languages can be added by request.
* When downloading a file (such as an audio file or document), the download process should be relatively faster due to some optimizations made in the function.
* Socializer now uses just the first name of users in typing notifications.
* socializer should be able to inform users about common errors when sending chat messages (such as sending messages to people in the current user's blacklist or banned from VK). Later, more errors related to posts will be added.
* The application will load up to 100 audio albums instead of the default 10.
## Changes in Version 0.23 (11.11.2019)
### New additions ### New additions
* Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later. * Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later.

View File

@ -1,289 +0,0 @@
# Changelog
## News in this version
## new additions
* the spelling correction module is able to add words to the dictionary so it will learn which words should start to ignore.
### bugfixes
* Now it is possible to perform authentication in accounts using two factor verification again. This issue was caused due to a recent change in the VK workflow for two factor verification processes.
### Changes
* The spelling correction module has been rewritten to take advantage of the newest enchant Python module which is more stable and can be added properly to the distribution, as opposed to the first enchant module we have tried.
* Better performance on Socializer should be noticed for users with many conversations opened. Before, socializer could freeze while loading all messages in conversations. Now that should work more efficiently and the application should not stop responding.
## News in Version 0.24
### New additions
* Socializer will ask for confirmation before closing the application.
* In all audio buffers, there is a new item in the context menu that allows downloading of the audio directly from the buffer. If there are multiple audios selected, socializer will ask for a folder where all audios should be placed. When downloading multiple audios, socializer will name those automatically by following the template "song title - artist".
* In all audio buffers, there are two new menu items for selecting and deselecting all items in the buffer.
* Added displaying of articles as attachments in wall posts. When opened, Socializer will open the article in the web browser.
* Starting from Version 0.24, there will be an installer for the Alpha version of socializer, always available from our downloads page.
### bugfixes
* Fixed an error that was making socializer unable to render correctly certain Links containing uppercase letters (such as yandex.disk shared links). Before, those links were giving 404 errors when pressed, now they should work normally. This error was present in wall posts, comments, topics and chat messages.
* Fixed an error related to chat notifications in Socializer. Before, the "online now" notification could break the Socializer interface, making it unable to load the chat in real time.
* Fixed a small inconsistency when marking a conversation as read. Before, if two messages were sent by the recipient, only the last message was marked as read and the previous was making the unread sound all the time. Now that issue should be handled properly.
### Changes
* Socializer will not be marked as Virus by most antivirus softwares due to a new build tool which is cleaner and less prone to be flagged by antivirus.
* Socializer is distributed with the Microsoft C++ redistributable package, so everyone will be able to use the software without needing to install any extra package.
* Replaced the underlying library we were using for spelling correction as is no longer in development. Instead, we started to use a new approach in socializer, which, in theory, should allow us to switch language for spelling correction and other benefits a bit later. For now, available languages are Russian, Ukranian, English, Polish and Spanish, but more languages can be added by request.
* When downloading a file (such as an audio file or document), the download process should be relatively faster due to some optimizations made in the function.
* Socializer now uses just the first name of users in typing notifications.
* socializer should be able to inform users about common errors when sending chat messages (such as sending messages to people in the current user's blacklist or banned from VK). Later, more errors related to posts will be added.
* The application will load up to 100 audio albums instead of the default 10.
## Changes in Version 0.23 (11.11.2019)
### New additions
* Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later.
* Switching accounts is now supported in socializer. In the application menu, there is an option called "manage accounts" which allows you to add or remove an account. Socializer will take changes after a restart of the application. In case of having multiple accounts, every time Socializer starts, you will see a dialog from where is possible to choose the account for logging in.
* when selecting multiple audio files in audio buffers, multiple actions can be performed in all items, these actions are present in the contextual menu of the buffer (namely play, add/remove from the library and move to a different playlist). This means you can select all the audios you want and Socializer will perform the selected options in all items, making it a bit easier to operate with multiple songs.
* Now it is possible to like and see who liked a comment when displaying it individually. This applies to comments in wall posts and topics.
* Now it is possible to choose how many items Socializer will load in conversation buffers, from the General tab in the preferences dialog. The default value is 50 items, and the maximum value is 200.
* There is a new tab called buffer settings, in the preferences dialog. Settings related to how many items should be loaded in certain buffer types have been moved to this tab, so it will separate better the configuration options in the application.
* Added management of the Blacklist on VK. Users can be blocked from people buffers (friends, online, or any buffer inside friend requests). You can access the blacklist from the application menu, located in the menu bar. From there, you can unblock any previously blocked user.
* In the new timeline dialog, it is possible to create video buffers by selecting the "video" radio button as buffer type.
### bugfixes
* Fixed an error that was causing socializer to not update the "Online friends" buffer if chat notifications were disabled.
* Fixed an error that was making Socializer unable to attach audio files from the computer, if the file does not include correct ID3 TAGS.
* Fixed a traceback that was being logged when attempting to load an image but cancel the dialog for attaching it.
* Fixed an error that was making Socializer to fail when loading the newsfeed buffer, thus not loading any other buffers. This error was caused due to VK sending a new object type representing push subscriptions. The item is ignored by Socializer so it will not break the newsfeed buffer anymore.
* Fixed an error that was making the status bar to not fit the full size of the Window. This was cutting the messages placed on it, now, all messages are displayed properly again.
* fixed an unhandled condition when playing a song and voice message at the same time, that was potentially making Socializer to stop loading certain buffers.
* fixed an error that was making socializer unable to parse video data, thus video buffers were impossible to be loaded.
### Changes
* Less confidential user data will be send to the logs, so it will be much safer to pass logs publicly.
* automatic update checks will be disabled if using socializer from the source code.
* it is possible to post in an user's wall by using the post button located next to the user, in people buffers. This applies only to online users and list of friends.
* When displaying a profile, information about mobile and home phone is displayed in the basic information tab.
* In wall posts, all comments, including replies, will be displayed in the same list. Before, you had to open a comment to read its replies. When a new comment is posted by the current user, the list of comments will be reloaded and new additions will be fetched and sorted properly.
## changes in Versions 0.21 and 0.22 (14.07.2019)
### New additions
* Added "post in groups" feature. In order to do so, you need to load the posts for the group where you want to send something. Once loaded, go to the post button in the group's wall and select whether you want to post in the group's behalf or as yourself.
* In all audio buffers, it is possible to select individual tracks to be played together. In order to do so, you need to press space to start the selection of items. When selected, the item will emit a sound to indicate the change. Press space in all items you want to select/unselect. When you're focusing an already selected item it will play a sound to indicate that it is already selected. Once you're done with your selection, pressing enter in the list of tracks will start the playback of the list of items you have selected. This is a very experimental feature. More actions can be supported based in this selection method if it proves to be useful.
* In conversation buffers, it is possible to display and open wall posts sent as attachments in messages.
* In people buffers, it is possible to create a new timeline by using the context menu while focusing an user. This method will create the buffer for the selected user, as opposed to creating the buffer from the menu bar, where you have to type the username or find it in a list.
### bugfixes
* Fixed an error with two factor authentication in the recent socializer version. Now it works reliably again.
* Fixed an error when trying to attach a photo to a wall post. The error was fixed in the [vk_api](https://github.com/python273/vk_api) module and the fix was sent to the developer of the library, so he will be able to merge it in the next version. In the meantime, socializer already includes the fix for this method, so you can upload photos to wall posts normally.
* Fixed an error retrieving some group information for the current session.
* When posting in a topic, links will be posted properly.
### Changes
* the audio player module has received some improvements:
- When there is something being played, the label of the "play" button, located in all audio buffers, will change automatically to "pause". When pressed, it will pause the song instead of starting the playback again since the beginning.
- The last change will work also in the dialog for displaying audio information. Now it's possible to play and pause an audio from such dialog.
- When playing a voice message, if a song is playing already socializer will decrease the volume so you can hear the voice message well enough. Some seconds after the message has finished, the song's volume will be restored.
* In audio buffers, you will play the focused audio when pressing enter in the item, instead of opening the audio information dialog.
* Removed some old keystrokes in socializer buffers due to better alternatives. The reason for this change is that currently you don't need to be focusing an item in a buffer for being able to use the alternative keystrokes, which makes those a better implementation.
- Control+Enter and control+Shift+Enter: superseeded by Control+P for playing (and pausing) the currently focused audio.
- F5 and F6: superseeded by Alt+down and up arrows for modifying volume.
## changes in version 0.20 (25.04.2019)
### New additions
* For users with multiple soundcards, there is a new tab in the preferences dialogue of Socializer, called sound. From there, you can define which soundcard will be used for input and output. [#25,](https://code.manuelcortez.net/manuelcortez/socializer/issues/25)
* the audio player can seek positions in the currently playing track. You can use the menu items (located in the main menu) or use the new available keystrokes dedicated to the actions. Seeking will be made in 5 second intervals.
* Alt+Shift+Left arrow: Seek 5 seconds backwards.
* Alt+Shift+Right arrow: Seek 5 seconds forwards.
* it is possible to select the language used in socializer from the preferences dialog. When changing the language, the application must be restarted for the changes to take effect.
* A new option, called open in vk.com, has been added in the context menu for almost all objects (items in home timeline, walls, documents, people, group topics and in buffers for conversations). This option will open the selected item in the VK website.
* when opening the list of friends added by an user, you can display the context menu from an item on the list and view the user profile, open it in VK.com, among other actions. [#8,](https://code.manuelcortez.net/manuelcortez/socializer/issues/8)
* When displaying a post, if you press enter in the button indicating how many people liked or shared the post, Socializer will display the listt of people who have liked or shared it. You can use the context menu in the list to do certain actions. [#38,](https://code.manuelcortez.net/manuelcortez/socializer/issues/38)
* it is possible to retrieve more items for conversation buffers. Due to API limitations, it is possible to load up to the last 600 messages for every conversation. Take into account that the process of loading more items takes some time. You will hear a message when the process is done.
* It is possible to delete entire conversations from the buffer's tree, by using the menu key and selecting "delete conversation". The conversation will be removed from VK.
* When loading a topic in a group, socializer will display the latest 100 messages. In order to load more messages, you will find a button that will load the previous 100 messages present in the topic, or the amount of messages not loaded yet.
### bugfixes
* All spelling dictionaries are included by default for the following languages: Russian, English, German, French, italian, Polish, spanish and Turkish. Before, some dictionaries were missing and the spelling checker was failing.
* Fixed an error in the default configuration template used for new sessions in the application. This error was making Socializer to fail when loading any conversation buffer.
* Fixed an error in the algorithm to detect friends disconnecting from VK. This problem was interrupting the connection with the chat server every time it was happening, thus chat server's connection should be more reliable now.
* The audio player should behave better in situations where a song is interrupted. Before, if you pressed "next song" while the currently playing sound was interrupted due to internet connection issues, two or more songs were played at the same time.
* The bug reporting feature works normally again.
### Changes
* Updated method for accessing audio files due to the latest changes on VK apps.
* When changing volume of the playing audio, it will decrease or increase the volume by 2% instead of 5%.
* Read confirmations will be sent to VK as soon as you read the message. Before, read confirmations were being sent every 3 minutes to the social network.
## Changes in version 0.19 (13.03.2019)
* Added a new buffer called documents. When loading the buffer, it will contain all documents owned by the current user. The context menu of any item will allow you to download the document to your computer or remove it from VK.
* 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:
* The stable channel will have releases every month, approximately, and is the channel where the code will be more tested and with less bugs. All support and help will be provided for the stable versions only.
* The alpha channel will have releases every time a change is added to socializer, it may even include several releases in the same day, but we will try to release only a new version every day. Support will not be provided for alpha versions, as they will be used to test the latest code in the application.
* Now it is possible to send voice messages from socializer. Voice messages are available from the "add" button in any conversation buffer.
* tokens generated by socializer will never expire. ([#3,](https://code.manuelcortez.net/manuelcortez/socializer/issues/3))
* In order to use all methods available in VK, socializer will use tokens of kate mobile for Android. It means you may receive an email by saying that you've authorised Kate for accessing your account from an Android device.
* Audio albums are loaded correctly.
* It is possible to play audios added by friends appearing in the news feed.
* Adding and removing an audio file to your library works.
* Unread messages will play a sound when focused.
* Unread messages will be marked as read when user focuses them.
* Socializer will handle restricted audio tracks. Restricted songs are not allowed to be played in the user's country. Before, playing a restricted track was generating an exception and playback could not resume. Now, playing an audio track will display an error notification.
* Fixed an error when people were trying to open a post in an empty buffer, or accessing the menu when there are no posts in the buffer.
* Now Socializer will not send a notification every 5 minutes.
* the chat widget now is a multiline text control. It means it is possible to add a new line by pressing shift+Enter, and send the message by pressing enter.
* Socializer should handle connection errors when loading items in buffers and retry in 2 minutes. Also, connection errors in the chat server are handled and chat should be able to reconnect by itself.
* When trying to add an audio or video to an album, if the current user does not have any album, it will display an error instead of a traceback.
* Added popular and suggested songs. This will not work when using alternative tokens.
* Now it is possible to update the status message, located in your profile.
* Now it is possible to upload an audio from your computer when adding attachments in a wall post. When adding attachments to a post or message in a conversation, you will have two options: upload from your computer and add a file from your VK profile.
* Updated Russian translation: thanks to Дарья Ратникова.
* Fixed some conditions, especially when rendering items in feeds, that were making the client to crash.
* new versions will include documentation and changelog.
* A new option for reporting issues directly from the help menu has been added. Issues will be publicly available in the [Project Issues page](https://code.manuelcortez.net/manuelcortez/socializer/issues)
## Changes in version 0.16 (13.12.2018)
* Added two more buffers: "Pending requests" and "I follow", located in the people buffer, under "friendship requests".
* Added an experimental photo viewer. Will show options for displaying the next and previous photo if the current post contains multiple images. Fullscreen button still doesn't work.
* Improved the chat features present in the application. Read documentation to get a full understanding about how it works now.
* Added video management (my videos, video albums and video search). For playing videos, you will be redirected to a website in your browser due to the VK'S policy.
* Added a setting that allows you to specify if you want socializer to load images when you are opening posts. It could be useful for slow connections or those who don't want images to be loaded.
* Added basic tagging for users in posts and comments. You can tag only people in your friends buffer.
* Added a basic user profile viewer.
* Added support for listening voice messages in chats. Currently it is not possible to send them.
* Fixed an error that was making Socializer unable to display chat history properly. It was showing the first 200 items in a conversation instead the last 200 items. Now chat will be displayed accordingly.
* Changed the chat history widget from list of items to a read only text box, similar to how it was displayed in skype. Now the widget should be fully visible and messages will work in the same way.
* It is possible to play songs sent in a chat message by opening them from the attachments panel.
* Reimplemented most of the audio playback methods (audio albums buffer still not working).
* Added some notifications and chat notifications when friends are online and offline. Most notifications can be configured from settings.
## Changes in build 2016.07.08 (08/07/2016)
* Removed platform from "last seen" column in the friends list as it could cause some problems and it was being not so exact.
* Now deleted audios are not parsed and displayed as "audio removed from library". They are silently ignored.
* It's possible to open a friends timeline for others.
* Fixed some strange bugs in the built version.
* Deactivated accounts will not cause problems in friends lists. They will be displayed as deactivated, wich means that it'll be impossible to interact with those accounts.
* When opened, the client will set online for the user account, it'll inform VK that this user is currently online. This parameter will be updated every 15 minutes, as stated in the API documentation.
* When opened, socializer will try to create chat buffers for all unread messages.
* Update some information on certain posts when an item is selected. For example, update the date of a post.
* Read messages will be marked as read in the social network, so it'll cause that your friends could see that you have read the message and socializer will not load chat buffers with read messages at startup.
* Included a brief manual in the help menu. Currently available only in English.
* Included a context menu in list items. Currently there are functions not available. Menu for chat buffers is not implemented yet.
* Implemented audio album load (in the music buffer), creation (in the application menu) and deletion (in the application menu, too).
* 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).
* Albums will be empty at startup. In order to get the album's audios, you'll have to navigate to the album and press the button "load". It'll load the needed information for displaying and playing the added songs
* If the config is invalid (for example you changed email or phone in the VK site and didn't changed that in Socializer, or just entered invalid credentials), the program will display an error with instructions for fixing the problem.
* Now is possible to press enter in the password or email/phone field and it'll do the action of the OK button.
* If you have set russian as the main language in the VK site, you'll see names in genitive and instrumental cases in certain phrases.
* Updated russian and spanish translations.
## Changes on build 2016.05.25
* 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.
* 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.
* 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.
* 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.
* 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.
* Posts from twitter are displayed in a better way (newline characters (\n) are handled properly instead being displayed).
* In the play all function, everything should be cleaned before start the new playback.
* 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.
* 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.
* Added your friendlist as a buffer. You can create chats from there by using the send message button.
## Changes for build 2016.04.5 (5/04/2016)
* Updated russian and spanish translations.
* Fixed minor bugs in the likes button for posts.
* Now it's possible to open wall posts by pressing enter, as newsfeeds' posts.
* 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.
* 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.
* Added more options in the search audio dialog. Now users could use more parameters and searches will be more precise.
* Added a new attachments' list. When a post is opened, this list will show up if there are attachments in the current post (attachments are audio, photos, video and links). You will be able to interact with the supported data (at the moment only photos, videos, audio and links are supported, more will be added in future).
* Added a changelog file which could be opened from the help menu.
* Added a preferences dialogue and a new application menu in the menu bar. From this dialogue you can change the number of items to be loaded for every buffer.

View File

@ -1,292 +0,0 @@
# -*- coding: utf-8 -*-
documentation = [
_(u"""# Changelog"""),
"",
_(u"""## News in this version"""),
"",
_(u"""## new additions"""),
"",
_(u"""* the spelling correction module is able to add words to the dictionary so it will learn which words should start to ignore."""),
"",
_(u"""### bugfixes"""),
"",
_(u"""* Now it is possible to perform authentication in accounts using two factor verification again. This issue was caused due to a recent change in the VK workflow for two factor verification processes."""),
"",
_(u"""### Changes"""),
"",
_(u"""* The spelling correction module has been rewritten to take advantage of the newest enchant Python module which is more stable and can be added properly to the distribution, as opposed to the first enchant module we have tried."""),
_(u"""* Better performance on Socializer should be noticed for users with many conversations opened. Before, socializer could freeze while loading all messages in conversations. Now that should work more efficiently and the application should not stop responding."""),
"",
_(u"""## News in Version 0.24"""),
"",
_(u"""### New additions"""),
"",
_(u"""* Socializer will ask for confirmation before closing the application."""),
_(u"""* In all audio buffers, there is a new item in the context menu that allows downloading of the audio directly from the buffer. If there are multiple audios selected, socializer will ask for a folder where all audios should be placed. When downloading multiple audios, socializer will name those automatically by following the template "song title - artist"."""),
_(u"""* In all audio buffers, there are two new menu items for selecting and deselecting all items in the buffer."""),
_(u"""* Added displaying of articles as attachments in wall posts. When opened, Socializer will open the article in the web browser."""),
_(u"""* Starting from Version 0.24, there will be an installer for the Alpha version of socializer, always available from our downloads page."""),
"",
_(u"""### bugfixes"""),
"",
_(u"""* Fixed an error that was making socializer unable to render correctly certain Links containing uppercase letters (such as yandex.disk shared links). Before, those links were giving 404 errors when pressed, now they should work normally. This error was present in wall posts, comments, topics and chat messages."""),
_(u"""* Fixed an error related to chat notifications in Socializer. Before, the "online now" notification could break the Socializer interface, making it unable to load the chat in real time."""),
_(u"""* Fixed a small inconsistency when marking a conversation as read. Before, if two messages were sent by the recipient, only the last message was marked as read and the previous was making the unread sound all the time. Now that issue should be handled properly."""),
"",
_(u"""### Changes"""),
"",
_(u"""* Socializer will not be marked as Virus by most antivirus softwares due to a new build tool which is cleaner and less prone to be flagged by antivirus."""),
_(u"""* Socializer is distributed with the Microsoft C++ redistributable package, so everyone will be able to use the software without needing to install any extra package."""),
_(u"""* Replaced the underlying library we were using for spelling correction as is no longer in development. Instead, we started to use a new approach in socializer, which, in theory, should allow us to switch language for spelling correction and other benefits a bit later. For now, available languages are Russian, Ukranian, English, Polish and Spanish, but more languages can be added by request."""),
_(u"""* When downloading a file (such as an audio file or document), the download process should be relatively faster due to some optimizations made in the function."""),
_(u"""* Socializer now uses just the first name of users in typing notifications."""),
_(u"""* socializer should be able to inform users about common errors when sending chat messages (such as sending messages to people in the current user's blacklist or banned from VK). Later, more errors related to posts will be added."""),
_(u"""* The application will load up to 100 audio albums instead of the default 10."""),
"",
_(u"""## Changes in Version 0.23 (11.11.2019)"""),
"",
_(u"""### New additions"""),
"",
_(u"""* Socializer is now more tolerant to internet issues. When attempting to create a wall post, comment, topic or send a chat message, if the data is unable to be posted to VK, socializer will allow you to try to post it again, giving you the opportunity to edit or copy the text of the post in case you want to save it for later."""),
_(u"""* Switching accounts is now supported in socializer. In the application menu, there is an option called "manage accounts" which allows you to add or remove an account. Socializer will take changes after a restart of the application. In case of having multiple accounts, every time Socializer starts, you will see a dialog from where is possible to choose the account for logging in."""),
_(u"""* when selecting multiple audio files in audio buffers, multiple actions can be performed in all items, these actions are present in the contextual menu of the buffer (namely play, add/remove from the library and move to a different playlist). This means you can select all the audios you want and Socializer will perform the selected options in all items, making it a bit easier to operate with multiple songs."""),
_(u"""* Now it is possible to like and see who liked a comment when displaying it individually. This applies to comments in wall posts and topics."""),
_(u"""* Now it is possible to choose how many items Socializer will load in conversation buffers, from the General tab in the preferences dialog. The default value is 50 items, and the maximum value is 200."""),
_(u"""* There is a new tab called buffer settings, in the preferences dialog. Settings related to how many items should be loaded in certain buffer types have been moved to this tab, so it will separate better the configuration options in the application."""),
_(u"""* Added management of the Blacklist on VK. Users can be blocked from people buffers (friends, online, or any buffer inside friend requests). You can access the blacklist from the application menu, located in the menu bar. From there, you can unblock any previously blocked user."""),
_(u"""* In the new timeline dialog, it is possible to create video buffers by selecting the "video" radio button as buffer type."""),
"",
_(u"""### bugfixes"""),
"",
_(u"""* Fixed an error that was causing socializer to not update the "Online friends" buffer if chat notifications were disabled."""),
_(u"""* Fixed an error that was making Socializer unable to attach audio files from the computer, if the file does not include correct ID3 TAGS."""),
_(u"""* Fixed a traceback that was being logged when attempting to load an image but cancel the dialog for attaching it."""),
_(u"""* Fixed an error that was making Socializer to fail when loading the newsfeed buffer, thus not loading any other buffers. This error was caused due to VK sending a new object type representing push subscriptions. The item is ignored by Socializer so it will not break the newsfeed buffer anymore."""),
_(u"""* Fixed an error that was making the status bar to not fit the full size of the Window. This was cutting the messages placed on it, now, all messages are displayed properly again."""),
_(u"""* fixed an unhandled condition when playing a song and voice message at the same time, that was potentially making Socializer to stop loading certain buffers."""),
_(u"""* fixed an error that was making socializer unable to parse video data, thus video buffers were impossible to be loaded."""),
"",
_(u"""### Changes"""),
"",
_(u"""* Less confidential user data will be send to the logs, so it will be much safer to pass logs publicly."""),
_(u"""* automatic update checks will be disabled if using socializer from the source code."""),
_(u"""* it is possible to post in an user's wall by using the post button located next to the user, in people buffers. This applies only to online users and list of friends."""),
_(u"""* When displaying a profile, information about mobile and home phone is displayed in the basic information tab."""),
_(u"""* In wall posts, all comments, including replies, will be displayed in the same list. Before, you had to open a comment to read its replies. When a new comment is posted by the current user, the list of comments will be reloaded and new additions will be fetched and sorted properly."""),
"",
_(u"""## changes in Versions 0.21 and 0.22 (14.07.2019)"""),
"",
_(u"""### New additions"""),
"",
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* In conversation buffers, it is possible to display and open wall posts sent as attachments in messages."""),
_(u"""* 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."""),
"",
_(u"""### bugfixes"""),
"",
_(u"""* Fixed an error with two factor authentication in the recent socializer version. Now it works reliably again."""),
_(u"""* 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."""),
_(u"""* Fixed an error retrieving some group information for the current session."""),
_(u"""* When posting in a topic, links will be posted properly."""),
"",
"",
_(u"""### Changes"""),
"",
_(u"""* the audio player module has received some improvements:"""),
_(u""" - 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."""),
_(u""" - 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."""),
_(u""" - 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."""),
_(u"""* In audio buffers, you will play the focused audio when pressing enter in the item, instead of opening the audio information dialog."""),
_(u"""* 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."""),
_(u""" - Control+Enter and control+Shift+Enter: superseeded by Control+P for playing (and pausing) the currently focused audio."""),
_(u""" - F5 and F6: superseeded by Alt+down and up arrows for modifying volume."""),
"",
_(u"""## changes in version 0.20 (25.04.2019)"""),
"",
_(u"""### New additions"""),
"",
_(u"""* 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)"""),
_(u"""* 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."""),
_(u""" * Alt+Shift+Left arrow: Seek 5 seconds backwards."""),
_(u""" * Alt+Shift+Right arrow: Seek 5 seconds forwards."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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)"""),
_(u"""* 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)"""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
"",
_(u"""### bugfixes"""),
"",
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* The bug reporting feature works normally again."""),
"",
_(u"""### Changes"""),
"",
_(u"""* Updated method for accessing audio files due to the latest changes on VK apps."""),
_(u"""* When changing volume of the playing audio, it will decrease or increase the volume by 2% instead of 5%. """),
_(u"""* 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."""),
"",
_(u"""## Changes in version 0.19 (13.03.2019)"""),
"",
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* Added experimental support to "subscribers" buffer, inside frienship requests. This shows friend requests that have been declined by the current user."""),
_(u"""* the message when an user is typing in conversation buffers will be announced only if the socializer window is focused."""),
_(u"""* 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."""),
_(u"""* Added experimental support to user and community polls:"""),
_(u""" * 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."""),
_(u""" * Otherwise it will display a dialog from where the user can vote in the current poll."""),
_(u"""* Fixed an error in Socializer that was making it unable to detect unread messages properly."""),
_(u"""* 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))"""),
_(u"""* 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))"""),
_(u"""* Socializer will load all conversations during startup, not only conversations with unread messages."""),
_(u"""* Added new global keystrokes, available in the main window."""),
_(u""" * Alt + up/down arrows: Increase / decrease volume."""),
_(u""" * Alt + Left/down arrows: Play previous and next song if playing an audios buffer."""),
_(u""" * Control + P: Play/pause."""),
_(u""" * control+Shift+P: Play all."""),
_(u"""* 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."""),
_(u"""* 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))"""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* Deleted posts will display an error message when trying to view details about those. Before, the dialog was created and left blank."""),
_(u"""* Improvements in audio features present in Socializer:"""),
_(u""" * 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."""),
_(u""" * Now it is possible to create and delete audio albums again."""),
_(u""" * Fixed errors when moving songs to albums. Now everything works as expected."""),
_(u"""* Added documents to the list of supported files when adding attachments to a wall post or private message."""),
_(u"""* It is possible to enable or disable proxy from the preferences dialog. The application must be restarted for this change to take effect."""),
_(u"""* 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))"""),
_(u"""* 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."""),
_(u"""* It is possible to retrieve previous items for the home buffer and walls (current user's wall and any other timeline):"""),
_(u""" * For the home buffer, only a limited amount of items (around 700) can be loaded, supposedly due to VK API limits."""),
_(u""" * For walls, all posts should be possible to be loaded, however, testing with walls containing more than 2000 posts are not performed yet."""),
_(u"""* Added improvements to groups:"""),
_(u""" * 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."""),
_(u""" * You can create or delete all buffers for groups by pressing the menu key or right mouse click in the "communities" buffer."""),
_(u""" * 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."""),
_(u"""* Authentication errors should be handled gracefully by the application:"""),
_(u""" * 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."""),
_(u""" * If the user introduced incorrect or invalid data, Socializer will display an error and prompt the user again for valid information."""),
_(u""" * If there is a connection problem when opening Socializer, it will display an error and inform the user about the issue."""),
"",
_(u"""## Changes in version 0.18 (21.01.2019)"""),
"",
_(u"""* Changed authentication tokens in Socializer. It is mandatory to download a fresh copy of socializer and start a new configuration for your account."""),
_(u"""* 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."""),
_(u"""* There is an installer file for Socializer, available in our downloads page. Installed version of Socializer will be more confortable for some people."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* If you are not allowed to post in someone's wall, the post button will not be visible."""),
_(u"""* 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."""),
_(u"""* 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))"""),
_(u"""* 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))"""),
_(u"""* 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."""),
_(u"""* 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))"""),
_(u"""* 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))"""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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))"""),
_(u"""* 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."""),
_(u"""* Added functionality regarding comments in wall posts:"""),
_(u""" * 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."""),
_(u""" * A new "replies" field has been added to the comments' list."""),
_(u""" * When writing a comment, it is possible to do the same actions available for a post (translate, spell checking and adding attachments)."""),
"",
_(u"""## Changes in version 0.17 (01.01.2019)"""),
"",
_(u"""* Added support for Two factor authentication (2FA). ([#13,](https://code.manuelcortez.net/manuelcortez/socializer/issues/13))"""),
_(u"""* 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:"""),
_(u""" * 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."""),
_(u""" * 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."""),
_(u"""* Now it is possible to send voice messages from socializer. Voice messages are available from the "add" button in any conversation buffer."""),
_(u"""* tokens generated by socializer will never expire. ([#3,](https://code.manuelcortez.net/manuelcortez/socializer/issues/3))"""),
_(u"""* 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."""),
_(u"""* Audio albums are loaded correctly."""),
_(u"""* It is possible to play audios added by friends appearing in the news feed."""),
_(u"""* Adding and removing an audio file to your library works."""),
_(u"""* Unread messages will play a sound when focused."""),
_(u"""* Unread messages will be marked as read when user focuses them."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* Now Socializer will not send a notification every 5 minutes."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* Added popular and suggested songs. This will not work when using alternative tokens."""),
_(u"""* Now it is possible to update the status message, located in your profile."""),
_(u"""* 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."""),
_(u"""* Updated Russian translation: thanks to Дарья Ратникова."""),
_(u"""* Fixed some conditions, especially when rendering items in feeds, that were making the client to crash."""),
_(u"""* new versions will include documentation and changelog."""),
_(u"""* 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)"""),
"",
_(u"""## Changes in version 0.16 (13.12.2018)"""),
"",
_(u"""* Added two more buffers: "Pending requests" and "I follow", located in the people buffer, under "friendship requests"."""),
_(u"""* 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."""),
_(u"""* Improved the chat features present in the application. Read documentation to get a full understanding about how it works now."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* Added basic tagging for users in posts and comments. You can tag only people in your friends buffer."""),
_(u"""* Added a basic user profile viewer."""),
_(u"""* Added support for listening voice messages in chats. Currently it is not possible to send them."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* It is possible to play songs sent in a chat message by opening them from the attachments panel."""),
_(u"""* Reimplemented most of the audio playback methods (audio albums buffer still not working)."""),
_(u"""* Added some notifications and chat notifications when friends are online and offline. Most notifications can be configured from settings."""),
"",
_(u"""## Changes in build 2016.07.08 (08/07/2016)"""),
"",
_(u"""* Removed platform from "last seen" column in the friends list as it could cause some problems and it was being not so exact."""),
_(u"""* Now deleted audios are not parsed and displayed as "audio removed from library". They are silently ignored."""),
_(u"""* It's possible to open a friends timeline for others."""),
_(u"""* Fixed some strange bugs in the built version."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* When opened, socializer will try to create chat buffers for all unread messages."""),
_(u"""* Update some information on certain posts when an item is selected. For example, update the date of a post."""),
_(u"""* 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."""),
_(u"""* Included a brief manual in the help menu. Currently available only in English."""),
_(u"""* Included a context menu in list items. Currently there are functions not available. Menu for chat buffers is not implemented yet."""),
_(u"""* Implemented audio album load (in the music buffer), creation (in the application menu) and deletion (in the application menu, too)."""),
_(u"""* 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)."""),
_(u"""* 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 """),
_(u"""* 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."""),
_(u"""* Now is possible to press enter in the password or email/phone field and it'll do the action of the OK button."""),
_(u"""* 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."""),
_(u"""* Updated russian and spanish translations."""),
"",
_(u"""## Changes on build 2016.05.25"""),
"",
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* Posts from twitter are displayed in a better way (newline characters (\n) are handled properly instead being displayed)."""),
_(u"""* In the play all function, everything should be cleaned before start the new playback."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* Added your friendlist as a buffer. You can create chats from there by using the send message button."""),
"",
_(u"""## Changes for build 2016.04.5 (5/04/2016)"""),
"",
_(u"""* Updated russian and spanish translations."""),
_(u"""* Fixed minor bugs in the likes button for posts."""),
_(u"""* Now it's possible to open wall posts by pressing enter, as newsfeeds' posts."""),
_(u"""* 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."""),
_(u"""* 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."""),
_(u"""* Added more options in the search audio dialog. Now users could use more parameters and searches will be more precise."""),
_(u"""* 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)."""),
_(u"""* Added a changelog file which could be opened from the help menu."""),
_(u"""* Added a preferences dialogue and a new application menu in the menu bar. From this dialogue you can change the number of items to be loaded for every buffer."""),
]

View File

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from codecs import open
""" This script converts the hold documentation (saved in markdown files) in a python file with a list of strings to translate it using gettext.""" """ This script converts the hold documentation (saved in markdown files) in a python file with a list of strings to translate it using gettext."""
def prepare_documentation_in_file(fileSource, fileDest): def prepare_documentation_in_file(fileSource, fileDest):
@ -7,16 +6,16 @@ def prepare_documentation_in_file(fileSource, fileDest):
@fileSource str: A markdown(.md) file. @fileSource str: A markdown(.md) file.
@fileDest str: A file where this will put the new strings""" @fileDest str: A file where this will put the new strings"""
f1 = open(fileSource, "r", encoding="utf-8") f1 = open(fileSource, "r")
f2 = open(fileDest, "w", encoding="utf-8") f2 = open(fileDest, "w")
lns = f1.readlines() lns = f1.readlines()
f2.write("# -*- coding: utf-8 -*-\n") f2.write("# -*- coding: utf-8 -*-\n")
f2.write("documentation = [\n") f2.write("documentation = [\n")
for i in lns: for i in lns:
if "\n" == i or i.splitlines()[0] == "": if "\n" == i:
newvar = "\"\",\n" newvar = "\"\","
elif "\n" == i[-1]: elif "\n" == i[-1]:
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i.splitlines()[0]) newvar = "_(u\"\"\"%s\"\"\"),\n" % (i[:-1])
else: else:
newvar = "_(u\"\"\"%s\"\"\"),\n" % (i) newvar = "_(u\"\"\"%s\"\"\"),\n" % (i)
f2.write(newvar) f2.write(newvar)
@ -24,6 +23,5 @@ def prepare_documentation_in_file(fileSource, fileDest):
f2.write("]") f2.write("]")
f2.close() f2.close()
prepare_documentation_in_file("manual.md", "strings.py") prepare_documentation_in_file("manual.md", "strings.py")
prepare_documentation_in_file("changelog.md", "changelog.py") prepare_documentation_in_file("changelog.md", "changelog.py")

View File

@ -1,85 +1,59 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import gettext
import os
import locale
import markdown import markdown
import os
import shutil import shutil
from importlib import reload from codecs import open as _open
import languageHandler
# Languages already translated or translating the documentation. languageHandler.setLanguage("en")
documentation_languages = ["ru", "en", "es"]
# Changelog translated languages.
changelog_languages = ["ru", "en", "es"]
# this function will help us to have both strings.py and changelog.py without issues by installing a global dummy translation function.
def install_null_translation(name):
_ = gettext.NullTranslations()
_.install()
return
def get_translations(name):
""" Create translation instances for every language of the translated document. """
translations = {}
if "documentation" in name:
langs = documentation_languages
else:
langs = changelog_languages
for l in langs:
if l != "en":
_ = gettext.translation(name, os.path.join(os.getcwd(), "locales"), languages=[l])
translations[l] = _
else:
_ = gettext.NullTranslations()
translations[l] = _
return translations
def generate_document(lang, lang_name, document_type="documentation"):
""" Generates a document by using the provided lang object, which should be a translation, and lang_name, which should be the two letter code representing the language. """
if document_type == "documentation":
translation_file = "socializer-documentation"
markdown_file = markdown.markdown("\n".join([lang.gettext(s) if s != "" else s for s in strings.documentation[1:]]), extensions=["markdown.extensions.toc"])
title = lang.gettext(strings.documentation[0])
filename = "manual.html"
elif document_type == "changelog":
translation_file = "socializer-documentation"
markdown_file = markdown.markdown("\n".join([lang.gettext(s) if s != "" else s for s in changelog.documentation[1:]]), extensions=["markdown.extensions.toc"])
title = lang.gettext(changelog.documentation[0])
filename = "changelog.html"
first_html_block = """<!doctype html>
<html lang="%s">
<head>
<title>%s</title>
<meta charset="utf-8">
</head>
<body>
<header><h1>%s</h1></header>
""" % (lang_name, title, title)
first_html_block = first_html_block+ markdown_file
first_html_block = first_html_block + "\n</body>\n</html>"
if not os.path.exists(os.path.join("documentation", lang_name)):
os.mkdir(os.path.join("documentation", lang_name))
mdfile = open(os.path.join("documentation", lang_name, filename), "w", encoding="utf-8")
mdfile.write(first_html_block)
mdfile.close()
def create_documentation():
changelog_translations = get_translations("socializer-documentation")
documentation_translations = get_translations("socializer-documentation")
print("Creating documentation in the supported languages...\n")
if not os.path.exists("documentation"):
os.mkdir("documentation")
if os.path.exists(os.path.join("documentation", "license.txt")) == False:
shutil.copy(os.path.join("..", "license.txt"), os.path.join("documentation", "license.txt"))
for i in documentation_languages:
print("Creating documentation for: %s" % (i,))
generate_document(lang_name=i, lang=documentation_translations.get(i))
for i in changelog_languages:
print("Creating changelog for: %s" % (i,))
generate_document(lang_name=i, lang=changelog_translations.get(i), document_type="changelog")
print("Done")
install_null_translation("twblue-documentation")
import strings import strings
import changelog import changelog
# the list of supported language codes
languages = ["en", "ru", "es"]
def generate_document(language, document_type="documentation"):
reload(languageHandler)
if document_type == "documentation":
translation_file = "socializer-documentation"
languageHandler.setLanguage(language, translation_file)
reload(strings)
markdown_file = markdown.markdown("\n".join(strings.documentation[1:]), extensions=["markdown.extensions.toc"])
title = strings.documentation[0][1:]
filename = "manual.html"
elif document_type == "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][1:]
filename = "changelog.html"
first_html_block = """<!doctype html>
<html lang="%s">
<head>
<title>%s</title>
<meta charset="utf-8">
</head>
<body>
<header><h1>%s</h1></header>
""" % (language, title, title)
first_html_block = first_html_block+ markdown_file
first_html_block = first_html_block + "\n</body>\n</html>"
if not os.path.exists(os.path.join("documentation", language)):
os.mkdir(os.path.join("documentation", language))
mdfile = _open(os.path.join("documentation", language, filename), "w", encoding="utf-8")
mdfile.write(first_html_block)
mdfile.close()
def create_documentation():
print("Creating documentation in the supported languages...\n")
if not os.path.exists("documentation"):
os.mkdir("documentation")
if os.path.exists(os.path.join("documentation", "license.txt")) == False:
shutil.copy(os.path.join("..", "license.txt"), os.path.join("documentation", "license.txt"))
for i in languages:
print("Creating documentation for: %s" % (i,))
generate_document(i)
generate_document(i, "changelog")
print("Done")
create_documentation() create_documentation()

176
doc/languageHandler.py Normal file
View File

@ -0,0 +1,176 @@
import __builtin__
import os
import sys
import ctypes
import locale
import gettext
#import paths
import platform
# A fix for the mac locales
if platform.system() != 'Windows':
if locale.getlocale()[0] is None:
locale.setlocale(locale.LC_ALL, 'en_US')
#a few Windows locale constants
LOCALE_SLANGUAGE=0x2
LOCALE_SLANGDISPLAYNAME=0x6f
curLang="en"
def localeNameToWindowsLCID(localeName):
"""Retreave the Windows locale identifier (LCID) for the given locale name
@param localeName: a string of 2letterLanguage_2letterCountry or or just 2letterLanguage
@type localeName: string
@returns: a Windows LCID
@rtype: integer
"""
#Windows Vista is able to convert locale names to LCIDs
func_LocaleNameToLCID=getattr(ctypes.windll.kernel32,'LocaleNameToLCID',None)
if func_LocaleNameToLCID is not None:
localeName=localeName.replace('_','-')
LCID=func_LocaleNameToLCID(unicode(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]
if len(LCList)>0:
LCID=LCList[0]
else:
LCID=0
return LCID
def getLanguageDescription(language):
"""Finds out the description (localized full name) of a given local name"""
desc=None
if platform.system() == "Windows":
LCID=localeNameToWindowsLCID(language)
if LCID!=0:
buf=ctypes.create_unicode_buffer(1024)
if '_' not in language:
res=ctypes.windll.kernel32.GetLocaleInfoW(LCID,LOCALE_SLANGDISPLAYNAME,buf,1024)
else:
res=0
if res==0:
res=ctypes.windll.kernel32.GetLocaleInfoW(LCID,LOCALE_SLANGUAGE,buf,1024)
desc=buf.value
elif platform.system() == "Linux" or not desc:
desc={
"am":pgettext("languageName","Amharic"),
"an":pgettext("languageName","Aragonese"),
"es":pgettext("languageName","Spanish"),
"pt":pgettext("languageName","Portuguese"),
"ru":pgettext("languageName","Russian"),
"it":pgettext("languageName","italian"),
"tr":pgettext("languageName","Turkey"),
"gl":pgettext("languageName","Galician"),
"ca":pgettext("languageName","Catala"),
"eu":pgettext("languageName","Vasque"),
"pl":pgettext("languageName","polish"),
"ar":pgettext("languageName","Arabic"),
"ne":pgettext("languageName","Nepali"),
"sr":pgettext("languageName","Serbian (Latin)"),
}.get(language,None)
return desc
def getAvailableLanguages():
"""generates a list of locale names, plus their full localized language and country names.
@rtype: list of tuples
"""
#Make a list of all the locales found in NVDA's locale dir
l=[x for x in os.listdir("locales") if not x.startswith('.')]
l=[x for x in l if os.path.isfile('locales/%s/LC_MESSAGES/twblue-documentation.mo' % x)]
#Make sure that en (english) is in the list as it may not have any locale files, but is default
if 'en' not in l:
l.append('en')
l.sort()
#For each locale, ask Windows for its human readable display name
d=[]
for i in l:
desc=getLanguageDescription(i)
label="%s, %s"%(desc,i) if desc else i
d.append(label)
#include a 'user default, windows' language, which just represents the default language for this user account
l.append("system")
# 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)
def makePgettext(translations):
"""Obtaina pgettext function for use with a gettext translations instance.
pgettext is used to support message contexts,
but Python 2.7's gettext module doesn't support this,
so NVDA must provide its own implementation.
"""
if isinstance(translations, gettext.GNUTranslations):
def pgettext(context, message):
message = unicode(message)
try:
# Look up the message with its context.
return translations._catalog[u"%s\x04%s" % (context, message)]
except KeyError:
return message
else:
def pgettext(context, message):
return unicode(message)
return pgettext
def setLanguage(lang, translation_file="socializer-documentation"):
system = platform.system()
global curLang
try:
if lang=="system":
if system == "Windows":
windowsLCID=ctypes.windll.kernel32.GetUserDefaultUILanguage()
localeName=locale.windows_locale[windowsLCID]
else:
localeName=locale.getlocale()[0]
trans=gettext.translation(translation_file, localedir="locales", languages=[localeName])
curLang=localeName
else:
trans=gettext.translation(translation_file, localedir="locales", languages=[lang])
curLang=lang
localeChanged=False
#Try setting Python's locale to lang
try:
locale.setlocale(locale.LC_ALL, lang)
localeChanged=True
except:
pass
if not localeChanged and '_' in lang:
#Python couldn'tsupport the language_country locale, just try language.
try:
locale.setlocale(locale.LC_ALL, lang.split('_')[0])
except:
pass
#Set the windows locale for this thread (NVDA core) to this locale.
if system == "Windows":
LCID=localeNameToWindowsLCID(lang)
ctypes.windll.kernel32.SetThreadLocale(LCID)
except IOError:
trans=gettext.translation(translation_file,fallback=True)
curLang="en"
trans.install(unicode=True)
# Install our pgettext function.
__builtin__.__dict__["pgettext"] = makePgettext(trans)
def getLanguage():
return curLang
def normalizeLanguage(lang):
"""
Normalizes a language-dialect string in to a standard form we can deal with.
Converts any dash to underline, and makes sure that language is lowercase and dialect is upercase.
"""
lang=lang.replace('-','_')
ld=lang.split('_')
ld[0]=ld[0].lower()
#Filter out meta languages such as x-western
if ld[0]=='x':
return None
if len(ld)>=2:
ld[1]=ld[1].upper()
return "_".join(ld)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
Socializer's manual # Socializer's manual
## Introduction ## Introduction

File diff suppressed because it is too large Load Diff

View File

@ -1,114 +1,69 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
documentation = [ documentation = [
_(u"""# Socializer's manual """), _(u"""Socializer's manual """),
"", "",_(u"""## Introduction"""),
_(u"""## Introduction"""), "",_(u"""Socializer is an application to use [VK.com](https://vk.com) in an easy and accessible way with minimal CPU resource usage. Socializer will allow you to interact with the VK social network by giving you access to the most relevant features such as:"""),
"", "",_(u"""* Basic post creation in your wall (including photos)."""),
_(u"""Socializer is an application to use [VK.com](https://vk.com) in an easy and accessible way with minimal CPU resource usage. Socializer will allow you to interact with the VK social network by giving you access to the most relevant features such as:"""), _(u"""* (limited) audio support. (*)"""),
"",
_(u"""* Supports two factor authentication (2FA)."""),
_(u"""* Post creation in user and community walls."""),
_(u"""* audio support."""),
_(u"""* Post comments."""), _(u"""* Post comments."""),
_(u"""* like, unlike and repost other's posts."""), _(u"""* like, unlike and repost other's posts."""),
_(u"""* Open other's timelines so you could track their friends, posts, audio or video files."""), _(u"""* Open other's timelines so you could track their friends, posts or audio files."""),
_(u"""* Basic chat features."""), _(u"""* Basic chat features."""),
"", "",_(u"""\* Audio support in socializer is limited due to the restrictions VK has decided to apply for third party applications on december 2016."""),
_(u"""## Usage"""), "",_(u"""## Usage"""),
"", "",_(u"""In order to use socializer, you must have an account in the [VK](https://vk.com) website. The process for registering an account is very accessible and is not covered in this manual. In the documentation, it is assumed you have a registered account on VK and you are able to sign in in the website by providing your phone number or email address, and a password. You will require this data for signing in the application later."""),
_(u"""In order to use socializer, you must have an account in the [VK](https://vk.com) website. The process for registering an account is very accessible and is not covered in this manual. In the documentation, it is assumed you have a registered account on VK and you are able to sign in in the website by providing your phone number or email address, and a password. You will require this data for signing in the application later."""), "",_(u"""## authorising the application"""),
"", "",_(u"""First of all, it's necessary to authorise the application so it can access your VK account and act on your behalf. The authorisation process is quite simple, and will be required only once. In order to start the authorisation process, you just need to run the executable file called "socializer.exe" (on some computers it will appear only as socializer, depending if windows explorer is set to display file extensions or not). You may like to place a Windows shortcut in your desktop for an easier access to the application."""),
_(u"""## authorising the application"""), "",_(u"""If this is the first time you have launched socializer, you will see a message dialog asking you to proceed with the account authorisation process. It consists in providing the authentication data you normally use to sign in VK. It is very important to know that this data will be stored in a folder called config, located in the same folder where are the socializer files. Your config folder is a very important storage for your authentication data, so you must be sure you never will share it with anyone, mostly because your data is stored as plain text (this will be fixed in a future release and your data will be properly encrypted). Socializer will need your authentication data for acting in your behalf and offering you a better experience that what it could do with a simple access token. You must provide your phone number or email address in the first text box, and your password in the second. When pressing OK, your data will be saved and the application will start to retrieve all the required information for showing your buffers."""),
"", "",_(u"""Once started, the application will start loading your data (posts, audio files, conversations, friends). When done, it will show you a notification indicating that the program is ready."""),
_(u"""First of all, it's necessary to authorise the application so it can access your VK account and act on your behalf. The authorisation process is quite simple, and will be required only once. In order to start the authorisation process, you just need to run the executable file called "socializer.exe" (on some computers it will appear only as socializer, depending if windows explorer is set to display file extensions or not). You may like to place a Windows shortcut in your desktop for an easier access to the application."""), "",_(u"""## General concepts"""),
"", "",_(u"""Before starting to describe Socializer's usage, we'll explain some concepts that will be used extensively throughout this manual."""),
_(u"""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."""), "",_(u"""### Buffer"""),
"", "",_(u"""A buffer is a list of items that will manage the data which arrives from VK, after being processed by the application. When you configure your account on Socializer and start it, many buffers are created. Each of them may contain some of the items which this program works with: Newsfeed posts, wall posts, audio and video files, friendship requests and conversations. According to the buffer you are focusing, you will be able to do different actions with these items."""),
_(u"""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."""), "",_(u"""All buffers will be updated in one of the following ways:"""),
"", "",_(u"""* Periodically: Most buffers containing posts, audio or video files and people, will be updated periodically to reflect the new additions to them. Updates will be every 2 minutes for every buffer, so if you posted something and did not see the post in the buffer, you may need to wait a moment. There is an option, located in the buffer menu on the menu bar, which allows you to trigger a manual update in the current buffer."""),
_(u"""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."""), _(u"""* Real time: Conversation buffers will be updated every time someone sends a message to you. When an user sends you a message, if there is not a conversation buffer created to receive the message, a new conversation buffer will be opened automatically and the message will be placed on it. If you already have an opened conversation for the user sending the message, the message will be placed at the end of the buffer. A different sound will indicate whether a new conversation has been opened or an existing buffer gets updated."""),
"", "",_(u"""### item"""),
_(u"""Once started, the application will start loading your data (posts, audio files, conversations, friends). When done, it will show you a notification indicating that the program is ready."""), "",_(u"""An item is an element representing some data provided by VK. Items are separated in buffers which stores items of the same type: Audio buffers will contain only audio files, wall buffers will be full of wall posts. The only exception to this rule is the newsfeed buffer, which can contain different kind of items. Actions are available in a per-item basis, allowing certain items to be treated differently than others and showing different dialogs, depending in the kind of data VK sends for them. All items show a menu with their available actions by focusing them in the list and pressing the menu key or a right mouse click."""),
"", "",_(u"""The following is a brief description of the kind of items socializer can work with, and what actions are available for those."""),
_(u"""## General concepts"""), "",_(u"""* Newsfeed post: It represents a post displayed in your "home" page on VK. It may contain a variety of information based in what you or your friends do. A newsfeed item may contain information about new audios added to your friend's library, new people added to friends, wall posts, reposts and new photos added. Depending on the kind of data VK has supplied, the item can open a dialog showing information about the post, a list displaying the people added to friends, or a dialog displaying information for every audio added to library. Take into account that it is not possible to play an audio item from the newsfeed buffer due to limits placed by VK, however, you may add it to your library and play it from your "my music" folder. If a wall post contains a long message, the first 140 characters will be displayed only. You can open the post to read the full message in the dialog. Available options for this item are different depending in the information the item contains. You can open or view the profile of the user that generated the item, like, dislike or add a comment to a post."""),
"", _(u"""* Wall post: Represent a post in an user's wall. This posts will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, the first 140 characters will be displayed only. You can open the post to read the full message in the dialog. When opened (by pressing enter or the open option in the associated menu), it will show a dialogue where you can read the message, see and interact with attachment files (by searching the list and pressing enter in the focused attachment to open it), see the photos included in the post, read information related to likes and times the post has been shared, and read all comments. Additionally, you can share the post, indicate you like it, or add a comment. You can cycle through every item in the dialog by pressing tab."""),
_(u"""Before starting to describe Socializer's usage, we'll explain some concepts that will be used extensively throughout this manual."""), _(u"""* Audio: It represent an audio uploaded to the VK'S platform. Actions available for this item are only opening the audio in a dialog and play it due to limitations in access to audio features. When opened, it will be displayed in a dialog allowing you to read the title of the song, artist name, duration and a few buttons: play and download. You can control playback of audio items from the buffer by using the player menu on the menu bar."""),
"", _(u"""* Video: It represent a video uploaded to the VK'S platform. Actions available for this item are opening the video in your default web browser and move it to a video album. When opened, it will open a web browser and play the video automatically due to VK limitations in access to video files."""),
_(u"""### Buffer"""), _(u"""* person: It contains information about a VK user, this item is present in all buffers under the "people" category. Actions available for this item are view user profile, send message and create a timeline, which is a special buffer to track all posts, friends or audios owned by the user. When opened, it will display the profile of this user in a dialog and will provide actions to send a message to the user, or view other sections of her/his profile."""),
"",
_(u"""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."""),
"",
_(u"""All buffers will be updated in one of the following ways:"""),
"",
_(u"""* Periodically: Most buffers containing posts, audio or video files and people, will be updated periodically to reflect the new additions to them. Updates will be every 2 minutes for every buffer, so if you posted something and did not see the post in the buffer, you may need to wait a moment. There is an option, located in the buffer menu on the menu bar, which allows you to trigger a manual update in the current buffer."""),
_(u"""* Real time: Conversation buffers will be updated every time someone sends a message to you. When an user sends you a message, if there is not a conversation buffer created to receive the message, a new conversation buffer will be opened automatically and the message will be placed on it. If you already have an opened conversation for the user sending the message, the message will be placed at the end of the buffer. A different sound will indicate whether a new conversation has been opened or an existing buffer gets updated. 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."""),
"",
_(u"""### item"""),
"",
_(u"""An item is an element representing some data provided by VK. Items are separated in buffers which stores items of the same type: Audio buffers will contain only audio files, wall buffers will be full of wall posts. The only exception to this rule is the newsfeed buffer, which can contain different kind of items. Actions are available in a per-item basis, allowing certain items to be treated differently than others and showing different dialogs, depending in the kind of data VK sends for them. All items show a menu with their available actions by focusing them in the list and pressing the menu key or a right mouse click."""),
"",
_(u"""The following is a brief description of the kind of items socializer can work with, and what actions are available for those."""),
"",
_(u"""* Newsfeed post: It represents a post displayed in your "home" page on VK. It may contain a variety of information based in what you or your friends do. A newsfeed item may contain information about new audios added to your friend's library, new people added to friends, wall posts, reposts and new photos added. Depending on the kind of data VK has supplied, the item can open a dialog showing information about the post, a list displaying the people added to friends, or a dialog displaying information for every audio added to library. 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."""),
_(u"""* Wall post: Represents a post in an user's wall. This post will be similar to wall posts displayed in the newsfeed. If a wall post contains a long message, only the first 140 characters will be displayed. You can open the post to read the full message in the dialog. When opened (by pressing enter or the open option in the associated menu), it will show a dialogue where you can read the message, see how many times the post has been viewed by other users, interact with attachment files (by searching the list and pressing enter in the focused attachment to open it), see the photos included in the post, read information related to likes and times the post has been shared, read and reply to comments. Additionally, you can share the post, indicate you like it, or add a comment. You can cycle through every item in the dialog by pressing tab."""),
_(u"""* Audio: It represents an audio uploaded to the VK'S platform. Actions available for this item are opening the audio in a dialog, add or remove it from your library, move the audio to a playlist, and play it. When opened, it will be displayed in a dialog allowing you to read the title of the song, artist name, duration and a few buttons: play, add or remove from your library and download. You can control playback of audio items from the buffer by using the player menu on the menu bar or the corresponding keyboard shortcuts. Additionally, it is possible to select multiple audios in the same buffer to perform specific actions on them, such as play, remove or add the selected audios to a playlist. In order to select multiple audios, press the spacebar in every audio item you want to select. You will hear a sound when an item is selected, and when you focus a selected audio. When you're done, press enter to play all the selected audios or use the context menu to see available actions. All actions will be applied in the selected audios."""),
_(u"""* Video: It represents a video uploaded to the VK'S platform. Actions available for this item are opening the video in your default web browser and move it to a video album. When opened, it will open a web browser and play the video automatically due to VK limitations in access to video files."""),
_(u"""* person: It contains information about a VK user, this item is present in all buffers under the "people" category. Actions available for this item are view user profile, send message and create a timeline, which is a special buffer to track all posts, friends, audios or videos owned by the user. When opened, it will display the profile of this user in a dialog and will provide actions to send a message to the user, or view other sections of her/his profile."""),
_(u"""* Message: A message appears only in conversation buffers and represents a chat message. It may include a list of attached files that will be displayed in a separated list. You can tab to that list (from the history) and press enter in the attached file you want to open. Chat items are marked as read automatically as soon as they are focused."""), _(u"""* Message: A message appears only in conversation buffers and represents a chat message. It may include a list of attached files that will be displayed in a separated list. You can tab to that list (from the history) and press enter in the attached file you want to open. Chat items are marked as read automatically as soon as they are focused."""),
"", "",_(u"""## Main interface"""),
_(u"""## Main interface"""), "",_(u"""The graphical user interface of Socializer consists of a window containing:"""),
"", "",_(u"""* a menu bar accomodating five menus (application, Me, buffer, player and help),"""),
_(u"""The graphical user interface of Socializer consists of a window containing:"""), _(u"""* One tree view,"""),
"", _(u"""* One list of items"""),
_(u"""* a menu bar accomodating five menus (application, Me, buffer, player and help),"""),
_(u"""* 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,"""),
_(u"""* One list of items, which also accepts the menu key to display actions available for the selected item,"""),
_(u"""* Some buttons, depending which is the focused buffer."""), _(u"""* Some buttons, depending which is the focused buffer."""),
"", "",_(u"""The actions that are available for every item will be described later."""),
_(u"""The actions that are available for every item will be described later."""), "",_(u"""In summary, the GUI contains two core components. These are the controls you will find while pressing the Tab key within the program's interface, and the different elements present on the menu bar."""),
"", "",_(u"""### Buttons in the application"""),
_(u"""In summary, the GUI contains two core components. These are the controls you will find while pressing the Tab key within the program's interface, and the different elements present on the menu bar."""), "",_(u"""* Post: this button opens up a dialogue box to write a post in your wall. For the moment, only posting in your own wall is supported. You can upload a picture by pressing the "attach" button and the photo button in the dialog which will appear, check spelling or translate your message by selecting one of the available buttons in the dialogue box. In addition, you can tag a friend in your post by pressing the corresponding button for that purpose. Also it is possible to configure the privacy settings for your post by allowing all users or just your friends to read it. Press the send button to send the post."""),
"",
_(u"""### Buttons in the application"""),
"",
_(u"""* Post: this button opens up a dialogue box to write a post in the wall of the focused user. For example, if you are in the "my wall" buffer you will send a post to your own wall, but if you are in an user timeline the post will be sent to the owner of the timeline. You can upload an attachment by pressing the "attach" button and choosing between uploading a photo, audio file or document in the dialog which will appear, check spelling or translate your message by selecting one of the available buttons in the dialogue box. In addition, you can tag a friend in your post by pressing the corresponding button for that purpose. Also it is possible to configure the privacy settings for your post by allowing all users or just your friends to read it. Press the send button to send the post."""),
_(u"""* 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"""),
_(u"""* Play: In audio buffers, plays the focused song. In video buffers, this button will open a web browser for playing the focused video, due to a limitation VK placed to third party developers with videos."""), _(u"""* Play: In audio buffers, plays the focused song. In video buffers, this button will open a web browser for playing the focused video, due to a limitation VK placed to third party developers with videos."""),
_(u"""* Play all: In audio buffers, play all songs starting from the focused buffer, until the last item in the list."""), _(u"""* Play all: In audio buffers, play all songs starting from the focused buffer, until the last item in the list."""),
_(u"""* Send message: Send a message to a friend, which will open a conversation buffer if it does not exist already. Conversation buffers contain a full conversation, accommodating chat messages, between the current user and someone else. You can type your message in the provided box and press enter to send it to your friend. Additionally, You can 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."""), _(u"""* Send message: Send a message to a friend, which will open a conversation buffer if it does not exist already. Conversation buffers contain a full conversation, accommodating chat messages, between the current user and someone else. You can type your message in the provided box and press enter to send it to your friend. Additionally, you can add an attachment (for the moment, only attaching an audio file from your library is supported) and open attachments sent in the focused message by pressing tab and finding them in the attachments list."""),
"", "",_(u"""Bear in mind that buttons will appear according to which actions are possible on the list you are browsing."""),
_(u"""Bear in mind that buttons will appear according to which actions are possible on the list you are browsing."""), "",_(u"""## Menus"""),
"", "",_(u"""Visually, Towards the top of the main application window, can be found a menu bar which contains many of the same functions as listed in the previous section, together with some additional items. To access the menu bar, press the alt key. You will find five menus listed: application, Me, buffer, player and help. This section describes the items on each one of them."""),
_(u"""## Menus"""), "",_(u"""### Application menu"""),
"", "",_(u"""* Create: opens a menu where you can create a new album. At the moment, only video albums are supported."""),
_(u"""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."""), _(u"""* Delete: opens a menu where you can delete an already existing album owned by yourself. Only video albums are supported at this time."""),
"",
_(u"""### Application menu"""),
"",
_(u"""* Create: opens a menu where you can create a new album. At the moment, only audio and video albums are supported."""),
_(u"""* 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."""),
_(u"""* blacklist: Opens a dialog which allows you to manage blocked people on VK."""),
_(u"""* Manage accounts: Opens up a dialogue from where you are able to add or delete an account in socializer. If you have more than an account, you will be asked at startup for the account you want to use in the application. You can use an account at once, but it is possible to have multiple accounts and switch between them by restarting the application."""),
_(u"""* Preferences: Opens a dialogue which lets you configure settings for the entire application."""), _(u"""* Preferences: Opens a dialogue which lets you configure settings for the entire application."""),
"", "",_(u"""### Me menu"""),
_(u"""### Me menu"""), "",_(u"""* Profile: Opens a menu with several options to do in your profile:"""),
"",
_(u"""* Profile: Opens a menu with several options to do in your profile:"""),
_(u""" * View profile: Displays your profile in a dialog in the application."""), _(u""" * View profile: Displays your profile in a dialog in the application."""),
_(u""" * Open in browser: Redirects you to your profile in vk.com."""), _(u""" * Open in browser: Redirects you to your profile in vk.com."""),
_(u"""* 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."""), "",_(u"""### Buffer menu"""),
"", "",_(u"""* New timeline: Lets you open a user's timeline by choosing the user in a dialog box. You can choose which items you want to track: wall posts, friends or audio items. It is created when you press enter. If you invoke this option relative to a user that has no items of the kind you specified, the operation will fail. If you try creating an existing timeline the program will warn you and will not create it again."""),
_(u"""### Buffer menu"""),
"",
_(u"""* New timeline: Lets you open an user's timeline by choosing the user in a dialog box. You can choose which items you want to track: wall posts, videos, friends or audio items. It is created when you press enter. If you invoke this option relative to a user that has no items of the kind you specified, the operation will fail. If you try creating an existing timeline the program will warn you and will not create it again."""),
_(u"""* Search: Shows a menu where you can search for audios or videos on VK. Search results will be created in a new buffer inside "music" or "videos"."""), _(u"""* Search: Shows a menu where you can search for audios or videos on VK. Search results will be created in a new buffer inside "music" or "videos"."""),
_(u"""* Update buffer: Performs a manual update operation in the buffer, which will retrieve all new items present in the social network since the last update."""), _(u"""* Update buffer: Performs a manual update operation in the buffer, which will retrieve all new items present in the social network since the last update."""),
_(u"""* Load previous items: This allows more items to be loaded for the specified buffer. Bear in mind that not all buffers support this setting."""), _(u"""* Load previous items: This allows more items to be loaded for the specified buffer. Bear in mind that not all buffers support this setting."""),
_(u"""* Remove buffer: dismisses the list you're on, if possible."""), _(u"""* Destroy: dismisses the list you're on, if possible."""),
"", "",_(u"""### Player menu"""),
_(u"""### Player menu"""), "",_(u"""* Play: Plays the currently focused audio item, if the current buffer contains audio files. If not, plays the focused audio in the "my music" buffer."""),
"",
_(u"""* Play: Plays the currently focused audio item, if the current buffer contains audio files. If not, plays the focused audio in the "my music" buffer."""),
_(u"""* Play all: Plays all audio items in the current buffer or the "my music" buffer, starting by the currently focused audio item until the last audio in the list."""), _(u"""* Play all: Plays all audio items in the current buffer or the "my music" buffer, starting by the currently focused audio item until the last audio in the list."""),
_(u"""* Stop: Stops audio playback."""), _(u"""* Stop: Stops audio playback."""),
_(u"""* Previous: Plays the previous audio in the buffer or the last item in the list, if the current audio was the first on the buffer."""), _(u"""* 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."""),
@ -117,72 +72,24 @@ _(u"""* Shuffle: Plays all audios in the current buffer or the "my music" buffer
_(u"""* Volume up: Increases volume by 5%."""), _(u"""* Volume up: Increases volume by 5%."""),
_(u"""* Volume down: decreases volume by 5%."""), _(u"""* Volume down: decreases volume by 5%."""),
_(u"""* Mute: Mutes audio playback, setting volume to 0%."""), _(u"""* Mute: Mutes audio playback, setting volume to 0%."""),
"", "",_(u"""### help menu"""),
_(u"""### help menu"""), "",_(u"""* About Socializer: shows the credits of the program."""),
"",
_(u"""* About Socializer: shows the credits of the program."""),
_(u"""* Documentation: opens up this file, where you can read some useful program concepts."""), _(u"""* Documentation: opens up this file, where you can read some useful program concepts."""),
_(u"""* Check for updates: every time you open the program it automatically checks for new versions. If an update is available, it will ask you if you want to download the update. If you accept, the updating process will commence. When complete, Socializer will be restarted. This item checks for new updates without having to restart the application."""), _(u"""* Check for updates: every time you open the program it automatically checks for new versions. If an update is available, it will ask you if you want to download the update. If you accept, the updating process will commence. When complete, Socializer will be restarted. This item checks for new updates without having to restart the application."""),
_(u"""* Changelog: opens up a document with the list of changes from the current version to the earliest."""), _(u"""* Changelog: opens up a document with the list of changes from the current version to the earliest."""),
_(u"""* Open logs directory: Opens windows explorer in the logs directory, useful to include your logs in a bug report."""), "",_(u"""## Keyboard shortcuts"""),
_(u"""* Open config directory: Opens Windows explorer in your config directory."""), "",_(u"""## configuration"""),
_(u"""* 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."""), "",_(u"""### The general tab"""),
"", "",_(u"""### The chats tab"""),
_(u"""## Keyboard shortcuts"""), "",_(u"""## License and source code"""),
"", "",_(u"""Socializer is free software, licensed under the GNU GPL license, either version 2 or, at your option, any later version. You can view the license in the file named license.txt, or online at <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>."""),
_(u"""Socializer includes some keyboard shortcuts, available from any buffer. Here you have the list of the available shortcuts:"""), "",_(u"""The source code of the program is available at <https://code.manuelcortez.net/manuelcortez/socializer>."""),
"", "",_(u"""## Contact"""),
_(u"""* 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."""), "",_(u"""If you still have questions after reading this document, if you wish to collaborate to the project in some other way, or if you simply want to get in touch with the application developer, follow the VK account of [Manuel Cortez.](https://vk.com/manuelcortez) You can also visit [The project website.](https://manuelcortez.net/socializer)"""),
_(u"""* Alt+Up/down: Increase and decrease audio volume by 5%."""), "",_(u"""## Credits"""),
_(u"""* 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."""), "",_(u"""Socializer is developed and mantained by [Manuel Cortez,](https://manuelcortez.net) with contributions by [Anibal Hernandez](https://dragodark.com)"""),
_(u"""* 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."""), "",_(u"""We would also like to thank the translators of Socializer, who have allowed the spreading of the application."""),
_(u"""* Alt+Left: Play the previous song."""), "",_(u"""* English: Manuel Cortéz."""),
_(u"""* Alt+Right: Play the next song."""), _(u"""* Spanish: Manuel Cortéz."""),
"", _(u"""* Russian: Valeria K."""),
_(u"""## configuration"""),
"",
_(u"""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."""),
"",
_(u"""### General tab"""),
"",
_(u"""* Language: allows you to switch the interface language for socializer. The application must be restarted after changing the language."""),
_(u"""* 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."""),
_(u"""* Use proxy: for countries where Vk is blocked by the internet providers, this settings allows socializer to connect via a proxy server already included in the application."""),
_(u"""* 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."""),
"",
_(u"""### Buffer settings tab"""),
"",
_(u"""* Number of items to load for newsfeed and wall buffers: Allows you to specify how many items should be retrieved from VK in the newsfeed buffer and when opening walls for other users. Default is 50 items, and maximum is 100."""),
_(u"""* Number of items to load in video buffers: Allows you to specify how many items should be retrieved from VK in video buffers. Default is 50, maximum value is 200."""),
_(u"""* Number of items to load in conversation buffers: allows you to specify how many messages Socializer will retrieve when loading a conversation. Default is 50, maximum value is 200."""),
"",
_(u"""### Chat settings tab"""),
"",
_(u"""* 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."""),
_(u"""* 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."""),
"",
_(u"""### Optional buffers tab"""),
"",
_(u"""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."""),
"",
_(u"""## License and source code"""),
"",
_(u"""Socializer is free software, licensed under the GNU GPL license, either version 2 or, at your option, any later version. You can view the license in the file named license.txt, or online at <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>."""),
"",
_(u"""The source code of the program is available at <https://code.manuelcortez.net/manuelcortez/socializer>."""),
"",
_(u"""## Contact"""),
"",
_(u"""If you still have questions after reading this document, if you wish to collaborate to the project in some other way, or if you simply want to get in touch with the team, [join the Socializer's community in VK.](https://vk.com/socializer.club) You can also visit [The project website.](http://socializer.su)"""),
"",
_(u"""## Credits"""),
"",
_(u"""Socializer is developed and maintained by [Manuel Cortez.](https://manuelcortez.net)"""),
"",
_(u"""We would also like to thank the translators of Socializer, who have allowed the spreading of the application."""),
"",
_(u"""* English: Manuel Cortéz."""),
_(u"""* Russian: Дарья Ратникова."""),
"",
_(u"""Special thanks to Дарья Ратникова, as she also manages the Socializer's community in VK, translates the website and the documentation into Russian."""),
] ]

View File

@ -1,5 +0,0 @@
from babel.messages.frontend import CommandLineInterface
CommandLineInterface().run(['pybabel', 'extract', '-o', '..\scripts\socializer-documentation.pot', '.'])
#CommandLineInterface().run(['pybabel','compile','-d','../src/locales'])
CommandLineInterface().run(['pybabel','update', '--input-file', 'socializer-documentation.pot', '--domain', 'socializer-documentation', '--output-dir', '../src/locales'])

View File

@ -1,23 +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 pywin32
pyenchant
markdown markdown
vk_api # For the moment we will use the modified vk_api version that does not try to include enum34 and
vkaudiotoken # already fixed the caption for wall uploaded photos.
# Hopefully I can uncomment this in the near future when my changes will get merged upstream.
#vk_api
bs4 bs4
configobj configobj
pypubsub pypubsub
requests
requests-oauthlib requests-oauthlib
future future
arrow arrow
backports.functools_lru_cache backports.functools_lru_cache
googletrans yandex.translate
mutagen mutagen
mock mock
babel # forked repositories previously found at http://q-continuum.net
nuitka git+https://code.manuelcortez.net/manuelcortez/libloader
pyenchant git+https://code.manuelcortez.net/manuelcortez/platform_utils
git+https://github.com/accessibleapps/libloader git+https://github.com/chrisnorman7/sound_lib
git+https://github.com/accessibleapps/platform_utils git+https://code.manuelcortez.net/manuelcortez/accessible_output2
git+https://github.com/accessibleapps/sound_lib # Modified vk_api.
git+https://github.com/accessibleapps/accessible_output2 git+https://github.com/manuelcortez/vk_api

58
scripts/build.sh Normal file
View File

@ -0,0 +1,58 @@
#!/bin/bash
# Define paths for a regular use, if there are not paths for python32 or 64, these commands will be taken.
pythonpath32="/C/python27x86"
pandocpath="pandoc.exe"
help () {
echo -e "$0 | usage:"
echo -e "$0 | \t./build.sh [-py32path <path to python for 32 bits> | -h]"
}
# parsing options from the command line
while [[ $# > 1 ]]
do
key="$1"
shift
case $key in
-py32path)
pythonpath32="$1"
shift
;;
-help)
help
;;
*)
help
esac
done
cd ../src
if [ -d build/ ];
then
rm -rf build
fi
if [ -d dist/ ];
then
rm -rf dist
fi
if [ -d documentation/ ];
then
rm -rf documentation
fi
mkdir documentation
cp ../changelog.md documentation/changelog.md
cd documentation
$pandocpath -s changelog.md -o changelog.html
rm changelog.md
cd ..
cd ../doc
$pythonpath32/python.exe generator.py
mv -f en ../src/documentation/
mv -f es ../src/documentation/
cd ../src
$pythonpath32/python.exe "setup.py" "py2exe" "--quiet"
mv -f dist ../nightly/socializer
rm -rf build
cd ../nightly
$pythonpath32/python.exe make_zipversion.py

View File

@ -1,26 +0,0 @@
#! /usr/bin/env python# -*- coding: iso-8859-1 -*-
import shutil
import os
import accessible_output2
import sound_lib
import enchant
dist_folder = "socializer.dist"
accessible_output2_files = accessible_output2.find_datafiles()
final_folder = os.path.join(dist_folder, accessible_output2_files[0][0])
module_dir = os.path.dirname(accessible_output2_files[0][1][0])
shutil.copytree(module_dir, final_folder)
soundlib_files = sound_lib.find_datafiles()
final_folder = os.path.join(dist_folder, soundlib_files[0][0])
os.makedirs(final_folder, exist_ok=True)
for file in soundlib_files[0][1]:
shutil.copy(file, final_folder)
enchant_path = os.path.dirname(enchant.__file__)
final_folder = os.path.join(dist_folder, "enchant")
if os.path.exists(final_folder):
os.remove(final_folder)
os.makedirs(final_folder, exist_ok=True)
shutil.copytree(os.path.join(enchant_path, "data"), os.path.join(final_folder, "data"))

View File

@ -1,32 +0,0 @@
#! /usr/bin/env python
import os
import json
print("Generating update files for Socializer...")# Determine if we are going to write stable or alpha update file.
# Stable file is when we build tags and alpha otherwise.
version = os.environ.get("CI_COMMIT_TAG") or os.environ.get("CI_COMMIT_SHORT_SHA")
if os.environ.get("CI_COMMIT_TAG") == None:
version_type = "alpha"
else:
version_type = "stable"
print("Version detected: %s" % (version_type,))
# Read update description and URL'S
if version_type == "alpha":
description = os.environ.get("CI_COMMIT_MESSAGE")
urls = dict(Windows32="https://files.mcvsoftware.com/socializer/alpha/socializer_x86.zip", Windows64="https://files.mcvsoftware.com/socializer/alpha/socializer_x64.zip")
else:
with open("update-description",'r') as f:
description = f.read()
urls=dict(Windows32="https://files.manuelcortez.net/socializer/{v}/socializer_{v}_x86.zip".format(v=version[1:]), Windows64="https://files.manuelcortez.net/socializer/{v}/socializer_{v}_x64.zip".format(v=version[1:]))
# build the main dict object
data = dict(current_version=version, description=description, downloads=urls)
print("Generating file with the following arguments: %r" % (data,))
if version_type == "alpha":
updatefile = "alpha.json"
else:
updatefile = "stable.json"
f = open(updatefile, "w")
json.dump(data, f, ensure_ascii=False)
f.close()

View File

@ -6,7 +6,10 @@ import sys
def create_archive(): def create_archive():
os.chdir("..\\src") os.chdir("..\\src")
print("Creating zip archive...") print("Creating zip archive...")
folder = "socializer.dist" if sys.version[0] == "3":
folder = "dist/main"
else:
folder = "dist"
shutil.make_archive("socializer", "zip", folder) shutil.make_archive("socializer", "zip", folder)
# if os.path.exists("dist"): # if os.path.exists("dist"):
# shutil.rmtree("dist") # shutil.rmtree("dist")

669
scripts/pygettext.py Normal file
View File

@ -0,0 +1,669 @@
#! /usr/bin/env python
# -*- coding: iso-8859-1 -*-
# Originally written by Barry Warsaw <barry@zope.com>
#
# Minimally patched to make it even more xgettext compatible
# by Peter Funk <pf@artcom-gmbh.de>
#
# 2002-11-22 Jürgen Hermann <jh@web.de>
# Added checks that _() only contains string literals, and
# command line args are resolved to module lists, i.e. you
# can now pass a filename, a module or package name, or a
# directory (including globbing chars, important for Win32).
# Made docstring fit in 80 chars wide displays using pydoc.
#
# for selftesting
try:
import fintl
_ = fintl.gettext
except ImportError:
_ = lambda s: s
__doc__ = _("""pygettext -- Python equivalent of xgettext(1)
Many systems (Solaris, Linux, Gnu) provide extensive tools that ease the
internationalization of C programs. Most of these tools are independent of
the programming language and can be used from within Python programs.
Martin von Loewis' work[1] helps considerably in this regard.
There's one problem though; xgettext is the program that scans source code
looking for message strings, but it groks only C (or C++). Python
introduces a few wrinkles, such as dual quoting characters, triple quoted
strings, and raw strings. xgettext understands none of this.
Enter pygettext, which uses Python's standard tokenize module to scan
Python source code, generating .pot files identical to what GNU xgettext[2]
generates for C and C++ code. From there, the standard GNU tools can be
used.
A word about marking Python strings as candidates for translation. GNU
xgettext recognizes the following keywords: gettext, dgettext, dcgettext,
and gettext_noop. But those can be a lot of text to include all over your
code. C and C++ have a trick: they use the C preprocessor. Most
internationalized C source includes a #define for gettext() to _() so that
what has to be written in the source is much less. Thus these are both
translatable strings:
gettext("Translatable String")
_("Translatable String")
Python of course has no preprocessor so this doesn't work so well. Thus,
pygettext searches only for _() by default, but see the -k/--keyword flag
below for how to augment this.
[1] http://www.python.org/workshops/1997-10/proceedings/loewis.html
[2] http://www.gnu.org/software/gettext/gettext.html
NOTE: pygettext attempts to be option and feature compatible with GNU
xgettext where ever possible. However some options are still missing or are
not fully implemented. Also, xgettext's use of command line switches with
option arguments is broken, and in these cases, pygettext just defines
additional switches.
Usage: pygettext [options] inputfile ...
Options:
-a
--extract-all
Extract all strings.
-d name
--default-domain=name
Rename the default output file from messages.pot to name.pot.
-E
--escape
Replace non-ASCII characters with octal escape sequences.
-D
--docstrings
Extract module, class, method, and function docstrings. These do
not need to be wrapped in _() markers, and in fact cannot be for
Python to consider them docstrings. (See also the -X option).
-h
--help
Print this help message and exit.
-k word
--keyword=word
Keywords to look for in addition to the default set, which are:
%(DEFAULTKEYWORDS)s
You can have multiple -k flags on the command line.
-K
--no-default-keywords
Disable the default set of keywords (see above). Any keywords
explicitly added with the -k/--keyword option are still recognized.
--no-location
Do not write filename/lineno location comments.
-n
--add-location
Write filename/lineno location comments indicating where each
extracted string is found in the source. These lines appear before
each msgid. The style of comments is controlled by the -S/--style
option. This is the default.
-o filename
--output=filename
Rename the default output file from messages.pot to filename. If
filename is `-' then the output is sent to standard out.
-p dir
--output-dir=dir
Output files will be placed in directory dir.
-S stylename
--style stylename
Specify which style to use for location comments. Two styles are
supported:
Solaris # File: filename, line: line-number
GNU #: filename:line
The style name is case insensitive. GNU style is the default.
-v
--verbose
Print the names of the files being processed.
-V
--version
Print the version of pygettext and exit.
-w columns
--width=columns
Set width of output to columns.
-x filename
--exclude-file=filename
Specify a file that contains a list of strings that are not be
extracted from the input files. Each string to be excluded must
appear on a line by itself in the file.
-X filename
--no-docstrings=filename
Specify a file that contains a list of files (one per line) that
should not have their docstrings extracted. This is only useful in
conjunction with the -D option above.
If `inputfile' is -, standard input is read.
""")
import os
import imp
import sys
import glob
import time
import getopt
import token
import tokenize
import operator
__version__ = '1.5'
default_keywords = ['_']
DEFAULTKEYWORDS = ', '.join(default_keywords)
EMPTYSTRING = ''
# The normal pot-file header. msgmerge and Emacs's po-mode work better if it's
# there.
pot_header = _('''\
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\\n"
"POT-Creation-Date: %(time)s\\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"
"MIME-Version: 1.0\\n"
"Content-Type: text/plain; charset=CHARSET\\n"
"Content-Transfer-Encoding: ENCODING\\n"
"Generated-By: pygettext.py %(version)s\\n"
''')
def usage(code, msg=''):
print >> sys.stderr, __doc__ % globals()
if msg:
print >> sys.stderr, msg
sys.exit(code)
escapes = []
def make_escapes(pass_iso8859):
global escapes
if pass_iso8859:
# Allow iso-8859 characters to pass through so that e.g. 'msgid
# "Höhe"' would result not result in 'msgid "H\366he"'. Otherwise we
# escape any character outside the 32..126 range.
mod = 128
else:
mod = 256
for i in range(256):
if 32 <= (i % mod) <= 126:
escapes.append(chr(i))
else:
escapes.append("\\%03o" % i)
escapes[ord('\\')] = '\\\\'
escapes[ord('\t')] = '\\t'
escapes[ord('\r')] = '\\r'
escapes[ord('\n')] = '\\n'
escapes[ord('\"')] = '\\"'
def escape(s):
global escapes
s = list(s)
for i in range(len(s)):
s[i] = escapes[ord(s[i])]
return EMPTYSTRING.join(s)
def safe_eval(s):
# unwrap quotes, safely
return eval(s, {'__builtins__':{}}, {})
def normalize(s):
# This converts the various Python string types into a format that is
# appropriate for .po files, namely much closer to C style.
lines = s.split('\n')
if len(lines) == 1:
s = '"' + escape(s) + '"'
else:
if not lines[-1]:
del lines[-1]
lines[-1] = lines[-1] + '\n'
for i in range(len(lines)):
lines[i] = escape(lines[i])
lineterm = '\\n"\n"'
s = '""\n"' + lineterm.join(lines) + '"'
return s
def containsAny(str, set):
"""Check whether 'str' contains ANY of the chars in 'set'"""
return 1 in [c in str for c in set]
def _visit_pyfiles(list, dirname, names):
"""Helper for getFilesForName()."""
# get extension for python source files
if not globals().has_key('_py_ext'):
global _py_ext
_py_ext = [triple[0] for triple in imp.get_suffixes()
if triple[2] == imp.PY_SOURCE][0]
# don't recurse into CVS directories
if 'CVS' in names:
names.remove('CVS')
# add all *.py files to list
list.extend(
[os.path.join(dirname, file) for file in names
if os.path.splitext(file)[1] == _py_ext]
)
def _get_modpkg_path(dotted_name, pathlist=None):
"""Get the filesystem path for a module or a package.
Return the file system path to a file for a module, and to a directory for
a package. Return None if the name is not found, or is a builtin or
extension module.
"""
# split off top-most name
parts = dotted_name.split('.', 1)
if len(parts) > 1:
# we have a dotted path, import top-level package
try:
file, pathname, description = imp.find_module(parts[0], pathlist)
if file: file.close()
except ImportError:
return None
# check if it's indeed a package
if description[2] == imp.PKG_DIRECTORY:
# recursively handle the remaining name parts
pathname = _get_modpkg_path(parts[1], [pathname])
else:
pathname = None
else:
# plain name
try:
file, pathname, description = imp.find_module(
dotted_name, pathlist)
if file:
file.close()
if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]:
pathname = None
except ImportError:
pathname = None
return pathname
def getFilesForName(name):
"""Get a list of module files for a filename, a module or package name,
or a directory.
"""
if not os.path.exists(name):
# check for glob chars
if containsAny(name, "*?[]"):
files = glob.glob(name)
list = []
for file in files:
list.extend(getFilesForName(file))
return list
# try to find module or package
name = _get_modpkg_path(name)
if not name:
return []
if os.path.isdir(name):
# find all python files in directory
list = []
os.path.walk(name, _visit_pyfiles, list)
return list
elif os.path.exists(name):
# a single file
return [name]
return []
class TokenEater:
def __init__(self, options):
self.__options = options
self.__messages = {}
self.__state = self.__waiting
self.__data = []
self.__lineno = -1
self.__freshmodule = 1
self.__curfile = None
def __call__(self, ttype, tstring, stup, etup, line):
# dispatch
## import token
## print >> sys.stderr, 'ttype:', token.tok_name[ttype], \
## 'tstring:', tstring
self.__state(ttype, tstring, stup[0])
def __waiting(self, ttype, tstring, lineno):
opts = self.__options
# Do docstring extractions, if enabled
if opts.docstrings and not opts.nodocstrings.get(self.__curfile):
# module docstring?
if self.__freshmodule:
if ttype == tokenize.STRING:
self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
self.__freshmodule = 0
elif ttype not in (tokenize.COMMENT, tokenize.NL):
self.__freshmodule = 0
return
# class docstring?
if ttype == tokenize.NAME and tstring in ('class', 'def'):
self.__state = self.__suiteseen
return
if ttype == tokenize.NAME and tstring in opts.keywords:
self.__state = self.__keywordseen
def __suiteseen(self, ttype, tstring, lineno):
# ignore anything until we see the colon
if ttype == tokenize.OP and tstring == ':':
self.__state = self.__suitedocstring
def __suitedocstring(self, ttype, tstring, lineno):
# ignore any intervening noise
if ttype == tokenize.STRING:
self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
self.__state = self.__waiting
elif ttype not in (tokenize.NEWLINE, tokenize.INDENT,
tokenize.COMMENT):
# there was no class docstring
self.__state = self.__waiting
def __keywordseen(self, ttype, tstring, lineno):
if ttype == tokenize.OP and tstring == '(':
self.__data = []
self.__lineno = lineno
self.__state = self.__openseen
else:
self.__state = self.__waiting
def __openseen(self, ttype, tstring, lineno):
if ttype == tokenize.OP and tstring == ')':
# We've seen the last of the translatable strings. Record the
# line number of the first line of the strings and update the list
# of messages seen. Reset state for the next batch. If there
# were no strings inside _(), then just ignore this entry.
if self.__data:
self.__addentry(EMPTYSTRING.join(self.__data))
self.__state = self.__waiting
elif ttype == tokenize.STRING:
self.__data.append(safe_eval(tstring))
elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT,
token.NEWLINE, tokenize.NL]:
# warn if we see anything else than STRING or whitespace
print >> sys.stderr, _(
'*** %(file)s:%(lineno)s: Seen unexpected token "%(token)s"'
) % {
'token': tstring,
'file': self.__curfile,
'lineno': self.__lineno
}
self.__state = self.__waiting
def __addentry(self, msg, lineno=None, isdocstring=0):
if lineno is None:
lineno = self.__lineno
if not msg in self.__options.toexclude:
entry = (self.__curfile, lineno)
self.__messages.setdefault(msg, {})[entry] = isdocstring
def set_filename(self, filename):
self.__curfile = filename
self.__freshmodule = 1
def write(self, fp):
options = self.__options
timestamp = time.strftime('%Y-%m-%d %H:%M+%Z')
# The time stamp in the header doesn't have the same format as that
# generated by xgettext...
print >> fp, pot_header % {'time': timestamp, 'version': __version__}
# Sort the entries. First sort each particular entry's keys, then
# sort all the entries by their first item.
reverse = {}
for k, v in self.__messages.items():
keys = v.keys()
keys.sort()
reverse.setdefault(tuple(keys), []).append((k, v))
rkeys = reverse.keys()
rkeys.sort()
for rkey in rkeys:
rentries = reverse[rkey]
rentries.sort()
for k, v in rentries:
isdocstring = 0
# If the entry was gleaned out of a docstring, then add a
# comment stating so. This is to aid translators who may wish
# to skip translating some unimportant docstrings.
if reduce(operator.__add__, v.values()):
isdocstring = 1
# k is the message string, v is a dictionary-set of (filename,
# lineno) tuples. We want to sort the entries in v first by
# file name and then by line number.
v = v.keys()
v.sort()
if not options.writelocations:
pass
# location comments are different b/w Solaris and GNU:
elif options.locationstyle == options.SOLARIS:
for filename, lineno in v:
d = {'filename': filename, 'lineno': lineno}
print >>fp, _(
'# File: %(filename)s, line: %(lineno)d') % d
elif options.locationstyle == options.GNU:
# fit as many locations on one line, as long as the
# resulting line length doesn't exceeds 'options.width'
locline = '#:'
for filename, lineno in v:
d = {'filename': filename, 'lineno': lineno}
s = _(' %(filename)s:%(lineno)d') % d
if len(locline) + len(s) <= options.width:
locline = locline + s
else:
print >> fp, locline
locline = "#:" + s
if len(locline) > 2:
print >> fp, locline
if isdocstring:
print >> fp, '#, docstring'
print >> fp, 'msgid', normalize(k)
print >> fp, 'msgstr ""\n'
def main():
global default_keywords
try:
opts, args = getopt.getopt(
sys.argv[1:],
'ad:DEhk:Kno:p:S:Vvw:x:X:',
['extract-all', 'default-domain=', 'escape', 'help',
'keyword=', 'no-default-keywords',
'add-location', 'no-location', 'output=', 'output-dir=',
'style=', 'verbose', 'version', 'width=', 'exclude-file=',
'docstrings', 'no-docstrings',
])
except getopt.error, msg:
usage(1, msg)
# for holding option values
class Options:
# constants
GNU = 1
SOLARIS = 2
# defaults
extractall = 0 # FIXME: currently this option has no effect at all.
escape = 0
keywords = []
outpath = ''
outfile = 'messages.pot'
writelocations = 1
locationstyle = GNU
verbose = 0
width = 78
excludefilename = ''
docstrings = 0
nodocstrings = {}
options = Options()
locations = {'gnu' : options.GNU,
'solaris' : options.SOLARIS,
}
# parse options
for opt, arg in opts:
if opt in ('-h', '--help'):
usage(0)
elif opt in ('-a', '--extract-all'):
options.extractall = 1
elif opt in ('-d', '--default-domain'):
options.outfile = arg + '.pot'
elif opt in ('-E', '--escape'):
options.escape = 1
elif opt in ('-D', '--docstrings'):
options.docstrings = 1
elif opt in ('-k', '--keyword'):
options.keywords.append(arg)
elif opt in ('-K', '--no-default-keywords'):
default_keywords = []
elif opt in ('-n', '--add-location'):
options.writelocations = 1
elif opt in ('--no-location',):
options.writelocations = 0
elif opt in ('-S', '--style'):
options.locationstyle = locations.get(arg.lower())
if options.locationstyle is None:
usage(1, _('Invalid value for --style: %s') % arg)
elif opt in ('-o', '--output'):
options.outfile = arg
elif opt in ('-p', '--output-dir'):
options.outpath = arg
elif opt in ('-v', '--verbose'):
options.verbose = 1
elif opt in ('-V', '--version'):
print _('pygettext.py (xgettext for Python) %s') % __version__
sys.exit(0)
elif opt in ('-w', '--width'):
try:
options.width = int(arg)
except ValueError:
usage(1, _('--width argument must be an integer: %s') % arg)
elif opt in ('-x', '--exclude-file'):
options.excludefilename = arg
elif opt in ('-X', '--no-docstrings'):
fp = open(arg)
try:
while 1:
line = fp.readline()
if not line:
break
options.nodocstrings[line[:-1]] = 1
finally:
fp.close()
# calculate escapes
make_escapes(options.escape)
# calculate all keywords
options.keywords.extend(default_keywords)
# initialize list of strings to exclude
if options.excludefilename:
try:
fp = open(options.excludefilename)
options.toexclude = fp.readlines()
fp.close()
except IOError:
print >> sys.stderr, _(
"Can't read --exclude-file: %s") % options.excludefilename
sys.exit(1)
else:
options.toexclude = []
# resolve args to module lists
expanded = []
for arg in args:
if arg == '-':
expanded.append(arg)
else:
expanded.extend(getFilesForName(arg))
args = expanded
# slurp through all the files
eater = TokenEater(options)
for filename in args:
if filename == '-':
if options.verbose:
print _('Reading standard input')
fp = sys.stdin
closep = 0
else:
if options.verbose:
print _('Working on %s') % filename
fp = open(filename)
closep = 1
try:
eater.set_filename(filename)
try:
tokenize.tokenize(fp.readline, eater)
except tokenize.TokenError, e:
print >> sys.stderr, '%s: %s, line %d, column %d' % (
e[0], filename, e[1][0], e[1][1])
finally:
if closep:
fp.close()
# write the output
if options.outfile == '-':
fp = sys.stdout
closep = 0
else:
if options.outpath:
options.outfile = os.path.join(options.outpath, options.outfile)
fp = open(options.outfile, 'w')
closep = 1
try:
eater.write(fp)
finally:
if closep:
fp.close()
if __name__ == '__main__':
main()
# some more test strings
_(u'a unicode string')
# this one creates a warning
_('*** Seen unexpected token "%(token)s"') % {'token': 'test'}
_('more' 'than' 'one' 'string')

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,81 +0,0 @@
#! /usr/bin/env python
""" Upload socializer to the ftp server. This script has been created to be executed from a continuous integrations system.
Important note: for this script to work, the following conditions should be met:
* There must be ftp server data, via environment variables (FTP_SERVER, FTP_USERNAME and FTP_PASSWORD) or via arguments to the script call (in the prior order). Connection to this server is done via default ftp port via TLS.
* this code assumes it's going to connect to an FTP via TLS.
* If the version to upload is alpha, there's not need of an extra variable. Otherwise, CI_COMMIT_TAG should point to a version as vx.x, where v is a literal and x are numbers, example may be v0.18, v0.25, v0.3. This variable should be set in the environment.
* Inside the ftp server, the following directory structure will be expected: socializer.su/static/files/. The script will create the <version> folder or alpha if needed.
* The script will upload all .exe, .zip and .json files located in the root directory from where it was called. The json files are uploaded to socializer.su/static/files/update and other files are going to socializer.su/static/files/<version>.
"""
import sys
import os
import glob
import ftplib
transferred=0
class MyFTP_TLS(ftplib.FTP_TLS):
"""Explicit FTPS, with shared TLS session"""
def ntransfercmd(self, cmd, rest=None):
conn, size = ftplib.FTP.ntransfercmd(self, cmd, rest)
if self._prot_p:
conn = self.context.wrap_socket(conn,
server_hostname=self.host,
session=self.sock.session) # this is the fix
return conn, size
def convert_bytes(n):
K, M, G, T, P = 1 << 10, 1 << 20, 1 << 30, 1 << 40, 1 << 50
if n >= P:
return '%.2fPb' % (float(n) / T)
elif n >= T:
return '%.2fTb' % (float(n) / T)
elif n >= G:
return '%.2fGb' % (float(n) / G)
elif n >= M:
return '%.2fMb' % (float(n) / M)
elif n >= K:
return '%.2fKb' % (float(n) / K)
else:
return '%d' % n
def callback(progress):
global transferred
transferred = transferred+len(progress)
print("Uploaded {}".format(convert_bytes(transferred),))
ftp_server = os.environ.get("FTP_SERVER") or sys.argv[1]
ftp_username = os.environ.get("FTP_USERNAME") or sys.argv[2]
ftp_password = os.environ.get("FTP_PASSWORD") or sys.argv[3]
version = os.environ.get("CI_COMMIT_TAG") or "alpha"
version = version.replace("v", "")
print("Uploading files to the Socializer server...")
print("Connecting to %s" % (ftp_server,))
connection = ftplib.FTP(ftp_server)
print("Connected to FTP server {}".format(ftp_server,))
connection.login(user=ftp_username, passwd=ftp_password)
#connection.prot_p()
print("Logged in successfully")
connection.cwd("socializer")
if version not in connection.nlst():
print("Creating version directory {} because does not exists...".format(version,))
connection.mkd(version)
if "update" not in connection.nlst():
print("Creating update info directory because does not exists...")
connection.mkd("update")
connection.cwd(version)
print("Moved into version directory")
files = glob.glob("*.zip")+glob.glob("*.exe")+glob.glob("*.json")
print("These files will be uploaded into the version folder: {}".format(files,))
for file in files:
transferred = 0
print("Uploading {}".format(file,))
with open(file, "rb") as f:
if file.endswith("json"):
connection.storbinary('STOR ../update/%s' % file, f, callback=callback, blocksize=1024*1024)
else:
connection.storbinary('STOR %s' % file, f, callback=callback, blocksize=1024*1024)
print("Upload completed. exiting...")
connection.quit()

View File

@ -2,7 +2,6 @@
language = string(default="system") language = string(default="system")
use_proxy = boolean(default=False) use_proxy = boolean(default=False)
first_start = boolean(default=True) first_start = boolean(default=True)
debug_logging = boolean(default=False)
[sound] [sound]
volume = integer(default=100) volume = integer(default=100)

View File

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

View File

@ -1,31 +1,103 @@
# -*- coding: utf-8 -*- # -*- 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 import logging
from vkaudiotoken import CommonParams, TokenReceiverOfficial, supported_clients, TokenException, TwoFAHelper from hashlib import md5
from . import wxUI from .wxUI import two_factor_auth, bad_password
log = logging.getLogger("authenticator.official") log = logging.getLogger("authenticator.official")
class AuthenticationError(Exception): pass 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): def login(user, password):
""" Generates authentication workflow at VK servers. """ try:
log.info("Authenticating user account.") access_token, secret, device_id = get_non_refreshed(user, password)
access_token = None response = refresh_token(access_token, secret, device_id)
try: except AuthenticationError:
params = CommonParams(supported_clients.VK_OFFICIAL.user_agent) bad_password()
receiver = TokenReceiverOfficial(user, password, params, "GET_CODE") raise AuthenticationError("")
access_token = receiver.get_token()["access_token"] try:
log.debug("got a valid access token for {}".format(user)) return response["response"]["token"], secret, device_id
except TokenException as err: except KeyError:
if err.code == TokenException.TWOFA_REQ and 'validation_sid' in err.extra: log.exception("An exception has occurred while attempting to authenticate. Printing response returned by vk...")
log.debug("User requires two factor verification. Calling methods to send an SMS...") log.exception(response)
try:
TwoFAHelper(params).validate_phone(err.extra['validation_sid'])
except TokenException as err:
if err.code == TokenException.TWOFA_ERR:
wxUI.two_auth_limit()
raise AuthenticationError("Error authentication two factor auth.")
code, remember = wxUI.two_factor_auth()
receiver = TokenReceiverOfficial(user, password, params, code)
access_token = receiver.get_token()["access_token"]
return access_token

View File

@ -5,16 +5,13 @@ import wx
import widgetUtils import widgetUtils
def two_factor_auth(): def two_factor_auth():
code = None code = None
dlg = wx.TextEntryDialog(None, _("Please provide the authentication code you have received from VK."), _("Two factor authentication code")) dlg = wx.TextEntryDialog(None, _("Please provide the authentication code you have received from VK."), _("Two factor authentication code"))
response = dlg.ShowModal() response = dlg.ShowModal()
if response == widgetUtils.OK: if response == widgetUtils.OK:
code = dlg.GetValue() code = dlg.GetValue()
dlg.Destroy() dlg.Destroy()
return (code, True) return (code, True)
def bad_password(): def bad_password():
return wx.MessageDialog(None, _("Your password or email address are incorrect. Please fix the mistakes and try it again."), _("Wrong data"), wx.ICON_ERROR).ShowModal() return wx.MessageDialog(None, _("Your password or email address are incorrect. Please fix the mistakes and try it again."), _("Wrong data"), wx.ICON_ERROR).ShowModal()
def two_auth_limit():
return wx.MessageDialog(None, _("It seems you have reached the limits to request authorization via SMS. Please try it again in a couple of hours."), _("Error requiring sms verification"), wx.ICON_ERROR).ShowModal()

View File

@ -1,5 +0,0 @@
[python: **.py]
input_dirs = .
output_file=socializer.pot
msgid_bugs_address=manuel@manuelcortez.net
copyright_holder=Manuel Cortez

View File

@ -11,6 +11,7 @@ MAINSPEC = "app-configuration.defaults"
app = None app = None
def setup (): def setup ():
global app global app
log.debug("Loading global app settings...") log.debug("Loading global app settings...")
app = config_utils.load_config(os.path.join(paths.config_path(), MAINFILE), os.path.join(paths.app_path(), MAINSPEC)) app = config_utils.load_config(os.path.join(paths.config_path(), MAINFILE), os.path.join(paths.app_path(), MAINSPEC))

View File

@ -6,68 +6,68 @@ import string
class ConfigLoadError(Exception): pass class ConfigLoadError(Exception): pass
def load_config(config_path, configspec_path=None, *args, **kwargs): def load_config(config_path, configspec_path=None, *args, **kwargs):
if os.path.exists(config_path): if os.path.exists(config_path):
clean_config(config_path) clean_config(config_path)
spec = ConfigObj(configspec_path, encoding='UTF8', list_values=False, _inspec=True) spec = ConfigObj(configspec_path, encoding='UTF8', list_values=False, _inspec=True)
try: try:
config = ConfigObj(infile=config_path, configspec=spec, create_empty=True, encoding='UTF8', *args, **kwargs) config = ConfigObj(infile=config_path, configspec=spec, create_empty=True, encoding='UTF8', *args, **kwargs)
except ParseError: except ParseError:
raise ConfigLoadError("Unable to load %r" % config_path) raise ConfigLoadError("Unable to load %r" % config_path)
validator = Validator() validator = Validator()
validated = config.validate(validator, copy=True) validated = config.validate(validator, copy=True)
if validated == True: if validated == True:
config.write() config.write()
return config return config
def is_blank(arg): def is_blank(arg):
"Check if a line is blank." "Check if a line is blank."
for c in arg: for c in arg:
if c not in string.whitespace: if c not in string.whitespace:
return False return False
return True return True
def get_keys(path): def get_keys(path):
"Gets the keys of a configobj config file." "Gets the keys of a configobj config file."
res=[] res=[]
fin=open(path) fin=open(path)
for line in fin: for line in fin:
if not is_blank(line): if not is_blank(line):
res.append(line[0:line.find('=')].strip()) res.append(line[0:line.find('=')].strip())
fin.close() fin.close()
return res return res
def hist(keys): def hist(keys):
"Generates a histogram of an iterable." "Generates a histogram of an iterable."
res={} res={}
for k in keys: for k in keys:
res[k]=res.setdefault(k,0)+1 res[k]=res.setdefault(k,0)+1
return res return res
def find_problems(hist): def find_problems(hist):
"Takes a histogram and returns a list of items occurring more than once." "Takes a histogram and returns a list of items occurring more than once."
res=[] res=[]
for k,v in list(hist.items()): for k,v in list(hist.items()):
if v>1: if v>1:
res.append(k) res.append(k)
return res return res
def clean_config(path): def clean_config(path):
"Cleans a config file. If duplicate values are found, delete all of them and just use the default." "Cleans a config file. If duplicate values are found, delete all of them and just use the default."
orig=[] orig=[]
cleaned=[] cleaned=[]
fin=open(path) fin=open(path)
for line in fin: for line in fin:
orig.append(line) orig.append(line)
fin.close() fin.close()
for p in find_problems(hist(get_keys(path))): for p in find_problems(hist(get_keys(path))):
for o in orig: for o in orig:
o.strip() o.strip()
if p not in o: if p not in o:
cleaned.append(o) cleaned.append(o)
if len(cleaned) != 0: if len(cleaned) != 0:
cam=open(path,'w') cam=open(path,'w')
for c in cleaned: for c in cleaned:
cam.write(c) cam.write(c)
cam.close() cam.close()
return True return True
else: else:
return False return False

1565
src/controller/buffers.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +0,0 @@
from .empty import emptyBuffer
from .home import homeBuffer as baseBuffer
from .wall import wallBuffer as feedBuffer
from .communityWall import communityWallBuffer as communityBuffer
from .communityBoard import communityBoardBuffer as topicBuffer
from .documents import documentsBuffer as documentBuffer
from .communityDocuments import communityDocumentsBuffer as documentCommunityBuffer
from .audio import audioBuffer
from .audioAlbum import audioAlbumBuffer as audioAlbum
from .video import videoBuffer
from .videoAlbum import videoAlbumBuffer as videoAlbum
from .chat import chatBuffer
from .people import peopleBuffer
from .friendRequests import friendRequestsBuffer as requestsBuffer
from .communityPeople import communityPeopleBuffer

View File

@ -1,309 +0,0 @@
# -*- coding: utf-8 -*-
import os
import logging
import webbrowser
import wx
import presenters
import views
import interactors
import widgetUtils
from pubsub import pub
from vk_api import upload
from mutagen.id3 import ID3
from presenters import player
from wxUI.tabs import audio
from sessionmanager import utils
from mysc.thread_utils import call_threaded
from wxUI import commonMessages, menus
from controller import selector
from .wall import wallBuffer
log = logging.getLogger("controller.buffers.audio")
class audioBuffer(wallBuffer):
def create_tab(self, parent):
self.tab = audio.audioTab(parent)
self.tab.name = self.name
self.connect_events()
if self.name == "me_audio":
self.tab.post.Enable(True)
def get_event(self, ev):
if ev.GetKeyCode() == wx.WXK_RETURN:
if len(self.tab.list.get_multiple_selection()) < 2:
event = "play_all"
else:
event = "play_audio"
else:
event = None
ev.Skip()
if event != None:
try:
getattr(self, event)(skip_pause=True)
except AttributeError:
pass
def connect_events(self):
widgetUtils.connect_event(self.tab.play, widgetUtils.BUTTON_PRESSED, self.play_audio)
widgetUtils.connect_event(self.tab.play_all, widgetUtils.BUTTON_PRESSED, self.play_all)
pub.subscribe(self.change_label, "playback-changed")
super(audioBuffer, self).connect_events()
def play_audio(self, *args, **kwargs):
if player.player.check_is_playing() and not "skip_pause" in kwargs:
return pub.sendMessage("pause")
selected = self.tab.list.get_multiple_selection()
if len(selected) == 0:
return
elif len(selected) == 1:
pub.sendMessage("play", object=self.session.db[self.name]["items"][selected[0]])
else:
selected_audios = [self.session.db[self.name]["items"][item] for item in selected]
pub.sendMessage("play-all", list_of_songs=selected_audios)
return True
def play_next(self, *args, **kwargs):
selected = self.tab.list.get_selected()
if selected < 0:
selected = 0
if self.tab.list.get_count() <= selected+1:
newpos = 0
else:
newpos = selected+1
self.tab.list.select_item(newpos)
self.play_audio()
def play_previous(self, *args, **kwargs):
selected = self.tab.list.get_selected()
if selected <= 0:
selected = self.tab.list.get_count()
newpos = selected-1
self.tab.list.select_item(newpos)
self.play_audio()
def open_post(self, *args, **kwargs):
selected = self.tab.list.get_multiple_selection()
if len(selected) < 1:
return
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
a = presenters.displayAudioPresenter(session=self.session, postObject=audios, interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
def play_all(self, *args, **kwargs):
selected = self.tab.list.get_selected()
if selected == -1:
selected = 0
if self.name not in self.session.db:
return
audios = [i for i in self.session.db[self.name]["items"][selected:]]
pub.sendMessage("play-all", list_of_songs=audios)
return True
def remove_buffer(self, mandatory=False):
if "me_audio" == self.name or "popular_audio" == self.name or "recommended_audio" == self.name:
output.speak(_("This buffer can't be deleted"))
return False
else:
if mandatory == False:
dlg = commonMessages.remove_buffer()
else:
dlg = widgetUtils.YES
if dlg == widgetUtils.YES:
self.session.db.pop(self.name)
return True
else:
return False
def get_more_items(self, *args, **kwargs):
# Translators: Some buffers can't use the get previous item feature due to API limitations.
output.speak(_("This buffer doesn't support getting more items."))
def onFocus(self, event, *args, **kwargs):
event.Skip()
def add_to_library(self, *args, **kwargs):
call_threaded(self._add_to_library, *args, **kwargs)
def _add_to_library(self, *args, **kwargs):
selected = self.tab.list.get_multiple_selection()
if len(selected) < 1:
return
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
errors_detected = 0
for i in audios:
args = {}
args["audio_id"] = i["id"]
if "album_id" in i:
args["album_id"] = i["album_id"]
args["owner_id"] = i["owner_id"]
try:
audio = self.session.vk.client.audio.add(**args)
except VkApiError:
errors_detected = errors_detected + 1
continue
if audio != None and int(audio) < 21:
errors_detected = errors_detected + 1
if errors_detected == 0:
if len(selected) == 1:
msg = _("Audio added to your library")
elif len(selected) > 1 and len(selected) < 5:
msg = _("{0} audios were added to your library.").format(len(selected),)
else:
msg = _("{audios} audios were added to your library.").format(audios=len(selected),)
output.speak(msg)
else:
output.speak(_("{0} errors occurred while attempting to add {1} audios to your library.").format(errors_detected, len(selected)))
def remove_from_library(self, *args, **kwargs):
call_threaded(self._remove_from_library, *args, **kwargs)
def _remove_from_library(self, *args, **kwargs):
selected = self.tab.list.get_multiple_selection()
if len(selected) < 1:
return
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
errors_detected = 0
audios_removed = 0
for i in range(0, len(selected)):
args = {}
args["audio_id"] = audios[i]["id"]
args["owner_id"] = self.session.user_id
result = self.session.vk.client.audio.delete(**args)
if int(result) != 1:
errors_dtected = errors_detected + 1
else:
self.session.db[self.name]["items"].pop(selected[i]-audios_removed)
self.tab.list.remove_item(selected[i]-audios_removed)
audios_removed = audios_removed + 1
if errors_detected == 0:
if len(selected) == 1:
msg = _("Audio removed.")
elif len(selected) > 1 and len(selected) < 5:
msg = _("{0} audios were removed.").format(len(selected),)
else:
msg = _("{audios} audios were removed.").format(audios=len(selected),)
output.speak(msg)
else:
output.speak(_("{0} errors occurred while attempting to remove {1} audios.").format(errors_detected, len(selected)))
def move_to_album(self, *args, **kwargs):
if len(self.session.audio_albums) == 0:
return commonMessages.no_audio_albums()
album = selector.album(_("Select the album where you want to move this song"), self.session)
if album.item == None:
return
call_threaded(self._move_to_album, album.item, *args, **kwargs)
def _move_to_album(self, album, *args, **kwargs):
selected = self.tab.list.get_multiple_selection()
if len(selected) < 1:
return
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
errors_detected = 0
for i in audios:
id = i["id"]
try:
response = self.session.vk.client.audio.add(playlist_id=album, audio_id=id, owner_id=i["owner_id"])
except VkApiError:
errors_detected = errors_detected + 1
if errors_detected == 0:
if len(selected) == 1:
msg = _("Audio added to playlist.")
elif len(selected) > 1 and len(selected) < 5:
msg = _("{0} audios were added to playlist.").format(len(selected),)
else:
msg = _("{audios} audios were added to playlist.").format(audios=len(selected),)
output.speak(msg)
else:
output.speak(_("{0} errors occurred while attempting to add {1} audios to your playlist.").format(errors_detected, len(selected)))
def get_menu(self):
p = self.get_post()
if p == None:
return
m = menus.audioMenu()
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_post, menuitem=m.open)
widgetUtils.connect_event(m, widgetUtils.MENU, self.play_audio, menuitem=m.play)
widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move)
widgetUtils.connect_event(m, widgetUtils.MENU, self.download, menuitem=m.download)
widgetUtils.connect_event(m, widgetUtils.MENU, self.select_all, menuitem=m.select)
widgetUtils.connect_event(m, widgetUtils.MENU, self.deselect_all, menuitem=m.deselect)
# if owner_id is the current user, the audio is added to the user's audios.
if p["owner_id"] == self.session.user_id:
m.library.SetItemLabel(_("&Remove"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library)
else:
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
return m
def post(self, *args, **kwargs):
""" Uploads an audio to the current user's library from the computer. """
file = self.tab.get_file_to_upload()
if file == None:
return
audio_tags = ID3(file)
if "TIT2" in audio_tags:
title = audio_tags["TIT2"].text[0]
else:
title = _("Untitled")
if "TPE1" in audio_tags:
artist = audio_tags["TPE1"].text[0]
else:
artist = _("Unknown artist")
uploader = upload.VkUpload(self.session.vk.session_object)
call_threaded(uploader.audio, file, title=title, artist=artist)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/audio{user_id}_{post_id}".format(user_id=post["owner_id"], post_id=post["id"])
webbrowser.open_new_tab(url)
def change_label(self, stopped):
if hasattr(self.tab, "play"):
if stopped == False:
self.tab.play.SetLabel(_("P&ause"))
else:
self.tab.play.SetLabel(_("P&lay"))
def __del__(self):
pub.unsubscribe(self.change_label, "playback-changed")
def download(self, *args, **kwargs):
selected = self.tab.list.get_multiple_selection()
if len(selected) < 1:
return
audios = [self.session.db[self.name]["items"][audio] for audio in selected]
if len(audios) == 0:
return
elif len(audios) == 1:
multiple = False
filename = utils.safe_filename("{0} - {1}.mp3".format(audios[0]["title"], audios[0]["artist"]))
else:
multiple = True
filename = "" # No default filename for multiple files.
path = self.tab.get_download_path(filename=filename, multiple=multiple)
self.download_threaded(path, multiple, audios)
def download_threaded(self, path, multiple, audios):
if multiple == False:
url = audios[0]["url"]
pub.sendMessage("download-file", url=url, filename=path)
return
else:
downloads = []
for i in audios:
filename = utils.safe_filename("{0} - {1}.mp3".format(i["title"], i["artist"]))
filepath = os.path.join(path, filename)
downloads.append((utils.transform_audio_url(i["url"]), filepath))
pub.sendMessage("download-files", downloads=downloads)
def select_all(self, *args, **kwargs):
items = self.tab.list.list.GetItemCount()
for i in range(0, items):
self.tab.list.list.SetItemImage(i, 1)
def deselect_all(self, *args, **kwargs):
items = self.tab.list.list.GetItemCount()
for i in range(0, items):
self.tab.list.list.SetItemImage(i, 0)

View File

@ -1,34 +0,0 @@
# -*- coding: utf-8 -*-
import logging
import wx
import widgetUtils
import output
from wxUI.tabs import audioAlbum
from .audio import audioBuffer
log = logging.getLogger("controller.buffers.audioPlaylist")
class audioAlbumBuffer(audioBuffer):
""" this buffer was supposed to be used with audio albums
but is deprecated as VK removed its audio support for third party apps."""
def create_tab(self, parent):
self.tab = audioAlbum.audioAlbumTab(parent)
self.tab.play.Enable(False)
self.tab.play_all.Enable(False)
self.connect_events()
self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)
def connect_events(self):
super(audioAlbumBuffer, self).connect_events()
widgetUtils.connect_event(self.tab.load, widgetUtils.BUTTON_PRESSED, self.load_album)
def load_album(self, *args, **kwargs):
output.speak(_("Loading album..."))
self.can_get_items = True
self.tab.load.Enable(False)
wx.CallAfter(self.get_items)
self.tab.play.Enable(True)
self.tab.play_all.Enable(True)

View File

@ -1,307 +0,0 @@
# -*- coding: utf-8 -*-
import time
import random
import logging
import webbrowser
import wx
import presenters
import views
import interactors
import widgetUtils
import output
from pubsub import pub
from vk_api.exceptions import VkApiError
from extra import translator, SpellChecker
from wxUI.tabs import chat
from mysc.thread_utils import call_threaded
from wxUI import commonMessages, menus
from sessionmanager import renderers
from .home import homeBuffer
log = logging.getLogger("controller.buffers.chat")
class chatBuffer(homeBuffer):
def insert(self, item, reversed=False):
""" Add a new item to the list. Uses session.composefunc for parsing the dictionary and create a valid result for putting it in the list."""
# as this tab is based in a text control, we have to overwrite the defaults.
item_ = getattr(renderers, self.compose_function)(item, self.session)
# the self.chat dictionary will have (first_line, last_line) as keys and message ID as a value for looking into it when needed.
# Here we will get first and last line of a chat message appended to the history.
values = self.tab.add_message(item_[0], reverse=reversed)
self.chats[values] = item["id"]
def get_focused_post(self):
""" Gets chat message currently in focus"""
# this function replaces self.get_post for this buffer, as we rely in a TextCtrl control for getting chats.
# Instead of the traditional method to do the trick.
# Get text position here.
position = self.tab.history.PositionToXY(self.tab.history.GetInsertionPoint())
id_ = None
# The dictionary keys should be looked in reverse order as we are interested in the last result only.
for i in reversed(list(self.chats.keys())):
# Check if position[2] (line position) matches with something in self.chats
# (All messages, except the last one, should be able to be matched here).
# position[2]+1 is added because line may start with 0, while in wx.TextCtrl.GetNumberOfLines() it returns a value counting from 1.
if position[2]+1 >= i[0]:
id_ = self.chats[i]
# If we find our chat message, let's skip the rest of the loop.
break
# Retrieve here the object based in id_
if id_ != None:
for i in self.session.db[self.name]["items"]:
if i["id"] == id_:
return i
return False
get_post = get_focused_post
def onFocus(self, event, *args, **kwargs):
if event.GetKeyCode() == wx.WXK_UP or event.GetKeyCode() == wx.WXK_DOWN or event.GetKeyCode() == wx.WXK_START or event.GetKeyCode() == wx.WXK_PAGEUP or event.GetKeyCode() == wx.WXK_PAGEDOWN or event.GetKeyCode() == wx.WXK_END:
msg = self.get_focused_post()
if msg == False: # Handle the case where the last line of the control cannot be matched to anything.
return
# Mark unread conversations as read.
if "read_state" in msg and msg["read_state"] == 0 and "out" in msg and msg["out"] == 0:
self.session.soundplayer.play("message_unread.ogg")
call_threaded(self.session.vk.client.messages.markAsRead, peer_id=self.kwargs["peer_id"])
[i.update(read_state=1) for i in self.session.db[self.name]["items"]]
if "attachments" in msg and len(msg["attachments"]) > 0:
self.tab.attachments.list.Enable(True)
self.attachments = list()
self.tab.attachments.clear()
self.parse_attachments(msg)
else:
self.tab.attachments.list.Enable(False)
self.tab.attachments.clear()
event.Skip()
def create_tab(self, parent):
self.tab = chat.chatTab(parent)
self.attachments = list()
self.connect_events()
self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)
def connect_events(self):
widgetUtils.connect_event(self.tab.send, widgetUtils.BUTTON_PRESSED, self.send_chat_to_user)
widgetUtils.connect_event(self.tab.attachment, widgetUtils.BUTTON_PRESSED, self.add_attachment)
widgetUtils.connect_event(self.tab.text, widgetUtils.KEYPRESS, self.catch_enter)
widgetUtils.connect_event(self.tab.actions, widgetUtils.BUTTON_PRESSED, self.actions)
self.tab.set_focus_function(self.onFocus)
def catch_enter(self, event, *args, **kwargs):
shift=event.ShiftDown()
if event.GetKeyCode() == wx.WXK_RETURN and shift == False:
return self.send_chat_to_user()
t = time.time()
if event.GetUnicodeKey() != wx.WXK_NONE and t-self.last_keypress > 5:
self.last_keypress = t
call_threaded(self.session.vk.client.messages.setActivity, peer_id=self.kwargs["peer_id"], type="typing")
event.Skip()
def get_items(self, show_nextpage=False):
""" Update buffer with newest items or get older items in the buffer."""
if self.can_get_items == False: return
retrieved = True
try:
num = getattr(self.session, "get_page")(show_nextpage=show_nextpage, name=self.name, *self.args, **self.kwargs)
except VkApiError as err:
log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code
return retrieved
except:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if not hasattr(self, "tab"):
# Create GUI associated to this buffer.
self.create_tab(self.parent)
# Add name to the new control so we could look for it when needed.
self.tab.name = self.name
if show_nextpage == False:
if self.tab.history.GetValue() != "" and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]]
[self.insert(i, False) for i in v]
else:
[self.insert(i) for i in self.session.db[self.name]["items"][:num]]
else:
if num > 0:
# At this point we save more CPU and mathematical work if we just delete everything in the chat history and readd all messages.
# Otherwise we'd have to insert new lines at the top and recalculate positions everywhere else.
# Firstly, we'd have to save the current focused object so we will place the user in the right part of the text after loading everything again.
focused_post = self.get_post()
self.chats = dict()
wx.CallAfter(self.tab.history.SetValue, "")
v = [i for i in self.session.db[self.name]["items"]]
[self.insert(i) for i in v]
# Now it's time to set back the focus in the post.
for i in self.chats.keys():
if self.chats[i] == focused_post["id"]:
line = i[0]
wx.CallAfter(self.tab.history.SetInsertionPoint, self.tab.history.XYToPosition(0, line))
output.speak(_("Items loaded"))
break
if self.unread == True and num > 0:
self.session.db[self.name]["items"][-1].update(read_state=0)
return retrieved
def get_more_items(self):
output.speak(_("Getting more items..."))
call_threaded(self.get_items, show_nextpage=True)
def add_attachment(self, *args, **kwargs):
a = presenters.attachPresenter(session=self.session, view=views.attachDialog(voice_messages=True), interactor=interactors.attachInteractor())
if len(a.attachments) != 0:
self.attachments_to_be_sent = a.attachments
def send_chat_to_user(self, *args, **kwargs):
text = self.tab.text.GetValue()
if text == "" and not hasattr(self, "attachments_to_be_sent"):
wx.Bell()
return
self.tab.text.SetValue("")
post_arguments = dict(random_id = random.randint(0, 100000), peer_id=self.kwargs["peer_id"])
if len(text) > 0:
post_arguments.update(message=text)
if hasattr(self, "attachments_to_be_sent") and len(self.attachments_to_be_sent) > 0:
attachments = self.attachments_to_be_sent[::]
else:
attachments = []
call_threaded(pub.sendMessage, "post", parent_endpoint="messages", child_endpoint="send", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
if hasattr(self, "attachments_to_be_sent"):
del self.attachments_to_be_sent
def __init__(self, unread=False, *args, **kwargs):
super(chatBuffer, self).__init__(*args, **kwargs)
self.unread = unread
self.chats = dict()
self.peer_typing = 0
self.last_keypress = time.time()
def parse_attachments(self, post):
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
try:
rendered_object = renderers.add_attachment(i)
except:
log.exception("Error parsing the following attachment on chat: %r" % (i,))
attachments.append(rendered_object)
self.attachments.append(i)
self.tab.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.open_attachment)
self.tab.insert_attachments(attachments)
def open_attachment(self, *args, **kwargs):
index = self.tab.attachments.get_selected()
attachment = self.attachments[index]
if attachment["type"] == "audio":
a = presenters.displayAudioPresenter(session=self.session, postObject=[attachment["audio"]], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
elif attachment["type"] == "audio_message":
link = attachment["audio_message"]["link_mp3"]
pub.sendMessage("play-message", message_url=link)
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)
if attachment["type"] == "wall":
pub.sendMessage("open-post", post_object=attachment["wall"], controller_="displayPost")
else:
log.debug("Unhandled attachment: %r" % (attachment,))
def clear_reads(self):
for i in self.session.db[self.name]["items"]:
if "read_state" in i and i["read_state"] == 0:
i["read_state"] = 1
def remove_buffer(self, mandatory=False):
""" Remove buffer if the current buffer is not the logged user's wall."""
if mandatory == False:
dlg = commonMessages.remove_buffer()
else:
dlg = widgetUtils.YES
if dlg == widgetUtils.YES:
self.session.db.pop(self.name)
return True
else:
return False
def open_in_browser(self, *args, **kwargs):
peer_id = self.kwargs["peer_id"]
url = "https://vk.com/im?sel={peer_id}".format(peer_id=peer_id)
webbrowser.open_new_tab(url)
def actions(self, *args, **kwargs):
menu = menus.toolsMenu()
widgetUtils.connect_event(menu, widgetUtils.MENU, self.translate_action, menuitem=menu.translate)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.spellcheck_action, menuitem=menu.spellcheck)
self.tab.PopupMenu(menu, self.tab.actions.GetPosition())
def translate(self, text):
dlg = translator.gui.translateDialog()
if dlg.get_response() == widgetUtils.OK:
language_dict = translator.translator.available_languages()
for k in language_dict:
if language_dict[k] == dlg.dest_lang.GetStringSelection():
dst = k
msg = translator.translator.translate(text, dst)
dlg.Destroy()
return msg
def spellcheck(self, text):
checker = SpellChecker.spellchecker.spellChecker(text)
if hasattr(checker, "fixed_text"):
final_text = checker.fixed_text
return final_text
def translate_action(self, *args, **kwargs):
text = self.tab.text.GetValue()
if text == "":
wx.Bell()
return
translated = self.translate(text)
if translated != None:
self.tab.text.ChangeValue(translated)
self.tab.text.SetFocus()
def spellcheck_action(self, *args, **kwargs):
text = self.tab.text.GetValue()
fixed = self.spellcheck(text)
if fixed != None:
self.tab.text.ChangeValue(fixed)
self.tab.text.SetFocus()
def translate_message(self, *args, **kwargs):
pass
def spellcheck_message(self, *args, **kwargs):
pass

View File

@ -1,68 +0,0 @@
# -*- coding: utf-8 -*-
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
import logging
import webbrowser
import wx
import presenters
import views
import interactors
import widgetUtils
from pubsub import pub
from wxUI.tabs import communityBoard
from mysc.thread_utils import call_threaded
from .wall import wallBuffer
log = logging.getLogger("controller.buffers.communityBoard")
class communityBoardBuffer(wallBuffer):
def create_tab(self, parent):
self.tab = communityBoard.communityBoardTab(parent)
self.connect_events()
self.tab.name = self.name
if "can_create_topic" not in self.session.db["group_info"][self.kwargs["group_id"]*-1] or ("can_create_topic" in self.session.db["group_info"][self.kwargs["group_id"]*-1] and self.session.db["group_info"][self.kwargs["group_id"]*-1]["can_create_topic"] != True):
self.tab.post.Enable(False)
def onFocus(self, event, *args, **kwargs):
event.Skip()
def open_post(self, *args, **kwargs):
""" Opens the currently focused post."""
post = self.get_post()
if post == None:
return
a = presenters.displayTopicPresenter(session=self.session, postObject=post, group_id=self.kwargs["group_id"], interactor=interactors.displayPostInteractor(), view=views.displayTopic())
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
# In order to load the selected topic we firstly have to catch the group_id, which is present in self.kwargs
# After getting the group_id we should make it negative
group_id = self.kwargs["group_id"]*-1
url = "https://vk.com/topic{group_id}_{topic_id}".format(group_id=group_id, topic_id=post["id"])
webbrowser.open_new_tab(url)
def post(self, *args, **kwargs):
menu = wx.Menu()
user1 = self.session.get_user(self.session.user_id)
user2 = self.session.get_user(-1*self.kwargs["group_id"])
user = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user1))
group = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user2))
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 1), group)
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 0), user)
self.tab.post.PopupMenu(menu, self.tab.post.GetPosition())
def _post(self, event, from_group):
owner_id = self.kwargs["group_id"]
user = self.session.get_user(-1*owner_id, key="user1")
title = _("Create topic in {user1_nom}").format(**user)
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createTopicDialog(title=title, message="", text="", topic_title=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
title = p.view.title.GetValue()
msg = p.text
post_arguments = dict(title=title, text=msg, group_id=owner_id, from_group=from_group)
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="board", child_endpoint="addTopic", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)

View File

@ -1,16 +0,0 @@
# -*- coding: utf-8 -*-
import logging
from wxUI.tabs import communityDocuments
from .documents import documentsBuffer
log = logging.getLogger("controller.buffers.communityDocuments")
class communityDocumentsBuffer(documentsBuffer):
can_get_items = True
def create_tab(self, parent):
self.tab = communityDocuments.communityDocumentsTab(parent)
self.connect_events()
self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)

View File

@ -1,26 +0,0 @@
# -*- coding: utf-8 -*-
import logging
import wx
import widgetUtils
from .people import peopleBuffer
log = logging.getLogger("controller.buffers.communityPeople")
class communityPeopleBuffer(peopleBuffer):
def get_menu(self, *args, **kwargs):
user = self.get_post()
m = wx.Menu()
if user.get("can_post") == True:
can_post = m.Append(wx.NewId(), _("&Post on user's wall"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.post, menuitem=can_post)
if user.get("can_write_private_message") == True:
can_write_message = m.Append(wx.Id(), _("Send message"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.new_chat, menuitem=can_write_message)
profile = m.Append(wx.NewId(), _("View profile"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=profile)
timeline = m.Append(wx.NewId(), _("Open timeline"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_timeline, menuitem=timeline)
open_in_browser = m.Append(wx.NewId(), _("Open in vk.com"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=open_in_browser)
return m

View File

@ -1,69 +0,0 @@
# -*- coding: utf-8 -*-
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
import logging
import wx
import presenters
import views
import interactors
import widgetUtils
import output
from pubsub import pub
from wxUI.tabs import communityWall
from mysc.thread_utils import call_threaded
from .wall import wallBuffer
log = logging.getLogger("controller.buffers.communityWall")
class communityWallBuffer(wallBuffer):
def __init__(self, *args, **kwargs):
super(communityWallBuffer, self).__init__(*args, **kwargs)
self.group_id = self.kwargs["owner_id"]
def create_tab(self, parent):
self.tab = communityWall.communityWallTab(parent)
self.connect_events()
self.tab.name = self.name
self.tab.post.Enable(False)
def connect_events(self):
super(communityWallBuffer, self).connect_events()
widgetUtils.connect_event(self.tab.load, widgetUtils.BUTTON_PRESSED, self.load_community)
def load_community(self, *args, **kwargs):
output.speak(_("Loading community..."))
self.can_get_items = True
self.tab.load.Enable(False)
wx.CallAfter(self.get_items)
def get_items(self, *args, **kwargs):
""" This method retrieves community information, useful to show different parts of the community itself."""
if self.can_get_items:
# Strangely, groups.get does not return counters so we need those to show options for loading specific posts for communities.
group_info = self.session.vk.client.groups.getById(group_ids=-1*self.kwargs["owner_id"], fields="counters")[0]
self.session.db["group_info"][self.group_id].update(group_info)
if "can_post" in self.session.db["group_info"][self.group_id] and self.session.db["group_info"][self.group_id]["can_post"] == True:
self.tab.post.Enable(True)
super(communityWallBuffer, self).get_items(*args, **kwargs)
def post(self, *args, **kwargs):
menu = wx.Menu()
user1 = self.session.get_user(self.session.user_id)
user2 = self.session.get_user(self.kwargs["owner_id"])
user = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user1))
group = menu.Append(wx.NewId(), _("Post as {user1_nom}").format(**user2))
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 1), group)
menu.Bind(widgetUtils.MENU, lambda evt: self._post(evt, 0), user)
self.tab.post.PopupMenu(menu, self.tab.post.GetPosition())
def _post(self, event, from_group):
owner_id = self.kwargs["owner_id"]
user = self.session.get_user(owner_id, key="user1")
title = _("Post to {user1_nom}'s wall").format(**user)
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=owner_id, from_group=from_group)
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)

View File

@ -1,93 +0,0 @@
# -*- coding: utf-8 -*-
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
import logging
import webbrowser
import arrow
import wx
import languageHandler
import widgetUtils
import output
from pubsub import pub
from wxUI.tabs import documents
from sessionmanager import utils
from mysc.thread_utils import call_threaded
from wxUI import menus
from .wall import wallBuffer
log = logging.getLogger("controller.buffers.documents")
class documentsBuffer(wallBuffer):
can_get_items = False
def create_tab(self, parent):
self.tab = documents.documentsTab(parent)
self.connect_events()
self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)
def onFocus(self, event, *args,**kwargs):
post = self.get_post()
if post == None:
return
original_date = arrow.get(post["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
self.tab.list.list.SetItem(self.tab.list.get_selected(), 4, created_at)
event.Skip()
def connect_events(self):
super(documentsBuffer, self).connect_events()
# Check if we have a load button in the tab, because documents community buffers don't include it.
if hasattr(self.tab, "load"):
widgetUtils.connect_event(self.tab.load, widgetUtils.BUTTON_PRESSED, self.load_documents)
def load_documents(self, *args, **kwargs):
output.speak(_("Loading documents..."))
self.can_get_items = True
self.tab.load.Enable(False)
wx.CallAfter(self.get_items)
def get_menu(self):
p = self.get_post()
if p == None:
return
if p["owner_id"] == self.session.user_id:
added = True
else:
added = False
m = menus.documentMenu(added)
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_remove_document, menuitem=m.action)
widgetUtils.connect_event(m, widgetUtils.MENU, self.download, menuitem=m.download)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
return m
def add_remove_document(self, *args, **kwargs):
p = self.get_post()
if p == None:
return
if p["owner_id"] == self.session.user_id:
result = self.session.vk.client.docs.delete(owner_id=p["owner_id"], doc_id=p["id"])
if result == 1:
output.speak(_("The document has been successfully deleted."))
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
else:
result = self.session.vk.client.docs.add(owner_id=p["owner_id"], doc_id=p["id"])
output.speak(_("The document has been successfully added."))
def download(self, *args, **kwargs):
post = self.get_post()
filename = utils.safe_filename(post["title"])
# If document does not end in .extension we must fix it so the file dialog will save it properly later.
if filename.endswith(post["ext"]) == False:
filename = filename+ "."+post["ext"]
filepath = self.tab.get_download_path(filename)
if filepath != None:
pub.sendMessage("download-file", url=post["url"], filename=filepath)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/doc{user_id}_{post_id}".format(user_id=post["owner_id"], post_id=post["id"])
webbrowser.open_new_tab(url)

View File

@ -1,27 +0,0 @@
# -*- coding: utf-8 -*-
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
import logging
import output
from wxUI.tabs import empty
log = logging.getLogger("controller.buffers.empty")
class emptyBuffer(object):
def __init__(self, name=None, parent=None, *args, **kwargs):
self.tab = empty.emptyTab(parent=parent, name=name)
self.name = name
def get_items(self, *args, **kwargs):
if not hasattr(self, "tab"):
# Create GUI associated to this buffer.
self.create_tab(self.parent)
# Add name to the new control so we could look for it when needed.
self.tab.name = self.name
pass
def get_more_items(self, *args, **kwargs):
output.speak(_("This buffer doesn't support getting more items."))
def remove_buffer(self, mandatory=False):
return False

View File

@ -1,81 +0,0 @@
# -*- coding: utf-8 -*-
import logging
import wx
from pubsub import pub
from vk_api.exceptions import VkApiError
from .people import peopleBuffer
log = logging.getLogger("controller.buffers.friendRequests")
class friendRequestsBuffer(peopleBuffer):
def get_items(self, show_nextpage=False):
if self.can_get_items == False: return
retrieved = True
try:
ids = self.session.vk.client.friends.getRequests(*self.args, **self.kwargs)
except VkApiError as err:
log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code
return retrieved
except:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
num = self.session.get_page(name=self.name, show_nextpage=show_nextpage, endpoint="get", parent_endpoint="users", count=1000, user_ids=", ".join([str(i) for i in ids["items"]]), fields="uid, first_name, last_name, last_seen")
if not hasattr(self, "tab"):
# Create GUI associated to this buffer.
self.create_tab(self.parent)
# Add name to the new control so we could look for it when needed.
self.tab.name = self.name
if show_nextpage == False:
if self.tab.list.get_count() > 0 and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse()
[wx.CallAfter(self.insert, i, True) for i in v]
else:
[wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
return retrieved
def accept_friendship(self, *args, **kwargs):
""" Adds a person to a list of friends. This method is done for accepting someone else's friend request.
https://vk.com/dev/friends.add
"""
person = self.get_post()
if person == None:
return
result = self.session.vk.client.friends.add(user_id=person["id"])
if result == 2:
msg = _("{0} {1} now is your friend.").format(person["first_name"], person["last_name"])
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
def decline_friendship(self, *args, **kwargs):
""" Declines a freind request.
https://vk.com/dev/friends.delete
"""
person = self.get_post()
if person == None:
return
result = self.session.vk.client.friends.delete(user_id=person["id"])
if "out_request_deleted" in result:
msg = _("You've deleted the friends request to {0} {1}.").format(person["first_name"], person["last_name"])
elif "in_request_deleted" in result:
msg = _("You've declined the friend request of {0} {1}.").format(person["first_name"], person["last_name"])
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
def keep_as_follower(self, *args, **kwargs):
""" Adds a person to The followers list of the current user.
https://vk.com/dev/friends.add
"""
person = self.get_post()
if person == None:
return
result = self.session.vk.client.friends.add(user_id=person["id"], follow=1)
if result == 2:
msg = _("{0} {1} is following you.").format(person["first_name"], person["last_name"])
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())

View File

@ -1,332 +0,0 @@
# -*- coding: utf-8 -*-
import logging
import webbrowser
import arrow
import wx
import presenters
import views
import interactors
import languageHandler
import widgetUtils
import output
from pubsub import pub
from vk_api.exceptions import VkApiError
from presenters import player
from wxUI.tabs import home
from sessionmanager import session, renderers
from mysc.thread_utils import call_threaded
from wxUI import commonMessages, menus
log = logging.getLogger("controller.buffers.home")
class homeBuffer(object):
""" a basic representation of a buffer. Other buffers should be derived from this class. This buffer represents the "news feed" """
def get_post(self):
""" Return the currently focused post."""
# Handle case where there are no items in the buffer.
if self.tab.list.get_count() == 0:
wx.Bell()
return None
return self.session.db[self.name]["items"][self.tab.list.get_selected()]
def __init__(self, parent=None, name="", session=None, composefunc=None, create_tab=True, *args, **kwargs):
""" Constructor:
@parent wx.Treebook: parent for the buffer panel,
@name str: Name for saving this buffer's data in the local storage variable,
@session sessionmanager.session.vkSession: Session for performing operations in the Vk API. This session should be logged in when this class is instanciated.
@composefunc str: This function will be called for composing the result which will be put in the listCtrl. Composefunc should exist in the sessionmanager.renderers module.
args and kwargs will be passed to get_items() without any filtering. Be careful there.
"""
super(homeBuffer, self).__init__()
self.parent = parent
self.args = args
self.kwargs = kwargs
self.session = session
self.compose_function = composefunc
self.name = name
if create_tab:
self.create_tab(self.parent)
#Update_function will be called every 3 minutes and it should be able to
# Get all new items in the buffer and sort them properly in the CtrlList.
# ToDo: Shall we allow dinamically set for update_function?
self.update_function = "get_page"
self.name = name
# source_key and post_key will point to the keys for sender and posts in VK API objects.
# They can be changed in the future for other item types in different buffers.
self.user_key = "source_id"
self.post_key = "post_id"
# When set to False, update_function won't be executed here.
self.can_get_items = True
def create_tab(self, parent):
""" Create the Wx panel."""
self.tab = home.homeTab(parent)
# Bind local events (they will respond to events happened in the buffer).
self.connect_events()
self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)
def insert(self, item, reversed=False):
""" Add a new item to the list. Uses renderers.composefunc for parsing the dictionary and create a valid result for putting it in the list."""
try:
item_ = getattr(renderers, self.compose_function)(item, self.session)
wx.CallAfter(self.tab.list.insert_item, reversed, *item_)
except:
log.exception(item)
def get_items(self, show_nextpage=False):
""" Retrieve items from the VK API. This function is called repeatedly by the main controller and users could call it implicitly as well with the update buffer option.
@show_nextpage boolean: If it's true, it will try to load previous results.
"""
if self.can_get_items == False: return
retrieved = True # Control variable for handling unauthorised/connection errors.
try:
num = getattr(self.session, "get_newsfeed")(show_nextpage=show_nextpage, name=self.name, *self.args, **self.kwargs)
except VkApiError as err:
log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code
return retrieved
except:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if not hasattr(self, "tab"):
# Create GUI associated to this buffer.
self.create_tab(self.parent)
# Add name to the new control so we could look for it when needed.
if show_nextpage == False:
if self.tab.list.get_count() > 0 and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse()
[wx.CallAfter(self.insert, i, True) for i in v]
else:
[wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
else:
if num > 0:
[wx.CallAfter(self.insert, i, False) for i in self.session.db[self.name]["items"][-num:]]
return retrieved
def get_more_items(self):
""" Returns previous items in the buffer."""
self.get_items(show_nextpage=True)
def post(self, *args, **kwargs):
""" Create a post in the current user's wall.
This process is handled in two parts. This is the first part, where the GUI is created and user can send the post.
During the second part (threaded), the post will be sent to the API."""
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=_("Write your post"), message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments=dict(privacy=p.privacy, message=p.text)
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
def connect_events(self):
""" Bind all events to this buffer"""
widgetUtils.connect_event(self.tab.post, widgetUtils.BUTTON_PRESSED, self.post)
widgetUtils.connect_event(self.tab.list.list, widgetUtils.KEYPRESS, self.get_event)
widgetUtils.connect_event(self.tab.list.list, wx.EVT_CONTEXT_MENU, self.show_menu)
self.tab.set_focus_function(self.onFocus)
def show_menu(self, ev, pos=0, *args, **kwargs):
""" Show contextual menu when pressing menu key or right mouse click in a list item."""
if self.tab.list.get_count() == 0: return
menu = self.get_menu()
if pos != 0:
self.tab.PopupMenu(menu, pos)
else:
self.tab.PopupMenu(menu, self.tab.list.list.GetPosition())
def show_menu_by_key(self, ev):
""" Show contextual menu when menu key is pressed"""
if self.tab.list.get_count() == 0:
return
if ev.GetKeyCode() == wx.WXK_WINDOWS_MENU:
self.show_menu(widgetUtils.MENU, pos=self.tab.list.list.GetPosition())
def get_menu(self):
""" Returns contextual menu options. They will change according to the focused item"""
p = self.get_post()
if p == None:
return
# determine if the current user is able to delete the object.
if "can_delete" in p:
can_delete = True==p["can_delete"]
else:
can_delete = False
m = menus.postMenu(can_delete=can_delete)
if ("likes" in p) == False:
m.like.Enable(False)
elif p["likes"]["user_likes"] == 1:
m.like.Enable(False)
m.dislike.Enable(True)
if ("comments" in p) == False:
m.comment.Enable(False)
m.open_in_browser.Enable(False)
if "type" in p and p["type"] != "friend" and p["type"] != "audio" and p["type"] != "video" and p["type"] != "playlist" or self.name != "home_timeline":
m.open_in_browser.Enable(True)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_post, menuitem=m.open)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_like, menuitem=m.like)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_dislike, menuitem=m.dislike)
widgetUtils.connect_event(m, widgetUtils.MENU, self.do_comment, menuitem=m.comment)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
if hasattr(m, "view_profile"):
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
if hasattr(m, "delete"):
widgetUtils.connect_event(m, widgetUtils.MENU, self.delete, menuitem=m.delete)
return m
def do_like(self, *args, **kwargs):
""" Set like in the currently focused post."""
post = self.get_post()
if post == None:
return
user = post[self.user_key]
id = post[self.post_key]
if "type" in post:
type_ = post["type"]
else:
type_ = "post"
l = self.session.vk.client.likes.add(owner_id=user, item_id=id, type=type_)
self.session.db[self.name]["items"][self.tab.list.get_selected()]["likes"]["count"] = l["likes"]
self.session.db[self.name]["items"][self.tab.list.get_selected()]["likes"]["user_likes"] = 1
# Translators: This will be used when user presses like.
output.speak(_("You liked this"))
def do_dislike(self, *args, **kwargs):
""" Set dislike (undo like) in the currently focused post."""
post = self.get_post()
if post == None:
return
user = post[self.user_key]
id = post[self.post_key]
if "type" in post:
type_ = post["type"]
else:
type_ = "post"
l = self.session.vk.client.likes.delete(owner_id=user, item_id=id, type=type_)
self.session.db[self.name]["items"][self.tab.list.get_selected()]["likes"]["count"] = l["likes"]
self.session.db[self.name]["items"][self.tab.list.get_selected()]["likes"]["user_likes"] = 2
# Translators: This will be user in 'dislike'
output.speak(_("You don't like this"))
def do_comment(self, *args, **kwargs):
""" Make a comment into the currently focused post."""
post = self.get_post()
if post == None:
return
comment = presenters.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"):
msg = comment.text
try:
user = post[self.user_key]
id = post[self.post_key]
self.session.vk.client.wall.addComment(owner_id=user, post_id=id, text=msg)
output.speak(_("You've posted a comment"))
except Exception as msg:
log.error(msg)
def delete(self, *args, **kwargs):
post = self.get_post()
if ("type" in post and post["type"] == "post") or self.name != "newsfeed":
question = commonMessages.remove_post()
if question == widgetUtils.NO:
return
if "owner_id" in self.kwargs:
result = self.session.vk.client.wall.delete(owner_id=self.kwargs["owner_id"], post_id=post[self.post_key])
else:
result = self.session.vk.client.wall.delete(post_id=post[self.post_key])
pub.sendMessage("post_deleted", post_id=post[self.post_key])
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
def get_event(self, ev):
""" Parses keyboard input in the ListCtrl and executes the event associated with user keypresses."""
if ev.GetKeyCode() == wx.WXK_RETURN: event = "open_post"
else:
event = None
ev.Skip()
if event != None:
try:
getattr(self, event)()
except AttributeError:
pass
def volume_down(self):
""" Decreases player volume by 2%"""
player.player.volume = player.player.volume-2
def volume_up(self):
""" Increases player volume by 2%"""
player.player.volume = player.player.volume+2
def play_audio(self, *args, **kwargs):
""" Play audio in currently focused buffer, if possible."""
post = self.get_post()
if post == None:
return
if "type" in post and post["type"] == "audio":
pub.sendMessage("play", object=post["audio"]["items"][0])
return True
def open_person_profile(self, *args, **kwargs):
""" Views someone's profile."""
selected = self.get_post()
if selected == None:
return
# Check all possible keys for an user object in VK API.
keys = ["from_id", "source_id", "id"]
for i in keys:
if i in selected:
pub.sendMessage("user-profile", person=selected[i])
break
def open_post(self, *args, **kwargs):
""" Opens the currently focused post."""
post = self.get_post()
if post == None:
return
if "type" in post and post["type"] == "audio":
a = presenters.displayAudioPresenter(session=self.session, postObject=post["audio"]["items"], interactor=interactors.displayAudioInteractor(), view=views.displayAudio())
elif "type" in post and post["type"] == "friend":
pub.sendMessage("open-post", post_object=post, controller_="displayFriendship", vars=dict(caption=_("{user1_nom} added the following friends")))
else:
pub.sendMessage("open-post", post_object=post, controller_="displayPost")
def pause_audio(self, *args, **kwargs):
""" pauses audio playback."""
pub.sendMessage("pause")
def remove_buffer(self, mandatory):
""" Function for removing a buffer. Returns True if removal is successful, False otherwise"""
return False
def get_users(self):
""" Returns source user in the post."""
post = self.get_post()
if post == None:
return
if ("type" in post) == False:
return [post["from_id"]]
else:
return [post["source_id"]]
def onFocus(self, event, *args,**kwargs):
""" Function executed when the item in a list is selected.
For this buffer it updates the date of posts in the list."""
post = self.get_post()
if post == None:
return
original_date = arrow.get(post["date"])
created_at = original_date.humanize(locale=languageHandler.curLang[:2])
self.tab.list.list.SetItem(self.tab.list.get_selected(), 2, created_at)
event.Skip()
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/wall{user_id}_{post_id}".format(user_id=post["source_id"], post_id=post["post_id"])
webbrowser.open_new_tab(url)

View File

@ -1,16 +0,0 @@
# -*- coding: utf-8 -*-
import logging
from wxUI.tabs import notification
from .wall import wallBuffer
log = logging.getLogger("controller.buffers")
class notificationBuffer(wallBuffer):
def create_tab(self, parent):
self.tab = notification.notificationTab(parent)
self.connect_events()
self.tab.name = self.name
def onFocus(self, event, *args, **kwargs):
event.Skip()

View File

@ -1,225 +0,0 @@
# -*- coding: utf-8 -*-
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
import time
import logging
import webbrowser
import arrow
import wx
import presenters
import views
import interactors
import languageHandler
import widgetUtils
from pubsub import pub
from wxUI.tabs import people
from wxUI.dialogs import timeline
from mysc.thread_utils import call_threaded
from wxUI import commonMessages, menus
from .wall import wallBuffer
log = logging.getLogger("controller.buffers.friends")
class peopleBuffer(wallBuffer):
def post(self, *args, **kwargs):
user = self.get_post()
if "can_post" not in user: # retrieve data if not present in the object.
user = self.session.vk.client.users.get(user_ids=user["id"], fields="can_post")[0]
if user.get("can_post") == True:
user_str = self.session.get_user(user["id"], key="user1")
title = _("Post to {user1_nom}'s wall").format(**user_str)
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=user["id"])
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
def create_tab(self, parent):
self.tab = people.peopleTab(parent)
self.connect_events()
self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)
def connect_events(self):
super(peopleBuffer, self).connect_events()
widgetUtils.connect_event(self.tab.new_chat, widgetUtils.BUTTON_PRESSED, self.new_chat)
def new_chat(self, *args, **kwargs):
user = self.get_post()
if user == None:
return
user_id = user["id"]
pub.sendMessage("new-chat", user_id=user_id)
def onFocus(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
if post.get("can_post") == True:
self.tab.post.Enable(True)
else:
self.tab.post.Enable(False)
# Check if we are allowed to contact people. this might be false for communitiy members.
if post.get("can_write_private_message") == True:
self.tab.new_chat.Enable(True)
else:
self.tab.new_chat.Enable(False)
if ("last_seen" in post) == False: return
original_date = arrow.get(post["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
online_status = _("Last seen {0}").format(original_date.humanize(locale=languageHandler.curLang[:2]),)
self.tab.list.list.SetItem(self.tab.list.get_selected(), 1, online_status)
def open_timeline(self, *args, **kwargs):
user = self.get_post()
if user == None:
return
a = timeline.timelineDialog([self.session.get_user(user["id"])["user1_gen"]], show_selector=False)
if a.get_response() == widgetUtils.OK:
buffer_type = a.get_buffer_type()
user_id = user["id"]
pub.sendMessage("create-timeline", user_id=user_id, buffer_type=buffer_type)
def get_menu(self, *args, **kwargs):
""" display menu for people buffers (friends and requests)"""
# If this is an incoming requests buffer, there is a flag in the peopleMenu that shows a few new options.
# So let's make sure we call it accordingly.
if self.name == "friend_requests":
m = menus.peopleMenu(is_request=True)
# Connect the accept and decline methods from here.
widgetUtils.connect_event(m, widgetUtils.MENU, self.accept_friendship, menuitem=m.accept)
widgetUtils.connect_event(m, widgetUtils.MENU, self.decline_friendship, menuitem=m.decline)
widgetUtils.connect_event(m, widgetUtils.MENU, self.keep_as_follower, menuitem=m.keep_as_follower)
elif self.name == "subscribers":
m = menus.peopleMenu(is_subscriber=True)
widgetUtils.connect_event(m, widgetUtils.MENU, self.accept_friendship, menuitem=m.add)
else:
m = menus.peopleMenu(is_request=False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.decline_friendship, menuitem=m.decline)
widgetUtils.connect_event(m, widgetUtils.MENU, self.block_person, menuitem=m.block)
# It is not allowed to send messages to people who is not your friends, so let's disable it if we're in a pending or outgoing requests buffer.
if "friend_requests" in self.name:
m.message.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.new_chat, menuitem=m.message)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_timeline, menuitem=m.timeline)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_person_profile, menuitem=m.view_profile)
widgetUtils.connect_event(m, widgetUtils.MENU, self.open_in_browser, menuitem=m.open_in_browser)
return m
def open_post(self, *args, **kwargs): pass
def play_audio(self, *args, **kwargs): return False
def pause_audio(self, *args, **kwargs): pass
def accept_friendship(self, *args, **kwargs):
pass
def decline_friendship(self, *args, **kwargs):
person = self.get_post()
if person == None:
return
user = self.session.get_user(person["id"])
question = commonMessages.remove_friend(user)
if question == widgetUtils.NO:
return
result = self.session.vk.client.friends.delete(user_id=person["id"])
if "friend_deleted" in result:
msg = _("You've removed {user1_nom} from your friends.").format(**user,)
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
def block_person(self, *args, **kwargs):
person = self.get_post()
if person == None:
return
user = self.session.get_user(person["id"])
question = commonMessages.block_person(user)
if question == widgetUtils.NO:
return
result = self.session.vk.client.account.ban(owner_id=person["id"])
if result == 1:
msg = _("You've blocked {user1_nom} from your friends.").format(**user,)
pub.sendMessage("notify", message=msg)
self.session.db[self.name]["items"].pop(self.tab.list.get_selected())
self.tab.list.remove_item(self.tab.list.get_selected())
def keep_as_follower(self, *args, **kwargs):
pass
def add_person(self, person):
# This tracks if the user already exists here, in such case we just will update the last_seen variable
existing = False
for i in self.session.db[self.name]["items"]:
if person["id"] == i["id"]:
existing = True
i["last_seen"]["time"] = person["last_seen"]["time"]
break
# Add the new user to the buffer just if it does not exists previously.
if existing == False:
# Ensure the user won't loose the focus after the new item is added.
focused_item = self.tab.list.get_selected()+1
self.session.db[self.name]["items"].insert(0, person)
self.insert(person, True)
# Selects back the previously focused item.
self.tab.list.select_item(focused_item)
def remove_person(self, user_id):
# Make sure the user is present in the buffer, otherwise don't attempt to remove a None Value from the list.
user = None
focused_user = self.get_post()
for i in self.session.db[self.name]["items"]:
if i["id"] == user_id:
user = i
break
if user != None:
person_index = self.session.db[self.name]["items"].index(user)
focused_item = self.tab.list.get_selected()
self.session.db[self.name]["items"].pop(person_index)
self.tab.list.remove_item(person_index)
if user != focused_user:
# Let's find the position of the previously focused user.
focus = None
for i in range(0, len(self.session.db[self.name]["items"])):
if focused_user["id"] == self.session.db[self.name]["items"][i]["id"]:
self.tab.list.select_item(i)
return
elif user == focused_user and person_index < self.tab.list.get_count():
self.tab.list.select_item(person_index)
else:
self.tab.list.select_item(self.tab.list.get_count()-1)
def get_friend(self, user_id):
for i in self.session.db["friends_"]["items"]:
if i["id"] == user_id:
return i
log.exception("Getting user manually...")
user = self.session.vk.client.users.get(user_ids=event.user_id, fields="last_seen")[0]
return user
def update_online(self):
online_users = self.session.vk.client.friends.getOnline()
now = time.time()
for i in self.session.db[self.name]["items"]:
if i["id"] in online_users:
i["last_seen"]["time"] = now
else:
log.exception("Removing an user from online status manually... %r" % (i))
self.remove_person(i["id"])
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/id{user_id}".format(user_id=post["id"])
webbrowser.open_new_tab(url)

View File

@ -1,125 +0,0 @@
# -*- coding: utf-8 -*-
import logging
import webbrowser
import wx
import widgetUtils
import output
from wxUI.tabs import video
from wxUI import commonMessages, menus
from controller import selector
from .wall import wallBuffer
log = logging.getLogger("controller.buffers.video")
class videoBuffer(wallBuffer):
""" This buffer represents video elements, and it can be used for showing videos for the logged user or someone else."""
def create_tab(self, parent):
self.tab = video.videoTab(parent)
self.connect_events()
self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)
def connect_events(self):
widgetUtils.connect_event(self.tab.play, widgetUtils.BUTTON_PRESSED, self.play_audio)
super(videoBuffer, self).connect_events()
def play_audio(self, *args, **kwargs):
""" Due to inheritance this method should be called play_audio, but play the currently focused video.
Opens a webbrowser pointing to the video's URL."""
selected = self.tab.list.get_selected()
if self.tab.list.get_count() == 0:
return
if selected == -1:
selected = 0
output.speak(_("Opening video in webbrowser..."))
webbrowser.open_new_tab(self.session.db[self.name]["items"][selected]["player"])
# print self.session.db[self.name]["items"][selected]
return True
def open_post(self, *args, **kwargs):
pass
def remove_buffer(self, mandatory=False):
if "me_video" == self.name:
output.speak(_("This buffer can't be deleted"))
return False
else:
if mandatory == False:
dlg = commonMessages.remove_buffer()
else:
dlg = widgetUtils.YES
if dlg == widgetUtils.YES:
self.session.db.pop(self.name)
return True
else:
return False
def get_more_items(self, *args, **kwargs):
# Translators: Some buffers can't use the get previous item feature due to API limitations.
output.speak(_("This buffer doesn't support getting more items."))
def onFocus(self, event, *args, **kwargs):
event.Skip()
def add_to_library(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
args = {}
args["video_id"] = post["id"]
if "album_id" in post:
args["album_id"] = post["album_id"]
args["owner_id"] = post["owner_id"]
video = self.session.vk.client.video.add(**args)
if video != None and int(video) > 21:
output.speak(_("Video added to your library"))
def remove_from_library(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
args = {}
args["video_id"] = post["id"]
args["owner_id"] = self.session.user_id
result = self.session.vk.client.video.delete(**args)
if int(result) == 1:
output.speak(_("Removed video from library"))
self.tab.list.remove_item(self.tab.list.get_selected())
def move_to_album(self, *args, **kwargs):
if len(self.session.video_albums) == 0:
return commonMessages.no_video_albums()
post= self.get_post()
if post == None:
return
album = selector.album(_("Select the album where you want to move this video"), self.session, "video_albums")
if album.item == None: return
id = post["id"]
response = self.session.vk.client.video.addToAlbum(album_ids=album.item, video_id=id, target_id=self.session.user_id, owner_id=self.get_post()["owner_id"])
if response == 1:
# Translators: Used when the user has moved an video to an album.
output.speak(_("Moved"))
def get_menu(self):
""" We'll use the same menu that is used for audio items, as the options are exactly the same"""
p = self.get_post()
if p == None:
return
m = menus.audioMenu()
widgetUtils.connect_event(m, widgetUtils.MENU, self.move_to_album, menuitem=m.move)
# if owner_id is the current user, the audio is added to the user's audios.
if p["owner_id"] == self.session.user_id:
m.library.SetItemLabel(_("&Remove"))
widgetUtils.connect_event(m, widgetUtils.MENU, self.remove_from_library, menuitem=m.library)
else:
widgetUtils.connect_event(m, widgetUtils.MENU, self.add_to_library, menuitem=m.library)
return m
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/video{user_id}_{video_id}".format(user_id=post["owner_id"], video_id=post["id"])
webbrowser.open_new_tab(url)

View File

@ -1,30 +0,0 @@
# -*- coding: utf-8 -*-
import logging
import wx
import widgetUtils
import output
from wxUI.tabs import videoAlbum
from .video import videoBuffer
log = logging.getLogger("controller.buffers")
class videoAlbumBuffer(videoBuffer):
def create_tab(self, parent):
self.tab = video.videoAlbumTab(parent)
self.tab.play.Enable(False)
self.connect_events()
self.tab.name = self.name
if hasattr(self, "can_post") and self.can_post == False and hasattr(self.tab, "post"):
self.tab.post.Enable(False)
def connect_events(self):
super(videoAlbumBuffer, self).connect_events()
widgetUtils.connect_event(self.tab.load, widgetUtils.BUTTON_PRESSED, self.load_album)
def load_album(self, *args, **kwargs):
output.speak(_("Loading album..."))
self.can_get_items = True
self.tab.load.Enable(False)
wx.CallAfter(self.get_items)
self.tab.play.Enable(True)

View File

@ -1,104 +0,0 @@
# -*- coding: utf-8 -*-
""" A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
import logging
import webbrowser
import wx
import presenters
import views
import interactors
import widgetUtils
import output
from pubsub import pub
from vk_api.exceptions import VkApiError
from mysc.thread_utils import call_threaded
from wxUI import commonMessages
from .home import homeBuffer
log = logging.getLogger("controller.buffers.wall")
class wallBuffer(homeBuffer):
""" This buffer represents an user's wall. It may be used either for the current user or someone else."""
def get_items(self, show_nextpage=False):
""" Update buffer with newest items or get older items in the buffer."""
if self.can_get_items == False: return
retrieved = True
try:
num = getattr(self.session, "get_page")(show_nextpage=show_nextpage, name=self.name, *self.args, **self.kwargs)
except VkApiError as err:
log.error("Error {0}: {1}".format(err.code, err.error))
retrieved = err.code
return retrieved
except:
log.exception("Connection error when updating buffer %s. Will try again in 2 minutes" % (self.name,))
return False
if not hasattr(self, "tab"):
# Create GUI associated to this buffer.
self.create_tab(self.parent)
# Add name to the new control so we could look for it when needed.
self.tab.name = self.name
if show_nextpage == False:
if self.tab.list.get_count() > 0 and num > 0:
v = [i for i in self.session.db[self.name]["items"][:num]]
v.reverse()
[wx.CallAfter(self.insert, i, True) for i in v]
else:
[wx.CallAfter(self.insert, i) for i in self.session.db[self.name]["items"][:num]]
else:
if num > 0:
[wx.CallAfter(self.insert, i, False) for i in self.session.db[self.name]["items"][-num:]]
return retrieved
def remove_buffer(self, mandatory=False):
""" Remove buffer if the current buffer is not the logged user's wall."""
if "me_feed" == self.name:
output.speak(_("This buffer can't be deleted"))
return False
else:
if mandatory == False:
dlg = commonMessages.remove_buffer()
else:
dlg = widgetUtils.YES
if dlg == widgetUtils.YES:
self.session.db.pop(self.name)
return True
else:
return False
def __init__(self, *args, **kwargs):
super(wallBuffer, self).__init__(*args, **kwargs)
self.user_key = "from_id"
self.post_key = "id"
self.can_post = True
self.can_write_private_message = True
# if this is an user timeline we must check permissions to hide buttons when needed.
if "owner_id" in self.kwargs and self.kwargs["owner_id"] > 0 and "feed" in self.name:
permissions = self.session.vk.client.users.get(user_ids=self.kwargs["owner_id"], fields="can_post, can_see_all_posts, can_write_private_message")
self.can_post = permissions[0]["can_post"]
self.can_see_all_posts = permissions[0]["can_see_all_posts"]
self.can_write_private_message = permissions[0]["can_write_private_message"]
log.debug("Checked permissions on buffer {0}, permissions were {1}".format(self.name, permissions))
def post(self, *args, **kwargs):
""" Create a post in the wall for the specified user
This process is handled in two parts. This is the first part, where the GUI is created and user can send the post.
During the second part (threaded), the post will be sent to the API."""
if "owner_id" not in self.kwargs:
return super(wallBuffer, self).post()
owner_id = self.kwargs["owner_id"]
user = self.session.get_user(owner_id, key="user1")
title = _("Post to {user1_nom}'s wall").format(**user)
p = presenters.createPostPresenter(session=self.session, interactor=interactors.createPostInteractor(), view=views.createPostDialog(title=title, message="", text=""))
if hasattr(p, "text") or hasattr(p, "privacy"):
post_arguments=dict(privacy=p.privacy, message=p.text, owner_id=owner_id)
attachments = []
if hasattr(p, "attachments"):
attachments = p.attachments
call_threaded(pub.sendMessage, "post", parent_endpoint="wall", child_endpoint="post", from_buffer=self.name, attachments_list=attachments, post_arguments=post_arguments)
def open_in_browser(self, *args, **kwargs):
post = self.get_post()
if post == None:
return
url = "https://vk.com/wall{user_id}_{post_id}".format(user_id=post["from_id"], post_id=post["id"])
webbrowser.open_new_tab(url)

File diff suppressed because it is too large Load Diff

View File

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

View File

@ -1,6 +1,4 @@
from __future__ import absolute_import
from __future__ import unicode_literals
from . import spellchecker from . import spellchecker
import platform import platform
if platform.system() == "Windows": if platform.system() == "Windows":
from .wx_ui import * from .wx_ui import *

View File

@ -1,76 +1,74 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os from __future__ import unicode_literals
import logging import logging
from . import wx_ui
import widgetUtils import widgetUtils
import output import output
import config import config
import languageHandler import languageHandler
import enchant
import paths
from . import twitterFilter
from enchant.checker import SpellChecker from enchant.checker import SpellChecker
from enchant.errors import DictNotFoundError from enchant.errors import DictNotFoundError
from enchant import tokenize from enchant import tokenize
from . import wx_ui
log = logging.getLogger("extra.SpellChecker.spellChecker") log = logging.getLogger("extra.SpellChecker.spellChecker")
class spellChecker(object): class spellChecker(object):
def __init__(self, text): def __init__(self, text, dictionary):
super(spellChecker, self).__init__() super(spellChecker, self).__init__()
self.active = True log.debug("Creating the SpellChecker object. Dictionary: %s" % (dictionary,))
try: self.active = True
if config.app["app-settings"]["language"] == "system": try:
log.debug("Using the system language") if config.app["app-settings"]["language"] == "system":
self.dict = enchant.DictWithPWL(languageHandler.curLang[:2], os.path.join(paths.config_path(), "wordlist.dict")) log.debug("Using the system language")
else: self.checker = SpellChecker(languageHandler.curLang, filters=[tokenize.EmailFilter, tokenize.URLFilter])
log.debug("Using language: %s" % (languageHandler.getLanguage(),)) else:
self.dict = enchant.DictWithPWL(languageHandler.getLanguage()[:2], os.path.join(paths.config_path(), "wordlist.dict")) log.debug("Using language: %s" % (languageHandler.getLanguage(),))
except DictNotFoundError: self.checker = SpellChecker(languageHandler.curLang, filters=[tokenize.EmailFilter, tokenize.URLFilter])
log.exception("Dictionary for language %s not found." % (languageHandler.getLanguage(),)) self.checker.set_text(text)
wx_ui.dict_not_found_error() except DictNotFoundError:
self.active = False print("no dict")
self.checker = SpellChecker(self.dict, filters=[twitterFilter.TwitterFilter, tokenize.EmailFilter, tokenize.URLFilter]) log.exception("Dictionary for language %s not found." % (dictionary,))
self.checker.set_text(text) wx_ui.dict_not_found_error()
if self.active == True: self.active = False
log.debug("Creating dialog...") if self.active == True:
self.dialog = wx_ui.spellCheckerDialog() log.debug("Creating dialog...")
widgetUtils.connect_event(self.dialog.ignore, widgetUtils.BUTTON_PRESSED, self.ignore) self.dialog = wx_ui.spellCheckerDialog()
widgetUtils.connect_event(self.dialog.ignoreAll, widgetUtils.BUTTON_PRESSED, self.ignoreAll) widgetUtils.connect_event(self.dialog.ignore, widgetUtils.BUTTON_PRESSED, self.ignore)
widgetUtils.connect_event(self.dialog.replace, widgetUtils.BUTTON_PRESSED, self.replace) widgetUtils.connect_event(self.dialog.ignoreAll, widgetUtils.BUTTON_PRESSED, self.ignoreAll)
widgetUtils.connect_event(self.dialog.replaceAll, widgetUtils.BUTTON_PRESSED, self.replaceAll) widgetUtils.connect_event(self.dialog.replace, widgetUtils.BUTTON_PRESSED, self.replace)
widgetUtils.connect_event(self.dialog.add, widgetUtils.BUTTON_PRESSED, self.add) widgetUtils.connect_event(self.dialog.replaceAll, widgetUtils.BUTTON_PRESSED, self.replaceAll)
self.check() self.check()
self.dialog.get_response() self.dialog.get_response()
self.fixed_text = self.checker.get_text() self.fixed_text = self.checker.get_text()
def check(self): def check(self):
try: try:
next(self.checker) next(self.checker)
textToSay = _(u"Misspelled word: %s") % (self.checker.word,) textToSay = _("Misspelled word: %s") % (self.checker.word,)
context = u"... %s %s %s" % (self.checker.leading_context(10), self.checker.word, self.checker.trailing_context(10)) context = "... %s %s %s" % (self.checker.leading_context(10), self.checker.word, self.checker.trailing_context(10))
self.dialog.set_title(textToSay) self.dialog.set_title(textToSay)
output.speak(textToSay) output.speak(textToSay)
self.dialog.set_word_and_suggestions(word=self.checker.word, context=context, suggestions=self.checker.suggest()) self.dialog.set_word_and_suggestions(word=self.checker.word, context=context, suggestions=self.checker.suggest())
except StopIteration: except StopIteration:
log.debug("Process finished.") log.debug("Process finished.")
wx_ui.finished() wx_ui.finished()
self.dialog.Destroy() self.dialog.Destroy()
def ignore(self, ev): def ignore(self, ev):
self.check() self.check()
def ignoreAll(self, ev): def ignoreAll(self, ev):
self.checker.ignore_always(word=self.checker.word) self.checker.ignore_always(word=self.checker.word)
self.check() self.check()
def replace(self, ev): def replace(self, ev):
self.checker.replace(self.dialog.get_selected_suggestion()) self.checker.replace(self.dialog.get_selected_suggestion())
self.check() self.check()
def replaceAll(self, ev): def replaceAll(self, ev):
self.checker.replace_always(self.dialog.get_selected_suggestion()) self.checker.replace_always(self.dialog.get_selected_suggestion())
self.check() self.check()
def add(self, ev): def clean(self):
self.checker.add() if hasattr(self, "dialog"):
self.check() self.dialog.Destroy()

View File

@ -1,16 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import re
from enchant.tokenize import Filter
class TwitterFilter(Filter):
"""Filter skipping over twitter usernames and hashtags.
This filter skips any words matching the following regular expression:
^[#@](\S){1, }$
That is, any words that resemble users and hashtags.
"""
_pattern = re.compile(r"^[#@](\S){1,}$")
def _skip(self,word):
if self._pattern.match(word):
return True
return False

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################ ############################################################
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net> # Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
@ -21,63 +21,60 @@ import wx
import application import application
class spellCheckerDialog(wx.Dialog): class spellCheckerDialog(wx.Dialog):
def __init__(self): def __init__(self):
super(spellCheckerDialog, self).__init__(None, 1) super(spellCheckerDialog, self).__init__(None, 1)
panel = wx.Panel(self) panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL) 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) self.word = wx.TextCtrl(panel, -1)
wordBox = wx.BoxSizer(wx.HORIZONTAL) wordBox = wx.BoxSizer(wx.HORIZONTAL)
wordBox.Add(word, 0, wx.ALL, 5) wordBox.Add(word, 0, wx.ALL, 5)
wordBox.Add(self.word, 0, wx.ALL, 5) wordBox.Add(self.word, 0, wx.ALL, 5)
context = wx.StaticText(panel, -1, _(u"Context")) context = wx.StaticText(panel, -1, _("Con&text"))
self.context = wx.TextCtrl(panel, -1) self.context = wx.TextCtrl(panel, -1)
contextBox = wx.BoxSizer(wx.HORIZONTAL) contextBox = wx.BoxSizer(wx.HORIZONTAL)
contextBox.Add(context, 0, wx.ALL, 5) contextBox.Add(context, 0, wx.ALL, 5)
contextBox.Add(self.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) self.suggestions = wx.ListBox(panel, -1, choices=[], style=wx.LB_SINGLE)
suggestionsBox = wx.BoxSizer(wx.HORIZONTAL) suggestionsBox = wx.BoxSizer(wx.HORIZONTAL)
suggestionsBox.Add(suggest, 0, wx.ALL, 5) suggestionsBox.Add(suggest, 0, wx.ALL, 5)
suggestionsBox.Add(self.suggestions, 0, wx.ALL, 5) suggestionsBox.Add(self.suggestions, 0, wx.ALL, 5)
self.ignore = wx.Button(panel, -1, _(u"&Ignore")) self.ignore = wx.Button(panel, -1, _("&Ignore"))
self.ignoreAll = wx.Button(panel, -1, _(u"I&gnore all")) self.ignoreAll = wx.Button(panel, -1, _("Ignore &all"))
self.replace = wx.Button(panel, -1, _(u"&Replace")) self.replace = wx.Button(panel, -1, _("&Replace"))
self.replaceAll = wx.Button(panel, -1, _(u"R&eplace all")) self.replaceAll = wx.Button(panel, -1, _("Replace a&ll"))
self.add = wx.Button(panel, -1, _(u"&Add to personal dictionary")) close = wx.Button(panel, wx.ID_CANCEL)
close = wx.Button(panel, wx.ID_CANCEL) btnBox = wx.BoxSizer(wx.HORIZONTAL)
btnBox = wx.BoxSizer(wx.HORIZONTAL) btnBox.Add(self.ignore, 0, wx.ALL, 5)
btnBox.Add(self.ignore, 0, wx.ALL, 5) btnBox.Add(self.ignoreAll, 0, wx.ALL, 5)
btnBox.Add(self.ignoreAll, 0, wx.ALL, 5) btnBox.Add(self.replace, 0, wx.ALL, 5)
btnBox.Add(self.replace, 0, wx.ALL, 5) btnBox.Add(self.replaceAll, 0, wx.ALL, 5)
btnBox.Add(self.replaceAll, 0, wx.ALL, 5) btnBox.Add(close, 0, wx.ALL, 5)
btnBox.Add(self.add, 0, wx.ALL, 5) sizer.Add(wordBox, 0, wx.ALL, 5)
btnBox.Add(close, 0, wx.ALL, 5) sizer.Add(contextBox, 0, wx.ALL, 5)
sizer.Add(wordBox, 0, wx.ALL, 5) sizer.Add(suggestionsBox, 0, wx.ALL, 5)
sizer.Add(contextBox, 0, wx.ALL, 5) sizer.Add(btnBox, 0, wx.ALL, 5)
sizer.Add(suggestionsBox, 0, wx.ALL, 5) panel.SetSizer(sizer)
sizer.Add(btnBox, 0, wx.ALL, 5) self.SetClientSize(sizer.CalcMin())
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def get_response(self):
return self.ShowModal()
def get_response(self): def set_title(self, title):
return self.ShowModal() return self.SetTitle(title)
def set_title(self, title): def set_word_and_suggestions(self, word, context, suggestions):
return self.SetTitle(title) self.word.SetValue(word)
self.context.ChangeValue(context)
self.suggestions.Set(suggestions)
self.suggestions.SetFocus()
def set_word_and_suggestions(self, word, context, suggestions): def get_selected_suggestion(self):
self.word.SetValue(word) return self.suggestions.GetStringSelection()
self.context.ChangeValue(context)
self.suggestions.Set(suggestions)
self.suggestions.SetFocus()
def get_selected_suggestion(self):
return self.suggestions.GetStringSelection()
def dict_not_found_error(): 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(): 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()

View File

@ -1,5 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import platform import platform
if platform.system() == "Windows":
from . import wx_ui as gui
from . import translator from . import translator
if platform.system() == "Windows":
from . import wx_ui as gui

View File

@ -1,116 +1,115 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import logging from __future__ import unicode_literals
from googletrans import Translator, LANGUAGES from builtins import zip
from yandex_translate import YandexTranslate
log = logging.getLogger("extras.translator")
# create a single translator instance
# see https://github.com/ssut/py-googletrans/issues/234
t = None
def translate(text="", target="en"): def translate(text="", target="en"):
global t t = YandexTranslate("trnsl.1.1.20161012T134532Z.d01b9c75fc39aa74.7d1be75a5166a80583eeb020e10f584168da6bf7")
log.debug("Received translation request for language %s, text=%s" % (target, text)) vars = dict(text=text, lang=target)
if t == None: return t.translate(**vars)["text"][0]
t = Translator()
vars = dict(text=text, dest=target)
return t.translate(**vars).text
supported_langs = None supported_langs = None
d = None
languages = { languages = {
"af": _(u"Afrikaans"), "af": _("Afrikaans"),
"sq": _(u"Albanian"), "sq": _("Albanian"),
"am": _(u"Amharic"), "am": _("Amharic"),
"ar": _(u"Arabic"), "ar": _("Arabic"),
"hy": _(u"Armenian"), "hy": _("Armenian"),
"az": _(u"Azerbaijani"), "az": _("Azerbaijani"),
"eu": _(u"Basque"), "eu": _("Basque"),
"be": _(u"Belarusian"), "be": _("Belarusian"),
"bn": _(u"Bengali"), "bn": _("Bengali"),
"bh": _(u"Bihari"), "bh": _("Bihari"),
"bg": _(u"Bulgarian"), "bg": _("Bulgarian"),
"my": _(u"Burmese"), "my": _("Burmese"),
"ca": _(u"Catalan"), "ca": _("Catalan"),
"chr": _(u"Cherokee"), "chr": _("Cherokee"),
"zh": _(u"Chinese"), "zh": _("Chinese"),
"zh-CN": _(u"Chinese_simplified"), "zh-CN": _("Chinese_simplified"),
"zh-TW": _(u"Chinese_traditional"), "zh-TW": _("Chinese_traditional"),
"hr": _(u"Croatian"), "hr": _("Croatian"),
"cs": _(u"Czech"), "cs": _("Czech"),
"da": _(u"Danish"), "da": _("Danish"),
"dv": _(u"Dhivehi"), "dv": _("Dhivehi"),
"nl": _(u"Dutch"), "nl": _("Dutch"),
"en": _(u"English"), "en": _("English"),
"eo": _(u"Esperanto"), "eo": _("Esperanto"),
"et": _(u"Estonian"), "et": _("Estonian"),
"tl": _(u"Filipino"), "tl": _("Filipino"),
"fi": _(u"Finnish"), "fi": _("Finnish"),
"fr": _(u"French"), "fr": _("French"),
"gl": _(u"Galician"), "gl": _("Galician"),
"ka": _(u"Georgian"), "ka": _("Georgian"),
"de": _(u"German"), "de": _("German"),
"el": _(u"Greek"), "el": _("Greek"),
"gn": _(u"Guarani"), "gn": _("Guarani"),
"gu": _(u"Gujarati"), "gu": _("Gujarati"),
"iw": _(u"Hebrew"), "iw": _("Hebrew"),
"hi": _(u"Hindi"), "hi": _("Hindi"),
"hu": _(u"Hungarian"), "hu": _("Hungarian"),
"is": _(u"Icelandic"), "is": _("Icelandic"),
"id": _(u"Indonesian"), "id": _("Indonesian"),
"iu": _(u"Inuktitut"), "iu": _("Inuktitut"),
"ga": _(u"Irish"), "ga": _("Irish"),
"it": _(u"Italian"), "it": _("Italian"),
"ja": _(u"Japanese"), "ja": _("Japanese"),
"kn": _(u"Kannada"), "kn": _("Kannada"),
"kk": _(u"Kazakh"), "kk": _("Kazakh"),
"km": _(u"Khmer"), "km": _("Khmer"),
"ko": _(u"Korean"), "ko": _("Korean"),
"ku": _(u"Kurdish"), "ku": _("Kurdish"),
"ky": _(u"Kyrgyz"), "ky": _("Kyrgyz"),
"lo": _(u"Laothian"), "lo": _("Laothian"),
"lv": _(u"Latvian"), "lv": _("Latvian"),
"lt": _(u"Lithuanian"), "lt": _("Lithuanian"),
"mk": _(u"Macedonian"), "mk": _("Macedonian"),
"ms": _(u"Malay"), "ms": _("Malay"),
"ml": _(u"Malayalam"), "ml": _("Malayalam"),
"mt": _(u"Maltese"), "mt": _("Maltese"),
"mr": _(u"Marathi"), "mr": _("Marathi"),
"mn": _(u"Mongolian"), "mn": _("Mongolian"),
"ne": _(u"Nepali"), "ne": _("Nepali"),
"no": _(u"Norwegian"), "no": _("Norwegian"),
"or": _(u"Oriya"), "or": _("Oriya"),
"ps": _(u"Pashto"), "ps": _("Pashto"),
"fa": _(u"Persian"), "fa": _("Persian"),
"pl": _(u"Polish"), "pl": _("Polish"),
"pt": _(u"Portuguese"), "pt": _("Portuguese"),
"pa": _(u"Punjabi"), "pa": _("Punjabi"),
"ro": _(u"Romanian"), "ro": _("Romanian"),
"ru": _(u"Russian"), "ru": _("Russian"),
"sa": _(u"Sanskrit"), "sa": _("Sanskrit"),
"sr": _(u"Serbian"), "sr": _("Serbian"),
"sd": _(u"Sindhi"), "sd": _("Sindhi"),
"si": _(u"Sinhalese"), "si": _("Sinhalese"),
"sk": _(u"Slovak"), "sk": _("Slovak"),
"sl": _(u"Slovenian"), "sl": _("Slovenian"),
"es": _(u"Spanish"), "es": _("Spanish"),
"sw": _(u"Swahili"), "sw": _("Swahili"),
"sv": _(u"Swedish"), "sv": _("Swedish"),
"tg": _(u"Tajik"), "tg": _("Tajik"),
"ta": _(u"Tamil"), "ta": _("Tamil"),
"tl": _(u"Tagalog"), "tl": _("Tagalog"),
"te": _(u"Telugu"), "te": _("Telugu"),
"th": _(u"Thai"), "th": _("Thai"),
"bo": _(u"Tibetan"), "bo": _("Tibetan"),
"tr": _(u"Turkish"), "tr": _("Turkish"),
"uk": _(u"Ukrainian"), "uk": _("Ukrainian"),
"ur": _(u"Urdu"), "ur": _("Urdu"),
"uz": _(u"Uzbek"), "uz": _("Uzbek"),
"ug": _(u"Uighur"), "ug": _("Uighur"),
"vi": _(u"Vietnamese"), "vi": _("Vietnamese"),
"cy": _(u"Welsh"), "cy": _("Welsh"),
"yi": _(u"Yiddish") "yi": _("Yiddish")
} }
def available_languages(): def available_languages():
return dict(sorted(languages.items(), key=lambda x: x[1])) global supported_langs, d
if supported_langs == None and d == None:
t = YandexTranslate("trnsl.1.1.20161012T134532Z.d01b9c75fc39aa74.7d1be75a5166a80583eeb020e10f584168da6bf7")
supported_langs = t.langs
d = []
for i in supported_langs:
d.append(languages[i])
return sorted(zip(supported_langs, d))

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################ ############################################################
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net> # Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
@ -16,30 +16,29 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
############################################################ ############################################################
from . import translator from __future__ import unicode_literals
import wx import wx
from widgetUtils import BaseDialog from . import translator
class translateDialog(BaseDialog): class translateDialog(wx.Dialog):
def __init__(self): def __init__(self):
languages = [] super(translateDialog, self).__init__(None, -1, title=_("Translate message"))
language_dict = translator.available_languages() panel = wx.Panel(self)
for k in language_dict: sizer = wx.BoxSizer(wx.VERTICAL)
languages.append(language_dict[k]) staticDest = wx.StaticText(panel, -1, _("Target language"))
super(translateDialog, self).__init__(None, -1, title=_(u"Translate message")) self.dest_lang = wx.ComboBox(panel, -1, choices=[x[1] for x in translator.available_languages()], style = wx.CB_READONLY)
panel = wx.Panel(self) self.dest_lang.SetFocus()
sizer = wx.BoxSizer(wx.VERTICAL) self.dest_lang.SetSelection(0)
staticDest = wx.StaticText(panel, -1, _(u"Target language")) listSizer = wx.BoxSizer(wx.HORIZONTAL)
self.dest_lang = wx.ComboBox(panel, -1, choices=languages, style = wx.CB_READONLY) listSizer.Add(staticDest)
self.dest_lang.SetFocus() listSizer.Add(self.dest_lang)
self.dest_lang.SetSelection(0) ok = wx.Button(panel, wx.ID_OK)
listSizer = wx.BoxSizer(wx.HORIZONTAL) ok.SetDefault()
listSizer.Add(staticDest) cancel = wx.Button(panel, wx.ID_CANCEL)
listSizer.Add(self.dest_lang) self.SetEscapeId(wx.ID_CANCEL)
ok = wx.Button(panel, wx.ID_OK)
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL)
self.SetEscapeId(wx.ID_CANCEL)
def get(self, control): def get(self, control):
return getattr(self, control).GetSelection() return getattr(self, control).GetSelection()
def get_response(self):
return self.ShowModal()

14
src/fixes/__init__.py Normal file
View File

@ -0,0 +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
def setup():
fix_requests.fix()
# if hasattr(sys, "frozen"):
fix_libloader.fix()
fix_win32com.fix()

View File

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

12
src/fixes/fix_requests.py Normal file
View File

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import requests
import paths
import os
import logging
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(), "cacert.pem")#.encode(paths.fsencoding)
# log.debug("Changed CA path to %s" % (os.environ["REQUESTS_CA_BUNDLE"]))#.decode(paths.fsencoding)))

View File

@ -0,0 +1,6 @@
from __future__ import unicode_literals
import win32com.client
def fix():
if win32com.client.gencache.is_readonly == True:
win32com.client.gencache.is_readonly = False
win32com.client.gencache.Rebuild()

View File

@ -1,12 +1,11 @@
!include "MUI2.nsh" !include "MUI2.nsh"
!include "LogicLib.nsh" !include "LogicLib.nsh"
!include "x64.nsh"
Unicode true Unicode true
CRCCheck on CRCCheck on
ManifestSupportedOS all ManifestSupportedOS all
XPStyle on XPStyle on
Name "Socializer" Name "Socializer"
OutFile "socializer_setup.exe" OutFile "socializer_0.23_setup.exe"
InstallDir "$PROGRAMFILES\socializer" InstallDir "$PROGRAMFILES\socializer"
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "InstallLocation" InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "InstallLocation"
RequestExecutionLevel admin RequestExecutionLevel admin
@ -15,10 +14,10 @@ SetCompressor /solid lzma
SetDatablockOptimize on SetDatablockOptimize on
VIAddVersionKey ProductName "Socializer" VIAddVersionKey ProductName "Socializer"
VIAddVersionKey LegalCopyright "Copyright 2019 Manuel Cortez." VIAddVersionKey LegalCopyright "Copyright 2019 Manuel Cortez."
VIAddVersionKey ProductVersion "0.24" VIAddVersionKey ProductVersion "0.23"
VIAddVersionKey FileVersion "0.24" VIAddVersionKey FileVersion "0.23"
VIProductVersion "0.24.0.0" VIProductVersion "0.23.0.0"
VIFileVersion "0.24.0.0" VIFileVersion "0.23.0.0"
!insertmacro MUI_PAGE_WELCOME !insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_DIRECTORY !insertmacro MUI_PAGE_DIRECTORY
var StartMenuFolder var StartMenuFolder
@ -38,11 +37,7 @@ var StartMenuFolder
Section Section
SetShellVarContext All SetShellVarContext All
SetOutPath "$INSTDIR" SetOutPath "$INSTDIR"
${If} ${RunningX64} File /r dist\main\*
File /r program64\*
${Else}
File /r program32\*
${EndIf}
CreateShortCut "$DESKTOP\socializer.lnk" "$INSTDIR\socializer.exe" CreateShortCut "$DESKTOP\socializer.lnk" "$INSTDIR\socializer.exe"
!insertmacro MUI_STARTMENU_WRITE_BEGIN startmenu !insertmacro MUI_STARTMENU_WRITE_BEGIN startmenu
CreateDirectory "$SMPROGRAMS\$StartMenuFolder" CreateDirectory "$SMPROGRAMS\$StartMenuFolder"
@ -55,7 +50,7 @@ WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "UninstallString" '"$INSTDIR\uninstall.exe"' WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "UninstallString" '"$INSTDIR\uninstall.exe"'
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "InstallLocation" $INSTDIR
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "Publisher" "Manuel Cortez" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall" "Publisher" "Manuel Cortez"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayVersion" "0.24" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "DisplayVersion" "0.23"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "URLInfoAbout" "http://socializer.su" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "URLInfoAbout" "http://socializer.su"
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMajor" 0 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMajor" 0
WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMinor" 19 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\socializer" "VersionMinor" 19
@ -72,7 +67,4 @@ RMDir /r "$SMPROGRAMS\$StartMenuFolder"
SectionEnd SectionEnd
Function .onInit Function .onInit
!insertmacro MUI_LANGDLL_DISPLAY !insertmacro MUI_LANGDLL_DISPLAY
${If} ${RunningX64}
StrCpy $instdir "$programfiles64\socializer"
${EndIf}
FunctionEnd FunctionEnd

View File

@ -1,8 +1,7 @@
from .base import *
from .attach import * from .attach import *
from . audioRecorder import * from . audioRecorder import *
from . blacklist import * from . blacklist import *
from .configuration import * from .configuration import *
from .postCreation import * from .postCreation import *
from .postDisplayer import * from .postDisplayer import *
from .profiles import * from .profiles import *

View File

@ -8,86 +8,86 @@ from . import base
class attachInteractor(base.baseInteractor): class attachInteractor(base.baseInteractor):
def insert_attachment(self, attachment): def insert_attachment(self, attachment):
self.view.attachments.insert_item(False, *attachment) self.view.attachments.insert_item(False, *attachment)
def remove_attachment(self, attachment): def remove_attachment(self, attachment):
self.view.attachments.remove_item(attachment) self.view.attachments.remove_item(attachment)
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(attachInteractor, self).install(*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.photo, widgetUtils.BUTTON_PRESSED, self.on_image)
widgetUtils.connect_event(self.view.audio, widgetUtils.BUTTON_PRESSED, self.on_audio) widgetUtils.connect_event(self.view.audio, widgetUtils.BUTTON_PRESSED, self.on_audio)
widgetUtils.connect_event(self.view.document, widgetUtils.BUTTON_PRESSED, self.on_document) widgetUtils.connect_event(self.view.document, widgetUtils.BUTTON_PRESSED, self.on_document)
if hasattr(self.view, "voice_message"): 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.voice_message, widgetUtils.BUTTON_PRESSED, self.on_upload_voice_message)
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_attachment) 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.insert_attachment, self.modulename+"_insert_attachment")
pub.subscribe(self.remove_attachment, self.modulename+"_remove_attachment") pub.subscribe(self.remove_attachment, self.modulename+"_remove_attachment")
def uninstall(self): def uninstall(self):
super(attachInteractor, self).uninstall() super(attachInteractor, self).uninstall()
pub.unsubscribe(self.insert_attachment, self.modulename+"_insert_attachment") pub.unsubscribe(self.insert_attachment, self.modulename+"_insert_attachment")
pub.unsubscribe(self.remove_attachment, self.modulename+"_remove_attachment") pub.unsubscribe(self.remove_attachment, self.modulename+"_remove_attachment")
def on_image(self, *args, **kwargs): def on_image(self, *args, **kwargs):
""" display menu for adding image attachments. """ """ display menu for adding image attachments. """
m = attachMenu() m = attachMenu()
# disable add from VK as it is not supported in images, yet. # disable add from VK as it is not supported in images, yet.
m.add.Enable(False) m.add.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.on_upload_image, menuitem=m.upload) widgetUtils.connect_event(m, widgetUtils.MENU, self.on_upload_image, menuitem=m.upload)
self.view.PopupMenu(m, self.view.photo.GetPosition()) self.view.PopupMenu(m, self.view.photo.GetPosition())
def on_audio(self, *args, **kwargs): def on_audio(self, *args, **kwargs):
""" display menu to add audio attachments.""" """ display menu to add audio attachments."""
m = attachMenu() m = attachMenu()
widgetUtils.connect_event(m, widgetUtils.MENU, self.on_upload_audio, menuitem=m.upload) 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) widgetUtils.connect_event(m, widgetUtils.MENU, self.on_add_audio, menuitem=m.add)
self.view.PopupMenu(m, self.view.audio.GetPosition()) self.view.PopupMenu(m, self.view.audio.GetPosition())
def on_document(self, *args, **kwargs): def on_document(self, *args, **kwargs):
""" display menu for adding document attachments. """ """ display menu for adding document attachments. """
m = attachMenu() m = attachMenu()
# disable add from VK as it is not supported in documents, yet. # disable add from VK as it is not supported in documents, yet.
m.add.Enable(False) m.add.Enable(False)
widgetUtils.connect_event(m, widgetUtils.MENU, self.on_upload_document, menuitem=m.upload) widgetUtils.connect_event(m, widgetUtils.MENU, self.on_upload_document, menuitem=m.upload)
self.view.PopupMenu(m, self.view.photo.GetPosition()) self.view.PopupMenu(m, self.view.photo.GetPosition())
def on_upload_image(self, *args, **kwargs): def on_upload_image(self, *args, **kwargs):
""" allows uploading an image from the computer. """ allows uploading an image from the computer.
""" """
image, description = self.view.get_image() image, description = self.view.get_image()
if image != None: if image != None:
self.presenter.upload_image(image, description) self.presenter.upload_image(image, description)
def on_upload_audio(self, *args, **kwargs): def on_upload_audio(self, *args, **kwargs):
""" Allows uploading an audio file from the computer. Only mp3 files are supported. """ """ Allows uploading an audio file from the computer. Only mp3 files are supported. """
audio = self.view.get_audio() audio = self.view.get_audio()
if audio != None: if audio != None:
self.presenter.upload_audio(audio) self.presenter.upload_audio(audio)
def on_upload_document(self, *args, **kwargs): def on_upload_document(self, *args, **kwargs):
""" allows uploading a document from the computer. """ allows uploading a document from the computer.
""" """
document = self.view.get_document() document = self.view.get_document()
if document != None: if document != None:
if document.endswith(".mp3") or document.endswith(".exe"): if document.endswith(".mp3") or document.endswith(".exe"):
self.view.invalid_attachment() self.view.invalid_attachment()
return return
self.presenter.upload_document(document) self.presenter.upload_document(document)
def on_upload_voice_message(self, *args, **kwargs): def on_upload_voice_message(self, *args, **kwargs):
self.presenter.upload_voice_message() self.presenter.upload_voice_message()
def on_add_audio(self, *args, **kwargs): def on_add_audio(self, *args, **kwargs):
""" Allow adding an audio directly from the user's audio library.""" """ Allow adding an audio directly from the user's audio library."""
audios = self.presenter.get_available_audios() audios = self.presenter.get_available_audios()
select = selector.selectAttachment(_("Select the audio files you want to send"), audios) select = selector.selectAttachment(_("Select the audio files you want to send"), audios)
if select.get_response() == widgetUtils.OK and select.attachments.GetCount() > 0: if select.get_response() == widgetUtils.OK and select.attachments.GetCount() > 0:
attachments = select.get_all_attachments() attachments = select.get_all_attachments()
self.presenter.take_audios(attachments) self.presenter.take_audios(attachments)
def on_remove_attachment(self, *args, **kwargs): def on_remove_attachment(self, *args, **kwargs):
""" Remove the currently focused item from the attachments list.""" """ Remove the currently focused item from the attachments list."""
current_item = self.view.attachments.get_selected() current_item = self.view.attachments.get_selected()
self.presenter.remove_attachment(current_item) self.presenter.remove_attachment(current_item)

View File

@ -5,25 +5,25 @@ from pubsub import pub
from . import base from . import base
class audioRecorderInteractor(base.baseInteractor): class audioRecorderInteractor(base.baseInteractor):
def install(self, presenter, view, modulename="audiorecorder"): def install(self, presenter, view, modulename="audiorecorder"):
super(audioRecorderInteractor, self).install(view=view, presenter=presenter, modulename=modulename) 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.play, widgetUtils.BUTTON_PRESSED, self.on_play)
widgetUtils.connect_event(view.record, widgetUtils.BUTTON_PRESSED, self.on_record) widgetUtils.connect_event(view.record, widgetUtils.BUTTON_PRESSED, self.on_record)
widgetUtils.connect_event(view.discard, widgetUtils.BUTTON_PRESSED, self.on_discard) widgetUtils.connect_event(view.discard, widgetUtils.BUTTON_PRESSED, self.on_discard)
def start(self): def start(self):
result = self.view.get_response() result = self.view.get_response()
if result == widgetUtils.OK: if result == widgetUtils.OK:
self.on_postprocess() self.on_postprocess()
def on_record(self, *args, **kwargs): def on_record(self, *args, **kwargs):
self.presenter.toggle_recording() self.presenter.toggle_recording()
def on_discard(self, *args, **kwargs): def on_discard(self, *args, **kwargs):
self.presenter.discard_recording() self.presenter.discard_recording()
def on_play(self, *args, **kwargs): def on_play(self, *args, **kwargs):
self.presenter.play() self.presenter.play()
def on_postprocess(self): def on_postprocess(self):
self.presenter.postprocess() self.presenter.postprocess()

View File

@ -3,38 +3,38 @@ from pubsub import pub
class baseInteractor(object): class baseInteractor(object):
def install(self, view, presenter, modulename): def install(self, view, presenter, modulename):
self.modulename = modulename self.modulename = modulename
self.view = view self.view = view
self.presenter = presenter self.presenter = presenter
pub.subscribe(self.disable_control, "{modulename}_disable_control".format(modulename=modulename)) 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.enable_control, "{modulename}_enable_control".format(modulename=modulename))
pub.subscribe(self.set_label, "{modulename}_set_label".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.focus_control, "{modulename}_focus_control".format(modulename=modulename))
pub.subscribe(self.set_title, "{modulename}_set_title".format(modulename=modulename)) pub.subscribe(self.set_title, "{modulename}_set_title".format(modulename=modulename))
def uninstall(self): def uninstall(self):
pub.unsubscribe(self.disable_control, "{modulename}_disable_control".format(modulename=self.modulename)) 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.enable_control, "{modulename}_enable_control".format(modulename=self.modulename))
pub.unsubscribe(self.set_label, "{modulename}_set_label".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.focus_control, "{modulename}_focus_control".format(modulename=self.modulename))
pub.unsubscribe(self.set_title, "{modulename}_set_title".format(modulename=self.modulename)) pub.unsubscribe(self.set_title, "{modulename}_set_title".format(modulename=self.modulename))
self.view.Destroy() self.view.Destroy()
def start(self): def start(self):
self.result = self.view.get_response() self.result = self.view.get_response()
def disable_control(self, control): def disable_control(self, control):
self.view.disable(control) self.view.disable(control)
def enable_control(self, control): def enable_control(self, control):
self.view.enable(control) self.view.enable(control)
def focus_control(self, control): def focus_control(self, control):
getattr(self.view, control).SetFocus() getattr(self.view, control).SetFocus()
def set_label(self, control, label): def set_label(self, control, label):
self.view.set(control, label) self.view.set(control, label)
def set_title(self, value): def set_title(self, value):
self.view.SetTitle(value) self.view.SetTitle(value)

View File

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

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import widgetUtils import widgetUtils
from pubsub import pub from pubsub import pub
from wxUI.commonMessages import restart_program as restart_program_dialog from wxUI.commonMessages import restart_program as restart_program_dialog
@ -6,55 +7,66 @@ from . import base
class configurationInteractor(base.baseInteractor): class configurationInteractor(base.baseInteractor):
def create_tab(self, tab, arglist=dict()): def create_tab(self, tab, arglist=dict()):
getattr(self.view, "create_"+tab)(**arglist) getattr(self.view, "create_"+tab)(**arglist)
def set_setting(self, tab, setting, value): def set_setting(self, tab, setting, value):
self.view.set_value(tab, setting, value) self.view.set_value(tab, setting, value)
def restart(self): def restart(self):
dlg = restart_program_dialog() dlg = restart_program_dialog()
if dlg == widgetUtils.YES: if dlg == widgetUtils.YES:
self.presenter.restart_application() self.presenter.restart_application()
def set_language(self, language): def set_language(self, language):
self.view.general.language.SetSelection(language) self.view.general.language.SetSelection(language)
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(configurationInteractor, self).install(*args, **kwargs) super(configurationInteractor, self).install(*args, **kwargs)
pub.subscribe(self.create_tab, self.modulename+"_create_tab") pub.subscribe(self.create_tab, self.modulename+"_create_tab")
pub.subscribe(self.set_setting, self.modulename+"_set") pub.subscribe(self.set_setting, self.modulename+"_set")
pub.subscribe(self.restart, self.modulename+"_restart_program") pub.subscribe(self.restart, self.modulename+"_restart_program")
pub.subscribe(self.set_language, self.modulename+"_set_language") pub.subscribe(self.set_language, self.modulename+"_set_language")
def uninstall(self): def uninstall(self):
super(configurationInteractor, self).uninstall() super(configurationInteractor, self).uninstall()
pub.unsubscribe(self.create_tab, self.modulename+"_create_tab") pub.unsubscribe(self.create_tab, self.modulename+"_create_tab")
pub.unsubscribe(self.set_setting, self.modulename+"_set") pub.unsubscribe(self.set_setting, self.modulename+"_set")
pub.unsubscribe(self.restart, self.modulename+"_restart_program") pub.unsubscribe(self.restart, self.modulename+"_restart_program")
pub.unsubscribe(self.set_language, self.modulename+"_set_language") pub.unsubscribe(self.set_language, self.modulename+"_set_language")
def start(self): def start(self):
self.view.realize() self.view.realize()
result = self.view.get_response() result = self.view.get_response()
if result == widgetUtils.OK: if result == widgetUtils.OK:
self.on_save_settings() self.on_save_settings()
def on_save_settings(self, *args, **kwargs): def on_save_settings(self, *args, **kwargs):
self.presenter.update_setting(section="buffers", setting="count_for_wall_buffers", value=self.view.get_value("buffers", "wall_buffer_count")) self.presenter.update_setting(section="buffers", setting="count_for_wall_buffers", value=self.view.get_value("buffers", "wall_buffer_count"))
self.presenter.update_setting(section="buffers", setting="count_for_video_buffers", value=self.view.get_value("buffers", "video_buffers_count")) self.presenter.update_setting(section="buffers", setting="count_for_video_buffers", value=self.view.get_value("buffers", "video_buffers_count"))
self.presenter.update_setting(section="buffers", setting="count_for_chat_buffers", value=self.view.get_value("buffers", "chat_buffers_count")) self.presenter.update_setting(section="buffers", setting="count_for_chat_buffers", value=self.view.get_value("buffers", "chat_buffers_count"))
self.presenter.update_setting(section="general", setting="load_images", value=self.view.get_value("general", "load_images")) self.presenter.update_setting(section="general", setting="load_images", value=self.view.get_value("general", "load_images"))
self.presenter.update_setting(section="chat", setting="notify_online", value=self.view.get_value("chat", "notify_online")) update_channel = self.presenter.get_update_channel_type(self.view.get_value("general", "update_channel"))
self.presenter.update_setting(section="chat", setting="notify_offline", value=self.view.get_value("chat", "notify_offline")) if update_channel != self.presenter.session.settings["general"]["update_channel"]:
self.presenter.update_setting(section="chat", setting="notifications", value=self.presenter.get_notification_type(self.view.get_value("chat", "notifications"))) if update_channel == "stable":
self.presenter.update_setting(section="load_at_startup", setting="audio_albums", value=self.view.get_value("startup", "audio_albums")) self.presenter.update_setting(section="general", setting="update_channel", value=update_channel)
self.presenter.update_setting(section="load_at_startup", setting="video_albums", value=self.view.get_value("startup", "video_albums")) elif update_channel == "weekly":
self.presenter.update_setting(section="load_at_startup", setting="communities", value=self.view.get_value("startup", "communities")) dialog = self.view.weekly_channel()
self.presenter.update_app_setting(section="app-settings", setting="language", value=self.presenter.codes[self.view.general.language.GetSelection()]) if dialog == widgetUtils.YES:
self.presenter.update_app_setting(section="sound", setting="input_device", value=self.view.get_value("sound", "input")) self.presenter.update_setting(section="general", setting="update_channel", value=update_channel)
self.presenter.update_app_setting(section="sound", setting="output_device", value=self.view.get_value("sound", "output")) elif update_channel == "alpha":
# self.presenter.update_app_setting(section="app-settings", setting="use_proxy", value=self.view.get_value("general", "use_proxy")) dialog = self.view.alpha_channel()
self.presenter.update_app_setting(section="app-settings", setting="debug_logging", value=self.view.get_value("general", "debug_logging")) if dialog == widgetUtils.YES:
self.presenter.save_app_settings_file() self.presenter.update_setting(section="general", setting="update_channel", value=update_channel)
self.presenter.save_settings_file() 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()

View File

@ -1,4 +1,5 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import widgetUtils import widgetUtils
from wxUI.dialogs import selector from wxUI.dialogs import selector
from pubsub import pub from pubsub import pub
@ -7,67 +8,64 @@ from .import base
class createPostInteractor(base.baseInteractor): class createPostInteractor(base.baseInteractor):
def set(self, control, value): def set(self, control, value):
if not hasattr(self.view, control): if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
getattr(self.view, control).SetValue(value) getattr(self.view, control).SetValue(value)
def add_tagged_users(self, users): def add_tagged_users(self, users):
self.view.text.SetValue(self.view.text.GetValue()+", ".join(users)) self.view.text.SetValue(self.view.text.GetValue()+", ".join(users))
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(createPostInteractor, self).install(*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.spellcheck, widgetUtils.BUTTON_PRESSED, self.on_spellcheck)
widgetUtils.connect_event(self.view.translateButton, widgetUtils.BUTTON_PRESSED, self.on_translate) widgetUtils.connect_event(self.view.translateButton, widgetUtils.BUTTON_PRESSED, self.on_translate)
widgetUtils.connect_event(self.view.mention, widgetUtils.BUTTON_PRESSED, self.on_mention) widgetUtils.connect_event(self.view.mention, widgetUtils.BUTTON_PRESSED, self.on_mention)
if hasattr(self.view, "attach"): if hasattr(self.view, "attach"):
widgetUtils.connect_event(self.view.attach, widgetUtils.BUTTON_PRESSED, self.on_add_attachments) widgetUtils.connect_event(self.view.attach, widgetUtils.BUTTON_PRESSED, self.on_add_attachments)
pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.add_tagged_users, self.modulename+"_add_tagged_users") pub.subscribe(self.add_tagged_users, self.modulename+"_add_tagged_users")
def uninstall(self): def uninstall(self):
super(createPostInteractor, self).uninstall() super(createPostInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.add_tagged_users, self.modulename+"_add_tagged_users") pub.unsubscribe(self.add_tagged_users, self.modulename+"_add_tagged_users")
def start(self): def start(self):
self.result = self.view.get_response() self.result = self.view.get_response()
if self.result == widgetUtils.OK: if self.result == widgetUtils.OK:
self.presenter.text = self.view.get_text() self.presenter.text = self.view.get_text()
if hasattr(self.view, "privacy"): if hasattr(self.view, "privacy"):
self.presenter.privacy = self.get_privacy_options() self.presenter.privacy = self.get_privacy_options()
else: else:
self.presenter.privacy = 0 self.presenter.privacy = 0
def get_privacy_options(self): def get_privacy_options(self):
p = self.view.get("privacy") p = self.view.get("privacy")
if p == _("Friends of friends"): if p == _("Friends of friends"):
privacy = 0 privacy = 0
elif p == _("All users"): elif p == _("All users"):
privacy = 1 privacy = 1
return privacy return privacy
def on_mention(self, *args, **kwargs): def on_mention(self, *args, **kwargs):
users = self.presenter.get_friends() users = self.presenter.get_friends()
select = selector.selectPeople(users) select = selector.selectPeople(users)
if select.get_response() == widgetUtils.OK and select.users.GetCount() > 0: if select.get_response() == widgetUtils.OK and select.users.GetCount() > 0:
tagged_users = select.get_all_users() tagged_users = select.get_all_users()
self.presenter.add_tagged_users(tagged_users) self.presenter.add_tagged_users(tagged_users)
def on_translate(self, *args, **kwargs): def on_translate(self, *args, **kwargs):
dlg = translator.gui.translateDialog() dlg = translator.gui.translateDialog()
if dlg.get_response() == widgetUtils.OK: if dlg.get_response() == widgetUtils.OK:
text_to_translate = self.view.get_text() text_to_translate = self.view.get_text()
language_dict = translator.translator.available_languages() dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
for k in language_dict: self.presenter.translate(text_to_translate, dest)
if language_dict[k] == dlg.dest_lang.GetStringSelection(): dlg.Destroy()
dst = k
self.presenter.translate(text_to_translate, dst)
dlg.Destroy()
def on_spellcheck(self, event=None): def on_spellcheck(self, event=None):
text = self.view.get_text() text = self.view.get_text()
self.presenter.spellcheck(text) self.presenter.spellcheck(text)
def on_add_attachments(self, *args, **kwargs): def on_add_attachments(self, *args, **kwargs):
self.presenter.add_attachments() self.presenter.add_attachments()

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import unicode_literals
import six import six
import widgetUtils import widgetUtils
import wx import wx
from extra import translator
from pubsub import pub from pubsub import pub
from wxUI import menus from wxUI import menus
from wxUI import commonMessages from wxUI import commonMessages
@ -10,295 +10,277 @@ from .import base
class displayPostInteractor(base.baseInteractor): class displayPostInteractor(base.baseInteractor):
def set(self, control, value): def set(self, control, value):
if not hasattr(self.view, control): if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
getattr(self.view, control).SetValue(value) getattr(self.view, control).SetValue(value)
def load_image(self, image): def load_image(self, image):
image = wx.Image(stream=six.BytesIO(image.content)) image = wx.Image(stream=six.BytesIO(image.content))
try: try:
self.view.image.SetBitmap(wx.Bitmap(image)) self.view.image.SetBitmap(wx.Bitmap(image))
except ValueError: except ValueError:
return return
self.view.panel.Layout() self.view.panel.Layout()
def add_items(self, control, items): def add_items(self, control, items):
if not hasattr(self.view, control): if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
for i in items: for i in items:
getattr(self.view, control).insert_item(False, *i) getattr(self.view, control).insert_item(False, *i)
def add_item(self, control, item, reversed=False): def add_item(self, control, item, reversed=False):
if not hasattr(self.view, control): if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
getattr(self.view, control).insert_item(reversed, *item) getattr(self.view, control).insert_item(reversed, *item)
def enable_attachments(self): def enable_attachments(self):
self.view.attachments.list.Enable(True) self.view.attachments.list.Enable(True)
def enable_photo_controls(self, navigation): def enable_photo_controls(self, navigation):
self.view.enable_photo_controls(navigation) self.view.enable_photo_controls(navigation)
def clean_list(self, list): def clean_list(self, list):
if not hasattr(self.view, list): if not hasattr(self.view, list):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
getattr(self.view, list).clear() getattr(self.view, list).clear()
def post_deleted(self): def post_deleted(self):
msg = commonMessages.post_deleted() msg = commonMessages.post_deleted()
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(displayPostInteractor, self).install(*args, **kwargs) super(displayPostInteractor, self).install(*args, **kwargs)
if hasattr(self.view, "comments"): if hasattr(self.view, "comments"):
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_show_comment) self.view.comments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_show_comment)
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_comment_changed) self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_comment_changed)
self.view.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_open_attachment) self.view.attachments.list.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_open_attachment)
widgetUtils.connect_event(self.view.like, widgetUtils.BUTTON_PRESSED, self.on_like) widgetUtils.connect_event(self.view.like, widgetUtils.BUTTON_PRESSED, self.on_like)
widgetUtils.connect_event(self.view.comment, widgetUtils.BUTTON_PRESSED, self.on_add_comment) widgetUtils.connect_event(self.view.comment, widgetUtils.BUTTON_PRESSED, self.on_add_comment)
widgetUtils.connect_event(self.view.tools, widgetUtils.BUTTON_PRESSED, self.on_show_tools_menu) widgetUtils.connect_event(self.view.tools, widgetUtils.BUTTON_PRESSED, self.on_show_tools_menu)
if hasattr(self.view, "likes"): if hasattr(self.view, "likes"):
widgetUtils.connect_event(self.view.likes, widgetUtils.BUTTON_PRESSED, self.on_show_likes_menu) widgetUtils.connect_event(self.view.likes, widgetUtils.BUTTON_PRESSED, self.on_show_likes_menu)
if hasattr(self.view, "shares"): if hasattr(self.view, "shares"):
widgetUtils.connect_event(self.view.shares, widgetUtils.BUTTON_PRESSED, self.on_show_shares_menu) widgetUtils.connect_event(self.view.shares, widgetUtils.BUTTON_PRESSED, self.on_show_shares_menu)
if hasattr(self.view, "repost"): if hasattr(self.view, "repost"):
widgetUtils.connect_event(self.view.repost, widgetUtils.BUTTON_PRESSED, self.on_repost) widgetUtils.connect_event(self.view.repost, widgetUtils.BUTTON_PRESSED, self.on_repost)
self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_focus) self.view.comments.list.Bind(wx.EVT_LIST_ITEM_FOCUSED, self.on_focus)
if hasattr(self.view, "reply"): if hasattr(self.view, "reply"):
widgetUtils.connect_event(self.view.reply, widgetUtils.BUTTON_PRESSED, self.on_reply) widgetUtils.connect_event(self.view.reply, widgetUtils.BUTTON_PRESSED, self.on_reply)
if hasattr(self.view, "load_more_comments"): if hasattr(self.view, "load_more_comments"):
widgetUtils.connect_event(self.view.load_more_comments, widgetUtils.BUTTON_PRESSED, self.on_load_more_comments) widgetUtils.connect_event(self.view.load_more_comments, widgetUtils.BUTTON_PRESSED, self.on_load_more_comments)
# self.view.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_show_menu, self.view.comments.list) # self.view.Bind(wx.EVT_LIST_ITEM_RIGHT_CLICK, self.on_show_menu, self.view.comments.list)
# self.view.Bind(wx.EVT_LIST_KEY_DOWN, self.on_show_menu_by_key, self.view.comments.list) # self.view.Bind(wx.EVT_LIST_KEY_DOWN, self.on_show_menu_by_key, self.view.comments.list)
pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.load_image, self.modulename+"_load_image") pub.subscribe(self.load_image, self.modulename+"_load_image")
pub.subscribe(self.add_items, self.modulename+"_add_items") pub.subscribe(self.add_items, self.modulename+"_add_items")
pub.subscribe(self.add_item, self.modulename+"_add_item") pub.subscribe(self.add_item, self.modulename+"_add_item")
pub.subscribe(self.enable_attachments, self.modulename+"_enable_attachments") pub.subscribe(self.enable_attachments, self.modulename+"_enable_attachments")
pub.subscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls") pub.subscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls")
pub.subscribe(self.post_deleted, self.modulename+"_post_deleted") pub.subscribe(self.post_deleted, self.modulename+"_post_deleted")
pub.subscribe(self.clean_list, self.modulename+"_clean_list") pub.subscribe(self.clean_list, self.modulename+"_clean_list")
def uninstall(self): def uninstall(self):
super(displayPostInteractor, self).uninstall() super(displayPostInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.load_image, self.modulename+"_load_image") pub.unsubscribe(self.load_image, self.modulename+"_load_image")
pub.unsubscribe(self.add_items, self.modulename+"_add_items") pub.unsubscribe(self.add_items, self.modulename+"_add_items")
pub.unsubscribe(self.add_item, self.modulename+"_add_item") pub.unsubscribe(self.add_item, self.modulename+"_add_item")
pub.unsubscribe(self.enable_attachments, self.modulename+"_enable_attachments") pub.unsubscribe(self.enable_attachments, self.modulename+"_enable_attachments")
pub.unsubscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls") pub.unsubscribe(self.enable_photo_controls, self.modulename+"_enable_photo_controls")
pub.unsubscribe(self.post_deleted, self.modulename+"_post_deleted") pub.unsubscribe(self.post_deleted, self.modulename+"_post_deleted")
pub.unsubscribe(self.clean_list, self.modulename+"_clean_list") pub.unsubscribe(self.clean_list, self.modulename+"_clean_list")
def on_focus(self, *args, **kwargs): def on_focus(self, *args, **kwargs):
item = self.view.comments.get_selected() item = self.view.comments.get_selected()
if item == -1: if item == -1:
self.view.reply.Enable(False) self.view.reply.Enable(False)
else: else:
self.view.reply.Enable(True) self.view.reply.Enable(True)
def on_like(self, *args, **kwargs): def on_like(self, *args, **kwargs):
self.presenter.post_like() self.presenter.post_like()
def on_repost(self, *args, **kwargs): def on_repost(self, *args, **kwargs):
self.presenter.post_repost() self.presenter.post_repost()
def on_reply(self, *args, **kwargs): def on_reply(self, *args, **kwargs):
if hasattr(self.view, "comments") and (hasattr(self.view, "repost") or not hasattr(self, "post_view")): if hasattr(self.view, "comments") and (hasattr(self.view, "repost") or not hasattr(self, "post_view")):
comment = self.view.comments.get_selected() comment = self.view.comments.get_selected()
self.presenter.reply(comment) self.presenter.reply(comment)
else: else:
self.presenter.reply() self.presenter.reply()
def on_add_comment(self, *args, **kwargs): def on_add_comment(self, *args, **kwargs):
self.presenter.add_comment() self.presenter.add_comment()
def on_load_more_comments(self, *args, **kwargs): def on_load_more_comments(self, *args, **kwargs):
if hasattr(self.presenter, "load_more_comments"): if hasattr(self.presenter, "load_more_comments"):
self.presenter.load_more_comments() self.presenter.load_more_comments()
def on_show_tools_menu(self, *args, **kwargs): def on_show_tools_menu(self, *args, **kwargs):
menu = menus.toolsMenu() menu = menus.toolsMenu()
# widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_open_url, menuitem=menu.url) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_open_url, menuitem=menu.url)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_translate, menuitem=menu.translate) 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.spellcheck) widgetUtils.connect_event(self.view, widgetUtils.MENU, self.on_spellcheck, menuitem=menu.CheckSpelling)
self.view.PopupMenu(menu, self.view.tools.GetPosition()) self.view.PopupMenu(menu, self.view.tools.GetPosition())
def on_open_url(self, *args, **kwargs): def on_open_url(self, *args, **kwargs):
pass pass
def on_open_attachment(self, *args, **kwargs): def on_open_attachment(self, *args, **kwargs):
attachment = self.view.attachments.get_selected() attachment = self.view.attachments.get_selected()
self.presenter.open_attachment(attachment) self.presenter.open_attachment(attachment)
def on_translate(self, *args, **kwargs): def on_translate(self, *args, **kwargs):
dlg = translator.gui.translateDialog() dlg = translator.gui.translateDialog()
if dlg.get_response() == widgetUtils.OK: if dlg.get_response() == widgetUtils.OK:
text_to_translate = self.view.get("post_view") text_to_translate = self.view.get("post_view")
language_dict = translator.translator.available_languages() dest = [x[0] for x in translator.translator.available_languages()][dlg.get("dest_lang")]
for k in language_dict: self.presenter.translate(text_to_translate, dest)
if language_dict[k] == dlg.dest_lang.GetStringSelection(): dlg.Destroy()
dst = k
self.presenter.translate(text_to_translate, dst)
dlg.Destroy()
def on_spellcheck(self, event=None): def on_spellcheck(self, event=None):
text = self.view.get("post_view") text = self.view.get("post_view")
self.presenter.spellcheck(text) self.presenter.spellcheck(text)
def on_show_comment(self, *args, **kwargs): def on_show_comment(self, *args, **kwargs):
comment = self.view.comments.get_selected() comment = self.view.comments.get_selected()
self.presenter.show_comment(comment) self.presenter.show_comment(comment)
def on_comment_changed(self, *args, **kwargs): def on_comment_changed(self, *args, **kwargs):
if hasattr(self.presenter, "change_comment"): if hasattr(self.presenter, "change_comment"):
comment = self.view.comments.get_selected() comment = self.view.comments.get_selected()
self.presenter.change_comment(comment) self.presenter.change_comment(comment)
def on_show_likes_menu(self, *args, **kwargs): def on_show_likes_menu(self, *args, **kwargs):
self.presenter.show_likes() self.presenter.show_likes()
def on_show_shares_menu(self, *args, **kwargs): def on_show_shares_menu(self, *args, **kwargs):
self.presenter.show_shares() self.presenter.show_shares()
class displayAudioInteractor(base.baseInteractor): class displayAudioInteractor(base.baseInteractor):
def set(self, control, value): def set(self, control, value):
if not hasattr(self.view, control): if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
getattr(self.view, control).SetValue(value) getattr(self.view, control).SetValue(value)
def add_items(self, control, items): def add_items(self, control, items):
if not hasattr(self.view, control): if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
for i in items: for i in items:
getattr(self.view, control).Append(i) getattr(self.view, control).Append(i)
getattr(self.view, control).SetSelection(0) getattr(self.view, control).SetSelection(0)
def change_label(self, stopped): def change_label(self, stopped):
if stopped == False: if stopped == False:
self.view.play.SetLabel(_("P&ause")) self.view.play.SetLabel(_("P&ause"))
else: else:
self.view.play.SetLabel(_("P&lay")) self.view.play.SetLabel(_("P&lay"))
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(displayAudioInteractor, self).install(*args, **kwargs) super(displayAudioInteractor, self).install(*args, **kwargs)
widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_CHANGED, self.on_change) widgetUtils.connect_event(self.view.list, widgetUtils.LISTBOX_CHANGED, self.on_change)
widgetUtils.connect_event(self.view.download, widgetUtils.BUTTON_PRESSED, self.on_download) 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.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.add, widgetUtils.BUTTON_PRESSED, self.on_add_to_library)
widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_from_library) widgetUtils.connect_event(self.view.remove, widgetUtils.BUTTON_PRESSED, self.on_remove_from_library)
pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.add_items, self.modulename+"_add_items") pub.subscribe(self.add_items, self.modulename+"_add_items")
pub.subscribe(self.change_label, "playback-changed") pub.subscribe(self.change_label, "playback-changed")
def uninstall(self): def uninstall(self):
super(displayAudioInteractor, self).uninstall() super(displayAudioInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.add_items, self.modulename+"_add_items") pub.unsubscribe(self.add_items, self.modulename+"_add_items")
pub.unsubscribe(self.change_label, "playback-changed") pub.unsubscribe(self.change_label, "playback-changed")
def on_change(self, *args, **kwargs): def on_change(self, *args, **kwargs):
post = self.view.get_audio() post = self.view.get_audio()
self.presenter.handle_changes(post) self.presenter.handle_changes(post)
def on_download(self, *args, **kwargs): def on_download(self, *args, **kwargs):
post = self.view.get_audio() post = self.view.get_audio()
suggested_filename = self.presenter.get_suggested_filename(post) suggested_filename = self.presenter.get_suggested_filename(post)
path = self.view.get_destination_path(suggested_filename) path = self.view.get_destination_path(suggested_filename)
self.presenter.download(post, path) self.presenter.download(post, path)
def on_play(self, *args, **kwargs): def on_play(self, *args, **kwargs):
post = self.view.get_audio() post = self.view.get_audio()
self.presenter.play(post) self.presenter.play(post)
def on_add_to_library(self, *args, **kwargs): def on_add_to_library(self, *args, **kwargs):
post = self.view.get_audio() post = self.view.get_audio()
self.presenter.add_to_library(post) self.presenter.add_to_library(post)
def on_remove_from_library(self, *args, **kwargs): def on_remove_from_library(self, *args, **kwargs):
post = self.view.get_audio() post = self.view.get_audio()
self.presenter.remove_from_library(post) self.presenter.remove_from_library(post)
class displayArticleInteractor(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 install(self, *args, **kwargs):
super(displayArticleInteractor, self).install(*args, **kwargs)
pub.subscribe(self.set, self.modulename+"_set")
def uninstall(self):
super(displayArticleInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set")
class displayPollInteractor(base.baseInteractor): class displayPollInteractor(base.baseInteractor):
def set(self, control, value): def set(self, control, value):
if not hasattr(self.view, control): if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
getattr(self.view, control).SetValue(value) getattr(self.view, control).SetValue(value)
def done(self): def done(self):
self.view.done() self.view.done()
def add_options(self, options, multiple): def add_options(self, options, multiple):
self.view.add_options(options, multiple) self.view.add_options(options, multiple)
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(displayPollInteractor, self).install(*args, **kwargs) super(displayPollInteractor, self).install(*args, **kwargs)
pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.done, self.modulename+"_done") pub.subscribe(self.done, self.modulename+"_done")
pub.subscribe(self.add_options, self.modulename+"_add_options") pub.subscribe(self.add_options, self.modulename+"_add_options")
def uninstall(self): def uninstall(self):
super(displayPollInteractor, self).uninstall() super(displayPollInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.done, self.modulename+"_done") pub.unsubscribe(self.done, self.modulename+"_done")
pub.unsubscribe(self.add_options, self.modulename+"_add_options") pub.unsubscribe(self.add_options, self.modulename+"_add_options")
def start(self, *args, **kwargs): def start(self, *args, **kwargs):
super(displayPollInteractor, self).start(*args, **kwargs) super(displayPollInteractor, self).start(*args, **kwargs)
if self.result == widgetUtils.OK: # USer votd. if self.result == widgetUtils.OK: # USer votd.
answers = self.view.get_answers() answers = self.view.get_answers()
self.presenter.vote(answers) self.presenter.vote(answers)
class displayFriendshipInteractor(base.baseInteractor): class displayFriendshipInteractor(base.baseInteractor):
def add_items(self, control, items): def add_items(self, control, items):
if not hasattr(self.view, control): if not hasattr(self.view, control):
raise AttributeError("The control is not present in the view.") raise AttributeError("The control is not present in the view.")
for i in items: for i in items:
getattr(self.view, control).insert_item(False, *[i]) getattr(self.view, control).insert_item(False, *[i])
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(displayFriendshipInteractor, self).install(*args, **kwargs) super(displayFriendshipInteractor, self).install(*args, **kwargs)
pub.subscribe(self.add_items, self.modulename+"_add_items") pub.subscribe(self.add_items, self.modulename+"_add_items")
self.view.friends.list.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu) self.view.friends.list.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu)
def uninstall(self): def uninstall(self):
super(displayFriendshipInteractor, self).uninstall() super(displayFriendshipInteractor, self).uninstall()
pub.unsubscribe(self.add_items, self.modulename+"_add_items") pub.unsubscribe(self.add_items, self.modulename+"_add_items")
def on_context_menu(self, *args, **kwargs): def on_context_menu(self, *args, **kwargs):
item = self.view.friends.get_selected() item = self.view.friends.get_selected()
if item < 0: if item < 0:
return return
menu = menus.peopleMenu(False, False, True) 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_view_profile, menuitem=menu.view_profile)
widgetUtils.connect_event(menu, widgetUtils.MENU, self.on_open_in_browser, menuitem=menu.open_in_browser) widgetUtils.connect_event(menu, widgetUtils.MENU, self.on_open_in_browser, menuitem=menu.open_in_browser)
# Generally message sending is blocked. # Generally message sending is blocked.
menu.message.Enable(False) menu.message.Enable(False)
self.view.PopupMenu(menu, self.view.friends.list.GetPosition()) self.view.PopupMenu(menu, self.view.friends.list.GetPosition())
def on_view_profile(self, *args, **kwargs): def on_view_profile(self, *args, **kwargs):
item = self.view.friends.get_selected() item = self.view.friends.get_selected()
self.presenter.view_profile(item) self.presenter.view_profile(item)
def on_open_in_browser(self, *args, **kwargs): def on_open_in_browser(self, *args, **kwargs):
item = self.view.friends.get_selected() item = self.view.friends.get_selected()
self.presenter.open_in_browser(item) self.presenter.open_in_browser(item)

View File

@ -9,62 +9,62 @@ from . import base
class userProfileInteractor(base.baseInteractor): class userProfileInteractor(base.baseInteractor):
def enable_control(self, tab, control): def enable_control(self, tab, control):
if not hasattr(self.view, tab): if not hasattr(self.view, tab):
raise AttributeError("The viw does not contain the specified tab.") raise AttributeError("The viw does not contain the specified tab.")
tab = getattr(self.view, tab) tab = getattr(self.view, tab)
if not hasattr(tab, control): if not hasattr(tab, control):
raise AttributeError("The control is not present in the tab.") raise AttributeError("The control is not present in the tab.")
getattr(tab, control).Enable(True) getattr(tab, control).Enable(True)
def set(self, tab, control, value): def set(self, tab, control, value):
if not hasattr(self.view, tab): if not hasattr(self.view, tab):
raise AttributeError("The view does not contain the specified tab.") raise AttributeError("The view does not contain the specified tab.")
tab = getattr(self.view, tab) tab = getattr(self.view, tab)
if not hasattr(tab, control): if not hasattr(tab, control):
raise AttributeError("The control is not present in the tab.") raise AttributeError("The control is not present in the tab.")
control = getattr(tab, control) control = getattr(tab, control)
control.SetValue(value) control.SetValue(value)
def set_label(self, tab, control, value): def set_label(self, tab, control, value):
if not hasattr(self.view, tab): if not hasattr(self.view, tab):
raise AttributeError("The viw does not contain the specified tab.") raise AttributeError("The viw does not contain the specified tab.")
tab = getattr(self.view, tab) tab = getattr(self.view, tab)
if not hasattr(tab, control): if not hasattr(tab, control):
raise AttributeError("The control is not present in the tab.") raise AttributeError("The control is not present in the tab.")
control = getattr(tab, control) control = getattr(tab, control)
control.SetLabel(value) control.SetLabel(value)
def load_image(self, image): def load_image(self, image):
image = wx.Image(stream=six.BytesIO(image.content)) image = wx.Image(stream=six.BytesIO(image.content))
try: try:
self.view.image.SetBitmap(wx.Bitmap(image)) self.view.image.SetBitmap(wx.Bitmap(image))
except ValueError: except ValueError:
return return
self.view.panel.Layout() self.view.panel.Layout()
def install(self, *args, **kwargs): def install(self, *args, **kwargs):
super(userProfileInteractor, self).install(*args, **kwargs) super(userProfileInteractor, self).install(*args, **kwargs)
pub.subscribe(self.set, self.modulename+"_set") pub.subscribe(self.set, self.modulename+"_set")
pub.subscribe(self.load_image, self.modulename+"_load_image") pub.subscribe(self.load_image, self.modulename+"_load_image")
self.view.create_controls("main_info") self.view.create_controls("main_info")
self.view.realice() self.view.realice()
widgetUtils.connect_event(self.view.main_info.go_site, widgetUtils.BUTTON_PRESSED, self.on_visit_website) widgetUtils.connect_event(self.view.main_info.go_site, widgetUtils.BUTTON_PRESSED, self.on_visit_website)
def uninstall(self): def uninstall(self):
super(userProfileInteractor, self).uninstall() super(userProfileInteractor, self).uninstall()
pub.unsubscribe(self.set, self.modulename+"_set") pub.unsubscribe(self.set, self.modulename+"_set")
pub.unsubscribe(self.load_image, self.modulename+"_load_image") pub.unsubscribe(self.load_image, self.modulename+"_load_image")
def on_visit_website(self, *args, **kwargs): def on_visit_website(self, *args, **kwargs):
urls = self.presenter.get_urls() urls = self.presenter.get_urls()
if len(urls) == 1: if len(urls) == 1:
self.presenter.visit_url(urls[0]) self.presenter.visit_url(urls[0])
else: else:
dialog = urlList.urlList() dialog = urlList.urlList()
dialog.populate_list(urls) dialog.populate_list(urls)
if dialog.get_response() != widgetUtils.OK: if dialog.get_response() != widgetUtils.OK:
return return
selected_url = urls[dialog.get_item()] selected_url = urls[dialog.get_item()]
self.presenter.visit_url(selected_url) self.presenter.visit_url(selected_url)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################ ############################################################
# Copyright (c) 2018 Manuel Cortez <manuel@manuelcortez.net> # Copyright (c) 2018 Manuel Cortez <manuel@manuelcortez.net>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
@ -28,37 +28,37 @@ from mysc.thread_utils import call_threaded
from . import wx_ui from . import wx_ui
class reportBug(object): class reportBug(object):
def __init__(self): def __init__(self):
self.dialog = wx_ui.reportBugDialog() self.dialog = wx_ui.reportBugDialog()
widgetUtils.connect_event(self.dialog.ok, widgetUtils.BUTTON_PRESSED, self.send) widgetUtils.connect_event(self.dialog.ok, widgetUtils.BUTTON_PRESSED, self.send)
self.dialog.get_response() self.dialog.get_response()
def do_report(self, *args, **kwargs): def do_report(self, *args, **kwargs):
r = requests.post(*args, **kwargs) r = requests.post(*args, **kwargs)
if r.status_code > 300: if r.status_code > 300:
wx.CallAfter(self.dialog.error) wx.CallAfter(self.dialog.error)
wx.CallAfter(self.dialog.progress.Destroy) wx.CallAfter(self.dialog.progress.Destroy)
wx.CallAfter(self.dialog.success, r.json()["data"]["issue"]["id"]) wx.CallAfter(self.dialog.success, r.json()["data"]["issue"]["id"])
def send(self, *args, **kwargs): def send(self, *args, **kwargs):
if self.dialog.get("summary") == "" or self.dialog.get("description") == "" or self.dialog.get("first_name") == "" or self.dialog.get("last_name") == "": if self.dialog.get("summary") == "" or self.dialog.get("description") == "" or self.dialog.get("first_name") == "" or self.dialog.get("last_name") == "":
self.dialog.no_filled() self.dialog.no_filled()
return return
if self.dialog.get("agree") == False: if self.dialog.get("agree") == False:
self.dialog.no_checkbox() self.dialog.no_checkbox()
return return
title = self.dialog.get("summary") title = self.dialog.get("summary")
body = self.dialog.get("description") body = self.dialog.get("description")
issue_type = "issue" # for now just have issue issue_type = "issue" # for now just have issue
app_type = paths.mode app_type = paths.mode
app_version = application.version app_version = application.version
reporter_name = "{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_type = "email" # For now just email is supported in the issue reporter
reporter_contact_handle = self.dialog.get("email") reporter_contact_handle = self.dialog.get("email")
operating_system = platform.platform() operating_system = platform.platform()
json = dict(title=title, issue_type=issue_type, body=body, operating_system=operating_system, app_type=app_type, app_version=app_version, reporter_name=reporter_name, reporter_contact_handle=reporter_contact_handle, reporter_contact_type=reporter_contact_type) json = dict(title=title, issue_type=issue_type, body=body, operating_system=operating_system, app_type=app_type, app_version=app_version, reporter_name=reporter_name, reporter_contact_handle=reporter_contact_handle, reporter_contact_type=reporter_contact_type)
auth=HTTPBasicAuth(application.bts_name, application.bts_access_token) auth=HTTPBasicAuth(application.bts_name, application.bts_access_token)
url = "{bts_url}/issue/new".format(bts_url=application.bts_url) url = "{bts_url}/issue/new".format(bts_url=application.bts_url)
call_threaded(self.do_report, url, json=json, auth=auth) call_threaded(self.do_report, url, json=json, auth=auth)
self.dialog.show_progress() self.dialog.show_progress()
self.dialog.EndModal(wx.ID_OK) self.dialog.EndModal(wx.ID_OK)

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
############################################################ ############################################################
# Copyright (c) 2018 Manuel cortez <manuel@manuelcortez.net> # Copyright (c) 2018 Manuel cortez <manuel@manuelcortez.net>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
@ -22,89 +22,89 @@ import widgetUtils
import application import application
class reportBugDialog(widgetUtils.BaseDialog): class reportBugDialog(widgetUtils.BaseDialog):
def __init__(self): def __init__(self):
super(reportBugDialog, self).__init__(parent=None, id=wx.NewId()) super(reportBugDialog, self).__init__(parent=None, id=wx.NewId())
self.SetTitle(_("Report an error")) self.SetTitle(_("Report an error"))
panel = wx.Panel(self) panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL) sizer = wx.BoxSizer(wx.VERTICAL)
summaryLabel = wx.StaticText(panel, -1, _("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) self.summary = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.summary) dc = wx.WindowDC(self.summary)
dc.SetFont(self.summary.GetFont()) dc.SetFont(self.summary.GetFont())
self.summary.SetSize(dc.GetTextExtent("a"*80)) self.summary.SetSize(dc.GetTextExtent("a"*80))
summaryB = wx.BoxSizer(wx.HORIZONTAL) summaryB = wx.BoxSizer(wx.HORIZONTAL)
summaryB.Add(summaryLabel, 0, wx.ALL, 5) summaryB.Add(summaryLabel, 0, wx.ALL, 5)
summaryB.Add(self.summary, 0, wx.ALL, 5) summaryB.Add(self.summary, 0, wx.ALL, 5)
sizer.Add(summaryB, 0, wx.ALL, 5) sizer.Add(summaryB, 0, wx.ALL, 5)
first_nameLabel = wx.StaticText(panel, -1, _("First Name"), size=wx.DefaultSize) first_nameLabel = wx.StaticText(panel, -1, _("First Name"), size=wx.DefaultSize)
self.first_name = wx.TextCtrl(panel, -1) self.first_name = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.first_name) dc = wx.WindowDC(self.first_name)
dc.SetFont(self.first_name.GetFont()) dc.SetFont(self.first_name.GetFont())
self.first_name.SetSize(dc.GetTextExtent("a"*40)) self.first_name.SetSize(dc.GetTextExtent("a"*40))
first_nameB = wx.BoxSizer(wx.HORIZONTAL) first_nameB = wx.BoxSizer(wx.HORIZONTAL)
first_nameB.Add(first_nameLabel, 0, wx.ALL, 5) first_nameB.Add(first_nameLabel, 0, wx.ALL, 5)
first_nameB.Add(self.first_name, 0, wx.ALL, 5) first_nameB.Add(self.first_name, 0, wx.ALL, 5)
sizer.Add(first_nameB, 0, wx.ALL, 5) sizer.Add(first_nameB, 0, wx.ALL, 5)
last_nameLabel = wx.StaticText(panel, -1, _("Last Name"), size=wx.DefaultSize) last_nameLabel = wx.StaticText(panel, -1, _("Last Name"), size=wx.DefaultSize)
self.last_name = wx.TextCtrl(panel, -1) self.last_name = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.last_name) dc = wx.WindowDC(self.last_name)
dc.SetFont(self.last_name.GetFont()) dc.SetFont(self.last_name.GetFont())
self.last_name.SetSize(dc.GetTextExtent("a"*40)) self.last_name.SetSize(dc.GetTextExtent("a"*40))
last_nameB = wx.BoxSizer(wx.HORIZONTAL) last_nameB = wx.BoxSizer(wx.HORIZONTAL)
last_nameB.Add(last_nameLabel, 0, wx.ALL, 5) last_nameB.Add(last_nameLabel, 0, wx.ALL, 5)
last_nameB.Add(self.last_name, 0, wx.ALL, 5) last_nameB.Add(self.last_name, 0, wx.ALL, 5)
sizer.Add(last_nameB, 0, wx.ALL, 5) sizer.Add(last_nameB, 0, wx.ALL, 5)
emailLabel = wx.StaticText(panel, -1, _("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) self.email = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.email) dc = wx.WindowDC(self.email)
dc.SetFont(self.email.GetFont()) dc.SetFont(self.email.GetFont())
self.email.SetSize(dc.GetTextExtent("a"*30)) self.email.SetSize(dc.GetTextExtent("a"*30))
emailB = wx.BoxSizer(wx.HORIZONTAL) emailB = wx.BoxSizer(wx.HORIZONTAL)
emailB.Add(emailLabel, 0, wx.ALL, 5) emailB.Add(emailLabel, 0, wx.ALL, 5)
emailB.Add(self.email, 0, wx.ALL, 5) emailB.Add(self.email, 0, wx.ALL, 5)
sizer.Add(emailB, 0, wx.ALL, 5) sizer.Add(emailB, 0, wx.ALL, 5)
descriptionLabel = wx.StaticText(panel, -1, _("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) self.description = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE)
dc = wx.WindowDC(self.description) dc = wx.WindowDC(self.description)
dc.SetFont(self.description.GetFont()) dc.SetFont(self.description.GetFont())
(x, y) = dc.GetMultiLineTextExtent("0"*2000) (x, y) = dc.GetMultiLineTextExtent("0"*2000)
self.description.SetSize((x, y)) self.description.SetSize((x, y))
descBox = wx.BoxSizer(wx.HORIZONTAL) descBox = wx.BoxSizer(wx.HORIZONTAL)
descBox.Add(descriptionLabel, 0, wx.ALL, 5) descBox.Add(descriptionLabel, 0, wx.ALL, 5)
descBox.Add(self.description, 0, wx.ALL, 5) descBox.Add(self.description, 0, wx.ALL, 5)
sizer.Add(descBox, 0, wx.ALL, 5) sizer.Add(descBox, 0, wx.ALL, 5)
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 = 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) self.agree.SetValue(False)
sizer.Add(self.agree, 0, wx.ALL, 5) sizer.Add(self.agree, 0, wx.ALL, 5)
self.ok = wx.Button(panel, wx.ID_OK, _("Send report")) self.ok = wx.Button(panel, wx.ID_OK, _("Send report"))
self.ok.SetDefault() self.ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL, _("Cancel")) cancel = wx.Button(panel, wx.ID_CANCEL, _("Cancel"))
btnBox = wx.BoxSizer(wx.HORIZONTAL) btnBox = wx.BoxSizer(wx.HORIZONTAL)
btnBox.Add(self.ok, 0, wx.ALL, 5) btnBox.Add(self.ok, 0, wx.ALL, 5)
btnBox.Add(cancel, 0, wx.ALL, 5) btnBox.Add(cancel, 0, wx.ALL, 5)
sizer.Add(btnBox, 0, wx.ALL, 5) sizer.Add(btnBox, 0, wx.ALL, 5)
panel.SetSizer(sizer) panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin()) self.SetClientSize(sizer.CalcMin())
def no_filled(self): def no_filled(self):
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() 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): def no_checkbox(self):
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() 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): def success(self, id):
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() 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() self.Destroy()
def error(self): def error(self):
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() 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() self.Destroy()
def show_progress(self): def show_progress(self):
self.progress = wx.ProgressDialog(title=_("Sending report..."), message=_("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() self.progress.ShowModal()

View File

@ -5,12 +5,12 @@ log = logging.getLogger("keyring")
keyring = None keyring = None
def setup(): def setup():
global keyring global keyring
if keyring == None: if keyring == None:
keyring = Keyring() keyring = Keyring()
log.debug("Keyring started") log.debug("Keyring started")
class Keyring(object): class Keyring(object):
def get_api_key(self): def get_api_key(self):
return "5093442" return "5093442"

View File

@ -12,7 +12,7 @@ import gettext
import paths import paths
import platform import platform
import application import application
#a few Windows locale constants #a few Windows locale constants
LOCALE_SLANGUAGE=0x2 LOCALE_SLANGUAGE=0x2
LOCALE_SLANGDISPLAYNAME=0x6f LOCALE_SLANGDISPLAYNAME=0x6f
@ -20,195 +20,195 @@ LOCALE_SLANGDISPLAYNAME=0x6f
curLang="en" curLang="en"
def localeNameToWindowsLCID(localeName): def localeNameToWindowsLCID(localeName):
"""Retreave the Windows locale identifier (LCID) for the given locale name """Retreave the Windows locale identifier (LCID) for the given locale name
@param localeName: a string of 2letterLanguage_2letterCountry or or just 2letterLanguage @param localeName: a string of 2letterLanguage_2letterCountry or or just 2letterLanguage
@type localeName: string @type localeName: string
@returns: a Windows LCID @returns: a Windows LCID
@rtype: integer @rtype: integer
""" """
#Windows Vista is able to convert locale names to LCIDs #Windows Vista is able to convert locale names to LCIDs
func_LocaleNameToLCID=getattr(ctypes.windll.kernel32,'LocaleNameToLCID',None) func_LocaleNameToLCID=getattr(ctypes.windll.kernel32,'LocaleNameToLCID',None)
if func_LocaleNameToLCID is not None: if func_LocaleNameToLCID is not None:
localeName=localeName.replace('_','-') localeName=localeName.replace('_','-')
LCID=func_LocaleNameToLCID(str(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 else: #Windows doesn't have this functionality, manually search Python's windows_locale dictionary for the LCID
localeName=locale.normalize(localeName) localeName=locale.normalize(localeName)
if '.' in localeName: if '.' in localeName:
localeName=localeName.split('.')[0] localeName=localeName.split('.')[0]
LCList=[x[0] for x in locale.windows_locale.items() if x[1]==localeName] LCList=[x[0] for x in locale.windows_locale.items() if x[1]==localeName]
if len(LCList)>0: if len(LCList)>0:
LCID=LCList[0] LCID=LCList[0]
else: else:
LCID=0 LCID=0
return LCID return LCID
def getLanguageDescription(language): def getLanguageDescription(language):
"""Finds out the description (localized full name) of a given local name""" """Finds out the description (localized full name) of a given local name"""
desc=None desc=None
if platform.system() == "Windows": if platform.system() == "Windows":
LCID=localeNameToWindowsLCID(language) LCID=localeNameToWindowsLCID(language)
if LCID!=0: if LCID!=0:
buf=ctypes.create_unicode_buffer(1024) buf=ctypes.create_unicode_buffer(1024)
if '_' not in language: if '_' not in language:
res=ctypes.windll.kernel32.GetLocaleInfoW(LCID,LOCALE_SLANGDISPLAYNAME,buf,1024) res=ctypes.windll.kernel32.GetLocaleInfoW(LCID,LOCALE_SLANGDISPLAYNAME,buf,1024)
else: else:
res=0 res=0
if res==0: if res==0:
res=ctypes.windll.kernel32.GetLocaleInfoW(LCID,LOCALE_SLANGUAGE,buf,1024) res=ctypes.windll.kernel32.GetLocaleInfoW(LCID,LOCALE_SLANGUAGE,buf,1024)
desc=buf.value desc=buf.value
elif platform.system() == "Linux" or not desc: elif platform.system() == "Linux" or not desc:
desc={ desc={
"am":pgettext("languageName","Amharic"), "am":pgettext("languageName","Amharic"),
"an":pgettext("languageName","Aragonese"), "an":pgettext("languageName","Aragonese"),
"es":pgettext("languageName","Spanish"), "es":pgettext("languageName","Spanish"),
"pt":pgettext("languageName","Portuguese"), "pt":pgettext("languageName","Portuguese"),
"ru":pgettext("languageName","Russian"), "ru":pgettext("languageName","Russian"),
"it":pgettext("languageName","italian"), "it":pgettext("languageName","italian"),
"tr":pgettext("languageName","Turkey"), "tr":pgettext("languageName","Turkey"),
"gl":pgettext("languageName","Galician"), "gl":pgettext("languageName","Galician"),
"ca":pgettext("languageName","Catala"), "ca":pgettext("languageName","Catala"),
"eu":pgettext("languageName","Vasque"), "eu":pgettext("languageName","Vasque"),
"pl":pgettext("languageName","polish"), "pl":pgettext("languageName","polish"),
"ar":pgettext("languageName","Arabic"), "ar":pgettext("languageName","Arabic"),
"ne":pgettext("languageName","Nepali"), "ne":pgettext("languageName","Nepali"),
"sr":pgettext("languageName","Serbian (Latin)"), "sr":pgettext("languageName","Serbian (Latin)"),
"ja":pgettext("languageName","Japanese"), "ja":pgettext("languageName","Japanese"),
}.get(language,None) }.get(language,None)
return desc return desc
def getAvailableLanguages(): def getAvailableLanguages():
"""generates a list of locale names, plus their full localized language and country names. """generates a list of locale names, plus their full localized language and country names.
@rtype: list of tuples @rtype: list of tuples
""" """
#Make a list of all the locales found in NVDA's locale dir #Make a list of all the locales found in NVDA's locale dir
l=[x for x in os.listdir(paths.locale_path()) if not x.startswith('.')] l=[x for x in os.listdir(paths.locale_path()) if not x.startswith('.')]
l=[x for x in l if os.path.isfile(os.path.join(paths.locale_path(), '%s/LC_MESSAGES/%s.po' % (x, application.short_name)))] l=[x for x in l if os.path.isfile(os.path.join(paths.locale_path(), '%s/LC_MESSAGES/%s.po' % (x, application.short_name)))]
#Make sure that en (english) is in the list as it may not have any locale files, but is default #Make sure that en (english) is in the list as it may not have any locale files, but is default
if 'en' not in l: if 'en' not in l:
l.append('en') l.append('en')
l.sort() l.sort()
#For each locale, ask Windows for its human readable display name #For each locale, ask Windows for its human readable display name
d=[] d=[]
for i in l: for i in l:
desc=getLanguageDescription(i) desc=getLanguageDescription(i)
label="%s, %s"%(desc,i) if desc else i label="%s, %s"%(desc,i) if desc else i
d.append(label) d.append(label)
#include a 'user default, windows' language, which just represents the default language for this user account #include a 'user default, windows' language, which just represents the default language for this user account
l.append("system") l.append("system")
# Translators: the label for the Windows default NVDA interface language. # Translators: the label for the Windows default NVDA interface language.
d.append(_("User default")) d.append(_("User default"))
#return a zipped up version of both the lists (a list with tuples of locale,label) #return a zipped up version of both the lists (a list with tuples of locale,label)
return list(zip(l,d)) return list(zip(l,d))
def makePgettext(translations): def makePgettext(translations):
"""Obtaina pgettext function for use with a gettext translations instance. """Obtaina pgettext function for use with a gettext translations instance.
pgettext is used to support message contexts, pgettext is used to support message contexts,
but Python 2.7's gettext module doesn't support this, but Python 2.7's gettext module doesn't support this,
so NVDA must provide its own implementation. so NVDA must provide its own implementation.
""" """
if isinstance(translations, gettext.GNUTranslations): if isinstance(translations, gettext.GNUTranslations):
def pgettext(context, message): def pgettext(context, message):
message = str(message) message = str(message)
try: try:
# Look up the message with its context. # Look up the message with its context.
return translations._catalog["%s\x04%s" % (context, message)] return translations._catalog["%s\x04%s" % (context, message)]
except KeyError: except KeyError:
return message return message
else: else:
def pgettext(context, message): def pgettext(context, message):
return str(message) return str(message)
return pgettext return pgettext
def setLanguage(lang): def setLanguage(lang):
system = platform.system() system = platform.system()
global curLang global curLang
try: try:
if lang=="system": if lang=="system":
if system == "Windows": if system == "Windows":
windowsLCID=ctypes.windll.kernel32.GetUserDefaultUILanguage() windowsLCID=ctypes.windll.kernel32.GetUserDefaultUILanguage()
localeName=locale.windows_locale[windowsLCID] localeName=locale.windows_locale[windowsLCID]
elif system == "Darwin": elif system == "Darwin":
import Foundation import Foundation
localeName = Foundation.NSLocale.currentLocale().identifier() localeName = Foundation.NSLocale.currentLocale().identifier()
elif system == "Linux": elif system == "Linux":
localeName = locale.getdefaultlocale()[0] localeName = locale.getdefaultlocale()[0]
trans=gettext.translation(application.short_name, localedir=paths.locale_path(), languages=[localeName]) trans=gettext.translation(application.short_name, localedir=paths.locale_path(), languages=[localeName])
curLang=localeName curLang=localeName
# else: # else:
# localeName=locale.getdefaultlocale()[0] # localeName=locale.getdefaultlocale()[0]
# trans=gettext.translation('twblue', localedir=paths.locale_path(), languages=[localeName]) # trans=gettext.translation('twblue', localedir=paths.locale_path(), languages=[localeName])
# curLang=localeName # curLang=localeName
else: else:
trans=gettext.translation(application.short_name, localedir=paths.locale_path(), languages=[lang]) trans=gettext.translation(application.short_name, localedir=paths.locale_path(), languages=[lang])
curLang=lang curLang=lang
localeChanged=False localeChanged=False
#Try setting Python's locale to lang #Try setting Python's locale to lang
# try: # try:
if system == "Windows": if system == "Windows":
locale.setlocale(locale.LC_ALL, langToWindowsLocale(lang)) locale.setlocale(locale.LC_ALL, langToWindowsLocale(lang))
localeChanged=True localeChanged=True
else: else:
locale.setlocale(locale.LC_ALL, lang) locale.setlocale(locale.LC_ALL, lang)
localeChanged=True localeChanged=True
# except: # except:
# pass # pass
if not localeChanged and '_' in lang: if not localeChanged and '_' in lang:
#Python couldn'tsupport the language_country locale, just try language. #Python couldn'tsupport the language_country locale, just try language.
try: try:
locale.setlocale(locale.LC_ALL, lang.split('_')[0]) locale.setlocale(locale.LC_ALL, lang.split('_')[0])
except: except:
pass pass
#Set the windows locale for this thread (NVDA core) to this locale. #Set the windows locale for this thread (NVDA core) to this locale.
if system == "Windows": if system == "Windows":
LCID=localeNameToWindowsLCID(lang) LCID=localeNameToWindowsLCID(lang)
ctypes.windll.kernel32.SetThreadLocale(LCID) ctypes.windll.kernel32.SetThreadLocale(LCID)
except IOError: except IOError:
trans=gettext.translation(application.short_name, fallback=True) trans=gettext.translation(application.short_name, fallback=True)
curLang="en" curLang="en"
if sys.version[0] == "3": if sys.version[0] == "3":
trans.install() trans.install()
else: else:
trans.install(unicode=True) trans.install(unicode=True)
# Install our pgettext function. # Install our pgettext function.
# __builtin__.__dict__["pgettext"] = makePgettext(trans) # __builtin__.__dict__["pgettext"] = makePgettext(trans)
def getLanguage(): def getLanguage():
return curLang return curLang
def normalizeLanguage(lang): def normalizeLanguage(lang):
""" """
Normalizes a language-dialect string in to a standard form we can deal with. Normalizes a language-dialect string in to a standard form we can deal with.
Converts any dash to underline, and makes sure that language is lowercase and dialect is upercase. Converts any dash to underline, and makes sure that language is lowercase and dialect is upercase.
""" """
lang=lang.replace('-','_') lang=lang.replace('-','_')
ld=lang.split('_') ld=lang.split('_')
ld[0]=ld[0].lower() ld[0]=ld[0].lower()
#Filter out meta languages such as x-western #Filter out meta languages such as x-western
if ld[0]=='x': if ld[0]=='x':
return None return None
if len(ld)>=2: if len(ld)>=2:
ld[1]=ld[1].upper() ld[1]=ld[1].upper()
return "_".join(ld) return "_".join(ld)
def langToWindowsLocale(lang): def langToWindowsLocale(lang):
languages = {"en": "eng", languages = {"en": "eng",
"ar": "ara", "ar": "ara",
"ca": "cat", "ca": "cat",
"de": "deu", "de": "deu",
"es": "esp", "es": "esp",
"fi": "fin", "fi": "fin",
"fr": "fre_FRA", "fr": "fre_FRA",
"gl": "glc", "gl": "glc",
"eu": "euq", "eu": "euq",
"hu": "hun", "hu": "hun",
"hr": "hrv", "hr": "hrv",
"it": "ita", "it": "ita",
"ja": "jpn", "ja": "jpn",
"pl": "plk", "pl": "plk",
"pt": "ptb", "pt": "ptb",
"ru": "rus", "ru": "rus",
"tr": "trk", "tr": "trk",
"sr": "eng", "sr": "eng",
} }
return languages[lang] return languages[lang]

Binary file not shown.

View File

@ -0,0 +1,535 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: Socializer\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-06-29 13:33-0500\n"
"PO-Revision-Date: 2016-06-29 16:25-0600\n"
"Last-Translator: \n"
"Language-Team: Manuel Cortez <manuel@manuelcortez.net>\n"
"Language: es\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 1.6.11\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#. Translators: the label for the Windows default NVDA interface language.
msgid "User default"
msgstr ""
msgid "socializer's manual "
msgstr "Manual de Socializer"
msgid "## Introduction"
msgstr "## Introducción"
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 ""
"Socializer es una aplicación para usar [vk.com](http://vk.com) de forma "
"fácil y accesible, con un consumo de CPU mínimo. Socializer te permitirá "
"interactuar con la red social VK, brindándote acceso a las características "
"más relevantes, tales como:"
msgid "* Basic post creation in your wall (including photos)."
msgstr ""
"* Creación básica de publicaciones en tu muro (incluyendo subida de fotos)"
msgid "* Audio addition, removal, download and search."
msgstr "* Añadir, descargar y buscar archivos de audio."
msgid "* audio albums management (create, delete and add audios)."
msgstr ""
"* Administración de albums de audio (crear, eliminar y añadir audios dentro "
"de albums)."
msgid "* Post comments."
msgstr "* Publicar comentarios."
msgid "* like, unlike and repost other's posts."
msgstr ""
"* Indicar que te gusta, que ya no te gusta o compartir publicaciones de "
"otros usuarios."
msgid ""
"* Open other's timelines so you could track someone's friends, posts or "
"audio files."
msgstr ""
"* Abrir líneas temporales de otros usuarios para poder ver sus "
"publicaciones, audios o amigos."
msgid "* Basic chat features."
msgstr "* Características básicas de chat."
msgid ""
"Note: When new features are added to socializer they will be added to this "
"section."
msgstr ""
"Nota: Cuando sean añadidas, las nuevas características se incluirán aquí."
msgid "## Running"
msgstr "## Abriendo socializer"
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."
msgstr ""
"Si estás usando una versión compilada (distribuible), descomprime el archivo "
"ZIP en un nuevo directorio que no contenga caracteres especiales, y abre el "
"archivo socializer.exe. Si no has configurado tu cuenta de VK, verás un "
"diálogo donde se te preguntará si deseas configurar una. Si presionas en sí, "
"podrás introducir tus datos. Toma en cuenta que la información proporcionada "
"ha de guardarse en un archivo de configuración, como texto plano. La "
"aplicación necesitará tu información para renovar el código de acceso cuando "
"expire."
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."
msgstr ""
"Nota: Cada que se brinde acceso a socializer, probablemente recibirás un "
"correo electrónico de VK diciéndote que puede que alguien haya entrado a tu "
"cuenta. Significa que un nuevo código de acceso ha sido generado entre VK y "
"Socializer mediante un proceso automático. Deberías ignorar estos avisos, a "
"no ser que hayas recibido un correo cuando no estés usando Socializer o "
"alguna otra aplicación. Puedes ver tus aplicaciones autorizadas en la página "
"de tu perfil en el sitio web de VK. Un nuevo código de acceso debe ser "
"generado cada 24 horas."
msgid "## Main interface"
msgstr "## Interfaz"
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:"
msgstr ""
"Si alguna vez has usado [TWBlue](https//github.com/manuelcortez/twblue) "
"anteriormente, te darás cuenta que la interfaz gráfica de socializer es muy "
"parecida. Una vez que hayas autorizado tu cuenta, Podrás ver una ventana con "
"los siguientes elementos:"
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."
msgstr ""
"* Una vista de árbol en la parte izquierda de laventana, donde podrás ver la "
"lista de buffers. Los buffers están divididos en tres categorías, "
"publicaciones, música y gente. Puedes expandir cada categoría para ver los "
"elementos hijos. Hay además buffers adicionales, líneas temporales y chats, "
"que serán usados para guardar líneas temporales para tus amigos, o chats "
"cuando recibas o envíes un mensaje."
msgid "* A button for making a post to your wall."
msgstr "* Un botón para publicar en tu muro."
msgid "* In audio buffers, Two buttons: Play and play all."
msgstr ""
"* En buffers de audio, un par de botones: Reproducir y reproducir todo."
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."
msgstr ""
"* En buffers para albums de audio, un botón llamado cargar álbum. De manera "
"predeterminada, los álbumes se encuentran vacíos, debes pulsar el botón "
"cargar álbum para descargar la información necesaria que permitirá mostrar "
"la música dentro del buffer del álbum."
msgid ""
"* A list where you will see the posts for the currently selected buffer."
msgstr "* Una lista donde podrás ver los elementos del buffer seleccionado."
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."
msgstr ""
"* En buffers de amigos, un botón que permite enviar un mensaje a la persona "
"seleccionada. Si es activado, el botón creará un buffer de chat "
"automáticamente."
msgid ""
"* A status bar where the program will put some useful information about what "
"it's doing at the moment."
msgstr ""
"* Una barra de estado, donde el programa escribirá información importante "
"sobre lo que se encuentra haciendo en cada momento."
msgid "* And a menu bar."
msgstr "* Y una barra de menú."
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:"
msgstr ""
"Cuando socializer inicia, intentará cargar los elementos en el buffer "
"principal, publicaciones en tu muro, canciones en tus buffers de audio (mis "
"audios, populares y recomendaciones), así como tus amigos. Por el momento "
"solo se pueden hacer pocas acciones para cada uno de estos tipos de elemento."
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."
msgstr ""
"* Archivos de audio: Puedes reproducir el audio seleccionado, ver los "
"detalles de la canción (incluyendo letras, si las tiene), añadirlo y "
"eliminarlo de tu biblioteca, y descargar la canción a tu disco duro. Puedes "
"encontrar archivos de audio en tus propios buffers de audio, en el buffer "
"principal y pueden estar incluidos como adjuntos en publicaciones. Puedes "
"abrir una línea temporal de audios para ver los audios de otros usuarios de "
"VK."
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."
msgstr ""
"* Publicaciones en el buffer principal: En el buffer principal, puedes "
"pulsar la tecla intro y socializer abrirá un diálogo que puede ser "
"diferente, dependiendo del tipo de publicación que estaba enfocada cuando se "
"presionó la tecla. Por ejemplo, abrirá la publicación si estabas en una "
"publicación \"normal\", una lista de personas si estabas en una publicación "
"que indicaba que alguien había añadido amigos, el visualizador de detalles "
"de audios si estabas en una publicación que indicaba que alguien había "
"añadido audios, etc."
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."
msgstr ""
"* publicaciones en el muro: Mostrará la publicación en un nuevo diálogo, que "
"te permitirá interactuar con el post, ver los adjuntos, ver y publicar "
"comentarios, así como indicar si te gusta, ya no te gusta y compartir la "
"publicación."
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."
msgstr ""
"* Puedes enviar un mensaje a alguien pulsando el botón Enviar mensaje, si "
"está disponible. Los usuarios con cuentas desactivadas no pueden recibir "
"mensajes."
msgid "### Making a post"
msgstr "### Haciendo una publicación"
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 ""
"Cuando pulses el botón para publicar, se mostrará un diálogo. Este diálogo "
"te permitirá publicar algo en tu muro. En este diálogo tienes que escribir "
"un mensaje. Puedes traducir el mensaje y corregir tus errores ortográficos. "
"También puedes publicar una dirección URL, y socializer intentará enviarla "
"como un adjunto a tu publicación, por lo que no tienes que preocuparte. "
"Cuando estés listo, solo presiona el botón enviar, y estará listo."
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 ""
"Si quieres añadir algunas fotos, presiona el botón adjuntar, seguidamente "
"encuentra el botón del elemento que quieres añadir. Después, selecciona el "
"archivo a adjuntar y lo podrás ver en la lista de archivos a cargar una vez "
"sea procesado por el programa. Cuando hayas terminado con los adjuntos, "
"presiona el botón aceptar, y continúa con tu publicación. Cuando esté todo "
"listo, pulsa el botón enviar. Tu publicación podría tomar un tiempo en ser "
"enviada, dependiendo de la cantidad y el tamaño de los adjuntos que "
"añadiste, pero debería aparecer publicada en tu muro y en el buffer "
"principal tan rápidamente como sea publicada."
msgid "### Working with posts in news feed"
msgstr "### Trabajando con publicaciones en el buffer principal."
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 ""
"Puedes pulsar la tecla intro en cualquier publicación de tu buffer principal "
"para abrir un nuevo diálogo con información. La información puede variar si "
"estás viendo una notificación de nuevos amigos (cuando alguien añade "
"amigos), un archivo de audio, o una publicación regular."
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 ""
"Si abres una publicación regular en tu buffer principal, serás capaz de leer "
"los comentarios en una lista, indicar si te gusta o ya no te gusta la "
"publicación, compartirla o añadir un nuevo comentario. Si la publicación "
"contiene adjuntos, encontrarás una lista con ellos. Puedes pulsar intro "
"sobre uno de ellos para abrir la acción predeterminada. La acción "
"predeterminada para cada archivo dependerá del tipo de archivo en el que te "
"enfoques."
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 ""
"Para las notificaciones de nuevos amigos, solo puedes ver las personas que "
"han sido añadidas. También hay algunas publicaciones que no se muestran por "
"defecto."
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 ""
"Además, puedes pulsar la tecla de aplicaciones o el botón derecho del ratón "
"para mostrar un menú de acciones rápidas que están disponibles para el "
"elemento seleccionado. Las acciones son diferentes para cada tipo de "
"publicación."
msgid "### Working with songs"
msgstr "### Trabajando con audios"
msgid "Note: the following applies to audio timelines too."
msgstr "Nota: Lo siguiente también es aplicable a líneas temporales de audio."
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 ""
"Si quieres reproducir o ver los detalles de un archivo de audio, debes "
"navegar hasta la vista de árbol y, utilizando las flechas de cursor, ubicar "
"algún buffer de audio (mis audios, populares o recomendaciones). Verás dos "
"botones extras, reproducir y reproducir todo. El botón reproducir "
"reproducirá el audio seleccionado, y el botón reproducir todo comenzará a "
"reproducir, a partir del audio seleccionado y hasta el final, todos los "
"audios del buffer. Puedes ir a la lista de canciones, buscar una canción que "
"te guste y pulsar el botón reproducir, o pulsar Control intro, que es un "
"atajo de teclado. Ten en cuenta que algunos atajos de teclado solo funcionan "
"cuando estás en la lista de elementos."
msgid ""
"You can play audio from any buffer, just press ctrl+return for making the "
"audio playback possible."
msgstr ""
"Puedes reproducir audios desde cualquier buffer, solo presiona Control intro "
"para hacer posible la reproducción."
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 ""
"Si alguien ha añadido más de un audio a su biblioteca, podrás ver algo como "
"lo siguiente: \"(alguien) ha añadido 4 audios: audio1, audio2, audio3 y "
"audio4\". Puedes pulsar intro en la publicación para abrir el diálogo del "
"visualizador de detalles de audios, donde podrás verlos todos en una lista. "
"De forma predeterminada, el primer audio detectado está seleccionado, lo que "
"significa que puedes pulsar tab para ver sus detalles, descargarlo y "
"añadirlo a la biblioteca. Si cambias la canción en la lista, notarás que la "
"información se actualizará y ahora los detalles y acciones a mostrar tendrán "
"efecto en el nuevo audio seleccionado."
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 ""
"Cuando un archivo de audio está siendo reproducido, puedes pulsar las teclas "
"f5 y f6 para bajar y subir volumen, respectivamente. También puedes pulsar "
"Control Shift Intro para pausar/reproducir la canción."
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 ""
"Si quieres ver algunos detalles para el audio seleccionado, pulsa intro "
"sobre él. Podrás leer información importante sobre la canción (título, "
"artista, duración y la letra, si está disponible). También podrás descargar "
"la canción a tu disco duro, solo tienes que pulsar el botón descargar en el "
"diálogo de detalles de audio."
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 ""
"Cuando la descarga inicie, puedes cerrar el visualizador de detalles de "
"audio y revisar la barra de estado para ver el progreso."
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 ""
"Además, puedes hacer una búsqueda de canciones usando la barra de menú, en "
"el menú buffer, buscar, luego audio. Mostrará un diálogo donde deberás "
"establecer tus preferencias de búsqueda."
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 ""
"Si presionas la tecla de aplicaciones podrás ver un menú desde el que puedes "
"realizar algunas acciones, por ejemplo mover la canción a un álbum, o "
"agregarlo/eliminarlo de tu biblioteca."
msgid "## menu Bar"
msgstr "## barra de menú"
msgid ""
"You can go to the menu bar by pressing ALT. Right now, there are three "
"menus, application, buffer and help:"
msgstr ""
"Puedes ir a la barra de menú pulsando la tecla ALT. Actualmente existen tres "
"menús: aplicación, buffer y ayuda."
msgid "### Application menu"
msgstr "### Menú aplicación"
msgid ""
"* Create. Here you can create some things in VK. The only supported item at "
"this moment is the audio album."
msgstr ""
"* Crear. Aquí puedes crear algunas cosas en VK. Actualmente solo se "
"encuentra soportada la creación de álbumes de audio."
msgid ""
"* Delete: Removes items from the VK servers. The only supported item here is "
"the audio album."
msgstr ""
"* eliminar. Elimina elementos desde el servidor de VK. Actualmente solo se "
"encuentra soportado el borrado de álbumes de audio."
msgid ""
"* you can set your preferences by opening the preferences dialog located in "
"this menu."
msgstr ""
"* Puedes establecer tus preferencias desde el diálogo de preferencias, "
"ubicado en este menú."
msgid "### Buffer menu"
msgstr "### Menú buffer"
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."
msgstr ""
"* Nueva línea temporal: Esta opción permite crear una línea temporal para "
"otro usuario de VK. Las líneas temporales pueden descargar publicaciones de "
"otros usuarios."
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."
msgstr ""
"* Buscar: permite hacer una búsqueda en VK. Por el momento solo se pueden "
"buscar archivos de audio. Las búsquedas de audio se añadirán en el buffer de "
"música y contendrán los últimos 299 resultados."
msgid ""
"* Update current buffer: perform an update operation in the selected buffer, "
"which will retrieve the new items."
msgstr ""
"* Actualizar buffer: Realiza una operación de actualización en el buffer "
"actual, lo que recuperará los nuevos elementos."
msgid ""
"* Load previous items: Get the previous items for the currently focused "
"buffer."
msgstr ""
"* Cargar elementos anteriores: Carga los elementos anteriormente publicados "
"en el buffer actual."
msgid ""
"* Remove buffer: Tries to remove the current buffer. Default buffers can't "
"be removed."
msgstr ""
"* Eliminar buffer: Intenta remover el buffer actual. Los buffers "
"predeterminados no pueden eliminarse."
msgid "The help menu is self explanatory."
msgstr "El menú ayuda se explica por sí solo."
msgid "## Contributing"
msgstr "## Contribuir"
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)."
msgstr ""
"Si notas algún error en este documento, alguna sección no cubierta o "
"simplemente quieres sugerir algo, puedes hacerlo mediante las formas de "
"contacto (lee la siguiente sección)."
msgid "## contact"
msgstr "## Contacto"
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."
msgstr ""
"Si tienes preguntas, no dudes en contactarme mediante [Twitter,](https://"
"twitter.com/manuelcortez00) o envíame un correo electrónico a "
"manuel(arroba)manuelcortez(punto)net. Solo asegúrate de remplazar las "
"palabras entre paréntesis por el símbolo original."

File diff suppressed because it is too large Load Diff

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -8,11 +8,10 @@ import sys
APP_LOG_FILE = 'debug.log' APP_LOG_FILE = 'debug.log'
ERROR_LOG_FILE = "error.log" ERROR_LOG_FILE = "error.log"
MESSAGE_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s" MESSAGE_FORMAT = "%(asctime)s %(name)s %(levelname)s: %(message)s"
DATE_FORMAT = "%d-%m-%Y %H:%M:%S" DATE_FORMAT = "%d/%m/%Y %H:%M:%S"
formatter = logging.Formatter(MESSAGE_FORMAT, datefmt=DATE_FORMAT) formatter = logging.Formatter(MESSAGE_FORMAT, datefmt=DATE_FORMAT)
# Let's mute some really verbose logs.
requests_log = logging.getLogger("requests") requests_log = logging.getLogger("requests")
requests_log.setLevel(logging.WARNING) requests_log.setLevel(logging.WARNING)
urllib3 = logging.getLogger("urllib3") urllib3 = logging.getLogger("urllib3")
@ -25,7 +24,7 @@ logger.setLevel(logging.DEBUG)
app_handler = RotatingFileHandler(os.path.join(paths.logs_path(), APP_LOG_FILE), mode="w", encoding="utf-8") app_handler = RotatingFileHandler(os.path.join(paths.logs_path(), APP_LOG_FILE), mode="w", encoding="utf-8")
app_handler.setFormatter(formatter) app_handler.setFormatter(formatter)
app_handler.setLevel(logging.WARNING) app_handler.setLevel(logging.DEBUG)
logger.addHandler(app_handler) logger.addHandler(app_handler)
error_handler = logging.FileHandler(os.path.join(paths.logs_path(), ERROR_LOG_FILE), mode="w", encoding="utf-8") error_handler = logging.FileHandler(os.path.join(paths.logs_path(), ERROR_LOG_FILE), mode="w", encoding="utf-8")

67
src/main.py Normal file
View File

@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
import logger
import sys
import fixes
import traceback
#if hasattr(sys, "frozen"):
fixes.setup()
import platform
import languageHandler
import widgetUtils
import paths
import config
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(),))
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
log.debug("Created Application mainloop object")
sm = sessionManager.sessionManagerController()
sm.show()
del sm
r = mainController.Controller()
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
View 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')

View File

@ -5,13 +5,14 @@ import logging
log = logging.getLogger("mysc.localization") log = logging.getLogger("mysc.localization")
def get(rootFolder): def get(rootFolder):
log.debug("Getting documentation folder. RootFolder: %s" % (rootFolder,)) log.debug("Getting documentation folder. RootFolder: %s" % (rootFolder,))
defaultLocale = languageHandler.curLang defaultLocale = languageHandler.curLang
if len(defaultLocale) > 2: if len(defaultLocale) > 2:
defaultLocale = defaultLocale[:2] defaultLocale = defaultLocale[:2]
log.debug("Locale: %s" % (defaultLocale,)) log.debug("Locale: %s" % (defaultLocale,))
if os.path.exists(rootFolder+"/"+defaultLocale): if os.path.exists(rootFolder+"/"+defaultLocale):
return defaultLocale return defaultLocale
else: else:
log.debug("The folder does not exist, using the English folder...") log.debug("The folder does not exist, using the English folder...")
return "en" return "en"

View File

@ -4,34 +4,34 @@ import logging
log = logging.getLogger("mysc.repeating_timer") log = logging.getLogger("mysc.repeating_timer")
class RepeatingTimer(threading.Thread): class RepeatingTimer(threading.Thread):
"""Call a function after a specified number of seconds, it will then repeat again after the specified number of seconds """Call a function after a specified number of seconds, it will then repeat again after the specified number of seconds
Note: If the function provided takes time to execute, this time is NOT taken from the next wait period Note: If the function provided takes time to execute, this time is NOT taken from the next wait period
t = RepeatingTimer(30.0, f, args=[], kwargs={}) t = RepeatingTimer(30.0, f, args=[], kwargs={})
t.start() t.start()
t.cancel() # stop the timer's actions t.cancel() # stop the timer's actions
""" """
def __init__(self, interval, function, daemon=True, *args, **kwargs): def __init__(self, interval, function, daemon=True, *args, **kwargs):
threading.Thread.__init__(self) threading.Thread.__init__(self)
self.daemon = daemon self.daemon = daemon
self.interval = float(interval) self.interval = float(interval)
self.function = function self.function = function
self.args = args self.args = args
self.kwargs = kwargs self.kwargs = kwargs
self.finished = threading.Event() self.finished = threading.Event()
def cancel(self): def cancel(self):
"""Stop the timer if it hasn't finished yet""" """Stop the timer if it hasn't finished yet"""
log.debug("Stopping repeater for %s" % (self.function,)) log.debug("Stopping repeater for %s" % (self.function,))
self.finished.set() self.finished.set()
stop = cancel stop = cancel
def run(self): def run(self):
while not self.finished.is_set(): while not self.finished.is_set():
self.finished.wait(self.interval) self.finished.wait(self.interval)
if not self.finished.is_set(): #In case someone has canceled while waiting if not self.finished.is_set(): #In case someone has canceled while waiting
try: try:
self.function(*self.args, **self.kwargs) self.function(*self.args, **self.kwargs)
except: except:
log.exception("Execution failed. Function: %r args: %r and kwargs: %r" % (self.function, self.args, self.kwargs)) log.exception("Execution failed. Function: %r args: %r and kwargs: %r" % (self.function, self.args, self.kwargs))

View File

@ -3,10 +3,10 @@ from __future__ import unicode_literals
import sys, os import sys, os
def restart_program(): def restart_program():
""" Function that restarts the application if is executed.""" """ Function that restarts the application if is executed."""
args = sys.argv[:] args = sys.argv[:]
if not hasattr(sys, "frozen"): if not hasattr(sys, "frozen"):
args.insert(0, sys.executable) args.insert(0, sys.executable)
if sys.platform == 'win32': if sys.platform == 'win32':
args = ['"%s"' % arg for arg in args] args = ['"%s"' % arg for arg in args]
os.execv(sys.executable, args) os.execv(sys.executable, args)

View File

@ -5,13 +5,13 @@ standard_library.install_aliases()
import threading import threading
def call_threaded(func, *args, **kwargs): def call_threaded(func, *args, **kwargs):
#Call the given function in a daemonized thread and return the thread. #Call the given function in a daemonized thread and return the thread.
def new_func(*a, **k): def new_func(*a, **k):
# try: # try:
func(*a, **k) func(*a, **k)
# except: # except:
# pass # pass
thread = threading.Thread(target=new_func, args=args, kwargs=kwargs) thread = threading.Thread(target=new_func, args=args, kwargs=kwargs)
thread.daemon = True thread.daemon = True
thread.start() thread.start()
return thread return thread

View File

@ -9,34 +9,34 @@ speaker = None
retries = 0 retries = 0
def speak(text, interrupt=0): def speak(text, interrupt=0):
global speaker, retries global speaker, retries
if not speaker: if not speaker:
setup() setup()
try: try:
speaker.speak(text, interrupt) speaker.speak(text, interrupt)
except: except:
if retries < 5: if retries < 5:
retries = retries + 1 retries = retries + 1
speak(text) speak(text)
# speaker.braille(text) # speaker.braille(text)
def setup (): def setup ():
global speaker global speaker
logger.debug("Initializing output subsystem.") logger.debug("Initializing output subsystem.")
try: try:
# speaker = speech.Speaker(speech.outputs.Sapi5()) # speaker = speech.Speaker(speech.outputs.Sapi5())
# else: # else:
speaker = outputs.auto.Auto() speaker = outputs.auto.Auto()
except: except:
logger.exception("Output: Error during initialization.") logger.exception("Output: Error during initialization.")
def enable_sapi(): def enable_sapi():
speaker = outputs.sapi.SAPI5() speaker = outputs.sapi.SAPI5()
def copy(text): def copy(text):
import win32clipboard import win32clipboard
#Copies text to the clipboard. #Copies text to the clipboard.
win32clipboard.OpenClipboard() win32clipboard.OpenClipboard()
win32clipboard.EmptyClipboard() win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardText(text) win32clipboard.SetClipboardText(text)
win32clipboard.CloseClipboard() win32clipboard.CloseClipboard()

View File

@ -15,58 +15,58 @@ fsencoding = sys.getfilesystemencoding()
#log = logging.getLogger("paths") #log = logging.getLogger("paths")
if len(glob.glob("Uninstall.exe")) > 0: # installed copy if len(glob.glob("Uninstall.exe")) > 0: # installed copy
mode= "installed" mode= "installed"
def app_path(): def app_path():
return paths_.app_path() return paths_.app_path()
def config_path(): def config_path():
global mode, directory global mode, directory
if mode == "portable": if mode == "portable":
if directory != None: path = os.path.join(directory, "config") if directory != None: path = os.path.join(directory, "config")
elif directory == None: path = os.path.join(app_path(), "config") elif directory == None: path = os.path.join(app_path(), "config")
elif mode == "installed": elif mode == "installed":
path = os.path.join(data_path(), "config") path = os.path.join(data_path(), "config")
if not os.path.exists(path): if not os.path.exists(path):
# log.debug("%s path does not exist, creating..." % (path,)) # log.debug("%s path does not exist, creating..." % (path,))
os.mkdir(path) os.mkdir(path)
return path return path
def logs_path(): def logs_path():
global mode, directory global mode, directory
if mode == "portable": if mode == "portable":
if directory != None: path = os.path.join(directory, "logs") if directory != None: path = os.path.join(directory, "logs")
elif directory == None: path = os.path.join(app_path(), "logs") elif directory == None: path = os.path.join(app_path(), "logs")
elif mode == "installed": elif mode == "installed":
path = os.path.join(data_path(), "logs") path = os.path.join(data_path(), "logs")
if not os.path.exists(path): if not os.path.exists(path):
# log.debug("%s path does not exist, creating..." % (path,)) # log.debug("%s path does not exist, creating..." % (path,))
os.mkdir(path) os.mkdir(path)
return path return path
def data_path(app_name='socializer'): def data_path(app_name='socializer'):
if platform.system() == "Windows": if platform.system() == "Windows":
data_path = os.path.join(os.getenv("AppData"), app_name) data_path = os.path.join(os.getenv("AppData"), app_name)
else: else:
data_path = os.path.join(os.environ['HOME'], ".%s" % app_name) data_path = os.path.join(os.environ['HOME'], ".%s" % app_name)
if not os.path.exists(data_path): if not os.path.exists(data_path):
os.mkdir(data_path) os.mkdir(data_path)
return data_path return data_path
def locale_path(): def locale_path():
return os.path.join(app_path(), "locales") return os.path.join(app_path(), "locales")
def sound_path(): def sound_path():
return os.path.join(app_path(), "sounds") return os.path.join(app_path(), "sounds")
def com_path(): def com_path():
global mode, directory global mode, directory
if mode == "portable": if mode == "portable":
if directory != None: path = os.path.join(directory, "com_cache") if directory != None: path = os.path.join(directory, "com_cache")
elif directory == None: path = os.path.join(app_path(), "com_cache") elif directory == None: path = os.path.join(app_path(), "com_cache")
elif mode == "installed": elif mode == "installed":
path = os.path.join(data_path(), "com_cache") path = os.path.join(data_path(), "com_cache")
if not os.path.exists(path): if not os.path.exists(path):
# log.debug("%s path does not exist, creating..." % (path,)) # log.debug("%s path does not exist, creating..." % (path,))
os.mkdir(path) os.mkdir(path)
return path return path

View File

@ -1,22 +1,20 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" A "presenter" in the socializer's terminology is a module that handles business logic in the application's workflow. """ 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. 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. 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: 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. 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. 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. 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). 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. 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. 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 . import player
from .base import *
from .attach import * from .attach import *
from .audioRecorder import * from .audioRecorder import *
from .blacklist import * from .blacklist import *
from .createPosts import * from .createPosts import *
from .displayPosts import * from .displayPosts import *
from .configuration import * from .configuration import *
from .profiles import * from .profiles import *

View File

@ -1,19 +1,19 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" A "presenter" in the socializer's terminology is a module that handles business logic in the application's workflow. """ 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. 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. 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: 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. 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. 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. 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). 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. 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. 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 .attach import *
from .audioRecorder import * from .audioRecorder import *
from .postCreation import * from .postCreation import *
from .postDisplayer import * from .postDisplayer import *
from .configuration import * from .configuration import *
from .profiles import * from .profiles import *

View File

@ -15,109 +15,109 @@ from . import audioRecorder, base
log = logging.getLogger(__file__) log = logging.getLogger(__file__)
class attachPresenter(base.basePresenter): class attachPresenter(base.basePresenter):
""" Controller used in some sections of the application, it can do the following: """ 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). * 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). * 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. * 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): def __init__(self, session, view, interactor, voice_messages=False):
""" Constructor. """ Constructor.
@ session sessionmanager.session object: an object capable of calling all VK methods and accessing the session database. @ session sessionmanager.session object: an object capable of calling all VK methods and accessing the session database.
@voice_messages bool: If True, will add a button for sending voice messages. @voice_messages bool: If True, will add a button for sending voice messages.
""" """
super(attachPresenter, self).__init__(view=view, interactor=interactor, modulename="attach") super(attachPresenter, self).__init__(view=view, interactor=interactor, modulename="attach")
self.session = session self.session = session
# Self.attachments will hold a reference to all attachments added to the dialog. # Self.attachments will hold a reference to all attachments added to the dialog.
self.attachments = list() self.attachments = list()
self.run() self.run()
def upload_image(self, image, description): def upload_image(self, image, description):
""" allows uploading an image from the computer. Description will be used when posting to VK. """ allows uploading an image from the computer. Description will be used when posting to VK.
""" """
imageInfo = {"type": "photo", "file": image, "description": description, "from": "local"} imageInfo = {"type": "photo", "file": image, "description": description, "from": "local"}
self.attachments.append(imageInfo) self.attachments.append(imageInfo)
# Translators: This is the text displayed in the attachments dialog, when the user adds a photo. # Translators: This is the text displayed in the attachments dialog, when the user adds a photo.
info = [_("Photo"), description] info = [_("Photo"), description]
self.send_message("insert_attachment", attachment=info) self.send_message("insert_attachment", attachment=info)
self.send_message("enable_control", control="remove") self.send_message("enable_control", control="remove")
def upload_audio(self, audio): def upload_audio(self, audio):
""" Allows uploading an audio file from the computer. Only mp3 files are supported. """ """ Allows uploading an audio file from the computer. Only mp3 files are supported. """
if audio != None: if audio != None:
# Define data structure for this attachment, as will be required by VK API later. # Define data structure for this attachment, as will be required by VK API later.
# Let's extract the ID3 tags to show them in the list and send them to VK, too. # Let's extract the ID3 tags to show them in the list and send them to VK, too.
try: try:
audio_tags = ID3(audio) audio_tags = ID3(audio)
if "TIT2" in audio_tags: if "TIT2" in audio_tags:
title = audio_tags["TIT2"].text[0] title = audio_tags["TIT2"].text[0]
else: else:
title = _("Untitled") title = _("Untitled")
if "TPE1" in audio_tags: if "TPE1" in audio_tags:
artist = audio_tags["TPE1"].text[0] artist = audio_tags["TPE1"].text[0]
else: else:
artist = _("Unknown artist") artist = _("Unknown artist")
except ID3NoHeaderError: # File doesn't include ID3 tags so let's assume unknown artist. except ID3NoHeaderError: # File doesn't include ID3 tags so let's assume unknown artist.
artist = _("Unknown artist") artist = _("Unknown artist")
title = os.path.basename(audio).replace(".mp3", "") title = os.path.basename(audio).replace(".mp3", "")
audioInfo = {"type": "audio", "file": audio, "from": "local", "title": title, "artist": artist} audioInfo = {"type": "audio", "file": audio, "from": "local", "title": title, "artist": artist}
self.attachments.append(audioInfo) self.attachments.append(audioInfo)
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file. # Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.
info = [_("Audio file"), "{title} - {artist}".format(title=title, artist=artist)] info = [_("Audio file"), "{title} - {artist}".format(title=title, artist=artist)]
self.send_message("insert_attachment", attachment=info) self.send_message("insert_attachment", attachment=info)
self.send_message("enable_control", control="remove") self.send_message("enable_control", control="remove")
def upload_document(self, document): def upload_document(self, document):
""" allows uploading a document from the computer. """ allows uploading a document from the computer.
""" """
doc_info = {"type": "document", "file": document, "from": "local", "title": os.path.basename(os.path.splitext(document)[0])} doc_info = {"type": "document", "file": document, "from": "local", "title": os.path.basename(os.path.splitext(document)[0])}
self.attachments.append(doc_info) self.attachments.append(doc_info)
# Translators: This is the text displayed in the attachments dialog, when the user adds a document. # Translators: This is the text displayed in the attachments dialog, when the user adds a document.
info = [_("Document"), os.path.basename(document)] info = [_("Document"), os.path.basename(document)]
self.send_message("insert_attachment", attachment=info) self.send_message("insert_attachment", attachment=info)
self.send_message("enable_control", control="remove") self.send_message("enable_control", control="remove")
def upload_voice_message(self): def upload_voice_message(self):
a = audioRecorder.audioRecorderPresenter(view=views.audioRecorderDialog(), interactor=interactors.audioRecorderInteractor()) a = audioRecorder.audioRecorderPresenter(view=views.audioRecorderDialog(), interactor=interactors.audioRecorderInteractor())
if a.file != None and a.duration != 0: if a.file != None and a.duration != 0:
audioInfo = {"type": "voice_message", "file": a.file, "from": "local"} audioInfo = {"type": "voice_message", "file": a.file, "from": "local"}
self.attachments.append(audioInfo) self.attachments.append(audioInfo)
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file. # Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.
info = [_("Voice message"), seconds_to_string(a.duration,)] info = [_("Voice message"), seconds_to_string(a.duration,)]
self.send_message("insert_attachment", attachment=info) self.send_message("insert_attachment", attachment=info)
self.send_message("enable_control", control="remove") self.send_message("enable_control", control="remove")
####### ToDo: replace this with selector presenter when finished. ####### ToDo: replace this with selector presenter when finished.
def get_available_audios(self): def get_available_audios(self):
# Let's reuse the already downloaded audios. # Let's reuse the already downloaded audios.
list_of_audios = self.session.db["me_audio"]["items"] list_of_audios = self.session.db["me_audio"]["items"]
audios = [] audios = []
for i in list_of_audios: for i in list_of_audios:
audios.append("{0}, {1}".format(i["title"], i["artist"])) audios.append("{0}, {1}".format(i["title"], i["artist"]))
return audios return audios
def take_audios(self, audios_list): def take_audios(self, audios_list):
list_of_audios = self.session.db["me_audio"]["items"] list_of_audios = self.session.db["me_audio"]["items"]
for i in audios_list: for i in audios_list:
info = dict(type="audio", id=list_of_audios[i]["id"], owner_id=list_of_audios[i]["owner_id"]) info = dict(type="audio", id=list_of_audios[i]["id"], owner_id=list_of_audios[i]["owner_id"])
info["from"] = "online" info["from"] = "online"
self.attachments.append(info) self.attachments.append(info)
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file. # Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.
info2 = [_("Audio file"), "{0} - {1}".format(list_of_audios[i]["title"], list_of_audios[i]["artist"])] info2 = [_("Audio file"), "{0} - {1}".format(list_of_audios[i]["title"], list_of_audios[i]["artist"])]
self.send_message("insert_attachment", attachment=info2) self.send_message("insert_attachment", attachment=info2)
self.check_remove_status() self.check_remove_status()
def remove_attachment(self, item_index): def remove_attachment(self, item_index):
""" Remove the currently focused item from the attachments list.""" """ Remove the currently focused item from the attachments list."""
log.debug("Removing item %d" % (item_index,)) log.debug("Removing item %d" % (item_index,))
if item_index == -1: item_index = 0 if item_index == -1: item_index = 0
self.attachments.pop(item_index) self.attachments.pop(item_index)
self.send_message("remove_attachment", attachment=item_index) self.send_message("remove_attachment", attachment=item_index)
self.check_remove_status() self.check_remove_status()
log.debug("Removed") log.debug("Removed")
def check_remove_status(self): def check_remove_status(self):
""" Checks whether the remove button should remain enabled.""" """ Checks whether the remove button should remain enabled."""
if len(self.attachments) == 0: if len(self.attachments) == 0:
self.send_message("disable_control", control="remove") self.send_message("disable_control", control="remove")

View File

@ -10,102 +10,102 @@ from mysc.thread_utils import call_threaded
from . import base from . import base
class audioRecorderPresenter(base.basePresenter): class audioRecorderPresenter(base.basePresenter):
def __init__(self, view, interactor): def __init__(self, view, interactor):
super(audioRecorderPresenter, self).__init__(view=view, interactor=interactor, modulename="audiorecorder") super(audioRecorderPresenter, self).__init__(view=view, interactor=interactor, modulename="audiorecorder")
self.recorded = False self.recorded = False
self.recording = None self.recording = None
self.duration = 0 self.duration = 0
self.playing = None self.playing = None
self.file = None self.file = None
self.run() self.run()
def toggle_recording(self, *args, **kwargs): def toggle_recording(self, *args, **kwargs):
if self.recording != None: if self.recording != None:
self.stop_recording() self.stop_recording()
else: else:
self.start_recording() self.start_recording()
def start_recording(self): def start_recording(self):
self.file = tempfile.mktemp(suffix='.wav') self.file = tempfile.mktemp(suffix='.wav')
self.recording = sound.get_recording(self.file) self.recording = sound.get_recording(self.file)
self.duration = time.time() self.duration = time.time()
self.recording.play() self.recording.play()
self.send_message("set_label", control="record", label=_("&Stop")) self.send_message("set_label", control="record", label=_("&Stop"))
output.speak(_("Recording")) output.speak(_("Recording"))
self.send_message("disable_control", control="ok") self.send_message("disable_control", control="ok")
def stop_recording(self): def stop_recording(self):
self.recording.stop() self.recording.stop()
self.duration = int(time.time()-self.duration) self.duration = int(time.time()-self.duration)
self.recording.free() self.recording.free()
output.speak(_("Stopped")) output.speak(_("Stopped"))
self.recorded = True self.recorded = True
self.send_message("set_label", control="record", label=_("&Record")) self.send_message("set_label", control="record", label=_("&Record"))
self.send_message("disable_control", control="record") self.send_message("disable_control", control="record")
self.send_message("enable_control", control="play") self.send_message("enable_control", control="play")
self.send_message("enable_control", control="discard") self.send_message("enable_control", control="discard")
self.send_message("enable_control", control="ok") self.send_message("enable_control", control="ok")
self.send_message("focus_control", control="play") self.send_message("focus_control", control="play")
def discard_recording(self, *args, **kwargs): def discard_recording(self, *args, **kwargs):
if self.playing: if self.playing:
self._stop() self._stop()
if self.recording != None: if self.recording != None:
self.cleanup() self.cleanup()
self.send_message("disable_control", control="play") self.send_message("disable_control", control="play")
self.send_message("disable_control", control="ok") self.send_message("disable_control", control="ok")
self.file = None self.file = None
self.send_message("enable_control", control="record") self.send_message("enable_control", control="record")
self.send_message("focus_control", control="record") self.send_message("focus_control", control="record")
self.send_message("disable_control", control="discard") self.send_message("disable_control", control="discard")
self.recording = None self.recording = None
output.speak(_("Discarded")) output.speak(_("Discarded"))
def play(self, *args, **kwargs): def play(self, *args, **kwargs):
if not self.playing: if not self.playing:
call_threaded(self._play) call_threaded(self._play)
else: else:
self._stop() self._stop()
def _play(self): def _play(self):
output.speak(_("Playing...")) output.speak(_("Playing..."))
# try: # try:
self.playing = sound_lib.stream.FileStream(file=str(self.file), flags=sound_lib.stream.BASS_UNICODE) self.playing = sound_lib.stream.FileStream(file=str(self.file), flags=sound_lib.stream.BASS_UNICODE)
self.playing.play() self.playing.play()
self.send_message("set_label", control="play", label=_("&Stop")) self.send_message("set_label", control="play", label=_("&Stop"))
try: try:
while self.playing.is_playing: while self.playing.is_playing:
pass pass
self.send_message("set_label", control="play", label=_("&Play")) self.send_message("set_label", control="play", label=_("&Play"))
self.playing.free() self.playing.free()
self.playing = None self.playing = None
except: except:
pass pass
def _stop(self): def _stop(self):
output.speak(_("Stopped")) output.speak(_("Stopped"))
self.playing.stop() self.playing.stop()
self.playing.free() self.playing.free()
self.send_message("set_label", control="play", label=_("&Play")) self.send_message("set_label", control="play", label=_("&Play"))
self.playing = None self.playing = None
def postprocess(self): def postprocess(self):
if self.file.lower().endswith('.wav'): if self.file.lower().endswith('.wav'):
output.speak(_("Recoding audio...")) output.speak(_("Recoding audio..."))
sound.recode_audio(self.file) sound.recode_audio(self.file)
self.wav_file = self.file self.wav_file = self.file
self.file = '%s.ogg' % self.file[:-4] self.file = '%s.ogg' % self.file[:-4]
self.cleanup() self.cleanup()
def cleanup(self): def cleanup(self):
if self.playing and self.playing.is_playing: if self.playing and self.playing.is_playing:
self.playing.stop() self.playing.stop()
if self.recording != None: if self.recording != None:
if self.recording.is_playing: if self.recording.is_playing:
self.recording.stop() self.recording.stop()
try: try:
self.recording.free() self.recording.free()
except: except:
pass pass
if hasattr(self, 'wav_file'): if hasattr(self, 'wav_file'):
os.remove(self.wav_file) os.remove(self.wav_file)

View File

@ -5,15 +5,15 @@ from interactors import configuration as interactor
class basePresenter(object): class basePresenter(object):
def __init__(self, view, interactor, modulename): def __init__(self, view, interactor, modulename):
self.modulename = modulename self.modulename = modulename
self.interactor = interactor self.interactor = interactor
self.view = view self.view = view
self.interactor.install(view=view, presenter=self, modulename=modulename) self.interactor.install(view=view, presenter=self, modulename=modulename)
def run(self): def run(self):
self.interactor.start() self.interactor.start()
self.interactor.uninstall() self.interactor.uninstall()
def send_message(self, msg, *args, **kwargs): def send_message(self, msg, *args, **kwargs):
pub.sendMessage(self.modulename+"_"+msg, *args, **kwargs) pub.sendMessage(self.modulename+"_"+msg, *args, **kwargs)

View File

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

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