Centralize constants + fix on conference URI by using defaults

This commit is contained in:
Julien Wadel 2021-08-24 18:55:14 +02:00
parent dabb628296
commit 4d375b1f35
23 changed files with 360 additions and 337 deletions

View file

@ -190,15 +190,16 @@ set(SOURCES
src/components/timeline/TimelineListModel.cpp
src/components/timeline/TimelineProxyModel.cpp
src/components/url-handlers/UrlHandlers.cpp
src/utils/LinphoneEnums.cpp
src/utils/Constants.cpp
src/utils/LinphoneEnums.cpp
src/utils/MediastreamerUtils.cpp
src/utils/QExifImageHeader.cpp
src/utils/Utils.cpp
src/utils/hacks/ChatRoomInitializer.cpp
src/utils/plugins/PluginsManager.cpp
src/utils/hacks/ChatRoomInitializer.cpp
src/utils/plugins/PluginsManager.cpp
)
set(PLUGIN_SOURCES src/utils/plugins/PluginDataAPI.cpp
src/utils/plugins/PluginNetworkHelper.cpp
src/utils/plugins/PluginNetworkHelper.cpp
src/utils/plugins/LinphonePlugin.cpp
)
@ -283,7 +284,7 @@ set(HEADERS
src/components/settings/SettingsModel.hpp
src/components/sip-addresses/SipAddressesModel.hpp
src/components/sip-addresses/SipAddressesProxyModel.hpp
src/components/sip-addresses/SipAddressesSorter.hpp
src/components/sip-addresses/SipAddressesSorter.hpp
src/components/sip-addresses/SipAddressObserver.hpp
src/components/sound-player/SoundPlayer.hpp
src/components/telephone-numbers/TelephoneNumbersModel.hpp
@ -291,17 +292,18 @@ set(HEADERS
src/components/timeline/TimelineListModel.hpp
src/components/timeline/TimelineProxyModel.hpp
src/components/url-handlers/UrlHandlers.hpp
src/utils/LinphoneEnums.hpp
src/utils/Constants.hpp
src/utils/LinphoneEnums.hpp
src/utils/MediastreamerUtils.hpp
src/utils/QExifImageHeader.hpp
src/utils/Utils.hpp
src/utils/hacks/ChatRoomInitializer.hpp
src/utils/hacks/ChatRoomInitializer.hpp
src/utils/plugins/PluginsManager.hpp
)
set(PLUGIN_HEADERS
include/LinphoneApp/PluginDataAPI.hpp
include/LinphoneApp/PluginDataAPI.hpp
include/LinphoneApp/PluginNetworkHelper.hpp
include/LinphoneApp/LinphonePlugin.hpp)
include/LinphoneApp/LinphonePlugin.hpp)
list(APPEND SOURCES include/LinphoneApp/PluginExample.json)
set(MAIN_FILE src/app/main.cpp)

View file

