mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-07 14:44:01 +00:00
feat(app): clean code => use forward declarations when possible, avoid include with relative paths, improve compile time...
This commit is contained in:
parent
5d1ef1c26a
commit
f1d1577aa0
96 changed files with 902 additions and 827 deletions
|
|
@ -25,45 +25,46 @@
|
|||
#include <QFileSelector>
|
||||
#include <QLibraryInfo>
|
||||
#include <QMenu>
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlFileSelector>
|
||||
#include <QQuickWindow>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QTimer>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "../components/Components.hpp"
|
||||
#include "../utils/LinphoneUtils.hpp"
|
||||
#include "../utils/Utils.hpp"
|
||||
|
||||
#include "cli/Cli.hpp"
|
||||
#include "components/Components.hpp"
|
||||
#include "logger/Logger.hpp"
|
||||
#include "paths/Paths.hpp"
|
||||
#include "providers/AvatarProvider.hpp"
|
||||
#include "providers/ImageProvider.hpp"
|
||||
#include "providers/ThumbnailProvider.hpp"
|
||||
#include "translator/DefaultTranslator.hpp"
|
||||
#include "utils/LinphoneUtils.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "App.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
namespace {
|
||||
constexpr char cDefaultLocale[] = "en";
|
||||
using namespace std;
|
||||
|
||||
constexpr char cLanguagePath[] = ":/languages/";
|
||||
namespace {
|
||||
constexpr char DefaultLocale[] = "en";
|
||||
|
||||
constexpr char LanguagePath[] = ":/languages/";
|
||||
|
||||
// The main windows of Linphone desktop.
|
||||
constexpr char cQmlViewMainWindow[] = "qrc:/ui/views/App/Main/MainWindow.qml";
|
||||
constexpr char cQmlViewCallsWindow[] = "qrc:/ui/views/App/Calls/CallsWindow.qml";
|
||||
constexpr char cQmlViewSettingsWindow[] = "qrc:/ui/views/App/Settings/SettingsWindow.qml";
|
||||
constexpr char QmlViewMainWindow[] = "qrc:/ui/views/App/Main/MainWindow.qml";
|
||||
constexpr char QmlViewCallsWindow[] = "qrc:/ui/views/App/Calls/CallsWindow.qml";
|
||||
constexpr char QmlViewSettingsWindow[] = "qrc:/ui/views/App/Settings/SettingsWindow.qml";
|
||||
|
||||
constexpr int cVersionUpdateCheckInterval = 86400000; // 24 hours in milliseconds.
|
||||
constexpr int VersionUpdateCheckInterval = 86400000; // 24 hours in milliseconds.
|
||||
}
|
||||
|
||||
static inline bool installLocale (App &app, QTranslator &translator, const QLocale &locale) {
|
||||
return translator.load(locale, cLanguagePath) && app.installTranslator(&translator);
|
||||
return translator.load(locale, LanguagePath) && app.installTranslator(&translator);
|
||||
}
|
||||
|
||||
static inline shared_ptr<linphone::Config> getConfigIfExists (const QCommandLineParser &parser) {
|
||||
|
|
@ -77,19 +78,19 @@ static inline shared_ptr<linphone::Config> getConfigIfExists (const QCommandLine
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::User | Mode::ExcludeAppPath | Mode::ExcludeAppVersion) {
|
||||
setWindowIcon(QIcon(WINDOW_ICON_PATH));
|
||||
setWindowIcon(QIcon(LinphoneUtils::WindowIconPath));
|
||||
|
||||
createParser();
|
||||
mParser->process(*this);
|
||||
|
||||
// Initialize logger.
|
||||
shared_ptr<linphone::Config> config = ::getConfigIfExists(*mParser);
|
||||
shared_ptr<linphone::Config> config = getConfigIfExists(*mParser);
|
||||
Logger::init(config);
|
||||
if (mParser->isSet("verbose"))
|
||||
Logger::getInstance()->setVerbose(true);
|
||||
|
||||
// List available locales.
|
||||
for (const auto &locale : QDir(cLanguagePath).entryList())
|
||||
for (const auto &locale : QDir(LanguagePath).entryList())
|
||||
mAvailableLocales << QLocale(locale);
|
||||
|
||||
// Init locale.
|
||||
|
|
@ -137,7 +138,7 @@ static QQuickWindow *createSubWindow (QQmlApplicationEngine *engine, const char
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void App::initContentApp () {
|
||||
shared_ptr<linphone::Config> config = ::getConfigIfExists(*mParser);
|
||||
shared_ptr<linphone::Config> config = getConfigIfExists(*mParser);
|
||||
bool mustBeIconified = false;
|
||||
|
||||
// Destroy qml components and linphone core if necessary.
|
||||
|
|
@ -206,9 +207,9 @@ void App::initContentApp () {
|
|||
mEngine->addImportPath(":/ui/views");
|
||||
|
||||
// Provide avatars/thumbnails providers.
|
||||
mEngine->addImageProvider(AvatarProvider::PROVIDER_ID, new AvatarProvider());
|
||||
mEngine->addImageProvider(ImageProvider::PROVIDER_ID, new ImageProvider());
|
||||
mEngine->addImageProvider(ThumbnailProvider::PROVIDER_ID, new ThumbnailProvider());
|
||||
mEngine->addImageProvider(AvatarProvider::ProviderId, new AvatarProvider());
|
||||
mEngine->addImageProvider(ImageProvider::ProviderId, new ImageProvider());
|
||||
mEngine->addImageProvider(ThumbnailProvider::ProviderId, new ThumbnailProvider());
|
||||
|
||||
mColors = new Colors(this);
|
||||
mColors->useConfig(config);
|
||||
|
|
@ -223,7 +224,7 @@ void App::initContentApp () {
|
|||
|
||||
// Load main view.
|
||||
qInfo() << QStringLiteral("Loading main view...");
|
||||
mEngine->load(QUrl(cQmlViewMainWindow));
|
||||
mEngine->load(QUrl(QmlViewMainWindow));
|
||||
if (mEngine->rootObjects().isEmpty())
|
||||
qFatal("Unable to open main window.");
|
||||
|
||||
|
|
@ -264,12 +265,12 @@ QString App::getCommandArgument () {
|
|||
|
||||
QQuickWindow *App::getCallsWindow () {
|
||||
if (CoreManager::getInstance()->getCore()->getConfig()->getInt(
|
||||
SettingsModel::UI_SECTION, "disable_calls_window", 0
|
||||
SettingsModel::UiSection, "disable_calls_window", 0
|
||||
))
|
||||
return nullptr;
|
||||
|
||||
if (!mCallsWindow)
|
||||
mCallsWindow = ::createSubWindow(mEngine, cQmlViewCallsWindow);
|
||||
mCallsWindow = createSubWindow(mEngine, QmlViewCallsWindow);
|
||||
|
||||
return mCallsWindow;
|
||||
}
|
||||
|
|
@ -282,7 +283,7 @@ QQuickWindow *App::getMainWindow () const {
|
|||
|
||||
QQuickWindow *App::getSettingsWindow () {
|
||||
if (!mSettingsWindow) {
|
||||
mSettingsWindow = ::createSubWindow(mEngine, cQmlViewSettingsWindow);
|
||||
mSettingsWindow = createSubWindow(mEngine, QmlViewSettingsWindow);
|
||||
QObject::connect(mSettingsWindow, &QWindow::visibilityChanged, this, [](QWindow::Visibility visibility) {
|
||||
if (visibility == QWindow::Hidden) {
|
||||
qInfo() << QStringLiteral("Update nat policy.");
|
||||
|
|
@ -382,7 +383,7 @@ void registerToolType (const char *name) {
|
|||
void App::registerTypes () {
|
||||
qInfo() << QStringLiteral("Registering types...");
|
||||
|
||||
qRegisterMetaType<std::shared_ptr<linphone::ProxyConfig> >();
|
||||
qRegisterMetaType<shared_ptr<linphone::ProxyConfig>>();
|
||||
qRegisterMetaType<ChatModel::EntryType>();
|
||||
|
||||
registerType<AssistantModel>("AssistantModel");
|
||||
|
|
@ -479,7 +480,7 @@ void App::setTrayIcon () {
|
|||
menu->addAction(quitAction);
|
||||
|
||||
systemTrayIcon->setContextMenu(menu);
|
||||
systemTrayIcon->setIcon(QIcon(WINDOW_ICON_PATH));
|
||||
systemTrayIcon->setIcon(QIcon(LinphoneUtils::WindowIconPath));
|
||||
systemTrayIcon->setToolTip("Linphone");
|
||||
systemTrayIcon->show();
|
||||
|
||||
|
|
@ -492,37 +493,37 @@ void App::initLocale (const shared_ptr<linphone::Config> &config) {
|
|||
// Try to use preferred locale.
|
||||
QString locale;
|
||||
if (config)
|
||||
locale = ::Utils::coreStringToAppString(config->getString(SettingsModel::UI_SECTION, "locale", ""));
|
||||
locale = Utils::coreStringToAppString(config->getString(SettingsModel::UiSection, "locale", ""));
|
||||
|
||||
if (!locale.isEmpty() && ::installLocale(*this, *mTranslator, QLocale(locale))) {
|
||||
if (!locale.isEmpty() && installLocale(*this, *mTranslator, QLocale(locale))) {
|
||||
mLocale = locale;
|
||||
return;
|
||||
}
|
||||
|
||||
// Try to use system locale.
|
||||
QLocale sysLocale = QLocale::system();
|
||||
if (::installLocale(*this, *mTranslator, sysLocale)) {
|
||||
if (installLocale(*this, *mTranslator, sysLocale)) {
|
||||
mLocale = sysLocale.name();
|
||||
return;
|
||||
}
|
||||
|
||||
// Use english.
|
||||
mLocale = cDefaultLocale;
|
||||
if (!::installLocale(*this, *mTranslator, QLocale(mLocale)))
|
||||
mLocale = DefaultLocale;
|
||||
if (!installLocale(*this, *mTranslator, QLocale(mLocale)))
|
||||
qFatal("Unable to install default translator.");
|
||||
}
|
||||
|
||||
QString App::getConfigLocale () const {
|
||||
return ::Utils::coreStringToAppString(
|
||||
return Utils::coreStringToAppString(
|
||||
CoreManager::getInstance()->getCore()->getConfig()->getString(
|
||||
SettingsModel::UI_SECTION, "locale", ""
|
||||
SettingsModel::UiSection, "locale", ""
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
void App::setConfigLocale (const QString &locale) {
|
||||
CoreManager::getInstance()->getCore()->getConfig()->setString(
|
||||
SettingsModel::UI_SECTION, "locale", ::Utils::appStringToCoreString(locale)
|
||||
SettingsModel::UiSection, "locale", Utils::appStringToCoreString(locale)
|
||||
);
|
||||
|
||||
emit configLocaleChanged(locale);
|
||||
|
|
@ -555,15 +556,15 @@ void App::openAppAfterInit (bool mustBeIconified) {
|
|||
// Display Assistant if it's the first time app launch.
|
||||
{
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
if (config->getInt(SettingsModel::UI_SECTION, "force_assistant_at_startup", 1)) {
|
||||
if (config->getInt(SettingsModel::UiSection, "force_assistant_at_startup", 1)) {
|
||||
QMetaObject::invokeMethod(mainWindow, "setView", Q_ARG(QVariant, "Assistant"), Q_ARG(QVariant, QString("")));
|
||||
config->setInt(SettingsModel::UI_SECTION, "force_assistant_at_startup", 0);
|
||||
config->setInt(SettingsModel::UiSection, "force_assistant_at_startup", 0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UPDATE_CHECK
|
||||
QTimer *timer = new QTimer(mEngine);
|
||||
timer->setInterval(cVersionUpdateCheckInterval);
|
||||
timer->setInterval(VersionUpdateCheckInterval);
|
||||
|
||||
QObject::connect(timer, &QTimer::timeout, this, &App::checkForUpdate);
|
||||
timer->start();
|
||||
|
|
@ -576,6 +577,6 @@ void App::openAppAfterInit (bool mustBeIconified) {
|
|||
|
||||
void App::checkForUpdate () {
|
||||
CoreManager::getInstance()->getCore()->checkForUpdate(
|
||||
::Utils::appStringToCoreString(applicationVersion())
|
||||
Utils::appStringToCoreString(applicationVersion())
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,21 +23,24 @@
|
|||
#ifndef APP_H_
|
||||
#define APP_H_
|
||||
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQuickWindow>
|
||||
#include <memory>
|
||||
|
||||
#include "../components/notifier/Notifier.hpp"
|
||||
#include "../components/other/colors/Colors.hpp"
|
||||
#include "single-application/SingleApplication.hpp"
|
||||
|
||||
#define APP_CODE_RESTART 1000
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class QCommandLineParser;
|
||||
class QQmlApplicationEngine;
|
||||
class QQuickWindow;
|
||||
class QSystemTrayIcon;
|
||||
|
||||
namespace linphone {
|
||||
class Config;
|
||||
}
|
||||
|
||||
class Colors;
|
||||
class DefaultTranslator;
|
||||
class Notifier;
|
||||
|
||||
class App : public SingleApplication {
|
||||
Q_OBJECT;
|
||||
|
|
@ -59,7 +62,7 @@ public:
|
|||
bool event (QEvent *event) override;
|
||||
#endif // ifdef Q_OS_MACOS
|
||||
|
||||
QQmlEngine *getEngine () {
|
||||
QQmlApplicationEngine *getEngine () {
|
||||
return mEngine;
|
||||
}
|
||||
|
||||
|
|
@ -83,8 +86,10 @@ public:
|
|||
return static_cast<App *>(QApplication::instance());
|
||||
}
|
||||
|
||||
static constexpr int RestartCode = 1000;
|
||||
|
||||
Q_INVOKABLE void restart () {
|
||||
exit(APP_CODE_RESTART);
|
||||
exit(RestartCode);
|
||||
}
|
||||
|
||||
Q_INVOKABLE QQuickWindow *getCallsWindow ();
|
||||
|
|
|
|||
|
|
@ -29,21 +29,21 @@
|
|||
|
||||
#include "AppController.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
// Must be unique. Used by `SingleApplication` and `Paths`.
|
||||
constexpr char cApplicationName[] = "linphone";
|
||||
constexpr char cApplicationVersion[] = LINPHONE_QT_GIT_VERSION;
|
||||
constexpr char cApplicationMinimalQtVersion[] = "5.9.0";
|
||||
constexpr char ApplicationName[] = "linphone";
|
||||
constexpr char ApplicationVersion[] = LINPHONE_QT_GIT_VERSION;
|
||||
constexpr char ApplicationMinimalQtVersion[] = "5.9.0";
|
||||
|
||||
constexpr char cDefaultFont[] = "Noto Sans";
|
||||
constexpr char DefaultFont[] = "Noto Sans";
|
||||
}
|
||||
|
||||
AppController::AppController (int &argc, char *argv[]) {
|
||||
QT_REQUIRE_VERSION(argc, argv, cApplicationMinimalQtVersion);
|
||||
QT_REQUIRE_VERSION(argc, argv, ApplicationMinimalQtVersion);
|
||||
Q_ASSERT(!mApp);
|
||||
|
||||
// Disable QML cache. Avoid malformed cache.
|
||||
|
|
@ -57,8 +57,8 @@ AppController::AppController (int &argc, char *argv[]) {
|
|||
// App creation.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
QCoreApplication::setApplicationName(cApplicationName);
|
||||
QCoreApplication::setApplicationVersion(cApplicationVersion);
|
||||
QCoreApplication::setApplicationName(ApplicationName);
|
||||
QCoreApplication::setApplicationVersion(ApplicationVersion);
|
||||
|
||||
mApp = new App(argc, argv);
|
||||
QQuickStyle::setStyle("Default");
|
||||
|
|
@ -88,7 +88,7 @@ AppController::AppController (int &argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
|
||||
mApp->setFont(QFont(cDefaultFont));
|
||||
mApp->setFont(QFont(DefaultFont));
|
||||
}
|
||||
|
||||
AppController::~AppController () {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#ifndef APP_CONTROLLER_H_
|
||||
#define APP_CONTROLLER_H_
|
||||
|
||||
#include "App.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -37,3 +40,5 @@ public:
|
|||
private:
|
||||
App *mApp = nullptr;
|
||||
};
|
||||
|
||||
#endif // APP_CONTROLLER_H_
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "app/App.hpp"
|
||||
#include "components/calls/CallsListModel.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
|
|
@ -181,7 +183,8 @@ static QString indentedWord (QString word, int &curPos, const int lineLength, co
|
|||
}
|
||||
|
||||
static string multilineIndent (const QString &str, int indentationNumber = 0) {
|
||||
static const int lineLength(80);
|
||||
constexpr int lineLength(80);
|
||||
|
||||
static const QRegExp spaceRegexp("(\\s)");
|
||||
const QString padding(indentationNumber * 2, ' ');
|
||||
|
||||
|
|
@ -294,7 +297,7 @@ QString Cli::Command::getFunctionSyntax () const {
|
|||
functionSyntax += argName;
|
||||
functionSyntax += QStringLiteral("=<");
|
||||
switch (mArgsScheme[argName].type) {
|
||||
case STRING :
|
||||
case String:
|
||||
functionSyntax += QStringLiteral("str");
|
||||
break;
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@ class Cli : public QObject {
|
|||
typedef void (*Function)(QHash<QString, QString> &);
|
||||
|
||||
enum ArgumentType {
|
||||
STRING
|
||||
String
|
||||
};
|
||||
|
||||
struct Argument {
|
||||
Argument (ArgumentType type = STRING, bool isOptional = false) {
|
||||
Argument (ArgumentType type = String, bool isOptional = false) {
|
||||
this->type = type;
|
||||
this->isOptional = isOptional;
|
||||
}
|
||||
|
|
@ -81,8 +81,6 @@ class Cli : public QObject {
|
|||
};
|
||||
|
||||
public:
|
||||
~Cli () = default;
|
||||
|
||||
enum CommandFormat {
|
||||
UnknownFormat,
|
||||
CliFormat,
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include "Logger.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
#if defined(__linux__) || defined(__APPLE__)
|
||||
#define BLUE "\x1B[1;34m"
|
||||
#define YELLOW "\x1B[1;33m"
|
||||
|
|
@ -46,19 +48,17 @@
|
|||
#define RESET ""
|
||||
#endif // if defined(__linux__) || defined(__APPLE__)
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr char cQtDomain[] = "qt";
|
||||
constexpr size_t cMaxLogsCollectionSize = 10485760; // 10MB.
|
||||
constexpr char cSrcPattern[] = "/linphone-desktop/src/";
|
||||
constexpr char QtDomain[] = "qt";
|
||||
constexpr size_t MaxLogsCollectionSize = 10485760; // 10MB.
|
||||
constexpr char SrcPattern[] = "/linphone-desktop/src/";
|
||||
}
|
||||
|
||||
QMutex Logger::mMutex;
|
||||
|
||||
Logger *Logger::mInstance = nullptr;
|
||||
Logger *Logger::mInstance;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -150,10 +150,10 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
|
|||
QByteArray contextArr;
|
||||
{
|
||||
const char *file = context.file;
|
||||
const char *pos = file ? Utils::rstrstr(file, cSrcPattern) : file;
|
||||
const char *pos = file ? Utils::rstrstr(file, SrcPattern) : file;
|
||||
|
||||
contextArr = QStringLiteral("%1:%2: ")
|
||||
.arg(pos ? pos + sizeof(cSrcPattern) - 1 : file)
|
||||
.arg(pos ? pos + sizeof(SrcPattern) - 1 : file)
|
||||
.arg(context.line)
|
||||
.toLocal8Bit();
|
||||
contextStr = contextArr.constData();
|
||||
|
|
@ -168,7 +168,7 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
|
|||
mMutex.lock();
|
||||
|
||||
fprintf(stderr, format, dateTime.constData(), QThread::currentThread(), contextStr, localMsg.constData());
|
||||
bctbx_log(cQtDomain, level, "QT: %s%s", contextStr, localMsg.constData());
|
||||
bctbx_log(QtDomain, level, "QT: %s%s", contextStr, localMsg.constData());
|
||||
|
||||
mMutex.unlock();
|
||||
|
||||
|
|
@ -204,7 +204,7 @@ void Logger::init (const shared_ptr<linphone::Config> &config) {
|
|||
}
|
||||
|
||||
linphone::Core::setLogCollectionPath(Utils::appStringToCoreString(folder));
|
||||
linphone::Core::setLogCollectionMaxFileSize(cMaxLogsCollectionSize);
|
||||
linphone::Core::setLogCollectionMaxFileSize(MaxLogsCollectionSize);
|
||||
|
||||
mInstance->enable(SettingsModel::getLogsEnabled(config));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@ namespace linphone {
|
|||
|
||||
class Logger {
|
||||
public:
|
||||
~Logger () = default;
|
||||
|
||||
bool isVerbose () const {
|
||||
return mVerbose;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,6 @@ int main (int argc, char *argv[]) {
|
|||
do {
|
||||
app->initContentApp();
|
||||
ret = app->exec();
|
||||
} while (ret == APP_CODE_RESTART);
|
||||
} while (ret == App::RestartCode);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,22 +37,22 @@
|
|||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr char cPathAssistantConfig[] = "/linphone/assistant/";
|
||||
constexpr char cPathAvatars[] = "/avatars/";
|
||||
constexpr char cPathCaptures[] = "/Linphone/captures/";
|
||||
constexpr char cPathCodecs[] = "/codecs/";
|
||||
constexpr char cPathLogs[] = "/logs/";
|
||||
constexpr char cPathPlugins[] = "/plugins/";
|
||||
constexpr char cPathThumbnails[] = "/thumbnails/";
|
||||
constexpr char cPathUserCertificates[] = "/usr-crt/";
|
||||
constexpr char PathAssistantConfig[] = "/linphone/assistant/";
|
||||
constexpr char PathAvatars[] = "/avatars/";
|
||||
constexpr char PathCaptures[] = "/Linphone/captures/";
|
||||
constexpr char PathCodecs[] = "/codecs/";
|
||||
constexpr char PathLogs[] = "/logs/";
|
||||
constexpr char PathPlugins[] = "/plugins/";
|
||||
constexpr char PathThumbnails[] = "/thumbnails/";
|
||||
constexpr char PathUserCertificates[] = "/usr-crt/";
|
||||
|
||||
constexpr char cPathCallHistoryList[] = "/call-history.db";
|
||||
constexpr char cPathConfig[] = "/linphonerc";
|
||||
constexpr char cPathFactoryConfig[] = "/linphone/linphonerc-factory";
|
||||
constexpr char cPathRootCa[] = "/linphone/rootca.pem";
|
||||
constexpr char cPathFriendsList[] = "/friends.db";
|
||||
constexpr char cPathMessageHistoryList[] = "/message-history.db";
|
||||
constexpr char cPathZrtpSecrets[] = "/zidcache";
|
||||
constexpr char PathCallHistoryList[] = "/call-history.db";
|
||||
constexpr char PathConfig[] = "/linphonerc";
|
||||
constexpr char PathFactoryConfig[] = "/linphone/linphonerc-factory";
|
||||
constexpr char PathRootCa[] = "/linphone/rootca.pem";
|
||||
constexpr char PathFriendsList[] = "/friends.db";
|
||||
constexpr char PathMessageHistoryList[] = "/message-history.db";
|
||||
constexpr char PathZrtpSecrets[] = "/zidcache";
|
||||
}
|
||||
|
||||
static inline bool dirPathExists (const QString &path) {
|
||||
|
|
@ -127,35 +127,35 @@ static inline QString getAppPackageMsPluginsDirPath () {
|
|||
}
|
||||
|
||||
static inline QString getAppAssistantConfigDirPath () {
|
||||
return getAppPackageDataDirPath() + cPathAssistantConfig;
|
||||
return getAppPackageDataDirPath() + PathAssistantConfig;
|
||||
}
|
||||
|
||||
static inline QString getAppConfigFilePath () {
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + cPathConfig;
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + PathConfig;
|
||||
}
|
||||
|
||||
static inline QString getAppCallHistoryFilePath () {
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathCallHistoryList;
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathCallHistoryList;
|
||||
}
|
||||
|
||||
static inline QString getAppFactoryConfigFilePath () {
|
||||
return getAppPackageDataDirPath() + cPathFactoryConfig;
|
||||
return getAppPackageDataDirPath() + PathFactoryConfig;
|
||||
}
|
||||
|
||||
static inline QString getAppPluginsDirPath () {
|
||||
return getAppPackageDataDirPath() + cPathPlugins;
|
||||
return getAppPackageDataDirPath() + PathPlugins;
|
||||
}
|
||||
|
||||
static inline QString getAppRootCaFilePath () {
|
||||
return getAppPackageDataDirPath() + cPathRootCa;
|
||||
return getAppPackageDataDirPath() + PathRootCa;
|
||||
}
|
||||
|
||||
static inline QString getAppFriendsFilePath () {
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathFriendsList;
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathFriendsList;
|
||||
}
|
||||
|
||||
static inline QString getAppMessageHistoryFilePath () {
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathMessageHistoryList;
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathMessageHistoryList;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -171,7 +171,7 @@ string Paths::getAssistantConfigDirPath () {
|
|||
}
|
||||
|
||||
string Paths::getAvatarsDirPath () {
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathAvatars);
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathAvatars);
|
||||
}
|
||||
|
||||
string Paths::getCallHistoryFilePath () {
|
||||
|
|
@ -179,11 +179,11 @@ string Paths::getCallHistoryFilePath () {
|
|||
}
|
||||
|
||||
string Paths::getCapturesDirPath () {
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + cPathCaptures);
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + PathCaptures);
|
||||
}
|
||||
|
||||
string Paths::getCodecsDirPath () {
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathCodecs);
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathCodecs);
|
||||
}
|
||||
|
||||
string Paths::getConfigFilePath (const QString &configPath, bool writable) {
|
||||
|
|
@ -191,7 +191,7 @@ string Paths::getConfigFilePath (const QString &configPath, bool writable) {
|
|||
? getAppConfigFilePath()
|
||||
: QFileInfo(configPath).absoluteFilePath();
|
||||
|
||||
return writable ? ::getWritableFilePath(path) : ::getReadableFilePath(path);
|
||||
return writable ? getWritableFilePath(path) : getReadableFilePath(path);
|
||||
}
|
||||
|
||||
string Paths::getFactoryConfigFilePath () {
|
||||
|
|
@ -207,7 +207,7 @@ string Paths::getDownloadDirPath () {
|
|||
}
|
||||
|
||||
string Paths::getLogsDirPath () {
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathLogs);
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathLogs);
|
||||
}
|
||||
|
||||
string Paths::getMessageHistoryFilePath () {
|
||||
|
|
@ -227,15 +227,15 @@ string Paths::getRootCaFilePath () {
|
|||
}
|
||||
|
||||
string Paths::getThumbnailsDirPath () {
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathThumbnails);
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathThumbnails);
|
||||
}
|
||||
|
||||
string Paths::getUserCertificatesDirPath () {
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathUserCertificates);
|
||||
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathUserCertificates);
|
||||
}
|
||||
|
||||
string Paths::getZrtpSecretsFilePath () {
|
||||
return getWritableFilePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + cPathZrtpSecrets);
|
||||
return getWritableFilePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathZrtpSecrets);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
const QString AvatarProvider::PROVIDER_ID = "avatar";
|
||||
const QString AvatarProvider::ProviderId = "avatar";
|
||||
|
||||
AvatarProvider::AvatarProvider () : QQuickImageProvider(
|
||||
QQmlImageProviderBase::Image,
|
||||
|
|
|
|||
|
|
@ -30,11 +30,10 @@
|
|||
class AvatarProvider : public QQuickImageProvider {
|
||||
public:
|
||||
AvatarProvider ();
|
||||
~AvatarProvider () = default;
|
||||
|
||||
QImage requestImage (const QString &id, QSize *size, const QSize &requestedSize) override;
|
||||
|
||||
static const QString PROVIDER_ID;
|
||||
static const QString ProviderId;
|
||||
|
||||
private:
|
||||
QString mAvatarsPath;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include <QSvgRenderer>
|
||||
|
||||
#include "app/App.hpp"
|
||||
#include "components/other/colors/Colors.hpp"
|
||||
|
||||
#include "ImageProvider.hpp"
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ using namespace std;
|
|||
|
||||
namespace {
|
||||
// Max image size in bytes. (100Kb)
|
||||
constexpr qint64 cMaxImageSize = 102400;
|
||||
constexpr qint64 MaxImageSize = 102400;
|
||||
}
|
||||
|
||||
static void removeAttribute (QXmlStreamAttributes &readerAttributes, const QString &name) {
|
||||
|
|
@ -234,7 +235,7 @@ static QByteArray computeContent (QFile &file) {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
const QString ImageProvider::PROVIDER_ID = "internal";
|
||||
const QString ImageProvider::ProviderId = "internal";
|
||||
|
||||
ImageProvider::ImageProvider () : QQuickImageProvider(
|
||||
QQmlImageProviderBase::Image,
|
||||
|
|
@ -252,7 +253,7 @@ QImage ImageProvider::requestImage (const QString &id, QSize *size, const QSize
|
|||
|
||||
// 1. Read and update XML content.
|
||||
QFile file(path);
|
||||
if (Q_UNLIKELY(QFileInfo(file).size() > cMaxImageSize)) {
|
||||
if (Q_UNLIKELY(QFileInfo(file).size() > MaxImageSize)) {
|
||||
qWarning() << QStringLiteral("Unable to open large file: `%1`.").arg(path);
|
||||
return QImage();
|
||||
}
|
||||
|
|
@ -262,7 +263,7 @@ QImage ImageProvider::requestImage (const QString &id, QSize *size, const QSize
|
|||
return QImage();
|
||||
}
|
||||
|
||||
const QByteArray content = ::computeContent(file);
|
||||
const QByteArray content = computeContent(file);
|
||||
if (Q_UNLIKELY(!content.length())) {
|
||||
qWarning() << QStringLiteral("Unable to parse file: `%1`.").arg(path);
|
||||
return QImage();
|
||||
|
|
|
|||
|
|
@ -30,11 +30,10 @@
|
|||
class ImageProvider : public QQuickImageProvider {
|
||||
public:
|
||||
ImageProvider ();
|
||||
~ImageProvider () = default;
|
||||
|
||||
QImage requestImage (const QString &id, QSize *size, const QSize &requestedSize) override;
|
||||
|
||||
static const QString PROVIDER_ID;
|
||||
static const QString ProviderId;
|
||||
};
|
||||
|
||||
#endif // IMAGE_PROVIDER_H_
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
const QString ThumbnailProvider::PROVIDER_ID = "thumbnail";
|
||||
const QString ThumbnailProvider::ProviderId = "thumbnail";
|
||||
|
||||
ThumbnailProvider::ThumbnailProvider () : QQuickImageProvider(
|
||||
QQmlImageProviderBase::Image,
|
||||
|
|
|
|||
|
|
@ -30,11 +30,10 @@
|
|||
class ThumbnailProvider : public QQuickImageProvider {
|
||||
public:
|
||||
ThumbnailProvider ();
|
||||
~ThumbnailProvider () = default;
|
||||
|
||||
QImage requestImage (const QString &id, QSize *size, const QSize &requestedSize) override;
|
||||
|
||||
static const QString PROVIDER_ID;
|
||||
static const QString ProviderId;
|
||||
|
||||
private:
|
||||
QString mThumbnailsPath;
|
||||
|
|
|
|||
|
|
@ -43,20 +43,22 @@
|
|||
#include <lmcons.h>
|
||||
#endif // ifdef Q_OS_WIN
|
||||
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "SingleApplication.hpp"
|
||||
#include "SingleApplicationPrivate.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
static const char NewInstance = 'N';
|
||||
static const char SecondaryInstance = 'S';
|
||||
static const char Reconnect = 'R';
|
||||
static const char InvalidConnection = '\0';
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr char NewInstance = 'N';
|
||||
constexpr char SecondaryInstance = 'S';
|
||||
constexpr char Reconnect = 'R';
|
||||
constexpr char InvalidConnection = '\0';
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
SingleApplicationPrivate::SingleApplicationPrivate (SingleApplication *q_ptr) : q_ptr(q_ptr) {
|
||||
|
|
@ -234,20 +236,20 @@ void SingleApplicationPrivate::connectToPrimary (int msecs, char connectionType)
|
|||
|
||||
// Handle any further termination signals to ensure the
|
||||
// QSharedMemory block is deleted even if the process crashes
|
||||
signal(SIGHUP, SingleApplicationPrivate::terminate); // 1
|
||||
signal(SIGINT, SingleApplicationPrivate::terminate); // 2
|
||||
signal(SIGQUIT, SingleApplicationPrivate::terminate); // 3
|
||||
signal(SIGILL, SingleApplicationPrivate::terminate); // 4
|
||||
signal(SIGABRT, SingleApplicationPrivate::terminate); // 6
|
||||
signal(SIGFPE, SingleApplicationPrivate::terminate); // 8
|
||||
signal(SIGBUS, SingleApplicationPrivate::terminate); // 10
|
||||
signal(SIGSEGV, SingleApplicationPrivate::terminate); // 11
|
||||
signal(SIGSYS, SingleApplicationPrivate::terminate); // 12
|
||||
signal(SIGPIPE, SingleApplicationPrivate::terminate); // 13
|
||||
signal(SIGALRM, SingleApplicationPrivate::terminate); // 14
|
||||
signal(SIGTERM, SingleApplicationPrivate::terminate); // 15
|
||||
signal(SIGXCPU, SingleApplicationPrivate::terminate); // 24
|
||||
signal(SIGXFSZ, SingleApplicationPrivate::terminate); // 25
|
||||
signal(SIGHUP, SingleApplicationPrivate::terminate); // 1
|
||||
signal(SIGINT, SingleApplicationPrivate::terminate); // 2
|
||||
signal(SIGQUIT, SingleApplicationPrivate::terminate); // 3
|
||||
signal(SIGILL, SingleApplicationPrivate::terminate); // 4
|
||||
signal(SIGABRT, SingleApplicationPrivate::terminate); // 6
|
||||
signal(SIGFPE, SingleApplicationPrivate::terminate); // 8
|
||||
signal(SIGBUS, SingleApplicationPrivate::terminate); // 10
|
||||
signal(SIGSEGV, SingleApplicationPrivate::terminate); // 11
|
||||
signal(SIGSYS, SingleApplicationPrivate::terminate); // 12
|
||||
signal(SIGPIPE, SingleApplicationPrivate::terminate); // 13
|
||||
signal(SIGALRM, SingleApplicationPrivate::terminate); // 14
|
||||
signal(SIGTERM, SingleApplicationPrivate::terminate); // 15
|
||||
signal(SIGXCPU, SingleApplicationPrivate::terminate); // 24
|
||||
signal(SIGXFSZ, SingleApplicationPrivate::terminate); // 25
|
||||
}
|
||||
|
||||
void SingleApplicationPrivate::terminate (int signum) {
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ class SingleApplicationPrivate : public QDBusAbstractAdaptor {
|
|||
|
||||
public:
|
||||
Q_DECLARE_PUBLIC(SingleApplication) SingleApplicationPrivate (SingleApplication *q_ptr);
|
||||
~SingleApplicationPrivate () = default;
|
||||
|
||||
QDBusConnection getBus () const;
|
||||
|
||||
|
|
|
|||
|
|
@ -75,8 +75,8 @@ public:
|
|||
|
||||
public Q_SLOTS:
|
||||
void slotConnectionEstablished ();
|
||||
void slotDataAvailable(QLocalSocket *, quint32);
|
||||
void slotClientConnectionClosed(QLocalSocket *, quint32);
|
||||
void slotDataAvailable (QLocalSocket *, quint32);
|
||||
void slotClientConnectionClosed (QLocalSocket *, quint32);
|
||||
};
|
||||
|
||||
#endif // SINGLE_APPLICATION_PRIVATE_H_
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@
|
|||
class DefaultTranslator : public QTranslator {
|
||||
public:
|
||||
DefaultTranslator (QObject *parent = Q_NULLPTR);
|
||||
~DefaultTranslator () = default;
|
||||
|
||||
QString translate (
|
||||
const char *context,
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "assistant/AssistantModel.hpp"
|
||||
#include "authentication/AuthenticationNotifier.hpp"
|
||||
#include "call/CallModel.hpp"
|
||||
#include "calls/CallsListModel.hpp"
|
||||
#include "calls/CallsListProxyModel.hpp"
|
||||
#include "camera/Camera.hpp"
|
||||
|
|
@ -34,12 +35,19 @@
|
|||
#include "codecs/VideoCodecsModel.hpp"
|
||||
#include "conference/ConferenceAddModel.hpp"
|
||||
#include "conference/ConferenceModel.hpp"
|
||||
#include "contact/ContactModel.hpp"
|
||||
#include "contact/VcardModel.hpp"
|
||||
#include "contacts/ContactsListModel.hpp"
|
||||
#include "contacts/ContactsListProxyModel.hpp"
|
||||
#include "core/CoreHandlers.hpp"
|
||||
#include "core/CoreManager.hpp"
|
||||
#include "file/FileDownloader.hpp"
|
||||
#include "file/FileExtractor.hpp"
|
||||
#include "notifier/Notifier.hpp"
|
||||
#include "presence/OwnPresenceModel.hpp"
|
||||
#include "settings/AccountSettingsModel.hpp"
|
||||
#include "settings/SettingsModel.hpp"
|
||||
#include "sip-addresses/SipAddressesModel.hpp"
|
||||
#include "sip-addresses/SipAddressesProxyModel.hpp"
|
||||
#include "sound-player/SoundPlayer.hpp"
|
||||
#include "telephone-numbers/TelephoneNumbersModel.hpp"
|
||||
|
|
|
|||
|
|
@ -20,18 +20,22 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../../app/paths/Paths.hpp"
|
||||
#include "../../utils/LinphoneUtils.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "app/paths/Paths.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/settings/AccountSettingsModel.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "utils/LinphoneUtils.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "AssistantModel.hpp"
|
||||
|
||||
#define DEFAULT_XMLRPC_URL "https://subscribe.linphone.org:444/wizard.php"
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
namespace {
|
||||
constexpr char DefaultXmlrpcUri[] = "https://subscribe.linphone.org:444/wizard.php";
|
||||
}
|
||||
|
||||
class AssistantModel::Handlers : public linphone::AccountCreatorListener {
|
||||
public:
|
||||
|
|
@ -144,7 +148,7 @@ AssistantModel::AssistantModel (QObject *parent) : QObject(parent) {
|
|||
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
mAccountCreator = core->createAccountCreator(
|
||||
core->getConfig()->getString("assistant", "xmlrpc_url", DEFAULT_XMLRPC_URL)
|
||||
core->getConfig()->getString("assistant", "xmlrpc_url", DefaultXmlrpcUri)
|
||||
);
|
||||
mAccountCreator->setListener(mHandlers);
|
||||
}
|
||||
|
|
@ -196,25 +200,25 @@ bool AssistantModel::addOtherSipAccount (const QVariantMap &map) {
|
|||
// Server address.
|
||||
{
|
||||
shared_ptr<linphone::Address> address = factory->createAddress(
|
||||
::Utils::appStringToCoreString(QStringLiteral("sip:%1").arg(domain))
|
||||
);
|
||||
Utils::appStringToCoreString(QStringLiteral("sip:%1").arg(domain))
|
||||
);
|
||||
address->setTransport(LinphoneUtils::stringToTransportType(map["transport"].toString()));
|
||||
|
||||
if (proxyConfig->setServerAddr(address->asString())) {
|
||||
qWarning() << QStringLiteral("Unable to add server address: `%1`.")
|
||||
.arg(::Utils::coreStringToAppString(address->asString()));
|
||||
.arg(Utils::coreStringToAppString(address->asString()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Sip Address.
|
||||
shared_ptr<linphone::Address> address = factory->createAddress(::Utils::appStringToCoreString(sipAddress));
|
||||
shared_ptr<linphone::Address> address = factory->createAddress(Utils::appStringToCoreString(sipAddress));
|
||||
if (!address) {
|
||||
qWarning() << QStringLiteral("Unable to create sip address object from: `%1`.").arg(sipAddress);
|
||||
return false;
|
||||
}
|
||||
|
||||
address->setDisplayName(::Utils::appStringToCoreString(map["displayName"].toString()));
|
||||
address->setDisplayName(Utils::appStringToCoreString(map["displayName"].toString()));
|
||||
proxyConfig->setIdentityAddress(address);
|
||||
|
||||
// AuthInfo.
|
||||
|
|
@ -222,7 +226,7 @@ bool AssistantModel::addOtherSipAccount (const QVariantMap &map) {
|
|||
factory->createAuthInfo(
|
||||
address->getUsername(), // Username.
|
||||
"", // User ID.
|
||||
::Utils::appStringToCoreString(map["password"].toString()), // Password.
|
||||
Utils::appStringToCoreString(map["password"].toString()), // Password.
|
||||
"", // HA1.
|
||||
"", // Realm.
|
||||
address->getDomain() // Domain.
|
||||
|
|
@ -235,14 +239,14 @@ bool AssistantModel::addOtherSipAccount (const QVariantMap &map) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getEmail () const {
|
||||
return ::Utils::coreStringToAppString(mAccountCreator->getEmail());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getEmail());
|
||||
}
|
||||
|
||||
void AssistantModel::setEmail (const QString &email) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (mAccountCreator->setEmail(::Utils::appStringToCoreString(email))) {
|
||||
switch (mAccountCreator->setEmail(Utils::appStringToCoreString(email))) {
|
||||
case linphone::AccountCreatorEmailStatusOk:
|
||||
break;
|
||||
case linphone::AccountCreatorEmailStatusMalformed:
|
||||
|
|
@ -259,14 +263,14 @@ void AssistantModel::setEmail (const QString &email) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getPassword () const {
|
||||
return ::Utils::coreStringToAppString(mAccountCreator->getPassword());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getPassword());
|
||||
}
|
||||
|
||||
void AssistantModel::setPassword (const QString &password) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (mAccountCreator->setPassword(::Utils::appStringToCoreString(password))) {
|
||||
switch (mAccountCreator->setPassword(Utils::appStringToCoreString(password))) {
|
||||
case linphone::AccountCreatorPasswordStatusOk:
|
||||
break;
|
||||
case linphone::AccountCreatorPasswordStatusTooShort:
|
||||
|
|
@ -277,11 +281,11 @@ void AssistantModel::setPassword (const QString &password) {
|
|||
break;
|
||||
case linphone::AccountCreatorPasswordStatusInvalidCharacters:
|
||||
error = tr("passwordStatusInvalidCharacters")
|
||||
.arg(::Utils::coreStringToAppString(config->getString("assistant", "password_regex", "")));
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "password_regex", "")));
|
||||
break;
|
||||
case linphone::AccountCreatorPasswordStatusMissingCharacters:
|
||||
error = tr("passwordStatusMissingCharacters")
|
||||
.arg(::Utils::coreStringToAppString(config->getString("assistant", "missing_characters", "")));
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "missing_characters", "")));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -302,14 +306,14 @@ void AssistantModel::setCountryCode (const QString &countryCode) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getPhoneNumber () const {
|
||||
return ::Utils::coreStringToAppString(mAccountCreator->getPhoneNumber());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getPhoneNumber());
|
||||
}
|
||||
|
||||
void AssistantModel::setPhoneNumber (const QString &phoneNumber) {
|
||||
shared_ptr<linphone::Config> config = CoreManager::getInstance()->getCore()->getConfig();
|
||||
QString error;
|
||||
|
||||
switch (mAccountCreator->setPhoneNumber(::Utils::appStringToCoreString(phoneNumber), ::Utils::appStringToCoreString(mCountryCode))) {
|
||||
switch (mAccountCreator->setPhoneNumber(Utils::appStringToCoreString(phoneNumber), Utils::appStringToCoreString(mCountryCode))) {
|
||||
case linphone::AccountCreatorPhoneNumberStatusOk:
|
||||
break;
|
||||
case linphone::AccountCreatorPhoneNumberStatusInvalid:
|
||||
|
|
@ -334,14 +338,14 @@ void AssistantModel::setPhoneNumber (const QString &phoneNumber) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getUsername () const {
|
||||
return ::Utils::coreStringToAppString(mAccountCreator->getUsername());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getUsername());
|
||||
}
|
||||
|
||||
void AssistantModel::setUsername (const QString &username) {
|
||||
emit usernameChanged(
|
||||
username,
|
||||
mapAccountCreatorUsernameStatusToString(
|
||||
mAccountCreator->setUsername(::Utils::appStringToCoreString(username))
|
||||
mAccountCreator->setUsername(Utils::appStringToCoreString(username))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -349,14 +353,14 @@ void AssistantModel::setUsername (const QString &username) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getDisplayName () const {
|
||||
return ::Utils::coreStringToAppString(mAccountCreator->getDisplayName());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getDisplayName());
|
||||
}
|
||||
|
||||
void AssistantModel::setDisplayName (const QString &displayName) {
|
||||
emit displayNameChanged(
|
||||
displayName,
|
||||
mapAccountCreatorUsernameStatusToString(
|
||||
mAccountCreator->setDisplayName(::Utils::appStringToCoreString(displayName))
|
||||
mAccountCreator->setDisplayName(Utils::appStringToCoreString(displayName))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -364,11 +368,11 @@ void AssistantModel::setDisplayName (const QString &displayName) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AssistantModel::getActivationCode () const {
|
||||
return ::Utils::coreStringToAppString(mAccountCreator->getActivationCode());
|
||||
return Utils::coreStringToAppString(mAccountCreator->getActivationCode());
|
||||
}
|
||||
|
||||
void AssistantModel::setActivationCode (const QString &activationCode) {
|
||||
mAccountCreator->setActivationCode(::Utils::appStringToCoreString(activationCode));
|
||||
mAccountCreator->setActivationCode(Utils::appStringToCoreString(activationCode));
|
||||
emit activationCodeChanged(activationCode);
|
||||
}
|
||||
|
||||
|
|
@ -381,11 +385,11 @@ QString AssistantModel::getConfigFilename () const {
|
|||
void AssistantModel::setConfigFilename (const QString &configFilename) {
|
||||
mConfigFilename = configFilename;
|
||||
|
||||
QString configPath = ::Utils::coreStringToAppString(Paths::getAssistantConfigDirPath()) + configFilename;
|
||||
QString configPath = Utils::coreStringToAppString(Paths::getAssistantConfigDirPath()) + configFilename;
|
||||
qInfo() << QStringLiteral("Set config on assistant: `%1`.").arg(configPath);
|
||||
|
||||
CoreManager::getInstance()->getCore()->getConfig()->loadFromXmlFile(
|
||||
::Utils::appStringToCoreString(configPath)
|
||||
Utils::appStringToCoreString(configPath)
|
||||
);
|
||||
|
||||
emit configFilenameChanged(configFilename);
|
||||
|
|
@ -408,7 +412,7 @@ QString AssistantModel::mapAccountCreatorUsernameStatusToString (linphone::Accou
|
|||
break;
|
||||
case linphone::AccountCreatorUsernameStatusInvalidCharacters:
|
||||
error = tr("usernameStatusInvalidCharacters")
|
||||
.arg(::Utils::coreStringToAppString(config->getString("assistant", "username_regex", "")));
|
||||
.arg(Utils::coreStringToAppString(config->getString("assistant", "username_regex", "")));
|
||||
break;
|
||||
case linphone::AccountCreatorUsernameStatusInvalid:
|
||||
error = tr("usernameStatusInvalid");
|
||||
|
|
|
|||
|
|
@ -20,15 +20,16 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "AuthenticationNotifier.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
AuthenticationNotifier::AuthenticationNotifier (QObject *parent) : QObject(parent) {
|
||||
QObject::connect(
|
||||
CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::authenticationRequested,
|
||||
|
|
@ -39,12 +40,12 @@ AuthenticationNotifier::AuthenticationNotifier (QObject *parent) : QObject(paren
|
|||
void AuthenticationNotifier::handleAuthenticationRequested (const shared_ptr<linphone::AuthInfo> &authInfo) {
|
||||
emit authenticationRequested(
|
||||
QVariant::fromValue(authInfo),
|
||||
::Utils::coreStringToAppString(authInfo->getRealm()),
|
||||
Utils::coreStringToAppString(authInfo->getRealm()),
|
||||
QStringLiteral("%1@%2").arg(
|
||||
::Utils::coreStringToAppString(authInfo->getUsername())
|
||||
Utils::coreStringToAppString(authInfo->getUsername())
|
||||
).arg(
|
||||
::Utils::coreStringToAppString(authInfo->getDomain())
|
||||
Utils::coreStringToAppString(authInfo->getDomain())
|
||||
),
|
||||
::Utils::coreStringToAppString(authInfo->getUserid())
|
||||
Utils::coreStringToAppString(authInfo->getUserid())
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,19 +23,22 @@
|
|||
#ifndef AUTHENTICATION_NOTIFIER_H_
|
||||
#define AUTHENTICATION_NOTIFIER_H_
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
// =============================================================================
|
||||
|
||||
namespace linphone {
|
||||
class AuthInfo;
|
||||
}
|
||||
|
||||
class AuthenticationNotifier : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
AuthenticationNotifier (QObject *parent = Q_NULLPTR);
|
||||
|
||||
~AuthenticationNotifier () = default;
|
||||
|
||||
signals:
|
||||
void authenticationRequested (const QVariant &authInfo, const QString &realm, const QString &sipAddress, const QString &userId);
|
||||
|
||||
|
|
@ -43,6 +46,6 @@ private:
|
|||
void handleAuthenticationRequested (const std::shared_ptr<linphone::AuthInfo> &authInfo);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::AuthInfo> );
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::AuthInfo>);
|
||||
|
||||
#endif // AUTHENTICATION_NOTIFIER_H_
|
||||
|
|
|
|||
|
|
@ -24,7 +24,11 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include "app/App.hpp"
|
||||
#include "components/calls/CallsListModel.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/notifier/Notifier.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "utils/LinphoneUtils.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
|
|
@ -35,8 +39,8 @@
|
|||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr char cAutoAnswerObjectName[] = "auto-answer-timer";
|
||||
constexpr int cDtmfSoundDelay = 200;
|
||||
constexpr char AutoAnswerObjectName[] = "auto-answer-timer";
|
||||
constexpr int DtmfSoundDelay = 200;
|
||||
}
|
||||
|
||||
CallModel::CallModel (shared_ptr<linphone::Call> call) {
|
||||
|
|
@ -56,7 +60,7 @@ CallModel::CallModel (shared_ptr<linphone::Call> call) {
|
|||
QTimer *timer = new QTimer(this);
|
||||
timer->setInterval(settings->getAutoAnswerDelay());
|
||||
timer->setSingleShot(true);
|
||||
timer->setObjectName(cAutoAnswerObjectName);
|
||||
timer->setObjectName(AutoAnswerObjectName);
|
||||
|
||||
QObject::connect(timer, &QTimer::timeout, this, &CallModel::acceptWithAutoAnswerDelay);
|
||||
timer->start();
|
||||
|
|
@ -81,14 +85,14 @@ CallModel::~CallModel () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString CallModel::getSipAddress () const {
|
||||
return ::Utils::coreStringToAppString(mCall->getRemoteAddress()->asString());
|
||||
return Utils::coreStringToAppString(mCall->getRemoteAddress()->asString());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CallModel::setRecordFile (shared_ptr<linphone::CallParams> &callParams) {
|
||||
callParams->setRecordFile(
|
||||
::Utils::appStringToCoreString(
|
||||
Utils::appStringToCoreString(
|
||||
QStringLiteral("%1%2.mkv")
|
||||
.arg(CoreManager::getInstance()->getSettingsModel()->getSavedVideosFolder())
|
||||
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss"))
|
||||
|
|
@ -185,7 +189,7 @@ void CallModel::askForTransfer () {
|
|||
}
|
||||
|
||||
bool CallModel::transferTo (const QString &sipAddress) {
|
||||
bool status = !!mCall->transfer(::Utils::appStringToCoreString(sipAddress));
|
||||
bool status = !!mCall->transfer(Utils::appStringToCoreString(sipAddress));
|
||||
if (status)
|
||||
qWarning() << QStringLiteral("Unable to transfer: `%1`.").arg(sipAddress);
|
||||
return status;
|
||||
|
|
@ -219,7 +223,7 @@ void CallModel::takeSnapshot () {
|
|||
qInfo() << QStringLiteral("Take snapshot of call:") << this;
|
||||
|
||||
const QString filePath = CoreManager::getInstance()->getSettingsModel()->getSavedScreenshotsFolder() + newName;
|
||||
mCall->takeVideoSnapshot(::Utils::appStringToCoreString(filePath));
|
||||
mCall->takeVideoSnapshot(Utils::appStringToCoreString(filePath));
|
||||
App::getInstance()->getNotifier()->notifySnapshotWasTaken(filePath);
|
||||
}
|
||||
|
||||
|
|
@ -245,7 +249,7 @@ void CallModel::stopRecording () {
|
|||
mCall->stopRecording();
|
||||
|
||||
App::getInstance()->getNotifier()->notifyRecordingCompleted(
|
||||
::Utils::coreStringToAppString(mCall->getParams()->getRecordFile())
|
||||
Utils::coreStringToAppString(mCall->getParams()->getRecordFile())
|
||||
);
|
||||
|
||||
emit recordingChanged(false);
|
||||
|
|
@ -253,7 +257,7 @@ void CallModel::stopRecording () {
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CallModel::handleCallEncryptionChanged (const std::shared_ptr<linphone::Call> &call) {
|
||||
void CallModel::handleCallEncryptionChanged (const shared_ptr<linphone::Call> &call) {
|
||||
if (call == mCall)
|
||||
emit securityUpdated();
|
||||
}
|
||||
|
|
@ -330,7 +334,7 @@ void CallModel::updateIsInConference () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void CallModel::stopAutoAnswerTimer () const {
|
||||
QTimer *timer = findChild<QTimer *>(cAutoAnswerObjectName, Qt::FindDirectChildrenOnly);
|
||||
QTimer *timer = findChild<QTimer *>(AutoAnswerObjectName, Qt::FindDirectChildrenOnly);
|
||||
if (timer) {
|
||||
timer->stop();
|
||||
timer->deleteLater();
|
||||
|
|
@ -552,7 +556,7 @@ void CallModel::sendDtmf (const QString &dtmf) {
|
|||
const char key = dtmf.constData()[0].toLatin1();
|
||||
qInfo() << QStringLiteral("Send dtmf: `%1`.").arg(key);
|
||||
mCall->sendDtmf(key);
|
||||
CoreManager::getInstance()->getCore()->playDtmf(key, cDtmfSoundDelay);
|
||||
CoreManager::getInstance()->getCore()->playDtmf(key, DtmfSoundDelay);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -579,12 +583,12 @@ bool CallModel::isSecured () const {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString CallModel::getLocalSas () const {
|
||||
QString token = ::Utils::coreStringToAppString(mCall->getAuthenticationToken());
|
||||
QString token = Utils::coreStringToAppString(mCall->getAuthenticationToken());
|
||||
return mCall->getDir() == linphone::CallDirIncoming ? token.left(2).toUpper() : token.right(2).toUpper();
|
||||
}
|
||||
|
||||
QString CallModel::getRemoteSas () const {
|
||||
QString token = ::Utils::coreStringToAppString(mCall->getAuthenticationToken());
|
||||
QString token = Utils::coreStringToAppString(mCall->getAuthenticationToken());
|
||||
return mCall->getDir() != linphone::CallDirIncoming ? token.left(2).toUpper() : token.right(2).toUpper();
|
||||
}
|
||||
|
||||
|
|
@ -654,42 +658,42 @@ void CallModel::updateStats (const shared_ptr<const linphone::CallStats> &callSt
|
|||
|
||||
statsList.clear();
|
||||
|
||||
statsList << ::createStat(tr("callStatsCodec"), payloadType
|
||||
statsList << createStat(tr("callStatsCodec"), payloadType
|
||||
? QStringLiteral("%1 / %2kHz").arg(Utils::coreStringToAppString(payloadType->getMimeType())).arg(payloadType->getClockRate() / 1000)
|
||||
: QString(""));
|
||||
statsList << ::createStat(tr("callStatsUploadBandwidth"), QStringLiteral("%1 kbits/s").arg(int(callStats->getUploadBandwidth())));
|
||||
statsList << ::createStat(tr("callStatsDownloadBandwidth"), QStringLiteral("%1 kbits/s").arg(int(callStats->getDownloadBandwidth())));
|
||||
statsList << ::createStat(tr("callStatsIceState"), iceStateToString(callStats->getIceState()));
|
||||
statsList << ::createStat(tr("callStatsIpFamily"), family);
|
||||
statsList << ::createStat(tr("callStatsSenderLossRate"), QStringLiteral("%1 %").arg(callStats->getSenderLossRate()));
|
||||
statsList << ::createStat(tr("callStatsReceiverLossRate"), QStringLiteral("%1 %").arg(callStats->getReceiverLossRate()));
|
||||
statsList << createStat(tr("callStatsUploadBandwidth"), QStringLiteral("%1 kbits/s").arg(int(callStats->getUploadBandwidth())));
|
||||
statsList << createStat(tr("callStatsDownloadBandwidth"), QStringLiteral("%1 kbits/s").arg(int(callStats->getDownloadBandwidth())));
|
||||
statsList << createStat(tr("callStatsIceState"), iceStateToString(callStats->getIceState()));
|
||||
statsList << createStat(tr("callStatsIpFamily"), family);
|
||||
statsList << createStat(tr("callStatsSenderLossRate"), QStringLiteral("%1 %").arg(callStats->getSenderLossRate()));
|
||||
statsList << createStat(tr("callStatsReceiverLossRate"), QStringLiteral("%1 %").arg(callStats->getReceiverLossRate()));
|
||||
|
||||
switch (callStats->getType()) {
|
||||
case linphone::StreamTypeAudio:
|
||||
statsList << ::createStat(tr("callStatsJitterBuffer"), QStringLiteral("%1 ms").arg(callStats->getJitterBufferSizeMs()));
|
||||
statsList << createStat(tr("callStatsJitterBuffer"), QStringLiteral("%1 ms").arg(callStats->getJitterBufferSizeMs()));
|
||||
break;
|
||||
case linphone::StreamTypeVideo: {
|
||||
statsList << ::createStat(tr("callStatsEstimatedDownloadBandwidth"), QStringLiteral("%1 kbits/s").arg(int(callStats->getEstimatedDownloadBandwidth())));
|
||||
const QString sentVideoDefinitionName = ::Utils::coreStringToAppString(params->getSentVideoDefinition()->getName());
|
||||
statsList << createStat(tr("callStatsEstimatedDownloadBandwidth"), QStringLiteral("%1 kbits/s").arg(int(callStats->getEstimatedDownloadBandwidth())));
|
||||
const QString sentVideoDefinitionName = Utils::coreStringToAppString(params->getSentVideoDefinition()->getName());
|
||||
const QString sentVideoDefinition = QStringLiteral("%1x%2")
|
||||
.arg(params->getSentVideoDefinition()->getWidth())
|
||||
.arg(params->getSentVideoDefinition()->getHeight());
|
||||
|
||||
statsList << ::createStat(tr("callStatsSentVideoDefinition"), sentVideoDefinition == sentVideoDefinitionName
|
||||
statsList << createStat(tr("callStatsSentVideoDefinition"), sentVideoDefinition == sentVideoDefinitionName
|
||||
? sentVideoDefinition
|
||||
: QStringLiteral("%1 (%2)").arg(sentVideoDefinition).arg(sentVideoDefinitionName));
|
||||
|
||||
const QString receivedVideoDefinitionName = ::Utils::coreStringToAppString(params->getReceivedVideoDefinition()->getName());
|
||||
const QString receivedVideoDefinitionName = Utils::coreStringToAppString(params->getReceivedVideoDefinition()->getName());
|
||||
const QString receivedVideoDefinition = QString("%1x%2")
|
||||
.arg(params->getReceivedVideoDefinition()->getWidth())
|
||||
.arg(params->getReceivedVideoDefinition()->getHeight());
|
||||
|
||||
statsList << ::createStat(tr("callStatsReceivedVideoDefinition"), receivedVideoDefinition == receivedVideoDefinitionName
|
||||
statsList << createStat(tr("callStatsReceivedVideoDefinition"), receivedVideoDefinition == receivedVideoDefinitionName
|
||||
? receivedVideoDefinition
|
||||
: QString("%1 (%2)").arg(receivedVideoDefinition).arg(receivedVideoDefinitionName));
|
||||
|
||||
statsList << ::createStat(tr("callStatsReceivedFramerate"), QStringLiteral("%1 FPS").arg(params->getReceivedFramerate()));
|
||||
statsList << ::createStat(tr("callStatsSentFramerate"), QStringLiteral("%1 FPS").arg(params->getSentFramerate()));
|
||||
statsList << createStat(tr("callStatsReceivedFramerate"), QStringLiteral("%1 FPS").arg(params->getReceivedFramerate()));
|
||||
statsList << createStat(tr("callStatsSentFramerate"), QStringLiteral("%1 FPS").arg(params->getSentFramerate()));
|
||||
} break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ public:
|
|||
CallStatusOutgoing,
|
||||
CallStatusPaused
|
||||
};
|
||||
|
||||
Q_ENUM(CallStatus);
|
||||
|
||||
enum CallEncryption {
|
||||
|
|
@ -83,7 +82,6 @@ public:
|
|||
CallEncryptionSrtp = linphone::MediaEncryptionSRTP,
|
||||
CallEncryptionZrtp = linphone::MediaEncryptionZRTP
|
||||
};
|
||||
|
||||
Q_ENUM(CallEncryption);
|
||||
|
||||
CallModel (std::shared_ptr<linphone::Call> call);
|
||||
|
|
|
|||
|
|
@ -21,22 +21,25 @@
|
|||
*/
|
||||
|
||||
#include <QTimer>
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../conference/ConferenceAddModel.hpp"
|
||||
#include "../conference/ConferenceHelperModel.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "app/App.hpp"
|
||||
#include "components/call/CallModel.hpp"
|
||||
#include "components/conference/ConferenceAddModel.hpp"
|
||||
#include "components/conference/ConferenceHelperModel.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "CallsListModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
/* Delay before removing call in ms. */
|
||||
constexpr int cDelayBeforeRemoveCall = 3000;
|
||||
// Delay before removing call in ms.
|
||||
constexpr int DelayBeforeRemoveCall = 3000;
|
||||
}
|
||||
|
||||
static inline int findCallIndex (QList<CallModel *> &list, const shared_ptr<linphone::Call> &call) {
|
||||
|
|
@ -96,7 +99,7 @@ void CallsListModel::askForTransfer (CallModel *callModel) {
|
|||
void CallsListModel::launchAudioCall (const QString &sipAddress, const QHash<QString, QString> &headers) const {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::appStringToCoreString(sipAddress));
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(Utils::appStringToCoreString(sipAddress));
|
||||
if (!address)
|
||||
return;
|
||||
|
||||
|
|
@ -107,7 +110,7 @@ void CallsListModel::launchAudioCall (const QString &sipAddress, const QHash<QSt
|
|||
QHashIterator<QString, QString> iterator(headers);
|
||||
while (iterator.hasNext()) {
|
||||
iterator.next();
|
||||
params->addCustomHeader(::Utils::appStringToCoreString(iterator.key()), ::Utils::appStringToCoreString(iterator.value()));
|
||||
params->addCustomHeader(Utils::appStringToCoreString(iterator.key()), Utils::appStringToCoreString(iterator.value()));
|
||||
}
|
||||
|
||||
core->inviteAddressWithParams(address, params);
|
||||
|
|
@ -121,7 +124,7 @@ void CallsListModel::launchVideoCall (const QString &sipAddress) const {
|
|||
return;
|
||||
}
|
||||
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(::Utils::appStringToCoreString(sipAddress));
|
||||
shared_ptr<linphone::Address> address = core->interpretUrl(Utils::appStringToCoreString(sipAddress));
|
||||
if (!address)
|
||||
return;
|
||||
|
||||
|
|
@ -156,9 +159,9 @@ static void joinConference (const shared_ptr<linphone::Call> &call) {
|
|||
}
|
||||
|
||||
shared_ptr<linphone::Conference> conference = core->getConference();
|
||||
const QString conferenceId = ::Utils::coreStringToAppString(call->getToHeader("conference-id"));
|
||||
const QString conferenceId = Utils::coreStringToAppString(call->getToHeader("conference-id"));
|
||||
|
||||
if (conference->getId() != ::Utils::appStringToCoreString(conferenceId)) {
|
||||
if (conference->getId() != Utils::appStringToCoreString(conferenceId)) {
|
||||
qWarning() << QStringLiteral("Trying to join conference with an invalid conference id: `%1`. Responding as a simple call...")
|
||||
.arg(conferenceId);
|
||||
return;
|
||||
|
|
@ -178,7 +181,7 @@ void CallsListModel::handleCallStateChanged (const shared_ptr<linphone::Call> &c
|
|||
switch (state) {
|
||||
case linphone::CallStateIncomingReceived:
|
||||
addCall(call);
|
||||
::joinConference(call);
|
||||
joinConference(call);
|
||||
break;
|
||||
|
||||
case linphone::CallStateOutgoingInit:
|
||||
|
|
@ -191,7 +194,7 @@ void CallsListModel::handleCallStateChanged (const shared_ptr<linphone::Call> &c
|
|||
break;
|
||||
|
||||
case linphone::CallStateStreamsRunning: {
|
||||
int index = ::findCallIndex(mList, call);
|
||||
int index = findCallIndex(mList, call);
|
||||
emit callRunning(index, &call->getData<CallModel>("call-model"));
|
||||
} break;
|
||||
|
||||
|
|
@ -232,9 +235,9 @@ void CallsListModel::addCall (const shared_ptr<linphone::Call> &call) {
|
|||
|
||||
// This connection is (only) useful for `CallsListProxyModel`.
|
||||
QObject::connect(callModel, &CallModel::isInConferenceChanged, this, [this, callModel](bool) {
|
||||
int id = ::findCallIndex(mList, *callModel);
|
||||
emit dataChanged(index(id, 0), index(id, 0));
|
||||
});
|
||||
int id = findCallIndex(mList, *callModel);
|
||||
emit dataChanged(index(id, 0), index(id, 0));
|
||||
});
|
||||
|
||||
int row = mList.count();
|
||||
|
||||
|
|
@ -255,7 +258,7 @@ void CallsListModel::removeCall (const shared_ptr<linphone::Call> &call) {
|
|||
return;
|
||||
}
|
||||
|
||||
QTimer::singleShot(cDelayBeforeRemoveCall, this, [this, callModel] {
|
||||
QTimer::singleShot(DelayBeforeRemoveCall, this, [this, callModel] {
|
||||
removeCallCb(callModel);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,12 @@
|
|||
#ifndef CALLS_LIST_MODEL_H_
|
||||
#define CALLS_LIST_MODEL_H_
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "../call/CallModel.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class CallModel;
|
||||
class CoreHandlers;
|
||||
|
||||
class CallsListModel : public QAbstractListModel {
|
||||
|
|
@ -36,7 +36,6 @@ class CallsListModel : public QAbstractListModel {
|
|||
|
||||
public:
|
||||
CallsListModel (QObject *parent = Q_NULLPTR);
|
||||
~CallsListModel () = default;
|
||||
|
||||
int rowCount (const QModelIndex &index = QModelIndex()) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,20 +20,22 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/call/CallModel.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
|
||||
#include "CallsListModel.hpp"
|
||||
#include "CallsListProxyModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
CallsListProxyModel::CallsListProxyModel (QObject *parent) : QSortFilterProxyModel(parent) {
|
||||
CallsListModel *callsListModel = CoreManager::getInstance()->getCallsListModel();
|
||||
|
||||
QObject::connect(callsListModel, &CallsListModel::callRunning, this, [this](int index, CallModel *callModel) {
|
||||
emit callRunning(index, callModel);
|
||||
});
|
||||
emit callRunning(index, callModel);
|
||||
});
|
||||
|
||||
setSourceModel(callsListModel);
|
||||
sort(0);
|
||||
|
|
|
|||
|
|
@ -25,16 +25,15 @@
|
|||
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include "../call/CallModel.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class CallModel;
|
||||
|
||||
class CallsListProxyModel : public QSortFilterProxyModel {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
CallsListProxyModel (QObject *parent = Q_NULLPTR);
|
||||
~CallsListProxyModel () = default;
|
||||
|
||||
signals:
|
||||
void callRunning (int index, CallModel *callModel);
|
||||
|
|
|
|||
|
|
@ -25,17 +25,18 @@
|
|||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/call/CallModel.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "MSFunctions.hpp"
|
||||
|
||||
#include "Camera.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr int cMaxFps = 30;
|
||||
constexpr int MaxFps = 30;
|
||||
}
|
||||
|
||||
struct ContextInfo {
|
||||
|
|
@ -186,7 +187,7 @@ Camera::Camera (QQuickItem *parent) : QQuickFramebufferObject(parent) {
|
|||
setMirrorVertically(true);
|
||||
|
||||
mRefreshTimer = new QTimer(this);
|
||||
mRefreshTimer->setInterval(1000 / cMaxFps);
|
||||
mRefreshTimer->setInterval(1000 / MaxFps);
|
||||
|
||||
QObject::connect(
|
||||
mRefreshTimer, &QTimer::timeout,
|
||||
|
|
|
|||
|
|
@ -29,13 +29,13 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
class CallModel;
|
||||
struct ContextInfo;
|
||||
|
||||
namespace linphone {
|
||||
class Call;
|
||||
}
|
||||
|
||||
class CallModel;
|
||||
struct ContextInfo;
|
||||
|
||||
class CameraRenderer : public QQuickFramebufferObject::Renderer {
|
||||
public:
|
||||
CameraRenderer ();
|
||||
|
|
@ -72,7 +72,6 @@ class Camera : public QQuickFramebufferObject {
|
|||
|
||||
public:
|
||||
Camera (QQuickItem *parent = Q_NULLPTR);
|
||||
~Camera () = default;
|
||||
|
||||
QQuickFramebufferObject::Renderer *createRenderer () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,17 +25,17 @@
|
|||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "MSFunctions.hpp"
|
||||
|
||||
#include "CameraPreview.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr int cMaxFps = 30;
|
||||
constexpr int MaxFps = 30;
|
||||
}
|
||||
|
||||
struct ContextInfo {
|
||||
|
|
@ -130,7 +130,7 @@ void CameraPreviewRenderer::updateWindowId () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QMutex CameraPreview::mCounterMutex;
|
||||
int CameraPreview::mCounter = 0;
|
||||
int CameraPreview::mCounter;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ CameraPreview::CameraPreview (QQuickItem *parent) : QQuickFramebufferObject(pare
|
|||
setMirrorVertically(true);
|
||||
|
||||
mRefreshTimer = new QTimer(this);
|
||||
mRefreshTimer->setInterval(1000 / cMaxFps);
|
||||
mRefreshTimer->setInterval(1000 / MaxFps);
|
||||
|
||||
QObject::connect(
|
||||
mRefreshTimer, &QTimer::timeout,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
// =============================================================================
|
||||
|
||||
MSFunctions *MSFunctions::mInstance = nullptr;
|
||||
MSFunctions *MSFunctions::mInstance;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -25,59 +25,59 @@
|
|||
#include <QDateTime>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileInfo>
|
||||
#include <QMimeDatabase>
|
||||
#include <QTimer>
|
||||
#include <QUuid>
|
||||
#include <QMimeDatabase>
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include "../../app/paths/Paths.hpp"
|
||||
#include "../../app/providers/ThumbnailProvider.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../../utils/QExifImageHeader.h"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "app/App.hpp"
|
||||
#include "app/paths/Paths.hpp"
|
||||
#include "app/providers/ThumbnailProvider.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/notifier/Notifier.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "utils/QExifImageHeader.h"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "ChatModel.hpp"
|
||||
|
||||
#define THUMBNAIL_IMAGE_FILE_HEIGHT 100
|
||||
#define THUMBNAIL_IMAGE_FILE_WIDTH 100
|
||||
|
||||
// Not enabled by default.
|
||||
#ifndef LIMIT_FILE_SIZE
|
||||
#define LIMIT_FILE_SIZE 0
|
||||
#endif
|
||||
|
||||
// In Bytes. (500)
|
||||
#define FILE_SIZE_LIMIT 524288000
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
namespace {
|
||||
constexpr int ThumbnailImageFileWidth = 100;
|
||||
constexpr int ThumbnailImageFileHeight = 100;
|
||||
|
||||
// In Bytes.
|
||||
constexpr qint64 FileSizeLimit = 524288000;
|
||||
}
|
||||
|
||||
static inline QString getFileId (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
return ::Utils::coreStringToAppString(message->getAppdata()).section(':', 0, 0);
|
||||
return Utils::coreStringToAppString(message->getAppdata()).section(':', 0, 0);
|
||||
}
|
||||
|
||||
static inline QString getDownloadPath (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
return ::Utils::coreStringToAppString(message->getAppdata()).section(':', 1);
|
||||
return Utils::coreStringToAppString(message->getAppdata()).section(':', 1);
|
||||
}
|
||||
|
||||
static inline bool fileWasDownloaded (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
const QString path = ::getDownloadPath(message);
|
||||
const QString path = getDownloadPath(message);
|
||||
return !path.isEmpty() && QFileInfo(path).isFile();
|
||||
}
|
||||
|
||||
static inline void fillThumbnailProperty (QVariantMap &dest, const shared_ptr<linphone::ChatMessage> &message) {
|
||||
QString fileId = ::getFileId(message);
|
||||
QString fileId = getFileId(message);
|
||||
if (!fileId.isEmpty() && !dest.contains("thumbnail"))
|
||||
dest["thumbnail"] = QStringLiteral("image://%1/%2")
|
||||
.arg(ThumbnailProvider::PROVIDER_ID).arg(fileId);
|
||||
.arg(ThumbnailProvider::ProviderId).arg(fileId);
|
||||
}
|
||||
|
||||
static inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
if (!message->getAppdata().empty())
|
||||
return;
|
||||
|
||||
QString thumbnailPath = ::Utils::coreStringToAppString(message->getFileTransferFilepath());
|
||||
QString thumbnailPath = Utils::coreStringToAppString(message->getFileTransferFilepath());
|
||||
QImage image(thumbnailPath);
|
||||
if (image.isNull())
|
||||
return;
|
||||
|
|
@ -88,9 +88,9 @@ static inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &mes
|
|||
rotation = int(exifImageHeader.value(QExifImageHeader::ImageTag::Orientation).toShort());
|
||||
|
||||
QImage thumbnail = image.scaled(
|
||||
THUMBNAIL_IMAGE_FILE_WIDTH, THUMBNAIL_IMAGE_FILE_HEIGHT,
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation
|
||||
);
|
||||
ThumbnailImageFileWidth, ThumbnailImageFileHeight,
|
||||
Qt::KeepAspectRatio, Qt::SmoothTransformation
|
||||
);
|
||||
|
||||
if (rotation != 0) {
|
||||
QTransform transform;
|
||||
|
|
@ -109,12 +109,12 @@ static inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &mes
|
|||
QString uuid = QUuid::createUuid().toString();
|
||||
QString fileId = QStringLiteral("%1.jpg").arg(uuid.mid(1, uuid.length() - 2));
|
||||
|
||||
if (!thumbnail.save(::Utils::coreStringToAppString(Paths::getThumbnailsDirPath()) + fileId, "jpg", 100)) {
|
||||
if (!thumbnail.save(Utils::coreStringToAppString(Paths::getThumbnailsDirPath()) + fileId, "jpg", 100)) {
|
||||
qWarning() << QStringLiteral("Unable to create thumbnail of: `%1`.").arg(thumbnailPath);
|
||||
return;
|
||||
}
|
||||
|
||||
message->setAppdata(::Utils::appStringToCoreString(fileId));
|
||||
message->setAppdata(Utils::appStringToCoreString(fileId));
|
||||
}
|
||||
|
||||
static inline void removeFileMessageThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
|
|
@ -123,7 +123,7 @@ static inline void removeFileMessageThumbnail (const shared_ptr<linphone::ChatMe
|
|||
|
||||
string fileId = message->getAppdata();
|
||||
if (!fileId.empty()) {
|
||||
QString thumbnailPath = ::Utils::coreStringToAppString(Paths::getThumbnailsDirPath() + fileId);
|
||||
QString thumbnailPath = Utils::coreStringToAppString(Paths::getThumbnailsDirPath() + fileId);
|
||||
if (!QFile::remove(thumbnailPath))
|
||||
qWarning() << QStringLiteral("Unable to remove `%1`.").arg(thumbnailPath);
|
||||
}
|
||||
|
|
@ -138,8 +138,6 @@ class ChatModel::MessageHandlers : public linphone::ChatMessageListener {
|
|||
public:
|
||||
MessageHandlers (ChatModel *chatModel) : mChatModel(chatModel) {}
|
||||
|
||||
~MessageHandlers () = default;
|
||||
|
||||
private:
|
||||
QList<ChatEntryData>::iterator findMessageEntry (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
return find_if(mChatModel->mEntries.begin(), mChatModel->mEntries.end(), [&message](const ChatEntryData &pair) {
|
||||
|
|
@ -190,11 +188,11 @@ private:
|
|||
|
||||
// File message downloaded.
|
||||
if (state == linphone::ChatMessageStateFileTransferDone && !message->isOutgoing()) {
|
||||
::createThumbnail(message);
|
||||
::fillThumbnailProperty((*it).first, message);
|
||||
createThumbnail(message);
|
||||
fillThumbnailProperty((*it).first, message);
|
||||
|
||||
message->setAppdata(
|
||||
::Utils::appStringToCoreString(::getFileId(message)) + ':' + message->getFileTransferFilepath()
|
||||
Utils::appStringToCoreString(getFileId(message)) + ':' + message->getFileTransferFilepath()
|
||||
);
|
||||
(*it).first["wasDownloaded"] = true;
|
||||
|
||||
|
|
@ -284,7 +282,7 @@ bool ChatModel::removeRows (int row, int count, const QModelIndex &parent) {
|
|||
}
|
||||
|
||||
QString ChatModel::getSipAddress () const {
|
||||
return ::Utils::coreStringToAppString(
|
||||
return Utils::coreStringToAppString(
|
||||
mChatRoom->getPeerAddress()->asStringUriOnly()
|
||||
);
|
||||
}
|
||||
|
|
@ -292,7 +290,7 @@ QString ChatModel::getSipAddress () const {
|
|||
void ChatModel::setSipAddress (const QString &sipAddress) {
|
||||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
|
||||
mChatRoom = core->getChatRoomFromUri(::Utils::appStringToCoreString(sipAddress));
|
||||
mChatRoom = core->getChatRoomFromUri(Utils::appStringToCoreString(sipAddress));
|
||||
Q_CHECK_PTR(mChatRoom.get());
|
||||
|
||||
handleIsComposingChanged(mChatRoom);
|
||||
|
|
@ -348,7 +346,7 @@ void ChatModel::removeAllEntries () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ChatModel::sendMessage (const QString &message) {
|
||||
shared_ptr<linphone::ChatMessage> _message = mChatRoom->createMessage(::Utils::appStringToCoreString(message));
|
||||
shared_ptr<linphone::ChatMessage> _message = mChatRoom->createMessage(Utils::appStringToCoreString(message));
|
||||
_message->setListener(mMessageHandlers);
|
||||
|
||||
insertMessageAtEnd(_message);
|
||||
|
|
@ -392,13 +390,10 @@ void ChatModel::sendFileMessage (const QString &path) {
|
|||
return;
|
||||
|
||||
qint64 fileSize = file.size();
|
||||
|
||||
#if LIMIT_FILE_SIZE
|
||||
if (fileSize > FILE_SIZE_LIMIT) {
|
||||
qWarning() << QStringLiteral("Unable to send file. (Size limit=%1)").arg(FILE_SIZE_LIMIT);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
if (fileSize > FileSizeLimit) {
|
||||
qWarning() << QStringLiteral("Unable to send file. (Size limit=%1)").arg(FileSizeLimit);
|
||||
return;
|
||||
}
|
||||
|
||||
shared_ptr<linphone::Content> content = CoreManager::getInstance()->getCore()->createContent();
|
||||
{
|
||||
|
|
@ -407,18 +402,18 @@ void ChatModel::sendFileMessage (const QString &path) {
|
|||
qWarning() << QStringLiteral("Unable to get supported mime type for: `%1`.").arg(path);
|
||||
return;
|
||||
}
|
||||
content->setType(::Utils::appStringToCoreString(mimeType[0]));
|
||||
content->setSubtype(::Utils::appStringToCoreString(mimeType[1]));
|
||||
content->setType(Utils::appStringToCoreString(mimeType[0]));
|
||||
content->setSubtype(Utils::appStringToCoreString(mimeType[1]));
|
||||
}
|
||||
|
||||
content->setSize(size_t(fileSize));
|
||||
content->setName(::Utils::appStringToCoreString(QFileInfo(file).fileName()));
|
||||
content->setName(Utils::appStringToCoreString(QFileInfo(file).fileName()));
|
||||
|
||||
shared_ptr<linphone::ChatMessage> message = mChatRoom->createFileTransferMessage(content);
|
||||
message->setFileTransferFilepath(::Utils::appStringToCoreString(path));
|
||||
message->setFileTransferFilepath(Utils::appStringToCoreString(path));
|
||||
message->setListener(mMessageHandlers);
|
||||
|
||||
::createThumbnail(message);
|
||||
createThumbnail(message);
|
||||
|
||||
insertMessageAtEnd(message);
|
||||
mChatRoom->sendChatMessage(message);
|
||||
|
|
@ -448,7 +443,7 @@ void ChatModel::downloadFile (int id) {
|
|||
}
|
||||
|
||||
bool soFarSoGood;
|
||||
const QString safeFilePath = ::Utils::getSafeFilePath(
|
||||
const QString safeFilePath = Utils::getSafeFilePath(
|
||||
QStringLiteral("%1%2")
|
||||
.arg(CoreManager::getInstance()->getSettingsModel()->getDownloadFolder())
|
||||
.arg(entry.first["fileName"].toString()),
|
||||
|
|
@ -460,7 +455,7 @@ void ChatModel::downloadFile (int id) {
|
|||
return;
|
||||
}
|
||||
|
||||
message->setFileTransferFilepath(::Utils::appStringToCoreString(safeFilePath));
|
||||
message->setFileTransferFilepath(Utils::appStringToCoreString(safeFilePath));
|
||||
message->setListener(mMessageHandlers);
|
||||
|
||||
if (message->downloadFile() < 0)
|
||||
|
|
@ -478,7 +473,7 @@ void ChatModel::openFile (int id, bool showDirectory) {
|
|||
return;
|
||||
}
|
||||
|
||||
QFileInfo info(::getDownloadPath(message));
|
||||
QFileInfo info(getDownloadPath(message));
|
||||
QDesktopServices::openUrl(
|
||||
QUrl(QStringLiteral("file:///%1").arg(showDirectory ? info.absolutePath() : info.absoluteFilePath()))
|
||||
);
|
||||
|
|
@ -528,17 +523,17 @@ const ChatModel::ChatEntryData ChatModel::getFileMessageEntry (int id) {
|
|||
void ChatModel::fillMessageEntry (QVariantMap &dest, const shared_ptr<linphone::ChatMessage> &message) {
|
||||
dest["type"] = EntryType::MessageEntry;
|
||||
dest["timestamp"] = QDateTime::fromMSecsSinceEpoch(message->getTime() * 1000);
|
||||
dest["content"] = ::Utils::coreStringToAppString(message->getText());
|
||||
dest["content"] = Utils::coreStringToAppString(message->getText());
|
||||
dest["isOutgoing"] = message->isOutgoing() || message->getState() == linphone::ChatMessageStateIdle;
|
||||
dest["status"] = message->getState();
|
||||
|
||||
shared_ptr<const linphone::Content> content = message->getFileTransferInformation();
|
||||
if (content) {
|
||||
dest["fileSize"] = quint64(content->getSize());
|
||||
dest["fileName"] = ::Utils::coreStringToAppString(content->getName());
|
||||
dest["fileName"] = Utils::coreStringToAppString(content->getName());
|
||||
dest["wasDownloaded"] = ::fileWasDownloaded(message);
|
||||
|
||||
::fillThumbnailProperty(dest, message);
|
||||
fillThumbnailProperty(dest, message);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -570,7 +565,7 @@ void ChatModel::removeEntry (ChatEntryData &pair) {
|
|||
switch (type) {
|
||||
case ChatModel::MessageEntry: {
|
||||
shared_ptr<linphone::ChatMessage> message = static_pointer_cast<linphone::ChatMessage>(pair.second);
|
||||
::removeFileMessageThumbnail(message);
|
||||
removeFileMessageThumbnail(message);
|
||||
mChatRoom->deleteMessage(message);
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ public:
|
|||
MessageEntry,
|
||||
CallEntry
|
||||
};
|
||||
|
||||
Q_ENUM(EntryType);
|
||||
|
||||
enum CallStatus {
|
||||
|
|
@ -56,7 +55,6 @@ public:
|
|||
CallStatusMissed = linphone::CallStatusMissed,
|
||||
CallStatusSuccess = linphone::CallStatusSuccess
|
||||
};
|
||||
|
||||
Q_ENUM(CallStatus);
|
||||
|
||||
enum MessageStatus {
|
||||
|
|
@ -69,7 +67,6 @@ public:
|
|||
MessageStatusInProgress = linphone::ChatMessageStateInProgress,
|
||||
MessageStatusNotDelivered = linphone::ChatMessageStateNotDelivered
|
||||
};
|
||||
|
||||
Q_ENUM(MessageStatus);
|
||||
|
||||
ChatModel (const QString &sipAddress);
|
||||
|
|
@ -119,7 +116,7 @@ signals:
|
|||
void messagesCountReset ();
|
||||
|
||||
private:
|
||||
typedef QPair<QVariantMap, std::shared_ptr<void> > ChatEntryData;
|
||||
typedef QPair<QVariantMap, std::shared_ptr<void>> ChatEntryData;
|
||||
|
||||
void setSipAddress (const QString &sipAddress);
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
|
||||
#include "ChatProxyModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Fetch the L last filtered chat entries.
|
||||
class ChatProxyModel::ChatModelFilter : public QSortFilterProxyModel {
|
||||
public:
|
||||
|
|
@ -59,8 +59,6 @@ private:
|
|||
|
||||
// =============================================================================
|
||||
|
||||
const int ChatProxyModel::ENTRIES_CHUNK_SIZE = 50;
|
||||
|
||||
ChatProxyModel::ChatProxyModel (QObject *parent) : QSortFilterProxyModel(parent) {
|
||||
setSourceModel(new ChatModelFilter(this));
|
||||
}
|
||||
|
|
@ -117,7 +115,7 @@ void ChatProxyModel::loadMoreEntries () {
|
|||
// Do not increase `mMaxDisplayedEntries` if it's not necessary...
|
||||
// Limit qml calls.
|
||||
if (count == mMaxDisplayedEntries)
|
||||
mMaxDisplayedEntries += ENTRIES_CHUNK_SIZE;
|
||||
mMaxDisplayedEntries += EntriesChunkSize;
|
||||
|
||||
invalidateFilter();
|
||||
|
||||
|
|
@ -149,7 +147,7 @@ QString ChatProxyModel::getSipAddress () const {
|
|||
}
|
||||
|
||||
void ChatProxyModel::setSipAddress (const QString &sipAddress) {
|
||||
mMaxDisplayedEntries = ENTRIES_CHUNK_SIZE;
|
||||
mMaxDisplayedEntries = EntriesChunkSize;
|
||||
|
||||
if (mChatModel) {
|
||||
ChatModel *chatModel = mChatModel.get();
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ private:
|
|||
void handleMessageReceived (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
void handleMessageSent (const std::shared_ptr<linphone::ChatMessage> &message);
|
||||
|
||||
int mMaxDisplayedEntries = ENTRIES_CHUNK_SIZE;
|
||||
int mMaxDisplayedEntries = EntriesChunkSize;
|
||||
|
||||
std::shared_ptr<ChatModel> mChatModel;
|
||||
|
||||
static const int ENTRIES_CHUNK_SIZE;
|
||||
static constexpr int EntriesChunkSize = 50;
|
||||
};
|
||||
|
||||
#endif // CHAT_PROXY_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -40,7 +40,6 @@ class AbstractCodecsModel : public QAbstractListModel {
|
|||
|
||||
public:
|
||||
AbstractCodecsModel (QObject *parent = Q_NULLPTR);
|
||||
virtual ~AbstractCodecsModel () = default;
|
||||
|
||||
int rowCount (const QModelIndex &index = QModelIndex()) const override;
|
||||
|
||||
|
|
@ -81,6 +80,6 @@ protected:
|
|||
QList<QVariantMap> mCodecs;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::PayloadType> );
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::PayloadType>);
|
||||
|
||||
#endif // ABSTRACT_CODECS_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
|
||||
#include "AudioCodecsModel.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -37,23 +37,23 @@
|
|||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr char cH264Description[] = "Provided by CISCO SYSTEM,INC";
|
||||
constexpr char H264Description[] = "Provided by CISCO SYSTEM,INC";
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
constexpr char cLibraryExtension[] = "so";
|
||||
constexpr char cH264InstallName[] = "libopenh264.so";
|
||||
constexpr char LibraryExtension[] = "so";
|
||||
constexpr char H264InstallName[] = "libopenh264.so";
|
||||
#ifdef Q_PROCESSOR_X86_64
|
||||
constexpr char cPluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-1.7.0-linux64.4.so.bz2";
|
||||
constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-1.7.0-linux64.4.so.bz2";
|
||||
#else
|
||||
constexpr char cPluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-1.7.0-linux32.4.so.bz2";
|
||||
constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-1.7.0-linux32.4.so.bz2";
|
||||
#endif // ifdef Q_PROCESSOR_X86_64
|
||||
#elif defined(Q_OS_WIN)
|
||||
constexpr char cLibraryExtension[] = "dll";
|
||||
constexpr char cH264InstallName[] = "openh264.dll";
|
||||
constexpr char LibraryExtension[] = "dll";
|
||||
constexpr char H264InstallName[] = "openh264.dll";
|
||||
#ifdef Q_OS_WIN64
|
||||
constexpr char cPluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-1.7.0-win64.dll.bz2";
|
||||
constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-1.7.0-win64.dll.bz2";
|
||||
#else
|
||||
constexpr char cPluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-1.7.0-win32.dll.bz2";
|
||||
constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-1.7.0-win32.dll.bz2";
|
||||
#endif // ifdef Q_OS_WIN64
|
||||
#endif // ifdef Q_OS_LINUX
|
||||
}
|
||||
|
|
@ -127,7 +127,7 @@ static bool downloadUpdatableCodec (
|
|||
|
||||
void VideoCodecsModel::updateCodecs () {
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
|
||||
static const QString codecSuffix = QStringLiteral(".%1").arg(cLibraryExtension);
|
||||
static const QString codecSuffix = QStringLiteral(".%1").arg(LibraryExtension);
|
||||
|
||||
QDirIterator it(Utils::coreStringToAppString(Paths::getCodecsDirPath()));
|
||||
while (it.hasNext()) {
|
||||
|
|
@ -147,7 +147,7 @@ void VideoCodecsModel::updateCodecs () {
|
|||
void VideoCodecsModel::downloadUpdatableCodecs (QObject *parent) {
|
||||
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
|
||||
QString codecsFolder = Utils::coreStringToAppString(Paths::getCodecsDirPath());
|
||||
downloadUpdatableCodec(parent, codecsFolder, "H264", cPluginUrlH264, cH264InstallName);
|
||||
downloadUpdatableCodec(parent, codecsFolder, "H264", PluginUrlH264, H264InstallName);
|
||||
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +165,7 @@ void VideoCodecsModel::load () {
|
|||
QDirIterator it(Utils::coreStringToAppString(Paths::getCodecsDirPath()));
|
||||
while (it.hasNext()) {
|
||||
QFileInfo info(it.next());
|
||||
if (info.suffix() == cLibraryExtension)
|
||||
if (info.suffix() == LibraryExtension)
|
||||
QLibrary(info.filePath()).load();
|
||||
}
|
||||
core->reloadMsPlugins("");
|
||||
|
|
@ -181,7 +181,7 @@ void VideoCodecsModel::load () {
|
|||
if (find_if(codecs.begin(), codecs.end(), [](const shared_ptr<linphone::PayloadType> &codec) {
|
||||
return codec->getMimeType() == "H264";
|
||||
}) == codecs.end())
|
||||
addDownloadableCodec("H264", cH264Description, cPluginUrlH264, cH264InstallName);
|
||||
addDownloadableCodec("H264", H264Description, PluginUrlH264, H264InstallName);
|
||||
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,15 +20,16 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/sip-addresses/SipAddressesModel.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "ConferenceAddModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
ConferenceHelperModel::ConferenceAddModel::ConferenceAddModel (QObject *parent) : QAbstractListModel(parent) {
|
||||
mConferenceHelperModel = qobject_cast<ConferenceHelperModel *>(parent);
|
||||
Q_CHECK_PTR(mConferenceHelperModel);
|
||||
|
|
@ -71,7 +72,7 @@ QVariant ConferenceHelperModel::ConferenceAddModel::data (const QModelIndex &ind
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool ConferenceHelperModel::ConferenceAddModel::addToConference (const shared_ptr<const linphone::Address> &linphoneAddress) {
|
||||
const QString sipAddress = ::Utils::coreStringToAppString(linphoneAddress->asStringUriOnly());
|
||||
const QString sipAddress = Utils::coreStringToAppString(linphoneAddress->asStringUriOnly());
|
||||
if (mSipAddresses.contains(sipAddress))
|
||||
return false;
|
||||
|
||||
|
|
@ -91,8 +92,8 @@ bool ConferenceHelperModel::ConferenceAddModel::addToConference (const QString &
|
|||
return false;
|
||||
|
||||
shared_ptr<linphone::Address> address = CoreManager::getInstance()->getCore()->interpretUrl(
|
||||
::Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
if (!address)
|
||||
return false;
|
||||
|
||||
|
|
@ -133,9 +134,9 @@ bool ConferenceHelperModel::ConferenceAddModel::removeFromConference (const QStr
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ConferenceHelperModel::ConferenceAddModel::update () {
|
||||
list<shared_ptr<linphone::Address> > linphoneAddresses;
|
||||
list<shared_ptr<linphone::Address>> linphoneAddresses;
|
||||
for (const auto &map : mRefs) {
|
||||
shared_ptr<linphone::Address> linphoneAddress = map->value("__linphoneAddress").value<shared_ptr<linphone::Address> >();
|
||||
shared_ptr<linphone::Address> linphoneAddress = map->value("__linphoneAddress").value<shared_ptr<linphone::Address>>();
|
||||
Q_CHECK_PTR(linphoneAddress);
|
||||
linphoneAddresses.push_back(linphoneAddress);
|
||||
}
|
||||
|
|
@ -147,7 +148,7 @@ void ConferenceHelperModel::ConferenceAddModel::update () {
|
|||
if (!call->getParams()->getLocalConferenceMode())
|
||||
continue;
|
||||
|
||||
const QString sipAddress = ::Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly());
|
||||
const QString sipAddress = Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly());
|
||||
if (!mSipAddresses.contains(sipAddress))
|
||||
call->terminate();
|
||||
}
|
||||
|
|
@ -161,7 +162,7 @@ void ConferenceHelperModel::ConferenceAddModel::update () {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
void ConferenceHelperModel::ConferenceAddModel::addToConferencePrivate (const shared_ptr<linphone::Address> &linphoneAddress) {
|
||||
QString sipAddress = ::Utils::coreStringToAppString(linphoneAddress->asStringUriOnly());
|
||||
QString sipAddress = Utils::coreStringToAppString(linphoneAddress->asStringUriOnly());
|
||||
QVariantMap map = CoreManager::getInstance()->getSipAddressesModel()->find(sipAddress);
|
||||
|
||||
map["sipAddress"] = sipAddress;
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ class ConferenceHelperModel::ConferenceAddModel : public QAbstractListModel {
|
|||
|
||||
public:
|
||||
ConferenceAddModel (QObject *parent = Q_NULLPTR);
|
||||
~ConferenceAddModel () = default;
|
||||
|
||||
int rowCount (const QModelIndex &index = QModelIndex()) const override;
|
||||
|
||||
|
|
@ -71,6 +70,6 @@ private:
|
|||
ConferenceHelperModel *mConferenceHelperModel = nullptr;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::Address> );
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::Address>);
|
||||
|
||||
#endif // CONFERENCE_ADD_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -20,18 +20,21 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "../sip-addresses/SipAddressesProxyModel.hpp"
|
||||
#include "ConferenceAddModel.hpp"
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
#include "app/App.hpp"
|
||||
#include "components/calls/CallsListModel.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/sip-addresses/SipAddressesProxyModel.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "ConferenceAddModel.hpp"
|
||||
#include "ConferenceHelperModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
ConferenceHelperModel::ConferenceHelperModel (QObject *parent) : QSortFilterProxyModel(parent) {
|
||||
mCore = CoreManager::getInstance()->getCore();
|
||||
mConference = mCore->getConference();
|
||||
|
|
@ -77,11 +80,11 @@ bool ConferenceHelperModel::filterAcceptsRow (int sourceRow, const QModelIndex &
|
|||
|
||||
bool ConferenceHelperModel::lessThan (const QModelIndex &left, const QModelIndex &right) const {
|
||||
shared_ptr<linphone::Call> callA = mCore->findCallFromUri(
|
||||
::Utils::appStringToCoreString(left.data().toMap()["sipAddress"].toString())
|
||||
);
|
||||
Utils::appStringToCoreString(left.data().toMap()["sipAddress"].toString())
|
||||
);
|
||||
shared_ptr<linphone::Call> callB = mCore->findCallFromUri(
|
||||
::Utils::appStringToCoreString(right.data().toMap()["sipAddress"].toString())
|
||||
);
|
||||
Utils::appStringToCoreString(right.data().toMap()["sipAddress"].toString())
|
||||
);
|
||||
|
||||
return callA && !callB;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@
|
|||
// Can filter the sip addresses with a pattern.
|
||||
// =============================================================================
|
||||
|
||||
class CallModel;
|
||||
|
||||
namespace linphone {
|
||||
class Conference;
|
||||
class Core;
|
||||
class Conference;
|
||||
class Core;
|
||||
}
|
||||
|
||||
class CallModel;
|
||||
|
||||
class ConferenceHelperModel : public QSortFilterProxyModel {
|
||||
Q_OBJECT;
|
||||
|
||||
|
|
@ -48,7 +48,6 @@ public:
|
|||
class ConferenceAddModel;
|
||||
|
||||
ConferenceHelperModel (QObject *parent = Q_NULLPTR);
|
||||
~ConferenceHelperModel () = default;
|
||||
|
||||
QHash<int, QByteArray> roleNames () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,16 +22,20 @@
|
|||
|
||||
#include <QDateTime>
|
||||
|
||||
#include "../../utils/LinphoneUtils.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/call/CallModel.hpp"
|
||||
#include "components/calls/CallsListModel.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "utils/LinphoneUtils.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "ConferenceModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
ConferenceModel::ConferenceModel (QObject *parent) : QSortFilterProxyModel(parent) {
|
||||
QObject::connect(this, &ConferenceModel::rowsRemoved, [this] {
|
||||
emit countChanged(rowCount());
|
||||
|
|
@ -77,7 +81,7 @@ void ConferenceModel::startRecording () {
|
|||
|
||||
CoreManager *coreManager = CoreManager::getInstance();
|
||||
coreManager->getCore()->startConferenceRecording(
|
||||
::Utils::appStringToCoreString(
|
||||
Utils::appStringToCoreString(
|
||||
QStringLiteral("%1%2.mkv")
|
||||
.arg(coreManager->getSettingsModel()->getSavedVideosFolder())
|
||||
.arg(QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm-ss"))
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ class ConferenceModel : public QSortFilterProxyModel {
|
|||
|
||||
public:
|
||||
ConferenceModel (QObject *parent = Q_NULLPTR);
|
||||
~ConferenceModel () = default;
|
||||
|
||||
protected:
|
||||
bool filterAcceptsRow (int sourceRow, const QModelIndex &sourceParent) const override;
|
||||
|
|
|
|||
|
|
@ -20,14 +20,17 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
#include "app/App.hpp"
|
||||
|
||||
#include "ContactModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
#include "VcardModel.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
ContactModel::ContactModel (QObject *parent, shared_ptr<linphone::Friend> linphoneFriend) : QObject(parent) {
|
||||
Q_CHECK_PTR(linphoneFriend);
|
||||
|
||||
|
|
@ -53,8 +56,8 @@ ContactModel::ContactModel (QObject *parent, VcardModel *vcardModel) : QObject(p
|
|||
|
||||
void ContactModel::refreshPresence () {
|
||||
Presence::PresenceStatus status = static_cast<Presence::PresenceStatus>(
|
||||
mLinphoneFriend->getConsolidatedPresence()
|
||||
);
|
||||
mLinphoneFriend->getConsolidatedPresence()
|
||||
);
|
||||
|
||||
emit presenceStatusChanged(status);
|
||||
emit presenceLevelChanged(Presence::getPresenceLevel(status));
|
||||
|
|
@ -160,7 +163,7 @@ void ContactModel::mergeVcardModel (VcardModel *vcardModel) {
|
|||
const QVariantMap oldAddress = vcardModel->getAddress();
|
||||
QVariantMap newAddress = vcardModel->getAddress();
|
||||
|
||||
static const char *attributes[4] = { "street", "locality", "postalCode", "country" };
|
||||
constexpr const char *attributes[4] = { "street", "locality", "postalCode", "country" };
|
||||
bool needMerge = true;
|
||||
|
||||
for (const auto &attribute : attributes)
|
||||
|
|
|
|||
|
|
@ -23,27 +23,27 @@
|
|||
#ifndef CONTACT_MODEL_H_
|
||||
#define CONTACT_MODEL_H_
|
||||
|
||||
#include "../presence/Presence.hpp"
|
||||
#include "VcardModel.hpp"
|
||||
#include "components/presence/Presence.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class VcardModel;
|
||||
|
||||
class ContactModel : public QObject {
|
||||
// Grant access to `mLinphoneFriend`.
|
||||
friend class ContactsListModel;
|
||||
friend class ContactsListProxyModel;
|
||||
friend class SipAddressesProxyModel;
|
||||
|
||||
Q_OBJECT;
|
||||
|
||||
Q_PROPERTY(Presence::PresenceStatus presenceStatus READ getPresenceStatus NOTIFY presenceStatusChanged);
|
||||
Q_PROPERTY(Presence::PresenceLevel presenceLevel READ getPresenceLevel NOTIFY presenceLevelChanged);
|
||||
Q_PROPERTY(VcardModel * vcard READ getVcardModel WRITE setVcardModel NOTIFY contactUpdated);
|
||||
|
||||
// Grant access to `mLinphoneFriend`.
|
||||
friend class ContactsListModel;
|
||||
friend class ContactsListProxyModel;
|
||||
friend class SipAddressesProxyModel;
|
||||
|
||||
public:
|
||||
ContactModel (QObject *parent, std::shared_ptr<linphone::Friend> linphoneFriend);
|
||||
ContactModel (QObject *parent, VcardModel *vcardModel);
|
||||
~ContactModel () = default;
|
||||
|
||||
void refreshPresence ();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,43 +25,45 @@
|
|||
#include <QImageReader>
|
||||
#include <QUuid>
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include "../../app/paths/Paths.hpp"
|
||||
#include "../../app/providers/AvatarProvider.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "app/App.hpp"
|
||||
#include "app/paths/Paths.hpp"
|
||||
#include "app/providers/AvatarProvider.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/sip-addresses/SipAddressesModel.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "VcardModel.hpp"
|
||||
|
||||
#define VCARD_SCHEME "linphone-desktop:/"
|
||||
|
||||
#define CHECK_VCARD_IS_WRITABLE(VCARD) Q_ASSERT(VCARD->mIsReadOnly == false)
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
#define CHECK_VCARD_IS_WRITABLE(VCARD) Q_ASSERT(VCARD->mIsReadOnly == false)
|
||||
|
||||
namespace {
|
||||
constexpr char VcardScheme[] = "linphone-desktop:/";
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T> > &list, const string &value) {
|
||||
static inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T>> &list, const string &value) {
|
||||
auto it = find_if(list.cbegin(), list.cend(), [&value](const shared_ptr<T> &entry) {
|
||||
return value == entry->getValue();
|
||||
});
|
||||
|
||||
return value == entry->getValue();
|
||||
});
|
||||
return it != list.cend() ? *it : nullptr;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
static inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T> > &list, const QString &value) {
|
||||
return ::findBelCardValue(list, ::Utils::appStringToCoreString(value));
|
||||
static inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T>> &list, const QString &value) {
|
||||
return findBelCardValue(list, Utils::appStringToCoreString(value));
|
||||
}
|
||||
|
||||
static inline bool isLinphoneDesktopPhoto (const shared_ptr<belcard::BelCardPhoto> &photo) {
|
||||
return !photo->getValue().compare(0, sizeof(VCARD_SCHEME) - 1, VCARD_SCHEME);
|
||||
return !photo->getValue().compare(0, sizeof(VcardScheme) - 1, VcardScheme);
|
||||
}
|
||||
|
||||
static shared_ptr<belcard::BelCardPhoto> findBelcardPhoto (const shared_ptr<belcard::BelCard> &belcard) {
|
||||
const list<shared_ptr<belcard::BelCardPhoto> > &photos = belcard->getPhotos();
|
||||
auto it = find_if(photos.cbegin(), photos.cend(), ::isLinphoneDesktopPhoto);
|
||||
const list<shared_ptr<belcard::BelCardPhoto>> &photos = belcard->getPhotos();
|
||||
auto it = find_if(photos.cbegin(), photos.cend(), isLinphoneDesktopPhoto);
|
||||
if (it != photos.cend())
|
||||
return *it;
|
||||
|
||||
|
|
@ -69,16 +71,16 @@ static shared_ptr<belcard::BelCardPhoto> findBelcardPhoto (const shared_ptr<belc
|
|||
}
|
||||
|
||||
static void removeBelcardPhoto (const shared_ptr<belcard::BelCard> &belcard, bool cleanPathsOnly = false) {
|
||||
list<shared_ptr<belcard::BelCardPhoto> > photos;
|
||||
list<shared_ptr<belcard::BelCardPhoto>> photos;
|
||||
for (const auto photo : belcard->getPhotos()) {
|
||||
if (::isLinphoneDesktopPhoto(photo))
|
||||
if (isLinphoneDesktopPhoto(photo))
|
||||
photos.push_back(photo);
|
||||
}
|
||||
|
||||
for (const auto photo : photos) {
|
||||
QString imagePath(
|
||||
::Utils::coreStringToAppString(
|
||||
Paths::getAvatarsDirPath() + photo->getValue().substr(sizeof(VCARD_SCHEME) - 1)
|
||||
Utils::coreStringToAppString(
|
||||
Paths::getAvatarsDirPath() + photo->getValue().substr(sizeof(VcardScheme) - 1)
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -105,7 +107,7 @@ VcardModel::~VcardModel () {
|
|||
if (!mIsReadOnly) {
|
||||
qInfo() << QStringLiteral("Destroy detached vcard:") << this;
|
||||
if (!mAvatarIsReadOnly)
|
||||
::removeBelcardPhoto(mVcard->getVcard());
|
||||
removeBelcardPhoto(mVcard->getVcard());
|
||||
} else
|
||||
qInfo() << QStringLiteral("Destroy attached vcard:") << this;
|
||||
}
|
||||
|
|
@ -114,20 +116,20 @@ VcardModel::~VcardModel () {
|
|||
|
||||
QString VcardModel::getAvatar () const {
|
||||
// Find desktop avatar.
|
||||
shared_ptr<belcard::BelCardPhoto> photo = ::findBelcardPhoto(mVcard->getVcard());
|
||||
shared_ptr<belcard::BelCardPhoto> photo = findBelcardPhoto(mVcard->getVcard());
|
||||
|
||||
// No path found.
|
||||
if (!photo)
|
||||
return QString("");
|
||||
|
||||
// Returns right path.
|
||||
return QStringLiteral("image://%1/%2").arg(AvatarProvider::PROVIDER_ID).arg(
|
||||
::Utils::coreStringToAppString(photo->getValue().substr(sizeof(VCARD_SCHEME) - 1))
|
||||
return QStringLiteral("image://%1/%2").arg(AvatarProvider::ProviderId).arg(
|
||||
Utils::coreStringToAppString(photo->getValue().substr(sizeof(VcardScheme) - 1))
|
||||
);
|
||||
}
|
||||
|
||||
static inline QString getFileIdFromAppPath (const QString &path) {
|
||||
const static QString appPrefix = QStringLiteral("image://%1/").arg(AvatarProvider::PROVIDER_ID);
|
||||
const static QString appPrefix = QStringLiteral("image://%1/").arg(AvatarProvider::ProviderId);
|
||||
return path.mid(appPrefix.length());
|
||||
}
|
||||
|
||||
|
|
@ -142,7 +144,7 @@ bool VcardModel::setAvatar (const QString &path) {
|
|||
// not an application path like `image:`.
|
||||
if (!path.isEmpty()) {
|
||||
if (path.startsWith("image:"))
|
||||
fileId = ::getFileIdFromAppPath(path);
|
||||
fileId = getFileIdFromAppPath(path);
|
||||
else {
|
||||
file.setFileName(path);
|
||||
|
||||
|
|
@ -155,7 +157,7 @@ bool VcardModel::setAvatar (const QString &path) {
|
|||
.arg(uuid.mid(1, uuid.length() - 2)) // Remove `{}`.
|
||||
.arg(info.suffix());
|
||||
|
||||
QString dest = ::Utils::coreStringToAppString(Paths::getAvatarsDirPath()) + fileId;
|
||||
QString dest = Utils::coreStringToAppString(Paths::getAvatarsDirPath()) + fileId;
|
||||
|
||||
if (!file.copy(dest))
|
||||
return false;
|
||||
|
|
@ -165,13 +167,13 @@ bool VcardModel::setAvatar (const QString &path) {
|
|||
}
|
||||
|
||||
// 2. Remove oldest photo.
|
||||
::removeBelcardPhoto(belcard, mAvatarIsReadOnly);
|
||||
removeBelcardPhoto(belcard, mAvatarIsReadOnly);
|
||||
mAvatarIsReadOnly = false;
|
||||
|
||||
// 3. Update new photo.
|
||||
if (!path.isEmpty()) {
|
||||
shared_ptr<belcard::BelCardPhoto> photo = belcard::BelCardGeneric::create<belcard::BelCardPhoto>();
|
||||
photo->setValue(VCARD_SCHEME + ::Utils::appStringToCoreString(fileId));
|
||||
photo->setValue(VcardScheme + Utils::appStringToCoreString(fileId));
|
||||
|
||||
if (!belcard->addPhoto(photo)) {
|
||||
file.remove();
|
||||
|
|
@ -187,7 +189,7 @@ bool VcardModel::setAvatar (const QString &path) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString VcardModel::getUsername () const {
|
||||
return ::Utils::coreStringToAppString(mVcard->getFullName());
|
||||
return Utils::coreStringToAppString(mVcard->getFullName());
|
||||
}
|
||||
|
||||
void VcardModel::setUsername (const QString &username) {
|
||||
|
|
@ -196,14 +198,14 @@ void VcardModel::setUsername (const QString &username) {
|
|||
if (username.length() == 0 || username == getUsername())
|
||||
return;
|
||||
|
||||
mVcard->setFullName(::Utils::appStringToCoreString(username));
|
||||
mVcard->setFullName(Utils::appStringToCoreString(username));
|
||||
emit vcardUpdated();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
static inline shared_ptr<belcard::BelCardAddress> getOrCreateBelCardAddress (shared_ptr<belcard::BelCard> belcard) {
|
||||
list<shared_ptr<belcard::BelCardAddress> > addresses = belcard->getAddresses();
|
||||
list<shared_ptr<belcard::BelCardAddress>> addresses = belcard->getAddresses();
|
||||
shared_ptr<belcard::BelCardAddress> address;
|
||||
|
||||
if (addresses.empty()) {
|
||||
|
|
@ -217,17 +219,17 @@ static inline shared_ptr<belcard::BelCardAddress> getOrCreateBelCardAddress (sha
|
|||
}
|
||||
|
||||
QVariantMap VcardModel::getAddress () const {
|
||||
list<shared_ptr<belcard::BelCardAddress> > addresses = mVcard->getVcard()->getAddresses();
|
||||
list<shared_ptr<belcard::BelCardAddress>> addresses = mVcard->getVcard()->getAddresses();
|
||||
QVariantMap map;
|
||||
|
||||
if (addresses.empty())
|
||||
return map;
|
||||
|
||||
shared_ptr<belcard::BelCardAddress> address = addresses.front();
|
||||
map["street"] = ::Utils::coreStringToAppString(address->getStreet());
|
||||
map["locality"] = ::Utils::coreStringToAppString(address->getLocality());
|
||||
map["postalCode"] = ::Utils::coreStringToAppString(address->getPostalCode());
|
||||
map["country"] = ::Utils::coreStringToAppString(address->getCountry());
|
||||
map["street"] = Utils::coreStringToAppString(address->getStreet());
|
||||
map["locality"] = Utils::coreStringToAppString(address->getLocality());
|
||||
map["postalCode"] = Utils::coreStringToAppString(address->getPostalCode());
|
||||
map["country"] = Utils::coreStringToAppString(address->getCountry());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
|
@ -235,32 +237,32 @@ QVariantMap VcardModel::getAddress () const {
|
|||
void VcardModel::setStreet (const QString &street) {
|
||||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCardAddress> address = ::getOrCreateBelCardAddress(mVcard->getVcard());
|
||||
address->setStreet(::Utils::appStringToCoreString(street));
|
||||
shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(mVcard->getVcard());
|
||||
address->setStreet(Utils::appStringToCoreString(street));
|
||||
emit vcardUpdated();
|
||||
}
|
||||
|
||||
void VcardModel::setLocality (const QString &locality) {
|
||||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCardAddress> address = ::getOrCreateBelCardAddress(mVcard->getVcard());
|
||||
address->setLocality(::Utils::appStringToCoreString(locality));
|
||||
shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(mVcard->getVcard());
|
||||
address->setLocality(Utils::appStringToCoreString(locality));
|
||||
emit vcardUpdated();
|
||||
}
|
||||
|
||||
void VcardModel::setPostalCode (const QString &postalCode) {
|
||||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCardAddress> address = ::getOrCreateBelCardAddress(mVcard->getVcard());
|
||||
address->setPostalCode(::Utils::appStringToCoreString(postalCode));
|
||||
shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(mVcard->getVcard());
|
||||
address->setPostalCode(Utils::appStringToCoreString(postalCode));
|
||||
emit vcardUpdated();
|
||||
}
|
||||
|
||||
void VcardModel::setCountry (const QString &country) {
|
||||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCardAddress> address = ::getOrCreateBelCardAddress(mVcard->getVcard());
|
||||
address->setCountry(::Utils::appStringToCoreString(country));
|
||||
shared_ptr<belcard::BelCardAddress> address = getOrCreateBelCardAddress(mVcard->getVcard());
|
||||
address->setCountry(Utils::appStringToCoreString(country));
|
||||
emit vcardUpdated();
|
||||
}
|
||||
|
||||
|
|
@ -275,10 +277,10 @@ QVariantList VcardModel::getSipAddresses () const {
|
|||
shared_ptr<linphone::Address> linphoneAddress = core->createAddress(value);
|
||||
|
||||
if (linphoneAddress)
|
||||
list << ::Utils::coreStringToAppString(linphoneAddress->asStringUriOnly());
|
||||
list << Utils::coreStringToAppString(linphoneAddress->asStringUriOnly());
|
||||
else
|
||||
qWarning() << QStringLiteral("Unable to parse sip address: `%1`")
|
||||
.arg(::Utils::coreStringToAppString(value));
|
||||
.arg(Utils::coreStringToAppString(value));
|
||||
}
|
||||
|
||||
return list;
|
||||
|
|
@ -287,13 +289,13 @@ QVariantList VcardModel::getSipAddresses () const {
|
|||
bool VcardModel::addSipAddress (const QString &sipAddress) {
|
||||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
string interpretedSipAddress = ::Utils::appStringToCoreString(SipAddressesModel::interpretSipAddress(sipAddress));
|
||||
string interpretedSipAddress = Utils::appStringToCoreString(SipAddressesModel::interpretSipAddress(sipAddress));
|
||||
if (interpretedSipAddress.empty())
|
||||
return false;
|
||||
|
||||
// Add sip address in belcard.
|
||||
shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
|
||||
if (::findBelCardValue(belcard->getImpp(), interpretedSipAddress))
|
||||
if (findBelCardValue(belcard->getImpp(), interpretedSipAddress))
|
||||
return false;
|
||||
|
||||
shared_ptr<belcard::BelCardImpp> value = belcard::BelCardGeneric::create<belcard::BelCardImpp>();
|
||||
|
|
@ -314,9 +316,9 @@ void VcardModel::removeSipAddress (const QString &sipAddress) {
|
|||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
|
||||
list<shared_ptr<belcard::BelCardImpp> > addresses = belcard->getImpp();
|
||||
shared_ptr<belcard::BelCardImpp> value = ::findBelCardValue(
|
||||
addresses, ::Utils::appStringToCoreString(SipAddressesModel::interpretSipAddress(sipAddress))
|
||||
list<shared_ptr<belcard::BelCardImpp>> addresses = belcard->getImpp();
|
||||
shared_ptr<belcard::BelCardImpp> value = findBelCardValue(
|
||||
addresses, Utils::appStringToCoreString(SipAddressesModel::interpretSipAddress(sipAddress))
|
||||
);
|
||||
|
||||
if (!value) {
|
||||
|
|
@ -348,7 +350,7 @@ QVariantList VcardModel::getCompanies () const {
|
|||
QVariantList list;
|
||||
|
||||
for (const auto &company : mVcard->getVcard()->getRoles())
|
||||
list.append(::Utils::coreStringToAppString(company->getValue()));
|
||||
list.append(Utils::coreStringToAppString(company->getValue()));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -357,11 +359,11 @@ bool VcardModel::addCompany (const QString &company) {
|
|||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
|
||||
if (::findBelCardValue(belcard->getRoles(), company))
|
||||
if (findBelCardValue(belcard->getRoles(), company))
|
||||
return false;
|
||||
|
||||
shared_ptr<belcard::BelCardRole> value = belcard::BelCardGeneric::create<belcard::BelCardRole>();
|
||||
value->setValue(::Utils::appStringToCoreString(company));
|
||||
value->setValue(Utils::appStringToCoreString(company));
|
||||
|
||||
if (!belcard->addRole(value)) {
|
||||
qWarning() << QStringLiteral("Unable to add company on vcard: `%1`.").arg(company);
|
||||
|
|
@ -378,7 +380,7 @@ void VcardModel::removeCompany (const QString &company) {
|
|||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
|
||||
shared_ptr<belcard::BelCardRole> value = ::findBelCardValue(belcard->getRoles(), company);
|
||||
shared_ptr<belcard::BelCardRole> value = findBelCardValue(belcard->getRoles(), company);
|
||||
|
||||
if (!value) {
|
||||
qWarning() << QStringLiteral("Unable to remove company on vcard: `%1`.").arg(company);
|
||||
|
|
@ -402,7 +404,7 @@ QVariantList VcardModel::getEmails () const {
|
|||
QVariantList list;
|
||||
|
||||
for (const auto &email : mVcard->getVcard()->getEmails())
|
||||
list.append(::Utils::coreStringToAppString(email->getValue()));
|
||||
list.append(Utils::coreStringToAppString(email->getValue()));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -411,11 +413,11 @@ bool VcardModel::addEmail (const QString &email) {
|
|||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
|
||||
if (::findBelCardValue(belcard->getEmails(), email))
|
||||
if (findBelCardValue(belcard->getEmails(), email))
|
||||
return false;
|
||||
|
||||
shared_ptr<belcard::BelCardEmail> value = belcard::BelCardGeneric::create<belcard::BelCardEmail>();
|
||||
value->setValue(::Utils::appStringToCoreString(email));
|
||||
value->setValue(Utils::appStringToCoreString(email));
|
||||
|
||||
if (!belcard->addEmail(value)) {
|
||||
qWarning() << QStringLiteral("Unable to add email on vcard: `%1`.").arg(email);
|
||||
|
|
@ -433,7 +435,7 @@ void VcardModel::removeEmail (const QString &email) {
|
|||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
|
||||
shared_ptr<belcard::BelCardEmail> value = ::findBelCardValue(belcard->getEmails(), email);
|
||||
shared_ptr<belcard::BelCardEmail> value = findBelCardValue(belcard->getEmails(), email);
|
||||
|
||||
if (!value) {
|
||||
qWarning() << QStringLiteral("Unable to remove email on vcard: `%1`.").arg(email);
|
||||
|
|
@ -457,7 +459,7 @@ QVariantList VcardModel::getUrls () const {
|
|||
QVariantList list;
|
||||
|
||||
for (const auto &url : mVcard->getVcard()->getURLs())
|
||||
list.append(::Utils::coreStringToAppString(url->getValue()));
|
||||
list.append(Utils::coreStringToAppString(url->getValue()));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -466,11 +468,11 @@ bool VcardModel::addUrl (const QString &url) {
|
|||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
|
||||
if (::findBelCardValue(belcard->getURLs(), url))
|
||||
if (findBelCardValue(belcard->getURLs(), url))
|
||||
return false;
|
||||
|
||||
shared_ptr<belcard::BelCardURL> value = belcard::BelCardGeneric::create<belcard::BelCardURL>();
|
||||
value->setValue(::Utils::appStringToCoreString(url));
|
||||
value->setValue(Utils::appStringToCoreString(url));
|
||||
|
||||
if (!belcard->addURL(value)) {
|
||||
qWarning() << QStringLiteral("Unable to add url on vcard: `%1`.").arg(url);
|
||||
|
|
@ -488,7 +490,7 @@ void VcardModel::removeUrl (const QString &url) {
|
|||
CHECK_VCARD_IS_WRITABLE(this);
|
||||
|
||||
shared_ptr<belcard::BelCard> belcard = mVcard->getVcard();
|
||||
shared_ptr<belcard::BelCardURL> value = ::findBelCardValue(belcard->getURLs(), url);
|
||||
shared_ptr<belcard::BelCardURL> value = findBelCardValue(belcard->getURLs(), url);
|
||||
|
||||
if (!value) {
|
||||
qWarning() << QStringLiteral("Unable to remove url on vcard: `%1`.").arg(url);
|
||||
|
|
|
|||
|
|
@ -23,11 +23,16 @@
|
|||
#ifndef VCARD_MODEL_H_
|
||||
#define VCARD_MODEL_H_
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
// =============================================================================
|
||||
|
||||
namespace linphone {
|
||||
class Vcard;
|
||||
}
|
||||
|
||||
class VcardModel : public QObject {
|
||||
friend class ContactModel; // Grant access to `mVcard`.
|
||||
|
||||
|
|
|
|||
|
|
@ -20,21 +20,25 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include <QQmlApplicationEngine>
|
||||
|
||||
#include "app/App.hpp"
|
||||
#include "components/contact/ContactModel.hpp"
|
||||
#include "components/contact/VcardModel.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
|
||||
#include "ContactsListModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
ContactsListModel::ContactsListModel (QObject *parent) : QAbstractListModel(parent) {
|
||||
mLinphoneFriends = CoreManager::getInstance()->getCore()->getFriendsLists().front();
|
||||
|
||||
// Clean friends.
|
||||
{
|
||||
list<shared_ptr<linphone::Friend> > toRemove;
|
||||
list<shared_ptr<linphone::Friend>> toRemove;
|
||||
for (const auto &linphoneFriend : mLinphoneFriends->getFriends()) {
|
||||
if (!linphoneFriend->getVcard())
|
||||
toRemove.push_back(linphoneFriend);
|
||||
|
|
@ -111,17 +115,15 @@ bool ContactsListModel::removeRows (int row, int count, const QModelIndex &paren
|
|||
|
||||
ContactModel *ContactsListModel::findContactModelFromSipAddress (const QString &sipAddress) const {
|
||||
auto it = find_if(mList.begin(), mList.end(), [&sipAddress](ContactModel *contactModel) {
|
||||
return contactModel->getVcardModel()->getSipAddresses().contains(sipAddress);
|
||||
});
|
||||
|
||||
return contactModel->getVcardModel()->getSipAddresses().contains(sipAddress);
|
||||
});
|
||||
return it != mList.end() ? *it : nullptr;
|
||||
}
|
||||
|
||||
ContactModel *ContactsListModel::findContactModelFromUsername (const QString &username) const {
|
||||
auto it = find_if(mList.begin(), mList.end(), [&username](ContactModel *contactModel) {
|
||||
return contactModel->getVcardModel()->getUsername() == username;
|
||||
});
|
||||
|
||||
return contactModel->getVcardModel()->getUsername() == username;
|
||||
});
|
||||
return it != mList.end() ? *it : nullptr;
|
||||
}
|
||||
|
||||
|
|
@ -187,14 +189,14 @@ void ContactsListModel::cleanAvatars () {
|
|||
|
||||
void ContactsListModel::addContact (ContactModel *contact) {
|
||||
QObject::connect(contact, &ContactModel::contactUpdated, this, [this, contact]() {
|
||||
emit contactUpdated(contact);
|
||||
});
|
||||
emit contactUpdated(contact);
|
||||
});
|
||||
QObject::connect(contact, &ContactModel::sipAddressAdded, this, [this, contact](const QString &sipAddress) {
|
||||
emit sipAddressAdded(contact, sipAddress);
|
||||
});
|
||||
emit sipAddressAdded(contact, sipAddress);
|
||||
});
|
||||
QObject::connect(contact, &ContactModel::sipAddressRemoved, this, [this, contact](const QString &sipAddress) {
|
||||
emit sipAddressRemoved(contact, sipAddress);
|
||||
});
|
||||
emit sipAddressRemoved(contact, sipAddress);
|
||||
});
|
||||
|
||||
mList << contact;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,13 +23,19 @@
|
|||
#ifndef CONTACTS_LIST_MODEL_H_
|
||||
#define CONTACTS_LIST_MODEL_H_
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <memory>
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
#include "../contact/ContactModel.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
namespace linphone {
|
||||
class FriendList;
|
||||
}
|
||||
|
||||
class ContactModel;
|
||||
class VcardModel;
|
||||
|
||||
class ContactsListModel : public QAbstractListModel {
|
||||
friend class SipAddressesModel;
|
||||
|
||||
|
|
@ -37,7 +43,6 @@ class ContactsListModel : public QAbstractListModel {
|
|||
|
||||
public:
|
||||
ContactsListModel (QObject *parent = Q_NULLPTR);
|
||||
~ContactsListModel () = default;
|
||||
|
||||
int rowCount (const QModelIndex &index = QModelIndex()) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,23 +22,28 @@
|
|||
|
||||
#include <cmath>
|
||||
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/contact/ContactModel.hpp"
|
||||
#include "components/contact/VcardModel.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "ContactsListModel.hpp"
|
||||
#include "ContactsListProxyModel.hpp"
|
||||
|
||||
#define USERNAME_WEIGHT 50.f
|
||||
#define SIP_ADDRESSES_WEIGHT 50.f
|
||||
|
||||
#define FACTOR_POS_0 1.0f
|
||||
#define FACTOR_POS_1 0.9f
|
||||
#define FACTOR_POS_2 0.8f
|
||||
#define FACTOR_POS_3 0.7f
|
||||
#define FACTOR_POS_OTHER 0.6f
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
namespace {
|
||||
constexpr float UsernameWeight = 50.f;
|
||||
constexpr float SipAddressWeight = 50.f;
|
||||
|
||||
constexpr float FactorPos0 = 1.0f;
|
||||
constexpr float FactorPos1 = 0.9f;
|
||||
constexpr float FactorPos2 = 0.8f;
|
||||
constexpr float FactorPos3 = 0.7f;
|
||||
constexpr float FactorPosOther = 0.6f;
|
||||
}
|
||||
|
||||
// Notes:
|
||||
//
|
||||
|
|
@ -49,7 +54,7 @@ using namespace std;
|
|||
// a separator like ` word`.
|
||||
//
|
||||
// - [_.-;@ ] is the main pattern (a separator).
|
||||
const QRegExp ContactsListProxyModel::mSearchSeparators("^[^_.-;@ ][_.-;@ ]");
|
||||
const QRegExp ContactsListProxyModel::SearchSeparators("^[^_.-;@ ][_.-;@ ]");
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -105,7 +110,7 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float
|
|||
// Search pattern.
|
||||
while ((index = string.indexOf(mFilter, index + 1, Qt::CaseInsensitive)) != -1) {
|
||||
// Search n chars between one separator and index.
|
||||
int tmpOffset = index - string.lastIndexOf(mSearchSeparators, index) - 1;
|
||||
int tmpOffset = index - string.lastIndexOf(SearchSeparators, index) - 1;
|
||||
|
||||
if ((tmpOffset != -1 && tmpOffset < offset) || offset == -1)
|
||||
if ((offset = tmpOffset) == 0) break;
|
||||
|
|
@ -113,28 +118,28 @@ float ContactsListProxyModel::computeStringWeight (const QString &string, float
|
|||
|
||||
switch (offset) {
|
||||
case -1: return 0;
|
||||
case 0: return percentage * FACTOR_POS_0;
|
||||
case 1: return percentage * FACTOR_POS_1;
|
||||
case 2: return percentage * FACTOR_POS_2;
|
||||
case 3: return percentage * FACTOR_POS_3;
|
||||
case 0: return percentage *FactorPos0;
|
||||
case 1: return percentage *FactorPos1;
|
||||
case 2: return percentage *FactorPos2;
|
||||
case 3: return percentage *FactorPos3;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return percentage * FACTOR_POS_OTHER;
|
||||
return percentage *FactorPosOther;
|
||||
}
|
||||
|
||||
float ContactsListProxyModel::computeContactWeight (const ContactModel *contact) const {
|
||||
float weight = computeStringWeight(contact->getVcardModel()->getUsername(), USERNAME_WEIGHT);
|
||||
float weight = computeStringWeight(contact->getVcardModel()->getUsername(), UsernameWeight);
|
||||
|
||||
// Get all contact's addresses.
|
||||
const list<shared_ptr<linphone::Address> > addresses = contact->mLinphoneFriend->getAddresses();
|
||||
const list<shared_ptr<linphone::Address>> addresses = contact->mLinphoneFriend->getAddresses();
|
||||
|
||||
float size = float(addresses.size());
|
||||
for (auto it = addresses.cbegin(); it != addresses.cend(); ++it)
|
||||
weight += computeStringWeight(
|
||||
::Utils::coreStringToAppString((*it)->asStringUriOnly()),
|
||||
SIP_ADDRESSES_WEIGHT / size
|
||||
);
|
||||
Utils::coreStringToAppString((*it)->asStringUriOnly()),
|
||||
SipAddressWeight / size
|
||||
);
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ class ContactsListProxyModel : public QSortFilterProxyModel {
|
|||
|
||||
public:
|
||||
ContactsListProxyModel (QObject *parent = Q_NULLPTR);
|
||||
~ContactsListProxyModel () = default;
|
||||
|
||||
Q_INVOKABLE void setFilter (const QString &pattern);
|
||||
|
||||
|
|
@ -66,7 +65,7 @@ private:
|
|||
// and reused by `lessThan`.
|
||||
mutable QHash<const ContactModel *, unsigned int> mWeights;
|
||||
|
||||
static const QRegExp mSearchSeparators;
|
||||
static const QRegExp SearchSeparators;
|
||||
};
|
||||
|
||||
#endif // CONTACTS_LIST_PROXY_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -25,16 +25,20 @@
|
|||
#include <QThread>
|
||||
#include <QTimer>
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "CoreManager.hpp"
|
||||
#include "app/App.hpp"
|
||||
#include "components/call/CallModel.hpp"
|
||||
#include "components/contact/ContactModel.hpp"
|
||||
#include "components/notifier/Notifier.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "CoreHandlers.hpp"
|
||||
|
||||
using namespace std;
|
||||
#include "CoreManager.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
// Schedule a function in app context.
|
||||
void scheduleFunctionInApp (function<void()> func) {
|
||||
App *app = App::getInstance();
|
||||
|
|
@ -199,7 +203,7 @@ void CoreHandlers::onNotifyPresenceReceivedForUriOrTel (
|
|||
const string &uriOrTel,
|
||||
const shared_ptr<const linphone::PresenceModel> &presenceModel
|
||||
) {
|
||||
emit presenceReceived(::Utils::coreStringToAppString(uriOrTel), presenceModel);
|
||||
emit presenceReceived(Utils::coreStringToAppString(uriOrTel), presenceModel);
|
||||
}
|
||||
|
||||
void CoreHandlers::onNotifyPresenceReceived (
|
||||
|
|
@ -277,7 +281,7 @@ void CoreHandlers::onVersionUpdateCheckResultReceived (
|
|||
) {
|
||||
if (result == linphone::VersionUpdateCheckResultNewVersionAvailable)
|
||||
App::getInstance()->getNotifier()->notifyNewVersionAvailable(
|
||||
::Utils::coreStringToAppString(version),
|
||||
::Utils::coreStringToAppString(url)
|
||||
Utils::coreStringToAppString(version),
|
||||
Utils::coreStringToAppString(url)
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,13 @@
|
|||
#include <QTimer>
|
||||
|
||||
#include "app/paths/Paths.hpp"
|
||||
#include "components/calls/CallsListModel.hpp"
|
||||
#include "components/chat/ChatModel.hpp"
|
||||
#include "components/contact/VcardModel.hpp"
|
||||
#include "components/contacts/ContactsListModel.hpp"
|
||||
#include "components/settings/AccountSettingsModel.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "components/sip-addresses/SipAddressesModel.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#if defined(Q_OS_LINUX)
|
||||
|
|
@ -36,6 +43,7 @@
|
|||
#include "messages-count-notifier/MessagesCountNotifierWindows.hpp"
|
||||
#endif // if defined(Q_OS_LINUX)
|
||||
|
||||
#include "CoreHandlers.hpp"
|
||||
#include "CoreManager.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -43,21 +51,21 @@
|
|||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr int cCbsCallInterval = 20;
|
||||
constexpr int CbsCallInterval = 20;
|
||||
|
||||
constexpr char cRcVersionName[] = "rc_version";
|
||||
constexpr int cRcVersionCurrent = 1;
|
||||
constexpr char RcVersionName[] = "rc_version";
|
||||
constexpr int RcVersionCurrent = 1;
|
||||
|
||||
// TODO: Remove hardcoded values. Use config directly.
|
||||
constexpr char cLinphoneDomain[] = "sip.linphone.org";
|
||||
constexpr char cDefaultContactParameters[] = "message-expires=604800";
|
||||
constexpr int cDefaultExpires = 3600;
|
||||
constexpr char cDownloadUrl[] = "https://www.linphone.org/technical-corner/linphone/downloads";
|
||||
constexpr char LinphoneDomain[] = "sip.linphone.org";
|
||||
constexpr char DefaultContactParameters[] = "message-expires=604800";
|
||||
constexpr int DefaultExpires = 3600;
|
||||
constexpr char DownloadUrl[] = "https://www.linphone.org/technical-corner/linphone/downloads";
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
CoreManager *CoreManager::mInstance = nullptr;
|
||||
CoreManager *CoreManager::mInstance;
|
||||
|
||||
CoreManager::CoreManager (QObject *parent, const QString &configPath) :
|
||||
QObject(parent), mHandlers(make_shared<CoreHandlers>(this)) {
|
||||
|
|
@ -140,7 +148,7 @@ void CoreManager::init (QObject *parent, const QString &configPath) {
|
|||
mInstance = new CoreManager(parent, configPath);
|
||||
|
||||
QTimer *timer = mInstance->mCbsTimer = new QTimer(mInstance);
|
||||
timer->setInterval(cCbsCallInterval);
|
||||
timer->setInterval(CbsCallInterval);
|
||||
|
||||
QObject::connect(timer, &QTimer::timeout, mInstance, &CoreManager::iterate);
|
||||
}
|
||||
|
|
@ -253,27 +261,27 @@ void CoreManager::createLinphoneCore (const QString &configPath) {
|
|||
|
||||
void CoreManager::migrate () {
|
||||
shared_ptr<linphone::Config> config = mCore->getConfig();
|
||||
int rcVersion = config->getInt(SettingsModel::UI_SECTION, cRcVersionName, 0);
|
||||
if (rcVersion == cRcVersionCurrent)
|
||||
int rcVersion = config->getInt(SettingsModel::UiSection, RcVersionName, 0);
|
||||
if (rcVersion == RcVersionCurrent)
|
||||
return;
|
||||
if (rcVersion > cRcVersionCurrent) {
|
||||
if (rcVersion > RcVersionCurrent) {
|
||||
qWarning() << QStringLiteral("RC file version (%1) is more recent than app rc file version (%2)!!!")
|
||||
.arg(rcVersion).arg(cRcVersionCurrent);
|
||||
.arg(rcVersion).arg(RcVersionCurrent);
|
||||
return;
|
||||
}
|
||||
|
||||
qInfo() << QStringLiteral("Migrate from old rc file (%1 to %2).")
|
||||
.arg(rcVersion).arg(cRcVersionCurrent);
|
||||
.arg(rcVersion).arg(RcVersionCurrent);
|
||||
|
||||
// Add message_expires param on old proxy configs.
|
||||
for (const auto &proxyConfig : mCore->getProxyConfigList()) {
|
||||
if (proxyConfig->getDomain() == cLinphoneDomain) {
|
||||
proxyConfig->setContactParameters(cDefaultContactParameters);
|
||||
proxyConfig->setExpires(cDefaultExpires);
|
||||
if (proxyConfig->getDomain() == LinphoneDomain) {
|
||||
proxyConfig->setContactParameters(DefaultContactParameters);
|
||||
proxyConfig->setExpires(DefaultExpires);
|
||||
proxyConfig->done();
|
||||
}
|
||||
}
|
||||
config->setInt(SettingsModel::UI_SECTION, cRcVersionName, cRcVersionCurrent);
|
||||
config->setInt(SettingsModel::UiSection, RcVersionName, RcVersionCurrent);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -307,5 +315,5 @@ void CoreManager::handleLogsUploadStateChanged (linphone::CoreLogCollectionUploa
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString CoreManager::getDownloadUrl () {
|
||||
return cDownloadUrl;
|
||||
return DownloadUrl;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,21 +23,22 @@
|
|||
#ifndef CORE_MANAGER_H_
|
||||
#define CORE_MANAGER_H_
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <QFutureWatcher>
|
||||
|
||||
#include "../calls/CallsListModel.hpp"
|
||||
#include "../chat/ChatModel.hpp"
|
||||
#include "../contacts/ContactsListModel.hpp"
|
||||
#include "../settings/AccountSettingsModel.hpp"
|
||||
#include "../settings/SettingsModel.hpp"
|
||||
#include "../sip-addresses/SipAddressesModel.hpp"
|
||||
|
||||
#include "CoreHandlers.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class QTimer;
|
||||
|
||||
class AccountSettingsModel;
|
||||
class CallsListModel;
|
||||
class ChatModel;
|
||||
class ContactsListModel;
|
||||
class CoreHandlers;
|
||||
class SettingsModel;
|
||||
class SipAddressesModel;
|
||||
class VcardModel;
|
||||
|
||||
class CoreManager : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
|
|
@ -45,8 +46,6 @@ class CoreManager : public QObject {
|
|||
Q_PROPERTY(QString downloadUrl READ getDownloadUrl CONSTANT);
|
||||
|
||||
public:
|
||||
~CoreManager () = default;
|
||||
|
||||
bool started () const {
|
||||
return mStarted;
|
||||
}
|
||||
|
|
@ -165,7 +164,7 @@ private:
|
|||
SettingsModel *mSettingsModel = nullptr;
|
||||
AccountSettingsModel *mAccountSettingsModel = nullptr;
|
||||
|
||||
QHash<QString, std::weak_ptr<ChatModel> > mChatModels;
|
||||
QHash<QString, std::weak_ptr<ChatModel>> mChatModels;
|
||||
|
||||
QTimer *mCbsTimer = nullptr;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,17 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../CoreManager.hpp"
|
||||
#include "components/chat/ChatModel.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
|
||||
#include "AbstractMessagesCountNotifier.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
AbstractMessagesCountNotifier::AbstractMessagesCountNotifier (QObject *parent) : QObject(parent) {
|
||||
CoreManager *coreManager = CoreManager::getInstance();
|
||||
QObject::connect(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ class AbstractMessagesCountNotifier : public QObject {
|
|||
|
||||
public:
|
||||
AbstractMessagesCountNotifier (QObject *parent = Q_NULLPTR);
|
||||
virtual ~AbstractMessagesCountNotifier () = default;
|
||||
|
||||
void updateUnreadMessagesCount ();
|
||||
|
||||
|
|
|
|||
|
|
@ -25,30 +25,33 @@
|
|||
#include <QSvgRenderer>
|
||||
#include <QSystemTrayIcon>
|
||||
#include <QTimer>
|
||||
#include <QWindow>
|
||||
|
||||
#include "../../../app/App.hpp"
|
||||
#include "../../../utils/LinphoneUtils.hpp"
|
||||
#include "../../../utils/Utils.hpp"
|
||||
#include "app/App.hpp"
|
||||
#include "utils/LinphoneUtils.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "MessagesCountNotifierLinux.hpp"
|
||||
|
||||
#define ICON_WIDTH 256
|
||||
#define ICON_HEIGHT 256
|
||||
|
||||
#define ICON_COUNTER_BACKGROUND_COLOR "#FF3C31"
|
||||
#define ICON_COUNTER_BACKGROUND_RADIUS 100
|
||||
#define ICON_COUNTER_BLINK_INTERVAL 1000
|
||||
#define ICON_COUNTER_TEXT_COLOR "#FFFBFA"
|
||||
#define ICON_COUNTER_TEXT_PIXEL_SIZE 144
|
||||
|
||||
// =============================================================================
|
||||
|
||||
namespace {
|
||||
constexpr int IconWidth = 256;
|
||||
constexpr int IconHeight = 256;
|
||||
|
||||
constexpr char IconCounterBackgroundColor[] = "#FF3C31";
|
||||
constexpr int IconCounterBackgroundRadius = 100;
|
||||
constexpr int IconCounterBlinkInterval = 1000;
|
||||
constexpr char IconCounterTextColor[] = "#FFFBFA";
|
||||
constexpr int IconCounterTextPixelSize = 144;
|
||||
}
|
||||
|
||||
MessagesCountNotifier::MessagesCountNotifier (QObject *parent) : AbstractMessagesCountNotifier(parent) {
|
||||
QSvgRenderer renderer(QStringLiteral(WINDOW_ICON_PATH));
|
||||
QSvgRenderer renderer((QString(LinphoneUtils::WindowIconPath)));
|
||||
if (!renderer.isValid())
|
||||
qFatal("Invalid SVG Image.");
|
||||
|
||||
QPixmap buf(ICON_WIDTH, ICON_HEIGHT);
|
||||
QPixmap buf(IconWidth, IconHeight);
|
||||
buf.fill(QColor(Qt::transparent));
|
||||
|
||||
QPainter painter(&buf);
|
||||
|
|
@ -58,7 +61,7 @@ MessagesCountNotifier::MessagesCountNotifier (QObject *parent) : AbstractMessage
|
|||
mBufWithCounter = new QPixmap();
|
||||
|
||||
mBlinkTimer = new QTimer(this);
|
||||
mBlinkTimer->setInterval(ICON_COUNTER_BLINK_INTERVAL);
|
||||
mBlinkTimer->setInterval(IconCounterBlinkInterval);
|
||||
QObject::connect(mBlinkTimer, &QTimer::timeout, this, &MessagesCountNotifier::update);
|
||||
|
||||
Utils::connectOnce(
|
||||
|
|
@ -91,17 +94,17 @@ void MessagesCountNotifier::notifyUnreadMessagesCount (int n) {
|
|||
|
||||
// Draw background.
|
||||
{
|
||||
p.setBrush(QColor(ICON_COUNTER_BACKGROUND_COLOR));
|
||||
p.drawEllipse(QPointF(width / 2, height / 2), ICON_COUNTER_BACKGROUND_RADIUS, ICON_COUNTER_BACKGROUND_RADIUS);
|
||||
p.setBrush(QColor(IconCounterBackgroundColor));
|
||||
p.drawEllipse(QPointF(width / 2, height / 2), IconCounterBackgroundRadius, IconCounterBackgroundRadius);
|
||||
}
|
||||
|
||||
// Draw text.
|
||||
{
|
||||
QFont font = p.font();
|
||||
font.setPixelSize(ICON_COUNTER_TEXT_PIXEL_SIZE);
|
||||
font.setPixelSize(IconCounterTextPixelSize);
|
||||
|
||||
p.setFont(font);
|
||||
p.setPen(QPen(QColor(ICON_COUNTER_TEXT_COLOR), 1));
|
||||
p.setPen(QPen(QColor(IconCounterTextColor), 1));
|
||||
p.drawText(QRect(0, 0, width, height), Qt::AlignCenter, QString::number(n));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,6 @@ public:
|
|||
MessagesCountNotifier (QObject *parent = Q_NULLPTR) : AbstractMessagesCountNotifier(parent) {}
|
||||
|
||||
void notifyUnreadMessagesCount (int n) override {
|
||||
::notifyUnreadMessagesCountMacOS(n);
|
||||
notifyUnreadMessagesCountMacOS(n);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "app/paths/Paths.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "FileDownloader.hpp"
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@
|
|||
#include <mz.h>
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
|
||||
#include "FileExtractor.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -24,10 +24,11 @@
|
|||
#define FILE_EXTRACTOR_H_
|
||||
|
||||
#include <QFile>
|
||||
#include <QTimer>
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class QTimer;
|
||||
|
||||
// Supports only bzip file.
|
||||
class FileExtractor : public QObject {
|
||||
class ExtractStream;
|
||||
|
|
|
|||
|
|
@ -20,43 +20,50 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include <QQmlApplicationEngine>
|
||||
#include <QQmlComponent>
|
||||
#include <QQuickWindow>
|
||||
#include <QScreen>
|
||||
#include <QTimer>
|
||||
|
||||
#include "../../app/App.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "app/App.hpp"
|
||||
#include "components/call/CallModel.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "Notifier.hpp"
|
||||
|
||||
#define NOTIFICATIONS_PATH "qrc:/ui/modules/Linphone/Notifications/"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Notifications QML properties/methods.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define NOTIFICATION_SHOW_METHOD_NAME "open"
|
||||
|
||||
#define NOTIFICATION_PROPERTY_DATA "notificationData"
|
||||
|
||||
#define NOTIFICATION_PROPERTY_X "popupX"
|
||||
#define NOTIFICATION_PROPERTY_Y "popupY"
|
||||
|
||||
#define NOTIFICATION_PROPERTY_WINDOW "__internalWindow"
|
||||
|
||||
#define NOTIFICATION_PROPERTY_TIMER "__timer"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Arbitrary hardcoded values.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define NOTIFICATION_SPACING 10
|
||||
#define N_MAX_NOTIFICATIONS 5
|
||||
#define MAX_TIMEOUT 30000
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr char NotificationsPath[] = "qrc:/ui/modules/Linphone/Notifications/";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Notifications QML properties/methods.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
constexpr char NotificationShowMethodName[] = "open";
|
||||
|
||||
constexpr char NotificationPropertyData[] = "notificationData";
|
||||
|
||||
constexpr char NotificationPropertyX[] = "popupX";
|
||||
constexpr char NotificationPropertyY[] = "popupY";
|
||||
|
||||
constexpr char NotificationPropertyWindow[] = "__internalWindow";
|
||||
|
||||
constexpr char NotificationPropertyTimer[] = "__timer";
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Arbitrary hardcoded values.
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
constexpr int NotificationSpacing = 10;
|
||||
constexpr int MaxNotificationsNumber = 5;
|
||||
constexpr int MaxTimeout = 30000;
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
|
||||
template<class T>
|
||||
|
|
@ -71,7 +78,7 @@ void setProperty (QObject &object, const char *property, const T &value) {
|
|||
// Available notifications.
|
||||
// =============================================================================
|
||||
|
||||
const QHash<int, Notifier::Notification> Notifier::mNotifications = {
|
||||
const QHash<int, Notifier::Notification> Notifier::Notifications = {
|
||||
{ Notifier::ReceivedMessage, { "NotificationReceivedMessage.qml", 10 } },
|
||||
{ Notifier::ReceivedFileMessage, { "NotificationReceivedFileMessage.qml", 10 } },
|
||||
{ Notifier::ReceivedCall, { "NotificationReceivedCall.qml", 30 } },
|
||||
|
|
@ -83,12 +90,12 @@ const QHash<int, Notifier::Notification> Notifier::mNotifications = {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
Notifier::Notifier (QObject *parent) : QObject(parent) {
|
||||
const int nComponents = mNotifications.size();
|
||||
const int nComponents = Notifications.size();
|
||||
mComponents = new QQmlComponent *[nComponents];
|
||||
|
||||
QQmlEngine *engine = App::getInstance()->getEngine();
|
||||
for (const auto &key : mNotifications.keys()) {
|
||||
QQmlComponent *component = new QQmlComponent(engine, QUrl(NOTIFICATIONS_PATH + Notifier::mNotifications[key].filename));
|
||||
for (const auto &key : Notifications.keys()) {
|
||||
QQmlComponent *component = new QQmlComponent(engine, QUrl(NotificationsPath + Notifier::Notifications[key].filename));
|
||||
if (Q_UNLIKELY(component->isError())) {
|
||||
qWarning() << QStringLiteral("Errors found in `Notification` component %1:").arg(key) << component->errors();
|
||||
abort();
|
||||
|
|
@ -102,7 +109,7 @@ Notifier::Notifier (QObject *parent) : QObject(parent) {
|
|||
Notifier::~Notifier () {
|
||||
delete mMutex;
|
||||
|
||||
const int nComponents = mNotifications.size();
|
||||
const int nComponents = Notifications.size();
|
||||
for (int i = 0; i < nComponents; ++i)
|
||||
delete mComponents[i];
|
||||
delete[] mComponents;
|
||||
|
|
@ -113,10 +120,10 @@ Notifier::~Notifier () {
|
|||
QObject *Notifier::createNotification (Notifier::NotificationType type) {
|
||||
mMutex->lock();
|
||||
|
||||
Q_ASSERT(mInstancesNumber <= N_MAX_NOTIFICATIONS);
|
||||
Q_ASSERT(mInstancesNumber <= MaxNotificationsNumber);
|
||||
|
||||
// Check existing instances.
|
||||
if (mInstancesNumber == N_MAX_NOTIFICATIONS) {
|
||||
if (mInstancesNumber == MaxNotificationsNumber) {
|
||||
qWarning() << QStringLiteral("Unable to create another notification.");
|
||||
mMutex->unlock();
|
||||
return nullptr;
|
||||
|
|
@ -129,7 +136,7 @@ QObject *Notifier::createNotification (Notifier::NotificationType type) {
|
|||
mInstancesNumber++;
|
||||
|
||||
{
|
||||
QQuickWindow *window = instance->findChild<QQuickWindow *>(NOTIFICATION_PROPERTY_WINDOW);
|
||||
QQuickWindow *window = instance->findChild<QQuickWindow *>(NotificationPropertyWindow);
|
||||
Q_CHECK_PTR(window);
|
||||
|
||||
QScreen *screen = window->screen();
|
||||
|
|
@ -141,11 +148,11 @@ QObject *Notifier::createNotification (Notifier::NotificationType type) {
|
|||
int windowHeight = window->height();
|
||||
int offset = geometry.y() + geometry.height() - windowHeight;
|
||||
|
||||
::setProperty(*instance, NOTIFICATION_PROPERTY_X, geometry.x() + geometry.width() - window->width());
|
||||
::setProperty(*instance, NOTIFICATION_PROPERTY_Y, offset - (mOffset % offset));
|
||||
::setProperty(*instance, NotificationPropertyX, geometry.x() + geometry.width() - window->width());
|
||||
::setProperty(*instance, NotificationPropertyY, offset - (mOffset % offset));
|
||||
|
||||
// Update offset.
|
||||
mOffset = (windowHeight + mOffset) + NOTIFICATION_SPACING;
|
||||
mOffset = (windowHeight + mOffset) + NotificationSpacing;
|
||||
if (mOffset - offset + geometry.y() >= 0)
|
||||
mOffset = 0;
|
||||
}
|
||||
|
|
@ -159,12 +166,12 @@ QObject *Notifier::createNotification (Notifier::NotificationType type) {
|
|||
|
||||
void Notifier::showNotification (QObject *notification, int timeout) {
|
||||
// Display notification.
|
||||
QMetaObject::invokeMethod(notification, NOTIFICATION_SHOW_METHOD_NAME, Qt::DirectConnection);
|
||||
QMetaObject::invokeMethod(notification, NotificationShowMethodName, Qt::DirectConnection);
|
||||
|
||||
QTimer *timer = new QTimer(notification);
|
||||
timer->setInterval(timeout > MAX_TIMEOUT ? MAX_TIMEOUT : timeout);
|
||||
timer->setInterval(timeout > MaxTimeout ? MaxTimeout : timeout);
|
||||
timer->setSingleShot(true);
|
||||
notification->setProperty(NOTIFICATION_PROPERTY_TIMER, QVariant::fromValue(timer));
|
||||
notification->setProperty(NotificationPropertyTimer, QVariant::fromValue(timer));
|
||||
|
||||
// Destroy it after timeout.
|
||||
QObject::connect(timer, &QTimer::timeout, this, [this, notification]() {
|
||||
|
|
@ -193,7 +200,7 @@ void Notifier::deleteNotification (QVariant notification) {
|
|||
qInfo() << QStringLiteral("Delete notification:") << instance;
|
||||
|
||||
instance->setProperty("__valid", true);
|
||||
instance->property(NOTIFICATION_PROPERTY_TIMER).value<QTimer *>()->stop();
|
||||
instance->property(NotificationPropertyTimer).value<QTimer *>()->stop();
|
||||
|
||||
mInstancesNumber--;
|
||||
Q_ASSERT(mInstancesNumber >= 0);
|
||||
|
|
@ -212,10 +219,10 @@ void Notifier::deleteNotification (QVariant notification) {
|
|||
QObject * notification = createNotification(TYPE); \
|
||||
if (!notification) \
|
||||
return; \
|
||||
const int timeout = mNotifications[TYPE].timeout * 1000;
|
||||
const int timeout = Notifications[TYPE].timeout * 1000;
|
||||
|
||||
#define SHOW_NOTIFICATION(DATA) \
|
||||
::setProperty(*notification, NOTIFICATION_PROPERTY_DATA, DATA); \
|
||||
::setProperty(*notification, NotificationPropertyData, DATA); \
|
||||
showNotification(notification, timeout);
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
|
@ -228,9 +235,9 @@ void Notifier::notifyReceivedMessage (const shared_ptr<linphone::ChatMessage> &m
|
|||
QVariantMap map;
|
||||
map["message"] = message->getFileTransferInformation()
|
||||
? tr("newFileMessage")
|
||||
: ::Utils::coreStringToAppString(message->getText());
|
||||
: Utils::coreStringToAppString(message->getText());
|
||||
|
||||
map["sipAddress"] = ::Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly());
|
||||
map["sipAddress"] = Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly());
|
||||
map["window"].setValue(App::getInstance()->getMainWindow());
|
||||
|
||||
SHOW_NOTIFICATION(map);
|
||||
|
|
@ -240,7 +247,7 @@ void Notifier::notifyReceivedFileMessage (const shared_ptr<linphone::ChatMessage
|
|||
CREATE_NOTIFICATION(Notifier::ReceivedFileMessage);
|
||||
|
||||
QVariantMap map;
|
||||
map["fileUri"] = ::Utils::coreStringToAppString(message->getFileTransferFilepath());
|
||||
map["fileUri"] = Utils::coreStringToAppString(message->getFileTransferFilepath());
|
||||
map["fileSize"] = quint64(message->getFileTransferInformation()->getSize());
|
||||
|
||||
SHOW_NOTIFICATION(map);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@
|
|||
#ifndef NOTIFIER_H_
|
||||
#define NOTIFIER_H_
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <memory>
|
||||
|
||||
#include <QObject>
|
||||
|
||||
// =============================================================================
|
||||
|
|
@ -31,6 +32,11 @@
|
|||
class QMutex;
|
||||
class QQmlComponent;
|
||||
|
||||
namespace linphone {
|
||||
class Call;
|
||||
class ChatMessage;
|
||||
}
|
||||
|
||||
class Notifier : public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
|
|
@ -77,7 +83,7 @@ private:
|
|||
QMutex *mMutex = nullptr;
|
||||
QQmlComponent **mComponents = nullptr;
|
||||
|
||||
static const QHash<int, Notification> mNotifications;
|
||||
static const QHash<int, Notification> Notifications;
|
||||
};
|
||||
|
||||
#endif // NOTIFIER_H_
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
// =============================================================================
|
||||
|
||||
Clipboard::Clipboard (QObject *parent) : QObject(parent) {
|
||||
connect(QGuiApplication::clipboard(), &QClipboard::dataChanged, this, &Clipboard::textChanged);
|
||||
QObject::connect(QGuiApplication::clipboard(), &QClipboard::dataChanged, this, &Clipboard::textChanged);
|
||||
}
|
||||
|
||||
QString Clipboard::getText () const {
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ class Clipboard : public QObject {
|
|||
|
||||
public:
|
||||
Clipboard (QObject *parent = Q_NULLPTR);
|
||||
~Clipboard () = default;
|
||||
|
||||
signals:
|
||||
void textChanged ();
|
||||
|
|
|
|||
|
|
@ -20,22 +20,23 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <QMetaProperty>
|
||||
|
||||
#include "../../../utils/Utils.hpp"
|
||||
|
||||
#include "Colors.hpp"
|
||||
|
||||
#if LINPHONE_FRIDAY
|
||||
#include <QDate>
|
||||
#endif // if LINPHONE_FRIDAY
|
||||
|
||||
using namespace std;
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "Colors.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr char cColorsSection[] = "ui_colors";
|
||||
constexpr char ColorsSection[] = "ui_colors";
|
||||
}
|
||||
|
||||
#if LINPHONE_FRIDAY
|
||||
|
|
@ -46,7 +47,7 @@ namespace {
|
|||
|
||||
Colors::Colors (QObject *parent) : QObject(parent) {
|
||||
#if LINPHONE_FRIDAY
|
||||
if (::isLinphoneFriday()) {
|
||||
if (isLinphoneFriday()) {
|
||||
setProperty("i", QColor("#F48D8D"));
|
||||
setProperty("s", QColor("#F58585"));
|
||||
setProperty("t", QColor("#FFC5C5"));
|
||||
|
|
@ -56,7 +57,7 @@ Colors::Colors (QObject *parent) : QObject(parent) {
|
|||
|
||||
void Colors::useConfig (const shared_ptr<linphone::Config> &config) {
|
||||
#if LINPHONE_FRIDAY
|
||||
if (!::isLinphoneFriday())
|
||||
if (!isLinphoneFriday())
|
||||
overrideColors(config);
|
||||
#else
|
||||
overrideColors(config);
|
||||
|
|
@ -74,10 +75,10 @@ void Colors::overrideColors (const shared_ptr<linphone::Config> &config) {
|
|||
for (int i = info->propertyOffset(); i < info->propertyCount(); ++i) {
|
||||
const QMetaProperty metaProperty = info->property(i);
|
||||
const string colorName = metaProperty.name();
|
||||
const string colorValue = config->getString(cColorsSection, colorName, "");
|
||||
const string colorValue = config->getString(ColorsSection, colorName, "");
|
||||
|
||||
if (!colorValue.empty())
|
||||
setProperty(colorName.c_str(), QColor(::Utils::coreStringToAppString(colorValue)));
|
||||
setProperty(colorName.c_str(), QColor(Utils::coreStringToAppString(colorValue)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,8 @@
|
|||
#ifndef COLORS_H_
|
||||
#define COLORS_H_
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <memory>
|
||||
|
||||
#include <QColor>
|
||||
#include <QObject>
|
||||
|
||||
|
|
@ -49,7 +50,7 @@
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
namespace linphone {
|
||||
class Config;
|
||||
class Config;
|
||||
}
|
||||
|
||||
class Colors : public QObject {
|
||||
|
|
@ -97,7 +98,6 @@ class Colors : public QObject {
|
|||
|
||||
public:
|
||||
Colors (QObject *parent = Q_NULLPTR);
|
||||
~Colors () = default;
|
||||
|
||||
void useConfig (const std::shared_ptr<linphone::Config> &config);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ class TextToSpeech : public QObject {
|
|||
|
||||
public:
|
||||
TextToSpeech (QObject *parent = Q_NULLPTR);
|
||||
~TextToSpeech () = default;
|
||||
|
||||
Q_INVOKABLE void say (const QString &text);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ class Units : public QObject {
|
|||
|
||||
public:
|
||||
Units (QObject *parent = Q_NULLPTR);
|
||||
~Units () = default;
|
||||
|
||||
private:
|
||||
float getDp () const;
|
||||
|
|
|
|||
|
|
@ -20,14 +20,14 @@
|
|||
* Author: Ghislain MARY
|
||||
*/
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
|
||||
#include "OwnPresenceModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
Presence::PresenceLevel OwnPresenceModel::getPresenceLevel () const {
|
||||
return Presence::getPresenceLevel(getPresenceStatus());
|
||||
}
|
||||
|
|
@ -60,10 +60,10 @@ static inline void addBuildStatus (QVariantList &list, Presence::PresenceStatus
|
|||
QVariantList OwnPresenceModel::getStatuses () const {
|
||||
QVariantList statuses;
|
||||
|
||||
::addBuildStatus(statuses, Presence::Online);
|
||||
::addBuildStatus(statuses, Presence::Busy);
|
||||
::addBuildStatus(statuses, Presence::DoNotDisturb);
|
||||
::addBuildStatus(statuses, Presence::Offline);
|
||||
addBuildStatus(statuses, Presence::Online);
|
||||
addBuildStatus(statuses, Presence::Busy);
|
||||
addBuildStatus(statuses, Presence::DoNotDisturb);
|
||||
addBuildStatus(statuses, Presence::Offline);
|
||||
|
||||
return statuses;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
#ifndef OWN_PRESENCE_MODEL_H_
|
||||
#define OWN_PRESENCE_MODEL_H_
|
||||
|
||||
#include "../presence/Presence.hpp"
|
||||
#include "Presence.hpp"
|
||||
|
||||
// =============================================================================
|
||||
// Gives the statuses list informations (icons, label, level, status).
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ public:
|
|||
DoNotDisturb = linphone::ConsolidatedPresenceDoNotDisturb,
|
||||
Offline = linphone::ConsolidatedPresenceOffline
|
||||
};
|
||||
|
||||
Q_ENUM(PresenceStatus);
|
||||
|
||||
enum PresenceLevel {
|
||||
|
|
@ -50,13 +49,10 @@ public:
|
|||
Red,
|
||||
White
|
||||
};
|
||||
|
||||
Q_ENUM(PresenceLevel);
|
||||
|
||||
Presence (QObject *parent = Q_NULLPTR) : QObject(parent) {}
|
||||
|
||||
~Presence () = default;
|
||||
|
||||
Q_INVOKABLE static PresenceLevel getPresenceLevel (const PresenceStatus &status);
|
||||
|
||||
Q_INVOKABLE static QString getPresenceStatusAsString (const PresenceStatus &status);
|
||||
|
|
|
|||
|
|
@ -20,16 +20,18 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../../app/paths/Paths.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "app/paths/Paths.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "AccountSettingsModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
#include "SettingsModel.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
static inline AccountSettingsModel::RegistrationState mapLinphoneRegistrationStateToUi (linphone::RegistrationState state) {
|
||||
switch (state) {
|
||||
case linphone::RegistrationStateNone:
|
||||
|
|
@ -64,18 +66,18 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (const shared_ptr<linphone::Pr
|
|||
CoreManager *coreManager = CoreManager::getInstance();
|
||||
shared_ptr<linphone::Core> core = coreManager->getCore();
|
||||
|
||||
list<shared_ptr<linphone::ProxyConfig> > proxyConfigs = core->getProxyConfigList();
|
||||
list<shared_ptr<linphone::ProxyConfig>> proxyConfigs = core->getProxyConfigList();
|
||||
if (find(proxyConfigs.cbegin(), proxyConfigs.cend(), proxyConfig) != proxyConfigs.cend()) {
|
||||
if (proxyConfig->done() == -1) {
|
||||
qWarning() << QStringLiteral("Unable to update proxy config: `%1`.")
|
||||
.arg(::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()));
|
||||
.arg(Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()));
|
||||
return false;
|
||||
}
|
||||
coreManager->getSettingsModel()->configureRlsUri();
|
||||
} else {
|
||||
if (core->addProxyConfig(proxyConfig) == -1) {
|
||||
qWarning() << QStringLiteral("Unable to add proxy config: `%1`.")
|
||||
.arg(::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()));
|
||||
.arg(Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString()));
|
||||
return false;
|
||||
}
|
||||
coreManager->getSettingsModel()->configureRlsUri(proxyConfig);
|
||||
|
|
@ -93,29 +95,29 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
|
|||
{
|
||||
const shared_ptr<const linphone::Address> address = proxyConfig->getIdentityAddress();
|
||||
map["sipAddress"] = address
|
||||
? ::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString())
|
||||
? Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asString())
|
||||
: QString("");
|
||||
}
|
||||
map["serverAddress"] = ::Utils::coreStringToAppString(proxyConfig->getServerAddr());
|
||||
map["serverAddress"] = Utils::coreStringToAppString(proxyConfig->getServerAddr());
|
||||
map["registrationDuration"] = proxyConfig->getPublishExpires();
|
||||
map["transport"] = ::Utils::coreStringToAppString(proxyConfig->getTransport());
|
||||
map["route"] = ::Utils::coreStringToAppString(proxyConfig->getRoute());
|
||||
map["contactParams"] = ::Utils::coreStringToAppString(proxyConfig->getContactParameters());
|
||||
map["transport"] = Utils::coreStringToAppString(proxyConfig->getTransport());
|
||||
map["route"] = Utils::coreStringToAppString(proxyConfig->getRoute());
|
||||
map["contactParams"] = Utils::coreStringToAppString(proxyConfig->getContactParameters());
|
||||
map["avpfInterval"] = proxyConfig->getAvpfRrInterval();
|
||||
map["registerEnabled"] = proxyConfig->registerEnabled();
|
||||
map["publishPresence"] = proxyConfig->publishEnabled();
|
||||
map["avpfEnabled"] = proxyConfig->getAvpfMode() == linphone::AVPFMode::AVPFModeEnabled;
|
||||
map["registrationState"] = ::mapLinphoneRegistrationStateToUi(proxyConfig->getState());
|
||||
map["registrationState"] = mapLinphoneRegistrationStateToUi(proxyConfig->getState());
|
||||
|
||||
shared_ptr<linphone::NatPolicy> natPolicy = proxyConfig->getNatPolicy();
|
||||
if (!natPolicy)
|
||||
natPolicy = proxyConfig->getCore()->createNatPolicy();
|
||||
map["iceEnabled"] = natPolicy->iceEnabled();
|
||||
map["turnEnabled"] = natPolicy->turnEnabled();
|
||||
map["stunServer"] = ::Utils::coreStringToAppString(natPolicy->getStunServer());
|
||||
map["turnUser"] = ::Utils::coreStringToAppString(natPolicy->getStunServerUsername());
|
||||
map["stunServer"] = Utils::coreStringToAppString(natPolicy->getStunServer());
|
||||
map["turnUser"] = Utils::coreStringToAppString(natPolicy->getStunServerUsername());
|
||||
shared_ptr<const linphone::AuthInfo> authInfo = proxyConfig->findAuthInfo();
|
||||
map["turnPassword"] = authInfo ? ::Utils::coreStringToAppString(authInfo->getPasswd()) : QString("");
|
||||
map["turnPassword"] = authInfo ? Utils::coreStringToAppString(authInfo->getPasswd()) : QString("");
|
||||
|
||||
return map;
|
||||
}
|
||||
|
|
@ -146,8 +148,8 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
|
|||
// Sip address.
|
||||
{
|
||||
shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(
|
||||
::Utils::appStringToCoreString(literal)
|
||||
);
|
||||
Utils::appStringToCoreString(literal)
|
||||
);
|
||||
if (!address) {
|
||||
qWarning() << QStringLiteral("Unable to create sip address object from: `%1`.").arg(literal);
|
||||
return false;
|
||||
|
|
@ -155,7 +157,7 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
|
|||
|
||||
if (proxyConfig->setIdentityAddress(address)) {
|
||||
qWarning() << QStringLiteral("Unable to set identity address: `%1`.")
|
||||
.arg(::Utils::coreStringToAppString(address->asStringUriOnly()));
|
||||
.arg(Utils::coreStringToAppString(address->asStringUriOnly()));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -164,15 +166,15 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
|
|||
{
|
||||
QString serverAddress = data["serverAddress"].toString();
|
||||
|
||||
if (proxyConfig->setServerAddr(::Utils::appStringToCoreString(serverAddress))) {
|
||||
if (proxyConfig->setServerAddr(Utils::appStringToCoreString(serverAddress))) {
|
||||
qWarning() << QStringLiteral("Unable to add server address: `%1`.").arg(serverAddress);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
proxyConfig->setPublishExpires(data["registrationDuration"].toInt());
|
||||
proxyConfig->setRoute(::Utils::appStringToCoreString(data["route"].toString()));
|
||||
proxyConfig->setContactParameters(::Utils::appStringToCoreString(data["contactParams"].toString()));
|
||||
proxyConfig->setRoute(Utils::appStringToCoreString(data["route"].toString()));
|
||||
proxyConfig->setContactParameters(Utils::appStringToCoreString(data["contactParams"].toString()));
|
||||
proxyConfig->setAvpfRrInterval(uint8_t(data["avpfInterval"].toInt()));
|
||||
proxyConfig->enableRegister(data["registerEnabled"].toBool());
|
||||
proxyConfig->enablePublish(data["publishPresence"].toBool());
|
||||
|
|
@ -187,22 +189,22 @@ bool AccountSettingsModel::addOrUpdateProxyConfig (
|
|||
natPolicy->enableIce(data["iceEnabled"].toBool());
|
||||
natPolicy->enableStun(data["iceEnabled"].toBool());
|
||||
natPolicy->enableTurn(data["turnEnabled"].toBool());
|
||||
natPolicy->setStunServer(::Utils::appStringToCoreString(data["stunServer"].toString()));
|
||||
natPolicy->setStunServerUsername(::Utils::appStringToCoreString(data["turnUser"].toString()));
|
||||
natPolicy->setStunServer(Utils::appStringToCoreString(data["stunServer"].toString()));
|
||||
natPolicy->setStunServerUsername(Utils::appStringToCoreString(data["turnUser"].toString()));
|
||||
|
||||
shared_ptr<const linphone::AuthInfo> authInfo = proxyConfig->findAuthInfo();
|
||||
shared_ptr<linphone::Core> core = proxyConfig->getCore();
|
||||
if (authInfo) {
|
||||
shared_ptr<linphone::AuthInfo> clonedAuthInfo = authInfo->clone();
|
||||
clonedAuthInfo->setPasswd(::Utils::appStringToCoreString(data["turnPassword"].toString()));
|
||||
clonedAuthInfo->setPasswd(Utils::appStringToCoreString(data["turnPassword"].toString()));
|
||||
|
||||
core->removeAuthInfo(authInfo);
|
||||
core->addAuthInfo(clonedAuthInfo);
|
||||
} else {
|
||||
authInfo = linphone::Factory::get()->createAuthInfo(
|
||||
::Utils::appStringToCoreString(data["turnUser"].toString()),
|
||||
::Utils::appStringToCoreString(data["turnUser"].toString()),
|
||||
::Utils::appStringToCoreString(data["turnPassword"].toString()),
|
||||
Utils::appStringToCoreString(data["turnUser"].toString()),
|
||||
Utils::appStringToCoreString(data["turnUser"].toString()),
|
||||
Utils::appStringToCoreString(data["turnPassword"].toString()),
|
||||
"",
|
||||
"",
|
||||
""
|
||||
|
|
@ -228,8 +230,8 @@ void AccountSettingsModel::addAuthInfo (
|
|||
const QString &password,
|
||||
const QString &userId
|
||||
) {
|
||||
authInfo->setPasswd(::Utils::appStringToCoreString(password));
|
||||
authInfo->setUserid(::Utils::appStringToCoreString(userId));
|
||||
authInfo->setPasswd(Utils::appStringToCoreString(password));
|
||||
authInfo->setUserid(Utils::appStringToCoreString(userId));
|
||||
|
||||
CoreManager::getInstance()->getCore()->addAuthInfo(authInfo);
|
||||
}
|
||||
|
|
@ -244,7 +246,7 @@ QString AccountSettingsModel::getUsername () const {
|
|||
shared_ptr<const linphone::Address> address = getUsedSipAddress();
|
||||
const string displayName = address->getDisplayName();
|
||||
|
||||
return ::Utils::coreStringToAppString(
|
||||
return Utils::coreStringToAppString(
|
||||
displayName.empty() ? address->getUsername() : displayName
|
||||
);
|
||||
}
|
||||
|
|
@ -253,9 +255,9 @@ void AccountSettingsModel::setUsername (const QString &username) {
|
|||
shared_ptr<const linphone::Address> address = getUsedSipAddress();
|
||||
shared_ptr<linphone::Address> newAddress = address->clone();
|
||||
|
||||
if (newAddress->setDisplayName(::Utils::appStringToCoreString(username))) {
|
||||
if (newAddress->setDisplayName(Utils::appStringToCoreString(username))) {
|
||||
qWarning() << QStringLiteral("Unable to set displayName on sip address: `%1`.")
|
||||
.arg(::Utils::coreStringToAppString(newAddress->asStringUriOnly()));
|
||||
.arg(Utils::coreStringToAppString(newAddress->asStringUriOnly()));
|
||||
} else {
|
||||
setUsedSipAddress(newAddress);
|
||||
}
|
||||
|
|
@ -264,18 +266,18 @@ void AccountSettingsModel::setUsername (const QString &username) {
|
|||
}
|
||||
|
||||
QString AccountSettingsModel::getSipAddress () const {
|
||||
return ::Utils::coreStringToAppString(getUsedSipAddress()->asStringUriOnly());
|
||||
return Utils::coreStringToAppString(getUsedSipAddress()->asStringUriOnly());
|
||||
}
|
||||
|
||||
AccountSettingsModel::RegistrationState AccountSettingsModel::getRegistrationState () const {
|
||||
shared_ptr<linphone::ProxyConfig> proxyConfig = CoreManager::getInstance()->getCore()->getDefaultProxyConfig();
|
||||
return proxyConfig ? ::mapLinphoneRegistrationStateToUi(proxyConfig->getState()) : RegistrationStateNotRegistered;
|
||||
return proxyConfig ? mapLinphoneRegistrationStateToUi(proxyConfig->getState()) : RegistrationStateNotRegistered;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString AccountSettingsModel::getPrimaryUsername () const {
|
||||
return ::Utils::coreStringToAppString(
|
||||
return Utils::coreStringToAppString(
|
||||
CoreManager::getInstance()->getCore()->getPrimaryContactParsed()->getUsername()
|
||||
);
|
||||
}
|
||||
|
|
@ -285,7 +287,7 @@ void AccountSettingsModel::setPrimaryUsername (const QString &username) {
|
|||
shared_ptr<linphone::Address> primary = core->getPrimaryContactParsed();
|
||||
|
||||
primary->setUsername(
|
||||
username.isEmpty() ? "linphone" : ::Utils::appStringToCoreString(username)
|
||||
username.isEmpty() ? "linphone" : Utils::appStringToCoreString(username)
|
||||
);
|
||||
core->setPrimaryContact(primary->asString());
|
||||
|
||||
|
|
@ -293,7 +295,7 @@ void AccountSettingsModel::setPrimaryUsername (const QString &username) {
|
|||
}
|
||||
|
||||
QString AccountSettingsModel::getPrimaryDisplayName () const {
|
||||
return ::Utils::coreStringToAppString(
|
||||
return Utils::coreStringToAppString(
|
||||
CoreManager::getInstance()->getCore()->getPrimaryContactParsed()->getDisplayName()
|
||||
);
|
||||
}
|
||||
|
|
@ -302,14 +304,14 @@ void AccountSettingsModel::setPrimaryDisplayName (const QString &displayName) {
|
|||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
shared_ptr<linphone::Address> primary = core->getPrimaryContactParsed();
|
||||
|
||||
primary->setDisplayName(::Utils::appStringToCoreString(displayName));
|
||||
primary->setDisplayName(Utils::appStringToCoreString(displayName));
|
||||
core->setPrimaryContact(primary->asString());
|
||||
|
||||
emit accountSettingsUpdated();
|
||||
}
|
||||
|
||||
QString AccountSettingsModel::getPrimarySipAddress () const {
|
||||
return ::Utils::coreStringToAppString(
|
||||
return Utils::coreStringToAppString(
|
||||
CoreManager::getInstance()->getCore()->getPrimaryContactParsed()->asString()
|
||||
);
|
||||
}
|
||||
|
|
@ -322,13 +324,13 @@ QVariantList AccountSettingsModel::getAccounts () const {
|
|||
|
||||
{
|
||||
QVariantMap account;
|
||||
account["sipAddress"] = ::Utils::coreStringToAppString(core->getPrimaryContactParsed()->asStringUriOnly());
|
||||
account["sipAddress"] = Utils::coreStringToAppString(core->getPrimaryContactParsed()->asStringUriOnly());
|
||||
accounts << account;
|
||||
}
|
||||
|
||||
for (const auto &proxyConfig : core->getProxyConfigList()) {
|
||||
QVariantMap account;
|
||||
account["sipAddress"] = ::Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asStringUriOnly());
|
||||
account["sipAddress"] = Utils::coreStringToAppString(proxyConfig->getIdentityAddress()->asStringUriOnly());
|
||||
account["proxyConfig"].setValue(proxyConfig);
|
||||
accounts << account;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,11 +49,9 @@ public:
|
|||
RegistrationStateNotRegistered,
|
||||
RegistrationStateInProgress
|
||||
};
|
||||
|
||||
Q_ENUM(RegistrationState);
|
||||
|
||||
AccountSettingsModel (QObject *parent = Q_NULLPTR);
|
||||
~AccountSettingsModel () = default;
|
||||
|
||||
bool addOrUpdateProxyConfig (const std::shared_ptr<linphone::ProxyConfig> &proxyConfig);
|
||||
|
||||
|
|
@ -110,6 +108,6 @@ private:
|
|||
);
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::ProxyConfig> );
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<linphone::ProxyConfig>);
|
||||
|
||||
#endif // ACCOUNT_SETTINGS_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -34,11 +34,11 @@
|
|||
using namespace std;
|
||||
|
||||
namespace {
|
||||
constexpr char cDefaultRlsUri[] = "sips:rls@sip.linphone.org";
|
||||
constexpr char cDefaultLogsEmail[] = "linphone-desktop@belledonne-communications.com";
|
||||
constexpr char DefaultRlsUri[] = "sips:rls@sip.linphone.org";
|
||||
constexpr char DefaultLogsEmail[] = "linphone-desktop@belledonne-communications.com";
|
||||
}
|
||||
|
||||
const string SettingsModel::UI_SECTION("ui");
|
||||
const string SettingsModel::UiSection("ui");
|
||||
|
||||
SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
|
||||
mConfig = CoreManager::getInstance()->getCore()->getConfig();
|
||||
|
|
@ -65,10 +65,9 @@ QStringList SettingsModel::getPlaybackDevices () const {
|
|||
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
|
||||
QStringList list;
|
||||
|
||||
for (const auto &device : core->getSoundDevices()) {
|
||||
for (const auto &device : core->getSoundDevices())
|
||||
if (core->soundDeviceCanPlayback(device))
|
||||
list << Utils::coreStringToAppString(device);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -225,17 +224,17 @@ static inline QVariantMap createMapFromVideoDefinition (const shared_ptr<const l
|
|||
QVariantList SettingsModel::getSupportedVideoDefinitions () const {
|
||||
QVariantList list;
|
||||
for (const auto &definition : linphone::Factory::get()->getSupportedVideoDefinitions())
|
||||
list << ::createMapFromVideoDefinition(definition);
|
||||
list << createMapFromVideoDefinition(definition);
|
||||
return list;
|
||||
}
|
||||
|
||||
QVariantMap SettingsModel::getVideoDefinition () const {
|
||||
return ::createMapFromVideoDefinition(CoreManager::getInstance()->getCore()->getPreferredVideoDefinition());
|
||||
return createMapFromVideoDefinition(CoreManager::getInstance()->getCore()->getPreferredVideoDefinition());
|
||||
}
|
||||
|
||||
void SettingsModel::setVideoDefinition (const QVariantMap &definition) {
|
||||
CoreManager::getInstance()->getCore()->setPreferredVideoDefinition(
|
||||
definition.value("__definition").value<shared_ptr<const linphone::VideoDefinition> >()->clone()
|
||||
definition.value("__definition").value<shared_ptr<const linphone::VideoDefinition>>()->clone()
|
||||
);
|
||||
|
||||
emit videoDefinitionChanged(definition);
|
||||
|
|
@ -250,66 +249,66 @@ bool SettingsModel::getVideoSupported () const {
|
|||
// =============================================================================
|
||||
|
||||
int SettingsModel::getAutoAnswerDelay () const {
|
||||
return mConfig->getInt(UI_SECTION, "auto_answer_delay", 0);
|
||||
return mConfig->getInt(UiSection, "auto_answer_delay", 0);
|
||||
}
|
||||
|
||||
void SettingsModel::setAutoAnswerDelay (int delay) {
|
||||
mConfig->setInt(UI_SECTION, "auto_answer_delay", delay);
|
||||
mConfig->setInt(UiSection, "auto_answer_delay", delay);
|
||||
emit autoAnswerDelayChanged(delay);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getAutoAnswerStatus () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "auto_answer", 0);
|
||||
return !!mConfig->getInt(UiSection, "auto_answer", 0);
|
||||
}
|
||||
|
||||
void SettingsModel::setAutoAnswerStatus (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "auto_answer", status);
|
||||
mConfig->setInt(UiSection, "auto_answer", status);
|
||||
emit autoAnswerStatusChanged(status);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getAutoAnswerVideoStatus () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "auto_answer_with_video", 0);
|
||||
return !!mConfig->getInt(UiSection, "auto_answer_with_video", 0);
|
||||
}
|
||||
|
||||
void SettingsModel::setAutoAnswerVideoStatus (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "auto_answer_with_video", status);
|
||||
mConfig->setInt(UiSection, "auto_answer_with_video", status);
|
||||
emit autoAnswerVideoStatusChanged(status);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getCallRecorderEnabled () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "call_recorder_enabled", 1);
|
||||
return !!mConfig->getInt(UiSection, "call_recorder_enabled", 1);
|
||||
}
|
||||
|
||||
void SettingsModel::setCallRecorderEnabled (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "call_recorder_enabled", status);
|
||||
mConfig->setInt(UiSection, "call_recorder_enabled", status);
|
||||
emit callRecorderEnabledChanged(status);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getChatEnabled () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "chat_enabled", 1);
|
||||
return !!mConfig->getInt(UiSection, "chat_enabled", 1);
|
||||
}
|
||||
|
||||
void SettingsModel::setChatEnabled (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "chat_enabled", status);
|
||||
mConfig->setInt(UiSection, "chat_enabled", status);
|
||||
emit chatEnabledChanged(status);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getChatNotificationSoundEnabled () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "chat_sound_notification_enabled", 1);
|
||||
return !!mConfig->getInt(UiSection, "chat_sound_notification_enabled", 1);
|
||||
}
|
||||
|
||||
void SettingsModel::setChatNotificationSoundEnabled (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "chat_sound_notification_enabled", status);
|
||||
mConfig->setInt(UiSection, "chat_sound_notification_enabled", status);
|
||||
emit chatNotificationSoundEnabledChanged(status);
|
||||
}
|
||||
|
||||
|
|
@ -317,12 +316,12 @@ void SettingsModel::setChatNotificationSoundEnabled (bool status) {
|
|||
|
||||
QString SettingsModel::getChatNotificationSoundPath () const {
|
||||
static const string defaultFile = linphone::Factory::get()->getSoundResourcesDir() + "/incoming_chat.wav";
|
||||
return Utils::coreStringToAppString(mConfig->getString(UI_SECTION, "chat_sound_notification_file", defaultFile));
|
||||
return Utils::coreStringToAppString(mConfig->getString(UiSection, "chat_sound_notification_file", defaultFile));
|
||||
}
|
||||
|
||||
void SettingsModel::setChatNotificationSoundPath (const QString &path) {
|
||||
QString cleanedPath = QDir::cleanPath(path);
|
||||
mConfig->setString(UI_SECTION, "chat_sound_notification_file", Utils::appStringToCoreString(cleanedPath));
|
||||
mConfig->setString(UiSection, "chat_sound_notification_file", Utils::appStringToCoreString(cleanedPath));
|
||||
emit chatNotificationSoundPathChanged(cleanedPath);
|
||||
}
|
||||
|
||||
|
|
@ -358,13 +357,13 @@ QVariantList SettingsModel::getSupportedMediaEncryptions () const {
|
|||
QVariantList list;
|
||||
|
||||
if (core->mediaEncryptionSupported(linphone::MediaEncryptionDTLS))
|
||||
list << ::buildEncryptionDescription(MediaEncryptionDtls, "DTLS");
|
||||
list << buildEncryptionDescription(MediaEncryptionDtls, "DTLS");
|
||||
|
||||
if (core->mediaEncryptionSupported(linphone::MediaEncryptionSRTP))
|
||||
list << ::buildEncryptionDescription(MediaEncryptionSrtp, "SRTP");
|
||||
list << buildEncryptionDescription(MediaEncryptionSrtp, "SRTP");
|
||||
|
||||
if (core->mediaEncryptionSupported(linphone::MediaEncryptionZRTP))
|
||||
list << ::buildEncryptionDescription(MediaEncryptionZrtp, "ZRTP");
|
||||
list << buildEncryptionDescription(MediaEncryptionZrtp, "ZRTP");
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -706,12 +705,12 @@ void SettingsModel::setDscpVideo (int dscp) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getRlsUriEnabled () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "rls_uri_enabled", true);
|
||||
return !!mConfig->getInt(UiSection, "rls_uri_enabled", true);
|
||||
}
|
||||
|
||||
void SettingsModel::setRlsUriEnabled (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "rls_uri_enabled", status);
|
||||
mConfig->setString("sip", "rls_uri", status ? cDefaultRlsUri : "");
|
||||
mConfig->setInt(UiSection, "rls_uri_enabled", status);
|
||||
mConfig->setString("sip", "rls_uri", status ? DefaultRlsUri : "");
|
||||
emit rlsUriEnabledChanged(status);
|
||||
}
|
||||
|
||||
|
|
@ -720,7 +719,7 @@ static string getRlsUriDomain () {
|
|||
if (!domain.empty())
|
||||
return domain;
|
||||
|
||||
shared_ptr<linphone::Address> linphoneAddress = CoreManager::getInstance()->getCore()->createAddress(cDefaultRlsUri);
|
||||
shared_ptr<linphone::Address> linphoneAddress = CoreManager::getInstance()->getCore()->createAddress(DefaultRlsUri);
|
||||
Q_CHECK_PTR(linphoneAddress);
|
||||
domain = linphoneAddress->getDomain();
|
||||
return domain;
|
||||
|
|
@ -737,7 +736,7 @@ void SettingsModel::configureRlsUri () {
|
|||
const string domain = getRlsUriDomain();
|
||||
for (const auto &proxyConfig : CoreManager::getInstance()->getCore()->getProxyConfigList())
|
||||
if (proxyConfig->getDomain() == domain) {
|
||||
mConfig->setString("sip", "rls_uri", cDefaultRlsUri);
|
||||
mConfig->setString("sip", "rls_uri", DefaultRlsUri);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -752,7 +751,7 @@ void SettingsModel::configureRlsUri (const shared_ptr<const linphone::ProxyConfi
|
|||
|
||||
const string domain = getRlsUriDomain();
|
||||
if (proxyConfig->getDomain() == domain) {
|
||||
mConfig->setString("sip", "rls_uri", cDefaultRlsUri);
|
||||
mConfig->setString("sip", "rls_uri", DefaultRlsUri);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -766,14 +765,14 @@ void SettingsModel::configureRlsUri (const shared_ptr<const linphone::ProxyConfi
|
|||
QString SettingsModel::getSavedScreenshotsFolder () const {
|
||||
return QDir::cleanPath(
|
||||
Utils::coreStringToAppString(
|
||||
mConfig->getString(UI_SECTION, "saved_screenshots_folder", Paths::getCapturesDirPath())
|
||||
mConfig->getString(UiSection, "saved_screenshots_folder", Paths::getCapturesDirPath())
|
||||
)
|
||||
) + QDir::separator();
|
||||
}
|
||||
|
||||
void SettingsModel::setSavedScreenshotsFolder (const QString &folder) {
|
||||
QString cleanedFolder = QDir::cleanPath(folder) + QDir::separator();
|
||||
mConfig->setString(UI_SECTION, "saved_screenshots_folder", Utils::appStringToCoreString(cleanedFolder));
|
||||
mConfig->setString(UiSection, "saved_screenshots_folder", Utils::appStringToCoreString(cleanedFolder));
|
||||
emit savedScreenshotsFolderChanged(cleanedFolder);
|
||||
}
|
||||
|
||||
|
|
@ -782,14 +781,14 @@ void SettingsModel::setSavedScreenshotsFolder (const QString &folder) {
|
|||
QString SettingsModel::getSavedVideosFolder () const {
|
||||
return QDir::cleanPath(
|
||||
Utils::coreStringToAppString(
|
||||
mConfig->getString(UI_SECTION, "saved_videos_folder", Paths::getCapturesDirPath())
|
||||
mConfig->getString(UiSection, "saved_videos_folder", Paths::getCapturesDirPath())
|
||||
)
|
||||
) + QDir::separator();
|
||||
}
|
||||
|
||||
void SettingsModel::setSavedVideosFolder (const QString &folder) {
|
||||
QString cleanedFolder = QDir::cleanPath(folder) + QDir::separator();
|
||||
mConfig->setString(UI_SECTION, "saved_videos_folder", Utils::appStringToCoreString(cleanedFolder));
|
||||
mConfig->setString(UiSection, "saved_videos_folder", Utils::appStringToCoreString(cleanedFolder));
|
||||
emit savedVideosFolderChanged(cleanedFolder);
|
||||
}
|
||||
|
||||
|
|
@ -798,14 +797,14 @@ void SettingsModel::setSavedVideosFolder (const QString &folder) {
|
|||
QString SettingsModel::getDownloadFolder () const {
|
||||
return QDir::cleanPath(
|
||||
Utils::coreStringToAppString(
|
||||
mConfig->getString(UI_SECTION, "download_folder", Paths::getDownloadDirPath())
|
||||
mConfig->getString(UiSection, "download_folder", Paths::getDownloadDirPath())
|
||||
)
|
||||
) + QDir::separator();
|
||||
}
|
||||
|
||||
void SettingsModel::setDownloadFolder (const QString &folder) {
|
||||
QString cleanedFolder = QDir::cleanPath(folder) + QDir::separator();
|
||||
mConfig->setString(UI_SECTION, "download_folder", Utils::appStringToCoreString(cleanedFolder));
|
||||
mConfig->setString(UiSection, "download_folder", Utils::appStringToCoreString(cleanedFolder));
|
||||
emit downloadFolderChanged(cleanedFolder);
|
||||
}
|
||||
|
||||
|
|
@ -825,11 +824,11 @@ void SettingsModel::setRemoteProvisioning (const QString &remoteProvisioning) {
|
|||
// -----------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getExitOnClose () const {
|
||||
return !!mConfig->getInt(UI_SECTION, "exit_on_close", 0);
|
||||
return !!mConfig->getInt(UiSection, "exit_on_close", 0);
|
||||
}
|
||||
|
||||
void SettingsModel::setExitOnClose (bool value) {
|
||||
mConfig->setInt(UI_SECTION, "exit_on_close", value);
|
||||
mConfig->setInt(UiSection, "exit_on_close", value);
|
||||
emit exitOnCloseChanged(value);
|
||||
}
|
||||
|
||||
|
|
@ -844,7 +843,7 @@ QString SettingsModel::getLogsFolder () const {
|
|||
void SettingsModel::setLogsFolder (const QString &folder) {
|
||||
// Do not update path in linphone core.
|
||||
// Just update the config file.
|
||||
mConfig->setString(UI_SECTION, "logs_folder", Utils::appStringToCoreString(folder));
|
||||
mConfig->setString(UiSection, "logs_folder", Utils::appStringToCoreString(folder));
|
||||
|
||||
emit logsFolderChanged(folder);
|
||||
}
|
||||
|
|
@ -872,7 +871,7 @@ bool SettingsModel::getLogsEnabled () const {
|
|||
}
|
||||
|
||||
void SettingsModel::setLogsEnabled (bool status) {
|
||||
mConfig->setInt(UI_SECTION, "logs_enabled", status);
|
||||
mConfig->setInt(UiSection, "logs_enabled", status);
|
||||
Logger::getInstance()->enable(status);
|
||||
emit logsEnabledChanged(status);
|
||||
}
|
||||
|
|
@ -881,12 +880,12 @@ void SettingsModel::setLogsEnabled (bool status) {
|
|||
|
||||
QString SettingsModel::getLogsEmail () const {
|
||||
return Utils::coreStringToAppString(
|
||||
mConfig->getString(UI_SECTION, "logs_email", cDefaultLogsEmail)
|
||||
mConfig->getString(UiSection, "logs_email", DefaultLogsEmail)
|
||||
);
|
||||
}
|
||||
|
||||
void SettingsModel::setLogsEmail (const QString &email) {
|
||||
mConfig->setString(UI_SECTION, "logs_email", Utils::appStringToCoreString(email));
|
||||
mConfig->setString(UiSection, "logs_email", Utils::appStringToCoreString(email));
|
||||
emit logsEmailChanged(email);
|
||||
}
|
||||
|
||||
|
|
@ -894,19 +893,19 @@ void SettingsModel::setLogsEmail (const QString &email) {
|
|||
|
||||
QString SettingsModel::getLogsFolder (const shared_ptr<linphone::Config> &config) {
|
||||
return Utils::coreStringToAppString(config
|
||||
? config->getString(UI_SECTION, "logs_folder", Paths::getLogsDirPath())
|
||||
? config->getString(UiSection, "logs_folder", Paths::getLogsDirPath())
|
||||
: Paths::getLogsDirPath());
|
||||
}
|
||||
|
||||
bool SettingsModel::getLogsEnabled (const shared_ptr<linphone::Config> &config) {
|
||||
return config ? config->getInt(UI_SECTION, "logs_enabled", false) : false;
|
||||
return config ? config->getInt(UiSection, "logs_enabled", false) : false;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
bool SettingsModel::getDeveloperSettingsEnabled () const {
|
||||
#ifdef DEBUG
|
||||
return !!mConfig->getInt(UI_SECTION, "developer_settings", 0);
|
||||
return !!mConfig->getInt(UiSection, "developer_settings", 0);
|
||||
#else
|
||||
return false;
|
||||
#endif // ifdef DEBUG
|
||||
|
|
@ -914,7 +913,7 @@ bool SettingsModel::getDeveloperSettingsEnabled () const {
|
|||
|
||||
void SettingsModel::setDeveloperSettingsEnabled (bool status) {
|
||||
#ifdef DEBUG
|
||||
mConfig->setInt(UI_SECTION, "developer_settings", status);
|
||||
mConfig->setInt(UiSection, "developer_settings", status);
|
||||
emit developerSettingsEnabledChanged(status);
|
||||
#else
|
||||
qWarning() << QStringLiteral("Unable to change developer settings mode in release version.");
|
||||
|
|
|
|||
|
|
@ -148,7 +148,6 @@ public:
|
|||
MediaEncryptionSrtp = linphone::MediaEncryptionSRTP,
|
||||
MediaEncryptionZrtp = linphone::MediaEncryptionZRTP
|
||||
};
|
||||
|
||||
Q_ENUM(MediaEncryption);
|
||||
|
||||
enum LimeState {
|
||||
|
|
@ -156,7 +155,6 @@ public:
|
|||
LimeStateMandatory = linphone::LimeStateMandatory,
|
||||
LimeStatePreferred = linphone::LimeStatePreferred
|
||||
};
|
||||
|
||||
Q_ENUM(LimeState);
|
||||
|
||||
SettingsModel (QObject *parent = Q_NULLPTR);
|
||||
|
|
@ -346,7 +344,7 @@ public:
|
|||
bool getDeveloperSettingsEnabled () const;
|
||||
void setDeveloperSettingsEnabled (bool status);
|
||||
|
||||
static const std::string UI_SECTION;
|
||||
static const std::string UiSection;
|
||||
|
||||
// ===========================================================================
|
||||
// SIGNALS.
|
||||
|
|
@ -446,6 +444,6 @@ private:
|
|||
std::shared_ptr<linphone::Config> mConfig;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<const linphone::VideoDefinition> );
|
||||
Q_DECLARE_METATYPE(std::shared_ptr<const linphone::VideoDefinition>);
|
||||
|
||||
#endif // SETTINGS_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -23,10 +23,12 @@
|
|||
#ifndef SIP_ADDRESS_OBSERVER_H_
|
||||
#define SIP_ADDRESS_OBSERVER_H_
|
||||
|
||||
#include "../contact/ContactModel.hpp"
|
||||
#include "components/presence/Presence.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class ContactModel;
|
||||
|
||||
class SipAddressObserver : public QObject {
|
||||
friend class SipAddressesModel;
|
||||
|
||||
|
|
@ -40,7 +42,6 @@ class SipAddressObserver : public QObject {
|
|||
|
||||
public:
|
||||
SipAddressObserver (const QString &sipAddress);
|
||||
~SipAddressObserver () = default;
|
||||
|
||||
signals:
|
||||
void contactChanged (ContactModel *contact);
|
||||
|
|
|
|||
|
|
@ -21,17 +21,24 @@
|
|||
*/
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QUrl>
|
||||
|
||||
#include "../../utils/LinphoneUtils.hpp"
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/call/CallModel.hpp"
|
||||
#include "components/chat/ChatModel.hpp"
|
||||
#include "components/contact/ContactModel.hpp"
|
||||
#include "components/contact/VcardModel.hpp"
|
||||
#include "components/contacts/ContactsListModel.hpp"
|
||||
#include "components/core/CoreHandlers.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "utils/LinphoneUtils.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "SipAddressesModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
SipAddressesModel::SipAddressesModel (QObject *parent) : QAbstractListModel(parent) {
|
||||
initSipAddresses();
|
||||
|
||||
|
|
@ -129,7 +136,7 @@ SipAddressObserver *SipAddressesModel::getSipAddressObserver (const QString &sip
|
|||
|
||||
QString SipAddressesModel::getTransportFromSipAddress (const QString &sipAddress) const {
|
||||
const shared_ptr<const linphone::Address> address = linphone::Factory::get()->createAddress(
|
||||
::Utils::appStringToCoreString(sipAddress)
|
||||
Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
|
||||
if (!address)
|
||||
|
|
@ -151,26 +158,26 @@ QString SipAddressesModel::getTransportFromSipAddress (const QString &sipAddress
|
|||
|
||||
QString SipAddressesModel::addTransportToSipAddress (const QString &sipAddress, const QString &transport) const {
|
||||
shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(
|
||||
::Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
|
||||
if (!address)
|
||||
return QString("");
|
||||
|
||||
address->setTransport(LinphoneUtils::stringToTransportType(transport.toUpper()));
|
||||
|
||||
return ::Utils::coreStringToAppString(address->asString());
|
||||
return Utils::coreStringToAppString(address->asString());
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
QString SipAddressesModel::interpretSipAddress (const QString &sipAddress, bool checkUsername) {
|
||||
shared_ptr<linphone::Address> lAddress = CoreManager::getInstance()->getCore()->interpretUrl(
|
||||
::Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
|
||||
if (lAddress && (!checkUsername || !lAddress->getUsername().empty()))
|
||||
return ::Utils::coreStringToAppString(lAddress->asStringUriOnly());
|
||||
return Utils::coreStringToAppString(lAddress->asStringUriOnly());
|
||||
return QString("");
|
||||
}
|
||||
|
||||
|
|
@ -180,14 +187,14 @@ QString SipAddressesModel::interpretSipAddress (const QUrl &sipAddress) {
|
|||
|
||||
bool SipAddressesModel::addressIsValid (const QString &address) {
|
||||
return !!linphone::Factory::get()->createAddress(
|
||||
::Utils::appStringToCoreString(address)
|
||||
Utils::appStringToCoreString(address)
|
||||
);
|
||||
}
|
||||
|
||||
bool SipAddressesModel::sipAddressIsValid (const QString &sipAddress) {
|
||||
shared_ptr<linphone::Address> address = linphone::Factory::get()->createAddress(
|
||||
::Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
Utils::appStringToCoreString(sipAddress)
|
||||
);
|
||||
return address && !address->getUsername().empty();
|
||||
}
|
||||
|
||||
|
|
@ -272,7 +279,7 @@ void SipAddressesModel::handleSipAddressRemoved (ContactModel *contact, const QS
|
|||
}
|
||||
|
||||
void SipAddressesModel::handleMessageReceived (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
const QString sipAddress = ::Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly());
|
||||
const QString sipAddress = Utils::coreStringToAppString(message->getFromAddress()->asStringUriOnly());
|
||||
addOrUpdateSipAddress(sipAddress, message);
|
||||
}
|
||||
|
||||
|
|
@ -286,7 +293,7 @@ void SipAddressesModel::handleCallStateChanged (
|
|||
|
||||
if (state == linphone::CallStateEnd || state == linphone::CallStateError)
|
||||
addOrUpdateSipAddress(
|
||||
::Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly()), call
|
||||
Utils::coreStringToAppString(call->getRemoteAddress()->asStringUriOnly()), call
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -347,7 +354,7 @@ void SipAddressesModel::handleAllEntriesRemoved (const QString &sipAddress) {
|
|||
|
||||
void SipAddressesModel::handleMessageSent (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
addOrUpdateSipAddress(
|
||||
::Utils::coreStringToAppString(message->getToAddress()->asStringUriOnly()),
|
||||
Utils::coreStringToAppString(message->getToAddress()->asStringUriOnly()),
|
||||
message
|
||||
);
|
||||
}
|
||||
|
|
@ -366,7 +373,7 @@ void SipAddressesModel::handleMessagesCountReset (const QString &sipAddress) {
|
|||
}
|
||||
|
||||
void SipAddressesModel::handlerIsComposingChanged (const shared_ptr<linphone::ChatRoom> &chatRoom) {
|
||||
auto it = mSipAddresses.find(::Utils::coreStringToAppString(chatRoom->getPeerAddress()->asStringUriOnly()));
|
||||
auto it = mSipAddresses.find(Utils::coreStringToAppString(chatRoom->getPeerAddress()->asStringUriOnly()));
|
||||
if (it != mSipAddresses.end()) {
|
||||
(*it)["isComposing"] = chatRoom->isRemoteComposing();
|
||||
|
||||
|
|
@ -469,12 +476,12 @@ void SipAddressesModel::initSipAddresses () {
|
|||
|
||||
// Get sip addresses from chatrooms.
|
||||
for (const auto &chatRoom : core->getChatRooms()) {
|
||||
list<shared_ptr<linphone::ChatMessage> > history = chatRoom->getHistory(0);
|
||||
list<shared_ptr<linphone::ChatMessage>> history = chatRoom->getHistory(0);
|
||||
|
||||
if (history.size() == 0)
|
||||
continue;
|
||||
|
||||
QString sipAddress = ::Utils::coreStringToAppString(chatRoom->getPeerAddress()->asStringUriOnly());
|
||||
QString sipAddress = Utils::coreStringToAppString(chatRoom->getPeerAddress()->asStringUriOnly());
|
||||
|
||||
QVariantMap map;
|
||||
map["sipAddress"] = sipAddress;
|
||||
|
|
@ -487,7 +494,7 @@ void SipAddressesModel::initSipAddresses () {
|
|||
// Get sip addresses from calls.
|
||||
QSet<QString> addressDone;
|
||||
for (const auto &callLog : core->getCallLogs()) {
|
||||
const QString sipAddress = ::Utils::coreStringToAppString(callLog->getRemoteAddress()->asStringUriOnly());
|
||||
const QString sipAddress = Utils::coreStringToAppString(callLog->getRemoteAddress()->asStringUriOnly());
|
||||
|
||||
if (addressDone.contains(sipAddress))
|
||||
continue; // Already used.
|
||||
|
|
|
|||
|
|
@ -24,12 +24,13 @@
|
|||
#define SIP_ADDRESSES_MODEL_H_
|
||||
|
||||
#include <QAbstractListModel>
|
||||
#include <QUrl>
|
||||
|
||||
#include "SipAddressObserver.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
class QUrl;
|
||||
|
||||
class ChatModel;
|
||||
class CoreHandlers;
|
||||
|
||||
|
|
@ -38,7 +39,6 @@ class SipAddressesModel : public QAbstractListModel {
|
|||
|
||||
public:
|
||||
SipAddressesModel (QObject *parent = Q_NULLPTR);
|
||||
~SipAddressesModel () = default;
|
||||
|
||||
int rowCount (const QModelIndex &index = QModelIndex()) const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,21 +20,24 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/contact/ContactModel.hpp"
|
||||
#include "components/contact/VcardModel.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
|
||||
#include "SipAddressesModel.hpp"
|
||||
#include "SipAddressesProxyModel.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
||||
namespace {
|
||||
constexpr int cWeightPos0 = 5;
|
||||
constexpr int cWeightPos1 = 4;
|
||||
constexpr int cWeightPos2 = 3;
|
||||
constexpr int cWeightPos3 = 2;
|
||||
constexpr int cWeightPosOther = 1;
|
||||
constexpr int WeightPos0 = 5;
|
||||
constexpr int WeightPos1 = 4;
|
||||
constexpr int WeightPos2 = 3;
|
||||
constexpr int WeightPos3 = 2;
|
||||
constexpr int WeightPosOther = 1;
|
||||
}
|
||||
|
||||
const QRegExp SipAddressesProxyModel::mSearchSeparators("^[^_.-;@ ][_.-;@ ]");
|
||||
const QRegExp SipAddressesProxyModel::SearchSeparators("^[^_.-;@ ][_.-;@ ]");
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
|
@ -111,19 +114,19 @@ int SipAddressesProxyModel::computeStringWeight (const QString &string) const {
|
|||
int offset = -1;
|
||||
|
||||
while ((index = string.indexOf(mFilter, index + 1, Qt::CaseInsensitive)) != -1) {
|
||||
int tmpOffset = index - string.lastIndexOf(mSearchSeparators, index) - 1;
|
||||
int tmpOffset = index - string.lastIndexOf(SearchSeparators, index) - 1;
|
||||
if ((tmpOffset != -1 && tmpOffset < offset) || offset == -1)
|
||||
if ((offset = tmpOffset) == 0) break;
|
||||
}
|
||||
|
||||
switch (offset) {
|
||||
case -1: return 0;
|
||||
case 0: return cWeightPos0;
|
||||
case 1: return cWeightPos1;
|
||||
case 2: return cWeightPos2;
|
||||
case 3: return cWeightPos3;
|
||||
case 0: return WeightPos0;
|
||||
case 1: return WeightPos1;
|
||||
case 2: return WeightPos2;
|
||||
case 3: return WeightPos3;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return cWeightPosOther;
|
||||
return WeightPosOther;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class SipAddressesProxyModel : public QSortFilterProxyModel {
|
|||
|
||||
public:
|
||||
SipAddressesProxyModel (QObject *parent = Q_NULLPTR);
|
||||
~SipAddressesProxyModel () = default;
|
||||
|
||||
Q_INVOKABLE void setFilter (const QString &pattern);
|
||||
|
||||
|
|
@ -46,7 +45,7 @@ private:
|
|||
|
||||
QString mFilter;
|
||||
|
||||
static const QRegExp mSearchSeparators;
|
||||
static const QRegExp SearchSeparators;
|
||||
};
|
||||
|
||||
#endif // SIP_ADDRESSES_PROXY_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -22,17 +22,18 @@
|
|||
|
||||
#include <QTimer>
|
||||
|
||||
#include "../../utils/Utils.hpp"
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/settings/SettingsModel.hpp"
|
||||
#include "utils/Utils.hpp"
|
||||
|
||||
#include "SoundPlayer.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
int cForceCloseTimerInterval = 20;
|
||||
int ForceCloseTimerInterval = 20;
|
||||
}
|
||||
|
||||
class SoundPlayer::Handlers : public linphone::PlayerListener {
|
||||
|
|
@ -60,7 +61,7 @@ private:
|
|||
|
||||
SoundPlayer::SoundPlayer (QObject *parent) : QObject(parent) {
|
||||
mForceCloseTimer = new QTimer(this);
|
||||
mForceCloseTimer->setInterval(cForceCloseTimerInterval);
|
||||
mForceCloseTimer->setInterval(ForceCloseTimerInterval);
|
||||
|
||||
QObject::connect(mForceCloseTimer, &QTimer::timeout, this, &SoundPlayer::handleEof);
|
||||
|
||||
|
|
@ -98,7 +99,7 @@ void SoundPlayer::play () {
|
|||
|
||||
if (
|
||||
(mPlaybackState == SoundPlayer::StoppedState || mPlaybackState == SoundPlayer::ErrorState) &&
|
||||
mInternalPlayer->open(::Utils::appStringToCoreString(mSource))
|
||||
mInternalPlayer->open(Utils::appStringToCoreString(mSource))
|
||||
) {
|
||||
qWarning() << QStringLiteral("Unable to open: `%1`").arg(mSource);
|
||||
return;
|
||||
|
|
@ -140,8 +141,8 @@ void SoundPlayer::buildInternalPlayer () {
|
|||
SettingsModel *settingsModel = coreManager->getSettingsModel();
|
||||
|
||||
mInternalPlayer = coreManager->getCore()->createLocalPlayer(
|
||||
::Utils::appStringToCoreString(settingsModel->getRingerDevice()), "", nullptr
|
||||
);
|
||||
Utils::appStringToCoreString(settingsModel->getRingerDevice()), "", nullptr
|
||||
);
|
||||
mInternalPlayer->setListener(mHandlers);
|
||||
|
||||
QObject::connect(settingsModel, &SettingsModel::ringerDeviceChanged, this, [this] {
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ public:
|
|||
StoppedState,
|
||||
ErrorState
|
||||
};
|
||||
|
||||
Q_ENUM(PlaybackState);
|
||||
|
||||
SoundPlayer (QObject *parent = Q_NULLPTR);
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@
|
|||
|
||||
#include "TelephoneNumbersModel.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
// =============================================================================
|
||||
|
||||
const QList<QPair<QLocale::Country, QString> > TelephoneNumbersModel::mCountryCodes = {
|
||||
using namespace std;
|
||||
|
||||
const QList<QPair<QLocale::Country, QString>> TelephoneNumbersModel::mCountryCodes = {
|
||||
{ QLocale::Afghanistan, "93" },
|
||||
{ QLocale::Albania, "355" },
|
||||
{ QLocale::Algeria, "213" },
|
||||
|
|
@ -289,9 +289,9 @@ QVariant TelephoneNumbersModel::data (const QModelIndex &index, int role) const
|
|||
int TelephoneNumbersModel::getDefaultIndex () const {
|
||||
QLocale::Country country = QLocale().country();
|
||||
const auto it = find_if(
|
||||
mCountryCodes.cbegin(), mCountryCodes.cend(), [&country](const QPair<QLocale::Country, QString> &pair) {
|
||||
return country == pair.first;
|
||||
}
|
||||
);
|
||||
mCountryCodes.cbegin(), mCountryCodes.cend(), [&country](const QPair<QLocale::Country, QString> &pair) {
|
||||
return country == pair.first;
|
||||
}
|
||||
);
|
||||
return it != mCountryCodes.cend() ? int(distance(mCountryCodes.cbegin(), it)) : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ class TelephoneNumbersModel : public QAbstractListModel {
|
|||
|
||||
public:
|
||||
TelephoneNumbersModel (QObject *parent = Q_NULLPTR);
|
||||
~TelephoneNumbersModel () = default;
|
||||
|
||||
int rowCount (const QModelIndex &index = QModelIndex()) const override;
|
||||
|
||||
|
|
@ -45,7 +44,7 @@ public:
|
|||
private:
|
||||
int getDefaultIndex () const;
|
||||
|
||||
static const QList<QPair<QLocale::Country, QString> > mCountryCodes;
|
||||
static const QList<QPair<QLocale::Country, QString>> mCountryCodes;
|
||||
};
|
||||
|
||||
#endif // ifndef TELEPHONE_NUMBERS_MODEL_H_
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include "../core/CoreManager.hpp"
|
||||
#include "components/core/CoreManager.hpp"
|
||||
#include "components/sip-addresses/SipAddressesModel.hpp"
|
||||
|
||||
#include "TimelineModel.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class TimelineModel : public QSortFilterProxyModel {
|
|||
|
||||
public:
|
||||
TimelineModel (QObject *parent = Q_NULLPTR);
|
||||
~TimelineModel () = default;
|
||||
|
||||
QHash<int, QByteArray> roleNames () const override;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include <QDesktopServices>
|
||||
|
||||
#include "../sip-addresses/SipAddressesModel.hpp"
|
||||
#include "components/sip-addresses/SipAddressesModel.hpp"
|
||||
|
||||
#include "UrlHandlers.hpp"
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class UrlHandlers : public QObject {
|
|||
|
||||
public:
|
||||
UrlHandlers (QObject *parent = Q_NULLPTR);
|
||||
~UrlHandlers () = default;
|
||||
|
||||
public slots:
|
||||
void handleSip (const QUrl &url);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
* Author: Ronan Abhamon
|
||||
*/
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include "LinphoneUtils.hpp"
|
||||
|
||||
// =============================================================================
|
||||
|
|
|
|||
|
|
@ -24,29 +24,27 @@
|
|||
#define LINPHONE_UTILS_H_
|
||||
|
||||
#include <linphone++/linphone.hh>
|
||||
#include <QString>
|
||||
|
||||
// =============================================================================
|
||||
|
||||
#define WINDOW_ICON_PATH ":/assets/images/linphone_logo.svg"
|
||||
|
||||
#define VU_MIN (-20.f)
|
||||
#define VU_MAX (4.f)
|
||||
class QString;
|
||||
|
||||
namespace LinphoneUtils {
|
||||
inline float computeVu (float volume) {
|
||||
if (volume < VU_MIN)
|
||||
constexpr float VuMin = -20.f;
|
||||
constexpr float VuMax = 4.f;
|
||||
|
||||
if (volume < VuMin)
|
||||
return 0.f;
|
||||
if (volume > VU_MAX)
|
||||
if (volume > VuMax)
|
||||
return 1.f;
|
||||
|
||||
return (volume - VU_MIN) / (VU_MAX - VU_MIN);
|
||||
return (volume - VuMin) / (VuMax - VuMin);
|
||||
}
|
||||
|
||||
linphone::TransportType stringToTransportType (const QString &transport);
|
||||
|
||||
static constexpr char WindowIconPath[] = ":/assets/images/linphone_logo.svg";
|
||||
}
|
||||
|
||||
#undef VU_MIN
|
||||
#undef VU_MAX
|
||||
|
||||
#endif // ifndef LINPHONE_UTILS_H_
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
// =============================================================================
|
||||
|
||||
namespace {
|
||||
constexpr int cSafeFilePathLimit = 100;
|
||||
constexpr int SafeFilePathLimit = 100;
|
||||
}
|
||||
|
||||
char *Utils::rstrstr (const char *a, const char *b) {
|
||||
|
|
@ -58,7 +58,7 @@ QString Utils::getSafeFilePath (const QString &filePath, bool *soFarSoGood) {
|
|||
const QString prefix = QStringLiteral("%1/%2").arg(info.absolutePath()).arg(info.baseName());
|
||||
const QString ext = info.completeSuffix();
|
||||
|
||||
for (int i = 1; i < cSafeFilePathLimit; ++i) {
|
||||
for (int i = 1; i < SafeFilePathLimit; ++i) {
|
||||
QString safePath = QStringLiteral("%1 (%3).%4").arg(prefix).arg(i).arg(ext);
|
||||
if (!QFileInfo::exists(safePath))
|
||||
return safePath;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue