GSoC Proposal: User Profile & File Transfer Support in Tox Qt GUI

Recently, I had applied for Google Summer of Code but I was not able to get through as my mentoring organization did not get enough slots from Google as they applied as an organization for the first time. I applied for User profile & File Transfer support in Tox Qt GUI client.

Short Description:

This project aims at making Tox Qt GUI client more elegant and user friendly by introducing user profile creation, data portability such that users will be able to carry their data in either encrypted or raw format and login from different machines under same profile. Another feature which the project will introduce is the file transfer support  with a nice file transfer manager widget, something similar to Firefox’s download manager.

Project:

The project will be mainly dealing with 2 major tasks. Two of them (user profile support and file transfer support) have something in common: they improve the security & reusability of the client

One of the key goals of the project would be to introduce user profile support in Tox Qt GUI. Currently, Tox Qt GUI does not save the user data, instead it creates a new profile, nothing carries over except the GUI-specific settings. The current proposal aims to introduce the user profile support in the Qt client. Some of the functionalities of the user profile support includes login dialog, import/export dialog, create new profiles,  login using any of already created in Qt GUI profiles, re-log under different profile without restarting the application and export/import profile in raw/encrypted format.

libtoxdata is a new library that provides standardized and secure way to save a user profile on a disc.  Most Tox clients are still saving all user data in raw format, meaning that once a data file is stolen, the user loses accessibility to account, but with this library a user can password-encrypt Tox data file when storing it on a disc. This feature will allow users to carry the data files either in raw or encrypted format and connect to the Tox network from any other machines.

Login dialog

(Mock up UI repo:https://github.com/seshagiriprabhu/gsoc-1)

Consists of two widgets:

1. Existing user widget:

Existing users can enter his/her profile name and password to login. Only users with user data pre-loaded locally would be able advance further to use the messenger. The  “nickname” in the login window is just a profile name, which is always unencrypted, it has nothing to do with the nickname. If password-protected, nickname and other information will be encrypted using that password, but not the profile name, since user would need to differentiate between different encrypted user profiles.

Mockup UI – 1: Login window for existing users

Each user profile would have it’s own folder(lets say: /home/seshagiri/.config/tox/), and each folder would have a user profile file, which is just tox_save() encrypted by libtoxdata, so any client could add support of user profiles just by using that library.

When a user tries to login  using a profile name chosen from the drop down menu of  [Mockup UI – 1], the widget will parse the corresponding .tox file from the profile directory using data_init_load and data_unlock functions

tox_data *profile = data_init_load("/home/seshagiri/.config/tox/whatever.tox");
data_unlock(profile, "password1");

If the data_unlock returns a zero, which means that the login was successful. Next step would be to load the user environment using tox_data function.

uint8_t *buffer;
size_t size = data_read_messenger(profile, &buffer);
tox_load(tox, buffer, size);

2. New user widget:

Mockup UI -2 : Sign up page for new users

A user could create a profile by entering a profile name and password.  A user can create multiple profiles under the same name as the tox core assigns each profiles a hash upon registering. A user will also be able to create “raw profiles” i.e passwordless unencrypted profiles.  When a user creates an account the widget will indeed call data_init_new function of  ProjectTox-libtoxdata.

tox_data* data_init_new(char *path, uint8_t *data_name, uint8_t *password);

The Project will also enable the logout feature that will save/update the tox_data and lock down the profile encrypted using data_write_messenger and data_lock functions.

int data_write_messenger(tox_data *data, uint8_t *buffer, size_t length);
int data_lock(tox_data *data);

Import-Export dialogs

(Import dialog mockup UI repo: https://github.com/seshagiriprabhu/gsoc-2)

(Export dialog mockup UI repo: https://github.com/seshagiriprabhu/gsoc-3)

A simple dialog box with file chooser in it, which will allow to pick any file from the disc. After a user chooses something, the widget would try to parse it as a tox data/profile file and display some informations like profile name, time when the profile was accessed last time etc.
There are currently 3 different tox data files: toxcore raw and libtoxprofile raw and encrypted. These are the two cases which the user profile import/export will encounter:

Profile type Import Export
Case 1:
Only encrypted profile
Allows to import encrypted profiles and raw toxcore data. When user tries to import a raw toxcore data, it will be converted to a tox encrypted profile, i.e. user will be asked to give it profile name and password Allows to export already existing profiles (which are all encrypted tox profiles) as tox encrypted profiles (basically just makes a copy of a selected profile) and raw profiles (just for compatibility with other clients).
Case 2:
Both encrypted and raw profiles
Allows to import encrypted profiles, raw profiles and raw toxcore data. When trying to import raw toxcore data, it can be converted to tox encrypted or raw profiles, i.e. user will have an option to choose. For encrypted the user will be asked for profile name and password, for raw just a profile name. Allows to export already existing profiles (which are all either encrypted tox profiles or raw tox profiles) in all possible formats, i.e.
raw profile → raw profile,
raw profile → encrypted profile,
raw profile → toxcore raw,
encrypted profile → raw profile,
encrypted profile → encrypted profile, encrypted profile → toxcore raw.

Mockup UI – 3: When the import dialog is opened

Mockup UI – 4: The widget displays some of the unencrypted fields of the loaded file

Upon selecting a file the widget will parse the selected file and will display some of the data (profile name, unix timestamp from when the profile was last used, profile type etc)  read from the unencrypted block of the .tox file.

Mockup UI – 5: Import dialog calls an authentication dialog

 Whether its case 1 or 2, the widget will force user to create an encrypted profile when a raw profile is imported. data_init function will be called here to create an encrypted profile.

Mockup UI – 6: When an encrypted profile is imported

 In both case 1 and 2, when a user tries to load an encrypted profile, the widget will prompt user a dialog box to enter the password in-order to unlock his profile. This is done by calling data_unlock function

Mockup UI – 7:, Export dialog box with filters

 After a user logins,  the data is unlocked and hence we could export it to any format we want. The only condition to be checked here is whether a user is logged in or not before exporting. The export widget will indeed call getSaveFileName of QFileDialog which will create a copy of /home/seshagiri/.config/tox/current_user.tox to the directory which user prefers if the current logged in user uses an encrypted profile. This is the code snippet which exports to any of the filter (raw, encrypted or toxcore raw)

QString filename = QFileDialog::getSaveFileName(this,tr("Export Profile"),
                  MySettings.value(DEFAULT_DIR_KEY).toString(),
                  tr(RAW";;"ENC";;"TOX_RAW),&selectedFilter);
if (selectedFilter == RAW) {
      // code for encrypted -> raw or raw -> raw conversion
} elseif (selectedFilter == ENC) {
      // code for enc -> enc or raw -> enc conversion
} else {
      // code for enc -> tox_raw or raw -> tox_raw conversion
}

 File transfer support is the next major task in this project. A new file transfer widget would be introduced as a part of the project. The file transfer widget maintains a list of files transferred between a particular friend and it will be stored in SQLite DB and sorted based on the timestamp of file transfer actions (send, receive, pause, accept and stop).

The file transfer widget is to be located between friend item widget and message display widget. It has two states: opened and close. When a user chats with one of his friends, upon opening the file manager widget, it will display a (file transfer manager) dialog box with a list of files transferred to that particular user using a QListWidget. A global file transfer manager could be accessed from the settings menu which has an embedded filter in-order to facilitate file search based on filename, friend(s), timestamp, send, stopped and received.

Users will be able to upload a file by clicking on the file attachment button at the right corner of the ChatView widget. Upon clicking on file transfer widget, a file transfer manager dialog will pop up.

File Transfer Manager Dialog

(Mockup UI repo: https://github.com/seshagiriprabhu/gsoc-4)

As an effort to bring all the file transfer actions at a single place, the project will introduce a file transfer manager just like the download manager of firefox. All the file transfer history could be accessed from this file transfer manager. The file transfer also consists of a search filter embedded to search based on various filters including: filename, date time of transfer, send, received, to/from a friendID etc.

Mockup UI – 8: File Transfer Manager Mockup UI

The project will enable certain callback functions of the toxcore upon accepting a friend request which includes callback functions like:

  1. File send request
    void tox_callback_file_send_request(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint64_t, uint8_t *, uint16_t, void *), void *userdata);
  2. File control request
    void tox_callback_file_control(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint8_t, uint8_t, uint8_t *, uint16_t, void *), void *userdata);
  3. File data
    void tox_callback_file_data(Tox *tox, void (*function)(Tox *m, int, uint8_t, uint8_t *, uint16_t length, void *), void *userdata);

SQLite database is going to be used as a part of the project for storing the file transfer history of the users. The application will be tweaked to detect an SQLite db file under a specified directory on the disc. If it is not found, the application will create a new database file. This event will happen whenever a user login occurs.

Schema of the file transfer database would look like this:

sqlite> CREATE TABLE transfer_details (
   → ID INTEGER PRIMARY KEY,
   → transfer_role VARCHAR,# transfer_role {send, received, sending, receiving, paused, stopped}
   → timestamp DATETIME,# Will be updated to the current system time when a transfer role changes
   → filename VARCHAR,
   → userID VARCHAR, # Logged in user’s id
   → friendID VARCHAR, # The id of the person at the other end
   → totalFileSize FLOAT, # The actual size of file to be transferred 
   → transferedFileSize FLOAT,# The size of file transferred so far
   → );

SQLite currently does not support data encryption. There is an opensource SQLcipher but it is not available for Qt platform yet. So its upto the user to keep the database file safe on the disc. The project will not use any object relational mapping library rather plain sql queries would be used to access the transfer_details.

If time permits, the project will include an implementation of a spell checker with multilingual support in the input text box widget. Currently, the Tox Qt GUI supports only English language and it doesn’t have spell checker. This proposal aims to integrate a spell checker with the input text box widget which will allow user to fix misspellings by using the spell check. The user would be able to select different language dictionaries from a context menu. Hunspell spell checker will be integrated to the Qt client as it extensively used in most popular open source applications like libreoffice, openoffice, mozilla firefox, thunderbird and chromium. Hunspell has support in  Mac OS X and Windows based operating systems.

Files to be added to the project:

src/logindialog.hpp An interface which is the entry point to the application. The user will be able to use the messenger only after authenticating or signing up. Will be called from starter class before creating mainwindow.
src/importdialog.hpp An dialog box which will import the user profiles. This class also validates the user profile data file and loads the user environment like previous GUI size, friendlist, chat logs etc upon completing the import
src/createuserprofile.hpp A dialog box for creating an encrypted profile. If the imported user profile is raw.
src/validateprofile.hpp A dialog box which asks password of the encrypted user profile which is imported
src/exportdialog.hpp A dialog class which deals with exporting the user profile data to a file. It will allow user to export to these formats: Raw, encrypted and toxcore raw format
src/filetransfermanagerDialog.hpp A dialog box which displays a list of files transferred by the current user. It also has an embedded file filter.
src/filetransferwidget.hpp A widget which maintains a list of files transferred by the current logged in user. This widget will make use of DataBaseManager class for all the database related operations.
src/fileItemDelegate.hpp This class provides display and editing features (pause, resume, stop) for data items of the model used for QTreeView in FileTransferManager dialog.
src/filefilterWidget.hpp A widget for filtering the files based on filename, timestamp, friend, send and received. This widget will also interact with DB.
src/DatabaseManager.hpp An object class for creating, storing, updating, deletion of file transfer data from the SQLite database. This will create a db file on the local disc either if it is destroyed/lost or when the application is opened for the first time.
submodules/ProjectTox-libtoxdata A library for saving and loading encrypted copies of the Tox Messenger using scrypt-jane.
src/spellchecker.hpp A widget which uses the hunspell to check the errors in the words entered in input text widget. The widget will also have a custom menu bar which could be used to get word suggestions if there are any spelling errors and the user could also select other languages using the same.

Profit for Tox Qt GUI

  1. Facilitate the use of Tox Qt GUI by allowing the user to create profile(s) and store the data in encrypted or raw format, thus making the Qt client more intuitive, portable and secure.
  2. A widget for sending and receiving files for the Qt client.
  3. Increasing the reach of Qt client to wide range of people by enabling multilingual support. 

Roadmap

  1. Until mid May: Publish my goals to the Tox Qt GUI community and try to get some feedback and  suggestions on my plans. I will get familiar with the specific Qt GUI internals that I require for my work.
  2. Until June end: Implement the first feature: that means that I will begin with implementing login and user account creation, continue with import/export user profile
  3. Until July end [buffer upto August mid]: Implement the second feature: I will begin designing (hard coded) the UI for transfer widget and continue with implementing the functionalities of the widget i.e send, receive, pause, accept, stop etc.
  4. Until mid August: If the above tasks are completed, integration of the spell checker for input text widget with multi-lingual support and support of notification messages would be implemented.

Detailed timeline

May 12 – May 23 Academical examinations
May 24 – May 27 Discuss implementation details and ideas. Fix some more bugs.
May 28 – June 2 Code the import, export and all the sub dialog boxes
June 3 – June 22 Integrate libtoxdata to Tox Qt GUI code base, validate the login, profile creation, importing raw and encrypted profiles, exporting to raw, encrypted and toxcore raw formats.
June 23 – June 29 Mid review + Testing all the features implemented so far
June 30 – July 6 Code the file transfer manager dialog  + Implementation of FileItemDelegate, FileFilter, FileTransferWidget, DatabaseManger and FileTranferManager
July 7 – July 20 Implement fileSendReceived, fileSendRequestReceived, fileControlReceived, fileDataReceived, fileControlReceived, fileDataReceived, sendFiles, receiveFilesand fileSendCompleted functions.
July 21 – July 27 Implement file drag’n’drop functionality in the message display widget and input text widget and integrate it with file transfer widget
July 28 – Aug 3 Implement search functionality with smart filter (filename, friend(s), timestamp, send and received) in the file transfer manager dialog
Aug 3 – Aug 11 Testing file transfer support
Aug 11 – Aug 22 Final report + if the above tasks are completed a spell checker with multi-lingual support in the input text widget would be implemented
Afterwards Continue testing and bug fixing

Personal Details

  • Full name: Seshagiri Prabhu Narasimha
  • Timezone: UTC +5:30
  • Email Address: seshagiriprabhu@gmail.com
  • IRC username: seshagiri
  • Patches for Tox:  #768, #108and#108
  • Github repo: https://github.com/seshagiriprabhu/
  • Will you treat Google Summer of Code as full time employment?:  Yes
  • How many hours per day will you work?: 7+ hours per day
  • List all obligations (and their dates) that may take time away from GSoC: I have exams starting from May 12th to 23rd. College will re-open in mid July. When the college re-opens, I will be able to work only for 5-6 hours per day.
  • Estimated last day of classes/exams: May 23rd
  • Estimated first day of classes: July 16th

Why Tox Qt GUI

I envy Tox, an open source messaging application that is developed from ground up by putting privacy at the forefront which makes it revolutionary. I have done a few contributions to Tox before.  I have been providing bug reports and patches to Tox from time to time (issues #768, #108). I have also written some other patches that are not yet committed (issues #108).

I have  designed UI for several websites which includes inctf.in, portal.inctf.in etc. In June 2013, I have done a contribution to Sympy,  a python library for symbolic mathematics, in which I replaced the Bareis Fraction free algorithm (with computational complexity of O(n!)) for determining the determinant of matrices with Laplace expansion algorithm which runs on O(n2 ).

Recently, I have won a programming challenge which involved  involved the development of an open source disaster management communication information system for an NGO, Wise Earth Technology. The system consists of mobile communication stations, running on cheap open source hardware (raspberry pi connected to a 5 inch TFT display), supported by a web  application that uses the django web framework. In order to guarantee the peaceful use of this application, while ensuring that the military can use it for rescue operations during disasters, a new Peaceful Open Source License was adopted.

That said, I think that I will succeed in providing clean and fully functional enhancements to the whole project.

Advertisements

One comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s