├── share └── ring │ └── bootstrap │ └── servers.json ├── doc ├── Diagram1.dia └── Diagram2.dia ├── .gitignore ├── .gitreview ├── .tx └── config ├── README.md ├── cmake ├── winBuild.cmake ├── winBuild64.cmake ├── FindCppunit.cmake ├── LibRingClientConfig.cmake.in ├── FindRing.cmake └── cmake_uninstall.cmake.in ├── src ├── web-chatview │ ├── .eslintrc.json │ ├── web.gresource.xml │ ├── chatview-gnome.css │ ├── README │ ├── linkify-string.js │ └── previewInfo.js ├── webresource.qrc ├── renderer.cpp ├── directrenderer.h ├── shmrenderer.h ├── api │ ├── chatview.h │ ├── contact.h │ ├── member.h │ ├── video.h │ ├── peerdiscoverymodel.h │ ├── profile.h │ ├── newcodecmodel.h │ ├── newdevicemodel.h │ ├── conversation.h │ ├── lrc.h │ ├── behaviorcontroller.h │ ├── datatransfermodel.h │ └── datatransfer.h ├── dbus │ ├── videomanager.h │ ├── pluginmanager.h │ ├── presencemanager.h │ ├── instancemanager.h │ ├── callmanager.h │ ├── configurationmanager.h │ ├── videomanager.cpp │ ├── pluginmanager.cpp │ ├── presencemanager.cpp │ ├── callmanager.cpp │ ├── configurationmanager.cpp │ ├── instancemanager.cpp │ └── metatypes.h ├── behaviorcontroller.cpp ├── dbuserrorhandlerdefault.cpp ├── dbuserrorhandlerdefault.h ├── interfaces │ ├── dbuserrorhandleri.h │ └── pixmapmanipulatori.h ├── qtwrapper │ ├── CMakeLists.txt │ ├── instancemanager_wrap.h │ ├── videomanager_wrap.cpp │ ├── instancemanager.cpp │ ├── pluginmanager_wrap.h │ └── pluginmanagerMock.cpp ├── private │ ├── namedirectory_p.h │ └── smartInfoHub_p.h ├── renderer.h ├── smartinfohub.h ├── authority │ ├── daemon.cpp │ └── daemon.h ├── pixmapmanipulatordefault.h ├── namedirectory.h ├── pixmapmanipulatordefault.cpp ├── globalinstances.h ├── directrenderer.cpp ├── globalinstances.cpp ├── chatview.cpp ├── peerdiscoverymodel.cpp ├── vcard.h ├── namedirectory.cpp ├── smartinfohub.cpp └── messagelistmodel.h ├── .clang-format ├── make-lrc.py └── INSTALL /share/ring/bootstrap/servers.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"host": "bootstrap.jami.net", "port": 4222} 3 | ] 4 | -------------------------------------------------------------------------------- /doc/Diagram1.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/savoirfairelinux/jami-libclient/HEAD/doc/Diagram1.dia -------------------------------------------------------------------------------- /doc/Diagram2.dia: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/savoirfairelinux/jami-libclient/HEAD/doc/Diagram2.dia -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | build/ 3 | build-local/ 4 | build-qml/ 5 | 6 | msvc/ 7 | translations/*.qm 8 | CMakeLists.txt.user 9 | -------------------------------------------------------------------------------- /.gitreview: -------------------------------------------------------------------------------- 1 | [gerrit] 2 | host=review.jami.net 3 | port=29420 4 | project=jami-libclient.git 5 | defaultremote=origin 6 | defaultbranch=master 7 | -------------------------------------------------------------------------------- /.tx/config: -------------------------------------------------------------------------------- 1 | [main] 2 | host = https://www.transifex.com 3 | 4 | [jami.lrc_en_ts] 5 | file_filter = translations/lrc_.ts 6 | source_file = translations/lrc_en.ts 7 | source_lang = en 8 | type = TS 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libringclient 2 | 3 | libringclient is a client library for Jami 4 | 5 | For more information about the Jami project, see the following: 6 | - Main website: https://jami.net 7 | - Bug tracker: https://git.jami.net 8 | - Repositories: https://review.jami.net 9 | 10 | For build/install instructions, see the INSTALL file. 11 | -------------------------------------------------------------------------------- /cmake/winBuild.cmake: -------------------------------------------------------------------------------- 1 | # this one is important 2 | SET(CMAKE_SYSTEM_NAME Windows) 3 | 4 | # specify the cross compiler 5 | SET(CMAKE_C_COMPILER i686-w64-mingw32-gcc) 6 | SET(CMAKE_CXX_COMPILER i686-w64-mingw32-g++) 7 | SET(CMAKE_RC_COMPILER i686-w64-mingw32-windres) 8 | SET(CMAKE_ASM_YASM_COMPILER yasm) 9 | SET(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32/) 10 | set(LIB_FLAGS "-Wl,--output-def,libringclient.def") 11 | -------------------------------------------------------------------------------- /cmake/winBuild64.cmake: -------------------------------------------------------------------------------- 1 | # this one is important 2 | SET(CMAKE_SYSTEM_NAME Windows) 3 | 4 | # specify the cross compiler 5 | SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) 6 | SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) 7 | SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) 8 | SET(CMAKE_ASM_YASM_COMPILER yasm) 9 | SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32/) 10 | set(LIB_FLAGS "-Wl,--output-def,libringclient.def") 11 | -------------------------------------------------------------------------------- /src/web-chatview/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "env": { 3 | "browser": true 4 | }, 5 | "plugins": ["html"], 6 | "extends": "eslint:recommended", 7 | "parserOptions": { 8 | "ecmaVersion": 6 9 | }, 10 | "rules": { 11 | "indent": [ 12 | "error", 13 | 4 14 | ], 15 | "linebreak-style": [ 16 | "error", 17 | "unix" 18 | ], 19 | "quotes": [ 20 | "error", 21 | "double" 22 | ], 23 | "semi": [ 24 | "error", 25 | "never" 26 | ], 27 | "no-inner-declarations": [ 28 | 0 29 | ] 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/web-chatview/web.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | chatview.html 6 | 7 | 8 | chatview.js 9 | linkify.js 10 | linkify-string.js 11 | linkify-html.js 12 | jed.js 13 | emoji.js 14 | 15 | 16 | chatview.css 17 | chatview-gnome.css 18 | emoji.css 19 | fa.css 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /cmake/FindCppunit.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE(FindPkgConfig) 2 | PKG_CHECK_MODULES(PC_CPPUNIT "cppunit") 3 | 4 | FIND_PATH(CPPUNIT_INCLUDE_DIRS 5 | NAMES cppunit/TestCase.h 6 | HINTS ${PC_CPPUNIT_INCLUDE_DIR} 7 | ${CMAKE_INSTALL_PREFIX}/include 8 | PATHS 9 | /usr/local/include 10 | /usr/include 11 | ) 12 | 13 | FIND_LIBRARY(CPPUNIT_LIBRARIES 14 | NAMES cppunit 15 | HINTS ${PC_CPPUNIT_LIBDIR} 16 | ${CMAKE_INSTALL_PREFIX}/lib 17 | ${CMAKE_INSTALL_PREFIX}/lib64 18 | PATHS 19 | ${CPPUNIT_INCLUDE_DIRS}/../lib 20 | /usr/local/lib 21 | /usr/lib 22 | ) 23 | 24 | LIST(APPEND CPPUNIT_LIBRARIES ${CMAKE_DL_LIBS}) 25 | 26 | INCLUDE(FindPackageHandleStandardArgs) 27 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) 28 | MARK_AS_ADVANCED(CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) 29 | -------------------------------------------------------------------------------- /src/webresource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | web-chatview/chatview.css 4 | web-chatview/chatview.html 5 | web-chatview/emoji.js 6 | web-chatview/chatview.js 7 | web-chatview/linkify.js 8 | web-chatview/linkify-html.js 9 | web-chatview/linkify-string.js 10 | web-chatview/previewInfo.js 11 | web-chatview/qwebchannel.js 12 | web-chatview/chatview-qt.css 13 | web-chatview/jed.js 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/web-chatview/chatview-gnome.css: -------------------------------------------------------------------------------- 1 | .internal_mes_wrapper { 2 | margin: 3px 0 0 0; 3 | } 4 | 5 | .message_wrapper { 6 | padding: 1em; 7 | } 8 | 9 | .sender_image { 10 | margin: 10px; 11 | } 12 | 13 | .message_out + .message_out .message_wrapper { 14 | border-top-right-radius: 10px; 15 | } 16 | 17 | .message_in + .message_in .message_wrapper { 18 | border-top-left-radius: 10px; 19 | } 20 | 21 | .message_in + .message_in .sender_image { 22 | visibility: hidden; 23 | } 24 | 25 | .message_out + .message_out .sender_image { 26 | visibility: hidden; 27 | } 28 | 29 | .message_text { 30 | hyphens: auto; 31 | word-break: break-word; 32 | word-wrap: break-word; 33 | } 34 | 35 | .menuoption { 36 | user-select: none; 37 | cursor: pointer; 38 | } 39 | 40 | #sendMessage { 41 | height: var(--navbar-height); 42 | } 43 | 44 | #sendMessage .nav-button, #sendMessage .nav-button.deactivated { 45 | height: 28px; 46 | width: 28px; 47 | margin: 1px; 48 | padding: 2px; 49 | } 50 | -------------------------------------------------------------------------------- /src/web-chatview/README: -------------------------------------------------------------------------------- 1 | # README - chatview 2 | 3 | The chatview runs under a WebKit GTK view. It is written using web technologies 4 | (HTML5/CSS3/JS) and is responsible for displaying everything that deals with the 5 | navbar, the messages, and the message bar. 6 | 7 | ## Contributing - syntax 8 | 9 | We have a set of ESLint rules that define clear syntax rules (web/.eslintrc.json). 10 | 11 | You will need the following tools: 12 | 13 | - ESLint (The pluggable linting utility for JavaScript and JSX) 14 | https://eslint.org/ 15 | - ESLint HTML plugin (eslint-plugin-html) 16 | https://www.npmjs.com/package/eslint-plugin-html 17 | 18 | Before pushing a patch, make sure that it passes ESLint: 19 | $ eslint chatview.html 20 | 21 | Most trivial issues can be fixed using 22 | $ eslint chatview.js --fix 23 | 24 | We will not accept patches introducing non-ESLint-compliant code. 25 | 26 | ## WebKit GTK 27 | 28 | Everything runs under WebKit GTK, that is if you need to write browser specific 29 | code, you will only need to support WebKit (CSS -webkit- prefix). 30 | 31 | Do not use querySelector if getElementById or getElementByClassName can be used 32 | instead. querySelector doesn't always make the code easier and has very bad 33 | performances. 34 | -------------------------------------------------------------------------------- /src/renderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018-2022 Savoir-faire Linux Inc. 3 | * Author: Sébastien Blin 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #include "renderer.h" 20 | 21 | #include 22 | #include 23 | 24 | namespace lrc { 25 | namespace video { 26 | 27 | using namespace lrc::api::video; 28 | 29 | Renderer::Renderer(const QString& id, const QSize& res) 30 | : id_(id) 31 | , size_(res) 32 | , QObject(nullptr) 33 | {} 34 | 35 | Renderer::~Renderer() {} 36 | 37 | QString 38 | Renderer::id() const 39 | { 40 | return id_; 41 | } 42 | 43 | QSize 44 | Renderer::size() const 45 | { 46 | return size_; 47 | } 48 | 49 | void 50 | Renderer::update(const QSize& size, const QString&) 51 | { 52 | size_ = size; 53 | } 54 | 55 | } // namespace video 56 | } // namespace lrc 57 | -------------------------------------------------------------------------------- /src/directrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2022 Savoir-faire Linux Inc. 3 | * Author : Alexandre Lision 4 | * Author: Andreas Traczyk 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library 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 GNU 14 | * Lesser 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 | 20 | #pragma once 21 | 22 | #include "renderer.h" 23 | #include "typedefs.h" 24 | 25 | namespace lrc { 26 | namespace video { 27 | 28 | class DirectRenderer final : public Renderer 29 | { 30 | Q_OBJECT 31 | public: 32 | DirectRenderer(const QString& id, const QSize& res); 33 | ~DirectRenderer(); 34 | 35 | // Renderer interface. 36 | void update(const QSize& res, const QString& shmPath) override; 37 | lrc::api::video::Frame currentFrame() const override; 38 | 39 | public Q_SLOTS: 40 | void startRendering() override; 41 | void stopRendering() override; 42 | 43 | private: 44 | struct Impl; 45 | std::unique_ptr pimpl_; 46 | }; 47 | 48 | } // namespace video 49 | } // namespace lrc 50 | -------------------------------------------------------------------------------- /src/shmrenderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2022 Savoir-faire Linux Inc. 3 | * Author : Emmanuel Lepage Vallee 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "renderer.h" 22 | #include "typedefs.h" 23 | 24 | namespace lrc { 25 | namespace video { 26 | 27 | class ShmRenderer final : public Renderer 28 | { 29 | Q_OBJECT 30 | public: 31 | ShmRenderer(const QString& id, const QSize& res, const QString& shmPath); 32 | ~ShmRenderer(); 33 | 34 | // Renderer interface. 35 | void update(const QSize& res, const QString& shmPath) override; 36 | lrc::api::video::Frame currentFrame() const override; 37 | 38 | void stopShm(); 39 | bool startShm(); 40 | 41 | public Q_SLOTS: 42 | void startRendering() override; 43 | void stopRendering() override; 44 | 45 | private: 46 | struct Impl; 47 | std::unique_ptr pimpl_; 48 | }; 49 | 50 | } // namespace video 51 | } // namespace lrc 52 | -------------------------------------------------------------------------------- /src/api/chatview.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2020-2022 Savoir-faire Linux Inc. * 3 | * Author: Sébastien Blin * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | // Qt 21 | #include 22 | #include 23 | #include 24 | 25 | namespace lrc { 26 | 27 | namespace api { 28 | 29 | namespace chatview { 30 | 31 | QVariantMap getTranslatedStrings(bool qwebview = true); 32 | 33 | } // namespace chatview 34 | } // namespace api 35 | } // namespace lrc 36 | -------------------------------------------------------------------------------- /cmake/LibRingClientConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | INCLUDE(GNUInstallDirs) 4 | 5 | SET(LIB_RING_CLIENT_INCLUDE_DIR @INCLUDE_INSTALL_DIR@/libringclient) 6 | 7 | STRING(REPLACE "${CMAKE_LIBRARY_ARCHITECTURE}" "" SANE_LIBRARY_PATH "${CMAKE_INSTALL_FULL_LIBDIR}" ) 8 | 9 | # First, always set the dynamic path 10 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib;.so;.dll") 11 | SET(LIB_RING_CLIENT_LIBRARY_NAME "ringclient") 12 | 13 | FIND_LIBRARY(LIB_RING_CLIENT_LIBRARY_DYNAMIC NAMES ringclient 14 | PATHS ${RING_BUILD_DIR}/.libs 15 | PATHS @LIB_INSTALL_DIR@ 16 | PATHS ${CMAKE_INSTALL_PREFIX}/libexec ) 17 | 18 | #if ENABLE_STATIC is set, default to the static version 19 | IF(DEFINED ${ENABLE_STATIC} OR ${ENABLE_STATIC} MATCHES true) 20 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.la;.lib") 21 | SET(LIB_RING_CLIENT_LIBRARY_NAME "ringclient_static") 22 | 23 | FIND_LIBRARY(LIB_RING_CLIENT_LIBRARY_STATIC NAMES ringclient_static 24 | PATHS ${RING_BUILD_DIR}/.libs 25 | PATHS @LIB_INSTALL_DIR@ 26 | PATHS ${CMAKE_INSTALL_PREFIX}/libexec ) 27 | ENDIF() 28 | 29 | 30 | FIND_LIBRARY(LIB_RING_CLIENT_LIBRARY NAMES ${LIB_RING_CLIENT_LIBRARY_NAME} 31 | PATHS ${RING_BUILD_DIR}/.libs 32 | PATHS @LIB_INSTALL_DIR@ 33 | PATHS ${CMAKE_INSTALL_PREFIX}/libexec ) 34 | 35 | 36 | # Set the usual CMake library variables. This is required for some other official 37 | # cmake macros to work 38 | INCLUDE(FindPackageHandleStandardArgs) 39 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIB_RING_CLIENT 40 | FOUND_VAR 41 | LIB_RING_CLIENT_FOUND 42 | REQUIRED_VARS 43 | LIB_RING_CLIENT_LIBRARY 44 | LIB_RING_CLIENT_INCLUDE_DIR 45 | VERSION_VAR 46 | @GENERIC_LIB_VERSION@ 47 | ) 48 | -------------------------------------------------------------------------------- /src/dbus/videomanager.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2012-2022 Savoir-faire Linux Inc. * 3 | * Author : Emmanuel Lepage Vallee * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #ifdef ENABLE_TEST 21 | #include "../../test/mocks/videomanager_mock.h" 22 | #else 23 | #ifdef ENABLE_LIBWRAP 24 | #include "videomanager_wrap.h" 25 | #else 26 | #include "video_dbus_interface.h" 27 | #include 28 | #endif 29 | #endif 30 | 31 | #include 32 | 33 | namespace VideoManager { 34 | 35 | LIB_EXPORT VideoManagerInterface& instance(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/dbus/pluginmanager.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2012-2022 Savoir-faire Linux Inc. * 3 | * Author : Aline Gondim Santos * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #ifdef ENABLE_TEST 21 | // #include "../../test/mocks/pluginmanager_mock.h" 22 | #else 23 | #ifdef ENABLE_LIBWRAP 24 | #include "pluginmanager_wrap.h" 25 | #else 26 | #include "plugin_dbus_interface.h" 27 | #include 28 | #endif 29 | #endif 30 | 31 | #include 32 | 33 | namespace PluginManager { 34 | 35 | LIB_EXPORT PluginManagerInterface& instance(); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/dbus/presencemanager.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2012-2022 Savoir-faire Linux Inc. * 3 | * Author : Emmanuel Lepage Vallee * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | #ifdef ENABLE_TEST 20 | #include "../../test/mocks/presencemanager_mock.h" 21 | #else 22 | #ifdef ENABLE_LIBWRAP 23 | #include "../qtwrapper/presencemanager_wrap.h" 24 | #else 25 | #include "presencemanager_dbus_interface.h" 26 | #include 27 | #endif 28 | #endif 29 | 30 | #include 31 | 32 | namespace PresenceManager { 33 | 34 | LIB_EXPORT PresenceManagerInterface& instance(); 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/behaviorcontroller.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Nicolas Jäger * 4 | * Author: Sébastien Blin * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 "api/behaviorcontroller.h" 20 | 21 | // Models and database 22 | #include "api/lrc.h" 23 | 24 | namespace lrc { 25 | 26 | using namespace api; 27 | 28 | BehaviorController::BehaviorController() 29 | : QObject(nullptr) 30 | {} 31 | 32 | BehaviorController::~BehaviorController() {} 33 | 34 | } // namespace lrc 35 | 36 | #include "api/moc_behaviorcontroller.cpp" 37 | -------------------------------------------------------------------------------- /src/dbuserrorhandlerdefault.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2015-2022 Savoir-faire Linux Inc. * 3 | * Author : Stepan Salenikovich * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #include "dbuserrorhandlerdefault.h" 19 | 20 | namespace Interfaces { 21 | 22 | void 23 | DBusErrorHandlerDefault::connectionError(const QString& error) 24 | { 25 | qDebug() << error; 26 | throw error.toLatin1().constData(); 27 | } 28 | 29 | void 30 | DBusErrorHandlerDefault::invalidInterfaceError(const QString& error) 31 | { 32 | qDebug() << error; 33 | throw error.toLatin1().constData(); 34 | } 35 | 36 | } // namespace Interfaces 37 | -------------------------------------------------------------------------------- /src/dbus/instancemanager.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2009-2022 Savoir-faire Linux Inc. * 3 | * Author : Jérémy Quentin * 4 | * Emmanuel Lepage Vallee * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #ifdef ENABLE_TEST 22 | #include "../../test/mocks/instancemanager_mock.h" 23 | #else 24 | #ifdef ENABLE_LIBWRAP 25 | #include "../qtwrapper/instancemanager_wrap.h" 26 | #else 27 | #include "instance_dbus_interface.h" 28 | #include 29 | #endif 30 | #endif 31 | #include 32 | 33 | namespace InstanceManager { 34 | 35 | LIB_EXPORT InstanceManagerInterface& instance(bool muteDring = false); 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/dbuserrorhandlerdefault.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2015-2022 Savoir-faire Linux Inc. * 3 | * Author : Stepan Salenikovich * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include 21 | 22 | #include "interfaces/dbuserrorhandleri.h" 23 | 24 | namespace Interfaces { 25 | 26 | /** 27 | * This implementation of the DBusErrorHandler interface throws an exception with the given message. 28 | */ 29 | class DBusErrorHandlerDefault : public DBusErrorHandlerI 30 | { 31 | public: 32 | [[noreturn]] void connectionError(const QString& error) override; 33 | [[noreturn]] void invalidInterfaceError(const QString& error) override; 34 | }; 35 | 36 | } // namespace Interfaces 37 | -------------------------------------------------------------------------------- /src/dbus/callmanager.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2009-2022 Savoir-faire Linux Inc. * 3 | * Author : Jérémy Quentin * 4 | * Emmanuel Lepage Vallee * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #ifdef ENABLE_TEST 22 | #include "../../test/mocks/callmanager_mock.h" 23 | #else 24 | #ifdef ENABLE_LIBWRAP 25 | #include "../qtwrapper/callmanager_wrap.h" 26 | #else 27 | #include "callmanager_dbus_interface.h" 28 | #include 29 | #endif 30 | #endif 31 | #include 32 | 33 | namespace CallManager { 34 | 35 | /// Singleton to access dbus "CallManager" interface 36 | LIB_EXPORT CallManagerInterface& instance(); 37 | 38 | } // namespace CallManager 39 | -------------------------------------------------------------------------------- /cmake/FindRing.cmake: -------------------------------------------------------------------------------- 1 | # Once done this will define 2 | # ring_INCLUDE_DIRS - include directories 3 | # ring_BIN - Path to Ring binary 4 | 5 | SET(RING_FOUND true) 6 | 7 | IF(EXISTS ${CMAKE_INSTALL_PREFIX}/include/jami/jami.h) 8 | SET(ring_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include/jami) 9 | ELSEIF(EXISTS ${RING_INCLUDE_DIR}/jami.h) 10 | SET(ring_INCLUDE_DIRS ${RING_INCLUDE_DIR}) 11 | ELSEIF(EXISTS ${RING_BUILD_DIR}/jami/jami.h) 12 | SET(ring_INCLUDE_DIRS ${RING_BUILD_DIR}/jami) 13 | ELSE() 14 | MESSAGE(STATUS "Daemon header not found! 15 | Add -DRING_BUILD_DIR or -DCMAKE_INSTALL_PREFIX") 16 | SET(RING_FOUND false) 17 | ENDIF() 18 | 19 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".dylib;.so;.dll") 20 | 21 | FIND_LIBRARY(ring_BIN NAMES ring 22 | PATHS ${RING_BUILD_DIR}/.libs 23 | PATHS ${CMAKE_INSTALL_PREFIX}/lib 24 | PATHS ${CMAKE_INSTALL_PREFIX}/libexec 25 | PATHS ${CMAKE_INSTALL_PREFIX}/bin 26 | ) 27 | 28 | IF(${ring_BIN} MATCHES "") 29 | FIND_LIBRARY(ring_BIN NAMES jami 30 | PATHS ${RING_BUILD_DIR}/.libs 31 | PATHS ${CMAKE_INSTALL_PREFIX}/lib 32 | PATHS ${CMAKE_INSTALL_PREFIX}/libexec 33 | PATHS ${CMAKE_INSTALL_PREFIX}/bin 34 | ) 35 | ENDIF() 36 | 37 | # Try a static version too 38 | IF(${ring_BIN} MATCHES "") 39 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a;.lib") 40 | 41 | FIND_LIBRARY(ring_BIN NAMES ring 42 | PATHS ${RING_BUILD_DIR}/.libs 43 | PATHS ${CMAKE_INSTALL_PREFIX}/lib 44 | PATHS ${CMAKE_INSTALL_PREFIX}/libexec 45 | ) 46 | 47 | IF(${ring_BIN} MATCHES "") 48 | FIND_LIBRARY(ring_BIN NAMES jami 49 | PATHS ${RING_BUILD_DIR}/.libs 50 | PATHS ${CMAKE_INSTALL_PREFIX}/lib 51 | PATHS ${CMAKE_INSTALL_PREFIX}/libexec 52 | ) 53 | ENDIF() 54 | 55 | IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Windows") 56 | ADD_DEFINITIONS(-fPIC) 57 | ENDIF() 58 | 59 | ENDIF() 60 | 61 | MESSAGE(STATUS "Ring daemon header is in " ${ring_INCLUDE_DIRS}) 62 | MESSAGE(STATUS "Ring library path is " ${ring_BIN}) 63 | -------------------------------------------------------------------------------- /src/interfaces/dbuserrorhandleri.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2015-2022 Savoir-faire Linux Inc. * 3 | * Author : Stepan Salenikovich * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include 21 | 22 | namespace Interfaces { 23 | 24 | /** 25 | * Some clients may not have a nice way to generally handle exceptions event wide (ie: handle any 26 | * exception which may occur during an itteration or an event on the main loop). This interface 27 | * gives them the option to implement various ways to handle dbus errors. 28 | */ 29 | class DBusErrorHandlerI 30 | { 31 | public: 32 | virtual ~DBusErrorHandlerI() = default; 33 | 34 | virtual void connectionError(const QString& error) = 0; 35 | virtual void invalidInterfaceError(const QString& error) = 0; 36 | }; 37 | 38 | } // namespace Interfaces 39 | -------------------------------------------------------------------------------- /src/qtwrapper/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | CMAKE_MINIMUM_REQUIRED(VERSION 3.16) 2 | 3 | IF(POLICY CMP0022) 4 | CMAKE_POLICY(SET CMP0022 NEW) 5 | ENDIF(POLICY CMP0022) 6 | 7 | PROJECT(qtwrapper) 8 | 9 | MESSAGE("Compiling with qtwrapper") 10 | 11 | SET(ENABLE_LIBWRAP true) 12 | ADD_DEFINITIONS(-DENABLE_LIBWRAP=true) 13 | 14 | SET(LOCAL_CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../../cmake/) 15 | SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LOCAL_CMAKE_MODULE_PATH}) 16 | 17 | IF (${MUTE_DRING} MATCHES true) 18 | #It makes clients debugging easier 19 | MESSAGE("Dring logs are disabled") 20 | ADD_DEFINITIONS(-DMUTE_DRING=true) 21 | ENDIF() 22 | 23 | FIND_PACKAGE(Qt${QT_VERSION_MAJOR}Core REQUIRED) 24 | FIND_PACKAGE(Ring REQUIRED) 25 | 26 | SET(libqtwrapper_LIB_SRCS 27 | instancemanager.cpp 28 | videomanager_wrap.cpp 29 | ) 30 | 31 | IF(NOT (${ENABLE_VIDEO} MATCHES "false")) 32 | MESSAGE("VIDEO enabled") 33 | ADD_DEFINITIONS(-DENABLE_VIDEO=true) 34 | SET(ENABLE_VIDEO 1 CACHE BOOL "Enable video") 35 | ENDIF(NOT (${ENABLE_VIDEO} MATCHES "false")) 36 | 37 | IF(NOT (${ENABLE_PLUGIN} MATCHES "false")) 38 | MESSAGE("PLUGIN enabled") 39 | ADD_DEFINITIONS(-DENABLE_PLUGIN=true) 40 | SET(ENABLE_PLUGIN 1 CACHE BOOL "Enable plugin") 41 | ENDIF(NOT (${ENABLE_PLUGIN} MATCHES "false")) 42 | 43 | IF(ENABLE_PLUGIN) 44 | MESSAGE("Adding pluginmanager.cpp") 45 | SET(plugin_SRC pluginmanager.cpp) 46 | ELSE() 47 | MESSAGE("Adding pluginmanagerMock.cpp") 48 | SET(plugin_SRC pluginmanagerMock.cpp) 49 | ENDIF() 50 | 51 | INCLUDE_DIRECTORIES(SYSTEM ${Qt6Core_INCLUDE_DIRS} ) 52 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) 53 | INCLUDE_DIRECTORIES(${ring_INCLUDE_DIRS}) 54 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) 55 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../dbus) 56 | 57 | ADD_LIBRARY( qtwrapper STATIC ${libqtwrapper_LIB_SRCS} ${plugin_SRC}) 58 | 59 | IF(NOT ${ring_BIN} MATCHES "ring_BIN-NOTFOUND") 60 | TARGET_LINK_LIBRARIES( qtwrapper 61 | ${QT_QTCORE_LIBRARY} 62 | Qt::Core 63 | ${ring_BIN} 64 | ) 65 | ENDIF() -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | # Taken from: 2 | # https://cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F 3 | # 4 | # Copyright (C) 2016-2022 Savoir-faire Linux Inc. 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, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | # 20 | 21 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 22 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 23 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 24 | 25 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 26 | string(REGEX REPLACE "\n" ";" files "${files}") 27 | foreach(file ${files}) 28 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 29 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 30 | exec_program( 31 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 32 | OUTPUT_VARIABLE rm_out 33 | RETURN_VALUE rm_retval 34 | ) 35 | if(NOT "${rm_retval}" STREQUAL 0) 36 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 37 | endif(NOT "${rm_retval}" STREQUAL 0) 38 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 39 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 40 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 41 | endforeach(file) 42 | -------------------------------------------------------------------------------- /src/api/contact.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Nicolas Jäger * 4 | * Author: Sébastien Blin * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #include "profile.h" 22 | 23 | #include 24 | 25 | namespace lrc { 26 | 27 | namespace api { 28 | 29 | namespace contact { 30 | 31 | /** 32 | * @var profileInfo 33 | * @var registeredName 34 | * @var isTrusted 35 | * @var isPresent 36 | * @var isBanned 37 | */ 38 | struct Info 39 | { 40 | profile::Info profileInfo; 41 | QString registeredName; 42 | bool isTrusted = false; 43 | bool isPresent = false; 44 | bool isBanned = false; 45 | QString conversationId {}; 46 | }; 47 | 48 | } // namespace contact 49 | } // namespace api 50 | } // namespace lrc 51 | -------------------------------------------------------------------------------- /src/dbus/configurationmanager.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2009-2022 Savoir-faire Linux Inc. * 3 | * Author : Jérémy Quentin * 4 | * Emmanuel Lepage Vallee * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #ifdef ENABLE_TEST 22 | #include "../../test/mocks/configurationmanager_mock.h" 23 | #else 24 | #ifdef ENABLE_LIBWRAP 25 | #include "../qtwrapper/configurationmanager_wrap.h" 26 | #else 27 | #include "configurationmanager_dbus_interface.h" 28 | #include 29 | #include "../qtwrapper/conversions_wrap.hpp" 30 | #endif 31 | #endif 32 | #include 33 | 34 | namespace ConfigurationManager { 35 | 36 | /// Singleton to access the ConfigurationManager dbus interface 37 | LIB_EXPORT ConfigurationManagerInterface& instance(); 38 | 39 | } // namespace ConfigurationManager 40 | -------------------------------------------------------------------------------- /src/private/namedirectory_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2016-2022 Savoir-faire Linux Inc. * 3 | * Author : Alexandre Viau * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include "namedirectory.h" 21 | 22 | typedef void (NameDirectoryPrivate::*NameDirectoryPrivateFct)(); 23 | 24 | class NameDirectoryPrivate : public QObject 25 | { 26 | Q_OBJECT 27 | 28 | private: 29 | NameDirectory* q_ptr; 30 | 31 | public: 32 | NameDirectoryPrivate(NameDirectory*); 33 | 34 | public Q_SLOTS: 35 | void slotNameRegistrationEnded(const QString& accountId, int status, const QString& name); 36 | void slotRegisteredNameFound(const QString& accountId, 37 | int status, 38 | const QString& address, 39 | const QString& name); 40 | void slotExportOnRingEnded(const QString& accountId, int status, const QString& pin); 41 | }; 42 | -------------------------------------------------------------------------------- /src/renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018-2022 Savoir-faire Linux Inc. 3 | * Author: Sébastien Blin 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program. If not, see . 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "api/video.h" 22 | #include "typedefs.h" 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace lrc { 33 | namespace video { 34 | 35 | class Renderer : public QObject 36 | { 37 | Q_OBJECT 38 | public: 39 | Renderer(const QString& id, const QSize& res); 40 | virtual ~Renderer(); 41 | 42 | /** 43 | * @return renderer's id 44 | */ 45 | QString id() const; 46 | 47 | /** 48 | * @return current renderer dimensions 49 | */ 50 | QSize size() const; 51 | 52 | /** 53 | * Update size and shmPath of a renderer 54 | * @param size new renderer dimensions 55 | * @param shmPath new shmPath 56 | */ 57 | virtual void update(const QSize& size, const QString& shmPath = {}); 58 | 59 | /** 60 | * @return current rendered frame 61 | */ 62 | virtual lrc::api::video::Frame currentFrame() const = 0; 63 | 64 | public Q_SLOTS: 65 | virtual void startRendering() = 0; 66 | virtual void stopRendering() = 0; 67 | 68 | Q_SIGNALS: 69 | void frameUpdated(); 70 | void stopped(); 71 | void started(); 72 | void frameBufferRequested(AVFrame* avFrame); 73 | 74 | private: 75 | QString id_; 76 | QSize size_; 77 | }; 78 | 79 | } // namespace video 80 | } // namespace lrc 81 | -------------------------------------------------------------------------------- /src/api/member.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2021 Savoir-faire Linux Inc. * 3 | * Author: Sébastien Blin * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include "typedefs.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | namespace lrc { 27 | 28 | namespace api { 29 | 30 | namespace member { 31 | Q_NAMESPACE 32 | Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") 33 | 34 | enum class Role { ADMIN, MEMBER, INVITED, BANNED, LEFT }; 35 | Q_ENUM_NS(Role) 36 | 37 | static inline Role 38 | to_role(const QString& roleStr) 39 | { 40 | if (roleStr == "admin") 41 | return Role::ADMIN; 42 | if (roleStr == "member") 43 | return Role::MEMBER; 44 | if (roleStr == "invited") 45 | return Role::INVITED; 46 | if (roleStr == "banned") 47 | return Role::BANNED; 48 | if (roleStr == "left") 49 | return Role::LEFT; 50 | return Role::MEMBER; 51 | } 52 | 53 | struct Member 54 | { 55 | QString uri = ""; 56 | Role role = Role::MEMBER; 57 | }; 58 | 59 | } // namespace member 60 | } // namespace api 61 | } // namespace lrc 62 | -------------------------------------------------------------------------------- /src/api/video.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018-2022 Savoir-faire Linux Inc. 3 | * Author: Sébastien Blin 4 | * Author: Andreas Traczyk 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library 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 GNU 14 | * Lesser 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 | 20 | #pragma once 21 | 22 | #include "typedefs.h" 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | extern "C" { 33 | #include 34 | } 35 | 36 | namespace lrc { 37 | namespace api { 38 | namespace video { 39 | Q_NAMESPACE 40 | Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") 41 | 42 | constexpr static const char PREVIEW_RENDERER_ID[] = "local"; 43 | 44 | using Channel = QString; 45 | using Resolution = QString; 46 | using Framerate = float; 47 | using FrameratesList = QVector; 48 | using ResRateList = QVector>; 49 | using Capabilities = QMap; 50 | 51 | // This class is used to expose video data frame(currently only 52 | // by the ShmRenderer class). 53 | struct Frame 54 | { 55 | // Used by SHM renderer. 56 | uint8_t* ptr {nullptr}; 57 | size_t size {0}; 58 | }; 59 | 60 | enum class DeviceType { CAMERA, DISPLAY, FILE, INVALID }; 61 | Q_ENUM_NS(DeviceType) 62 | 63 | // This class describes the current video input device. 64 | struct RenderedDevice 65 | { 66 | QString name; 67 | DeviceType type = DeviceType::INVALID; 68 | }; 69 | 70 | // This class describes current video settings 71 | struct Settings 72 | { 73 | Channel channel = ""; 74 | QString name = ""; 75 | QString id = ""; 76 | Framerate rate = 0; 77 | Resolution size = ""; 78 | }; 79 | } // namespace video 80 | } // namespace api 81 | } // namespace lrc 82 | -------------------------------------------------------------------------------- /src/dbus/videomanager.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2012-2022 Savoir-faire Linux Inc. * 3 | * Author : Emmanuel Lepage Vallee * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #include "videomanager.h" 19 | 20 | #include "../globalinstances.h" 21 | #include "../interfaces/dbuserrorhandleri.h" 22 | 23 | VideoManagerInterface& 24 | VideoManager::instance() 25 | { 26 | #ifdef ENABLE_LIBWRAP 27 | static auto interface = new VideoManagerInterface(); 28 | #else 29 | if (!dbus_metaTypeInit) 30 | registerCommTypes(); 31 | 32 | static auto interface = new VideoManagerInterface("cx.ring.Ring", 33 | "/cx/ring/Ring/VideoManager", 34 | QDBusConnection::sessionBus()); 35 | if (!interface->connection().isConnected()) { 36 | GlobalInstances::dBusErrorHandler().connectionError( 37 | "Error : jamid not connected. Service " + interface->service() 38 | + " not connected. From video manager interface."); 39 | } 40 | if (!interface->isValid()) { 41 | GlobalInstances::dBusErrorHandler().invalidInterfaceError( 42 | "Error : jamid is not available, make sure it is running"); 43 | } 44 | #endif 45 | return *interface; 46 | } 47 | -------------------------------------------------------------------------------- /src/dbus/pluginmanager.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2013-2022 Savoir-faire Linux Inc. * 3 | * Author : Aline Gondim Santos * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #include "pluginmanager.h" 19 | 20 | #include "../globalinstances.h" 21 | #include "../interfaces/dbuserrorhandleri.h" 22 | 23 | PluginManagerInterface& 24 | PluginManager::instance() 25 | { 26 | #ifdef ENABLE_LIBWRAP 27 | static auto interface = new PluginManagerInterface(); 28 | #else 29 | if (!dbus_metaTypeInit) 30 | registerCommTypes(); 31 | static auto interface = new PluginManagerInterface("cx.ring.Ring", 32 | "/cx/ring/Ring/PluginManagerInterface", 33 | QDBusConnection::sessionBus()); 34 | 35 | if (!interface->connection().isConnected()) { 36 | GlobalInstances::dBusErrorHandler().connectionError( 37 | "Error : jamid not connected. Service " + interface->service() 38 | + " not connected. From presence interface."); 39 | } 40 | if (!interface->isValid()) { 41 | GlobalInstances::dBusErrorHandler().invalidInterfaceError( 42 | "Error : jamid is not available, make sure it is running"); 43 | } 44 | #endif 45 | return *interface; 46 | } 47 | -------------------------------------------------------------------------------- /src/dbus/presencemanager.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2013-2022 Savoir-faire Linux Inc. * 3 | * Author : Emmanuel Lepage Vallee * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #include "presencemanager.h" 19 | 20 | #include "../globalinstances.h" 21 | #include "../interfaces/dbuserrorhandleri.h" 22 | 23 | PresenceManagerInterface& 24 | PresenceManager::instance() 25 | { 26 | #ifdef ENABLE_LIBWRAP 27 | static auto interface = new PresenceManagerInterface(); 28 | #else 29 | if (!dbus_metaTypeInit) 30 | registerCommTypes(); 31 | static auto interface = new PresenceManagerInterface("cx.ring.Ring", 32 | "/cx/ring/Ring/PresenceManager", 33 | QDBusConnection::sessionBus()); 34 | 35 | if (!interface->connection().isConnected()) { 36 | GlobalInstances::dBusErrorHandler().connectionError( 37 | "Error : jamid not connected. Service " + interface->service() 38 | + " not connected. From presence interface."); 39 | } 40 | if (!interface->isValid()) { 41 | GlobalInstances::dBusErrorHandler().invalidInterfaceError( 42 | "Error : jamid is not available, make sure it is running"); 43 | } 44 | #endif 45 | return *interface; 46 | } 47 | -------------------------------------------------------------------------------- /src/dbus/callmanager.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2009-2022 Savoir-faire Linux Inc. * 3 | * Author : Jérémy Quentin * 4 | * Emmanuel Lepage Vallee * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 "callmanager.h" 20 | 21 | #include "../globalinstances.h" 22 | #include "../interfaces/dbuserrorhandleri.h" 23 | 24 | CallManagerInterface& 25 | CallManager::instance() 26 | { 27 | #ifdef ENABLE_LIBWRAP 28 | static auto interface = new CallManagerInterface(); 29 | #else 30 | if (!dbus_metaTypeInit) 31 | registerCommTypes(); 32 | 33 | static auto interface = new CallManagerInterface("cx.ring.Ring", 34 | "/cx/ring/Ring/CallManager", 35 | QDBusConnection::sessionBus()); 36 | 37 | if (!interface->connection().isConnected()) { 38 | GlobalInstances::dBusErrorHandler().connectionError( 39 | "Error : jamid not connected. Service " + interface->service() 40 | + " not connected. From call manager interface."); 41 | } 42 | if (!interface->isValid()) { 43 | GlobalInstances::dBusErrorHandler().invalidInterfaceError( 44 | "Error : jamid is not available, make sure it is running"); 45 | } 46 | #endif 47 | return *interface; 48 | } 49 | -------------------------------------------------------------------------------- /src/smartinfohub.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2016-2022 Savoir-faire Linux Inc. * 3 | * Author: Olivier Grégoire * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | 19 | #pragma once 20 | 21 | #include 22 | #include "typedefs.h" 23 | 24 | class SmartInfoHubPrivate; 25 | 26 | class SmartInfoHub final : public QObject 27 | { 28 | Q_OBJECT 29 | public: 30 | // Singleton 31 | static SmartInfoHub& instance(); 32 | 33 | void start(); 34 | void stop(); 35 | 36 | void setRefreshTime(uint32_t timeMS); 37 | 38 | // Getter 39 | float localFps() const; 40 | float remoteFps() const; 41 | int remoteWidth() const; 42 | int remoteHeight() const; 43 | int localWidth() const; 44 | int localHeight() const; 45 | QString callID() const; 46 | QString localVideoCodec() const; 47 | QString localAudioCodec() const; 48 | QString remoteVideoCodec() const; 49 | QString remoteAudioCodec() const; 50 | bool isConference() const; 51 | 52 | Q_SIGNALS: 53 | /// Emitted when informations have changed 54 | void changed(); 55 | 56 | private Q_SLOTS: 57 | void slotSmartInfo(const MapStringString& info); 58 | 59 | private: 60 | // use to initialise the connection between the Qsignal and the lambda function 61 | SmartInfoHub(); 62 | virtual ~SmartInfoHub(); 63 | 64 | SmartInfoHubPrivate* d_ptr; 65 | }; 66 | -------------------------------------------------------------------------------- /src/dbus/configurationmanager.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2009-2022 Savoir-faire Linux Inc. * 3 | * Author : Jérémy Quentin * 4 | * Emmanuel Lepage Vallee * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 "configurationmanager.h" 20 | 21 | #include "../globalinstances.h" 22 | #include "../interfaces/dbuserrorhandleri.h" 23 | 24 | ConfigurationManagerInterface& 25 | ConfigurationManager::instance() 26 | { 27 | #ifdef ENABLE_LIBWRAP 28 | static auto interface = new ConfigurationManagerInterface(); 29 | #else 30 | if (!dbus_metaTypeInit) 31 | registerCommTypes(); 32 | static auto interface = new ConfigurationManagerInterface("cx.ring.Ring", 33 | "/cx/ring/Ring/ConfigurationManager", 34 | QDBusConnection::sessionBus()); 35 | if (!interface->connection().isConnected()) { 36 | GlobalInstances::dBusErrorHandler().connectionError( 37 | "Error : jamid not connected. Service " + interface->service() 38 | + " not connected. From configuration manager interface."); 39 | } 40 | if (!interface->isValid()) { 41 | GlobalInstances::dBusErrorHandler().invalidInterfaceError( 42 | "Error : jamid is not available, make sure it is running"); 43 | } 44 | #endif 45 | return *interface; 46 | } 47 | -------------------------------------------------------------------------------- /src/authority/daemon.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Nicolas Jäger * 4 | * Author: Sébastien Blin * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | // Lrc 20 | #include "daemon.h" 21 | 22 | namespace lrc { 23 | 24 | namespace authority { 25 | 26 | namespace daemon { 27 | 28 | void 29 | addContact(const api::account::Info& owner, const QString& contactUri) 30 | { 31 | ConfigurationManager::instance().addContact(owner.id, contactUri); 32 | } 33 | 34 | void 35 | addContact(const api::account::Info& owner, const api::contact::Info& contactInfo) 36 | { 37 | ConfigurationManager::instance().addContact(owner.id, contactInfo.profileInfo.uri); 38 | } 39 | 40 | void 41 | removeContact(const api::account::Info& owner, const QString& contactUri, bool banned) 42 | { 43 | ConfigurationManager::instance().removeContact(owner.id, contactUri, banned); 44 | } 45 | 46 | bool 47 | addContactFromPending(const api::account::Info& owner, const QString& contactUri) 48 | { 49 | return ConfigurationManager::instance().acceptTrustRequest(owner.id, contactUri); 50 | } 51 | 52 | bool 53 | discardFromPending(const api::account::Info& owner, const QString& contactUri) 54 | { 55 | return ConfigurationManager::instance().discardTrustRequest(owner.id, contactUri); 56 | } 57 | 58 | } // namespace daemon 59 | 60 | } // namespace authority 61 | 62 | } // namespace lrc 63 | -------------------------------------------------------------------------------- /src/private/smartInfoHub_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2016-2022 Savoir-faire Linux Inc. * 3 | * Author: Olivier Grégoire * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | 19 | /* widget_p.h (_p means private) */ 20 | #include 21 | #include "../smartinfohub.h" 22 | #include "typedefs.h" 23 | 24 | #pragma once 25 | 26 | // variables contain in the map information 27 | static QString LOCAL_FPS = QStringLiteral("local FPS"); 28 | static QString LOCAL_AUDIO_CODEC = QStringLiteral("local audio codec"); 29 | static QString LOCAL_VIDEO_CODEC = QStringLiteral("local video codec"); 30 | static QString LOCAL_WIDTH = QStringLiteral("local width"); 31 | static QString LOCAL_HEIGHT = QStringLiteral("local height"); 32 | static QString REMOTE_FPS = QStringLiteral("remote FPS"); 33 | static QString REMOTE_WIDTH = QStringLiteral("remote width"); 34 | static QString REMOTE_HEIGHT = QStringLiteral("remote height"); 35 | static QString REMOTE_VIDEO_CODEC = QStringLiteral("remote video codec"); 36 | static QString REMOTE_AUDIO_CODEC = QStringLiteral("remote audio codec"); 37 | static QString CALL_ID = QStringLiteral("callID"); 38 | 39 | class SmartInfoHubPrivate; 40 | class SmartInfoHubPrivate final : public QObject 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | constexpr static const char* DEFAULT_RETURN_VALUE_QSTRING = "void"; 46 | 47 | uint32_t m_refreshTimeInformationMS = 500; 48 | QMap m_information; 49 | 50 | void setMapInfo(const MapStringString& info); 51 | }; 52 | -------------------------------------------------------------------------------- /src/api/peerdiscoverymodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2019-2022 Savoir-faire Linux Inc. * 3 | * Author: Mingrui Zhang * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | 19 | #pragma once 20 | 21 | // Lrc 22 | #include "typedefs.h" 23 | 24 | // Qt 25 | #include 26 | 27 | // std 28 | #include 29 | #include 30 | #include 31 | 32 | namespace lrc { 33 | 34 | class CallbacksHandler; 35 | class PeerDiscoveryModelPimpl; 36 | 37 | namespace api { 38 | 39 | struct PeerContact 40 | { 41 | std::string uri; 42 | std::string displayName; 43 | }; 44 | 45 | enum class PeerModelChanged { INSERT, REMOVE }; 46 | 47 | /** 48 | * @brief Class that manages local peer discovery info 49 | */ 50 | class LIB_EXPORT PeerDiscoveryModel : public QObject 51 | { 52 | Q_OBJECT 53 | public: 54 | PeerDiscoveryModel(const CallbacksHandler& callbackHandler, const QString& accountID); 55 | ~PeerDiscoveryModel(); 56 | /** 57 | * get a map of discovered peers account 58 | * @return a std::vector 59 | */ 60 | std::vector getNearbyPeers() const; 61 | 62 | Q_SIGNALS: 63 | /** 64 | * Connect this signal to know when the status of local peer discovery map changed. 65 | */ 66 | void modelChanged(const QString& contactUri, PeerModelChanged state, const QString& displayname); 67 | 68 | private: 69 | std::unique_ptr pimpl_; 70 | }; 71 | } // namespace api 72 | } // namespace lrc 73 | Q_DECLARE_METATYPE(lrc::api::PeerDiscoveryModel*) 74 | -------------------------------------------------------------------------------- /src/qtwrapper/instancemanager_wrap.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 2014-2022 Savoir-faire Linux Inc. * 3 | * Author : Philippe Groarke * 4 | * Author : Alexandre Lision * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the Lesser GNU General Public License * 17 | * along with this program. If not, see . * 18 | *****************************************************************************/ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | #include "jami.h" 31 | #include "../typedefs.h" 32 | #include "conversions_wrap.hpp" 33 | 34 | /* 35 | * Proxy class for interface org.ring.Ring.Instance 36 | */ 37 | class InstanceManagerInterface : public QObject 38 | { 39 | Q_OBJECT 40 | public: 41 | InstanceManagerInterface(bool muteDring = false); 42 | ~InstanceManagerInterface(); 43 | 44 | // TODO: These are not present in jami.h 45 | 46 | public Q_SLOTS: // METHODS 47 | void Register(int pid, const QString& name) 48 | { 49 | Q_UNUSED(pid) // When directly linked, the PID is always the current process PID 50 | Q_UNUSED(name) 51 | } 52 | 53 | void Unregister(int pid) 54 | { 55 | Q_UNUSED(pid) // When directly linked, the PID is always the current process PID 56 | DRing::fini(); 57 | } 58 | 59 | bool isConnected(); 60 | 61 | private: 62 | Q_SIGNALS: // SIGNALS 63 | void started(); 64 | }; 65 | 66 | namespace cx { 67 | namespace Ring { 68 | namespace Ring { 69 | typedef ::InstanceManagerInterface Instance; 70 | } 71 | } // namespace Ring 72 | } // namespace cx 73 | -------------------------------------------------------------------------------- /src/pixmapmanipulatordefault.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2013-2022 Savoir-faire Linux Inc. * 3 | * Author : Emmanuel Lepage Vallee * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include "interfaces/pixmapmanipulatori.h" 21 | 22 | namespace Interfaces { 23 | 24 | /// Default implementation of the PixmapManipulator interface which simply returns empty 25 | /// QVariants/QByteArrays 26 | class LIB_EXPORT PixmapManipulatorDefault : public PixmapManipulatorI 27 | { 28 | public: 29 | QVariant conversationPhoto(const lrc::api::conversation::Info& conversation, 30 | const lrc::api::account::Info& accountInfo, 31 | const QSize& size, 32 | bool displayPresence = true) override; 33 | QVariant numberCategoryIcon(const QVariant& p, 34 | const QSize& size, 35 | bool displayPresence = false, 36 | bool isPresent = false) override; 37 | QByteArray toByteArray(const QVariant& pxm) override; 38 | QVariant personPhoto(const QByteArray& data, const QString& type = "PNG") override; 39 | QVariant decorationRole(const QModelIndex& index) override; 40 | QVariant decorationRole(const lrc::api::conversation::Info& conversation, 41 | const lrc::api::account::Info& accountInfo) override; 42 | /** 43 | * Return the icons associated with the action and its state 44 | */ 45 | QVariant userActionIcon(const UserActionElement& state) const override; 46 | }; 47 | 48 | } // namespace Interfaces 49 | -------------------------------------------------------------------------------- /src/authority/daemon.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Nicolas Jäger * 4 | * Author: Sébastien Blin * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | // Lrc 22 | #include "api/account.h" 23 | #include "api/contact.h" 24 | #include "dbus/configurationmanager.h" 25 | 26 | namespace lrc { 27 | 28 | namespace authority { 29 | 30 | namespace daemon { 31 | /** 32 | * Ask the daemon to add contact to the daemon. 33 | * @param owner 34 | * @param contactUri 35 | */ 36 | void addContact(const api::account::Info& owner, const QString& contactUri); 37 | /** 38 | * Ask the daemon to add contact to the daemon. 39 | * @param owner 40 | * @param contactInfo 41 | */ 42 | void addContact(const api::account::Info& owner, const api::contact::Info& contactInfo); 43 | /** 44 | * Ask the daemon to remove a contact and may ban it. 45 | * @param owner 46 | * @param contactInfo 47 | * @param banned 48 | */ 49 | void removeContact(const api::account::Info& owner, const QString& contactUri, bool banned); 50 | /** 51 | * Ask the daemon to add a contact from the pending list. 52 | * @param owner 53 | * @param contactUri 54 | * @return if operation succeed 55 | */ 56 | bool addContactFromPending(const api::account::Info& owner, const QString& contactUri); 57 | /** 58 | * Ask the daemon to discard a pending. 59 | * @param owner 60 | * @param contactUri 61 | * @return if operation succeed 62 | */ 63 | bool discardFromPending(const api::account::Info& owner, const QString& contactUri); 64 | 65 | } // namespace daemon 66 | 67 | } // namespace authority 68 | 69 | } // namespace lrc 70 | -------------------------------------------------------------------------------- /src/api/profile.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Nicolas Jäger * 4 | * Author: Sébastien Blin * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace lrc { 25 | 26 | namespace api { 27 | 28 | namespace profile { 29 | Q_NAMESPACE 30 | Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") 31 | 32 | enum class Type { INVALID, JAMI, SIP, PENDING, TEMPORARY, COUNT__ }; 33 | Q_ENUM_NS(Type) 34 | 35 | static inline const QString 36 | to_string(const Type& type) 37 | { 38 | switch (type) { 39 | case Type::JAMI: 40 | return "JAMI"; 41 | case Type::SIP: 42 | return "SIP"; 43 | case Type::PENDING: 44 | return "PENDING"; 45 | case Type::TEMPORARY: 46 | return "TEMPORARY"; 47 | case Type::INVALID: 48 | case Type::COUNT__: 49 | default: 50 | return "INVALID"; 51 | } 52 | } 53 | 54 | static inline Type 55 | to_type(const QString& type) 56 | { 57 | if (type == "PENDING") 58 | return Type::PENDING; 59 | else if (type == "SIP") 60 | return Type::SIP; 61 | else if (type == "JAMI") 62 | return Type::JAMI; 63 | else if (type == "TEMPORARY") 64 | return Type::TEMPORARY; 65 | else 66 | return Type::INVALID; 67 | } 68 | 69 | /** 70 | * @var uri 71 | * @var avatar 72 | * @var alias 73 | * @var type 74 | */ 75 | struct Info 76 | { 77 | QString uri = ""; 78 | QString avatar = ""; 79 | QString alias = ""; 80 | Type type = Type::INVALID; 81 | }; 82 | 83 | } // namespace profile 84 | } // namespace api 85 | } // namespace lrc 86 | -------------------------------------------------------------------------------- /src/qtwrapper/videomanager_wrap.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 2014-2022 Savoir-faire Linux Inc. * 3 | * Author : Philippe Groarke * 4 | * Author : Alexandre Lision * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the Lesser GNU General Public License * 17 | * along with this program. If not, see . * 18 | *****************************************************************************/ 19 | #include "videomanager_wrap.h" 20 | 21 | VideoManagerInterface::VideoManagerInterface() 22 | { 23 | #ifdef ENABLE_VIDEO 24 | using DRing::exportable_callback; 25 | using DRing::VideoSignal; 26 | videoHandlers 27 | = {exportable_callback([this]() { Q_EMIT deviceEvent(); }), 28 | exportable_callback([this](const std::string& id, 29 | const std::string& shmPath, 30 | int width, 31 | int height, 32 | bool isMixer) { 33 | Q_EMIT decodingStarted(QString(id.c_str()), 34 | QString(shmPath.c_str()), 35 | width, 36 | height, 37 | isMixer); 38 | }), 39 | exportable_callback([this](const std::string& id, 40 | const std::string& shmPath, 41 | bool isMixer) { 42 | Q_EMIT decodingStopped(QString(id.c_str()), QString(shmPath.c_str()), isMixer); 43 | })}; 44 | #endif 45 | } 46 | 47 | VideoManagerInterface::~VideoManagerInterface() {} 48 | -------------------------------------------------------------------------------- /src/dbus/instancemanager.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2009-2022 Savoir-faire Linux Inc. * 3 | * Author : Jérémy Quentin * 4 | * Emmanuel Lepage Vallee * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | 20 | #include "instancemanager.h" 21 | 22 | #ifndef _MSC_VER 23 | #include 24 | #else 25 | #include "../../daemon/compat/msvc/unistd.h" 26 | #endif // !_MSC_VER 27 | 28 | #include "../globalinstances.h" 29 | #include "../interfaces/dbuserrorhandleri.h" 30 | 31 | InstanceManagerInterface& 32 | InstanceManager::instance(bool muteDring) 33 | { 34 | #ifdef ENABLE_LIBWRAP 35 | static auto interface = new InstanceManagerInterface(muteDring); 36 | #else 37 | if (!dbus_metaTypeInit) 38 | registerCommTypes(); 39 | Q_UNUSED(muteDring) 40 | 41 | static auto interface = new InstanceManagerInterface("cx.ring.Ring", 42 | "/cx/ring/Ring/Instance", 43 | QDBusConnection::sessionBus()); 44 | 45 | if (!interface->connection().isConnected()) { 46 | GlobalInstances::dBusErrorHandler().connectionError( 47 | "Error : jamid not connected. Service " + interface->service() 48 | + " not connected. From instance interface."); 49 | } 50 | static bool registered = false; 51 | if (!registered) { 52 | QDBusPendingReply reply = interface->Register(getpid(), ""); 53 | registered = true; 54 | reply.waitForFinished(); 55 | } 56 | 57 | /* we do not check if the interface isValid; 58 | * isValid() return 'false' if there was any error; 59 | * we expect there to be an error when we first launch the client and the daemon is not yet 60 | * running; 61 | * TODO: check if we get the expected error, or another, see: 62 | * http://doc.qt.io/qt-4.8/qdbuserror.html#ErrorType-enum 63 | */ 64 | 65 | #endif 66 | return *interface; 67 | } 68 | -------------------------------------------------------------------------------- /src/qtwrapper/instancemanager.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2009-2022 Savoir-faire Linux Inc. * 3 | * Authors : Alexandre Lision alexandre.lision@savoirfairelinux.com * 4 | * Author : Alexandre Lision * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | 20 | #include "instancemanager_wrap.h" 21 | #include "callmanager.h" 22 | #include "presencemanager.h" 23 | #include "configurationmanager.h" 24 | #ifdef ENABLE_VIDEO 25 | #include "videomanager.h" 26 | #endif // ENABLE_VIDEO 27 | 28 | static int ringFlags = 0; 29 | 30 | InstanceManagerInterface::InstanceManagerInterface(bool muteDring) 31 | { 32 | using namespace std::placeholders; 33 | 34 | using std::bind; 35 | using DRing::exportable_callback; 36 | using DRing::CallSignal; 37 | using DRing::ConfigurationSignal; 38 | using DRing::PresenceSignal; 39 | using DRing::DataTransferSignal; 40 | using DRing::ConversationSignal; 41 | 42 | #ifdef ENABLE_VIDEO 43 | using DRing::VideoSignal; 44 | #endif 45 | 46 | #ifndef MUTE_DRING 47 | if (!muteDring) { 48 | ringFlags |= DRing::DRING_FLAG_DEBUG; 49 | ringFlags |= DRing::DRING_FLAG_CONSOLE_LOG; 50 | } 51 | #endif 52 | 53 | DRing::init(static_cast(ringFlags)); 54 | 55 | registerSignalHandlers(CallManager::instance().callHandlers); 56 | registerSignalHandlers(ConfigurationManager::instance().confHandlers); 57 | registerSignalHandlers(PresenceManager::instance().presHandlers); 58 | registerSignalHandlers(ConfigurationManager::instance().dataXferHandlers); 59 | #ifdef ENABLE_VIDEO 60 | registerSignalHandlers(VideoManager::instance().videoHandlers); 61 | #endif 62 | registerSignalHandlers(ConfigurationManager::instance().conversationsHandlers); 63 | 64 | if (!DRing::start()) 65 | printf("Error initializing daemon\n"); 66 | else 67 | printf("Daemon is running\n"); 68 | } 69 | 70 | InstanceManagerInterface::~InstanceManagerInterface() {} 71 | 72 | bool 73 | InstanceManagerInterface::isConnected() 74 | { 75 | return true; 76 | } 77 | -------------------------------------------------------------------------------- /src/namedirectory.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2016-2022 Savoir-faire Linux Inc. * 3 | * Author : Alexandre Viau * 4 | * Emmanuel Lepage Vallee * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #include "typedefs.h" 22 | 23 | class NameDirectoryPrivate; 24 | class Account; 25 | 26 | class LIB_EXPORT NameDirectory : public QObject 27 | { 28 | Q_OBJECT 29 | Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") 30 | public: 31 | // Register name status 32 | enum class RegisterNameStatus { 33 | SUCCESS = 0, 34 | WRONG_PASSWORD = 1, 35 | INVALID_NAME = 2, 36 | ALREADY_TAKEN = 3, 37 | NETWORK_ERROR = 4 38 | }; 39 | Q_ENUM(RegisterNameStatus) 40 | 41 | // Lookup name status 42 | enum class LookupStatus { SUCCESS = 0, INVALID_NAME = 1, NOT_FOUND = 2, ERROR = 3 }; 43 | Q_ENUM(LookupStatus) 44 | 45 | enum class ExportOnRingStatus { SUCCESS = 0, WRONG_PASSWORD = 1, NETWORK_ERROR = 2, INVALID }; 46 | Q_ENUM(ExportOnRingStatus) 47 | 48 | // Singleton 49 | static NameDirectory& instance(); 50 | 51 | // Lookup 52 | Q_INVOKABLE bool lookupName(const QString& nameServiceURL, const QString& name) const; 53 | Q_INVOKABLE bool lookupAddress(const QString& nameServiceURL, const QString& address) const; 54 | 55 | private: 56 | // Constructors & Destructors 57 | explicit NameDirectory(); 58 | virtual ~NameDirectory(); 59 | 60 | NameDirectoryPrivate* d_ptr; 61 | Q_DECLARE_PRIVATE(NameDirectory) 62 | Q_DISABLE_COPY(NameDirectory) 63 | 64 | Q_SIGNALS: 65 | /// RegisterName has ended 66 | void nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name); 67 | 68 | /// Name or address lookup has completed 69 | void registeredNameFound(NameDirectory::LookupStatus status, 70 | const QString& address, 71 | const QString& name); 72 | 73 | // Export account has ended with pin generated 74 | void exportOnRingEnded(NameDirectory::ExportOnRingStatus status, const QString& pin); 75 | }; 76 | Q_DECLARE_METATYPE(NameDirectory*) 77 | -------------------------------------------------------------------------------- /src/pixmapmanipulatordefault.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2013-2022 Savoir-faire Linux Inc. * 3 | * Author : Emmanuel Lepage Vallee * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #include "pixmapmanipulatordefault.h" 19 | 20 | // Qt 21 | #include 22 | #include 23 | #include 24 | 25 | // LRC 26 | #include "api/account.h" 27 | #include "api/conversation.h" 28 | 29 | namespace Interfaces { 30 | 31 | QVariant 32 | PixmapManipulatorDefault::numberCategoryIcon(const QVariant& p, 33 | const QSize& size, 34 | bool displayPresence, 35 | bool isPresent) 36 | { 37 | Q_UNUSED(p) 38 | Q_UNUSED(size) 39 | Q_UNUSED(displayPresence) 40 | Q_UNUSED(isPresent) 41 | return QVariant(); 42 | } 43 | 44 | QVariant 45 | PixmapManipulatorDefault::conversationPhoto(const lrc::api::conversation::Info& conversation, 46 | const lrc::api::account::Info& accountInfo, 47 | const QSize& size, 48 | bool displayPresence) 49 | { 50 | Q_UNUSED(conversation) 51 | Q_UNUSED(accountInfo) 52 | Q_UNUSED(size) 53 | Q_UNUSED(displayPresence) 54 | return QVariant(); 55 | } 56 | 57 | QByteArray 58 | PixmapManipulatorDefault::toByteArray(const QVariant& pxm) 59 | { 60 | Q_UNUSED(pxm) 61 | return QByteArray(); 62 | } 63 | 64 | QVariant 65 | PixmapManipulatorDefault::personPhoto(const QByteArray& data, const QString& type) 66 | { 67 | Q_UNUSED(data) 68 | Q_UNUSED(type) 69 | return QVariant(); 70 | } 71 | 72 | QVariant 73 | PixmapManipulatorDefault::userActionIcon(const UserActionElement& state) const 74 | { 75 | Q_UNUSED(state) 76 | return QVariant(); 77 | } 78 | 79 | QVariant 80 | PixmapManipulatorDefault::decorationRole(const QModelIndex& index) 81 | { 82 | Q_UNUSED(index) 83 | return QVariant(); 84 | } 85 | 86 | QVariant 87 | PixmapManipulatorDefault::decorationRole(const lrc::api::conversation::Info& conversation, 88 | const lrc::api::account::Info& accountInfo) 89 | { 90 | Q_UNUSED(conversation) 91 | Q_UNUSED(accountInfo) 92 | return QVariant(); 93 | } 94 | 95 | } // namespace Interfaces 96 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | # Based on the .clang-format for Qt Creator 2 | # 3 | # This is for clang-format >= 10.0. 4 | # 5 | # https://releases.llvm.org/10.0.0/tools/clang/docs/ClangFormatStyleOptions.html 6 | # 7 | --- 8 | Language: Cpp 9 | AccessModifierOffset: -4 10 | AlignAfterOpenBracket: Align 11 | AlignConsecutiveAssignments: false 12 | AlignConsecutiveDeclarations: false 13 | AlignConsecutiveMacros: true 14 | AlignEscapedNewlines: DontAlign 15 | AlignOperands: true 16 | AlignTrailingComments: true 17 | AllowAllParametersOfDeclarationOnNextLine: true 18 | AllowShortBlocksOnASingleLine: false 19 | AllowShortCaseLabelsOnASingleLine: false 20 | AllowShortFunctionsOnASingleLine: Inline 21 | AllowShortIfStatementsOnASingleLine: false 22 | AllowShortLambdasOnASingleLine: Inline 23 | AllowShortLoopsOnASingleLine: false 24 | AlwaysBreakAfterReturnType: TopLevelDefinitions 25 | AlwaysBreakBeforeMultilineStrings: false 26 | AlwaysBreakTemplateDeclarations: Yes 27 | BinPackArguments: false 28 | BinPackParameters: false 29 | BraceWrapping: 30 | AfterClass: true 31 | AfterControlStatement: false 32 | AfterEnum: false 33 | AfterFunction: true 34 | AfterNamespace: false 35 | AfterObjCDeclaration: false 36 | AfterStruct: true 37 | AfterUnion: false 38 | BeforeCatch: false 39 | BeforeElse: false 40 | IndentBraces: false 41 | SplitEmptyFunction: false 42 | SplitEmptyRecord: false 43 | SplitEmptyNamespace: false 44 | BreakBeforeBinaryOperators: All 45 | BreakBeforeBraces: Custom 46 | BreakBeforeInheritanceComma: false 47 | BreakBeforeTernaryOperators: true 48 | BreakConstructorInitializersBeforeComma: false 49 | BreakConstructorInitializers: BeforeComma 50 | BreakAfterJavaFieldAnnotations: false 51 | BreakStringLiterals: true 52 | ColumnLimit: 100 53 | CommentPragmas: '^ IWYU pragma:' 54 | CompactNamespaces: false 55 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 56 | ConstructorInitializerIndentWidth: 4 57 | ContinuationIndentWidth: 4 58 | Cpp11BracedListStyle: true 59 | DerivePointerAlignment: false 60 | DisableFormat: false 61 | ExperimentalAutoDetectBinPacking: false 62 | FixNamespaceComments: true 63 | ForEachMacros: 64 | - forever # avoids { wrapped to next line 65 | - foreach 66 | - Q_FOREACH 67 | - BOOST_FOREACH 68 | IncludeCategories: 69 | - Regex: '^/g, '>'); 40 | } 41 | 42 | function escapeAttr(href) { 43 | return href.replace(/"/g, '"'); 44 | } 45 | 46 | function attributesToString(attributes) { 47 | if (!attributes) { 48 | return ''; 49 | } 50 | var result = []; 51 | 52 | for (var attr in attributes) { 53 | var val = attributes[attr] + ''; 54 | result.push(attr + '="' + escapeAttr(val) + '"'); 55 | } 56 | return result.join(' '); 57 | } 58 | 59 | function linkifyStr(str) { 60 | var opts = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; 61 | 62 | opts = new Options(opts); 63 | 64 | var tokens = tokenize(str); 65 | var result = []; 66 | 67 | for (var i = 0; i < tokens.length; i++) { 68 | var token = tokens[i]; 69 | 70 | if (token.type === 'nl' && opts.nl2br) { 71 | result.push('
\n'); 72 | continue; 73 | } else if (!token.isLink || !opts.check(token)) { 74 | result.push(escapeText(token.toString())); 75 | continue; 76 | } 77 | 78 | var _opts$resolve = opts.resolve(token); 79 | 80 | var formatted = _opts$resolve.formatted; 81 | var formattedHref = _opts$resolve.formattedHref; 82 | var tagName = _opts$resolve.tagName; 83 | var className = _opts$resolve.className; 84 | var target = _opts$resolve.target; 85 | var attributes = _opts$resolve.attributes; 86 | 87 | 88 | var link = '<' + tagName + ' href="' + escapeAttr(formattedHref) + '"'; 89 | 90 | if (className) { 91 | link += ' class="' + escapeAttr(className) + '"'; 92 | } 93 | 94 | if (target) { 95 | link += ' target="' + escapeAttr(target) + '"'; 96 | } 97 | 98 | if (attributes) { 99 | link += ' ' + attributesToString(attributes); 100 | } 101 | 102 | link += '>' + escapeText(formatted) + ''; 103 | result.push(link); 104 | } 105 | 106 | return result.join(''); 107 | } 108 | 109 | if (!String.prototype.linkify) { 110 | String.prototype.linkify = function (opts) { 111 | return linkifyStr(this, opts); 112 | }; 113 | } 114 | 115 | return linkifyStr; 116 | }(linkify); 117 | window.linkifyStr = linkifyString; 118 | })(window, linkify); 119 | -------------------------------------------------------------------------------- /src/globalinstances.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2015-2022 Savoir-faire Linux Inc. * 3 | * Author : Stepan Salenikovich * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include 21 | 22 | #include 23 | 24 | namespace Interfaces { 25 | class ContactMethodSelectorI; 26 | class DBusErrorHandlerI; 27 | class PixmapManipulatorI; 28 | class ShortcutCreatorI; 29 | } // namespace Interfaces 30 | 31 | /** 32 | * Use these functions to get and set the global instance of the implementation of each interface. 33 | * 34 | * The setter functions demand an std::unique_ptr because they become the object owners. 35 | * 36 | * Note that certain interfaces do not have a default implementation in LRC, in this case the getter 37 | * function will throw an exception if no instance has been set by the client. 38 | */ 39 | namespace GlobalInstances { 40 | 41 | /** 42 | * LRC does not provide a default implementation of this interface, thus an exception will be thrown 43 | * if this getter is called without an instance being set by the client 44 | */ 45 | 46 | Interfaces::DBusErrorHandlerI& dBusErrorHandler(); 47 | void setDBusErrorHandler(std::unique_ptr instance); 48 | 49 | /** 50 | * LRC does not provide a default implementation of this interface, thus an exception will be thrown 51 | * if this getter is called without an instance being set by the client 52 | */ 53 | 54 | LIB_EXPORT Interfaces::PixmapManipulatorI& pixmapManipulator(); 55 | void LIB_EXPORT setPixmapManipulator(std::unique_ptr instance); 56 | 57 | LIB_EXPORT Interfaces::ShortcutCreatorI& shortcutCreator(); 58 | void LIB_EXPORT setShortcutCreator(std::unique_ptr instance); 59 | 60 | // Private use only 61 | void setInterfaceInternal(Interfaces::ContactMethodSelectorI*); 62 | void setInterfaceInternal(Interfaces::DBusErrorHandlerI*); 63 | void setInterfaceInternal(Interfaces::PixmapManipulatorI*); 64 | void setInterfaceInternal(Interfaces::ShortcutCreatorI*); 65 | 66 | /** 67 | * Generic interface setter. This metamethod can set any type of interface 68 | * dynamically using variadic template, compile time type deduction and 69 | * the macro subsystem. Passing an invalid interface should trigger compile 70 | * time errors. 71 | * 72 | * The interface object is created internally and additional parameters 73 | * can be passed. 74 | */ 75 | template 76 | void 77 | setInterface(Ts... args) 78 | { 79 | try { 80 | auto i = new I(args...); 81 | setInterfaceInternal(i); 82 | } catch (void* e) { // TODO define some kind of object for errors like this 83 | qDebug() << "Interface could not be set"; 84 | } 85 | } 86 | 87 | } // namespace GlobalInstances 88 | -------------------------------------------------------------------------------- /src/qtwrapper/pluginmanager_wrap.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 2014-2022 Savoir-faire Linux Inc. * 3 | * Author : Aline Gondim Santos * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the Lesser GNU General Public License * 16 | * along with this program. If not, see . * 17 | *****************************************************************************/ 18 | #pragma once 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "typedefs.h" 30 | #ifdef ENABLE_PLUGIN 31 | #include 32 | #endif 33 | #include "conversions_wrap.hpp" 34 | 35 | /* 36 | * Proxy class for interface org.ring.Ring.PluginManager 37 | */ 38 | class PluginManagerInterface : public QObject 39 | { 40 | Q_OBJECT 41 | public: 42 | PluginManagerInterface() {} 43 | ~PluginManagerInterface() {} 44 | 45 | public Q_SLOTS: // METHODS 46 | 47 | bool loadPlugin(const QString& path); 48 | 49 | bool unloadPlugin(const QString& path); 50 | 51 | MapStringString getPluginDetails(const QString& path); 52 | 53 | QStringList getInstalledPlugins(); 54 | 55 | QStringList getLoadedPlugins(); 56 | 57 | int installPlugin(const QString& jplPath, bool force); 58 | 59 | int uninstallPlugin(const QString& pluginRootPath); 60 | 61 | QStringList getCallMediaHandlers(); 62 | 63 | void toggleCallMediaHandler(const QString& mediaHandlerId, const QString& callId, bool toggle); 64 | 65 | QStringList getChatHandlers(); 66 | 67 | void toggleChatHandler(const QString& chatHandlerId, 68 | const QString& accountId, 69 | const QString& peerId, 70 | bool toggle); 71 | 72 | QStringList getCallMediaHandlerStatus(const QString& callId); 73 | 74 | MapStringString getCallMediaHandlerDetails(const QString& mediaHandlerId); 75 | 76 | QStringList getChatHandlerStatus(const QString& accountId, const QString& peerId); 77 | 78 | MapStringString getChatHandlerDetails(const QString& chatHandlerId); 79 | 80 | void setPluginsEnabled(bool enable); 81 | 82 | bool getPluginsEnabled(); 83 | 84 | VectorMapStringString getPluginPreferences(const QString& path, const QString& accountId); 85 | 86 | bool setPluginPreference(const QString& path, 87 | const QString& accountId, 88 | const QString& key, 89 | const QString& value); 90 | 91 | MapStringString getPluginPreferencesValues(const QString& path, const QString& accountId); 92 | 93 | bool resetPluginPreferencesValues(const QString& path, const QString& accountId); 94 | }; 95 | 96 | namespace org { 97 | namespace ring { 98 | namespace Ring { 99 | typedef ::PluginManagerInterface PluginManager; 100 | } 101 | } // namespace ring 102 | } // namespace org 103 | -------------------------------------------------------------------------------- /src/api/newcodecmodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2018-2022 Savoir-faire Linux Inc. * 3 | * Author: Sébastien Blin * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include "api/account.h" 21 | #include "typedefs.h" 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | namespace lrc { 29 | 30 | class CallbacksHandler; 31 | class NewCodecModelPimpl; 32 | 33 | namespace api { 34 | 35 | namespace account { 36 | struct Info; 37 | } 38 | 39 | struct Codec 40 | { 41 | unsigned int id; 42 | bool enabled; 43 | QString name; 44 | QString samplerate; 45 | QString bitrate; 46 | QString min_bitrate; 47 | QString max_bitrate; 48 | QString type; 49 | QString quality; 50 | QString min_quality; 51 | QString max_quality; 52 | bool auto_quality_enabled; 53 | }; 54 | 55 | /** 56 | * @brief Class that manages ring devices for an account 57 | */ 58 | class LIB_EXPORT NewCodecModel : public QObject 59 | { 60 | Q_OBJECT 61 | 62 | public: 63 | const account::Info& owner; 64 | 65 | NewCodecModel(const account::Info& owner, const CallbacksHandler& callbacksHandler); 66 | ~NewCodecModel(); 67 | 68 | /** 69 | * @return audio codecs for the account 70 | */ 71 | QList getAudioCodecs() const; 72 | /** 73 | * @return video codecs for the account 74 | */ 75 | QList getVideoCodecs() const; 76 | /** 77 | * Set a higher priority to a codec 78 | * @param codecId 79 | * @param isVideo 80 | */ 81 | void increasePriority(const unsigned int& codecid, bool isVideo); 82 | /** 83 | * Set a lower priority to a codec 84 | * @param codecId 85 | * @param isVideo 86 | */ 87 | void decreasePriority(const unsigned int& codecid, bool isVideo); 88 | /** 89 | * Enable a codec 90 | * @param codecId 91 | * @param enabled true if enabled else false 92 | * @return if codecId is the only codec impacted 93 | */ 94 | bool enable(const unsigned int& codecid, bool enabled); 95 | /** 96 | * Enable/Disable auto quality for this codec 97 | * @param codecId 98 | * @param on true if enabled else false 99 | * @return 100 | */ 101 | void autoQuality(const unsigned int& codecid, bool on); 102 | /** 103 | * Change wanted quality 104 | * @param codecId 105 | * @param quality 106 | * @return 107 | */ 108 | void quality(const unsigned int& codecid, double quality); 109 | /** 110 | * Change wanted bitrate 111 | * @param codecId 112 | * @param bitrate 113 | * @return 114 | */ 115 | void bitrate(const unsigned int& codecid, double bitrate); 116 | 117 | private: 118 | std::unique_ptr pimpl_; 119 | }; 120 | } // namespace api 121 | } // namespace lrc 122 | Q_DECLARE_METATYPE(lrc::api::NewCodecModel*) 123 | -------------------------------------------------------------------------------- /src/api/newdevicemodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Sébastien Blin * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include "api/account.h" 21 | #include "typedefs.h" 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | namespace lrc { 30 | 31 | class CallbacksHandler; 32 | class NewDeviceModelPimpl; 33 | 34 | namespace api { 35 | 36 | namespace account { 37 | struct Info; 38 | } 39 | 40 | struct Device 41 | { 42 | QString id = ""; 43 | QString name = ""; 44 | bool isCurrent = false; 45 | }; 46 | 47 | /** 48 | * @brief Class that manages ring devices for an account 49 | */ 50 | class LIB_EXPORT NewDeviceModel : public QObject 51 | { 52 | Q_OBJECT 53 | 54 | public: 55 | /** 56 | * Used by deviceRevoked's status 57 | */ 58 | enum class Status { SUCCESS = 0, WRONG_PASSWORD = 1, UNKNOWN_DEVICE = 2 }; 59 | const account::Info& owner; 60 | 61 | NewDeviceModel(const account::Info& owner, const CallbacksHandler& callbacksHandler); 62 | ~NewDeviceModel(); 63 | 64 | /** 65 | * Get ring devices of an account 66 | * @return a copy of current devices 67 | */ 68 | QList getAllDevices() const; 69 | 70 | /** 71 | * Retrieve a device by its id 72 | * @param id of the device 73 | * @return the device if found else a device with a null id 74 | */ 75 | Device getDevice(const QString& id) const; 76 | 77 | /** 78 | * Revoke a ring device 79 | * @param id of the device to revoke 80 | * @param password of the account's archive 81 | * @note will emit deviceRevoked when finished 82 | */ 83 | Q_INVOKABLE void revokeDevice(const QString& id, const QString& password); 84 | 85 | /** 86 | * Change the name of the current device 87 | * @param newName 88 | * @note will emit deviceUpdated when finished 89 | * @note ring can't change the name of another device 90 | */ 91 | void setCurrentDeviceName(const QString& newName); 92 | 93 | Q_SIGNALS: 94 | /** 95 | * Link to this signal to know when a new device is added 96 | * @param id added device 97 | */ 98 | void deviceAdded(const QString& id) const; 99 | /** 100 | * Link to this signal to know when a device is removed 101 | * @param id removed device 102 | * @param Status (SUCCESS, WRONG_PASSWORD, UNKNOWN_DEVICE) 103 | */ 104 | void deviceRevoked(const QString& id, const Status status) const; 105 | /** 106 | * Link to this signal when a device get a new name 107 | * @param id 108 | */ 109 | void deviceUpdated(const QString& id) const; 110 | 111 | private: 112 | std::unique_ptr pimpl_; 113 | }; 114 | } // namespace api 115 | } // namespace lrc 116 | Q_DECLARE_METATYPE(lrc::api::NewDeviceModel*) 117 | -------------------------------------------------------------------------------- /src/api/conversation.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Nicolas Jäger * 4 | * Author: Sébastien Blin * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #include "interaction.h" 22 | #include "messagelistmodel.h" 23 | #include "member.h" 24 | #include "typedefs.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | namespace lrc { 31 | 32 | namespace api { 33 | 34 | namespace conversation { 35 | Q_NAMESPACE 36 | Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") 37 | 38 | enum class Mode { ONE_TO_ONE, ADMIN_INVITES_ONLY, INVITES_ONLY, PUBLIC, NON_SWARM }; 39 | Q_ENUM_NS(Mode) 40 | 41 | static inline Mode 42 | to_mode(const int intMode) 43 | { 44 | switch (intMode) { 45 | case 0: 46 | return Mode::ONE_TO_ONE; 47 | case 1: 48 | return Mode::ADMIN_INVITES_ONLY; 49 | case 2: 50 | return Mode::INVITES_ONLY; 51 | case 3: 52 | return Mode::PUBLIC; 53 | case 4: 54 | return Mode::NON_SWARM; 55 | default: 56 | return Mode::ONE_TO_ONE; 57 | } 58 | } 59 | 60 | struct Info 61 | { 62 | Info() 63 | : interactions(std::make_unique(nullptr)) 64 | {} 65 | Info(const Info& other) = delete; 66 | Info(Info&& other) = default; 67 | Info& operator=(const Info& other) = delete; 68 | Info& operator=(Info&& other) = default; 69 | 70 | bool allMessagesLoaded = false; 71 | QString uid = ""; 72 | QString accountId; 73 | QVector participants; 74 | QString callId; 75 | QString confId; 76 | std::unique_ptr interactions; 77 | QString lastMessageUid = 0; 78 | QHash parentsId; // pair messageid/parentid for messages without parent loaded 79 | unsigned int unreadMessages = 0; 80 | 81 | QSet typers; 82 | 83 | MapStringString infos {}; 84 | 85 | QString getCallId() const { return confId.isEmpty() ? callId : confId; } 86 | 87 | inline bool isLegacy() const { return mode == Mode::NON_SWARM; } 88 | inline bool isSwarm() const { return !isLegacy(); } 89 | // for each contact we must have one non-swarm conversation or one active one-to-one 90 | // conversation. Where active means peer did not leave the conversation. 91 | inline bool isCoreDialog() const { return isLegacy() || mode == Mode::ONE_TO_ONE; }; 92 | 93 | inline QStringList participantsUris() const 94 | { 95 | QStringList result; 96 | for (const auto& p : participants) 97 | result.append(p.uri); 98 | return result; 99 | } 100 | 101 | Mode mode = Mode::NON_SWARM; 102 | bool needsSyncing = false; 103 | bool isRequest = false; 104 | bool readOnly = false; 105 | }; 106 | 107 | } // namespace conversation 108 | } // namespace api 109 | } // namespace lrc 110 | -------------------------------------------------------------------------------- /src/directrenderer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2012-2022 Savoir-faire Linux Inc. 3 | * Author: Alexandre Lision 4 | * Author: Guillaume Roguez 5 | * Author: Andreas Traczyk 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library 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 GNU 15 | * Lesser 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 | #include "directrenderer.h" 22 | 23 | #include "dbus/videomanager.h" 24 | #include "videomanager_interface.h" 25 | 26 | #include 27 | 28 | namespace lrc { 29 | namespace video { 30 | 31 | using namespace lrc::api::video; 32 | 33 | struct DirectRenderer::Impl : public QObject 34 | { 35 | Q_OBJECT 36 | public: 37 | Impl(DirectRenderer* parent) 38 | : QObject(nullptr) 39 | , parent_(parent) 40 | { 41 | configureTarget(); 42 | VideoManager::instance().registerSinkTarget(parent_->id(), target); 43 | }; 44 | ~Impl() 45 | { 46 | parent_->stopRendering(); 47 | VideoManager::instance().registerSinkTarget(parent_->id(), {}); 48 | } 49 | 50 | // sink target callbacks 51 | void configureTarget() 52 | { 53 | using namespace std::placeholders; 54 | target.pull = std::bind(&Impl::pullCallback, this); 55 | target.push = std::bind(&Impl::pushCallback, this, _1); 56 | }; 57 | 58 | DRing::FrameBuffer pullCallback() 59 | { 60 | QMutexLocker lk(&mutex); 61 | if (!frameBufferPtr) { 62 | frameBufferPtr.reset(av_frame_alloc()); 63 | } 64 | 65 | // A response to this signal should be used to provide client 66 | // allocated buffer specs via the AVFrame structure. 67 | // Important: Subscription to this signal MUST be synchronous(Qt::DirectConnection). 68 | Q_EMIT parent_->frameBufferRequested(frameBufferPtr.get()); 69 | 70 | if (frameBufferPtr->data[0] == nullptr) { 71 | return nullptr; 72 | } 73 | 74 | return std::move(frameBufferPtr); 75 | }; 76 | 77 | void pushCallback(DRing::FrameBuffer buf) 78 | { 79 | { 80 | QMutexLocker lk(&mutex); 81 | frameBufferPtr = std::move(buf); 82 | } 83 | 84 | Q_EMIT parent_->frameUpdated(); 85 | }; 86 | 87 | private: 88 | DirectRenderer* parent_; 89 | 90 | public: 91 | DRing::SinkTarget target; 92 | QMutex mutex; 93 | DRing::FrameBuffer frameBufferPtr; 94 | }; 95 | 96 | DirectRenderer::DirectRenderer(const QString& id, const QSize& res) 97 | : Renderer(id, res) 98 | , pimpl_(std::make_unique(this)) 99 | {} 100 | 101 | DirectRenderer::~DirectRenderer() {} 102 | 103 | void 104 | DirectRenderer::startRendering() 105 | { 106 | Q_EMIT started(); 107 | } 108 | 109 | void 110 | DirectRenderer::stopRendering() 111 | { 112 | Q_EMIT stopped(); 113 | } 114 | 115 | void 116 | DirectRenderer::update(const QSize& res, const QString&) 117 | { 118 | stopRendering(); 119 | Renderer::update(res); 120 | 121 | VideoManager::instance().registerSinkTarget(id(), pimpl_->target); 122 | startRendering(); 123 | } 124 | 125 | Frame 126 | DirectRenderer::currentFrame() const 127 | { 128 | return {}; 129 | } 130 | 131 | } // namespace video 132 | } // namespace lrc 133 | 134 | #include "moc_directrenderer.cpp" 135 | #include "directrenderer.moc" 136 | -------------------------------------------------------------------------------- /src/interfaces/pixmapmanipulatori.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2013-2022 Savoir-faire Linux Inc. * 3 | * Author : Emmanuel Lepage Vallee * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include 21 | 22 | // Qt 23 | class QVariant; 24 | class QModelIndex; 25 | class QByteArray; 26 | 27 | // Ring 28 | struct UserActionElement; 29 | 30 | namespace lrc { 31 | namespace api { 32 | namespace account { 33 | struct Info; 34 | } 35 | namespace conversation { 36 | struct Info; 37 | } 38 | } // namespace api 39 | } // namespace lrc 40 | 41 | namespace Interfaces { 42 | 43 | /** 44 | * Different clients can have multiple way of displaying images. Some may 45 | * add borders, other add corner radius (see Ubuntu-SDK HIG). This 46 | * abstract class define many operations that can be defined by each clients. 47 | * 48 | * Most methods return QVariants as this library doesn't link against QtGui 49 | * 50 | * This interface is not frozen, more methods may be added later. 51 | */ 52 | class PixmapManipulatorI 53 | { 54 | public: 55 | // Implementation can use random values to extend this 56 | enum CollectionIconHint { 57 | NONE, 58 | HISTORY, 59 | CONTACT, 60 | BOOKMARK, 61 | PHONE_NUMBER, 62 | RINGTONE, 63 | PROFILE, 64 | CERTIFICATE, 65 | ACCOUNT, 66 | RECORDING, 67 | MACRO, 68 | }; 69 | 70 | virtual ~PixmapManipulatorI() = default; 71 | 72 | virtual QVariant conversationPhoto(const lrc::api::conversation::Info& conversation, 73 | const lrc::api::account::Info& accountInfo, 74 | const QSize& size, 75 | bool displayPresence = true) 76 | { 77 | Q_UNUSED(conversation); 78 | Q_UNUSED(accountInfo); 79 | Q_UNUSED(size); 80 | Q_UNUSED(displayPresence); 81 | return {}; 82 | } 83 | virtual QVariant numberCategoryIcon(const QVariant& p, 84 | const QSize& size, 85 | bool displayPresence = false, 86 | bool isPresent = false) 87 | = 0; 88 | virtual QByteArray toByteArray(const QVariant& pxm) = 0; 89 | virtual QVariant personPhoto(const QByteArray& data, const QString& type = "PNG") = 0; 90 | virtual QVariant decorationRole(const QModelIndex& index) = 0; 91 | virtual QVariant decorationRole(const lrc::api::conversation::Info& conversation, 92 | const lrc::api::account::Info& accountInfo) 93 | { 94 | Q_UNUSED(conversation); 95 | Q_UNUSED(accountInfo); 96 | return {}; 97 | } 98 | 99 | /** 100 | * Return the icons associated with the action and its state 101 | */ 102 | virtual QVariant userActionIcon(const UserActionElement& state) const = 0; 103 | }; 104 | 105 | } // namespace Interfaces 106 | -------------------------------------------------------------------------------- /src/api/lrc.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Nicolas Jäger * 4 | * Author: Sébastien Blin * 5 | * Author : Aline Gondim Santos * 6 | * * 7 | * This library is free software; you can redistribute it and/or * 8 | * modify it under the terms of the GNU Lesser General Public * 9 | * License as published by the Free Software Foundation; either * 10 | * version 2.1 of the License, or (at your option) any later version. * 11 | * * 12 | * This library 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 GNU * 15 | * Lesser 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 | #pragma once 21 | 22 | #include "typedefs.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | namespace lrc { 29 | 30 | class LrcPimpl; 31 | 32 | namespace api { 33 | 34 | class BehaviorController; 35 | class NewAccountModel; 36 | class DataTransferModel; 37 | class AVModel; 38 | class PluginModel; 39 | 40 | class LIB_EXPORT Lrc 41 | { 42 | public: 43 | /** 44 | * Construct an Lrc object and optionally invoke callbacks 45 | * to control ui informing the user of a possibly lengthy 46 | * migration process. 47 | * @param willMigrateCb 48 | * @param didMigrateCb 49 | */ 50 | Lrc(MigrationCb willMigrateCb = {}, MigrationCb didMigrateCb = {}, bool muteDring = false); 51 | ~Lrc(); 52 | /** 53 | * get a reference on account model. 54 | * @return a NewAccountModel&. 55 | */ 56 | NewAccountModel& getAccountModel() const; 57 | /** 58 | * get a reference on the behavior controller. 59 | * @return a BehaviorController&. 60 | */ 61 | BehaviorController& getBehaviorController() const; 62 | /** 63 | * get a reference on the audio-video controller. 64 | * @return a AVModel&. 65 | */ 66 | AVModel& getAVModel() const; 67 | 68 | /** 69 | * get a reference on the PLUGIN controller. 70 | * @return a PluginModel&. 71 | */ 72 | PluginModel& getPluginModel() const; 73 | 74 | /** 75 | * Inform the daemon that the connectivity changed 76 | */ 77 | void connectivityChanged() const; 78 | 79 | /** 80 | * Test connection with daemon 81 | */ 82 | static bool isConnected(); 83 | /** 84 | * Can communicate with the daemon via dbus 85 | */ 86 | static bool dbusIsValid(); 87 | /** 88 | * Connect to debugMessageReceived signal 89 | */ 90 | void subscribeToDebugReceived(); 91 | 92 | /** 93 | * Helper: get active call list from daemon 94 | */ 95 | static VectorString activeCalls(); 96 | 97 | /** 98 | * Close all active calls and conferences 99 | */ 100 | void hangupCallsAndConferences(); 101 | 102 | /** 103 | * Helper: get call list from daemon 104 | */ 105 | static VectorString getCalls(); 106 | 107 | /** 108 | * Helper: get conference list from daemon 109 | */ 110 | static VectorString getConferences(const QString& accountId = ""); 111 | 112 | /** 113 | * Preference 114 | */ 115 | static std::atomic_bool holdConferences; 116 | 117 | /** 118 | * If cache contact's avatar or reload 119 | */ 120 | static std::atomic_bool cacheAvatars; 121 | 122 | /** 123 | * Make monitor continous or discrete 124 | */ 125 | static void monitor(bool continous); 126 | 127 | private: 128 | std::unique_ptr lrcPimpl_; 129 | }; 130 | 131 | } // namespace api 132 | } // namespace lrc 133 | -------------------------------------------------------------------------------- /src/api/behaviorcontroller.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Nicolas Jäger * 4 | * Author: Sébastien Blin * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #include "typedefs.h" 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace lrc { 28 | 29 | class BehaviorControllerPimpl; 30 | 31 | namespace api { 32 | class Lrc; 33 | 34 | namespace conversation { 35 | struct Info; 36 | } 37 | 38 | namespace interaction { 39 | struct Info; 40 | } 41 | 42 | /** 43 | * @brief Class that helps to control behaviors from the client side. 44 | * @note This class must only refer to the common behaviors. 45 | */ 46 | class LIB_EXPORT BehaviorController : public QObject 47 | { 48 | Q_OBJECT 49 | 50 | public: 51 | BehaviorController(); 52 | ~BehaviorController(); 53 | 54 | Q_SIGNALS: 55 | /** 56 | * Emitted when the client should open the chat view. 57 | */ 58 | void showChatView(const QString& accountId, const QString& convUid) const; 59 | /** 60 | * Emitted when the client should ask the user whether it wants to leave a message after a 61 | * failed call. 62 | */ 63 | void showLeaveMessageView(const QString& accountId, const QString& convUid) const; 64 | /** 65 | * Emitted when the client should open the call view. 66 | */ 67 | void showCallView(const QString& accountId, const QString& convUid) const; 68 | /** 69 | * Emitted when the client should open the incoming call view. 70 | */ 71 | void showIncomingCallView(const QString& accountId, const QString& convUid) const; 72 | /** 73 | * Emitted when the client receives a new trust request 74 | */ 75 | void newTrustRequest(const QString& accountId, const QString& conversationId, const QString& contactUri) const; 76 | /** 77 | * Emitted when a trust request has been accepted, refused or blocked 78 | */ 79 | void trustRequestTreated(const QString& accountId, const QString& contactUri) const; 80 | /** 81 | * Emitted when the client receives an unread message to display (text or file for now) 82 | */ 83 | void newUnreadInteraction(const QString& accountId, 84 | const QString& conversation, 85 | const QString& interactionId, 86 | const interaction::Info& interaction) const; 87 | /** 88 | * Emitted when the unread interaction is now read 89 | */ 90 | void newReadInteraction(const QString& accountId, 91 | const QString& conversation, 92 | const QString& interactionId) const; 93 | /** 94 | * Emitted debugMessageReceived 95 | */ 96 | void debugMessageReceived(const QString& message); 97 | /** 98 | * Emitted audioMeter 99 | */ 100 | void audioMeter(const QString& id, float level); 101 | 102 | /** 103 | * Emitted callStatusChanged 104 | */ 105 | void callStatusChanged(const QString& accountId, const QString& callId) const; 106 | }; 107 | } // namespace api 108 | } // namespace lrc 109 | Q_DECLARE_METATYPE(lrc::api::BehaviorController*) 110 | -------------------------------------------------------------------------------- /src/api/datatransfermodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2018-2022 Savoir-faire Linux Inc. * 3 | * Author: Guillaume Roguez * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | #include "api/datatransfer.h" 21 | #include "api/account.h" 22 | 23 | #include "typedefs.h" 24 | 25 | #include 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace lrc { 32 | 33 | class CallbacksHandler; 34 | class Database; 35 | 36 | namespace api { 37 | 38 | class BehaviorController; 39 | 40 | namespace datatransfer { 41 | class Info; 42 | } // namespace datatransfer 43 | 44 | /** 45 | * @brief Class that manages data transfer. 46 | */ 47 | class LIB_EXPORT DataTransferModel : public QObject 48 | { 49 | Q_OBJECT 50 | public: 51 | DataTransferModel(); 52 | ~DataTransferModel(); 53 | 54 | void sendFile(const QString& account_id, 55 | const QString& peer_uri, 56 | const QString& conversationId, 57 | const QString& file_path, 58 | const QString& display_name); 59 | 60 | void transferInfo(const QString& accountId, const QString& fileId, datatransfer::Info& lrc_info); 61 | 62 | void fileTransferInfo(const QString& accountId, 63 | const QString& conversationId, 64 | const QString& fileId, 65 | QString& path, 66 | qlonglong& total, 67 | qlonglong& progress); 68 | 69 | QString accept(const QString& accountId, const QString& fileId, const QString& filePath = {}); 70 | 71 | void download(const QString& accountId, 72 | const QString& convId, 73 | const QString& interactionId, 74 | const QString& fileId, 75 | const QString& filePath = {}); 76 | 77 | void copyTo(const QString& accountId, 78 | const QString& convId, 79 | const QString& interactionId, 80 | const QString& destPath, 81 | const QString& displayName); 82 | 83 | void cancel(const QString& accountId, const QString& conversationId, const QString& fileId); 84 | 85 | void registerTransferId(const QString& fileId, const QString& interactionId); 86 | 87 | QString getInteractionIdFromFileId(const QString& fileId); 88 | 89 | QString getFileIdFromInteractionId(const QString& fileId); 90 | 91 | /** 92 | * Creates APPDATA/received and return the path 93 | */ 94 | static QString createDefaultDirectory(); 95 | 96 | Q_SIGNALS: 97 | /** 98 | * Connect this signal to know when a data transfer is incoming. 99 | */ 100 | void incomingTransfer(api::datatransfer::Info dataTransferInfo); 101 | 102 | /** 103 | * Connect this signal to know when an existing data transfer has changed of status. 104 | * @param transfer_id unique identification of incoming data transfer. 105 | * @param status reported status. 106 | */ 107 | void transferStatusChanged(const QString& uid, datatransfer::Status status); 108 | 109 | private: 110 | class Impl; 111 | std::unique_ptr pimpl_; 112 | }; 113 | } // namespace api 114 | } // namespace lrc 115 | Q_DECLARE_METATYPE(lrc::api::DataTransferModel*) 116 | -------------------------------------------------------------------------------- /src/qtwrapper/pluginmanagerMock.cpp: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 2014-2022 Savoir-faire Linux Inc. * 3 | * Author : Aline Gondim Santos * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the Lesser GNU General Public License * 16 | * along with this program. If not, see . * 17 | *****************************************************************************/ 18 | #pragma once 19 | 20 | #include "pluginmanager_wrap.h" 21 | 22 | bool 23 | PluginManagerInterface::loadPlugin(const QString& path) 24 | { 25 | return false; 26 | } 27 | 28 | bool 29 | PluginManagerInterface::unloadPlugin(const QString& path) 30 | { 31 | return false; 32 | } 33 | 34 | MapStringString 35 | PluginManagerInterface::getPluginDetails(const QString& path) 36 | { 37 | return {}; 38 | } 39 | 40 | QStringList 41 | PluginManagerInterface::getInstalledPlugins() 42 | { 43 | return {}; 44 | } 45 | 46 | QStringList 47 | PluginManagerInterface::getLoadedPlugins() 48 | { 49 | return {}; 50 | } 51 | 52 | int 53 | PluginManagerInterface::installPlugin(const QString& jplPath, bool force) 54 | { 55 | return 0; 56 | } 57 | 58 | int 59 | PluginManagerInterface::uninstallPlugin(const QString& pluginRootPath) 60 | { 61 | return 0; 62 | } 63 | 64 | QStringList 65 | PluginManagerInterface::getCallMediaHandlers() 66 | { 67 | return {}; 68 | } 69 | 70 | void 71 | PluginManagerInterface::toggleCallMediaHandler(const QString& mediaHandlerId, 72 | const QString& callId, 73 | bool toggle) 74 | {} 75 | 76 | QStringList 77 | PluginManagerInterface::getChatHandlers() 78 | { 79 | return {}; 80 | } 81 | 82 | void 83 | PluginManagerInterface::toggleChatHandler(const QString& chatHandlerId, 84 | const QString& accountId, 85 | const QString& peerId, 86 | bool toggle) 87 | {} 88 | 89 | QStringList 90 | PluginManagerInterface::getCallMediaHandlerStatus(const QString& callId) 91 | { 92 | return {}; 93 | } 94 | 95 | MapStringString 96 | PluginManagerInterface::getCallMediaHandlerDetails(const QString& mediaHandlerId) 97 | { 98 | return {}; 99 | } 100 | 101 | QStringList 102 | PluginManagerInterface::getChatHandlerStatus(const QString& accountId, const QString& peerId) 103 | { 104 | return {}; 105 | } 106 | 107 | MapStringString 108 | PluginManagerInterface::getChatHandlerDetails(const QString& chatHandlerId) 109 | { 110 | return {}; 111 | } 112 | 113 | void 114 | PluginManagerInterface::setPluginsEnabled(bool enable) 115 | {} 116 | 117 | bool 118 | PluginManagerInterface::getPluginsEnabled() 119 | { 120 | return false; 121 | } 122 | 123 | VectorMapStringString 124 | PluginManagerInterface::getPluginPreferences(const QString& path, const QString& accountId) 125 | { 126 | return {}; 127 | } 128 | 129 | bool 130 | PluginManagerInterface::setPluginPreference(const QString& path, 131 | const QString& accountId, 132 | const QString& key, 133 | const QString& value) 134 | { 135 | return false; 136 | } 137 | 138 | MapStringString 139 | PluginManagerInterface::getPluginPreferencesValues(const QString& path, const QString& accountId) 140 | { 141 | return {}; 142 | } 143 | 144 | bool 145 | PluginManagerInterface::resetPluginPreferencesValues(const QString& path, const QString& accountId) 146 | { 147 | return false; 148 | } 149 | -------------------------------------------------------------------------------- /src/globalinstances.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2015-2022 Savoir-faire Linux Inc. * 3 | * Author : Stepan Salenikovich * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #include "globalinstances.h" 19 | 20 | #include 21 | 22 | #include "interfaces/dbuserrorhandleri.h" 23 | #include "interfaces/pixmapmanipulatori.h" 24 | 25 | #include "dbuserrorhandlerdefault.h" 26 | #include "pixmapmanipulatordefault.h" 27 | 28 | namespace GlobalInstances { 29 | 30 | struct InstanceManager 31 | { 32 | std::unique_ptr m_dBusErrorHandler; 33 | std::unique_ptr m_pixmapManipulator; 34 | }; 35 | 36 | static InstanceManager& 37 | instanceManager() 38 | { 39 | static std::unique_ptr manager {new InstanceManager}; 40 | return *manager.get(); 41 | } 42 | /** 43 | * LRC does not provide a default implementation of this interface, thus an exception will be thrown 44 | * if this getter is called without an instance being set by the client 45 | */ 46 | 47 | Interfaces::DBusErrorHandlerI& 48 | dBusErrorHandler() 49 | { 50 | if (!instanceManager().m_dBusErrorHandler) 51 | instanceManager().m_dBusErrorHandler.reset(new Interfaces::DBusErrorHandlerDefault); 52 | return *instanceManager().m_dBusErrorHandler; 53 | } 54 | 55 | void 56 | setDBusErrorHandler(std::unique_ptr instance) 57 | { 58 | // do not allow empty pointers 59 | if (!instance) { 60 | qWarning() << "ignoring empty unique_ptr"; 61 | return; 62 | } 63 | instanceManager().m_dBusErrorHandler = std::move(instance); 64 | } 65 | 66 | /** 67 | * LRC does not provide a default implementation of this interface, thus an exception will be thrown 68 | * if this getter is called without an instance being set by the client 69 | */ 70 | 71 | Interfaces::PixmapManipulatorI& 72 | pixmapManipulator() 73 | { 74 | if (!instanceManager().m_pixmapManipulator) 75 | instanceManager().m_pixmapManipulator.reset(new Interfaces::PixmapManipulatorDefault); 76 | return *instanceManager().m_pixmapManipulator.get(); 77 | } 78 | 79 | void 80 | setPixmapManipulator(std::unique_ptr instance) 81 | { 82 | // do not allow empty pointers 83 | if (!instance) { 84 | qWarning() << "ignoring empty unique_ptr"; 85 | return; 86 | } 87 | instanceManager().m_pixmapManipulator = std::move(instance); 88 | } 89 | 90 | /* 91 | * This API have some advantage over a more "explicit" one 92 | * 1) It treat interfaces as class instead of as objects, making conceptual sense 93 | * 2) It remove the boilerplate code related to creating the unique_ptr away from 94 | * the client 95 | * 3) It offer a transparent entry point for interface without having to 96 | * extend the API when adding new interfaces 97 | * 4) It mimic the addCollection interface, making the API more consistent. It 98 | * also does so without the tick layer of black magic used in the Media and 99 | * collection APIs. 100 | */ 101 | #define REGISTER_INTERFACE(I, m) \ 102 | void setInterfaceInternal(I* i) { instanceManager().m = std::unique_ptr(i); } 103 | 104 | #pragma GCC diagnostic push 105 | #pragma GCC diagnostic ignored "-Wmissing-declarations" 106 | 107 | REGISTER_INTERFACE(Interfaces::DBusErrorHandlerI, m_dBusErrorHandler) 108 | REGISTER_INTERFACE(Interfaces::PixmapManipulatorI, m_pixmapManipulator) 109 | 110 | #pragma GCC diagnostic pop 111 | 112 | #undef REGISTER_INTERFACE 113 | 114 | } // namespace GlobalInstances 115 | -------------------------------------------------------------------------------- /src/chatview.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2020-2022 Savoir-faire Linux Inc. * 3 | * Author: Sébastien Blin * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #include "api/chatview.h" 19 | 20 | namespace lrc { 21 | 22 | namespace api { 23 | 24 | namespace chatview { 25 | 26 | QVariantMap 27 | getTranslatedStrings(bool qwebview) 28 | { 29 | return { 30 | {"Hide chat view", QObject::tr("Hide chat view")}, 31 | {"Place video call", QObject::tr("Place video call")}, 32 | {"Show available plugins", QObject::tr("Show available plugins")}, 33 | {"Place audio call", QObject::tr("Place audio call")}, 34 | {"Add to conversations", QObject::tr("Add to conversations")}, 35 | {"Unban contact", QObject::tr("Unban contact")}, 36 | {"Send", QObject::tr("Send")}, 37 | {"Options", QObject::tr("Options")}, 38 | {"Jump to latest", QObject::tr("Jump to latest")}, 39 | {"Send file", QObject::tr("Send file")}, 40 | {"Add emoji", QObject::tr("Add emoji")}, 41 | {"Leave video message", QObject::tr("Leave video message")}, 42 | {"Leave audio message", QObject::tr("Leave audio message")}, 43 | {"Block", QObject::tr("Block")}, 44 | {"Copy to downloads", QObject::tr("Copy to downloads")}, 45 | {"Write to {0}", QObject::tr("Write to {0}")}, 46 | {"Note: an interaction will create a new contact.", 47 | QObject::tr("Note: an interaction will create a new contact.")}, 48 | {"is not in your contacts", QObject::tr("is not in your contacts")}, 49 | {"has sent you a conversation request.", 50 | QObject::tr("has sent you a conversation request.")}, 51 | {"Hello, do you want to join the conversation?", 52 | QObject::tr("Hello, do you want to join the conversation?")}, 53 | {"You have accepted the conversation request.", 54 | QObject::tr("You have accepted the conversation request.")}, 55 | {"We are waiting for another device to synchronize the conversation.", 56 | QObject::tr("We are waiting for another device to synchronize the conversation.")}, 57 | {"Note: you can automatically accept this invitation by sending a message.", 58 | QObject::tr("Note: you can automatically accept this invitation by sending a message.")}, 59 | {"%d days ago", qwebview ? QObject::tr("{0} days ago") : QObject::tr("%d days ago")}, 60 | {"%d hours ago", qwebview ? QObject::tr("{0} hours ago") : QObject::tr("%d hours ago")}, 61 | {"%d minutes ago", 62 | qwebview ? QObject::tr("{0} minutes ago") : QObject::tr("%d minutes ago")}, 63 | {"one day ago", QObject::tr("one day ago")}, 64 | {"one hour ago", QObject::tr("one hour ago")}, 65 | {"just now", QObject::tr("just now")}, 66 | {"Failure", QObject::tr("Failure")}, 67 | {"Accept", QObject::tr("Accept")}, 68 | {"Refuse", QObject::tr("Refuse")}, 69 | {"Delete", QObject::tr("Delete")}, 70 | {"Retry", QObject::tr("Retry")}, 71 | {"unjoinable peer", QObject::tr("Unable to make contact")}, 72 | {"connecting", QObject::tr("Connecting")}, 73 | {"accepted", QObject::tr("Accepted")}, 74 | {"canceled", QObject::tr("Canceled")}, 75 | {"ongoing", QObject::tr("Ongoing")}, 76 | {"awaiting peer", QObject::tr("Waiting for contact")}, 77 | {"awaiting host", QObject::tr("Incoming transfer")}, 78 | {"awaiting peer timeout", QObject::tr("Timed out waiting for contact")}, 79 | {"finished", QObject::tr("Finished")}, 80 | }; 81 | } 82 | 83 | } // namespace chatview 84 | } // namespace api 85 | } // namespace lrc 86 | -------------------------------------------------------------------------------- /src/api/datatransfer.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2018-2022 Savoir-faire Linux Inc. * 3 | * Author: Guillaume Roguez * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #pragma once 19 | 20 | // LRC 21 | #include "typedefs.h" 22 | 23 | // std 24 | #include 25 | 26 | #include 27 | 28 | namespace lrc { 29 | namespace api { 30 | 31 | namespace datatransfer { 32 | Q_NAMESPACE 33 | Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") 34 | 35 | enum class Status { 36 | on_connection, // outgoing tx: wait for connection/acceptance, incoming tx: wait for local acceptance 37 | on_progress, // connected, data transfer progress reporting 38 | success, // transfer finished with success, all data sent 39 | stop_by_peer, // error: transfer terminated by peer 40 | stop_by_host, // eror: transfer terminated by local host 41 | unjoinable_peer, // error: (outgoing only) peer connection failed 42 | timeout_expired, // error: (outgoing only) peer awaiting too long, close turn socket 43 | invalid_pathname, // error: (file transfer only) given file is not a valid 44 | unsupported, // error: unable to do the transfer (generic error) 45 | INVALID 46 | }; 47 | Q_ENUM_NS(Status) 48 | 49 | static inline const QString 50 | to_string(const Status& status) 51 | { 52 | switch (status) { 53 | case Status::on_connection: 54 | return "on_connection"; 55 | case Status::on_progress: 56 | return "on_progress"; 57 | case Status::success: 58 | return "success"; 59 | case Status::stop_by_peer: 60 | return "stop_by_peer"; 61 | case Status::stop_by_host: 62 | return "stop_by_host"; 63 | case Status::unjoinable_peer: 64 | return "unjoinable_peer"; 65 | case Status::timeout_expired: 66 | return "timeout_expired"; 67 | case Status::invalid_pathname: 68 | return "invalid_pathname"; 69 | case Status::unsupported: 70 | return "unsupported"; 71 | case Status::INVALID: 72 | default: 73 | return "INVALID"; 74 | } 75 | } 76 | 77 | static inline Status 78 | to_status(const QString& status) 79 | { 80 | if (status == "on_connection") 81 | return datatransfer::Status::on_connection; 82 | else if (status == "on_progress") 83 | return datatransfer::Status::on_progress; 84 | else if (status == "success") 85 | return datatransfer::Status::success; 86 | else if (status == "stop_by_peer") 87 | return datatransfer::Status::stop_by_peer; 88 | else if (status == "stop_by_host") 89 | return datatransfer::Status::stop_by_host; 90 | else if (status == "unjoinable_peer") 91 | return datatransfer::Status::unjoinable_peer; 92 | else if (status == "timeout_expired") 93 | return datatransfer::Status::timeout_expired; 94 | else if (status == "invalid_pathname") 95 | return datatransfer::Status::invalid_pathname; 96 | else if (status == "unsupported") 97 | return datatransfer::Status::unsupported; 98 | else 99 | return datatransfer::Status::INVALID; 100 | } 101 | 102 | struct Info 103 | { 104 | QString uid; ///< long-term and unique identifier (used for historic) 105 | Status status; 106 | bool isOutgoing; 107 | std::size_t totalSize; 108 | std::size_t progress; ///< if status >= on_progress, gives number of bytes tx/rx until now 109 | QString path; 110 | QString displayName; 111 | QString accountId; 112 | QString peerUri; 113 | QString conversationId; 114 | std::time_t timestamp = 0; 115 | }; 116 | 117 | } // namespace datatransfer 118 | 119 | } // namespace api 120 | } // namespace lrc 121 | -------------------------------------------------------------------------------- /src/peerdiscoverymodel.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2019-2022 Savoir-faire Linux Inc. * 3 | * Author: Mingrui Zhang * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | #include "api/peerdiscoverymodel.h" 19 | 20 | // new LRC 21 | #include "callbackshandler.h" 22 | 23 | // Dbus 24 | #include "dbus/configurationmanager.h" 25 | 26 | namespace lrc { 27 | 28 | using namespace api; 29 | 30 | class PeerDiscoveryModelPimpl : public QObject 31 | { 32 | Q_OBJECT 33 | public: 34 | PeerDiscoveryModelPimpl(PeerDiscoveryModel& linked, 35 | const CallbacksHandler& callbackHandler, 36 | const QString& accountID); 37 | ~PeerDiscoveryModelPimpl(); 38 | 39 | PeerDiscoveryModel& linked_; 40 | const CallbacksHandler& callbacksHandler_; 41 | const QString accountID_; 42 | 43 | public Q_SLOTS: 44 | 45 | /** 46 | * Emit peerMapStatusChanged. 47 | * @param accountId 48 | * @param status 49 | */ 50 | void slotPeerMapStatusChanged(const QString& accountID, 51 | const QString& contactUri, 52 | int state, 53 | const QString& displayname); 54 | }; 55 | 56 | PeerDiscoveryModel::PeerDiscoveryModel(const CallbacksHandler& callbacksHandler, 57 | const QString& accountID) 58 | : QObject() 59 | , pimpl_(std::make_unique(*this, callbacksHandler, accountID)) 60 | {} 61 | 62 | PeerDiscoveryModel::~PeerDiscoveryModel() {} 63 | 64 | PeerDiscoveryModelPimpl::PeerDiscoveryModelPimpl(PeerDiscoveryModel& linked, 65 | const CallbacksHandler& callbacksHandler, 66 | const QString& accountID) 67 | : linked_(linked) 68 | , callbacksHandler_(callbacksHandler) 69 | , accountID_(accountID) 70 | { 71 | connect(&callbacksHandler_, 72 | &CallbacksHandler::newPeerSubscription, 73 | this, 74 | &PeerDiscoveryModelPimpl::slotPeerMapStatusChanged); 75 | } 76 | 77 | PeerDiscoveryModelPimpl::~PeerDiscoveryModelPimpl() 78 | { 79 | disconnect(&callbacksHandler_, 80 | &CallbacksHandler::newPeerSubscription, 81 | this, 82 | &PeerDiscoveryModelPimpl::slotPeerMapStatusChanged); 83 | } 84 | 85 | void 86 | PeerDiscoveryModelPimpl::slotPeerMapStatusChanged(const QString& accountID, 87 | const QString& contactUri, 88 | int state, 89 | const QString& displayname) 90 | { 91 | if (accountID != accountID_) { 92 | return; 93 | } 94 | emit linked_.modelChanged(contactUri, 95 | state == 0 ? PeerModelChanged::INSERT : PeerModelChanged::REMOVE, 96 | displayname); 97 | } 98 | 99 | std::vector 100 | PeerDiscoveryModel::getNearbyPeers() const 101 | { 102 | std::vector result; 103 | const MapStringString nearbyPeers = ConfigurationManager::instance().getNearbyPeers( 104 | pimpl_->accountID_); 105 | result.reserve(nearbyPeers.size()); 106 | 107 | QMap::const_iterator i = nearbyPeers.constBegin(); 108 | while (i != nearbyPeers.constEnd()) { 109 | result.emplace_back(PeerContact {i.key().toStdString(), i.value().toStdString()}); 110 | ++i; 111 | } 112 | return result; 113 | } 114 | 115 | } // namespace lrc 116 | 117 | #include "api/moc_peerdiscoverymodel.cpp" 118 | #include "peerdiscoverymodel.moc" 119 | -------------------------------------------------------------------------------- /make-lrc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import tempfile 4 | import re 5 | import sys 6 | import os 7 | import subprocess 8 | import platform 9 | import argparse 10 | import multiprocessing 11 | import shutil 12 | import fileinput 13 | import re 14 | from enum import Enum 15 | 16 | qt_version_default = '6.2.3' 17 | 18 | vs_where_path = os.path.join( 19 | os.environ['ProgramFiles(x86)'], 'Microsoft Visual Studio', 'Installer', 'vswhere.exe' 20 | ) 21 | 22 | host_is_64bit = (False, True)[platform.machine().endswith('64')] 23 | this_dir = os.path.dirname(os.path.realpath(__file__)) 24 | build_dir = os.path.join(this_dir, 'build') 25 | 26 | qt_path = os.path.join('c:', os.sep, 'Qt') 27 | qt_kit_path = 'msvc2019_64' 28 | qt_root_path = os.getenv('QT_ROOT_DIRECTORY', qt_path) 29 | 30 | def execute_cmd(cmd, with_shell=False, env_vars=None, cmd_dir=os.getcwd()): 31 | p = subprocess.Popen(cmd, 32 | shell=with_shell, 33 | stdout=sys.stdout, 34 | env=env_vars, 35 | cwd=cmd_dir) 36 | _, _ = p.communicate() 37 | return p.returncode 38 | 39 | 40 | def getLatestVSVersion(): 41 | args = [ 42 | '-latest', 43 | '-products *', 44 | '-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64', 45 | '-property installationVersion' 46 | ] 47 | cmd = [vs_where_path] + args 48 | output = subprocess.check_output(' '.join(cmd)).decode('utf-8') 49 | if output: 50 | return output.splitlines()[0].split('.')[0] 51 | else: 52 | return 53 | 54 | 55 | def findVSLatestDir(): 56 | args = [ 57 | '-latest', 58 | '-products *', 59 | '-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64', 60 | '-property installationPath' 61 | ] 62 | cmd = [vs_where_path] + args 63 | output = subprocess.check_output(' '.join(cmd)).decode('utf-8') 64 | if output: 65 | return output.splitlines()[0] 66 | else: 67 | return 68 | 69 | 70 | def getVSEnv(arch='x64', platform='', version=''): 71 | env_cmd = 'set path=%path:"=% && ' + \ 72 | getVSEnvCmd(arch, platform, version) + ' && set' 73 | p = subprocess.Popen(env_cmd, 74 | shell=True, 75 | stdout=subprocess.PIPE) 76 | stdout, _ = p.communicate() 77 | out = stdout.decode('utf-8', 'ignore').split("\r\n")[5:-1] 78 | return dict(s.split('=', 1) for s in out) 79 | 80 | 81 | def getVSEnvCmd(arch='x64', platform='', version=''): 82 | vcEnvInit = [findVSLatestDir() + r'\VC\Auxiliary\Build\"vcvarsall.bat'] 83 | if platform != '': 84 | args = [arch, platform, version] 85 | else: 86 | args = [arch, version] 87 | if args: 88 | vcEnvInit.extend(args) 89 | vcEnvInit = 'call \"' + ' '.join(vcEnvInit) 90 | return vcEnvInit 91 | 92 | 93 | def build(qtver): 94 | print("Building with Qt " + qtver) 95 | 96 | config_str = 'Release' 97 | 98 | vs_env_vars = {} 99 | vs_env_vars.update(getVSEnv()) 100 | 101 | qt_dir = os.path.join(qt_root_path, qtver, qt_kit_path) 102 | daemon_dir = os.path.dirname(this_dir) + '\\daemon' 103 | daemon_bin = daemon_dir + '\\build\\x64\\ReleaseLib_win32\\bin\\jami.lib' 104 | 105 | cmake_options = [ 106 | '-DCMAKE_PREFIX_PATH=' + qt_dir, 107 | '-Dring_BIN=' + daemon_bin, 108 | '-DRING_INCLUDE_DIR=' + daemon_dir + '\\src\\jami' 109 | ] 110 | 111 | if not os.path.exists(build_dir): 112 | os.makedirs(build_dir) 113 | 114 | cmd = ['cmake', '..'] 115 | 116 | print('Configuring…') 117 | cmd.extend(cmake_options) 118 | if(execute_cmd(cmd, False, vs_env_vars, build_dir)): 119 | print("Cmake generate error") 120 | sys.exit(1) 121 | 122 | print('Building…') 123 | cmd = [ 124 | 'cmake', '--build', '.', 125 | '--config', config_str, 126 | '--', '-m' 127 | ] 128 | if(execute_cmd(cmd, False, vs_env_vars, build_dir)): 129 | print("Cmake build error") 130 | sys.exit(1) 131 | 132 | 133 | def parse_args(): 134 | ap = argparse.ArgumentParser(description="Windows Jami-lrc build tool") 135 | ap.add_argument( 136 | '-q', '--qtver', default=qt_version_default, 137 | help='Sets the Qt version to build with') 138 | 139 | parsed_args = ap.parse_args() 140 | 141 | return parsed_args 142 | 143 | 144 | def main(): 145 | if not host_is_64bit: 146 | print('These scripts will only run on a 64-bit Windows system for now!') 147 | sys.exit(1) 148 | 149 | if int(getLatestVSVersion()) < 15: 150 | print('These scripts require at least Visual Studio v15 2017!') 151 | sys.exit(1) 152 | 153 | parsed_args = parse_args() 154 | build(parsed_args.qtver) 155 | 156 | 157 | if __name__ == '__main__': 158 | main() 159 | -------------------------------------------------------------------------------- /src/vcard.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2017-2022 Savoir-faire Linux Inc. * 3 | * Author: Sébastien Blin * 4 | * Author : Alexandre Lision * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser 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 | #pragma once 20 | 21 | #include 22 | #include 23 | 24 | namespace lrc { 25 | namespace vCard { 26 | 27 | constexpr static const char* PROFILE_VCF = "x-ring/ring.profile.vcard"; 28 | 29 | struct Delimiter 30 | { 31 | constexpr static const char* SEPARATOR_TOKEN = ";"; 32 | constexpr static const char* END_LINE_TOKEN = "\n"; 33 | constexpr static const char* BEGIN_TOKEN = "BEGIN:VCARD"; 34 | constexpr static const char* END_TOKEN = "END:VCARD"; 35 | }; 36 | 37 | struct Property 38 | { 39 | constexpr static const char* UID = "UID"; 40 | constexpr static const char* VERSION = "VERSION"; 41 | constexpr static const char* ADDRESS = "ADR"; 42 | constexpr static const char* AGENT = "AGENT"; 43 | constexpr static const char* BIRTHDAY = "BDAY"; 44 | constexpr static const char* CATEGORIES = "CATEGORIES"; 45 | constexpr static const char* CLASS = "CLASS"; 46 | constexpr static const char* DELIVERY_LABEL = "LABEL"; 47 | constexpr static const char* EMAIL = "EMAIL"; 48 | constexpr static const char* FORMATTED_NAME = "FN"; 49 | constexpr static const char* GEOGRAPHIC_POSITION = "GEO"; 50 | constexpr static const char* KEY = "KEY"; 51 | constexpr static const char* LOGO = "LOGO"; 52 | constexpr static const char* MAILER = "MAILER"; 53 | constexpr static const char* NAME = "N"; 54 | constexpr static const char* NICKNAME = "NICKNAME"; 55 | constexpr static const char* NOTE = "NOTE"; 56 | constexpr static const char* ORGANIZATION = "ORG"; 57 | constexpr static const char* PHOTO = "PHOTO"; 58 | constexpr static const char* PRODUCT_IDENTIFIER = "PRODID"; 59 | constexpr static const char* REVISION = "REV"; 60 | constexpr static const char* ROLE = "ROLE"; 61 | constexpr static const char* SORT_STRING = "SORT-STRING"; 62 | constexpr static const char* SOUND = "SOUND"; 63 | constexpr static const char* TELEPHONE = "TEL"; 64 | constexpr static const char* TIME_ZONE = "TZ"; 65 | constexpr static const char* TITLE = "TITLE"; 66 | constexpr static const char* URL = "URL"; 67 | constexpr static const char* BASE64 = "ENCODING=BASE64"; 68 | constexpr static const char* TYPE_PNG = "TYPE=PNG"; 69 | constexpr static const char* TYPE_JPEG = "TYPE=JPEG"; 70 | constexpr static const char* PHOTO_PNG = "PHOTO;ENCODING=BASE64;TYPE=PNG"; 71 | constexpr static const char* PHOTO_JPEG = "PHOTO;ENCODING=BASE64;TYPE=JPEG"; 72 | 73 | constexpr static const char* X_RINGACCOUNT = "X-RINGACCOUNTID"; 74 | }; 75 | 76 | namespace utils { 77 | /** 78 | * Payload to vCard 79 | * @param content payload 80 | * @return the vCard representation 81 | */ 82 | static QHash 83 | toHashMap(const QByteArray& content) 84 | { 85 | // TODO without Qt 86 | QHash vCard; 87 | QByteArray previousKey, previousValue; 88 | const QList lines = content.split('\n'); 89 | 90 | foreach (const QByteArray& property, lines) { 91 | // Ignore empty lines 92 | if (property.size()) { 93 | // Some properties are over multiple lines 94 | if (property[0] == ' ' && previousKey.size()) { 95 | previousValue += property.right(property.size() - 1); 96 | } 97 | 98 | // Do not use split, URIs can have : in them 99 | const int dblptPos = property.indexOf(':'); 100 | const QByteArray k(property.left(dblptPos)), 101 | v(property.right(property.size() - dblptPos - 1)); 102 | vCard[k] = v; 103 | } 104 | } 105 | return vCard; 106 | } 107 | } // namespace utils 108 | } // namespace vCard 109 | } // namespace lrc 110 | -------------------------------------------------------------------------------- /src/namedirectory.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2016-2022 Savoir-faire Linux Inc. * 3 | * Author : Alexandre Viau * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | 19 | #include 20 | 21 | #include "namedirectory.h" 22 | #include "private/namedirectory_p.h" 23 | #include "dbus/configurationmanager.h" 24 | 25 | NameDirectoryPrivate::NameDirectoryPrivate(NameDirectory* q) 26 | : q_ptr(q) 27 | { 28 | ConfigurationManagerInterface& configurationManager = ConfigurationManager::instance(); 29 | 30 | connect(&configurationManager, 31 | &ConfigurationManagerInterface::nameRegistrationEnded, 32 | this, 33 | &NameDirectoryPrivate::slotNameRegistrationEnded, 34 | Qt::QueuedConnection); 35 | connect(&configurationManager, 36 | &ConfigurationManagerInterface::registeredNameFound, 37 | this, 38 | &NameDirectoryPrivate::slotRegisteredNameFound, 39 | Qt::QueuedConnection); 40 | connect(&configurationManager, 41 | &ConfigurationManagerInterface::exportOnRingEnded, 42 | this, 43 | &NameDirectoryPrivate::slotExportOnRingEnded, 44 | Qt::QueuedConnection); 45 | } 46 | 47 | NameDirectory::NameDirectory() 48 | : QObject(QCoreApplication::instance()) 49 | , d_ptr(new NameDirectoryPrivate(this)) 50 | {} 51 | 52 | /// Singleton 53 | NameDirectory& 54 | NameDirectory::instance() 55 | { 56 | static auto instance = new NameDirectory; 57 | return *instance; 58 | } 59 | 60 | // Name registration ended 61 | void 62 | NameDirectoryPrivate::slotNameRegistrationEnded(const QString& accountId, 63 | int status, 64 | const QString& name) 65 | { 66 | qDebug() << "Name registration ended. Account:" << accountId << "status:" << status 67 | << "name:" << name; 68 | 69 | emit q_ptr->nameRegistrationEnded(static_cast(status), name); 70 | } 71 | 72 | // Registered Name found 73 | void 74 | NameDirectoryPrivate::slotRegisteredNameFound(const QString& accountId, 75 | int status, 76 | const QString& address, 77 | const QString& name) 78 | { 79 | switch (static_cast(status)) { 80 | case NameDirectory::LookupStatus::INVALID_NAME: 81 | qDebug() << "lookup name is INVALID:" << name << accountId; 82 | break; 83 | case NameDirectory::LookupStatus::NOT_FOUND: 84 | qDebug() << "lookup name NOT FOUND:" << name << accountId; 85 | break; 86 | case NameDirectory::LookupStatus::ERROR: 87 | qDebug() << "lookup name ERROR:" << name << accountId; 88 | break; 89 | case NameDirectory::LookupStatus::SUCCESS: 90 | break; 91 | } 92 | 93 | emit q_ptr->registeredNameFound(static_cast(status), address, name); 94 | } 95 | 96 | // Export account has ended with pin generated 97 | void 98 | NameDirectoryPrivate::slotExportOnRingEnded(const QString& accountId, int status, const QString& pin) 99 | { 100 | qDebug() << "Export on ring ended for account: " << accountId << "status: " << status 101 | << "PIN: " << pin; 102 | 103 | emit q_ptr->exportOnRingEnded(static_cast(status), pin); 104 | } 105 | 106 | // Lookup a name 107 | bool 108 | NameDirectory::lookupName(const QString& nameServiceURL, const QString& name) const 109 | { 110 | return ConfigurationManager::instance().lookupName("", nameServiceURL, name); 111 | } 112 | 113 | // Lookup an address 114 | bool 115 | NameDirectory::lookupAddress(const QString& nameServiceURL, const QString& address) const 116 | { 117 | return ConfigurationManager::instance().lookupAddress("", nameServiceURL, address); 118 | } 119 | 120 | NameDirectory::~NameDirectory() 121 | { 122 | delete d_ptr; 123 | } 124 | -------------------------------------------------------------------------------- /src/web-chatview/previewInfo.js: -------------------------------------------------------------------------------- 1 | /* MIT License 2 | 3 | Copyright (c) 2019 Andrej Gajdos 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE.*/ 22 | 23 | /** 24 | * Retrieves the title of a webpage which is used to fill out the preview of a hyperlink 25 | * @param doc the DOM of the url that is being previewed 26 | * @returns the title of the given webpage 27 | */ 28 | 29 | function getTitle(doc){ 30 | const og_title = doc.querySelector('meta[property="og:title"]') 31 | if (og_title !== null && og_title.content.length > 0) { 32 | return og_title.content 33 | } 34 | const twitter_title = doc.querySelector('meta[name="twitter:title"]') 35 | if (twitter_title !== null && twitter_title.content.length > 0) { 36 | return twitter_title.content 37 | } 38 | const doc_title = doc.title 39 | if (doc_title !== null && doc_title.length > 0) { 40 | return doc_title 41 | } 42 | if (doc.querySelector("h1") !== null){ 43 | const header_1 = doc.querySelector("h1").innerHTML 44 | if (header_1 !== null && header_1.length > 0) { 45 | return header_1 46 | } 47 | } 48 | if (doc.querySelector("h2") !== null){ 49 | const header_2 = doc.querySelector("h2").innerHTML 50 | if (header_2 !== null && header_2.length > 0) { 51 | return header_2 52 | } 53 | } 54 | return null 55 | } 56 | 57 | /** 58 | * Obtains a description of the webpage for the hyperlink preview 59 | * @param doc the DOM of the url that is being previewed 60 | * @returns a description of the webpage 61 | */ 62 | function getDescription(doc){ 63 | const og_description = doc.querySelector('meta[property="og:description"]') 64 | if (og_description !== null && og_description.content.length > 0) { 65 | return og_description.content 66 | } 67 | const twitter_description = doc.querySelector('meta[name="twitter:description"]') 68 | if (twitter_description !== null && twitter_description.content.length > 0) { 69 | return twitter_description.content 70 | } 71 | const meta_description = doc.querySelector('meta[name="description"]') 72 | if (meta_description !== null && meta_description.content.length > 0) { 73 | return meta_description.content 74 | } 75 | var all_paragraphs = doc.querySelectorAll("p") 76 | let first_visible_paragraph = null 77 | for (var i = 0; i < all_paragraphs.length; i++) { 78 | if (all_paragraphs[i].offsetParent !== null && 79 | !all_paragraphs[i].childElementCount !== 0) { 80 | first_visible_paragraph = all_paragraphs[i].textContent 81 | break 82 | } 83 | } 84 | return first_visible_paragraph 85 | } 86 | 87 | /** 88 | * Gets the image that represents a webpage. 89 | * @param doc the DOM of the url that is being previewed 90 | * @returns the image representing the url or null if no such image was found 91 | */ 92 | function getImage(doc) { 93 | const og_image = doc.querySelector('meta[property="og:image"]') 94 | if (og_image !== null && og_image.content.length > 0){ 95 | return og_image.content 96 | } 97 | const image_rel_link = doc.querySelector('link[rel="image_src"]') 98 | if (image_rel_link !== null && image_rel_link.href.length > 0){ 99 | return image_rel_link.href 100 | } 101 | const twitter_img = doc.querySelector('meta[name="twitter:image"]') 102 | if (twitter_img !== null && twitter_img.content.length > 0) { 103 | return twitter_img.content 104 | } 105 | 106 | let imgs = Array.from(doc.getElementsByTagName("img")) 107 | if (imgs.length > 0) { 108 | imgs = imgs.filter(img => { 109 | let add_image = true 110 | if (img.naturalWidth > img.naturalHeight) { 111 | if (img.naturalWidth / img.naturalHeight > 3) { 112 | add_image = false 113 | } 114 | } else { 115 | if (img.naturalHeight / img.naturalWidth > 3) { 116 | add_image = false 117 | } 118 | } 119 | if (img.naturalHeight <= 50 || img.naturalWidth <= 50) { 120 | add_image = false 121 | } 122 | return add_image 123 | }) 124 | } 125 | return null 126 | } 127 | -------------------------------------------------------------------------------- /src/smartinfohub.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (C) 2016-2022 Savoir-faire Linux Inc. * 3 | * Author: Olivier Grégoire * 4 | * * 5 | * This library is free software; you can redistribute it and/or * 6 | * modify it under the terms of the GNU Lesser General Public * 7 | * License as published by the Free Software Foundation; either * 8 | * version 2.1 of the License, or (at your option) any later version. * 9 | * * 10 | * This library is distributed in the hope that it will be useful, * 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 13 | * Lesser General Public License for more details. * 14 | * * 15 | * You should have received a copy of the GNU General Public License * 16 | * along with this program. If not, see . * 17 | ***************************************************************************/ 18 | 19 | #include "smartinfohub.h" 20 | #include "private/smartInfoHub_p.h" 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | SmartInfoHub::SmartInfoHub() 27 | { 28 | d_ptr = new SmartInfoHubPrivate; 29 | connect(&CallManager::instance(), 30 | &CallManagerInterface::SmartInfo, 31 | this, 32 | &SmartInfoHub::slotSmartInfo, 33 | Qt::QueuedConnection); 34 | } 35 | 36 | SmartInfoHub::~SmartInfoHub() {} 37 | 38 | void 39 | SmartInfoHub::start() 40 | { 41 | CallManager::instance().startSmartInfo(d_ptr->m_refreshTimeInformationMS); 42 | } 43 | 44 | void 45 | SmartInfoHub::stop() 46 | { 47 | CallManager::instance().stopSmartInfo(); 48 | } 49 | 50 | SmartInfoHub& 51 | SmartInfoHub::instance() 52 | { 53 | // Singleton 54 | static SmartInfoHub instance_; 55 | return instance_; 56 | } 57 | 58 | void 59 | SmartInfoHub::setRefreshTime(uint32_t timeMS) 60 | { 61 | d_ptr->m_refreshTimeInformationMS = timeMS; 62 | } 63 | 64 | // Retrieve information from the map and implement all the variables 65 | void 66 | SmartInfoHub::slotSmartInfo(const MapStringString& map) 67 | { 68 | for (int i = 0; i < map.size(); i++) 69 | d_ptr->m_information[map.keys().at(i)] = map[map.keys().at(i)]; 70 | 71 | emit changed(); 72 | } 73 | // Getter 74 | 75 | bool 76 | SmartInfoHub::isConference() const 77 | { 78 | return (d_ptr->m_information["type"] == "conference"); 79 | } 80 | 81 | float 82 | SmartInfoHub::localFps() const 83 | { 84 | if (!d_ptr->m_information[LOCAL_FPS].isEmpty()) 85 | return d_ptr->m_information[LOCAL_FPS].toFloat(); 86 | 87 | return 0.0; 88 | } 89 | 90 | float 91 | SmartInfoHub::remoteFps() const 92 | { 93 | if (!d_ptr->m_information[REMOTE_FPS].isEmpty()) 94 | return d_ptr->m_information[REMOTE_FPS].toFloat(); 95 | 96 | return 0.0; 97 | } 98 | 99 | int 100 | SmartInfoHub::remoteWidth() const 101 | { 102 | if (!d_ptr->m_information[REMOTE_WIDTH].isEmpty()) 103 | return d_ptr->m_information[REMOTE_WIDTH].toInt(); 104 | else 105 | return 0; 106 | } 107 | 108 | int 109 | SmartInfoHub::remoteHeight() const 110 | { 111 | if (!d_ptr->m_information[REMOTE_HEIGHT].isEmpty()) 112 | return d_ptr->m_information[REMOTE_HEIGHT].toInt(); 113 | else 114 | return 0; 115 | } 116 | 117 | int 118 | SmartInfoHub::localWidth() const 119 | { 120 | if (!d_ptr->m_information[LOCAL_WIDTH].isEmpty()) 121 | return d_ptr->m_information[LOCAL_WIDTH].toInt(); 122 | else 123 | return 0; 124 | } 125 | 126 | int 127 | SmartInfoHub::localHeight() const 128 | { 129 | if (!d_ptr->m_information[LOCAL_HEIGHT].isEmpty()) 130 | return d_ptr->m_information[LOCAL_HEIGHT].toInt(); 131 | else 132 | return 0; 133 | } 134 | 135 | QString 136 | SmartInfoHub::callID() const 137 | { 138 | if (!d_ptr->m_information[CALL_ID].isEmpty()) 139 | return d_ptr->m_information[CALL_ID]; 140 | else 141 | return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; 142 | } 143 | 144 | QString 145 | SmartInfoHub::localVideoCodec() const 146 | { 147 | if (!d_ptr->m_information[LOCAL_VIDEO_CODEC].isEmpty()) 148 | return d_ptr->m_information[LOCAL_VIDEO_CODEC]; 149 | else 150 | return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; 151 | } 152 | 153 | QString 154 | SmartInfoHub::localAudioCodec() const 155 | { 156 | if (!d_ptr->m_information[LOCAL_AUDIO_CODEC].isEmpty()) 157 | return d_ptr->m_information[LOCAL_AUDIO_CODEC]; 158 | else 159 | return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; 160 | } 161 | 162 | QString 163 | SmartInfoHub::remoteVideoCodec() const 164 | { 165 | if (!d_ptr->m_information[REMOTE_VIDEO_CODEC].isEmpty()) 166 | return d_ptr->m_information[REMOTE_VIDEO_CODEC]; 167 | else 168 | return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; 169 | } 170 | 171 | QString 172 | SmartInfoHub::remoteAudioCodec() const 173 | { 174 | if (!d_ptr->m_information[REMOTE_AUDIO_CODEC].isEmpty()) 175 | return d_ptr->m_information[REMOTE_AUDIO_CODEC]; 176 | else 177 | return SmartInfoHubPrivate::DEFAULT_RETURN_VALUE_QSTRING; 178 | } 179 | -------------------------------------------------------------------------------- /src/messagelistmodel.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020-2022 Savoir-faire Linux Inc. 3 | * 4 | * Author: Kateryna Kostiuk 5 | * Author: Trevor Tabah 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, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 19 | */ 20 | #pragma once 21 | 22 | #include "api/interaction.h" 23 | 24 | #include 25 | 26 | namespace lrc { 27 | namespace api { 28 | 29 | namespace interaction { 30 | struct Info; 31 | } 32 | 33 | #define MSG_ROLES \ 34 | X(Id) \ 35 | X(Author) \ 36 | X(Body) \ 37 | X(ParentId) \ 38 | X(Timestamp) \ 39 | X(Duration) \ 40 | X(Type) \ 41 | X(Status) \ 42 | X(IsRead) \ 43 | X(ContactAction) \ 44 | X(ActionUri) \ 45 | X(LinkPreviewInfo) \ 46 | X(Linkified) \ 47 | X(TransferName) \ 48 | X(Readers) 49 | 50 | namespace MessageList { 51 | Q_NAMESPACE 52 | enum Role { 53 | DummyRole = Qt::UserRole + 1, 54 | #define X(role) role, 55 | MSG_ROLES 56 | #undef X 57 | }; 58 | Q_ENUM_NS(Role) 59 | } // namespace MessageList 60 | 61 | class MessageListModel : public QAbstractListModel 62 | { 63 | Q_OBJECT 64 | 65 | public: 66 | using item_t = const QPair; 67 | 68 | typedef QList>::ConstIterator constIterator; 69 | typedef QList>::Iterator iterator; 70 | typedef QList>::reverse_iterator reverseIterator; 71 | 72 | explicit MessageListModel(QObject* parent = nullptr); 73 | ~MessageListModel() = default; 74 | 75 | // map functions 76 | QPair emplace(const QString& msgId, 77 | interaction::Info message, 78 | bool beginning = false); 79 | iterator find(const QString& msgId); 80 | constIterator find(const QString& msgId) const; 81 | QPair insert(std::pair message, 82 | bool beginning = false); 83 | Q_INVOKABLE int erase(const QString& msgId); 84 | interaction::Info& operator[](const QString& messageId); 85 | iterator end(); 86 | constIterator end() const; 87 | constIterator cend() const; 88 | iterator begin(); 89 | constIterator begin() const; 90 | reverseIterator rbegin(); 91 | int size() const; 92 | void clear(int leaveN = 0); 93 | bool empty() const; 94 | interaction::Info at(const QString& intId) const; 95 | QPair front() const; 96 | QPair last() const; 97 | QPair atIndex(int index) const; 98 | 99 | QPair insert(int index, QPair message); 100 | int indexOfMessage(const QString& msgId, bool reverse = true) const; 101 | void moveMessages(QList msgIds, const QString& parentId); 102 | 103 | int rowCount(const QModelIndex& parent = QModelIndex()) const override; 104 | virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const; 105 | QHash roleNames() const override; 106 | QVariant dataForItem(item_t item, int indexRow, int role = Qt::DisplayRole) const; 107 | bool contains(const QString& msgId); 108 | int getIndexOfMessage(const QString& messageId) const; 109 | void addHyperlinkInfo(const QString& messageId, const QVariantMap& info); 110 | void linkifyMessage(const QString& messageId, const QString& linkified); 111 | 112 | void setRead(const QString& peer, const QString& messageId); 113 | QString getRead(const QString& peer); 114 | 115 | // use these if the underlying data model is changed from conversationmodel 116 | // Note: this is not ideal, and this class should be refactored into a proper 117 | // view model and absorb the interaction management logic to avoid exposing 118 | // these emission wrappers 119 | void emitBeginResetModel(); 120 | void emitEndResetModel(); 121 | void emitDataChanged(iterator it, VectorInt roles = {}); 122 | void emitDataChanged(const QString& msgId, VectorInt roles = {}); 123 | 124 | protected: 125 | using Role = MessageList::Role; 126 | 127 | private: 128 | QList> interactions_; 129 | // Note: because read status are updated even if interaction is not loaded 130 | // we need to keep track of these status outside the interaction::Info 131 | // lastDisplayedMessageUid_ stores: {"peerId":"messageId"} 132 | // messageToReaders_ caches: "messageId":["peer1", "peer2"] 133 | // to allow quick access. 134 | QMap lastDisplayedMessageUid_; 135 | QMap messageToReaders_; 136 | 137 | void moveMessage(const QString& msgId, const QString& parentId); 138 | void insertMessage(int index, item_t& message); 139 | iterator insertMessage(iterator it, item_t& message); 140 | void removeMessage(int index, iterator it); 141 | void moveMessage(int from, int to); 142 | }; 143 | } // namespace api 144 | } // namespace lrc 145 | Q_DECLARE_METATYPE(lrc::api::MessageListModel*) 146 | -------------------------------------------------------------------------------- /src/dbus/metatypes.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * Copyright (C) 2009-2022 Savoir-faire Linux Inc. * 3 | * Author : Emmanuel Lepage Vallee * 4 | * Jérémy Quentin * 5 | * * 6 | * This library is free software; you can redistribute it and/or * 7 | * modify it under the terms of the GNU Lesser General Public * 8 | * License as published by the Free Software Foundation; either * 9 | * version 2.1 of the License, or (at your option) any later version. * 10 | * * 11 | * This library 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 GNU * 14 | * Lesser General Public License for more details. * 15 | * * 16 | * You should have received a copy of the Lesser GNU General Public License * 17 | * along with this program. If not, see . * 18 | *****************************************************************************/ 19 | #pragma once 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | 26 | #include "../typedefs.h" 27 | 28 | #ifndef ENABLE_LIBWRAP 29 | #include 30 | #endif 31 | #pragma GCC diagnostic push 32 | #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant" 33 | 34 | Q_DECLARE_METATYPE(MapStringString) 35 | Q_DECLARE_METATYPE(MapStringInt) 36 | Q_DECLARE_METATYPE(VectorMapStringString) 37 | Q_DECLARE_METATYPE(MapStringMapStringStringList) 38 | Q_DECLARE_METATYPE(VectorInt) 39 | Q_DECLARE_METATYPE(VectorUInt) 40 | Q_DECLARE_METATYPE(VectorULongLong) 41 | Q_DECLARE_METATYPE(VectorString) 42 | Q_DECLARE_METATYPE(MapStringVectorString) 43 | Q_DECLARE_METATYPE(VectorVectorByte) 44 | Q_DECLARE_METATYPE(DataTransferInfo) 45 | Q_DECLARE_METATYPE(uint64_t) 46 | Q_DECLARE_METATYPE(Message) 47 | 48 | #ifndef ENABLE_LIBWRAP 49 | static inline QDBusArgument& 50 | operator<<(QDBusArgument& argument, const DataTransferInfo& info) 51 | { 52 | argument.beginStructure(); 53 | argument << info.accountId; 54 | argument << info.lastEvent; 55 | argument << info.flags; 56 | argument << info.totalSize; 57 | argument << info.bytesProgress; 58 | argument << info.author; 59 | argument << info.peer; 60 | argument << info.conversationId; 61 | argument << info.displayName; 62 | argument << info.path; 63 | argument << info.mimetype; 64 | argument.endStructure(); 65 | 66 | return argument; 67 | } 68 | 69 | static inline const QDBusArgument& 70 | operator>>(const QDBusArgument& argument, DataTransferInfo& info) 71 | { 72 | argument.beginStructure(); 73 | argument >> info.accountId; 74 | argument >> info.lastEvent; 75 | argument >> info.flags; 76 | argument >> info.totalSize; 77 | argument >> info.bytesProgress; 78 | argument >> info.author; 79 | argument >> info.peer; 80 | argument >> info.conversationId; 81 | argument >> info.displayName; 82 | argument >> info.path; 83 | argument >> info.mimetype; 84 | argument.endStructure(); 85 | 86 | return argument; 87 | } 88 | 89 | static inline QDBusArgument& 90 | operator<<(QDBusArgument& argument, const Message& m) 91 | { 92 | argument.beginStructure(); 93 | argument << m.from; 94 | argument << m.payloads; 95 | argument << m.received; 96 | argument.endStructure(); 97 | 98 | return argument; 99 | } 100 | 101 | static inline const QDBusArgument& 102 | operator>>(const QDBusArgument& argument, Message& m) 103 | { 104 | argument.beginStructure(); 105 | argument >> m.from; 106 | argument >> m.payloads; 107 | argument >> m.received; 108 | argument.endStructure(); 109 | 110 | return argument; 111 | } 112 | #endif 113 | 114 | #ifndef ENABLE_LIBWRAP 115 | static bool dbus_metaTypeInit = false; 116 | #endif 117 | inline void 118 | registerCommTypes() 119 | { 120 | #ifndef ENABLE_LIBWRAP 121 | qRegisterMetaType("MapStringString"); 122 | qDBusRegisterMetaType(); 123 | qRegisterMetaType("MapStringInt"); 124 | qDBusRegisterMetaType(); 125 | qRegisterMetaType("VectorMapStringString"); 126 | qDBusRegisterMetaType(); 127 | qRegisterMetaType("MapStringMapStringVectorString"); 128 | qDBusRegisterMetaType(); 129 | qRegisterMetaType("VectorInt"); 130 | qDBusRegisterMetaType(); 131 | qRegisterMetaType("VectorUInt"); 132 | qDBusRegisterMetaType(); 133 | qRegisterMetaType("VectorULongLong"); 134 | qDBusRegisterMetaType(); 135 | qRegisterMetaType("VectorString"); 136 | qDBusRegisterMetaType(); 137 | qRegisterMetaType("MapStringVectorString"); 138 | qDBusRegisterMetaType(); 139 | qRegisterMetaType("VectorVectorByte"); 140 | qDBusRegisterMetaType(); 141 | qRegisterMetaType("DataTransferInfo"); 142 | qDBusRegisterMetaType(); 143 | qRegisterMetaType("Message"); 144 | qDBusRegisterMetaType(); 145 | qRegisterMetaType>("QVector"); 146 | qDBusRegisterMetaType>(); 147 | dbus_metaTypeInit = true; 148 | #endif 149 | } 150 | 151 | #pragma GCC diagnostic pop 152 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005 Free 5 | Software Foundation, Inc. 6 | 7 | This file is free documentation; the Free Software Foundation gives 8 | unlimited permission to copy, distribute and modify it. 9 | 10 | ## Disclaimer 11 | 12 | Because the LRC is multi-platforms and supporting macOS, we need a recent version of Qt to do rendering with Metal. So, Qt 6.2 is necessary. 13 | This version is generally not packaged on a lot of platforms, and to control available plugins and such, we have our own Qt packaged (generated by https://review.jami.net/jami-project and available on https://jami.net on the distributions we support). 14 | So, you will need to get Qt 6.2 first. For this, there is 3 methods: 15 | 16 | ### Qt from https://jami.net (recommended) 17 | 18 | If your distribution is supported, we provide a Qt package (`libqt-jami`) on our repo. Follow instructions https://jami.net/download-jami-linux/ (but instead installing `jami` install `libqt-jami`). 19 | The files will be installed in `/usr/lib/libqt-jami`. 20 | 21 | ### Qt from your distribution 22 | 23 | If Qt 6.2 is available, you can use the packages from your distribution: 24 | 25 | It should be (For now qt5 only is packaged by distributions, so names can change). 26 | 27 | #### Dependencies, Debian based 28 | 29 | ``` 30 | sudo apt-get install cmake make doxygen g++ gettext libnotify-dev pandoc nasm libqrencode-dev \ 31 | libnotify-dev libnm-dev \ 32 | qtbase6-dev \ 33 | qtmultimedia6-dev libqt6svg6-dev qtwebengine6-dev qtdeclarative6-dev \ 34 | qtquickcontrols2-6-dev qml-module-qtquick2 qml-module-qtquick-controls \ 35 | qml-module-qtquick-controls2 qml-module-qtquick-dialogs \ 36 | qml-module-qtquick-layouts qml-module-qtquick-privatewidgets \ 37 | qml-module-qtquick-shapes qml-module-qtquick-window2 \ 38 | qml-module-qtquick-templates2 qml-module-qt-labs-platform \ 39 | qml-module-qtwebengine qml-module-qtwebchannel \ 40 | qml-module-qt-labs-qmlmodels 41 | ``` 42 | 43 | #### Dependencies, Fedora based 44 | 45 | ``` 46 | sudo dnf install qt6-qtsvg-devel qt6-qtwebengine-devel qt6-qtmultimedia-devel qt6-qtdeclarative-devel qt6-qtquickcontrols2-devel qt6-qtquickcontrols qrencode-devel NetworkManager-libnm-devel 47 | ``` 48 | 49 | ### Build Qt from sources 50 | 51 | https://www.qt.io/product/qt6 52 | 53 | 54 | Basic Installation 55 | ================== 56 | 57 | These are generic installation instructions. 58 | 59 | To install the appplication, type the following commands in a console, while in the root directory of this application: 60 | 61 | mkdir -p build 62 | cd build 63 | cmake .. 64 | The following options are often useful to append to the cmake line: 65 | -DRING_BUILD_DIR= 66 | -DRING_XML_INTERFACES_DIR= 67 | -DCMAKE_INSTALL_PREFIX= 68 | -DCMAKE_BUILD_TYPE= 69 | -DENABLE_VIDEO= 70 | make -jx # where x is the number of core you have 71 | make install 72 | 73 | (e.g. `-DCMAKE_PREFIX_PATH=/usr/lib/libqt-jami` if you use Qt from jami.net) 74 | 75 | Explanation 76 | =========== 77 | 78 | This script will configure and prepare the compilation and installation of the program and correctly link it against Ring daemon. 79 | 80 | All needed files will be built in "build" directory. 81 | So you have to go to this directory: 82 | 83 | cd build 84 | 85 | Then execute the Makefile, to compile the application (src, doc...) 86 | 87 | make 88 | 89 | Then install it all using: 90 | 91 | make install 92 | 93 | You have to use "sudo" to be able to install the program in a protected directory (which is the case by default and most of the time). 94 | Therefore it will ask for your system password. 95 | 96 | OS X Install 97 | ============ 98 | 99 | # Install necessary tools: 100 | brew install cmake 101 | brew install qt6 102 | export CMAKE_PREFIX_PATH= 103 | 104 | hint: default install location with HomeBrew is /usr/local/Cellar/qt6 105 | 106 | # First make sure you have built ring daemon for OS X. 107 | 108 | mkdir build && cd build 109 | cmake .. -DCMAKE_INSTALL_PREFIX= [-DCMAKE_BUILD_TYPE=Debug for compiling with debug symbols] 110 | make install 111 | 112 | You can now link and build the OSX client with Ring daemon and LRC library 113 | 114 | Testing 115 | ======= 116 | 117 | Tests are written in the `test` directory. 118 | To run tests, you need to rebuild the application with these commands (from the root directory of the project): 119 | 120 | mkdir -p build-test 121 | cd build-test 122 | cmake .. -DENABLE_TEST=true 123 | The following options are often useful to append to the cmake line: 124 | -DRING_BUILD_DIR= 125 | -DRING_XML_INTERFACES_DIR= 126 | -DCMAKE_INSTALL_PREFIX= 127 | -DCMAKE_BUILD_TYPE= 128 | -DENABLE_VIDEO= 129 | make -jx # where x is the number of core you have 130 | make test # or ./LRCTester for more verbosity. 131 | 132 | In the `test` directory you can also find a `mocks` folder used to simulate the ring daemon. 133 | `CppUnit` is the testing library used for this project. 134 | 135 | 136 | Internationalization 137 | ==================== 138 | 139 | To regenerate strings for translations we use lupdate (within root of the project) 140 | 141 | lupdate ./src/ -source-language en -ts translations/lrc_en.ts 142 | 143 | Hint: On OSX lupdate is installed with Qt in /usr/local/Cellar/qt6/6.2.0/bin/ when installed with HomeBrew 144 | --------------------------------------------------------------------------------