From 20d06c589d11a91afdd4ac1cbdbe1556516e779d Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Fri, 25 Aug 2017 10:47:24 +0200 Subject: [PATCH] feat(app): use static inline --- src/app/App.cpp | 8 ++-- src/app/logger/Logger.cpp | 2 +- src/app/paths/Paths.cpp | 38 +++++++++---------- src/components/call/CallModel.cpp | 2 +- src/components/calls/CallsListModel.cpp | 6 +-- src/components/chat/ChatModel.cpp | 12 +++--- src/components/codecs/AbstractCodecsModel.cpp | 2 +- src/components/contact/VcardModel.cpp | 10 ++--- src/components/other/colors/Colors.cpp | 2 +- src/components/presence/OwnPresenceModel.cpp | 2 +- .../settings/AccountSettingsModel.cpp | 2 +- src/components/settings/SettingsModel.cpp | 4 +- 12 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/app/App.cpp b/src/app/App.cpp index b2e06d52f..1f55524ec 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -61,11 +61,11 @@ using namespace std; // ============================================================================= -inline bool installLocale (App &app, QTranslator &translator, const QLocale &locale) { +static inline bool installLocale (App &app, QTranslator &translator, const QLocale &locale) { return translator.load(locale, LANGUAGES_PATH) && app.installTranslator(&translator); } -inline shared_ptr getConfigIfExists (const QCommandLineParser &parser) { +static inline shared_ptr getConfigIfExists (const QCommandLineParser &parser) { string configPath = Paths::getConfigFilePath(parser.value("config"), false); if (Paths::filePathExists(configPath)) return linphone::Config::newWithFactory(configPath, ""); @@ -114,7 +114,7 @@ App::~App () { // ----------------------------------------------------------------------------- -inline QQuickWindow *createSubWindow (QQmlApplicationEngine *engine, const char *path) { +static QQuickWindow *createSubWindow (QQmlApplicationEngine *engine, const char *path) { QQmlComponent component(engine, QUrl(path)); if (component.isError()) { qWarning() << component.errors(); @@ -130,7 +130,7 @@ inline QQuickWindow *createSubWindow (QQmlApplicationEngine *engine, const char // ----------------------------------------------------------------------------- -inline void activeSplashScreen (QQmlApplicationEngine *engine) { +static void activeSplashScreen (QQmlApplicationEngine *engine) { qInfo() << QStringLiteral("Open splash screen..."); QQuickWindow *splashScreen = ::createSubWindow(engine, QML_VIEW_SPLASH_SCREEN); QObject::connect(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted, splashScreen, [splashScreen] { diff --git a/src/app/logger/Logger.cpp b/src/app/logger/Logger.cpp index 4221a581e..db392cc1a 100644 --- a/src/app/logger/Logger.cpp +++ b/src/app/logger/Logger.cpp @@ -62,7 +62,7 @@ Logger *Logger::mInstance = nullptr; // ----------------------------------------------------------------------------- -inline QByteArray getFormattedCurrentTime () { +static inline QByteArray getFormattedCurrentTime () { return QDateTime::currentDateTime().toString("HH:mm:ss:zzz").toLocal8Bit(); } diff --git a/src/app/paths/Paths.cpp b/src/app/paths/Paths.cpp index 75725ce48..a6815d7ae 100644 --- a/src/app/paths/Paths.cpp +++ b/src/app/paths/Paths.cpp @@ -52,12 +52,12 @@ using namespace std; // ============================================================================= -inline bool dirPathExists (const QString &path) { +static inline bool dirPathExists (const QString &path) { QDir dir(path); return dir.exists(); } -inline bool filePathExists (const QString &path) { +static inline bool filePathExists (const QString &path) { QFileInfo info(path); if (!::dirPathExists(info.path())) return false; @@ -66,13 +66,13 @@ inline bool filePathExists (const QString &path) { return file.exists(); } -inline void ensureDirPathExists (const QString &path) { +static inline void ensureDirPathExists (const QString &path) { QDir dir(path); if (!dir.exists() && !dir.mkpath(path)) qFatal("Unable to access at directory: `%s`", path.toStdString().c_str()); } -inline void ensureFilePathExists (const QString &path) { +static inline void ensureFilePathExists (const QString &path) { QFileInfo info(path); ::ensureDirPathExists(info.path()); @@ -81,27 +81,27 @@ inline void ensureFilePathExists (const QString &path) { qFatal("Unable to access at path: `%s`", path.toStdString().c_str()); } -inline string getReadableDirPath (const QString &dirname) { +static inline string getReadableDirPath (const QString &dirname) { return ::Utils::appStringToCoreString(QDir::toNativeSeparators(dirname)); } -inline string getWritableDirPath (const QString &dirname) { +static inline string getWritableDirPath (const QString &dirname) { ::ensureDirPathExists(dirname); return ::getReadableDirPath(dirname); } -inline string getReadableFilePath (const QString &filename) { +static inline string getReadableFilePath (const QString &filename) { return ::Utils::appStringToCoreString(QDir::toNativeSeparators(filename)); } -inline string getWritableFilePath (const QString &filename) { +static inline string getWritableFilePath (const QString &filename) { ::ensureFilePathExists(filename); return ::getReadableFilePath(filename); } // ----------------------------------------------------------------------------- -inline QDir getAppPackageDir () { +static inline QDir getAppPackageDir () { QDir dir(QCoreApplication::applicationDirPath()); if (dir.dirName() == "MacOS") { dir.cdUp(); @@ -111,47 +111,47 @@ inline QDir getAppPackageDir () { return dir; } -inline QString getAppPackageDataDirPath () { +static inline QString getAppPackageDataDirPath () { QDir dir = ::getAppPackageDir(); dir.cd("share"); return dir.absolutePath(); } -inline QString getAppPackageMsPluginsDirPath () { +static inline QString getAppPackageMsPluginsDirPath () { QDir dir = ::getAppPackageDir(); dir.cd(MSPLUGINS_DIR); return dir.absolutePath(); } -inline QString getAppAssistantConfigDirPath () { +static inline QString getAppAssistantConfigDirPath () { return ::getAppPackageDataDirPath() + PATH_ASSISTANT_CONFIG; } -inline QString getAppConfigFilePath () { +static inline QString getAppConfigFilePath () { return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + PATH_CONFIG; } -inline QString getAppCallHistoryFilePath () { +static inline QString getAppCallHistoryFilePath () { return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_CALL_HISTORY_LIST; } -inline QString getAppFactoryConfigFilePath () { +static inline QString getAppFactoryConfigFilePath () { return ::getAppPackageDataDirPath() + PATH_FACTORY_CONFIG; } -inline QString getAppPluginsDirPath () { +static inline QString getAppPluginsDirPath () { return ::getAppPackageDataDirPath() + PATH_PLUGINS; } -inline QString getAppRootCaFilePath () { +static inline QString getAppRootCaFilePath () { return ::getAppPackageDataDirPath() + PATH_ROOT_CA; } -inline QString getAppFriendsFilePath () { +static inline QString getAppFriendsFilePath () { return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_FRIENDS_LIST; } -inline QString getAppMessageHistoryFilePath () { +static inline QString getAppMessageHistoryFilePath () { return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_MESSAGE_HISTORY_LIST; } diff --git a/src/components/call/CallModel.cpp b/src/components/call/CallModel.cpp index e0788dce6..543628bd6 100644 --- a/src/components/call/CallModel.cpp +++ b/src/components/call/CallModel.cpp @@ -589,7 +589,7 @@ QVariantList CallModel::getVideoStats () const { // ----------------------------------------------------------------------------- -inline QVariantMap createStat (const QString &key, const QString &value) { +static inline QVariantMap createStat (const QString &key, const QString &value) { QVariantMap m; m["key"] = key; m["value"] = value; diff --git a/src/components/calls/CallsListModel.cpp b/src/components/calls/CallsListModel.cpp index e1588fbfa..63312fbed 100644 --- a/src/components/calls/CallsListModel.cpp +++ b/src/components/calls/CallsListModel.cpp @@ -37,7 +37,7 @@ using namespace std; // ============================================================================= -inline int findCallIndex (QList &list, const shared_ptr &call) { +static inline int findCallIndex (QList &list, const shared_ptr &call) { auto it = find_if(list.begin(), list.end(), [call](CallModel *callModel) { return call == callModel->getCall(); }); @@ -47,7 +47,7 @@ inline int findCallIndex (QList &list, const shared_ptr(distance(list.begin(), it)); } -inline int findCallIndex (QList &list, const CallModel &callModel) { +static inline int findCallIndex (QList &list, const CallModel &callModel) { return ::findCallIndex(list, callModel.getCall()); } @@ -143,7 +143,7 @@ void CallsListModel::terminateAllCalls () const { // ----------------------------------------------------------------------------- -inline void joinConference (const shared_ptr &call) { +static void joinConference (const shared_ptr &call) { if (call->getToHeader("method") != "join-conference") return; diff --git a/src/components/chat/ChatModel.cpp b/src/components/chat/ChatModel.cpp index 3fcb5b4c8..8e387d561 100644 --- a/src/components/chat/ChatModel.cpp +++ b/src/components/chat/ChatModel.cpp @@ -53,27 +53,27 @@ using namespace std; // ============================================================================= -inline QString getFileId (const shared_ptr &message) { +static inline QString getFileId (const shared_ptr &message) { return ::Utils::coreStringToAppString(message->getAppdata()).section(':', 0, 0); } -inline QString getDownloadPath (const shared_ptr &message) { +static inline QString getDownloadPath (const shared_ptr &message) { return ::Utils::coreStringToAppString(message->getAppdata()).section(':', 1); } -inline bool fileWasDownloaded (const shared_ptr &message) { +static inline bool fileWasDownloaded (const shared_ptr &message) { const QString path = ::getDownloadPath(message); return !path.isEmpty() && QFileInfo(path).isFile(); } -inline void fillThumbnailProperty (QVariantMap &dest, const shared_ptr &message) { +static inline void fillThumbnailProperty (QVariantMap &dest, const shared_ptr &message) { QString fileId = ::getFileId(message); if (!fileId.isEmpty() && !dest.contains("thumbnail")) dest["thumbnail"] = QStringLiteral("image://%1/%2") .arg(ThumbnailProvider::PROVIDER_ID).arg(fileId); } -inline void createThumbnail (const shared_ptr &message) { +static inline void createThumbnail (const shared_ptr &message) { if (!message->getAppdata().empty()) return; @@ -117,7 +117,7 @@ inline void createThumbnail (const shared_ptr &message) { message->setAppdata(::Utils::appStringToCoreString(fileId)); } -inline void removeFileMessageThumbnail (const shared_ptr &message) { +static inline void removeFileMessageThumbnail (const shared_ptr &message) { if (message && message->getFileTransferInformation()) { message->cancelFileTransfer(); diff --git a/src/components/codecs/AbstractCodecsModel.cpp b/src/components/codecs/AbstractCodecsModel.cpp index d76d03113..cb102d5c0 100644 --- a/src/components/codecs/AbstractCodecsModel.cpp +++ b/src/components/codecs/AbstractCodecsModel.cpp @@ -29,7 +29,7 @@ using namespace std; // ============================================================================= -inline shared_ptr getCodecFromMap (const QVariantMap &map) { +static inline shared_ptr getCodecFromMap (const QVariantMap &map) { return map.value("__codec").value >(); } diff --git a/src/components/contact/VcardModel.cpp b/src/components/contact/VcardModel.cpp index 47494503d..c1c8791eb 100644 --- a/src/components/contact/VcardModel.cpp +++ b/src/components/contact/VcardModel.cpp @@ -42,7 +42,7 @@ using namespace std; // ============================================================================= template -inline shared_ptr findBelCardValue (const list > &list, const string &value) { +static inline shared_ptr findBelCardValue (const list > &list, const string &value) { auto it = find_if(list.cbegin(), list.cend(), [&value](const shared_ptr &entry) { return value == entry->getValue(); }); @@ -51,11 +51,11 @@ inline shared_ptr findBelCardValue (const list > &list, const s } template -inline shared_ptr findBelCardValue (const list > &list, const QString &value) { +static inline shared_ptr findBelCardValue (const list > &list, const QString &value) { return ::findBelCardValue(list, ::Utils::appStringToCoreString(value)); } -inline bool isLinphoneDesktopPhoto (const shared_ptr &photo) { +static inline bool isLinphoneDesktopPhoto (const shared_ptr &photo) { return !photo->getValue().compare(0, sizeof(VCARD_SCHEME) - 1, VCARD_SCHEME); } @@ -126,7 +126,7 @@ QString VcardModel::getAvatar () const { ); } -inline QString getFileIdFromAppPath (const QString &path) { +static inline QString getFileIdFromAppPath (const QString &path) { const static QString appPrefix = QStringLiteral("image://%1/").arg(AvatarProvider::PROVIDER_ID); return path.mid(appPrefix.length()); } @@ -202,7 +202,7 @@ void VcardModel::setUsername (const QString &username) { // ----------------------------------------------------------------------------- -inline shared_ptr getOrCreateBelCardAddress (shared_ptr belcard) { +static inline shared_ptr getOrCreateBelCardAddress (shared_ptr belcard) { list > addresses = belcard->getAddresses(); shared_ptr address; diff --git a/src/components/other/colors/Colors.cpp b/src/components/other/colors/Colors.cpp index 2fd4a1c13..4238ac668 100644 --- a/src/components/other/colors/Colors.cpp +++ b/src/components/other/colors/Colors.cpp @@ -38,7 +38,7 @@ using namespace std; #if LINPHONE_FRIDAY - inline bool isLinphoneFriday () { + static inline bool isLinphoneFriday () { return QDate::currentDate().dayOfWeek() == 5; } diff --git a/src/components/presence/OwnPresenceModel.cpp b/src/components/presence/OwnPresenceModel.cpp index c090d47ec..1d5f283b4 100644 --- a/src/components/presence/OwnPresenceModel.cpp +++ b/src/components/presence/OwnPresenceModel.cpp @@ -45,7 +45,7 @@ void OwnPresenceModel::setPresenceStatus (Presence::PresenceStatus status) { // ----------------------------------------------------------------------------- -inline void addBuildStatus (QVariantList &list, Presence::PresenceStatus status) { +static inline void addBuildStatus (QVariantList &list, Presence::PresenceStatus status) { Presence::PresenceLevel level = Presence::getPresenceLevel(status); QVariantMap map; diff --git a/src/components/settings/AccountSettingsModel.cpp b/src/components/settings/AccountSettingsModel.cpp index 344f36bb4..2e528958b 100644 --- a/src/components/settings/AccountSettingsModel.cpp +++ b/src/components/settings/AccountSettingsModel.cpp @@ -30,7 +30,7 @@ using namespace std; // ============================================================================= -inline AccountSettingsModel::RegistrationState mapLinphoneRegistrationStateToUi (linphone::RegistrationState state) { +static inline AccountSettingsModel::RegistrationState mapLinphoneRegistrationStateToUi (linphone::RegistrationState state) { switch (state) { case linphone::RegistrationStateNone: case linphone::RegistrationStateCleared: diff --git a/src/components/settings/SettingsModel.cpp b/src/components/settings/SettingsModel.cpp index a8c1b1887..5b6d92fd1 100644 --- a/src/components/settings/SettingsModel.cpp +++ b/src/components/settings/SettingsModel.cpp @@ -200,7 +200,7 @@ void SettingsModel::setVideoFramerate (int framerate) { // ----------------------------------------------------------------------------- -inline QVariantMap createMapFromVideoDefinition (const shared_ptr &definition) { +static inline QVariantMap createMapFromVideoDefinition (const shared_ptr &definition) { QVariantMap map; if (!definition) { @@ -298,7 +298,7 @@ bool SettingsModel::getLimeIsSupported () const { // ----------------------------------------------------------------------------- -inline QVariant buildEncryptionDescription (SettingsModel::MediaEncryption encryption, const char *description) { +static inline QVariant buildEncryptionDescription (SettingsModel::MediaEncryption encryption, const char *description) { return QVariantList() << encryption << description; }