Commit 20d06c58 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): use static inline

parent fca63cdf
...@@ -61,11 +61,11 @@ using namespace std; ...@@ -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); return translator.load(locale, LANGUAGES_PATH) && app.installTranslator(&translator);
} }
inline shared_ptr<linphone::Config> getConfigIfExists (const QCommandLineParser &parser) { static inline shared_ptr<linphone::Config> getConfigIfExists (const QCommandLineParser &parser) {
string configPath = Paths::getConfigFilePath(parser.value("config"), false); string configPath = Paths::getConfigFilePath(parser.value("config"), false);
if (Paths::filePathExists(configPath)) if (Paths::filePathExists(configPath))
return linphone::Config::newWithFactory(configPath, ""); return linphone::Config::newWithFactory(configPath, "");
...@@ -114,7 +114,7 @@ App::~App () { ...@@ -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)); QQmlComponent component(engine, QUrl(path));
if (component.isError()) { if (component.isError()) {
qWarning() << component.errors(); qWarning() << component.errors();
...@@ -130,7 +130,7 @@ inline QQuickWindow *createSubWindow (QQmlApplicationEngine *engine, const char ...@@ -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..."); qInfo() << QStringLiteral("Open splash screen...");
QQuickWindow *splashScreen = ::createSubWindow(engine, QML_VIEW_SPLASH_SCREEN); QQuickWindow *splashScreen = ::createSubWindow(engine, QML_VIEW_SPLASH_SCREEN);
QObject::connect(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted, splashScreen, [splashScreen] { QObject::connect(CoreManager::getInstance()->getHandlers().get(), &CoreHandlers::coreStarted, splashScreen, [splashScreen] {
......
...@@ -62,7 +62,7 @@ Logger *Logger::mInstance = nullptr; ...@@ -62,7 +62,7 @@ Logger *Logger::mInstance = nullptr;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
inline QByteArray getFormattedCurrentTime () { static inline QByteArray getFormattedCurrentTime () {
return QDateTime::currentDateTime().toString("HH:mm:ss:zzz").toLocal8Bit(); return QDateTime::currentDateTime().toString("HH:mm:ss:zzz").toLocal8Bit();
} }
......
...@@ -52,12 +52,12 @@ using namespace std; ...@@ -52,12 +52,12 @@ using namespace std;
// ============================================================================= // =============================================================================
inline bool dirPathExists (const QString &path) { static inline bool dirPathExists (const QString &path) {
QDir dir(path); QDir dir(path);
return dir.exists(); return dir.exists();
} }
inline bool filePathExists (const QString &path) { static inline bool filePathExists (const QString &path) {
QFileInfo info(path); QFileInfo info(path);
if (!::dirPathExists(info.path())) if (!::dirPathExists(info.path()))
return false; return false;
...@@ -66,13 +66,13 @@ inline bool filePathExists (const QString &path) { ...@@ -66,13 +66,13 @@ inline bool filePathExists (const QString &path) {
return file.exists(); return file.exists();
} }
inline void ensureDirPathExists (const QString &path) { static inline void ensureDirPathExists (const QString &path) {
QDir dir(path); QDir dir(path);
if (!dir.exists() && !dir.mkpath(path)) if (!dir.exists() && !dir.mkpath(path))
qFatal("Unable to access at directory: `%s`", path.toStdString().c_str()); 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); QFileInfo info(path);
::ensureDirPathExists(info.path()); ::ensureDirPathExists(info.path());
...@@ -81,27 +81,27 @@ inline void ensureFilePathExists (const QString &path) { ...@@ -81,27 +81,27 @@ inline void ensureFilePathExists (const QString &path) {
qFatal("Unable to access at path: `%s`", path.toStdString().c_str()); 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)); return ::Utils::appStringToCoreString(QDir::toNativeSeparators(dirname));
} }
inline string getWritableDirPath (const QString &dirname) { static inline string getWritableDirPath (const QString &dirname) {
::ensureDirPathExists(dirname); ::ensureDirPathExists(dirname);
return ::getReadableDirPath(dirname); return ::getReadableDirPath(dirname);
} }
inline string getReadableFilePath (const QString &filename) { static inline string getReadableFilePath (const QString &filename) {
return ::Utils::appStringToCoreString(QDir::toNativeSeparators(filename)); return ::Utils::appStringToCoreString(QDir::toNativeSeparators(filename));
} }
inline string getWritableFilePath (const QString &filename) { static inline string getWritableFilePath (const QString &filename) {
::ensureFilePathExists(filename); ::ensureFilePathExists(filename);
return ::getReadableFilePath(filename); return ::getReadableFilePath(filename);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
inline QDir getAppPackageDir () { static inline QDir getAppPackageDir () {
QDir dir(QCoreApplication::applicationDirPath()); QDir dir(QCoreApplication::applicationDirPath());
if (dir.dirName() == "MacOS") { if (dir.dirName() == "MacOS") {
dir.cdUp(); dir.cdUp();
...@@ -111,47 +111,47 @@ inline QDir getAppPackageDir () { ...@@ -111,47 +111,47 @@ inline QDir getAppPackageDir () {
return dir; return dir;
} }
inline QString getAppPackageDataDirPath () { static inline QString getAppPackageDataDirPath () {
QDir dir = ::getAppPackageDir(); QDir dir = ::getAppPackageDir();
dir.cd("share"); dir.cd("share");
return dir.absolutePath(); return dir.absolutePath();
} }
inline QString getAppPackageMsPluginsDirPath () { static inline QString getAppPackageMsPluginsDirPath () {
QDir dir = ::getAppPackageDir(); QDir dir = ::getAppPackageDir();
dir.cd(MSPLUGINS_DIR); dir.cd(MSPLUGINS_DIR);
return dir.absolutePath(); return dir.absolutePath();
} }
inline QString getAppAssistantConfigDirPath () { static inline QString getAppAssistantConfigDirPath () {
return ::getAppPackageDataDirPath() + PATH_ASSISTANT_CONFIG; return ::getAppPackageDataDirPath() + PATH_ASSISTANT_CONFIG;
} }
inline QString getAppConfigFilePath () { static inline QString getAppConfigFilePath () {
return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + PATH_CONFIG; return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + PATH_CONFIG;
} }
inline QString getAppCallHistoryFilePath () { static inline QString getAppCallHistoryFilePath () {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_CALL_HISTORY_LIST; return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_CALL_HISTORY_LIST;
} }
inline QString getAppFactoryConfigFilePath () { static inline QString getAppFactoryConfigFilePath () {
return ::getAppPackageDataDirPath() + PATH_FACTORY_CONFIG; return ::getAppPackageDataDirPath() + PATH_FACTORY_CONFIG;
} }
inline QString getAppPluginsDirPath () { static inline QString getAppPluginsDirPath () {
return ::getAppPackageDataDirPath() + PATH_PLUGINS; return ::getAppPackageDataDirPath() + PATH_PLUGINS;
} }
inline QString getAppRootCaFilePath () { static inline QString getAppRootCaFilePath () {
return ::getAppPackageDataDirPath() + PATH_ROOT_CA; return ::getAppPackageDataDirPath() + PATH_ROOT_CA;
} }
inline QString getAppFriendsFilePath () { static inline QString getAppFriendsFilePath () {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_FRIENDS_LIST; return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_FRIENDS_LIST;
} }
inline QString getAppMessageHistoryFilePath () { static inline QString getAppMessageHistoryFilePath () {
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_MESSAGE_HISTORY_LIST; return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + PATH_MESSAGE_HISTORY_LIST;
} }
......
...@@ -589,7 +589,7 @@ QVariantList CallModel::getVideoStats () const { ...@@ -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; QVariantMap m;
m["key"] = key; m["key"] = key;
m["value"] = value; m["value"] = value;
......
...@@ -37,7 +37,7 @@ using namespace std; ...@@ -37,7 +37,7 @@ using namespace std;
// ============================================================================= // =============================================================================
inline int findCallIndex (QList<CallModel *> &list, const shared_ptr<linphone::Call> &call) { static inline int findCallIndex (QList<CallModel *> &list, const shared_ptr<linphone::Call> &call) {
auto it = find_if(list.begin(), list.end(), [call](CallModel *callModel) { auto it = find_if(list.begin(), list.end(), [call](CallModel *callModel) {
return call == callModel->getCall(); return call == callModel->getCall();
}); });
...@@ -47,7 +47,7 @@ inline int findCallIndex (QList<CallModel *> &list, const shared_ptr<linphone::C ...@@ -47,7 +47,7 @@ inline int findCallIndex (QList<CallModel *> &list, const shared_ptr<linphone::C
return static_cast<int>(distance(list.begin(), it)); return static_cast<int>(distance(list.begin(), it));
} }
inline int findCallIndex (QList<CallModel *> &list, const CallModel &callModel) { static inline int findCallIndex (QList<CallModel *> &list, const CallModel &callModel) {
return ::findCallIndex(list, callModel.getCall()); return ::findCallIndex(list, callModel.getCall());
} }
...@@ -143,7 +143,7 @@ void CallsListModel::terminateAllCalls () const { ...@@ -143,7 +143,7 @@ void CallsListModel::terminateAllCalls () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
inline void joinConference (const shared_ptr<linphone::Call> &call) { static void joinConference (const shared_ptr<linphone::Call> &call) {
if (call->getToHeader("method") != "join-conference") if (call->getToHeader("method") != "join-conference")
return; return;
......
...@@ -53,27 +53,27 @@ using namespace std; ...@@ -53,27 +53,27 @@ using namespace std;
// ============================================================================= // =============================================================================
inline QString getFileId (const shared_ptr<linphone::ChatMessage> &message) { 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);
} }
inline QString getDownloadPath (const shared_ptr<linphone::ChatMessage> &message) { static inline QString getDownloadPath (const shared_ptr<linphone::ChatMessage> &message) {
return ::Utils::coreStringToAppString(message->getAppdata()).section(':', 1); return ::Utils::coreStringToAppString(message->getAppdata()).section(':', 1);
} }
inline bool fileWasDownloaded (const shared_ptr<linphone::ChatMessage> &message) { 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(); return !path.isEmpty() && QFileInfo(path).isFile();
} }
inline void fillThumbnailProperty (QVariantMap &dest, const shared_ptr<linphone::ChatMessage> &message) { 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")) if (!fileId.isEmpty() && !dest.contains("thumbnail"))
dest["thumbnail"] = QStringLiteral("image://%1/%2") dest["thumbnail"] = QStringLiteral("image://%1/%2")
.arg(ThumbnailProvider::PROVIDER_ID).arg(fileId); .arg(ThumbnailProvider::PROVIDER_ID).arg(fileId);
} }
inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) { static inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
if (!message->getAppdata().empty()) if (!message->getAppdata().empty())
return; return;
...@@ -117,7 +117,7 @@ inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) { ...@@ -117,7 +117,7 @@ inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
message->setAppdata(::Utils::appStringToCoreString(fileId)); message->setAppdata(::Utils::appStringToCoreString(fileId));
} }
inline void removeFileMessageThumbnail (const shared_ptr<linphone::ChatMessage> &message) { static inline void removeFileMessageThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
if (message && message->getFileTransferInformation()) { if (message && message->getFileTransferInformation()) {
message->cancelFileTransfer(); message->cancelFileTransfer();
......
...@@ -29,7 +29,7 @@ using namespace std; ...@@ -29,7 +29,7 @@ using namespace std;
// ============================================================================= // =============================================================================
inline shared_ptr<linphone::PayloadType> getCodecFromMap (const QVariantMap &map) { static inline shared_ptr<linphone::PayloadType> getCodecFromMap (const QVariantMap &map) {
return map.value("__codec").value<shared_ptr<linphone::PayloadType> >(); return map.value("__codec").value<shared_ptr<linphone::PayloadType> >();
} }
......
...@@ -42,7 +42,7 @@ using namespace std; ...@@ -42,7 +42,7 @@ using namespace std;
// ============================================================================= // =============================================================================
template<class T> template<class T>
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) { auto it = find_if(list.cbegin(), list.cend(), [&value](const shared_ptr<T> &entry) {
return value == entry->getValue(); return value == entry->getValue();
}); });
...@@ -51,11 +51,11 @@ inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T> > &list, const s ...@@ -51,11 +51,11 @@ inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T> > &list, const s
} }
template<class T> template<class T>
inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T> > &list, const QString &value) { static inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T> > &list, const QString &value) {
return ::findBelCardValue(list, ::Utils::appStringToCoreString(value)); return ::findBelCardValue(list, ::Utils::appStringToCoreString(value));
} }
inline bool isLinphoneDesktopPhoto (const shared_ptr<belcard::BelCardPhoto> &photo) { 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(VCARD_SCHEME) - 1, VCARD_SCHEME);
} }
...@@ -126,7 +126,7 @@ QString VcardModel::getAvatar () const { ...@@ -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); const static QString appPrefix = QStringLiteral("image://%1/").arg(AvatarProvider::PROVIDER_ID);
return path.mid(appPrefix.length()); return path.mid(appPrefix.length());
} }
...@@ -202,7 +202,7 @@ void VcardModel::setUsername (const QString &username) { ...@@ -202,7 +202,7 @@ void VcardModel::setUsername (const QString &username) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
inline shared_ptr<belcard::BelCardAddress> getOrCreateBelCardAddress (shared_ptr<belcard::BelCard> belcard) { 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; shared_ptr<belcard::BelCardAddress> address;
......
...@@ -38,7 +38,7 @@ using namespace std; ...@@ -38,7 +38,7 @@ using namespace std;
#if LINPHONE_FRIDAY #if LINPHONE_FRIDAY
inline bool isLinphoneFriday () { static inline bool isLinphoneFriday () {
return QDate::currentDate().dayOfWeek() == 5; return QDate::currentDate().dayOfWeek() == 5;
} }
......
...@@ -45,7 +45,7 @@ void OwnPresenceModel::setPresenceStatus (Presence::PresenceStatus status) { ...@@ -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); Presence::PresenceLevel level = Presence::getPresenceLevel(status);
QVariantMap map; QVariantMap map;
......
...@@ -30,7 +30,7 @@ using namespace std; ...@@ -30,7 +30,7 @@ using namespace std;
// ============================================================================= // =============================================================================
inline AccountSettingsModel::RegistrationState mapLinphoneRegistrationStateToUi (linphone::RegistrationState state) { static inline AccountSettingsModel::RegistrationState mapLinphoneRegistrationStateToUi (linphone::RegistrationState state) {
switch (state) { switch (state) {
case linphone::RegistrationStateNone: case linphone::RegistrationStateNone:
case linphone::RegistrationStateCleared: case linphone::RegistrationStateCleared:
......
...@@ -200,7 +200,7 @@ void SettingsModel::setVideoFramerate (int framerate) { ...@@ -200,7 +200,7 @@ void SettingsModel::setVideoFramerate (int framerate) {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
inline QVariantMap createMapFromVideoDefinition (const shared_ptr<const linphone::VideoDefinition> &definition) { static inline QVariantMap createMapFromVideoDefinition (const shared_ptr<const linphone::VideoDefinition> &definition) {
QVariantMap map; QVariantMap map;
if (!definition) { if (!definition) {
...@@ -298,7 +298,7 @@ bool SettingsModel::getLimeIsSupported () const { ...@@ -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; return QVariantList() << encryption << description;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment