├── .gitignore ├── .gitmodules ├── .travis.yml ├── .travis_publish_win.sh ├── LICENSE ├── README.md ├── screenshots ├── client_chat.png ├── mockup.svg ├── profile_creation.png └── profile_selection.png └── src ├── CMakeLists.txt ├── cmake ├── FindFlatbuffers.cmake └── FindTox.cmake ├── config.cpp ├── config.h ├── dialog ├── chat.cpp ├── chat.h ├── detachable_window.cpp ├── detachable_window.h ├── error.cpp ├── error.h ├── main.cpp ├── main.h ├── profile_create.cpp ├── profile_create.h ├── profile_selection.cpp ├── profile_selection.h ├── settings.cpp └── settings.h ├── gtox.cpp ├── gtox.desktop ├── gtox.h ├── i18n ├── .gitignore ├── CMakeLists.txt ├── de.po ├── en.po ├── es.po ├── fr.po ├── it.po ├── ru.po ├── stats.sh └── update.sh ├── main.cpp ├── resources ├── flatbuffers │ ├── CMakeLists.txt │ ├── Config.fbs │ ├── ConfigGlobal.fbs │ ├── Log.fbs │ └── generated │ │ └── .gitignore ├── gresource.sh ├── icon │ ├── CMakeLists.txt │ ├── avatar.svg │ ├── chat-attach-symbolic.svg │ ├── chat-detach-symbolic.svg │ ├── clipboard-symbolic.svg │ ├── icon.svg │ ├── icon_128.svg │ ├── notification.svg │ ├── plus-symbolic.svg │ ├── remove-symbolic.svg │ ├── settings-symbolic.svg │ ├── status_away.svg │ ├── status_away_tcp.svg │ ├── status_busy.svg │ ├── status_busy_tcp.svg │ ├── status_message.svg │ ├── status_offline.svg │ ├── status_offline_tcp.svg │ ├── status_online.svg │ └── status_online_tcp.svg ├── style │ ├── CMakeLists.txt │ ├── common.css │ ├── dark.css │ ├── light.css │ ├── main_alt.css │ └── profile.css └── ui │ ├── CMakeLists.txt │ ├── chat_bubble_left.ui │ ├── chat_bubble_right.ui │ ├── chat_filepreview.ui │ ├── chat_filerecv.ui │ ├── dialog_assistant.ui │ ├── dialog_chat.ui │ ├── dialog_contact.ui │ ├── dialog_detachable.ui │ ├── dialog_profile.ui │ ├── dialog_settings.ui │ ├── list_item_contact.ui │ ├── list_item_notification.ui │ ├── list_item_notification_mini.ui │ ├── list_item_profile.ui │ ├── popover_settings.ui │ ├── status_menu.ui │ └── videoplayer.ui ├── tox ├── CMakeLists.txt ├── av.cpp ├── av.h ├── config.cpp ├── config.h ├── contact │ ├── call.cpp │ ├── call.h │ ├── contact.cpp │ ├── contact.h │ ├── file │ │ ├── file.cpp │ │ ├── file.h │ │ ├── file_recv.cpp │ │ ├── file_recv.h │ │ ├── file_send.cpp │ │ ├── file_send.h │ │ ├── manager.cpp │ │ └── manager.h │ ├── manager.cpp │ ├── manager.h │ ├── receipt.cpp │ └── receipt.h ├── core.cpp ├── core.h ├── exception.cpp ├── exception.h ├── flatbuffers │ ├── CMakeLists.txt │ ├── Config.fbs │ ├── File.fbs │ └── generated │ │ └── .gitignore ├── profile.cpp ├── profile.h ├── storage.cpp ├── storage.h ├── test │ ├── contact.t.h │ ├── core.t.h │ ├── file.t.h │ ├── global_fixture.t.h │ ├── profile.t.h │ └── types.t.h ├── types.cpp ├── types.h └── utils.h ├── utils ├── audio_notification.cpp ├── audio_notification.h ├── builder.cpp ├── builder.h ├── debug.cpp ├── debug.h ├── dispatcher.h ├── gstreamer.cpp ├── gstreamer.h ├── storage.cpp ├── storage.h ├── webcam.cpp └── webcam.h └── widget ├── avatar.cpp ├── avatar.h ├── chat_action.cpp ├── chat_action.h ├── chat_bubble.cpp ├── chat_bubble.h ├── chat_file.cpp ├── chat_file.h ├── chat_file_popover.cpp ├── chat_file_popover.h ├── chat_input.cpp ├── chat_input.h ├── chat_message.cpp ├── chat_message.h ├── contact.cpp ├── contact.h ├── imagescaled.cpp ├── imagescaled.h ├── label.cpp ├── label.h ├── main_menu.cpp ├── main_menu.h ├── popover.cpp ├── popover.h ├── videoplayer.cpp └── videoplayer.h /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /toxcore 3 | /.cproject 4 | /.project 5 | /.settings/ -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "src/audio"] 2 | path = src/audio 3 | url = https://github.com/Tox/Sounds 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | branches: 2 | except: 3 | - AUR 4 | cache: ccache 5 | language: cpp 6 | sudo: required 7 | matrix: 8 | include: 9 | - compiler: gcc 10 | env: DOCKER=kokutoru/gtox-travis-build CMAKE=cmake TEST=1 11 | services: 12 | - docker 13 | - compiler: clang 14 | env: DOCKER=kokutoru/gtox-travis-build CMAKE=cmake TEST=1 15 | services: 16 | - docker 17 | - compiler: gcc 18 | env: DOCKER=kokutoru/gtox-travis-build-mingw-w64 CMAKE=i686-w64-mingw32-cmake TEST=0 PUB_WIN=1 PUB_COPY=i686-w64-mingw32 PUB_FILE=gtox.win.i686 19 | services: 20 | - docker 21 | - compiler: gcc 22 | env: DOCKER=kokutoru/gtox-travis-build-mingw-w64 CMAKE=x86_64-w64-mingw32-cmake TEST=0 PUB_WIN=1 PUB_COPY=x86_64-w64-mingw32 PUB_FILE=gtox.win.x86-64 23 | services: 24 | - docker 25 | git: 26 | submodules: true 27 | before_install: 28 | - ccache -s 29 | - docker pull $DOCKER 30 | script: 31 | - mkdir src/build 32 | - docker run -v ~/.ccache:/root/.ccache -v $PWD:/opt/gtox -w /opt/gtox/src/build $DOCKER bash -c "PATH=\"/usr/lib/ccache/bin/:$PATH\" CXX=$CXX $CMAKE -DCMAKE_INSTALL_PREFIX:PATH=./publish .." 33 | - docker run -v ~/.ccache:/root/.ccache -v $PWD:/opt/gtox -w /opt/gtox/src/build $DOCKER bash -c "make" 34 | - if [ $TEST = 1 ]; then docker run -v $PWD:/opt/gtox -w /opt/gtox/src/build $DOCKER bash -c "./tox/toxmm-test"; fi 35 | after_success: 36 | - if [ "$PUB_WIN" = 1 ]; then docker run -e "TRAVIS_BRANCH=$TRAVIS_BRANCH" -e "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST" -e "PUBLISH_KEY=$PUBLISH_KEY" -e "PUBLISH_HOST=$PUBLISH_HOST" -e "PUB_COPY=$PUB_COPY" -e "PUB_FILE=$PUB_FILE" -v $PWD:/opt/gtox -w /opt/gtox/src/build $DOCKER bash -c "../../.travis_publish_win.sh"; fi 37 | - ccache -s 38 | env: 39 | global: 40 | - secure: XNEZRZwimLwOjmco3uL2kOZM3NJmPW7X6PtpuOKtmVYRfrWAtNf+egrsOko1sGW0SR+2p2O2EljtRRJpIWwquGksQr1dtkuQC0JnwYo9rPGw+BaV3dRybR1bbN/622XpVv6C2RQPzf8u94I9itH/Qa7uU4NofdByPPkqWZXSZ7fup3Dcbn4L0EfrTOJjg8cvYqWWYTB3F1v/tjNwoi4SZd80EofSo1UpBei/EVWNAqf/T+7kRqEWhbhqrtrQVLAxVEkRSqYgfmtQ6UmVFXVm+JhIvOW82Bf8xmS9WYf0hqZ8ZCcdq6no8FmszzNXrIDBlqd53ePCt+RLTZkShxArqWB/sYE2KfHv3ISA4K0WsmTrN3Y9zVwI2f7G2w2E5drNcYg2pOr32vgeTnVisiRPlT+IJtBKkplGMFDKYjcqB3eDPdgQ1glBN/ndg7jyUggvoXDkBWj3pKcfVR+UMqGtpXj29UTE3GtgsTXv9ZLeMQFhRhfu0KAl0qnjZGfvy2CX+iI13rFTSMRGJG2pssb0BL7KZqKqo2SwHOhFl+FB5WiWi5mpzde5J9QILpfkwqVJxs8/qcRgxufLsHQKbn52teNKyHncx6KTZTf2MjZOfrajy3DvLne2W/BdJ7qVbqfCe3EGeaT3xU1q2TBw8zDaIpqM04C0xxgqnaLPX6wN0Qo= 41 | - secure: DyAYT7w9QeXLk9alHcGVxAcC+88tW2/3iBsPoF017119lrQWaGqnb4UCxVw9TkhTNQeQJUq7LSFdrL7z2+jzbONoQgUysoWFCgDWpZy1E4x+F/13E9z3O+YZ5tVwHH738uqD9ZOW8Rz0SDEpZKe4QEE/3vdzsmjsFQ8rtNPPraSNKoDDkjs0xy5qPUcIK2V3+nG+802bQ4kuyjiB0kk7tRjrhcdVlr9TcCH/FjzjJYOe0GNw+F1IGi+/rZq9KKNmThiQ2JOEDIbianj2umO12weBDU0Ygxb0PQ11fZxFsZP+vB9isSRVTWQYXbyVJZB0twFav3aQM8nHspO0MZPSB6SRxYRS/CS3kA+duonG3nuGKW3gHsCTe/v4qByFGKUeQyDPXOc4Hl/aBhykkT0rPIOtc6ob6jD9m9MiSqJxSc/Q3K0WrSORkKaGx7tKeMI1hG+bckjjRGl/mAw94hO7+8ETRzxFnwc+O31sLwPBClCPStr9j+jkwbCqwqiAe8mmXanjRJGpXBWOhzxIRtr1/hx/Jxx85XbUbgCACzevDALjWrXYPYW3e2h3zveq514ej6aUOMEA8CFVzuoBCe0eeVU1wAPZUOz13PboufZKs6PRFz254Iwjw06E2e0RASDeJXhzCNPteyi2mhZIkJVlIMftLDq6FinfJ9uxF4lWh+c= 42 | -------------------------------------------------------------------------------- /.travis_publish_win.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | if [ "$TRAVIS_BRANCH" != "master" -o "$TRAVIS_PULL_REQUEST" != "false" ]; then 3 | echo "Nothing todo" 4 | exit 5 | fi 6 | 7 | mkdir publish 8 | make install || exit $? 9 | cp -rT /usr/$PUB_COPY publish 10 | cd publish 11 | 12 | echo "Fix libharfbuzz-1.dll bug" 13 | cp bin/libharfbuzz-0.dll bin/libharfbuzz-1.dll 14 | cp bin/libharfbuzz-gobject-0.dll bin/libharfbuzz-gobject-1.dll 15 | cp bin/libharfbuzz-icu-0.dll bin/libharfbuzz-icu-1.dll 16 | 17 | echo "Generate loaders.cache for SVG" 18 | FILE=lib/gdk-pixbuf-2.0/2.10.0/loaders.cache 19 | echo "\"../lib/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.dll\"" > $FILE 20 | echo "\"svg\" 2 \"gdk-pixbuf\" \"Scalable Vector Graphics\" \"LGPL\"" >> $FILE 21 | echo "\"image/svg+xml\" \"image/svg\" \"image/svg-xml\" \"image/vnd.adobe.svg+xml\" \"text/xml-svg\" \"image/svg+xml-compressed\" \"\"" >> $FILE 22 | echo "\"svg\" \"svgz\" \"svg.gz\" \"\"" >> $FILE 23 | echo "\" > $FILE 24 | echo "\" <\!DOCTYPE svg\" \"* \" 100" >> $FILE 25 | echo "" >> $FILE 26 | echo "" >> $FILE 27 | 28 | echo "Remove unused files" 29 | find . -name "*.a" -type f -delete &> /dev/null 30 | find . -name "*.h" -type f -delete &> /dev/null 31 | find . -name "*.c" -type f -delete &> /dev/null 32 | find . -name "*.hpp" -type f -delete &> /dev/null 33 | find . -name "*.cpp" -type f -delete &> /dev/null 34 | find . -name "*.o" -type f -delete &> /dev/null 35 | find . -name "*.pc" -type f -delete &> /dev/null 36 | find . -name "*.m4" -type f -delete &> /dev/null 37 | find . -name "*.sh" -type f -delete &> /dev/null 38 | find . -name "*.spec" -type f -delete &> /dev/null 39 | find . -name "*.cmake" -type f -delete &> /dev/null 40 | find . -name include -exec rm -rf {} \; &> /dev/null 41 | find . -name proc -exec rm -rf {} \; &> /dev/null 42 | rm -rf share/doc &> /dev/null 43 | find . -type d -empty -exec rm -rf {} \; &> /dev/null 44 | 45 | echo "Get version" 46 | git fetch --unshallow 47 | PKG_VERSION=`git describe --long --tags 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' || printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"` 48 | 49 | echo "Generate Zip" 50 | sudo pacman -S zip --noconfirm 51 | zip -r9 ../$PUB_FILE.$PKG_VERSION.zip ./* > /dev/null &> /dev/null 52 | cd .. 53 | 54 | if [ ! -z "$PUBLISH_KEY" ]; then 55 | echo "Upload" 56 | curl -u $PUBLISH_KEY -T $PUB_FILE.$PKG_VERSION.zip $PUBLISH_HOST -k 57 | fi 58 | 59 | -------------------------------------------------------------------------------- /screenshots/client_chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoKuToru/gTox/3ae68fb92def001b8ae3c29e88d7370e8c5145cb/screenshots/client_chat.png -------------------------------------------------------------------------------- /screenshots/profile_creation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoKuToru/gTox/3ae68fb92def001b8ae3c29e88d7370e8c5145cb/screenshots/profile_creation.png -------------------------------------------------------------------------------- /screenshots/profile_selection.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KoKuToru/gTox/3ae68fb92def001b8ae3c29e88d7370e8c5145cb/screenshots/profile_selection.png -------------------------------------------------------------------------------- /src/cmake/FindFlatbuffers.cmake: -------------------------------------------------------------------------------- 1 | find_path(FLATBUFFERS_INCLUDE_DIR flatbuffers/flatbuffers.h) 2 | 3 | find_library(FLATBUFFERS_LIBRARY flatbuffers) 4 | 5 | include(FindPackageHandleStandardArgs) 6 | find_package_handle_standard_args(Flatbuffers DEFAULT_MSG FLATBUFFERS_INCLUDE_DIR FLATBUFFERS_LIBRARY) 7 | -------------------------------------------------------------------------------- /src/cmake/FindTox.cmake: -------------------------------------------------------------------------------- 1 | find_path(TOX_INCLUDE_DIR tox/tox.h) 2 | find_path(TOXAV_INCLUDE_DIR tox/toxav.h) 3 | 4 | find_library(TOX_LIBRARY toxcore) 5 | find_library(TOXAV_LIBRARY toxav) 6 | 7 | include(FindPackageHandleStandardArgs) 8 | find_package_handle_standard_args(Tox DEFAULT_MSG TOX_INCLUDE_DIR TOXAV_INCLUDE_DIR TOX_LIBRARY TOXAV_LIBRARY) 9 | -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef GTOX_CONFIG_H 20 | #define GTOX_CONFIG_H 21 | #include 22 | #include "utils/debug.h" 23 | 24 | class config_global: public Glib::Object, public utils::debug::track_obj { 25 | friend class config; 26 | public: 27 | Glib::PropertyProxy property_theme_color(); 28 | 29 | Glib::PropertyProxy property_profile_remember(); 30 | 31 | Glib::PropertyProxy property_video_default_device(); 32 | 33 | private: 34 | config_global(); 35 | 36 | void load_flatbuffer(); 37 | void save_flatbuffer(); 38 | 39 | std::string m_config_file; 40 | 41 | Glib::Property m_property_theme_color; 42 | 43 | Glib::Property m_property_profile_remember; 44 | 45 | Glib::Property m_property_video_default_device; 46 | }; 47 | 48 | class config: public Glib::Object { 49 | public: 50 | Glib::PropertyProxy property_systemtray_visible(); 51 | Glib::PropertyProxy property_systemtray_on_start(); 52 | Glib::PropertyProxy property_systemtray_on_close(); 53 | 54 | Glib::PropertyProxy property_chat_notification_on_message(); 55 | Glib::PropertyProxy property_chat_notification_with_audio(); 56 | Glib::PropertyProxy property_chat_auto_away(); 57 | Glib::PropertyProxy property_chat_send_typing(); 58 | Glib::PropertyProxy property_chat_logging(); 59 | 60 | Glib::PropertyProxy property_file_auto_accept(); 61 | Glib::PropertyProxy property_file_display_inline(); 62 | 63 | Glib::PropertyProxy property_contacts_compact_list(); 64 | Glib::PropertyProxy property_contacts_display_active(); 65 | 66 | Glib::PropertyProxy property_window_x(); 67 | Glib::PropertyProxy property_window_y(); 68 | Glib::PropertyProxy property_window_w(); 69 | Glib::PropertyProxy property_window_h(); 70 | 71 | config(Glib::ustring config_file); 72 | 73 | static config_global& global(); 74 | 75 | private: 76 | void load_flatbuffer(); 77 | void save_flatbuffer(); 78 | 79 | std::string m_config_file; 80 | 81 | Glib::Property m_property_systemtray_visible; 82 | Glib::Property m_property_systemtray_on_start; 83 | Glib::Property m_property_systemtray_on_close; 84 | 85 | Glib::Property m_property_chat_notification_on_message; 86 | Glib::Property m_property_chat_notification_with_audio; 87 | Glib::Property m_property_chat_auto_away; 88 | Glib::Property m_property_chat_send_typing; 89 | Glib::Property m_property_chat_logging; 90 | 91 | Glib::Property m_property_file_auto_accept; 92 | Glib::Property m_property_file_display_inline; 93 | 94 | Glib::Property m_property_contacts_compact_list; 95 | Glib::Property m_property_contacts_display_active; 96 | 97 | Glib::Property m_property_window_x; 98 | Glib::Property m_property_window_y; 99 | Glib::Property m_property_window_w; 100 | Glib::Property m_property_window_h; 101 | }; 102 | 103 | #endif 104 | -------------------------------------------------------------------------------- /src/dialog/detachable_window.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef DIALOGDETACHABLEWINDOW_H 20 | #define DIALOGDETACHABLEWINDOW_H 21 | 22 | #include 23 | #include "utils/debug.h" 24 | #include "utils/builder.h" 25 | 26 | namespace dialog { 27 | 28 | class main; 29 | 30 | class detachable_window 31 | : public Gtk::Window, 32 | public utils::debug::track_obj { 33 | public: 34 | //props 35 | auto property_has_focus() -> Glib::PropertyProxy; 36 | auto property_is_attached() -> Glib::PropertyProxy; 37 | auto property_headerbar_title() -> Glib::PropertyProxy; 38 | auto property_headerbar_subtitle() -> Glib::PropertyProxy; 39 | auto property_body() -> Glib::PropertyProxy; 40 | auto property_headerbar() -> Glib::PropertyProxy_ReadOnly; 41 | 42 | using type_slot_detachable_add = sigc::slot; 43 | using type_slot_detachable_del = sigc::slot; 44 | using type_signal_close = sigc::signal; 45 | 46 | type_signal_close signal_close(); 47 | 48 | detachable_window(type_slot_detachable_add main_add, 49 | type_slot_detachable_del main_del); 50 | virtual ~detachable_window(); 51 | 52 | void present(); 53 | 54 | private: 55 | type_slot_detachable_add m_attach; 56 | 57 | Gtk::HeaderBar* m_headerbar_attached; 58 | Gtk::HeaderBar* m_headerbar_detached; 59 | Gtk::Button* m_btn_attach; 60 | Gtk::Button* m_btn_detach; 61 | Gtk::Button* m_btn_close_attached; 62 | Gtk::Button* m_btn_close_detached; 63 | 64 | std::vector> m_bindings; 65 | 66 | Glib::Property m_prop_has_focus; 67 | Glib::Property m_prop_is_attached; 68 | Glib::Property m_prop_headerbar_title; 69 | Glib::Property m_prop_headerbar_subtitle; 70 | Glib::Property m_prop_body; 71 | Glib::Property m_prop_headerbar; 72 | 73 | type_signal_close m_signal_close; 74 | 75 | sigc::connection m_con_map; 76 | sigc::connection m_con_unmap; 77 | sigc::connection m_con_active; 78 | }; 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /src/dialog/error.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #include "error.h" 21 | #include 22 | #include 23 | 24 | using namespace dialog; 25 | 26 | error::error(Gtk::Window& parent,bool fatal, std::string title, std::string message): 27 | MessageDialog(parent, title, false, fatal?Gtk::MESSAGE_ERROR:Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true) { 28 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { fatal, title, message }); 29 | set_secondary_text(((fatal)?_("gTox can't continue.\n" 30 | "The following problem occurred:\n" 31 | "\n" 32 | ""):"") 33 | + Glib::Markup::escape_text(message) 34 | + ((fatal)?(Glib::Markup::escape_text("\n\n") 35 | + _("\n" 36 | "\n" 37 | "Please make sure that you are using the newest gTox version.\n" 38 | "If you do use the newest, please report the error to us.")):""), true); 39 | 40 | if (fatal) { 41 | add_button(_("Report"), 213); 42 | } 43 | } 44 | 45 | error::error(bool fatal,std::string title, std::string message): 46 | MessageDialog(title, false, fatal?Gtk::MESSAGE_ERROR:Gtk::MESSAGE_WARNING, Gtk::BUTTONS_CLOSE, true) { 47 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { fatal, title, message }); 48 | set_secondary_text(((fatal)?_("gTox can't continue.\n" 49 | "The following problem occurred:\n" 50 | "\n" 51 | ""):"") 52 | + Glib::Markup::escape_text(message) 53 | + ((fatal)?(Glib::Markup::escape_text("\n\n") 54 | + _("\n" 55 | "\n" 56 | "Please make sure that you are using the newest gTox version.\n" 57 | "If you do use the newest, please report the error to us.")):""), true); 58 | 59 | if (fatal) { 60 | add_button(_("Report"), 213); 61 | } 62 | } 63 | 64 | error::~error() { 65 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 66 | } 67 | 68 | int error::run() { 69 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 70 | switch(MessageDialog::run()) { 71 | case 213: 72 | if (!Gio::AppInfo::launch_default_for_uri("https://github.com/KoKuToru/gTox/issues/new")) { 73 | //TODO ! 74 | } 75 | //continue to run: 76 | run(); 77 | break; 78 | } 79 | 80 | return 0; 81 | } 82 | -------------------------------------------------------------------------------- /src/dialog/error.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef DIALOGERROR_H 21 | #define DIALOGERROR_H 22 | 23 | #include 24 | #include "utils/debug.h" 25 | 26 | namespace dialog { 27 | class error : public Gtk::MessageDialog, public utils::debug::track_obj { 28 | public: 29 | error(Gtk::Window& parent, bool fatal, std::string title, std::string message); 30 | error(bool fatal, std::string title, std::string message); 31 | virtual ~error(); 32 | 33 | int run(); 34 | }; 35 | } 36 | #endif 37 | -------------------------------------------------------------------------------- /src/dialog/main.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2014 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef DIALOGCONTACT_H 21 | #define DIALOGCONTACT_H 22 | 23 | #include 24 | #include "utils/builder.h" 25 | #include "utils/storage.h" 26 | #include "tox/types.h" 27 | #include "widget/main_menu.h" 28 | #include "config.h" 29 | #include "storage.h" 30 | #include "utils/debug.h" 31 | #include "detachable_window.h" 32 | 33 | namespace dialog { 34 | // contact list with pinned chat 35 | class main : public Gtk::Window, public utils::debug::track_obj
{ 36 | private: 37 | std::shared_ptr m_toxcore; 38 | 39 | //Glib::RefPtr m_status_icon; 40 | 41 | Gtk::HeaderBar* m_headerbar; 42 | Gtk::MenuButton* m_btn_status; 43 | Gtk::Stack* m_stack_header; 44 | Gtk::Stack* m_stack; 45 | Gtk::ListBox* m_list_contact; 46 | Gtk::ListBox* m_list_contact_active; 47 | Gtk::ListBox* m_list_notify; 48 | Gtk::ScrolledWindow* m_list_contact_scroll; 49 | Gtk::Revealer* m_request_revealer; 50 | Gtk::Button* m_request_btn; 51 | 52 | Gtk::Image* m_status_icon; 53 | 54 | sigc::connection m_store_pos_size; 55 | 56 | std::string m_config_path; 57 | 58 | Glib::RefPtr m_binding_title; 59 | Glib::RefPtr m_binding_subtitle; 60 | Glib::RefPtr m_binding_position; 61 | Glib::RefPtr m_binding_contact_active; 62 | 63 | Gtk::Menu m_popup_menu; 64 | 65 | std::shared_ptr m_menu; 66 | 67 | Glib::RefPtr m_action; 68 | 69 | std::vector> m_stack_data; 70 | 71 | std::shared_ptr m_config; 72 | 73 | std::vector> m_requests; 74 | 75 | public: 76 | main(BaseObjectType* cobject, 77 | utils::builder builder, 78 | const Glib::ustring& file); 79 | ~main(); 80 | 81 | std::shared_ptr& tox(); 82 | 83 | static utils::builder::ref
create(const Glib::ustring& file); 84 | 85 | void detachable_window_add(dialog::detachable_window* window); 86 | void detachable_window_del(dialog::detachable_window* window); 87 | 88 | void exit(); 89 | 90 | std::shared_ptr& config(); 91 | 92 | protected: 93 | void load_contacts(); 94 | 95 | std::shared_ptr m_storage; 96 | }; 97 | } 98 | #endif 99 | -------------------------------------------------------------------------------- /src/dialog/profile_create.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2014 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #include "profile_create.h" 21 | #include "tox/types.h" 22 | #include "tox/core.h" 23 | #include 24 | 25 | using namespace dialog; 26 | 27 | profile_create::profile_create(BaseObjectType* cobject, 28 | utils::builder builder, 29 | const Glib::ustring& path): 30 | Gtk::Assistant(cobject), 31 | m_aborted(true), 32 | m_path(path) { 33 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { path.raw() }); 34 | 35 | property_resizable() = false; 36 | set_size_request(800, 600); 37 | set_position(Gtk::WindowPosition::WIN_POS_CENTER_ALWAYS); 38 | 39 | builder.get_widget("assistant_username", m_username); 40 | builder.get_widget("assistant_statusmessage", m_status); 41 | builder.get_widget("assistant_file_tox", m_file_tox); 42 | 43 | auto w = builder.get_widget("assistant_first_page"); 44 | m_username->signal_changed().connect([this, w]() { 45 | utils::debug::scope_log log(DBG_LVL_2("gtox"), {}); 46 | toxmm::contactAddrPublic addr; 47 | m_last_toxcore = toxmm::core::create_state(m_username->get_text(), m_status->get_text(), addr); 48 | 49 | if (!m_username->get_text().empty()) { 50 | int i = 0; 51 | do { 52 | auto name = m_username->get_text() + (i?("_"+std::to_string(i)):""); 53 | m_file_tox->set_text(Glib::build_filename(m_path, name + ".tox")); 54 | i += 1; 55 | } while (Glib::file_test(m_file_tox->get_text(), Glib::FILE_TEST_IS_REGULAR)); 56 | 57 | if (w) { 58 | set_page_complete(*w, true); 59 | } 60 | } else { 61 | m_file_tox->set_text(""); 62 | if (w) { 63 | set_page_complete(*w, false); 64 | } 65 | } 66 | }); 67 | 68 | m_status->signal_changed().connect([this, w]() { 69 | utils::debug::scope_log log(DBG_LVL_2("gtox"), {}); 70 | toxmm::contactAddrPublic addr; 71 | m_last_toxcore = toxmm::core::create_state(m_username->get_text(), m_status->get_text(), addr); 72 | }); 73 | } 74 | 75 | utils::builder::ref profile_create::create(const Glib::ustring& path) { 76 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { path.raw() }); 77 | return utils::builder::create_ref( 78 | "/org/gtox/ui/dialog_assistant.ui", 79 | "dialog_assistant", 80 | path); 81 | } 82 | 83 | profile_create::~profile_create() { 84 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 85 | } 86 | 87 | void profile_create::on_cancel() { 88 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 89 | m_path.clear(); 90 | hide(); 91 | } 92 | 93 | void profile_create::on_apply() { 94 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 95 | auto stream = Gio::File::create_for_path(m_file_tox->get_text())->create_file(); 96 | auto bytes = Glib::Bytes::create((void*)m_last_toxcore.data(), m_last_toxcore.size()); 97 | stream->write_bytes(bytes); 98 | stream->close(); 99 | m_aborted = false; 100 | m_path = m_file_tox->get_text(); 101 | m_path.clear(); 102 | hide(); 103 | } 104 | 105 | void profile_create::on_close() { 106 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 107 | } 108 | 109 | bool profile_create::is_aborted() { 110 | utils::debug::scope_log log(DBG_LVL_5("gtox"), {}); 111 | return m_aborted; 112 | } 113 | 114 | Glib::ustring profile_create::get_path() { 115 | utils::debug::scope_log log(DBG_LVL_5("gtox"), {}); 116 | return m_path; 117 | } 118 | -------------------------------------------------------------------------------- /src/dialog/profile_create.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2014 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | 21 | #ifndef FIRSTSTARTASSISTANT_H 22 | #define FIRSTSTARTASSISTANT_H 23 | 24 | #include 25 | #include "utils/builder.h" 26 | #include "utils/debug.h" 27 | 28 | namespace dialog { 29 | class profile_create : public Gtk::Assistant, public utils::debug::track_obj { 30 | private: 31 | bool m_aborted; 32 | Glib::ustring m_path; 33 | 34 | std::vector m_last_toxcore; 35 | 36 | Gtk::Entry *m_username = nullptr; 37 | Gtk::Entry *m_status = nullptr; 38 | Gtk::Entry *m_file_tox = nullptr; 39 | 40 | void on_cancel(); 41 | void on_close(); 42 | void on_apply(); 43 | 44 | public: 45 | ~profile_create(); 46 | 47 | profile_create(BaseObjectType* cobject, utils::builder builder, 48 | const Glib::ustring& path); 49 | 50 | static utils::builder::ref create(const Glib::ustring& path); 51 | 52 | bool is_aborted(); 53 | Glib::ustring get_path(); 54 | }; 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/dialog/profile_selection.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef DIALOGPROFILE_H 21 | #define DIALOGPROFILE_H 22 | 23 | #include 24 | #include "utils/builder.h" 25 | #include "utils/dispatcher.h" 26 | #include "utils/debug.h" 27 | 28 | namespace dialog { 29 | class profile_selection : public Gtk::Window, public utils::debug::track_obj { 30 | private: 31 | std::vector m_accounts; 32 | bool m_abort; 33 | bool m_quited; 34 | std::string m_selected_path; 35 | 36 | Gtk::ListBox* m_profile_list; 37 | Gtk::Revealer* m_revealer; 38 | 39 | Gtk::Menu m_popup_menu; 40 | 41 | void quit(); 42 | 43 | void set_accounts(const std::vector& accounts); 44 | 45 | public: 46 | profile_selection(BaseObjectType* cobject, utils::builder builder, 47 | const std::vector& accounts); 48 | 49 | static utils::builder::ref create(const std::vector& accounts); 50 | 51 | virtual ~profile_selection(); 52 | 53 | bool is_aborted(); 54 | std::string get_path(); 55 | }; 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/dialog/settings.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2014 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef DIALOGSETTINGS_H 21 | #define DIALOGSETTINGS_H 22 | 23 | #include "utils/builder.h" 24 | #include "config.h" 25 | #include "utils/debug.h" 26 | #include "detachable_window.h" 27 | #include "widget/imagescaled.h" 28 | #include "utils/webcam.h" 29 | 30 | namespace dialog { 31 | class main; 32 | class settings : public detachable_window, public utils::debug::track_obj { 33 | private: 34 | main& m_main; 35 | 36 | Gtk::Widget* m_body; 37 | 38 | Gtk::Switch* m_tray_visible; 39 | Gtk::Switch* m_tray_on_start; 40 | Gtk::Switch* m_tray_on_close; 41 | 42 | Gtk::Switch* m_c_n_on_message; 43 | Gtk::Switch* m_c_n_with_audio; 44 | Gtk::ComboBox* m_c_auto_away; 45 | Gtk::Switch* m_c_send_typing; 46 | Gtk::Switch* m_c_logging; 47 | 48 | Gtk::FileChooserButton* m_ft_save_to; 49 | Gtk::Switch* m_ft_auto_accept; 50 | Gtk::Switch* m_ft_display_inline; 51 | 52 | Gtk::Switch* m_cl_use_compact; 53 | Gtk::Switch* m_cl_display_active; 54 | 55 | Gtk::Switch* m_connection_udp; 56 | Gtk::ComboBox* m_proxy_type; 57 | Gtk::Entry* m_proxy_host; 58 | Gtk::Entry* m_proxy_port; 59 | 60 | Gtk::ComboBox* m_t_color; 61 | 62 | Gtk::Switch* m_p_remember; 63 | 64 | Gtk::ComboBox* m_video_device; 65 | widget::imagescaled* m_video_preview; 66 | Gtk::Label* m_video_error; 67 | 68 | std::vector> m_bindings; 69 | 70 | utils::webcam m_webcam; 71 | 72 | public: 73 | settings(main& main); 74 | virtual ~settings(); 75 | 76 | void activated(); 77 | }; 78 | } 79 | #endif 80 | -------------------------------------------------------------------------------- /src/gtox.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=0.01 3 | Type=Application 4 | Name=gTox 5 | Comment=a GTK-based tox-client 6 | TryExec=gtox 7 | Exec=gtox %u 8 | Icon=gtox 9 | Categories=InstantMessaging;AudioVideo;Network; 10 | Terminal=false 11 | Encoding=UTF-8 12 | MimeType=application/x-extension-tox;application/x-extension-gtox;x-scheme-handler/tox; 13 | -------------------------------------------------------------------------------- /src/gtox.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2015 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef GTOX_APPLICATION 21 | #define GTOX_APPLICATION 22 | #include 23 | #include "utils/debug.h" 24 | 25 | class gTox : public Gtk::Application, public utils::debug::track_obj { 26 | public: 27 | gTox(bool non_unique); 28 | static Glib::RefPtr create(bool non_unique); 29 | static Glib::RefPtr instance(); 30 | 31 | const std::string m_config_path; 32 | const std::string m_avatar_path; 33 | const std::string m_config_global_path; 34 | 35 | Glib::RefPtr m_theme_binding; 36 | 37 | protected: 38 | void on_activate() override; 39 | void on_open(const Gio::Application::type_vec_files& files, 40 | const Glib::ustring& hint) override; 41 | int on_command_line(const Glib::RefPtr& command_line) override; 42 | 43 | private: 44 | static Glib::RefPtr m_instance; 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /src/i18n/.gitignore: -------------------------------------------------------------------------------- 1 | template.pot 2 | layout.pot 3 | source.pot 4 | -------------------------------------------------------------------------------- /src/i18n/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #Find necessary programs: msgcat and msgfmt 2 | find_program(GETTEXT_MSGCAT_EXECUTABLE msgcat) 3 | if(NOT GETTEXT_MSGCAT_EXECUTABLE) 4 | message(FATAL_ERROR "msgcat not found") 5 | endif() 6 | 7 | find_program(GETTEXT_MSGFMT_EXECUTABLE msgfmt) 8 | if(NOT GETTEXT_MSGFMT_EXECUTABLE) 9 | message(FATAL_ERROR "msgfmt not found") 10 | endif() 11 | 12 | 13 | set(TRANSLATIONS 14 | de 15 | en 16 | es 17 | fr 18 | it 19 | ru 20 | ) 21 | 22 | 23 | foreach(trans ${TRANSLATIONS}) 24 | add_custom_command( 25 | COMMENT "Generate Locale '${trans}'" 26 | OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${trans}/LC_MESSAGES/gtox.mo 27 | POST_BUILD 28 | COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/${trans}/LC_MESSAGES/ 29 | 30 | # Create binary file with translations 31 | COMMAND ${GETTEXT_MSGFMT_EXECUTABLE} 32 | ${CMAKE_CURRENT_SOURCE_DIR}/${trans}.po 33 | -o ${CMAKE_CURRENT_BINARY_DIR}/${trans}/LC_MESSAGES/gtox.mo 34 | 35 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${trans}.po 36 | ) 37 | 38 | set(mo_files 39 | ${mo_files} ${CMAKE_CURRENT_BINARY_DIR}/${trans}/LC_MESSAGES/gtox.mo 40 | ) 41 | 42 | install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${trans}" 43 | DESTINATION share/locale 44 | FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) 45 | endforeach() 46 | 47 | # Create a target that's accessible form parent directory 48 | add_custom_target(gtox-locale DEPENDS ${mo_files}) 49 | -------------------------------------------------------------------------------- /src/i18n/stats.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | echo "translation | untranslated" 3 | echo ":-----------|------------:" 4 | for f in *.po; do 5 | if [ "$f" != "en.po" ]; then 6 | untranslated=`msgcat template.pot $f -o - | msgfmt --statistic - 2>&1 | tr -dc '0-9 ' | awk -v N=2 '{print $N}'` 7 | printf "%-12s|%13s\n" $f $untranslated 8 | fi 9 | done 10 | -------------------------------------------------------------------------------- /src/i18n/update.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | for f in *.po; do 3 | msgcat --use-first $f template.pot -o $f 4 | msgattrib --set-obsolete --ignore-file=template.pot -o $f $f 5 | msgattrib --no-obsolete -o $f $f 6 | done 7 | -------------------------------------------------------------------------------- /src/resources/flatbuffers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(NAME "gtox-flatbuffers.gresource") 4 | set(CNAME "gtox_flatbuffers") 5 | set(PREFIX "/org/gtox/flatbuffers") 6 | set(OPTIONS "compressed=\\\"true\\\"") 7 | 8 | set(SRC 9 | Config.fbs 10 | ConfigGlobal.fbs 11 | Log.fbs 12 | ) 13 | 14 | ADD_CUSTOM_TARGET(gtox-flatbuffers-resource ALL 15 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c") 16 | 17 | find_program(GLIB_COMPILE_RESOURCE_EXECUTEABLE glib-compile-resources) 18 | if(NOT GLIB_COMPILE_RESOURCE_EXECUTEABLE) 19 | message(FATAL_ERROR "glib-compile-resources not found") 20 | endif() 21 | 22 | find_program(BASH_EXECUTEABLE bash) 23 | if(NOT BASH_EXECUTEABLE) 24 | message(FATAL_ERROR "bash not found") 25 | endif() 26 | 27 | find_program(FLAT_C_EXECUTABLE flatc) 28 | if(NOT FLAT_C_EXECUTABLE) 29 | message(FATAL_ERROR "flatc not found") 30 | endif() 31 | 32 | foreach(_item ${SRC}) 33 | GET_FILENAME_COMPONENT(_item_we "${_item}" NAME_WE) 34 | set(BFBS ${BFBS} "${CMAKE_CURRENT_SOURCE_DIR}/generated/${_item_we}.bfbs") 35 | set(BFBS_NAMES ${BFBS_NAMES} "${_item_we}.bfbs") 36 | add_custom_command( 37 | OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/generated/${_item_we}_generated.h" "${CMAKE_CURRENT_SOURCE_DIR}/generated/${_item_we}.bfbs" 38 | POST_BUILD 39 | COMMAND "${FLAT_C_EXECUTABLE}" -c --scoped-enums --gen-mutable -o ./generated --strict-json "${_item}" 40 | COMMAND "${FLAT_C_EXECUTABLE}" -b --schema -o ./generated "${_item}" 41 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 42 | DEPENDS ${_item} 43 | ) 44 | SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_SOURCE_DIR}/generated/${_item_we}_generated.h" PROPERTIES GENERATED 1) 45 | ADD_CUSTOM_TARGET("gtox-flatbuffers-${_item_we}" ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generated/${_item_we}_generated.h") 46 | add_dependencies(gtox-flatbuffers-resource "gtox-flatbuffers-${_item_we}") 47 | endforeach() 48 | 49 | add_custom_command( 50 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h" 51 | COMMAND "${BASH_EXECUTEABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../gresource.sh" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml" "${PREFIX}" "${OPTIONS}" ${BFBS_NAMES} 52 | COMMAND "${GLIB_COMPILE_RESOURCE_EXECUTEABLE}" --target="${NAME}.c" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}/generated" --generate-source --c-name "${CNAME}" "${NAME}.xml" 53 | COMMAND "${GLIB_COMPILE_RESOURCE_EXECUTEABLE}" --target="${NAME}.h" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}/generated" --generate-header --c-name "${CNAME}" "${NAME}.xml" 54 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 55 | DEPENDS ${BFBS} 56 | ) 57 | 58 | set (GRESOURCE ${GRESOURCE} "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c" PARENT_SCOPE) 59 | SET_SOURCE_FILES_PROPERTIES(${GRESOURCE} PROPERTIES GENERATED 1) 60 | -------------------------------------------------------------------------------- /src/resources/flatbuffers/Config.fbs: -------------------------------------------------------------------------------- 1 | namespace flatbuffers.Config; 2 | 3 | //never reorder these properties ! 4 | 5 | table Config { 6 | systemtray_visible: bool = true; 7 | systemtray_on_start: bool = false; 8 | systemtray_on_close: bool = true; 9 | 10 | chat_notification_on_message: bool = true; 11 | chat_notification_with_audio: bool = true; 12 | chat_auto_away: int = 0; 13 | chat_send_typing: bool = true; 14 | chat_logging: bool = true; 15 | 16 | file_save_path: string (deprecated); 17 | file_auto_accept: bool = true; 18 | file_display_inline: bool = true; 19 | 20 | contacts_compact_list: bool = true; 21 | contacts_display_active: bool = false; 22 | 23 | window_x: int = -1; 24 | window_y: int = -1; 25 | window_w: int = -1; 26 | window_h: int = -1; 27 | } 28 | 29 | root_type Config; 30 | -------------------------------------------------------------------------------- /src/resources/flatbuffers/ConfigGlobal.fbs: -------------------------------------------------------------------------------- 1 | namespace flatbuffers.Config; 2 | 3 | //never reorder these properties ! 4 | 5 | table Global { 6 | connection_udp: bool (deprecated); 7 | connection_tcp: bool (deprecated); 8 | 9 | proxy_type: int (deprecated); 10 | proxy_host: string (deprecated); 11 | proxy_port: int (deprecated); 12 | 13 | theme_color: int; 14 | 15 | profile_remember: bool; 16 | 17 | av_video_default: string; 18 | } 19 | 20 | root_type Global; 21 | -------------------------------------------------------------------------------- /src/resources/flatbuffers/Log.fbs: -------------------------------------------------------------------------------- 1 | namespace flatbuffers.Log; 2 | 3 | union Data { 4 | Message, 5 | Action, 6 | File 7 | } 8 | 9 | enum MessageStatus: short { 10 | PENDING, 11 | DONE 12 | } 13 | 14 | table Message { 15 | message:string; 16 | status:MessageStatus; 17 | } 18 | 19 | table Action { 20 | action:string; 21 | status:MessageStatus; 22 | } 23 | 24 | enum FileStatus:short { 25 | PENDING, 26 | DONE, 27 | ABORTED 28 | } 29 | 30 | table File { 31 | uuid:string; 32 | name:string; 33 | path:string; 34 | status:FileStatus; 35 | receiver:string; 36 | } 37 | 38 | table Item { 39 | sender:string; 40 | timestamp:ulong; 41 | data:Data; 42 | } 43 | 44 | table Collection { 45 | items:[Item]; 46 | } 47 | 48 | root_type Collection; 49 | -------------------------------------------------------------------------------- /src/resources/flatbuffers/generated/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | 6 | -------------------------------------------------------------------------------- /src/resources/gresource.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/bash 2 | echo "" > $1 3 | echo "" >> $1 4 | echo "" >> $1 5 | for var in ${1:+"${@:4}"} 6 | do 7 | echo "$var" >> $1 8 | done 9 | echo "" >> $1 10 | echo "" >> $1 11 | -------------------------------------------------------------------------------- /src/resources/icon/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(NAME "gtox-icon.gresource") 4 | set(CNAME "gtox_icon") 5 | set(PREFIX "/org/gtox/icon") 6 | set(OPTIONS "compressed=\\\"true\\\"") 7 | 8 | set(SRC 9 | chat-attach-symbolic.svg 10 | chat-detach-symbolic.svg 11 | icon_128.svg 12 | settings-symbolic.svg 13 | status_online.svg 14 | status_offline.svg 15 | status_busy.svg 16 | status_message.svg 17 | status_away.svg 18 | status_online_tcp.svg 19 | status_busy_tcp.svg 20 | status_away_tcp.svg 21 | avatar.svg 22 | plus-symbolic.svg 23 | remove-symbolic.svg 24 | clipboard-symbolic.svg 25 | notification.svg) 26 | 27 | find_program(GLIB_COMPILE_RESOURCE_EXECUTEABLE glib-compile-resources) 28 | if(NOT GLIB_COMPILE_RESOURCE_EXECUTEABLE) 29 | message(FATAL_ERROR "glib-compile-resources not found") 30 | endif() 31 | 32 | find_program(BASH_EXECUTEABLE bash) 33 | if(NOT BASH_EXECUTEABLE) 34 | message(FATAL_ERROR "bash not found") 35 | endif() 36 | 37 | #ADD ICONS TO RESOURCE 38 | add_custom_command( 39 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h" 40 | COMMAND "${BASH_EXECUTEABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../gresource.sh" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml" "${PREFIX}" "${OPTIONS}" ${SRC} 41 | COMMAND "${GLIB_COMPILE_RESOURCE_EXECUTEABLE}" --target="${NAME}.c" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}" --generate-source --c-name "${CNAME}" "${NAME}.xml" 42 | COMMAND "${GLIB_COMPILE_RESOURCE_EXECUTEABLE}" --target="${NAME}.h" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}" --generate-header --c-name "${CNAME}" "${NAME}.xml" 43 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 44 | DEPENDS ${SRC} 45 | ) 46 | 47 | set (GRESOURCE ${GRESOURCE} "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c" PARENT_SCOPE) 48 | 49 | ADD_CUSTOM_TARGET(gtox-icon-resource ALL 50 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c") 51 | 52 | find_program(RSVG_CONVERT_EXECUTEABLE rsvg-convert) 53 | if(NOT RSVG_CONVERT_EXECUTEABLE) 54 | message(FATAL_ERROR "rsvg-convert not found") 55 | endif() 56 | 57 | #Application icon 58 | SET(SIZES 59 | 14 60 | 16 61 | 22 62 | 24 63 | 32 64 | 36 65 | 48 66 | 64 67 | 72 68 | 96 69 | 128 70 | 192 71 | 256 72 | 512 73 | ) 74 | foreach(size ${SIZES}) 75 | set(icon_path 76 | "${CMAKE_CURRENT_BINARY_DIR}/hicolor/${size}x${size}/apps" 77 | ) 78 | 79 | #convert svg to png with rsvg 80 | add_custom_command( 81 | COMMENT "Generate Icon '${size}x${size}'" 82 | OUTPUT "${icon_path}/gtox.png" 83 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 84 | POST_BUILD 85 | 86 | #make sure folder exists 87 | COMMAND mkdir -p "${icon_path}" 88 | 89 | # convert 90 | COMMAND ${RSVG_CONVERT_EXECUTEABLE} "icon.svg" -w ${size} -h ${size} -f png -o "${icon_path}/gtox.png" 91 | 92 | DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/icon.svg" 93 | ) 94 | 95 | set(icons 96 | ${icons} "${icon_path}/gtox.png" 97 | ) 98 | endforeach() 99 | 100 | add_custom_command( 101 | COMMENT "Generate Icon 'scalable'" 102 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/hicolor/scalable/apps/gtox.svg" 103 | COMMAND mkdir -p "${CMAKE_CURRENT_BINARY_DIR}/hicolor/scalable/apps" 104 | COMMAND cp "${CMAKE_CURRENT_SOURCE_DIR}/icon.svg" "${CMAKE_CURRENT_BINARY_DIR}/hicolor/scalable/apps/gtox.svg" 105 | POST_BUILD 106 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" 107 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/icon.svg) 108 | 109 | add_custom_target(gtox-icon DEPENDS ${icons} ${CMAKE_CURRENT_BINARY_DIR}/hicolor/scalable/apps/gtox.svg) 110 | 111 | install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/hicolor" 112 | DESTINATION share/icons 113 | FILE_PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) 114 | 115 | -------------------------------------------------------------------------------- /src/resources/icon/clipboard-symbolic.svg: -------------------------------------------------------------------------------- 1 | 2 | 17 | 19 | 20 | 22 | image/svg+xml 23 | 25 | 26 | 27 | 28 | 29 | 31 | 52 | 57 | 58 | -------------------------------------------------------------------------------- /src/resources/icon/notification.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 55 | 60 | 61 | -------------------------------------------------------------------------------- /src/resources/icon/status_away.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 55 | 60 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/resources/icon/status_away_tcp.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 23 | 28 | 29 | 30 | 51 | 53 | 54 | 56 | image/svg+xml 57 | 59 | 60 | 61 | 62 | 63 | 68 | 74 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /src/resources/icon/status_busy.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 55 | 60 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/resources/icon/status_busy_tcp.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 23 | 28 | 29 | 30 | 49 | 51 | 52 | 54 | image/svg+xml 55 | 57 | 58 | 59 | 60 | 61 | 66 | 72 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/resources/icon/status_message.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 51 | 53 | 54 | 56 | image/svg+xml 57 | 59 | 60 | 61 | 62 | 63 | 66 | 72 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/resources/icon/status_offline.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 55 | 60 | 61 | 62 | -------------------------------------------------------------------------------- /src/resources/icon/status_offline_tcp.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 23 | 28 | 29 | 30 | 48 | 50 | 51 | 53 | image/svg+xml 54 | 56 | 57 | 58 | 59 | 60 | 65 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /src/resources/icon/status_online.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 38 | 40 | 41 | 43 | image/svg+xml 44 | 46 | 47 | 48 | 49 | 50 | 55 | 60 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/resources/icon/status_online_tcp.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 20 | 23 | 28 | 29 | 30 | 48 | 50 | 51 | 53 | image/svg+xml 54 | 56 | 57 | 58 | 59 | 60 | 65 | 71 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /src/resources/style/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(NAME "gtox-style.gresource") 4 | set(CNAME "gtox_style") 5 | set(PREFIX "/org/gtox/style") 6 | set(OPTIONS "compressed=\\\"true\\\"") 7 | 8 | set(SRC 9 | common.css 10 | dark.css 11 | light.css) 12 | 13 | find_program(GLIB_COMPILE_RESOURCE_EXECUTEABLE glib-compile-resources) 14 | if(NOT GLIB_COMPILE_RESOURCE_EXECUTEABLE) 15 | message(FATAL_ERROR "glib-compile-resources not found") 16 | endif() 17 | 18 | find_program(BASH_EXECUTEABLE bash) 19 | if(NOT BASH_EXECUTEABLE) 20 | message(FATAL_ERROR "bash not found") 21 | endif() 22 | 23 | add_custom_command( 24 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h" 25 | COMMAND "${BASH_EXECUTEABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../gresource.sh" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml" "${PREFIX}" "${OPTIONS}" ${SRC} 26 | COMMAND "${GLIB_COMPILE_RESOURCE_EXECUTEABLE}" --target="${NAME}.c" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}" --generate-source --c-name "${CNAME}" "${NAME}.xml" 27 | COMMAND "${GLIB_COMPILE_RESOURCE_EXECUTEABLE}" --target="${NAME}.h" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}" --generate-header --c-name "${CNAME}" "${NAME}.xml" 28 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 29 | DEPENDS ${SRC} 30 | ) 31 | 32 | set (GRESOURCE ${GRESOURCE} "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c" PARENT_SCOPE) 33 | 34 | #following is not working ? 35 | ADD_CUSTOM_TARGET(gtox-style-resource ALL 36 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c") 37 | 38 | -------------------------------------------------------------------------------- /src/resources/style/common.css: -------------------------------------------------------------------------------- 1 | /** 2 | Profile selection 3 | **/ 4 | 5 | .gtox-profile-frame, .gtox-contact-frame, .gtox-notification { 6 | padding: 5px; 7 | padding-left: 9px; 8 | padding-right: 5px; 9 | 10 | } 11 | 12 | .gtox-profile-avatar, .gtox-contact-avatar, .gtox-notification-image { 13 | padding: 5px 14 | } 15 | 16 | .gtox-profile-name, .gtox-contact-name, .gtox-notification-title { 17 | font-size: 120%; 18 | padding: 0 5px; 19 | } 20 | 21 | .gtox-profile-status, .gtox-contact-status, .gtox-notification-status { 22 | font-size: 80%; 23 | padding: 0 5px; 24 | } 25 | 26 | .gtox-profile-path, .gtox-contact-path { 27 | font-size: 80%; 28 | padding: 0 5px; 29 | } 30 | 31 | .gtox-contact-status-icon, .gtox-notification-icon { 32 | padding-left: 2px; 33 | padding-right: 6px; 34 | } 35 | 36 | .gtox-profile-spinner-wrapper { 37 | padding: 10px; 38 | } 39 | 40 | .gtox-profile-spinner-label { 41 | padding-left: 10px; 42 | } 43 | 44 | .gtox-contact-avatar, .gtox-profile-avatar { 45 | border-radius: 5px; 46 | } 47 | 48 | /** 49 | Popovers 50 | **/ 51 | GtkPopover { 52 | padding: 0.5em; 53 | } 54 | 55 | GtkListBoxRow { 56 | padding: 0px; 57 | } 58 | 59 | /** 60 | Headerbar tweaks, correctly render radius 61 | **/ 62 | 63 | .gtox-headerbar-right { 64 | border-top-left-radius: 0; 65 | } 66 | 67 | .gtox-headerbar-left { 68 | border-top-right-radius: 0; 69 | } 70 | 71 | /** 72 | Chat bubbles 73 | **/ 74 | 75 | .gtox-chat { 76 | padding: 5px; 77 | } 78 | 79 | .gtox-bubble { 80 | border-radius: 7px; 81 | background-color: rgba(0,0,0,0.2); 82 | padding: 5px; 83 | } 84 | 85 | .gtox-left .gtox-bubble { 86 | border-top-left-radius: 0; 87 | } 88 | 89 | .gtox-right .gtox-bubble { 90 | border-bottom-right-radius: 0; 91 | } 92 | 93 | .gtox-right .gtox-avatar { 94 | border-left: none; 95 | border-radius: 0px 5px 5px 0px; 96 | background: white; 97 | } 98 | 99 | .gtox-left .gtox-avatar { 100 | border-right: none; 101 | border-radius: 5px 0px 0px 5px; 102 | background: white; 103 | } 104 | 105 | .bubble_chat_line { 106 | background: transparent; 107 | padding: 4px; 108 | border: none; 109 | } 110 | 111 | 112 | .bubble_chat_line.top_left { 113 | border-radius: 5px 0 0 0; 114 | } 115 | 116 | .bubble_chat_line.top_right { 117 | border-radius: 0 5px 0 0; 118 | } 119 | 120 | .bubble_chat_line.bottom_left { 121 | border-radius: 0 0 0 5px; 122 | } 123 | 124 | .bubble_chat_line.bottom_right { 125 | border-radius: 0 0 5px 0; 126 | } 127 | 128 | .bubble_chat_line_time, .bubble_chat_file, .bubble_chat_file_preview { 129 | border-radius: 3px; 130 | padding: 2px; 131 | } 132 | 133 | .gtox-action-username { 134 | font-weight: bolder; 135 | padding-right: 0.5em; 136 | } 137 | 138 | .gtox-opacity-0 { 139 | opacity: 0; 140 | } 141 | -------------------------------------------------------------------------------- /src/resources/style/dark.css: -------------------------------------------------------------------------------- 1 | /*@import url("resource:///org/gtk/libgtk/theme/Adwaita-dark.css");*/ 2 | @import url("resource:///org/gtox/style/common.css"); 3 | 4 | /** 5 | Profile selection 6 | **/ 7 | 8 | .gtox-profile, .gtox-contact, .gtox-notification { 9 | border-bottom: 1px solid rgba(0,0,0,0.3); 10 | } 11 | 12 | .gtox-profile-path, .gtox-contact-path { 13 | color: gray; 14 | } 15 | 16 | .gtox-contact-avatar, .gtox-profile-avatar { 17 | background: rgba(50, 50, 50, 1); 18 | } 19 | 20 | .gtox-profile:selected { 21 | background-color: rgba(255,255,255,0.2); 22 | } 23 | 24 | .gtox-contact-active { 25 | background-color: rgba(40,150,40,0.2); 26 | } 27 | 28 | .gtox-contact:selected { 29 | background-color: transparent; 30 | } 31 | 32 | .gtox-contact:prelight { 33 | background-color: rgba(255,255,255,0.2); 34 | } 35 | 36 | .gtox-notification:selected { 37 | background-color: rgba(255,255,255,0.2); 38 | } 39 | 40 | .gtox-notification-area { 41 | background-color: rgba(150,40,40,0.2); 42 | } 43 | 44 | .gtox-notification:selected { 45 | background-color: transparent; 46 | } 47 | 48 | .gtox-notification:prelight { 49 | background-color: rgba(255,255,255,0.2); 50 | } 51 | 52 | /** 53 | Item lists, like in Status selection in Popover 54 | **/ 55 | 56 | .gtox-item-list { 57 | border-bottom: 1px solid rgba(0,0,0,0.3); 58 | } 59 | 60 | .gtox-item-list:selected { 61 | background: rgba(0,0,0,0.2); 62 | } 63 | 64 | /** 65 | Chat bubbles 66 | **/ 67 | 68 | .gtox-chat { 69 | 70 | } 71 | 72 | .gtox-bubble { 73 | background-color: rgba(0,0,0,0.2); 74 | } 75 | 76 | .gtox-left .gtox-bubble { 77 | border-top-left-radius: 0; 78 | } 79 | 80 | .gtox-right .gtox-bubble { 81 | border-bottom-right-radius: 0; 82 | } 83 | 84 | .gtox-right #Avatar { 85 | background: rgba(50, 50, 50, 1); 86 | } 87 | 88 | .gtox-left #Avatar { 89 | background: rgba(50, 50, 50, 1); 90 | } 91 | 92 | .message_receipt { 93 | opacity: 1; 94 | } 95 | 96 | .message_pending { 97 | background: rgba(0,0,0,0.3); 98 | opacity: 0.3; 99 | } 100 | 101 | .message_failed { 102 | opacity: 0.3; 103 | background: rgba(255,0,0,0.3); 104 | } 105 | 106 | .bubble_chat_line { 107 | background: transparent; 108 | } 109 | 110 | .bubble_chat_line_time { 111 | background: rgba(255,255,255,0.2); 112 | color: black; 113 | } 114 | 115 | .bubble_chat_file { 116 | background: rgba(0,0,0,0.2); 117 | border: 1px solid rgba(0,0,0,0.2); 118 | color: white; 119 | } 120 | 121 | .bubble_chat_file_preview { 122 | border: 1px solid rgba(255,255,255,0.1); 123 | color: white; 124 | } 125 | -------------------------------------------------------------------------------- /src/resources/style/light.css: -------------------------------------------------------------------------------- 1 | /*@import url("resource:///org/gtk/libgtk/theme/Adwaita-dark.css");*/ 2 | @import url("resource:///org/gtox/style/common.css"); 3 | 4 | /** 5 | Profile selection 6 | **/ 7 | 8 | .gtox-profile, .gtox-contact, .gtox-notification { 9 | border-bottom: 1px solid rgba(0,0,0,0.3); 10 | } 11 | 12 | .gtox-profile-path, .gtox-contact-path { 13 | color: gray; 14 | } 15 | 16 | .gtox-contact-avatar, .gtox-profile-avatar { 17 | background: rgba(240, 240, 240, 1); 18 | } 19 | 20 | .gtox-profile:selected { 21 | background-color: rgba(0,0,0,0.2); 22 | color: black; 23 | } 24 | 25 | .gtox-contact-active { 26 | background-color: rgba(40,150,40,0.4); 27 | } 28 | 29 | .gtox-contact:selected { 30 | background-color: transparent; 31 | color: black; 32 | } 33 | 34 | .gtox-contact:prelight { 35 | background-color: rgba(0,0,0,0.2); 36 | } 37 | 38 | .gtox-notification:selected { 39 | background-color: rgba(0,0,0,0.2); 40 | } 41 | 42 | .gtox-notification-area { 43 | background-color: rgba(150,40,40,0.6); 44 | } 45 | 46 | .gtox-notification { 47 | color: white; 48 | } 49 | 50 | .gtox-notification:selected { 51 | background-color: transparent; 52 | } 53 | 54 | .gtox-notification:prelight { 55 | background-color: rgba(0,0,0,0.2); 56 | } 57 | 58 | /** 59 | Item lists, like in Status selection in Popover 60 | **/ 61 | 62 | .gtox-item-list { 63 | border-bottom: 1px solid rgba(0,0,0,0.3); 64 | } 65 | 66 | .gtox-item-list:selected { 67 | background: rgba(0,0,0,0.2); 68 | } 69 | 70 | /** 71 | Chat bubbles 72 | **/ 73 | 74 | .gtox-chat { 75 | 76 | } 77 | 78 | .gtox-bubble { 79 | background-color: rgba(0,0,0,0.2); 80 | } 81 | 82 | .gtox-left .gtox-bubble { 83 | border-top-left-radius: 0; 84 | } 85 | 86 | .gtox-right .gtox-bubble { 87 | border-bottom-right-radius: 0; 88 | } 89 | 90 | .gtox-right #Avatar { 91 | background: rgba(0, 0, 0, 0.2); 92 | } 93 | 94 | .gtox-left #Avatar { 95 | background: rgba(0, 0, 0, 0.2); 96 | } 97 | 98 | .message_receipt { 99 | opacity: 1; 100 | } 101 | 102 | .message_pending { 103 | background: rgba(240, 240, 240, 1); 104 | opacity: 0.3; 105 | } 106 | 107 | .message_failed { 108 | opacity: 0.3; 109 | background: rgba(240, 240, 240, 1); 110 | } 111 | 112 | .bubble_chat_line { 113 | background: transparent; 114 | } 115 | 116 | .bubble_chat_line_time { 117 | background: rgba(255,255,255,0.2); 118 | color: black; 119 | } 120 | 121 | .bubble_chat_file { 122 | background: rgba(255,255,255,0.2); 123 | border: 1px solid rgba(255,255,255,0.2); 124 | color: black; 125 | } 126 | 127 | .bubble_chat_file_preview { 128 | border: 1px solid rgba(0,0,0,0.1); 129 | color: black; 130 | } 131 | -------------------------------------------------------------------------------- /src/resources/style/main_alt.css: -------------------------------------------------------------------------------- 1 | GtkPaned { 2 | background: black; 3 | } 4 | 5 | *:insensitive { 6 | background-image: 7 | -gtk-gradient ( 8 | linear, 9 | left top, right bottom, 10 | color-stop(0, black), 11 | color-stop(0.01, black), 12 | color-stop(0.03, transparent), 13 | color-stop(0.47, transparent), 14 | color-stop(0.49, black), 15 | color-stop(0.51, black), 16 | color-stop(0.53, transparent), 17 | color-stop(0.97, transparent), 18 | color-stop(0.99, black), 19 | color-stop(1, black)); 20 | background-repeat: repeat; 21 | background-size: 10px 10px; 22 | } 23 | 24 | *:insensitive > * { 25 | background-image: initial; 26 | } 27 | 28 | GtkFrame { 29 | background-color: @theme_base_color; 30 | border: none; 31 | } 32 | 33 | GtkPopover { 34 | padding: 0.5em; 35 | } 36 | 37 | .headerbar-right { 38 | border-top-left-radius: 0; 39 | } 40 | 41 | .headerbar-left { 42 | border-top-right-radius: 0; 43 | } 44 | 45 | #WidgetNotification { 46 | background-color: @bg_color; 47 | color: @fg_color; 48 | border-radius: 10px 10px 0 0; 49 | border:none; 50 | padding: 5px; 51 | } 52 | 53 | /*#HeaderBarRight { 54 | background-color: transparent; 55 | } 56 | 57 | #HeaderBarLeft { 58 | background-color: transparent; 59 | }*/ 60 | 61 | #WidgetContactListItem { 62 | border-bottom: 1px solid rgba(0,0,0,0.3); 63 | } 64 | 65 | #WidgetContactListItem:selected, #PopoverStatusListItem:selected { 66 | background: rgba(0,0,0,0.2); 67 | } 68 | 69 | #Debug { 70 | border: 2px solid #FF0000; 71 | } 72 | 73 | #WidgetChatLineRight { 74 | padding: 0.25em; 75 | background-color: rgba(0,0,0,0.2); 76 | border-radius: 7px 7px 0px 7px; 77 | } 78 | 79 | #WidgetChatLineLeft { 80 | padding: 0.25em; 81 | background-color: rgba(0,0,0,0.2); 82 | border-radius: 0 7px 7px 7px; 83 | } 84 | 85 | #WidgetContactListItem { 86 | padding: 5px; 87 | } 88 | 89 | #WidgetContactListItem #Avatar { 90 | padding: 4px 91 | } 92 | 93 | #WidgetContactListItem #Name { 94 | font-size: 120%; 95 | padding: 5px; 96 | } 97 | 98 | #WidgetContactListItem #Status { 99 | font-size: 80%; 100 | padding: 5px; 101 | } 102 | 103 | #BigText { 104 | font-size: 120%; 105 | } 106 | 107 | #SmallText { 108 | font-size: 80%; 109 | } 110 | 111 | #WidgetContactListItem #StatusIcon { 112 | padding-left: 9px; 113 | padding-right: 5px; 114 | } 115 | 116 | #PopoverStatusListItem { 117 | border-radius: 5px; 118 | } 119 | 120 | #ChatTime { 121 | background: rgba(255,255,255,0.2); 122 | color: black; 123 | border-radius: 3px; 124 | padding: 2px; 125 | } 126 | 127 | #WidgetChatLineRight .chatmsg { 128 | padding: 2px; 129 | } 130 | 131 | #WidgetChatLineLeft .chatmsg { 132 | padding: 2px; 133 | } 134 | 135 | GtkListBox.settings GtkListBoxRow { 136 | padding: 10px; 137 | } 138 | 139 | .bubble_chat_line { 140 | background: transparent; 141 | padding: 2px; 142 | } 143 | 144 | .message_receipt { 145 | opacity: 1; 146 | } 147 | 148 | .message_pending { 149 | background: rgba(0,0,0,0.3); 150 | opacity: 0.3; 151 | } 152 | 153 | .message_failed { 154 | opacity: 0.3; 155 | background: rgba(255,0,0,0.3); 156 | } 157 | 158 | .bubble_chat_line.top_left { 159 | padding-top: 4px; 160 | border-radius: 5px 0 0 0; 161 | } 162 | 163 | .bubble_chat_line.top_right { 164 | border-radius: 0 5px 0 0; 165 | } 166 | 167 | .bubble_chat_line.bottom_left { 168 | border-radius: 0 0 5px 0; 169 | } 170 | 171 | .bubble_chat_line.bottom_right { 172 | border-radius: 0 0 0 5px; 173 | } 174 | -------------------------------------------------------------------------------- /src/resources/style/profile.css: -------------------------------------------------------------------------------- 1 | /* 2 | Profile selection 3 | */ 4 | 5 | .gtox-profile { 6 | padding: 5px; 7 | background-image: 8 | -gtk-gradient ( 9 | linear, 10 | left top, right bottom, 11 | color-stop(0, transparent), 12 | color-stop(0.01, transparent), 13 | color-stop(0.03, transparent), 14 | color-stop(0.47, transparent), 15 | color-stop(0.49, transparent), 16 | color-stop(0.51, transparent), 17 | color-stop(0.53, transparent), 18 | color-stop(0.97, transparent), 19 | color-stop(0.99, transparent), 20 | color-stop(1, transparent)); 21 | background-repeat: repeat; 22 | background-size: 10px 10px; 23 | border-bottom: 1px solid rgba(0,0,0,0.3); 24 | padding-left: 9px; 25 | padding-right: 5px; 26 | } 27 | 28 | .gtox-profile .gtox-profile-avatar { 29 | padding: 5px 30 | } 31 | 32 | .gtox-profile .gtox-profile-name { 33 | font-size: 120%; 34 | padding: 0 5px; 35 | } 36 | 37 | .gtox-profile .gtox-profile-status { 38 | font-size: 80%; 39 | padding: 0 5px; 40 | } 41 | 42 | .gtox-profile .gtox-profile-path { 43 | font-size: 80%; 44 | padding: 0 5px; 45 | color: gray; 46 | } 47 | 48 | .gtox-profile:insensitive { 49 | background-image: 50 | -gtk-gradient ( 51 | linear, 52 | left top, right bottom, 53 | color-stop(0, black), 54 | color-stop(0.01, black), 55 | color-stop(0.03, transparent), 56 | color-stop(0.47, transparent), 57 | color-stop(0.49, black), 58 | color-stop(0.51, black), 59 | color-stop(0.53, transparent), 60 | color-stop(0.97, transparent), 61 | color-stop(0.99, black), 62 | color-stop(1, black)); 63 | background-repeat: repeat; 64 | background-size: 10px 10px; 65 | } 66 | 67 | .gtox-profile:selected { 68 | background-color: rgba(40,150,40,0.2); 69 | } 70 | 71 | 72 | -------------------------------------------------------------------------------- /src/resources/ui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(NAME "gtox-ui.gresource") 4 | set(CNAME "gtox_ui") 5 | set(PREFIX "/org/gtox/ui") 6 | set(OPTIONS "compressed=\\\"true\\\"") 7 | 8 | set(SRC 9 | dialog_profile.ui 10 | list_item_profile.ui 11 | list_item_contact.ui 12 | list_item_notification.ui 13 | list_item_notification_mini.ui 14 | dialog_assistant.ui 15 | dialog_contact.ui 16 | popover_settings.ui 17 | dialog_settings.ui 18 | chat_filerecv.ui 19 | chat_filepreview.ui 20 | status_menu.ui 21 | dialog_chat.ui 22 | chat_bubble_right.ui 23 | chat_bubble_left.ui 24 | videoplayer.ui 25 | dialog_detachable.ui) 26 | 27 | set(LAYOUT ${SRC} PARENT_SCOPE) 28 | 29 | find_program(GLIB_COMPILE_RESOURCE_EXECUTEABLE glib-compile-resources) 30 | if(NOT GLIB_COMPILE_RESOURCE_EXECUTEABLE) 31 | message(FATAL_ERROR "glib-compile-resources not found") 32 | endif() 33 | 34 | find_program(BASH_EXECUTEABLE bash) 35 | if(NOT BASH_EXECUTEABLE) 36 | message(FATAL_ERROR "bash not found") 37 | endif() 38 | 39 | add_custom_command( 40 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h" 41 | COMMAND "${BASH_EXECUTEABLE}" "${CMAKE_CURRENT_SOURCE_DIR}/../gresource.sh" "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml" "${PREFIX}" "${OPTIONS}" ${SRC} 42 | COMMAND "${GLIB_COMPILE_RESOURCE_EXECUTEABLE}" --target="${NAME}.c" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}" --generate-source --c-name "${CNAME}" "${NAME}.xml" 43 | COMMAND "${GLIB_COMPILE_RESOURCE_EXECUTEABLE}" --target="${NAME}.h" --sourcedir="${CMAKE_CURRENT_SOURCE_DIR}" --generate-header --c-name "${CNAME}" "${NAME}.xml" 44 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} 45 | DEPENDS ${SRC} 46 | ) 47 | 48 | set (GRESOURCE ${GRESOURCE} "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c" PARENT_SCOPE) 49 | 50 | ADD_CUSTOM_TARGET(gtox-ui-resource ALL 51 | DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${NAME}.c") 52 | 53 | 54 | -------------------------------------------------------------------------------- /src/resources/ui/list_item_notification.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 8 | 9 | True 10 | False 11 | start 12 | 13 | 14 | 64 15 | 64 16 | True 17 | False 18 | center 19 | 22 | 23 | 24 | 2 25 | 0 26 | 2 27 | 28 | 29 | 30 | 31 | True 32 | False 33 | start 34 | True 35 | Title 36 | end 37 | True 38 | 41 | 42 | 43 | 1 44 | 0 45 | 46 | 47 | 48 | 49 | True 50 | False 51 | start 52 | True 53 | Message 54 | end 55 | True 56 | 59 | 60 | 61 | 1 62 | 1 63 | 64 | 65 | 66 | 67 | True 68 | False 69 | 72 | 73 | 74 | 0 75 | 0 76 | 2 77 | 78 | 79 | 80 | 81 | True 82 | False 83 | center 84 | 85 | 86 | 87 | 90 | 91 | 92 | 0 93 | 2 94 | 3 95 | 96 | 97 | 98 | 99 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /src/resources/ui/list_item_notification_mini.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 8 | 9 | True 10 | False 11 | start 12 | 13 | 14 | 32 15 | 32 16 | True 17 | False 18 | center 19 | 22 | 23 | 24 | 3 25 | 0 26 | 27 | 28 | 29 | 30 | True 31 | False 32 | start 33 | True 34 | Title 35 | end 36 | True 37 | 40 | 41 | 42 | 1 43 | 0 44 | 45 | 46 | 47 | 48 | True 49 | False 50 | end 51 | True 52 | Message 53 | end 54 | True 55 | 58 | 59 | 60 | 2 61 | 0 62 | 63 | 64 | 65 | 66 | True 67 | False 68 | 71 | 72 | 73 | 0 74 | 0 75 | 76 | 77 | 78 | 79 | True 80 | False 81 | center 82 | 83 | 84 | 85 | 88 | 89 | 90 | 0 91 | 1 92 | 4 93 | 94 | 95 | 96 | 97 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /src/resources/ui/status_menu.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | Online 7 | status.online 8 | status_online 9 | 10 | 11 | Busy 12 | status.busy 13 | status_busy 14 | 15 | 16 | Away 17 | status.away 18 | status_away 19 | 20 | 21 | Exit 22 | status.offline 23 | status_offline 24 | 25 | 26 | Switch Profile 27 | status.switch 28 | status_offline 29 | 30 |
31 |
32 |
33 | -------------------------------------------------------------------------------- /src/tox/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | project(toxmm) 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | set(CMAKE_BUILD_TYPE Debug) 5 | 6 | find_package(PkgConfig) 7 | pkg_check_modules(GLIBMM glibmm-2.4) 8 | link_directories(${GLIBMM_LIBRARY_DIRS}) 9 | include_directories(${GLIBMM_INCLUDE_DIRS}) 10 | 11 | set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) 12 | find_package(Tox) 13 | include_directories(${TOX_INCLUDE_DIR}) 14 | include_directories(${TOXAV_INCLUDE_DIR}) 15 | 16 | set(SOURCES 17 | 18 | types.cpp 19 | core.cpp 20 | exception.cpp 21 | profile.cpp 22 | storage.cpp 23 | config.cpp 24 | contact/manager.cpp 25 | contact/contact.cpp 26 | contact/receipt.cpp 27 | contact/file/manager.cpp 28 | contact/file/file.cpp 29 | contact/file/file_recv.cpp 30 | contact/file/file_send.cpp 31 | av.cpp 32 | contact/call.cpp 33 | utils.h 34 | ) 35 | 36 | add_library(${PROJECT_NAME} STATIC 37 | ${SOURCES} 38 | ) 39 | target_link_libraries(${PROJECT_NAME} ${GLIBMM_LIBRARIES} ${TOX_LIBRARY} ${TOXAV_LIBRARY}) 40 | target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 41 | 42 | add_subdirectory(flatbuffers) 43 | add_dependencies(${PROJECT_NAME} toxmm-flatbuffers) 44 | 45 | set(TEST_SOURCES 46 | ${CMAKE_CURRENT_SOURCE_DIR}/test/global_fixture.t.h 47 | ${CMAKE_CURRENT_SOURCE_DIR}/test/profile.t.h 48 | ${CMAKE_CURRENT_SOURCE_DIR}/test/types.t.h 49 | ${CMAKE_CURRENT_SOURCE_DIR}/test/core.t.h 50 | ${CMAKE_CURRENT_SOURCE_DIR}/test/contact.t.h 51 | ${CMAKE_CURRENT_SOURCE_DIR}/test/file.t.h 52 | ) 53 | 54 | find_package(CxxTest) 55 | if(CXXTEST_FOUND) 56 | include_directories(${CXXTEST_INCLUDE_DIR}) 57 | enable_testing() 58 | 59 | CXXTEST_ADD_TEST(${PROJECT_NAME}-test runner.cc ${TEST_SOURCES}) 60 | 61 | pkg_check_modules(GIOMM giomm-2.4) 62 | link_directories(${GIOMM_LIBRARY_DIRS}) 63 | include_directories(${GIOMM_INCLUDE_DIRS}) 64 | target_link_libraries(${PROJECT_NAME}-test ${GIOMM_LIBRARIES} ${PROJECT_NAME} uuid) 65 | endif() 66 | -------------------------------------------------------------------------------- /src/tox/config.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_CONFIG_H 20 | #define TOXMM_CONFIG_H 21 | #include 22 | #include "storage.h" 23 | #include 24 | #include "utils.h" 25 | 26 | namespace toxmm { 27 | class config : public Glib::Object, public std::enable_shared_from_this { 28 | public: 29 | static std::shared_ptr create(const std::shared_ptr storage); 30 | 31 | private: 32 | void load_flatbuffer(); 33 | void save_flatbuffer(); 34 | 35 | std::shared_ptr m_storage; 36 | 37 | config(const std::shared_ptr storage); 38 | config(const config&) = delete; 39 | void operator=(const config&) = delete; 40 | 41 | // Install properties 42 | INST_PROP (Glib::ustring , property_download_path, "config-download-path") 43 | INST_PROP (Glib::ustring , property_avatar_path, "config-avatar-path") 44 | INST_PROP (bool , property_connection_udp, "config-connection-udp") 45 | INST_PROP (TOX_PROXY_TYPE, property_proxy_type, "config-proxy-type") 46 | INST_PROP (Glib::ustring , property_proxy_host, "config-proxy-host") 47 | INST_PROP (int , property_proxy_port, "config-proxy-port") 48 | }; 49 | } 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/tox/contact/call.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_CONTACT_CALL_H 20 | #define TOXMM_CONTACT_CALL_H 21 | 22 | #include 23 | #include "types.h" 24 | #include "av.h" 25 | #include "utils.h" 26 | 27 | namespace toxmm { 28 | class call : public Glib::Object, public std::enable_shared_from_this { 29 | friend class contact; 30 | friend class contact_manager; 31 | public: 32 | enum CALL_STATE { 33 | CALL_RESUME, 34 | CALL_PAUSE, 35 | CALL_CANCEL 36 | }; 37 | 38 | std::shared_ptr contact(); 39 | std::shared_ptr core(); 40 | std::shared_ptr av(); 41 | 42 | private: 43 | std::weak_ptr m_contact; 44 | 45 | call(const std::shared_ptr& contact); 46 | 47 | CALL_STATE m_prev_call_state; 48 | 49 | // Install all properties 50 | INST_PROP (CALL_STATE, property_state, "call-state") 51 | INST_PROP (av::image , property_video_frame, "call-video-frame") 52 | INST_PROP (av::audio , property_audio_frame, "call-audio-frame") 53 | INST_PROP_RO (CALL_STATE, property_remote_state, "call-remote-state") 54 | INST_PROP_RO (av::image , property_remote_video_frame, "call-remote-video-frame") 55 | INST_PROP_RO (av::audio , property_remote_audio_frame, "call-remote-audio-frame") 56 | INST_PROP (uint32_t , property_video_kilobitrate, "call-video-kilobitrate") 57 | INST_PROP (uint32_t , property_audio_kilobitrate, "call-audio-kilobitrate") 58 | INST_PROP_RO (uint32_t , property_suggested_video_kilobitrate, "call-suggested-video-kilobitrate") 59 | INST_PROP_RO (uint32_t , property_suggested_audio_kilobitrate, "call-suggested-audio-kilobitrate") 60 | 61 | // Install all signals 62 | INST_SIGNAL (signal_incoming_call , void) 63 | INST_SIGNAL (signal_error , void) 64 | INST_SIGNAL (signal_finish , void) 65 | INST_SIGNAL (signal_suggestion_updated, void) 66 | }; 67 | } 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/tox/contact/contact.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_CONTACT_H 20 | #define TOXMM_CONTACT_H 21 | #include 22 | #include 23 | #include 24 | #include "types.h" 25 | #include 26 | #include "av.h" 27 | #include "utils.h" 28 | 29 | namespace toxmm { 30 | class file_manager; 31 | class receipt; 32 | class call; 33 | class contact : public Glib::Object, public std::enable_shared_from_this { 34 | friend class contact_manager; 35 | friend class file_manager; 36 | public: 37 | //functions 38 | std::shared_ptr send_message(const std::string& message); 39 | std::shared_ptr send_action (const std::string& action); 40 | 41 | std::shared_ptr core(); 42 | std::shared_ptr contact_manager(); 43 | std::shared_ptr file_manager(); 44 | std::shared_ptr call(); 45 | 46 | private: 47 | std::weak_ptr m_contact_manager; 48 | std::shared_ptr m_file_manager; 49 | std::shared_ptr m_call; 50 | 51 | std::shared_ptr m_avatar_send; 52 | Glib::RefPtr m_avatar_send_monitor; 53 | 54 | contact(std::shared_ptr manager, contactNr nr); 55 | contact(const contact&) = delete; 56 | void operator=(const contact&) = delete; 57 | 58 | void init(); 59 | 60 | contactAddrPublic toxcore_get_addr(); 61 | Glib::ustring toxcore_get_name(); 62 | Glib::ustring toxcore_get_status_message(); 63 | TOX_USER_STATUS toxcore_get_status(); 64 | TOX_CONNECTION toxcore_get_connection(); 65 | 66 | // Install all properties 67 | INST_PROP_RO (contactNr , property_nr, "contact-nr") 68 | INST_PROP_RO (contactAddrPublic, property_addr_public, "contact-addr-public") 69 | INST_PROP_RO (Glib::ustring , property_name, "contact-name") 70 | INST_PROP_RO (Glib::ustring , property_name_or_addr, "contact-name-or-addr") 71 | INST_PROP_RO (Glib::ustring , property_status_message, "contact-status-message") 72 | INST_PROP_RO (TOX_USER_STATUS , property_status, "contact-status") 73 | INST_PROP_RO (TOX_CONNECTION , property_connection, "contact-connection") 74 | INST_PROP (bool , property_typing, "contact-typing") 75 | INST_PROP_RO (bool , property_remote_typing, "contact-remote-typing") 76 | 77 | // Install all signals 78 | INST_SIGNAL (signal_receipt , void, receiptNr) 79 | INST_SIGNAL (signal_recv_message , void, Glib::ustring) 80 | INST_SIGNAL (signal_recv_action , void, Glib::ustring) 81 | INST_SIGNAL (signal_send_message , void, Glib::ustring, std::shared_ptr) 82 | INST_SIGNAL (signal_send_action , void, Glib::ustring, std::shared_ptr) 83 | INST_SIGNAL (signal_send_file_chunk_request, void, fileNr, uint64_t, size_t) 84 | INST_SIGNAL (signal_recv_file , void, fileNr, TOX_FILE_KIND, size_t, Glib::ustring) 85 | INST_SIGNAL (signal_recv_file_chunk , void, fileNr, uint64_t, const std::vector&) 86 | INST_SIGNAL (signal_recv_file_control , void, fileNr, TOX_FILE_CONTROL) 87 | }; 88 | 89 | } 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /src/tox/contact/file/file.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_FILE_H 20 | #define TOXMM_FILE_H 21 | #include 22 | #include 23 | #include 24 | #include "types.h" 25 | #include "utils.h" 26 | 27 | namespace toxmm { 28 | class file_manager; 29 | class contact_manager; 30 | class contact; 31 | class core; 32 | 33 | class file: 34 | virtual public Glib::Object, 35 | public std::enable_shared_from_this { 36 | 37 | friend class file_manager; 38 | friend class file_recv; 39 | friend class file_send; 40 | 41 | public: 42 | auto core() -> std::shared_ptr; 43 | auto file_manager() -> std::shared_ptr; 44 | auto contact_manager() -> std::shared_ptr; 45 | auto contact() -> std::shared_ptr; 46 | 47 | virtual ~file() {} 48 | virtual bool is_recv() = 0; 49 | 50 | file(); 51 | file(std::shared_ptr manager); 52 | file(const file&) = delete; 53 | void operator=(const file&) = delete; 54 | 55 | protected: 56 | virtual void resume() = 0; 57 | virtual void send_chunk_request(uint64_t position, size_t length) = 0; 58 | virtual void recv_chunk(uint64_t position, const std::vector& data) = 0; 59 | virtual void finish() = 0; 60 | virtual void abort() = 0; 61 | 62 | void pre_send_chunk_request(uint64_t position, size_t length); 63 | void pre_recv_chunk(uint64_t position, const std::vector& data); 64 | void seek(uint64_t position); 65 | 66 | private: 67 | std::weak_ptr m_file_manager; 68 | 69 | void init(); 70 | 71 | // Install properties 72 | INST_PROP_RO (uniqueId , property_uuid, "file-uuid") 73 | INST_PROP_RO (fileId , property_id, "file-id") 74 | INST_PROP_RO (fileNr , property_nr, "file-nr") 75 | INST_PROP_RO (TOX_FILE_KIND , property_kind, "file-kind") 76 | INST_PROP_RO (uint64_t , property_position, "file-position") 77 | INST_PROP_RO (uint64_t , property_size, "file-size") 78 | INST_PROP_RO (Glib::ustring , property_name, "file-name") 79 | INST_PROP_RO (Glib::ustring , property_path, "file-path") 80 | INST_PROP (TOX_FILE_CONTROL, property_state, "file-state") 81 | INST_PROP_RO (TOX_FILE_CONTROL, property_state_remote, "file-remote") 82 | INST_PROP_RO (double , property_progress, "file-progress") 83 | INST_PROP_RO (bool , property_complete, "file-complete") 84 | INST_PROP_RO (bool , property_active, "file-active") 85 | }; 86 | } 87 | #endif 88 | -------------------------------------------------------------------------------- /src/tox/contact/file/file_recv.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #include "file_recv.h" 20 | #include "exception.h" 21 | 22 | using namespace toxmm; 23 | 24 | file_recv::file_recv(std::shared_ptr manager): 25 | Glib::ObjectBase(typeid(file_recv)), 26 | file(manager) { 27 | } 28 | 29 | void file_recv::resume() { 30 | if (m_stream) { 31 | m_stream.reset(); 32 | } 33 | auto file = Gio::File::create_for_path(property_path().get_value()); 34 | m_stream = file->append_to(); 35 | m_stream->seek(0, Glib::SEEK_TYPE_END); 36 | m_stream->seek(std::min(goffset(property_size()), m_stream->tell()), 37 | Glib::SEEK_TYPE_SET); 38 | m_stream->truncate(m_stream->tell()); 39 | try { 40 | seek(uint64_t(m_stream->tell())); 41 | } catch (toxmm::exception) { 42 | //this is pretty stupid 43 | //when we pause and then resume 44 | //seek is not possible ! 45 | // 46 | //we effectly ignore the error now 47 | //if we can seek we seek 48 | //if we can't seek we think we seeked 49 | // 50 | //it looks like we can only seek once each file before resume 51 | //but we have no way of knowing here if it's the first time we resume 52 | //or the second time.. 53 | //so we will just try and hope 54 | } 55 | } 56 | 57 | void file_recv::send_chunk_request(uint64_t, size_t) { 58 | throw std::runtime_error("file_recv::send_chunk_request"); 59 | } 60 | 61 | void file_recv::recv_chunk(uint64_t position, const std::vector& chunk) { 62 | if (!m_stream) { 63 | return; 64 | } 65 | //TODO: make async 66 | m_stream->seek(position, Glib::SEEK_TYPE_SET); 67 | m_stream->write_bytes(Glib::Bytes::create(chunk.data(), chunk.size())); 68 | } 69 | 70 | void file_recv::finish() { 71 | if (m_stream) { 72 | m_stream.reset(); 73 | } 74 | } 75 | 76 | void file_recv::abort() { 77 | if (m_stream) { 78 | m_stream.reset(); 79 | } 80 | auto file = Gio::File::create_for_path(property_path().get_value()); 81 | try { 82 | file->remove(); 83 | } catch (...) { 84 | //ignore 85 | } 86 | } 87 | 88 | bool file_recv::is_recv() { 89 | return true; 90 | } 91 | -------------------------------------------------------------------------------- /src/tox/contact/file/file_recv.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_FILE_RECV_H 20 | #define TOXMM_FILE_RECV_H 21 | #include 22 | #include 23 | #include 24 | #include "file.h" 25 | 26 | namespace toxmm { 27 | class file_recv: virtual public Glib::Object, public file { 28 | friend class file_manager; 29 | protected: 30 | void resume(); 31 | void send_chunk_request(uint64_t, size_t); 32 | void recv_chunk(uint64_t position, const std::vector& chunk); 33 | void finish(); 34 | void abort(); 35 | bool is_recv(); 36 | 37 | private: 38 | Glib::RefPtr m_stream; 39 | 40 | file_recv(std::shared_ptr manager); 41 | file_recv(const file_recv&) = delete; 42 | void operator=(const file_recv&) = delete; 43 | }; 44 | } 45 | #endif 46 | -------------------------------------------------------------------------------- /src/tox/contact/file/file_send.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #include "file_send.h" 20 | #include "core.h" 21 | #include "contact/contact.h" 22 | #include "exception.h" 23 | 24 | using namespace toxmm; 25 | 26 | file_send::file_send(std::shared_ptr manager): 27 | Glib::ObjectBase(typeid(file_send)), 28 | file(manager) { 29 | } 30 | 31 | void file_send::resume() { 32 | m_queue.clear(); 33 | if (m_stream) { 34 | m_stream.reset(); 35 | } 36 | auto file = Gio::File::create_for_path(property_path().get_value()); 37 | if (file->query_exists()) { 38 | m_stream = file->read(); 39 | } 40 | } 41 | 42 | void file_send::send_chunk_request(uint64_t position, size_t size) { 43 | if (!m_stream) { 44 | return; 45 | } 46 | 47 | m_queue.push_back({position, size}); 48 | 49 | iterate(); 50 | } 51 | 52 | void file_send::iterate() { 53 | while (!m_queue.empty()) { 54 | auto last = m_queue.front(); 55 | auto position = last.first; 56 | auto size = last.second; 57 | 58 | //TODO: make async 59 | if (m_stream) { 60 | m_stream->seek(position, Glib::SEEK_TYPE_SET); 61 | } 62 | std::vector chunk(size); 63 | gsize dummy; 64 | if (m_stream) { 65 | m_stream->read_all(chunk.data(), chunk.size(), dummy); 66 | } 67 | 68 | //send 69 | auto c = core(); 70 | auto ct = contact(); 71 | if (!c || !ct) { 72 | return; 73 | } 74 | 75 | TOX_ERR_FILE_SEND_CHUNK error; 76 | tox_file_send_chunk(c->toxcore(), 77 | ct->property_nr().get_value(), 78 | property_nr().get_value(), 79 | position, 80 | chunk.data(), 81 | chunk.size(), 82 | &error); 83 | switch (error) { 84 | case TOX_ERR_FILE_SEND_CHUNK_SENDQ: 85 | //try again later ! 86 | Glib::signal_idle().connect_once(sigc::track_obj([this]() { 87 | iterate(); 88 | }, *this)); 89 | return; 90 | case TOX_ERR_FILE_SEND_CHUNK_OK: 91 | break; 92 | default: 93 | throw toxmm::exception(error); 94 | } 95 | 96 | m_queue.pop_front(); 97 | 98 | if (position + size >= property_size().get_value()) { 99 | //upload complete 100 | m_property_complete = true; 101 | m_property_active = false; 102 | } 103 | } 104 | } 105 | 106 | void file_send::recv_chunk(uint64_t, const std::vector&) { 107 | throw std::runtime_error("file_recv::send_chunk_request"); 108 | } 109 | 110 | void file_send::finish() { 111 | m_queue.clear(); 112 | if (m_stream) { 113 | m_stream.reset(); 114 | } 115 | } 116 | 117 | void file_send::abort() { 118 | m_queue.clear(); 119 | if (m_stream) { 120 | m_stream.reset(); 121 | } 122 | } 123 | 124 | bool file_send::is_recv() { 125 | return false; 126 | } 127 | -------------------------------------------------------------------------------- /src/tox/contact/file/file_send.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_FILE_SEND_H 20 | #define TOXMM_FILE_SEND_H 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "file.h" 26 | 27 | namespace toxmm { 28 | class file_send: virtual public Glib::Object, public file { 29 | friend class file_manager; 30 | protected: 31 | void resume(); 32 | void send_chunk_request(uint64_t position, size_t length); 33 | void recv_chunk(uint64_t, const std::vector&); 34 | void finish(); 35 | void abort(); 36 | bool is_recv(); 37 | 38 | private: 39 | Glib::RefPtr m_stream; 40 | std::deque> m_queue; 41 | 42 | file_send(std::shared_ptr manager); 43 | file_send(const file_send&) = delete; 44 | void operator=(const file_send&) = delete; 45 | 46 | void iterate(); 47 | }; 48 | } 49 | #endif 50 | -------------------------------------------------------------------------------- /src/tox/contact/file/manager.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_FILE_MANAGER_H 20 | #define TOXMM_FILE_MANAGER_H 21 | #include 22 | #include 23 | #include 24 | #include "types.h" 25 | #include "utils.h" 26 | 27 | namespace toxmm { 28 | class file; 29 | class core; 30 | class contact_manager; 31 | class file_manager: public std::enable_shared_from_this { 32 | friend class contact; 33 | public: 34 | ~file_manager(); 35 | 36 | //functions 37 | std::shared_ptr find(fileNr nr); 38 | std::shared_ptr find(uniqueId id); 39 | 40 | std::shared_ptr send_file(const Glib::ustring& path, bool avatar = false); 41 | 42 | std::shared_ptr core(); 43 | std::shared_ptr contact_manager(); 44 | std::shared_ptr contact(); 45 | 46 | private: 47 | std::weak_ptr m_contact; 48 | std::vector> m_file; 49 | 50 | file_manager(std::shared_ptr contact); 51 | file_manager(const file_manager&) = delete; 52 | void operator=(const file_manager&) = delete; 53 | 54 | void init(); 55 | void load(); 56 | void save(); 57 | 58 | // Install signals 59 | //! Emits when a new file is incoming 60 | INST_SIGNAL (signal_recv_file , void, std::shared_ptr&) 61 | //! Emits when a new file will go out 62 | INST_SIGNAL (signal_send_file , void, std::shared_ptr&) 63 | //! Emits when a chunk for a incoming file was received 64 | INST_SIGNAL (signal_recv_chunk , void, std::shared_ptr&, const std::vector&) 65 | //! Emits when a chunk for a outgoing file will be send 66 | INST_SIGNAL (signal_send_chunk , void, std::shared_ptr&, const std::vector&) 67 | //! Emits when a chunk for a outgoing file is requested 68 | INST_SIGNAL (signal_send_chunk_request , void, std::shared_ptr&, uint64_t, size_t) 69 | //! Emits when a when a control-command was received 70 | INST_SIGNAL (signal_recv_control , void, std::shared_ptr&, TOX_FILE_CONTROL) 71 | //! Emits when a when a control-command will be send 72 | INST_SIGNAL (signal_send_control , void, std::shared_ptr&, TOX_FILE_CONTROL) 73 | 74 | }; 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /src/tox/contact/manager.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_CONTACT_MANAGER_H 20 | #define TOXMM_CONTACT_MANAGER_H 21 | #include 22 | #include 23 | #include 24 | #include "types.h" 25 | #include "utils.h" 26 | 27 | namespace toxmm { 28 | class contact_manager : public std::enable_shared_from_this { 29 | friend class core; 30 | public: 31 | std::shared_ptr find(contactAddrPublic addr); 32 | std::shared_ptr find(contactNr nr); 33 | 34 | const std::vector>& get_all(); 35 | 36 | void add_contact(contactAddrPublic addr_public); 37 | void add_contact(contactAddr addr, const std::string& message); 38 | void remove_contact(std::shared_ptr contact); 39 | 40 | void destroy(); 41 | ~contact_manager(); 42 | 43 | std::shared_ptr core(); 44 | 45 | private: 46 | std::weak_ptr m_core; 47 | 48 | std::vector> m_contact; 49 | 50 | contact_manager(std::shared_ptr core); 51 | contact_manager(const contact_manager&) = delete; 52 | void operator=(const contact_manager&) = delete; 53 | 54 | void init(); 55 | 56 | // Install signals 57 | INST_SIGNAL (signal_request, void, contactAddrPublic, Glib::ustring) 58 | INST_SIGNAL (signal_removed, void, std::shared_ptr) 59 | INST_SIGNAL (signal_added , void, std::shared_ptr) 60 | }; 61 | 62 | } 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /src/tox/contact/receipt.cpp: -------------------------------------------------------------------------------- 1 | #include "receipt.h" 2 | #include "contact.h" 3 | 4 | using namespace toxmm; 5 | 6 | receipt::receipt(std::shared_ptr contact, receiptNr nr): 7 | Glib::ObjectBase(typeid(receipt)) { 8 | m_property_nr = nr; 9 | 10 | m_connection = contact->signal_receipt().connect(sigc::track_obj([this](receiptNr nr) { 11 | if (property_nr().get_value() < nr) { 12 | m_signal_lost(); 13 | m_connection.disconnect(); 14 | } else if (property_nr().get_value() == nr) { 15 | m_signal_okay(); 16 | m_connection.disconnect(); 17 | } 18 | }, *this)); 19 | } 20 | -------------------------------------------------------------------------------- /src/tox/contact/receipt.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM_CONTACT_RECEIPT_H 20 | #define TOXMM_CONTACT_RECEIPT_H 21 | 22 | #include 23 | #include "types.h" 24 | #include "utils.h" 25 | 26 | namespace toxmm { 27 | class receipt : public Glib::Object, public std::enable_shared_from_this { 28 | friend class contact; 29 | private: 30 | sigc::connection m_connection; 31 | 32 | receipt(std::shared_ptr contact, receiptNr nr); 33 | receipt(const receipt&) = delete; 34 | void operator=(const receipt&) = delete; 35 | 36 | // Install properties 37 | INST_PROP (receiptNr, property_nr, "receipt-nr") 38 | 39 | // Install signals 40 | INST_SIGNAL (signal_okay, void) 41 | INST_SIGNAL (signal_lost, void) 42 | }; 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/tox/exception.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef TOXMM2_EXCEPTION_H 21 | #define TOXMM2_EXCEPTION_H 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | namespace toxmm { 29 | class exception: public std::exception { 30 | private: 31 | const std::type_index m_type; 32 | std::string m_what; 33 | int m_what_id; 34 | public: 35 | exception(const std::string& what); 36 | exception(TOX_ERR_OPTIONS_NEW error); 37 | exception(TOX_ERR_NEW error); 38 | exception(TOX_ERR_BOOTSTRAP error); 39 | exception(TOX_ERR_FRIEND_ADD error); 40 | exception(TOX_ERR_FRIEND_BY_PUBLIC_KEY error); 41 | exception(TOX_ERR_FRIEND_DELETE error); 42 | exception(TOX_ERR_FRIEND_SEND_MESSAGE error); 43 | exception(TOX_ERR_SET_INFO error); 44 | exception(TOX_ERR_FRIEND_QUERY error); 45 | exception(TOX_ERR_SET_TYPING error); 46 | exception(TOX_ERR_FRIEND_GET_PUBLIC_KEY error); 47 | exception(TOX_ERR_FRIEND_GET_LAST_ONLINE error); 48 | exception(TOX_ERR_FILE_CONTROL error); 49 | exception(TOX_ERR_FILE_SEEK error); 50 | exception(TOX_ERR_FILE_GET error); 51 | exception(TOX_ERR_FILE_SEND error); 52 | exception(TOX_ERR_FILE_SEND_CHUNK error); 53 | 54 | exception(TOXAV_ERR_NEW error); 55 | exception(TOXAV_ERR_CALL error); 56 | exception(TOXAV_ERR_ANSWER error); 57 | exception(TOXAV_ERR_CALL_CONTROL error); 58 | exception(TOXAV_ERR_BIT_RATE_SET error); 59 | exception(TOXAV_ERR_SEND_FRAME error); 60 | 61 | virtual const char* what() const noexcept; 62 | virtual std::type_index type() const noexcept; 63 | virtual int what_id() const noexcept; 64 | }; 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /src/tox/flatbuffers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | set(SRC 4 | File.fbs 5 | Config.fbs) 6 | 7 | ADD_CUSTOM_TARGET(toxmm-flatbuffers ALL) 8 | 9 | find_program(FLAT_C_EXECUTABLE flatc) 10 | if(NOT FLAT_C_EXECUTABLE) 11 | message(FATAL_ERROR "flatc not found") 12 | endif() 13 | 14 | foreach(_item ${SRC}) 15 | GET_FILENAME_COMPONENT(_item_we "${_item}" NAME_WE) 16 | add_custom_command( 17 | OUTPUT "${CMAKE_CURRENT_SOURCE_DIR}/generated/${_item_we}_generated.h" 18 | POST_BUILD 19 | COMMAND "${FLAT_C_EXECUTABLE}" -c -o ./generated --strict-json "${_item}" 20 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 21 | DEPENDS ${_item} 22 | ) 23 | SET_SOURCE_FILES_PROPERTIES("${CMAKE_CURRENT_SOURCE_DIR}/generated/${_item_we}_generated.h" PROPERTIES GENERATED 1) 24 | ADD_CUSTOM_TARGET("toxmm-flatbuffers-${_item_we}" ALL DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/generated/${_item_we}_generated.h") 25 | add_dependencies(toxmm-flatbuffers "toxmm-flatbuffers-${_item_we}") 26 | endforeach() 27 | -------------------------------------------------------------------------------- /src/tox/flatbuffers/Config.fbs: -------------------------------------------------------------------------------- 1 | namespace flatbuffers.Config; 2 | 3 | //never reorder these properties ! 4 | 5 | table Config { 6 | download_path:string; 7 | avatar_path:string; 8 | connection_udp:bool; 9 | connection_tcp:bool (deprecated); 10 | proxy_type:int; 11 | proxy_host:string; 12 | proxy_port:int; 13 | } 14 | 15 | root_type Config; 16 | -------------------------------------------------------------------------------- /src/tox/flatbuffers/File.fbs: -------------------------------------------------------------------------------- 1 | namespace flatbuffers.File; 2 | 3 | //never reorder these properties ! 4 | 5 | table File { 6 | uuid:string; 7 | id:string; 8 | kind:int; 9 | position:ulong; 10 | size:ulong; 11 | name:string; 12 | path:string; 13 | progress:double; 14 | is_recv:bool; 15 | state:int; 16 | } 17 | 18 | table Manager { 19 | files:[File]; 20 | 21 | } 22 | 23 | root_type Manager; 24 | -------------------------------------------------------------------------------- /src/tox/flatbuffers/generated/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | 6 | -------------------------------------------------------------------------------- /src/tox/profile.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2015 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #include "profile.h" 21 | #include 22 | 23 | using namespace toxmm; 24 | 25 | std::set& profile::create_used_files() { 26 | static std::set used_files; 27 | return used_files; 28 | } 29 | 30 | profile::profile(): m_used_files(create_used_files()) { 31 | 32 | } 33 | 34 | void profile::open(const Glib::ustring& path) { 35 | if (m_file) { 36 | close(); 37 | } 38 | 39 | m_file = Gio::File::create_for_path(path); 40 | 41 | m_can_write = m_used_files.find(path) == m_used_files.end(); 42 | m_can_read = true; 43 | 44 | if (m_can_write) { 45 | try { 46 | m_file->open_readwrite(); 47 | } catch (...) { 48 | m_can_write = false; 49 | } 50 | } 51 | 52 | try { 53 | m_stream = m_file->read(); 54 | } catch (...) { 55 | m_can_read = false; 56 | } 57 | 58 | m_used_files.insert(m_file->get_path()); 59 | } 60 | 61 | profile::~profile() { 62 | close(); 63 | } 64 | 65 | void profile::close() { 66 | m_can_write = false; 67 | m_can_read = false; 68 | 69 | if (m_file) { 70 | m_used_files.erase(m_file->get_path()); 71 | } 72 | 73 | m_stream.clear(); 74 | m_file.clear(); 75 | } 76 | 77 | bool profile::can_write() { 78 | return m_can_write; 79 | } 80 | 81 | bool profile::can_read() { 82 | return m_can_read; 83 | } 84 | 85 | void profile::write(const std::vector& data) { 86 | if (!can_write()) { 87 | throw std::runtime_error("profile::can_write() == false"); 88 | } 89 | 90 | m_stream.clear(); 91 | 92 | Glib::RefPtr stream; 93 | try { 94 | stream = m_file->replace(std::string(), true); 95 | } catch (Gio::Error exp) { 96 | if (exp.code() != Gio::Error::CANT_CREATE_BACKUP) { 97 | throw; 98 | } 99 | stream = m_file->replace(); 100 | } 101 | 102 | stream->truncate(0); 103 | stream->write_bytes(Glib::Bytes::create((gconstpointer)data.data(), 104 | data.size())); 105 | stream->close(); 106 | 107 | open(m_file->get_path()); 108 | } 109 | 110 | std::vector profile::read() { 111 | if (!can_read()) { 112 | throw std::runtime_error("profile::can_read() == false"); 113 | } 114 | 115 | std::vector data(m_stream->query_info()->get_size()); 116 | 117 | gsize size; 118 | m_stream->seek(0, Glib::SeekType::SEEK_TYPE_SET); 119 | m_stream->read_all((void*)data.data(), data.size(), size); 120 | 121 | return data; 122 | } 123 | 124 | void profile::move(const Glib::ustring& new_path) { 125 | if (!can_read()) { 126 | throw std::runtime_error("profile::can_read() == false"); 127 | } 128 | if (!can_write()) { 129 | throw std::runtime_error("profile::can_write() == false"); 130 | } 131 | 132 | m_stream.clear(); 133 | 134 | m_file->move( 135 | Gio::File::create_for_path(new_path)); 136 | 137 | open(new_path); 138 | } 139 | -------------------------------------------------------------------------------- /src/tox/profile.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2015 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef TOXMM2_PROFILE_H 21 | #define TOXMM2_PROFILE_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | namespace toxmm { 32 | 33 | //TODO: make this portable 34 | class profile { 35 | private: 36 | std::set& create_used_files(); 37 | 38 | bool m_can_write; 39 | bool m_can_read; 40 | Glib::RefPtr m_file; 41 | Glib::RefPtr m_stream; 42 | std::set& m_used_files; 43 | 44 | public: 45 | profile(); 46 | profile(const profile& o) = delete; 47 | ~profile(); 48 | 49 | void operator=(const profile& o) = delete; 50 | 51 | void open(const Glib::ustring& path); 52 | void close(); 53 | 54 | bool can_write(); 55 | bool can_read(); 56 | 57 | /** 58 | * @brief if new_path exists it will be overwritten with this profile 59 | * @param new_path 60 | */ 61 | void move(const Glib::ustring& new_path); 62 | 63 | void write(const std::vector& data); 64 | std::vector read(); 65 | }; 66 | } 67 | 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /src/tox/storage.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #include "storage.h" 20 | -------------------------------------------------------------------------------- /src/tox/storage.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef TOXMM2_STORAGE_H 20 | #define TOXMM2_STORAGE_H 21 | 22 | #include 23 | 24 | namespace toxmm { 25 | 26 | /** 27 | * @brief toxmm will use this class to save data it will need to 28 | * permanently store somewhere 29 | */ 30 | class storage { 31 | public: 32 | /** 33 | * @brief set_prefix_key, main unique-key value 34 | * 35 | * @param prefix 36 | */ 37 | virtual void set_prefix_key(const std::string& prefix) = 0; 38 | 39 | /** 40 | * @brief saves the data somehow 41 | * 42 | * @param unique key for the data 43 | * @param data 44 | */ 45 | virtual void save(const std::initializer_list& key, const std::vector& data) = 0; 46 | 47 | /** 48 | * @brief loads the data somehow 49 | * 50 | * If not data is found for the given key, 51 | * data.size() should be set to zero. 52 | * 53 | * @param unique key for the data 54 | * @param data 55 | */ 56 | virtual void load(const std::initializer_list& key, std::vector& data) = 0; 57 | 58 | virtual ~storage() {} 59 | }; 60 | } 61 | 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/tox/test/contact.t.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "../types.h" 4 | #include "../core.h" 5 | #include "../storage.h" 6 | #include "../contact/manager.h" 7 | #include "../contact/contact.h" 8 | #include "../contact/receipt.h" 9 | #include 10 | #include 11 | #include 12 | 13 | #include "global_fixture.t.h" 14 | 15 | //MUST BE AFTER TestCore ! 16 | class TestContact : public CxxTest::TestSuite 17 | { 18 | public: 19 | void test_message() { 20 | gfix.wait_for_online(); 21 | gfix.wait_for_contact(); 22 | 23 | Glib::ustring msg = "Test message aą"; 24 | Glib::ustring recv_message; 25 | Glib::ustring send_message; 26 | bool receipt_okay = false; 27 | int count = 0; 28 | sigc::connection con1 = gfix.contact_b->signal_recv_message().connect([&](Glib::ustring s) { 29 | recv_message = s; 30 | ++count; 31 | }); 32 | sigc::connection con3; 33 | std::shared_ptr receipt; 34 | sigc::connection con2 = gfix.contact_a->signal_send_message().connect([&](Glib::ustring s, std::shared_ptr r) { 35 | receipt = r; 36 | send_message = s; 37 | con3 = r->signal_okay().connect([&]() { 38 | receipt_okay = true; 39 | ++count; 40 | }); 41 | ++count; 42 | }); 43 | gfix.contact_a->send_message(msg); 44 | gfix.wait_while([&]() { 45 | return count < 3; 46 | }); 47 | con1.disconnect(); 48 | con2.disconnect(); 49 | con3.disconnect(); 50 | 51 | TS_ASSERT_EQUALS(std::string(recv_message), std::string(msg)); 52 | TS_ASSERT_EQUALS(std::string(send_message), std::string(msg)); 53 | TS_ASSERT_EQUALS(receipt_okay, true); 54 | } 55 | 56 | void test_action() { 57 | gfix.wait_for_online(); 58 | gfix.wait_for_contact(); 59 | 60 | Glib::ustring msg = "Test message aą"; 61 | Glib::ustring recv_message; 62 | Glib::ustring send_message; 63 | bool receipt_okay = false; 64 | int count = 0; 65 | sigc::connection con1 = gfix.contact_b->signal_recv_action().connect([&](Glib::ustring s) { 66 | recv_message = s; 67 | ++count; 68 | }); 69 | sigc::connection con3; 70 | std::shared_ptr receipt; 71 | sigc::connection con2 = gfix.contact_a->signal_send_action().connect([&](Glib::ustring s, std::shared_ptr r) { 72 | receipt = r; 73 | send_message = s; 74 | con3 = r->signal_okay().connect([&]() { 75 | receipt_okay = true; 76 | ++count; 77 | }); 78 | ++count; 79 | }); 80 | gfix.contact_a->send_action(msg); 81 | gfix.wait_while([&]() { 82 | return count < 3; 83 | }); 84 | con1.disconnect(); 85 | con2.disconnect(); 86 | con3.disconnect(); 87 | 88 | TS_ASSERT_EQUALS(std::string(recv_message), std::string(msg)); 89 | TS_ASSERT_EQUALS(std::string(send_message), std::string(msg)); 90 | TS_ASSERT_EQUALS(receipt_okay, true); 91 | } 92 | }; 93 | -------------------------------------------------------------------------------- /src/tox/types.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #include "types.h" 20 | #include "core.h" 21 | 22 | extern "C" 23 | { 24 | #if defined _WIN32 || defined __CYGWIN__ 25 | #include 26 | #else 27 | #include 28 | #endif 29 | } 30 | 31 | using namespace toxmm; 32 | 33 | std::string contactAddr::to_hex() { 34 | return core::to_hex(m_addr.begin(), m_addr.size()); 35 | } 36 | 37 | decltype(contactAddr::m_addr) contactAddr::from_hex(const std::string& hex) { 38 | decltype(contactAddr::m_addr) tmp; 39 | auto tmp_hex = core::from_hex(hex); 40 | std::copy(tmp_hex.begin(), tmp_hex.begin() + std::min(tmp_hex.size(), tmp.size()), tmp.begin()); 41 | return tmp; 42 | } 43 | 44 | std::string contactAddrPublic::to_hex() { 45 | return core::to_hex(m_addr.begin(), m_addr.size()); 46 | } 47 | 48 | decltype(contactAddrPublic::m_addr) contactAddrPublic::from_hex(const std::string& hex) { 49 | decltype(contactAddrPublic::m_addr) tmp; 50 | auto tmp_hex = core::from_hex(hex); 51 | std::copy(tmp_hex.begin(), tmp_hex.begin() + std::min(tmp_hex.size(), tmp.size()), tmp.begin()); 52 | return tmp; 53 | } 54 | 55 | std::string fileId::to_hex() { 56 | return core::to_hex(m_id.begin(), m_id.size()); 57 | } 58 | 59 | decltype(fileId::m_id) fileId::from_hex(const std::string& hex) { 60 | decltype(fileId::m_id) tmp; 61 | auto tmp_hex = core::from_hex(hex); 62 | std::copy(tmp_hex.begin(), tmp_hex.begin() + std::min(tmp_hex.size(), tmp.size()), tmp.begin()); 63 | return tmp; 64 | } 65 | 66 | std::string hash::to_hex() { 67 | return core::to_hex(m_hash.begin(), m_hash.size()); 68 | } 69 | 70 | decltype(hash::m_hash) hash::from_hex(const std::string& hex) { 71 | decltype(hash::m_hash) tmp; 72 | auto tmp_hex = core::from_hex(hex); 73 | std::copy(tmp_hex.begin(), tmp_hex.begin() + std::min(tmp_hex.size(), tmp.size()), tmp.begin()); 74 | return tmp; 75 | } 76 | 77 | uniqueId uniqueId::create_random() { 78 | #if defined _WIN32 || defined __CYGWIN__ 79 | UUID uuid; 80 | UuidCreate(&uuid); 81 | 82 | unsigned char* str; 83 | UuidToStringA(&uuid, &str ); 84 | 85 | std::string s((char*) str ); 86 | 87 | RpcStringFreeA(&str ); 88 | #else 89 | uuid_t uuid; 90 | uuid_generate(uuid); 91 | char s[37]; 92 | uuid_unparse(uuid, s); 93 | #endif 94 | return uniqueId(s); 95 | } 96 | -------------------------------------------------------------------------------- /src/tox/utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef INST_PROP 20 | #define INST_PROP(t, a, n) \ 21 | protected: \ 22 | Glib::Property m_ ## a{*this, n}; \ 23 | public: \ 24 | Glib::PropertyProxy a() { \ 25 | return {this, n}; \ 26 | } \ 27 | Glib::PropertyProxy_ReadOnly a() const { \ 28 | return {this, n}; \ 29 | } 30 | #endif 31 | #ifndef INST_PROP_RO 32 | #define INST_PROP_RO(t, a, n) \ 33 | protected: \ 34 | Glib::Property m_ ## a{*this, n}; \ 35 | public: \ 36 | Glib::PropertyProxy_ReadOnly a() { \ 37 | return {this, n}; \ 38 | } 39 | #endif 40 | #ifndef INST_SIGNAL 41 | #define INST_SIGNAL(n, ...) \ 42 | protected: \ 43 | using type_ ## n = sigc::signal<__VA_ARGS__>; \ 44 | type_ ## n m_ ## n; \ 45 | public: \ 46 | const type_ ## n n() const { \ 47 | return m_ ## n; \ 48 | } \ 49 | type_ ## n n() { \ 50 | return m_ ## n; \ 51 | } 52 | #endif 53 | -------------------------------------------------------------------------------- /src/utils/audio_notification.cpp: -------------------------------------------------------------------------------- 1 | #include "audio_notification.h" 2 | 3 | using namespace utils; 4 | 5 | std::vector audio_notification::m_others; 6 | 7 | audio_notification::audio_notification(const Glib::ustring& audio_uri) { 8 | m_audio_player.property_uri() = audio_uri; 9 | 10 | m_audio_player.signal_error().connect(sigc::track_obj([this](Glib::ustring error) { 11 | std::cerr << "GSTREAMER-ERROR: " << error << std::endl; 12 | delete this; 13 | }, *this)); 14 | m_audio_player.property_position().signal_changed().connect(sigc::track_obj([this]() { 15 | delete this; 16 | }, *this)); 17 | 18 | m_audio_player.property_volume() = 1; 19 | m_audio_player.property_state() = Gst::STATE_PLAYING; 20 | 21 | for (auto n : m_others) { 22 | n->m_audio_player.property_volume() = 0; 23 | } 24 | m_others.push_back(this); 25 | } 26 | 27 | audio_notification::~audio_notification() { 28 | auto iter = std::find( 29 | m_others.begin(), 30 | m_others.end(), 31 | this); 32 | if (iter != m_others.end()) { 33 | m_others.erase(iter); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/utils/audio_notification.h: -------------------------------------------------------------------------------- 1 | #ifndef GTOX_NOTIFICATION_H 2 | #define GTOX_NOTIFICATION_H 3 | 4 | #include 5 | #include "gstreamer.h" 6 | 7 | namespace utils { 8 | class audio_notification { 9 | private: 10 | static std::vector m_others; 11 | 12 | gstreamer m_audio_player; 13 | 14 | public: 15 | audio_notification(const audio_notification&) = delete; 16 | audio_notification(const Glib::ustring& audio_uri); 17 | 18 | void operator=(const audio_notification&) = delete; 19 | 20 | ~audio_notification(); 21 | }; 22 | } 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/utils/builder.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2015 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #include "builder.h" 21 | 22 | using namespace utils; 23 | 24 | builder::builder(const Glib::RefPtr builder): 25 | m_builder(builder) { 26 | } 27 | 28 | Glib::RefPtr builder::operator->() { 29 | return m_builder; 30 | } 31 | 32 | GtkWidget* builder::get_cwidget(const Glib::ustring& name) 33 | { 34 | GObject *cobject = gtk_builder_get_object (m_builder->gobj(), name.c_str()); 35 | if(!cobject) { 36 | throw std::runtime_error(std::string() + "gToxBuilder - widget \"" + name + "\"not found"); 37 | } 38 | 39 | if (!GTK_IS_WIDGET (cobject)) { 40 | throw std::runtime_error("gToxBuilder - not a widget"); 41 | return 0; 42 | } 43 | 44 | return GTK_WIDGET(cobject); 45 | } 46 | -------------------------------------------------------------------------------- /src/utils/dispatcher.h: -------------------------------------------------------------------------------- 1 | #ifndef DISPATCHER_H 2 | #define DISPATCHER_H 3 | #include 4 | #include 5 | 6 | #ifndef SIGC_CPP11_HACK 7 | #define SIGC_CPP11_HACK 8 | namespace sigc { 9 | SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE 10 | } 11 | #endif 12 | 13 | namespace utils { 14 | /** 15 | * @brief The Dispatcher, executes given function on gtk main loop. 16 | * 17 | * Makes sure the class-instance with the dispatcher still exists. 18 | * Simplifies multithreading programming a lot. 19 | */ 20 | class dispatcher { 21 | public: 22 | /** 23 | * Makes a weak reference to a Dispatcher. 24 | * Needed when you don't join threads in the class-instance with the dispatcher. 25 | */ 26 | class ref { 27 | private: 28 | std::weak_ptr m_exists; 29 | public: 30 | ref(const dispatcher& o): m_exists(o.m_exists) {} 31 | template sigc::connection emit(T f) const { 32 | std::weak_ptr weak = m_exists; 33 | return Glib::signal_idle().connect([f, weak]() { 34 | auto strong = weak.lock(); 35 | if (strong) { 36 | f(); 37 | } 38 | return false; 39 | }); 40 | } 41 | }; 42 | 43 | friend class dispatcher::ref; 44 | private: 45 | std::shared_ptr m_exists = std::make_shared(true); 46 | public: 47 | template sigc::connection emit(T f) const { 48 | std::weak_ptr weak = m_exists; 49 | return Glib::signal_idle().connect([f, weak]() { 50 | auto strong = weak.lock(); 51 | //make sure our dispatcher still exists ! 52 | if (strong) { 53 | f(); 54 | } 55 | return false; 56 | }); 57 | } 58 | dispatcher() {} 59 | dispatcher(const dispatcher&) = delete; 60 | void operator=(const dispatcher&) = delete; 61 | }; 62 | } 63 | #endif 64 | -------------------------------------------------------------------------------- /src/utils/gstreamer.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef GTOX_GSTREAMER_H 20 | #define GTOX_GSTREAMER_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "dispatcher.h" 27 | #include "utils/debug.h" 28 | 29 | namespace utils { 30 | class gstreamer: public Glib::Object, public debug::track_obj { 31 | private: 32 | utils::dispatcher m_dispatcher; 33 | 34 | Glib::RefPtr m_playbin; 35 | Glib::RefPtr m_appsink; 36 | 37 | Glib::RefPtr m_uri_binding; 38 | Glib::RefPtr m_volume; 39 | 40 | void init(); 41 | void destroy(); 42 | 43 | public: 44 | auto property_uri() -> Glib::PropertyProxy; 45 | auto property_state() -> Glib::PropertyProxy; 46 | auto property_position() -> Glib::PropertyProxy_ReadOnly; 47 | auto property_duration() -> Glib::PropertyProxy_ReadOnly; 48 | auto property_volume() -> Glib::PropertyProxy; 49 | auto property_pixbuf() -> Glib::PropertyProxy_ReadOnly>; 50 | 51 | using type_signal_error = sigc::signal; 52 | 53 | auto signal_error() -> type_signal_error; 54 | 55 | gstreamer(); 56 | virtual ~gstreamer(); 57 | 58 | gstreamer(const gstreamer&) = delete; 59 | void operator=(const gstreamer&) = delete; 60 | 61 | void set_position(gint64 pos); 62 | 63 | // ! the following function will block ! 64 | static std::pair has_video_audio(Glib::ustring uri); 65 | // ! the following function will block ! 66 | static Glib::RefPtr get_video_preview(Glib::ustring uri); 67 | 68 | private: 69 | Glib::Property m_property_uri; 70 | Glib::Property m_property_state; 71 | Glib::Property m_property_position; 72 | Glib::Property m_property_duration; 73 | Glib::Property m_property_volume; 74 | Glib::Property> m_property_pixbuf; 75 | 76 | type_signal_error m_signal_error; 77 | 78 | static Glib::RefPtr extract_frame(Glib::RefPtr sample, 79 | std::shared_ptr > resolution); 80 | }; 81 | } 82 | #endif 83 | -------------------------------------------------------------------------------- /src/utils/storage.cpp: -------------------------------------------------------------------------------- 1 | #include "storage.h" 2 | #include 3 | #include 4 | using namespace utils; 5 | 6 | storage::storage() { 7 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 8 | } 9 | 10 | void storage::set_prefix_key(const std::string& prefix) { 11 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { prefix }); 12 | m_prefix = prefix; 13 | } 14 | 15 | void storage::load(const std::initializer_list& key, std::vector& data) { 16 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { std::vector(key), data }); 17 | auto file_path = get_path_for_key(key); 18 | 19 | //open file 20 | auto file = Gio::File::create_for_path(file_path); 21 | //read file 22 | Glib::RefPtr stream; 23 | if (file->query_exists()) { 24 | try { 25 | stream = file->read(); 26 | } catch (Gio::Error) { 27 | //couldn't read the file 28 | //lets ignore it for now.. 29 | } 30 | } 31 | if (!stream) { 32 | //file not found 33 | data.clear(); 34 | return; 35 | } 36 | data.resize(stream->query_info()->get_size()); 37 | gsize size; 38 | stream->read_all((void*)data.data(), data.size(), size); 39 | } 40 | 41 | void storage::save(const std::initializer_list& key, const std::vector& data) { 42 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { std::vector(key) }); 43 | auto file_path = get_path_for_key(key); 44 | 45 | //open file 46 | auto file = Gio::File::create_for_path(file_path); 47 | auto parent = file->get_parent(); 48 | //make sure folder exists 49 | if (parent) { 50 | if (!Glib::file_test(parent->get_path(), Glib::FILE_TEST_IS_DIR)) { 51 | parent->make_directory_with_parents(); 52 | } 53 | } 54 | //replace file 55 | auto stream = file->replace(); 56 | stream->truncate(0); 57 | stream->write_bytes(Glib::Bytes::create((gconstpointer)data.data(), data.size())); 58 | stream->close(); 59 | } 60 | 61 | std::string storage::get_path_for_key(const std::initializer_list& key) { 62 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { std::vector(key) }); 63 | std::string file_path = Glib::build_filename(Glib::get_user_config_dir(), 64 | "gtox"); 65 | if (!m_prefix.empty()) { 66 | file_path = Glib::build_filename(file_path, m_prefix); 67 | } 68 | for(auto item : key) { 69 | file_path = Glib::build_filename(file_path, item); 70 | } 71 | file_path += ".bin"; 72 | 73 | return file_path; 74 | } 75 | 76 | storage::~storage() { 77 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 78 | } 79 | -------------------------------------------------------------------------------- /src/utils/storage.h: -------------------------------------------------------------------------------- 1 | #ifndef STORAGE_H 2 | #define STORAGE_H 3 | #include 4 | #include "tox/storage.h" 5 | #include "utils/debug.h" 6 | 7 | namespace utils { 8 | class storage : public toxmm::storage, public debug::track_obj { 9 | friend class main; 10 | private: 11 | std::string m_prefix; 12 | 13 | public: 14 | storage(); 15 | virtual ~storage(); 16 | 17 | protected: 18 | void set_prefix_key(const std::string& prefix) override; 19 | void load(const std::initializer_list& key, std::vector& data) override; 20 | void save(const std::initializer_list& key, const std::vector& data) override; 21 | 22 | std::string get_path_for_key(const std::initializer_list& key); 23 | }; 24 | } 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/utils/webcam.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef GTOX_WEBCAM_H 20 | #define GTOX_WEBCAM_H 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include "dispatcher.h" 27 | #include "utils/debug.h" 28 | 29 | namespace utils { 30 | class webcam: public Glib::Object, public debug::track_obj { 31 | private: 32 | utils::dispatcher m_dispatcher; 33 | 34 | Glib::RefPtr m_pipeline; 35 | Glib::RefPtr m_appsink; 36 | 37 | void init(); 38 | void destroy(); 39 | 40 | public: 41 | auto property_device()-> Glib::PropertyProxy>; 42 | auto property_state() -> Glib::PropertyProxy; 43 | auto property_pixbuf()-> Glib::PropertyProxy_ReadOnly>; 44 | 45 | using type_signal_error = sigc::signal; 46 | 47 | auto signal_error() -> type_signal_error; 48 | 49 | webcam(); 50 | virtual ~webcam(); 51 | 52 | webcam(const webcam&) = delete; 53 | void operator=(const webcam&) = delete; 54 | 55 | // ! the following function will block ! 56 | static std::vector> get_webcam_devices(); 57 | static Glib::ustring get_webcam_device_name(const std::shared_ptr& device); 58 | // ! the following function will block ! 59 | static std::shared_ptr get_webcam_device_by_name(const Glib::ustring& name); 60 | 61 | private: 62 | Glib::Property> m_property_device; 63 | Glib::Property m_property_state; 64 | Glib::Property> m_property_pixbuf; 65 | 66 | type_signal_error m_signal_error; 67 | 68 | static Glib::RefPtr extract_frame(Glib::RefPtr sample, 69 | std::shared_ptr > resolution); 70 | }; 71 | } 72 | #endif 73 | -------------------------------------------------------------------------------- /src/widget/avatar.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2015 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef WIDGETAVATAR_H 21 | #define WIDGETAVATAR_H 22 | 23 | #include 24 | #include "utils/builder.h" 25 | #include "utils/dispatcher.h" 26 | #include "tox/types.h" 27 | #include "utils/debug.h" 28 | 29 | namespace widget { 30 | class avatar : public Gtk::Image, public utils::debug::track_obj { 31 | public: 32 | avatar() {} 33 | avatar(toxmm::contactAddrPublic addr); 34 | avatar(BaseObjectType* cobject, 35 | utils::builder, 36 | toxmm::contactAddrPublic addr); 37 | virtual ~avatar(); 38 | 39 | void load(toxmm::contactAddrPublic addr); 40 | void save_for(toxmm::contactAddrPublic addr); 41 | 42 | protected: 43 | bool on_draw(const Cairo::RefPtr& cr) override; 44 | Gtk::SizeRequestMode get_request_mode_vfunc() const override; 45 | void get_preferred_width_vfunc(int& minimum_width, 46 | int& natural_width) const override; 47 | void get_preferred_height_vfunc(int& minimum_height, 48 | int& natural_height) const override; 49 | 50 | private: 51 | class image: public Glib::Object { 52 | public: 53 | Glib::PropertyProxy> property_pixbuf(); 54 | 55 | image(toxmm::contactAddrPublic addr); 56 | 57 | private: 58 | Glib::Property> m_property_pixbuf; 59 | 60 | Glib::RefPtr m_file; 61 | Glib::RefPtr m_monitor; 62 | utils::dispatcher m_dispatcher; 63 | int m_version = 0; 64 | 65 | void load(); 66 | }; 67 | 68 | Glib::RefPtr m_binding; 69 | }; 70 | } 71 | #endif 72 | -------------------------------------------------------------------------------- /src/widget/chat_action.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #include "chat_action.h" 20 | 21 | using namespace widget; 22 | 23 | chat_action::label::label(Glib::PropertyProxy_ReadOnly name, 24 | Glib::DateTime time, 25 | const Glib::ustring& message): 26 | widget::label(message), 27 | m_name(name), 28 | m_time(time) { 29 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { 30 | name.get_value().raw(), 31 | time.format("%c").raw(), 32 | message.raw() 33 | }); 34 | } 35 | 36 | Glib::ustring chat_action::label::get_selection() { 37 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 38 | auto selection = widget::label::get_selection(); 39 | if (selection.length() == get_text().length()) { 40 | selection = Glib::ustring::compose("[%2] %1 %3", 41 | m_name, 42 | m_time.format("%c"), 43 | selection); 44 | } 45 | return selection; 46 | } 47 | 48 | chat_action::chat_action(Glib::PropertyProxy_ReadOnly name, 49 | Glib::DateTime time, 50 | const Glib::ustring& text): 51 | m_label(name, time.to_local(), text) { 52 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { 53 | name.get_value().raw(), 54 | time.format("%c").raw(), 55 | text.raw() 56 | }); 57 | m_username.show(); 58 | m_username.get_style_context()->add_class("gtox-action-username"); 59 | m_username.property_valign() = Gtk::ALIGN_START; 60 | 61 | m_username_binding = Glib::Binding::bind_property( 62 | name, 63 | m_username.property_label(), 64 | Glib::BINDING_DEFAULT | Glib::BINDING_SYNC_CREATE); 65 | 66 | show(); 67 | add(m_hbox); 68 | m_hbox.show(); 69 | m_hbox.add(m_username); 70 | m_hbox.add(m_label); 71 | property_reveal_child() = false; 72 | m_dispatcher.emit([this]() { 73 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 74 | property_reveal_child() = true; 75 | }); 76 | } 77 | 78 | chat_action::~chat_action() { 79 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 80 | } 81 | -------------------------------------------------------------------------------- /src/widget/chat_action.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef WIDGETCHATACTIONREAL_H 20 | #define WIDGETCHATACTIONREAL_H 21 | 22 | #include 23 | #include "label.h" 24 | #include "utils/debug.h" 25 | #include "utils/dispatcher.h" 26 | 27 | namespace widget { 28 | class chat_action : public Gtk::Revealer, public utils::debug::track_obj { 29 | private: 30 | class label: public widget::label { 31 | private: 32 | Glib::PropertyProxy_ReadOnly m_name; 33 | Glib::DateTime m_time; 34 | public: 35 | label(Glib::PropertyProxy_ReadOnly name, 36 | Glib::DateTime time, 37 | const Glib::ustring& message); 38 | virtual Glib::ustring get_selection() override; 39 | virtual ~label() {} 40 | }; 41 | 42 | Gtk::HBox m_hbox; 43 | Gtk::Label m_username; 44 | label m_label; 45 | utils::dispatcher m_dispatcher; 46 | 47 | Glib::RefPtr m_username_binding; 48 | 49 | public: 50 | chat_action(Glib::PropertyProxy_ReadOnly name, 51 | Glib::DateTime time, 52 | const Glib::ustring& text); 53 | virtual ~chat_action(); 54 | }; 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /src/widget/chat_bubble.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef WIDGET_CHAT_BUBBLE_H 20 | #define WIDGET_CHAT_BUBBLE_H 21 | 22 | #include 23 | #include "utils/builder.h" 24 | #include "utils/dispatcher.h" 25 | #include "tox/types.h" 26 | #include "utils/debug.h" 27 | 28 | namespace widget { 29 | class avatar; 30 | class chat_bubble: public Gtk::Revealer, public utils::debug::track_obj { 31 | private: 32 | utils::dispatcher m_dispatcher; 33 | 34 | avatar* m_avatar; 35 | Gtk::Box* m_row_box; 36 | Gtk::Label* m_username; 37 | Gtk::Frame* m_frame; 38 | 39 | Glib::RefPtr m_binding_name; 40 | 41 | void init(utils::builder builder); 42 | 43 | public: 44 | chat_bubble(BaseObjectType* cobject, 45 | utils::builder builder, 46 | Glib::PropertyProxy_ReadOnly name, 47 | Glib::PropertyProxy_ReadOnly addr, 48 | Glib::DateTime time); 49 | virtual ~chat_bubble(); 50 | 51 | void add_row(Gtk::Widget& widget); 52 | 53 | static utils::builder::ref create(std::shared_ptr core, Glib::DateTime time); 54 | static utils::builder::ref create(std::shared_ptr contact, Glib::DateTime time); 55 | }; 56 | } 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /src/widget/chat_file.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef WIDGETCHATFILERECV_H 20 | #define WIDGETCHATFILERECV_H 21 | #include "tox/types.h" 22 | #include "utils/dispatcher.h" 23 | #include 24 | #include "utils/builder.h" 25 | #include 26 | #include "widget/imagescaled.h" 27 | #include "widget/videoplayer.h" 28 | #include 29 | #include "utils/debug.h" 30 | #include "widget/chat_file_popover.h" 31 | #include "config.h" 32 | 33 | namespace widget { 34 | class file: public Gtk::Frame, public utils::debug::track_obj { 35 | private: 36 | std::shared_ptr m_file; 37 | utils::dispatcher m_dispatcher; 38 | 39 | Gtk::Spinner* m_spinner; 40 | Gtk::Label* m_file_name; 41 | Gtk::Button* m_file_info; 42 | Gtk::Button* m_file_info_2; 43 | Gtk::Revealer* m_preview_revealer; 44 | Gtk::Revealer* m_info_revealer; 45 | Gtk::Box* m_preview; 46 | Gtk::EventBox* m_eventbox; 47 | Gtk::Image* m_net_icon; 48 | 49 | sigc::connection m_leave_timer; 50 | 51 | widget::imagescaled m_preview_image; 52 | widget::videoplayer* m_preview_video; 53 | 54 | widget::chat_file_popover m_file_info_popover; 55 | 56 | std::vector> m_bindings; 57 | 58 | std::thread m_preview_thread; 59 | 60 | bool m_display_inline; 61 | 62 | public: 63 | file(BaseObjectType* cobject, 64 | utils::builder builder, 65 | const std::shared_ptr& file, 66 | const std::shared_ptr& config); 67 | virtual ~file(); 68 | static utils::builder::ref create(const std::shared_ptr& file, 69 | const std::shared_ptr& config); 70 | static utils::builder::ref create(const Glib::ustring& file_path, 71 | const std::shared_ptr& config); 72 | 73 | protected: 74 | void update_complete(); 75 | }; 76 | 77 | } 78 | #endif 79 | -------------------------------------------------------------------------------- /src/widget/chat_file_popover.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef WIDGETPOPOVERFILE_H 20 | #define WIDGETPOPOVERFILE_H 21 | 22 | #include 23 | #include "utils/debug.h" 24 | #include "tox/types.h" 25 | 26 | namespace widget { 27 | class chat_file_popover: public Gtk::Popover, public utils::debug::track_obj { 28 | private: 29 | std::shared_ptr m_file; 30 | 31 | Gtk::Box* m_body; 32 | Gtk::ToggleButton* m_file_resume; 33 | Gtk::ToggleButton* m_file_cancel; 34 | Gtk::ToggleButton* m_file_pause; 35 | Gtk::ProgressBar* m_file_progress; 36 | Gtk::Widget* m_file_open_bar; 37 | Gtk::Label* m_file_speed; 38 | Gtk::Label* m_file_size; 39 | Gtk::Label* m_file_time; 40 | Gtk::Label* m_file_name; 41 | Gtk::Widget* m_file_control; 42 | Gtk::Button* m_file_dir; 43 | Gtk::Button* m_file_open; 44 | Gtk::Widget* m_file_info_box_1; 45 | Gtk::Widget* m_file_info_box_2; 46 | Gtk::Label* m_status; 47 | 48 | uint64_t m_last_position; 49 | 50 | std::vector> m_bindings; 51 | 52 | public: 53 | chat_file_popover(const std::shared_ptr& file); 54 | ~chat_file_popover(); 55 | 56 | protected: 57 | void update_complete(); 58 | }; 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /src/widget/chat_input.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef WIDGETCHATTEXTVIEW_H 20 | #define WIDGETCHATTEXTVIEW_H 21 | 22 | #include 23 | #include "utils/builder.h" 24 | #include "utils/debug.h" 25 | 26 | namespace widget { 27 | class chat_input: public Gtk::TextView, public utils::debug::track_obj { 28 | private: 29 | Glib::RefPtr m_bold_tag; 30 | Glib::RefPtr m_italic_tag; 31 | Glib::RefPtr m_underline_tag; 32 | 33 | Glib::RefPtr m_buffer; 34 | 35 | public: 36 | chat_input(BaseObjectType* cobject, utils::builder); 37 | virtual ~chat_input(); 38 | 39 | Glib::ustring get_serialized_text(); 40 | }; 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/widget/chat_message.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #include "chat_message.h" 20 | 21 | using namespace widget; 22 | 23 | chat_message::label::label(Glib::PropertyProxy_ReadOnly name, 24 | Glib::DateTime time, 25 | const Glib::ustring& message): 26 | widget::label(message), 27 | m_name(name), 28 | m_time(time) { 29 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { 30 | name.get_value().raw(), 31 | time.format("%c").raw() 32 | }); 33 | } 34 | 35 | Glib::ustring chat_message::label::get_selection() { 36 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 37 | auto selection = widget::label::get_selection(); 38 | if (selection.length() == get_text().length()) { 39 | selection = Glib::ustring::compose("[%2] %1: %3", 40 | m_name, 41 | m_time.format("%c"), 42 | selection); 43 | } 44 | return selection; 45 | } 46 | 47 | chat_message::chat_message(Glib::PropertyProxy_ReadOnly name, 48 | Glib::DateTime time, 49 | const Glib::ustring& text): 50 | m_label(name, time.to_local(), text) { 51 | utils::debug::scope_log log(DBG_LVL_1("gtox"), { 52 | name.get_value().raw(), 53 | time.format("%c").raw() 54 | }); 55 | show(); 56 | add(m_label); 57 | property_reveal_child() = false; 58 | m_dispatcher.emit([this]() { 59 | utils::debug::scope_log log(DBG_LVL_1("gtox"), {}); 60 | property_reveal_child() = true; 61 | }); 62 | } 63 | -------------------------------------------------------------------------------- /src/widget/chat_message.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see 18 | **/ 19 | #ifndef WIDGETCHATMESSAGEREAL_H 20 | #define WIDGETCHATMESSAGEREAL_H 21 | 22 | #include 23 | #include "label.h" 24 | #include "utils/debug.h" 25 | #include "utils/dispatcher.h" 26 | 27 | namespace widget { 28 | class chat_message : public Gtk::Revealer, public utils::debug::track_obj { 29 | private: 30 | class label: public widget::label { 31 | private: 32 | Glib::PropertyProxy_ReadOnly m_name; 33 | Glib::DateTime m_time; 34 | public: 35 | label(Glib::PropertyProxy_ReadOnly name, 36 | Glib::DateTime time, 37 | const Glib::ustring& message); 38 | virtual Glib::ustring get_selection() override; 39 | virtual ~label() {} 40 | }; 41 | 42 | label m_label; 43 | utils::dispatcher m_dispatcher; 44 | 45 | public: 46 | chat_message(Glib::PropertyProxy_ReadOnly name, 47 | Glib::DateTime time, 48 | const Glib::ustring& text); 49 | }; 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /src/widget/contact.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2014 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef WIDGETCONTACTLISTITEM_H 21 | #define WIDGETCONTACTLISTITEM_H 22 | 23 | #include 24 | #include "widget/avatar.h" 25 | #include "tox/types.h" 26 | #include "utils/builder.h" 27 | #include "utils/dispatcher.h" 28 | #include "utils/debug.h" 29 | 30 | namespace dialog { 31 | class main; 32 | class chat; 33 | } 34 | 35 | namespace widget { 36 | class contact : public Gtk::ListBoxRow, public utils::debug::track_obj { 37 | private: 38 | dialog::main& m_main; 39 | std::shared_ptr m_chat; 40 | 41 | utils::dispatcher m_dispatcher; 42 | 43 | std::shared_ptr m_contact; 44 | 45 | widget::avatar* m_avatar; 46 | widget::avatar* m_avatar_mini; 47 | 48 | Gtk::Label* m_name; 49 | Gtk::Label* m_status_msg; 50 | Gtk::Image* m_status_icon; 51 | Gtk::Spinner* m_spin; 52 | 53 | Gtk::Label* m_name_mini; 54 | Gtk::Label* m_status_msg_mini; 55 | Gtk::Image* m_status_icon_mini; 56 | Gtk::Spinner* m_spin_mini; 57 | 58 | Gtk::Widget* m_contact_list_grid_mini; 59 | Gtk::Widget* m_contact_list_grid; 60 | 61 | Gtk::Revealer* m_revealer; 62 | 63 | Glib::RefPtr m_bindings[7]; 64 | 65 | bool m_for_active_chats; 66 | bool m_played_online_sound; 67 | 68 | public: 69 | contact(BaseObjectType* cobject, 70 | utils::builder builder, 71 | dialog::main& main, 72 | std::shared_ptr contact, 73 | bool for_active_chats=false); 74 | virtual ~contact(); 75 | 76 | static utils::builder::ref create(dialog::main& main, 77 | std::shared_ptr contact, 78 | bool for_active_chats=false); 79 | 80 | //! for sort 81 | int compare(contact* other); 82 | 83 | std::shared_ptr get_contact(); 84 | void activated(); 85 | 86 | protected: 87 | void on_show(); 88 | void on_hide(); 89 | }; 90 | } 91 | #endif 92 | -------------------------------------------------------------------------------- /src/widget/imagescaled.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2015 Luca Béla Palkovics 5 | Copyright (C) 2015 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef WIDGETIMAGESCALED_H 21 | #define WIDGETIMAGESCALED_H 22 | 23 | #include 24 | #include "utils/builder.h" 25 | #include "utils/dispatcher.h" 26 | #include "utils/debug.h" 27 | 28 | namespace widget { 29 | class imagescaled : public Gtk::Image, public utils::debug::track_obj { 30 | public: 31 | imagescaled(); 32 | imagescaled(BaseObjectType* cobject, 33 | utils::builder); 34 | ~imagescaled(); 35 | 36 | private: 37 | void calculate_size(int w, int h, 38 | double& out_pw, double& out_ph, 39 | double& out_scale) const; 40 | 41 | protected: 42 | bool on_draw(const Cairo::RefPtr& cr) override; 43 | Gtk::SizeRequestMode get_request_mode_vfunc() const override; 44 | void get_preferred_width_vfunc(int& minimum_width, 45 | int& natural_width) const override; 46 | void get_preferred_height_vfunc(int& minimum_height, 47 | int& natural_height) const override; 48 | void get_preferred_height_for_width_vfunc( 49 | int width, 50 | int& minimum_height, 51 | int& natural_height) const override; 52 | void get_preferred_width_for_height_vfunc( 53 | int height, 54 | int& minimum_width, 55 | int& natural_width) const override; 56 | }; 57 | } 58 | #endif 59 | -------------------------------------------------------------------------------- /src/widget/label.h: -------------------------------------------------------------------------------- 1 | /** 2 | gTox a GTK-based tox-client - https://github.com/KoKuToru/gTox.git 3 | 4 | Copyright (C) 2014 Luca Béla Palkovics 5 | Copyright (C) 2014 Maurice Mohlek 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see 19 | **/ 20 | #ifndef WIDGETCHATMESSAGE_H 21 | #define WIDGETCHATMESSAGE_H 22 | 23 | #include 24 | #include "utils/debug.h" 25 | 26 | namespace widget { 27 | class label : public Gtk::DrawingArea, public utils::debug::track_obj