@ -45,6 +45,7 @@
#include "providers/ThumbnailProvider.hpp"
#include "translator/DefaultTranslator.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "components/other/desktop-tools/DesktopTools.hpp"
#include "components/timeline/TimelineModel.hpp"
@ -60,26 +61,6 @@
using namespace std;
namespace {
constexpr char DefaultLocale[] = "en";
constexpr char LanguagePath[] = ":/languages/";
// The main windows of Linphone desktop.
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";
#ifdef ENABLE_UPDATE_CHECK
constexpr int VersionUpdateCheckInterval = 86400000; // 24 hours in milliseconds.
#endif // ifdef ENABLE_UPDATE_CHECK
constexpr char MainQmlUri[] = "Linphone";
constexpr char AttachVirtualWindowMethodName[] = "attachVirtualWindow";
constexpr char AboutPath[] = "qrc:/ui/views/App/Main/Dialogs/About.qml";
constexpr char AssistantViewName[] = "Assistant";
#ifdef Q_OS_LINUX
const QString AutoStartDirectory(QDir::homePath().append(QStringLiteral("/.config/autostart/")));
#elif defined(Q_OS_MACOS)
@ -160,7 +141,7 @@ namespace {
// -----------------------------------------------------------------------------
static inline bool installLocale (App &app, QTranslator &translator, const QLocale &locale) {
return translator.load(locale, LanguagePath) && app.installTranslator(&translator);
return translator.load(locale, Constants::LanguagePath) && app.installTranslator(&translator);
}
static inline string getConfigPathIfExists (const QCommandLineParser &parser) {
@ -221,7 +202,7 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U
connect(this, SIGNAL(applicationStateChanged(Qt::ApplicationState)), this, SLOT(stateChanged(Qt::ApplicationState)));
setWindowIcon(QIcon(Utils::WindowIconPath));
setWindowIcon(QIcon(Constants::WindowIconPath));
createParser();
mParser->process(*this);
@ -233,7 +214,7 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true, Mode::U
Logger::getInstance()->setVerbose(true);
// List available locales.
for (const auto &locale : QDir(LanguagePath).entryList())
for (const auto &locale : QDir(Constants::LanguagePath).entryList())
mAvailableLocales << QLocale(locale);
// Init locale.
@ -409,7 +390,7 @@ void App::initContentApp () {
// Load main view.
qInfo() << QStringLiteral("Loading main view...");
mEngine->load(QUrl(QmlViewMainWindow));
mEngine->load(QUrl(Constants::QmlViewMainWindow));
if (mEngine->rootObjects().isEmpty())
qFatal("Unable to open main window.");
@ -535,7 +516,7 @@ static QObject *makeSharedSingleton (QQmlEngine *, QJSEngine *) {
template<typename T, T *(*function)(void)>
static inline void registerSharedSingletonType (const char *name) {
qmlRegisterSingletonType<T>(MainQmlUri, 1, 0, name, makeSharedSingleton<T, function>);
qmlRegisterSingletonType<T>(Constants::MainQmlUri, 1, 0, name, makeSharedSingleton<T, function>);
}
template<typename T, T *(CoreManager::*function)() const>
@ -547,24 +528,24 @@ static QObject *makeSharedSingleton (QQmlEngine *, QJSEngine *) {
template<typename T, T *(CoreManager::*function)() const>
static inline void registerSharedSingletonType (const char *name) {
qmlRegisterSingletonType<T>(MainQmlUri, 1, 0, name, makeSharedSingleton<T, function>);
qmlRegisterSingletonType<T>(Constants::MainQmlUri, 1, 0, name, makeSharedSingleton<T, function>);
}
template<typename T>
static inline void registerUncreatableType (const char *name) {
qmlRegisterUncreatableType<T>(MainQmlUri, 1, 0, name, QLatin1String("Uncreatable"));
qmlRegisterUncreatableType<T>(Constants::MainQmlUri, 1, 0, name, QLatin1String("Uncreatable"));
}
template<typename T>
static inline void registerSingletonType (const char *name) {
qmlRegisterSingletonType<T>(MainQmlUri, 1, 0, name, [](QQmlEngine *engine, QJSEngine *) -> QObject *{
qmlRegisterSingletonType<T>(Constants::MainQmlUri, 1, 0, name, [](QQmlEngine *engine, QJSEngine *) -> QObject *{
return new T(engine);
});
}
template<typename T>
static inline void registerType (const char *name) {
qmlRegisterType<T>(MainQmlUri, 1, 0, name);
qmlRegisterType<T>(Constants::MainQmlUri, 1, 0, name);
}
template<typename T>
@ -718,8 +699,8 @@ void App::setTrayIcon () {
root->connect(aboutAction, &QAction::triggered, root, [root] {
App::smartShowWindow(root);
QMetaObject::invokeMethod(
root, AttachVirtualWindowMethodName, Qt::DirectConnection,
Q_ARG(QVariant, QUrl(AboutPath)), Q_ARG(QVariant, QVariant()), Q_ARG(QVariant, QVariant())
root, Constants::AttachVirtualWindowMethodName, Qt::DirectConnection,
Q_ARG(QVariant, QUrl(Constants::AboutPath)), Q_ARG(QVariant, QVariant()), Q_ARG(QVariant, QVariant())
);
});
@ -755,7 +736,7 @@ void App::setTrayIcon () {
systemTrayIcon->setContextMenu(menu);
systemTrayIcon->setIcon(QIcon(Utils::WindowIconPath));
systemTrayIcon->setIcon(QIcon(Constants::WindowIconPath));
systemTrayIcon->setToolTip(APPLICATION_NAME);
systemTrayIcon->show();
mSystemTrayIcon = systemTrayIcon;
@ -770,7 +751,7 @@ void App::initLocale (const shared_ptr<linphone::Config> &config) {
QString locale;
// Use english. This default translator is used if there are no found translations in others loads
mLocale = DefaultLocale;
mLocale = Constants::DefaultLocale;
if (!installLocale(*this, *mDefaultTranslator, QLocale(mLocale)))
qFatal("Unable to install default translator.");
@ -929,8 +910,8 @@ void App::openAppAfterInit (bool mustBeIconified) {
qInfo() << QStringLiteral("Open " APPLICATION_NAME " app.");
auto coreManager = CoreManager::getInstance();
// Create other windows.
mCallsWindow = createSubWindow(mEngine, QmlViewCallsWindow);
mSettingsWindow = createSubWindow(mEngine, QmlViewSettingsWindow);
mCallsWindow = createSubWindow(mEngine, Constants::QmlViewCallsWindow);
mSettingsWindow = createSubWindow(mEngine, Constants::QmlViewSettingsWindow);
QObject::connect(mSettingsWindow, &QWindow::visibilityChanged, this, [coreManager](QWindow::Visibility visibility) {
if (visibility == QWindow::Hidden) {
qInfo() << QStringLiteral("Update nat policy.");
@ -951,11 +932,11 @@ void App::openAppAfterInit (bool mustBeIconified) {
// Display Assistant if it does not exist proxy config.
if (coreManager->getCore()->getAccountList().empty())
QMetaObject::invokeMethod(mainWindow, "setView", Q_ARG(QVariant, AssistantViewName), Q_ARG(QVariant, QString("")));
QMetaObject::invokeMethod(mainWindow, "setView", Q_ARG(QVariant, Constants::AssistantViewName), Q_ARG(QVariant, QString("")));
#ifdef ENABLE_UPDATE_CHECK
QTimer *timer = new QTimer(mEngine);
timer->setInterval(VersionUpdateCheckInterval);
timer->setInterval(Constants::VersionUpdateCheckInterval);
QObject::connect(timer, &QTimer::timeout, this, &App::checkForUpdate);
timer->start();

View file

@ -29,18 +29,14 @@
#include "AppController.hpp"
#include "components/other/desktop-tools/DesktopTools.hpp"
#include "utils/Constants.hpp"
// =============================================================================
using namespace std;
namespace {
constexpr char ApplicationMinimalQtVersion[] = "5.9.0";
constexpr char DefaultFont[] = "Noto Sans";
}
AppController::AppController (int &argc, char *argv[]) {
DesktopTools::init();
QT_REQUIRE_VERSION(argc, argv, ApplicationMinimalQtVersion)
QT_REQUIRE_VERSION(argc, argv, Constants::ApplicationMinimalQtVersion)
Q_ASSERT(!mApp);
// Disable QML cache. Avoid malformed cache.
qputenv("QML_DISABLE_DISK_CACHE", "true");
@ -99,7 +95,7 @@ AppController::AppController (int &argc, char *argv[]) {
}
qInfo() << "Available fonts : " << QFontDatabase().families();
mApp->setFont(QFont(DefaultFont));
mApp->setFont(QFont(Constants::DefaultFont));
}
AppController::~AppController () {

View file

@ -29,7 +29,7 @@
#include "components/settings/SettingsModel.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "Logger.hpp"
// =============================================================================
@ -52,12 +52,6 @@
using namespace std;
namespace {
constexpr char QtDomain[] = "qt";
constexpr size_t MaxLogsCollectionSize = 10485760; // 10MB.
constexpr char SrcPattern[] = "/src/";
}
QMutex Logger::mMutex;
Logger *Logger::mInstance;
@ -152,10 +146,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, SrcPattern) : file;
const char *pos = file ? Utils::rstrstr(file, Constants::SrcPattern) : file;
contextArr = QStringLiteral("%1:%2: ")
.arg(pos ? pos + sizeof(SrcPattern) - 1 : file)
.arg(pos ? pos + sizeof(Constants::SrcPattern) - 1 : file)
.arg(context.line)
.toLocal8Bit();
contextStr = contextArr.constData();
@ -172,7 +166,7 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
fprintf(stdout, format, dateTime.constData(), QThread::currentThread(), contextStr, localMsg.constData());
if( level == BCTBX_LOG_FATAL)
QMessageBox::critical(nullptr, "Linphone will crash", msg); // Print an error message before sending msg to bctoolbox
bctbx_log(QtDomain, level, "QT: %s%s", contextStr, localMsg.constData());
bctbx_log(Constants::QtDomain, level, "QT: %s%s", contextStr, localMsg.constData());
mMutex.unlock();
@ -203,14 +197,14 @@ void Logger::init (const shared_ptr<linphone::Config> &config) {
{
shared_ptr<linphone::LoggingService> loggingService = mInstance->mLoggingService = linphone::LoggingService::get();
loggingService->setDomain(QtDomain);
loggingService->setDomain(Constants::QtDomain);
loggingService->setLogLevel(linphone::LogLevel::Message);
loggingService->addListener(make_shared<LinphoneLogger>(mInstance));
}
linphone::Core::setLogCollectionPath(Utils::appStringToCoreString(folder));
linphone::Core::setLogCollectionPrefix(EXECUTABLE_NAME);
linphone::Core::setLogCollectionMaxFileSize(MaxLogsCollectionSize);
linphone::Core::setLogCollectionMaxFileSize(Constants::MaxLogsCollectionSize);
mInstance->enable(SettingsModel::getLogsEnabled(config));
}

View file

@ -27,6 +27,7 @@
#include "config.h"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "Paths.hpp"
@ -34,31 +35,6 @@
using namespace std;
namespace {
constexpr char PathAssistantConfig[] = "/" EXECUTABLE_NAME "/assistant/";
constexpr char PathAvatars[] = "/avatars/";
constexpr char PathCaptures[] = "/" EXECUTABLE_NAME "/captures/";
constexpr char PathCodecs[] = "/codecs/";
constexpr char PathTools[] = "/tools/";
constexpr char PathLogs[] = "/logs/";
#ifdef APPLE
constexpr char PathPlugins[] = "/Plugins/";
#else
constexpr char PathPlugins[] = "/plugins/";
#endif
constexpr char PathPluginsApp[] = "app/";
constexpr char PathThumbnails[] = "/thumbnails/";
constexpr char PathUserCertificates[] = "/usr-crt/";
constexpr char PathCallHistoryList[] = "/call-history.db";
constexpr char PathConfig[] = "/linphonerc";
constexpr char PathFactoryConfig[] = "/" EXECUTABLE_NAME "/linphonerc-factory";
constexpr char PathRootCa[] = "/" EXECUTABLE_NAME "/rootca.pem";
constexpr char PathFriendsList[] = "/friends.db";
constexpr char PathMessageHistoryList[] = "/message-history.db";
constexpr char PathZrtpSecrets[] = "/zidcache";
}
static inline bool dirPathExists (const QString &path) {
QDir dir(path);
return dir.exists();
@ -165,39 +141,39 @@ static inline QString getAppPackageMsPluginsDirPath () {
}
static inline QString getAppPackagePluginsDirPath () {
return getAppPackageDir().absolutePath() + PathPlugins;
return getAppPackageDir().absolutePath() + Constants::PathPlugins;
}
static inline QString getAppAssistantConfigDirPath () {
return getAppPackageDataDirPath() + PathAssistantConfig;
return getAppPackageDataDirPath() + Constants::PathAssistantConfig;
}
static inline QString getAppConfigFilePath () {
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + PathConfig;
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + Constants::PathConfig;
}
static inline QString getAppCallHistoryFilePath () {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathCallHistoryList;
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathCallHistoryList;
}
static inline QString getAppFactoryConfigFilePath () {
return getAppPackageDataDirPath() + PathFactoryConfig;
return getAppPackageDataDirPath() + Constants::PathFactoryConfig;
}
static inline QString getAppRootCaFilePath () {
return getAppPackageDataDirPath() + PathRootCa;
return getAppPackageDataDirPath() + Constants::PathRootCa;
}
static inline QString getAppFriendsFilePath () {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathFriendsList;
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathFriendsList;
}
static inline QString getAppMessageHistoryFilePath () {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathMessageHistoryList;
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathMessageHistoryList;
}
static inline QString getAppPluginsDirPath () {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)+ PathPlugins;
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)+ Constants::PathPlugins;
}
// -----------------------------------------------------------------------------
@ -212,7 +188,7 @@ string Paths::getAssistantConfigDirPath () {
}
string Paths::getAvatarsDirPath () {
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathAvatars);
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathAvatars);
}
string Paths::getCallHistoryFilePath () {
@ -220,11 +196,11 @@ string Paths::getCallHistoryFilePath () {
}
string Paths::getCapturesDirPath () {
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + PathCaptures);
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation) + Constants::PathCaptures);
}
string Paths::getCodecsDirPath () {
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathCodecs);
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathCodecs);
}
string Paths::getConfigDirPath (bool writable) {
@ -262,7 +238,7 @@ string Paths::getDownloadDirPath () {
}
string Paths::getLogsDirPath () {
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathLogs);
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathLogs);
}
string Paths::getMessageHistoryFilePath () {
@ -278,11 +254,11 @@ string Paths::getPackageMsPluginsDirPath () {
}
string Paths::getPackagePluginsAppDirPath () {
return getReadableDirPath(getAppPackagePluginsDirPath()+PathPluginsApp);
return getReadableDirPath(getAppPackagePluginsDirPath() + Constants::PathPluginsApp);
}
string Paths::getPluginsAppDirPath () {
return getWritableDirPath(getAppPluginsDirPath()+PathPluginsApp);
return getWritableDirPath(getAppPluginsDirPath() + Constants::PathPluginsApp);
}
QStringList Paths::getPluginsAppFolders() {
@ -297,17 +273,17 @@ string Paths::getRootCaFilePath () {
}
string Paths::getThumbnailsDirPath () {
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathThumbnails);
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathThumbnails);
}
string Paths::getToolsDirPath () {
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathTools);
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathTools);
}
string Paths::getUserCertificatesDirPath () {
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathUserCertificates);
return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathUserCertificates);
}
string Paths::getZrtpSecretsFilePath () {
return getWritableFilePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PathZrtpSecrets);
return getWritableFilePath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + Constants::PathZrtpSecrets);
}
// -----------------------------------------------------------------------------

View file

@ -33,15 +33,12 @@
#include "components/other/images/ImageListModel.hpp"
#include "components/other/images/ImageModel.hpp"
#include "utils/Constants.hpp"
// =============================================================================
using namespace std;
namespace {
// Max image size in bytes. (100Kb)
constexpr qint64 MaxImageSize = 102400;
}
static void removeAttribute (QXmlStreamAttributes &readerAttributes, const QString &name) {
auto it = find_if(readerAttributes.cbegin(), readerAttributes.cend(), [&name](const QXmlStreamAttribute &attribute) {
return name == attribute.name() && !attribute.prefix().length();
@ -267,7 +264,7 @@ QImage ImageProvider::requestImage (const QString &id, QSize *size, const QSize
return QImage();
}
if (Q_UNLIKELY(QFileInfo(file).size() > MaxImageSize)) {
if (Q_UNLIKELY(QFileInfo(file).size() > Constants::MaxImageSize)) {
qWarning() << QStringLiteral("Unable to open large file: `%1`.").arg(path);
return QImage();
}

View file

@ -24,6 +24,7 @@
#include "components/settings/SettingsModel.hpp"
#include "components/sip-addresses/SipAddressesModel.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "AssistantModel.hpp"
@ -33,10 +34,6 @@
using namespace std;
namespace {
constexpr char DefaultXmlrpcUri[] = "https://subscribe.linphone.org:444/wizard.php";
}
class AssistantModel::Handlers : public linphone::AccountCreatorListener {
public:
Handlers (AssistantModel *assistant) {
@ -151,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", DefaultXmlrpcUri)
core->getConfig()->getString("assistant", "xmlrpc_url", Constants::DefaultXmlrpcUri)
);
mAccountCreator->addListener(mHandlers);
}

View file

@ -46,33 +46,9 @@
#include "components/settings/SettingsModel.hpp"
#include "utils/QExifImageHeader.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
// =============================================================================
namespace {
constexpr int ThumbnailImageFileWidth = 100;
constexpr int ThumbnailImageFileHeight = 100;
// In Bytes.
constexpr qint64 FileSizeLimit = 524288000;
}
/*
std::shared_ptr<ChatMessageModel::ChatMessageListener::ChatMessageListener> ChatMessageModel::ChatMessageListener::create(ChatMessageModel * model, std::shared_ptr<linphone::ChatMessage> chatMessage, QObject * parent){// Call it instead constructor
auto listener = std::shared_ptr<ChatMessageModel::ChatMessageListener::ChatMessageListener>(new ChatMessageModel::ChatMessageListener::ChatMessageListener(model,chatMessage, parent), [model](ChatMessageModel::ChatMessageListener::ChatMessageListener * listener){
chatMessage->removeListener(model->getHandler());
});
chatMessage->addListener(listener);
return model;
}
ChatMessageModel::ChatMessageListener::ChatMessageListener(ChatMessageModel * model, std::shared_ptr<linphone::ChatMessage> chatMessage, QObject * parent){
connect(this, &ChatMessageModel::ChatMessageListener::onFileTransferSend, model, ChatMessageModel::onFileTransferSend);
connect(this, &ChatMessageModel::ChatMessageListener::onFileTransferProgressIndication, model, ChatMessageModel::onFileTransferProgressIndication);
connect(this, &ChatMessageModel::ChatMessageListener::onMsgStateChanged, model, ChatMessageModel::onMsgStateChanged);
}
ChatMessageModel::ChatMessageListener::~ChatMessageListener(){
}
*/
// Warning : isFileTransfer/isFile/getpath cannot be used for Content that comes from linphone::ChatMessage::getContents(). That lead to a crash.
// in SDK there is this note : return c->isFile(); // TODO FIXME this doesn't work when Content is from linphone_chat_message_get_contents() list
@ -169,7 +145,7 @@ void ContentModel::createThumbnail () {
if (exifImageHeader.loadFromJpeg(path))
rotation = int(exifImageHeader.value(QExifImageHeader::ImageTag::Orientation).toShort());
QImage thumbnail = image.scaled(
ThumbnailImageFileWidth, ThumbnailImageFileHeight,
Constants::ThumbnailImageFileWidth, Constants::ThumbnailImageFileHeight,
Qt::KeepAspectRatio, Qt::SmoothTransformation
);

View file

@ -57,6 +57,7 @@
#include "components/core/event-count-notifier/AbstractEventCountNotifier.hpp"
#include "utils/QExifImageHeader.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "utils/LinphoneEnums.hpp"
@ -65,14 +66,6 @@
using namespace std;
namespace {
constexpr int ThumbnailImageFileWidth = 100;
constexpr int ThumbnailImageFileHeight = 100;
// In Bytes.
constexpr qint64 FileSizeLimit = 524288000;
}
// -----------------------------------------------------------------------------
@ -629,8 +622,8 @@ void ChatRoomModel::sendFileMessage (const QString &path) {
return;
qint64 fileSize = file.size();
if (fileSize > FileSizeLimit) {
qWarning() << QStringLiteral("Unable to send file. (Size limit=%1)").arg(FileSizeLimit);
if (fileSize > Constants::FileSizeLimit) {
qWarning() << QStringLiteral("Unable to send file. (Size limit=%1)").arg(Constants::FileSizeLimit);
return;
}

View file

@ -27,6 +27,7 @@
#include "components/file/FileDownloader.hpp"
#include "components/file/FileExtractor.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "VideoCodecsModel.hpp"
#include <linphone/linphonecore.h>
@ -35,30 +36,6 @@
using namespace std;
namespace {
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
constexpr char H264Description[] = "Provided by CISCO SYSTEM,INC";
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
#ifdef Q_OS_LINUX
constexpr char LibraryExtension[] = "so";
constexpr char H264InstallName[] = "libopenh264.so";
#ifdef Q_PROCESSOR_X86_64
constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1.0-linux64.5.so.bz2";
#else
constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1-0-linux32.5.so.bz2";
#endif // ifdef Q_PROCESSOR_X86_64
#elif defined(Q_OS_WIN)
constexpr char LibraryExtension[] = "dll";
constexpr char H264InstallName[] = "openh264.dll";
#ifdef Q_OS_WIN64
constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-2.1.0-win64.dll.bz2";
#else
constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-2.1.0-win32.dll.bz2";
#endif // ifdef Q_OS_WIN64
#endif // ifdef Q_OS_LINUX
}
VideoCodecsModel::VideoCodecsModel (QObject *parent) : AbstractCodecsModel(parent) {
load();
}
@ -132,7 +109,7 @@ static bool downloadUpdatableCodec (
void VideoCodecsModel::updateCodecs () {
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
static const QString codecSuffix = QStringLiteral(".%1").arg(LibraryExtension);
static const QString codecSuffix = QStringLiteral(".%1").arg(Constants::LibraryExtension);
QDirIterator it(getCodecsFolder());
while (it.hasNext()) {
@ -151,7 +128,7 @@ void VideoCodecsModel::updateCodecs () {
void VideoCodecsModel::downloadUpdatableCodecs (QObject *parent) {
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
downloadUpdatableCodec(parent, getCodecsFolder(), "H264", PluginUrlH264, H264InstallName);
downloadUpdatableCodec(parent, getCodecsFolder(), "H264", Constants::PluginUrlH264, Constants::H264InstallName);
#else
Q_UNUSED(parent);
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
@ -192,7 +169,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", H264Description, PluginUrlH264, H264InstallName);
addDownloadableCodec("H264", Constants::H264Description, Constants::PluginUrlH264, Constants::H264InstallName);
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
}

View file

@ -29,6 +29,7 @@
#include "components/core/CoreManager.hpp"
#include "components/sip-addresses/SipAddressesModel.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "VcardModel.hpp"
@ -38,10 +39,6 @@ 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) {
auto it = find_if(list.cbegin(), list.cend(), [&value](const shared_ptr<T> &entry) {
@ -56,7 +53,7 @@ static inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T>> &list, c
}
static inline bool isLinphoneDesktopPhoto (const shared_ptr<belcard::BelCardPhoto> &photo) {
return !photo->getValue().compare(0, sizeof(VcardScheme) - 1, VcardScheme);
return !photo->getValue().compare(0, sizeof(Constants::VcardScheme) - 1, Constants::VcardScheme);
}
static shared_ptr<belcard::BelCardPhoto> findBelcardPhoto (const shared_ptr<belcard::BelCard> &belcard) {
@ -78,7 +75,7 @@ static void removeBelcardPhoto (const shared_ptr<belcard::BelCard> &belcard, boo
for (const auto photo : photos) {
QString imagePath(
Utils::coreStringToAppString(
Paths::getAvatarsDirPath() + photo->getValue().substr(sizeof(VcardScheme) - 1)
Paths::getAvatarsDirPath() + photo->getValue().substr(sizeof(Constants::VcardScheme) - 1)
)
);
@ -122,7 +119,7 @@ QString VcardModel::getAvatar () const {
// Returns right path.
return QStringLiteral("image://%1/%2").arg(AvatarProvider::ProviderId).arg(
Utils::coreStringToAppString(photo->getValue().substr(sizeof(VcardScheme) - 1))
Utils::coreStringToAppString(photo->getValue().substr(sizeof(Constants::VcardScheme) - 1))
);
}
@ -171,7 +168,7 @@ bool VcardModel::setAvatar (const QString &path) {
// 3. Update new photo.
if (!path.isEmpty()) {
shared_ptr<belcard::BelCardPhoto> photo = belcard::BelCardGeneric::create<belcard::BelCardPhoto>();
photo->setValue(VcardScheme + Utils::appStringToCoreString(fileId));
photo->setValue(Constants::VcardScheme + Utils::appStringToCoreString(fileId));
if (!belcard->addPhoto(photo)) {
file.remove();

View file

@ -42,6 +42,7 @@
#include "components/timeline/TimelineListModel.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#if defined(Q_OS_MACOS)
#include "event-count-notifier/EventCountNotifierMacOs.hpp"
@ -59,19 +60,6 @@
using namespace std;
namespace {
constexpr int CbsCallInterval = 20;
constexpr char RcVersionName[] = "rc_version";
constexpr int RcVersionCurrent = 1;
// TODO: Remove hardcoded values. Use config directly.
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";
}
// -----------------------------------------------------------------------------
CoreManager *CoreManager::mInstance=nullptr;
@ -286,38 +274,38 @@ void CoreManager::handleChatRoomCreated(const std::shared_ptr<ChatRoomModel> &ch
void CoreManager::migrate () {
shared_ptr<linphone::Config> config = mCore->getConfig();
int rcVersion = config->getInt(SettingsModel::UiSection, RcVersionName, 0);
if (rcVersion == RcVersionCurrent)
int rcVersion = config->getInt(SettingsModel::UiSection, Constants::RcVersionName, 0);
if (rcVersion == Constants::RcVersionCurrent)
return;
if (rcVersion > RcVersionCurrent) {
if (rcVersion > Constants::RcVersionCurrent) {
qWarning() << QStringLiteral("RC file version (%1) is more recent than app rc file version (%2)!!!")
.arg(rcVersion).arg(RcVersionCurrent);
.arg(rcVersion).arg(Constants::RcVersionCurrent);
return;
}
qInfo() << QStringLiteral("Migrate from old rc file (%1 to %2).")
.arg(rcVersion).arg(RcVersionCurrent);
.arg(rcVersion).arg(Constants::RcVersionCurrent);
// Add message_expires param on old proxy configs.
/*
for (const auto &proxyConfig : mCore->getProxyConfigList()) {
if (proxyConfig->getDomain() == LinphoneDomain) {
proxyConfig->setContactParameters(DefaultContactParameters);
proxyConfig->setExpires(DefaultExpires);
if (proxyConfig->getDomain() == Constants::LinphoneDomain) {
proxyConfig->setContactParameters(Constants::DefaultContactParameters);
proxyConfig->setExpires(Constants::DefaultExpires);
proxyConfig->done();
}
}*/
for(const auto &account : mCore->getAccountList()){
auto params = account->getParams();
if( params->getDomain() == LinphoneDomain) {
if( params->getDomain() == Constants::LinphoneDomain) {
auto newParams = params->clone();
newParams->setContactParameters(DefaultContactParameters);
newParams->setExpires(DefaultExpires);
newParams->setContactParameters(Constants::DefaultContactParameters);
newParams->setExpires(Constants::DefaultExpires);
account->setParams(newParams);
}
}
config->setInt(SettingsModel::UiSection, RcVersionName, RcVersionCurrent);
config->setInt(SettingsModel::UiSection, Constants::RcVersionName, Constants::RcVersionCurrent);
}
// -----------------------------------------------------------------------------
@ -342,7 +330,7 @@ int CoreManager::getMissedCallCountFromLocal( const QString &localAddress)const{
void CoreManager::startIterate(){
mCbsTimer = new QTimer(this);
mCbsTimer->setInterval(CbsCallInterval);
mCbsTimer->setInterval(Constants::CbsCallInterval);
QObject::connect(mCbsTimer, &QTimer::timeout, this, &CoreManager::iterate);
qInfo() << QStringLiteral("Start iterate");
mCbsTimer->start();
@ -379,7 +367,7 @@ void CoreManager::handleLogsUploadStateChanged (linphone::Core::LogCollectionUpl
// -----------------------------------------------------------------------------
QString CoreManager::getDownloadUrl () {
return DownloadUrl;
return Constants::DownloadUrl;
}
void CoreManager::setLastRemoteProvisioningState(const linphone::ConfiguringState& state){

View file

@ -27,6 +27,7 @@
#include "app/App.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "EventCountNotifierSystemTrayIcon.hpp"
@ -44,7 +45,7 @@ namespace {
}
EventCountNotifier::EventCountNotifier (QObject *parent) : AbstractEventCountNotifier(parent) {
QSvgRenderer renderer((QString(Utils::WindowIconPath)));
QSvgRenderer renderer((QString(Constants::WindowIconPath)));
if (!renderer.isValid())
qFatal("Invalid SVG Image.");

View file

@ -32,9 +32,6 @@
using namespace std;
constexpr char LinphoneBZip2_exe[] = "http://www.linphone.org/releases/windows/tools/bzip2/bzip2.exe";
constexpr char LinphoneBZip2_dll[] = "http://www.linphone.org/releases/windows/tools/bzip2/bzip2.dll";
FileExtractor::FileExtractor (QObject *parent) : QObject(parent) {}
FileExtractor::~FileExtractor () {}
@ -69,14 +66,14 @@ void FileExtractor::extract () {
QTimer * timer = mTimer;
FileDownloader * fileDownloader = new FileDownloader();
int downloadStep = 0;
fileDownloader->setUrl(QUrl(LinphoneBZip2_exe));
fileDownloader->setUrl(QUrl(Constants::LinphoneBZip2_exe));
fileDownloader->setDownloadFolder(Utils::coreStringToAppString(Paths::getToolsDirPath()));
QObject::connect(fileDownloader, &FileDownloader::totalBytesChanged, this, &FileExtractor::setTotalBytes);
QObject::connect(fileDownloader, &FileDownloader::readBytesChanged, this, &FileExtractor::setReadBytes);
QObject::connect(fileDownloader, &FileDownloader::downloadFinished, [fileDownloader, timer, downloadStep ]()mutable {
if( downloadStep++ == 0){
fileDownloader->setUrl(QUrl(LinphoneBZip2_dll));
fileDownloader->setUrl(QUrl(Constants::LinphoneBZip2_dll));
fileDownloader->download();
}else {
fileDownloader->deleteLater();

View file

@ -26,6 +26,7 @@
#include "components/core/CoreHandlers.hpp"
#include "components/core/CoreManager.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "AccountSettingsModel.hpp"
#include "SettingsModel.hpp"
@ -138,6 +139,8 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
else
map["route"] = "";
map["conferenceUri"] = Utils::coreStringToAppString(proxyConfig->getConferenceFactoryUri());
if(map["conferenceUri"] == "")
map["conferenceUri"] = Constants::DefaultConferenceURI;
map["contactParams"] = Utils::coreStringToAppString(proxyConfig->getContactParameters());
map["avpfInterval"] = proxyConfig->getAvpfRrInterval();
map["registerEnabled"] = proxyConfig->registerEnabled();
@ -172,7 +175,9 @@ QVariantMap AccountSettingsModel::getProxyConfigDescription (const shared_ptr<li
QString AccountSettingsModel::getConferenceURI() const{
shared_ptr<linphone::Core> core = CoreManager::getInstance()->getCore();
shared_ptr<linphone::ProxyConfig> proxyConfig = core->getDefaultProxyConfig();
return proxyConfig ? Utils::coreStringToAppString(proxyConfig->getConferenceFactoryUri()) : "";
if( proxyConfig && proxyConfig->getConferenceFactoryUri() == "")
proxyConfig->setConferenceFactoryUri(Utils::appStringToCoreString(Constants::DefaultConferenceURI));
return proxyConfig ? Utils::coreStringToAppString(proxyConfig->getConferenceFactoryUri()) : Constants::DefaultConferenceURI;
}
void AccountSettingsModel::setDefaultProxyConfig (const shared_ptr<linphone::ProxyConfig> &proxyConfig) {

View file

@ -31,6 +31,7 @@
#include "components/core/CoreManager.hpp"
#include "include/LinphoneApp/PluginNetworkHelper.hpp"
#include "utils/Utils.hpp"
#include "utils/Constants.hpp"
#include "utils/MediastreamerUtils.hpp"
#include "SettingsModel.hpp"
@ -38,11 +39,6 @@
using namespace std;
namespace {
constexpr char DefaultRlsUri[] = "sips:rls@sip.linphone.org";
constexpr char DefaultLogsEmail[] = "linphone-desktop@belledonne-communications.com";
}
const string SettingsModel::UiSection("ui");
const string SettingsModel::ContactsSection("contacts_import");
@ -1084,7 +1080,7 @@ bool SettingsModel::getRlsUriEnabled () const {
void SettingsModel::setRlsUriEnabled (bool status) {
mConfig->setInt(UiSection, "rls_uri_enabled", status);
mConfig->setString("sip", "rls_uri", status ? DefaultRlsUri : "");
mConfig->setString("sip", "rls_uri", status ? Constants::DefaultRlsUri : "");
emit rlsUriEnabledChanged(status);
}
@ -1093,7 +1089,7 @@ static string getRlsUriDomain () {
if (!domain.empty())
return domain;
shared_ptr<linphone::Address> linphoneAddress = CoreManager::getInstance()->getCore()->createAddress(DefaultRlsUri);
shared_ptr<linphone::Address> linphoneAddress = CoreManager::getInstance()->getCore()->createAddress(Constants::DefaultRlsUri);
Q_CHECK_PTR(linphoneAddress);
domain = linphoneAddress->getDomain();
return domain;
@ -1110,7 +1106,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", DefaultRlsUri);
mConfig->setString("sip", "rls_uri", Constants::DefaultRlsUri);
return;
}
@ -1125,7 +1121,7 @@ void SettingsModel::configureRlsUri (const shared_ptr<const linphone::ProxyConfi
const string domain = getRlsUriDomain();
if (proxyConfig->getDomain() == domain) {
mConfig->setString("sip", "rls_uri", DefaultRlsUri);
mConfig->setString("sip", "rls_uri", Constants::DefaultRlsUri);
return;
}
@ -1288,7 +1284,7 @@ void SettingsModel::setLogsEnabled (bool status) {
QString SettingsModel::getLogsEmail () const {
return Utils::coreStringToAppString(
mConfig->getString(UiSection, "logs_email", DefaultLogsEmail)
mConfig->getString(UiSection, "logs_email", Constants::DefaultLogsEmail)
);
}

View file

@ -0,0 +1,105 @@
#include "Constants.hpp"
constexpr char Constants::WindowIconPath[];
constexpr char Constants::DefaultLocale[];
constexpr char Constants::LanguagePath[];
// The main windows of Linphone desktop.
constexpr char Constants::QmlViewMainWindow[];
constexpr char Constants::QmlViewCallsWindow[];
constexpr char Constants::QmlViewSettingsWindow[];
#ifdef ENABLE_UPDATE_CHECK
constexpr int Constants::VersionUpdateCheckInterval;
#endif // ifdef ENABLE_UPDATE_CHECK
constexpr char Constants::MainQmlUri[];
constexpr char Constants::AttachVirtualWindowMethodName[];
constexpr char Constants::AboutPath[];
constexpr char Constants::AssistantViewName[];
constexpr char Constants::ApplicationMinimalQtVersion[];
constexpr char Constants::DefaultFont[];
constexpr char Constants::QtDomain[];
constexpr size_t Constants::MaxLogsCollectionSize;
constexpr char Constants::SrcPattern[];
constexpr char Constants::PathAssistantConfig[];
constexpr char Constants::PathAvatars[];
constexpr char Constants::PathCaptures[];
constexpr char Constants::PathCodecs[];
constexpr char Constants::PathTools[];
constexpr char Constants::PathLogs[];
#ifdef APPLE
constexpr char Constants::PathPlugins[];
#else
constexpr char Constants::PathPlugins[];
#endif
constexpr char Constants::PathPluginsApp[];
constexpr char Constants::PathThumbnails[];
constexpr char Constants::PathUserCertificates[];
constexpr char Constants::PathCallHistoryList[];
constexpr char Constants::PathConfig[];
constexpr char Constants::PathFactoryConfig[];
constexpr char Constants::PathRootCa[];
constexpr char Constants::PathFriendsList[];
constexpr char Constants::PathMessageHistoryList[];
constexpr char Constants::PathZrtpSecrets[];
// Max image size in bytes. (100Kb)
constexpr qint64 Constants::MaxImageSize;
constexpr int Constants::ThumbnailImageFileWidth;
constexpr int Constants::ThumbnailImageFileHeight;
// In Bytes.
constexpr qint64 Constants::FileSizeLimit;
constexpr char Constants::DefaultXmlrpcUri[];
constexpr char Constants::DefaultConferenceURI[];
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
constexpr char Constants::H264Description[];
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
#ifdef Q_OS_LINUX
constexpr char Constants::LibraryExtension[];
constexpr char Constants::H264InstallName[];
#ifdef Q_PROCESSOR_X86_64
constexpr char Constants::PluginUrlH264[];
#else
constexpr char Constants::PluginUrlH264[];
#endif // ifdef Q_PROCESSOR_X86_64
#elif defined(Q_OS_WIN)
constexpr char Constants::LibraryExtension[];
constexpr char Constants::H264InstallName[];
#ifdef Q_OS_WIN64
constexpr char Constants::PluginUrlH264[];
#else
constexpr char Constants::PluginUrlH264[];
#endif // ifdef Q_OS_WIN64
#endif // ifdef Q_OS_LINUX
constexpr char Constants::VcardScheme[];
constexpr int Constants::CbsCallInterval;
constexpr char Constants::RcVersionName[];
constexpr int Constants::RcVersionCurrent;
// TODO: Remove hardcoded values. Use config directly.
constexpr char Constants::LinphoneDomain[];
constexpr char Constants::DefaultContactParameters[];
constexpr int Constants::DefaultExpires;
constexpr char Constants::DownloadUrl[];
constexpr char Constants::LinphoneBZip2_exe[];
constexpr char Constants::LinphoneBZip2_dll[];
constexpr char Constants::DefaultRlsUri[];
constexpr char Constants::DefaultLogsEmail[];

View file

@ -0,0 +1,144 @@
/*
* Copyright (c) 2021 Belledonne Communications SARL.
*
* This file is part of linphone-desktop
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef CONSTANTS_H_
#define CONSTANTS_H_
#include <QObject>
#include <QString>
#include <QDir>
#include "config.h"
// =============================================================================
class Constants : public QObject{
Q_OBJECT
public:
Constants(QObject * parent = nullptr) : QObject(parent){}
//----------------------------------------------------------------------------------
static constexpr char WindowIconPath[] = ":/assets/images/linphone_logo.svg";
static constexpr char DefaultLocale[] = "en";
static constexpr char ApplicationMinimalQtVersion[] = "5.9.0";
static constexpr char DefaultFont[] = "Noto Sans";
static constexpr size_t MaxLogsCollectionSize = 10485760; // 10MB.
#ifdef ENABLE_UPDATE_CHECK
static constexpr int VersionUpdateCheckInterval = 86400000; // 24 hours in milliseconds.
#endif // ifdef ENABLE_UPDATE_CHECK
static constexpr char DefaultXmlrpcUri[] = "https://subscribe.linphone.org:444/wizard.php";
static constexpr char LinphoneDomain[] = "sip.linphone.org";
static constexpr char DefaultContactParameters[] = "message-expires=604800";
static constexpr int DefaultExpires = 3600;
static constexpr char DownloadUrl[] = "https://www.linphone.org/technical-corner/linphone";
static constexpr char LinphoneBZip2_exe[] = "http://www.linphone.org/releases/windows/tools/bzip2/bzip2.exe";
static constexpr char LinphoneBZip2_dll[] = "http://www.linphone.org/releases/windows/tools/bzip2/bzip2.dll";
static constexpr char DefaultRlsUri[] = "sips:rls@sip.linphone.org";
static constexpr char DefaultLogsEmail[] = "linphone-desktop@belledonne-communications.com";
static constexpr char DefaultConferenceURI[] = "sip:conference-factory@sip.linphone.org";
// Max image size in bytes. (100Kb)
static constexpr qint64 MaxImageSize = 102400;// In Bytes.
static constexpr qint64 FileSizeLimit = 524288000;// In Bytes.
static constexpr int ThumbnailImageFileWidth = 100;
static constexpr int ThumbnailImageFileHeight = 100;
static constexpr char PathAssistantConfig[] = "/" EXECUTABLE_NAME "/assistant/";
static constexpr char PathAvatars[] = "/avatars/";
static constexpr char PathCaptures[] = "/" EXECUTABLE_NAME "/captures/";
static constexpr char PathCodecs[] = "/codecs/";
static constexpr char PathTools[] = "/tools/";
static constexpr char PathLogs[] = "/logs/";
#ifdef APPLE
static constexpr char PathPlugins[] = "/Plugins/";
#else
static constexpr char PathPlugins[] = "/plugins/";
#endif
static constexpr char PathPluginsApp[] = "app/";
static constexpr char PathThumbnails[] = "/thumbnails/";
static constexpr char PathUserCertificates[] = "/usr-crt/";
static constexpr char PathCallHistoryList[] = "/call-history.db";
static constexpr char PathConfig[] = "/linphonerc";
static constexpr char PathFactoryConfig[] = "/" EXECUTABLE_NAME "/linphonerc-factory";
static constexpr char PathRootCa[] = "/" EXECUTABLE_NAME "/rootca.pem";
static constexpr char PathFriendsList[] = "/friends.db";
static constexpr char PathMessageHistoryList[] = "/message-history.db";
static constexpr char PathZrtpSecrets[] = "/zidcache";
static constexpr char LanguagePath[] = ":/languages/";
// The main windows of Linphone desktop.
static constexpr char QmlViewMainWindow[] = "qrc:/ui/views/App/Main/MainWindow.qml";
static constexpr char QmlViewCallsWindow[] = "qrc:/ui/views/App/Calls/CallsWindow.qml";
static constexpr char QmlViewSettingsWindow[] = "qrc:/ui/views/App/Settings/SettingsWindow.qml";
static constexpr char MainQmlUri[] = "Linphone";
static constexpr char AttachVirtualWindowMethodName[] = "attachVirtualWindow";
static constexpr char AboutPath[] = "qrc:/ui/views/App/Main/Dialogs/About.qml";
static constexpr char AssistantViewName[] = "Assistant";
static constexpr char QtDomain[] = "qt";
static constexpr char SrcPattern[] = "/src/";
static constexpr char VcardScheme[] = "linphone-desktop:/";
static constexpr int CbsCallInterval = 20;
static constexpr char RcVersionName[] = "rc_version";
static constexpr int RcVersionCurrent = 1;
//--------------------------------------------------------------------------------
// CISCO
//--------------------------------------------------------------------------------
#if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
static constexpr char H264Description[] = "Provided by CISCO SYSTEM,INC";
#endif // if defined(Q_OS_LINUX) || defined(Q_OS_WIN)
#ifdef Q_OS_LINUX
static constexpr char LibraryExtension[] = "so";
static constexpr char H264InstallName[] = "libopenh264.so";
#ifdef Q_PROCESSOR_X86_64
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1.0-linux64.5.so.bz2";
#else
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/libopenh264-2.1-0-linux32.5.so.bz2";
#endif // ifdef Q_PROCESSOR_X86_64
#elif defined(Q_OS_WIN)
static constexpr char LibraryExtension[] = "dll";
static constexpr char H264InstallName[] = "openh264.dll";
#ifdef Q_OS_WIN64
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-2.1.0-win64.dll.bz2";
#else
static constexpr char PluginUrlH264[] = "http://ciscobinary.openh264.org/openh264-2.1.0-win32.dll.bz2";
#endif // ifdef Q_OS_WIN64
#endif // ifdef Q_OS_LINUX
//--------------------------------------------------------------------------------
};
#endif

View file

@ -1,55 +0,0 @@
/*
* Copyright (c) 2010-2020 Belledonne Communications SARL.
*
* This file is part of linphone-desktop
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QString>
#include <QQmlEngine>
#include "LinphoneUtils.hpp"
#include "utils/Utils.hpp"
#include "components/core/CoreManager.hpp"
#include "components/contacts/ContactsListModel.hpp"
#include "components/contact/ContactModel.hpp"
// =============================================================================
linphone::TransportType LinphoneUtils::stringToTransportType (const QString &transport) {
if (transport == QLatin1String("TCP"))
return linphone::TransportType::Tcp;
if (transport == QLatin1String("UDP"))
return linphone::TransportType::Udp;
if (transport == QLatin1String("TLS"))
return linphone::TransportType::Tls;
return linphone::TransportType::Dtls;
}
std::shared_ptr<linphone::Address> LinphoneUtils::interpretUrl(const QString& address){
return CoreManager::getInstance()->getCore()->interpretUrl(Utils::appStringToCoreString(address));
}
/*
bool LinphoneUtils::hasCapability(const QString& address, const LinphoneEnums::FriendCapability& capability){
auto contact = CoreManager::getInstance()->getContactsListModel()->findContactModelFromSipAddress(address);
if(contact)
return contact->hasCapability(capability);
else
return false;
}
*/

View file

@ -1,41 +0,0 @@
/*
* Copyright (c) 2010-2020 Belledonne Communications SARL.
*
* This file is part of linphone-desktop
* (see https://www.linphone.org).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LINPHONE_UTILS_H_
#define LINPHONE_UTILS_H_
#include <linphone++/linphone.hh>
#include "LinphoneEnums.hpp"
// =============================================================================
class QString;
namespace LinphoneUtils {
linphone::TransportType stringToTransportType (const QString &transport);
std::shared_ptr<linphone::Address> interpretUrl(const QString& address);
static constexpr char WindowIconPath[] = ":/assets/images/linphone_logo.svg";
}
#endif // ifndef LINPHONE_UTILS_H_

View file

@ -37,7 +37,6 @@ namespace {
}
constexpr char Utils::WindowIconPath[];
linphone::TransportType Utils::stringToTransportType (const QString &transport) {
if (transport == QLatin1String("TCP"))
return linphone::TransportType::Tcp;

View file

@ -56,9 +56,7 @@ public:
Q_INVOKABLE static QString toDateTimeString(QDateTime date);
Q_INVOKABLE static QString toTimeString(QDateTime date);
Q_INVOKABLE static QString toDateString(QDateTime date);
//----------------------------------------------------------------------------------
static constexpr char WindowIconPath[] = ":/assets/images/linphone_logo.svg";
//----------------------------------------------------------------------------------
static inline QString coreStringToAppString (const std::string &str) {
return QString::fromLocal8Bit(str.c_str(), int(str.size()));

View file

@ -155,7 +155,7 @@ DialogPlus {
Layout.fillWidth: true
Layout.rightMargin: 15
//: 'Give a subject' : Placeholder in a form about setting a subject
placeholderText :'Give a subject'
placeholderText : qsTr('subjectPlaceholder')
text:(chatRoomModel?chatRoomModel.getSubject():'')
Keys.onReturnPressed: nextItemInFocusChain().forceActiveFocus()
TooltipArea{
@ -175,7 +175,7 @@ DialogPlus {
spacing:20
Text{
//: 'Last contacts' : Header for showing last contacts
text :'Last contacts'
text : qsTr('LastContactsTitle')
color: Colors.g.color
font.pointSize: Units.dp * 11
font.weight: Font.DemiBold