mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-05-06 20:23:08 +00:00
feat(app): use static inline
This commit is contained in:
parent
fca63cdff4
commit
20d06c589d
12 changed files with 45 additions and 45 deletions
|
|
@ -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<linphone::Config> getConfigIfExists (const QCommandLineParser &parser) {
|
||||
static inline shared_ptr<linphone::Config> 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] {
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ Logger *Logger::mInstance = nullptr;
|
|||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
inline QByteArray getFormattedCurrentTime () {
|
||||
static inline QByteArray getFormattedCurrentTime () {
|
||||
return QDateTime::currentDateTime().toString("HH:mm:ss:zzz").toLocal8Bit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
return call == callModel->getCall();
|
||||
});
|
||||
|
|
@ -47,7 +47,7 @@ inline int findCallIndex (QList<CallModel *> &list, const shared_ptr<linphone::C
|
|||
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());
|
||||
}
|
||||
|
||||
|
|
@ -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")
|
||||
return;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
inline bool fileWasDownloaded (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
static inline bool fileWasDownloaded (const shared_ptr<linphone::ChatMessage> &message) {
|
||||
const QString path = ::getDownloadPath(message);
|
||||
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);
|
||||
if (!fileId.isEmpty() && !dest.contains("thumbnail"))
|
||||
dest["thumbnail"] = QStringLiteral("image://%1/%2")
|
||||
.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())
|
||||
return;
|
||||
|
||||
|
|
@ -117,7 +117,7 @@ inline void createThumbnail (const shared_ptr<linphone::ChatMessage> &message) {
|
|||
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()) {
|
||||
message->cancelFileTransfer();
|
||||
|
||||
|
|
|
|||
|
|
@ -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> >();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ using namespace std;
|
|||
// =============================================================================
|
||||
|
||||
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) {
|
||||
return value == entry->getValue();
|
||||
});
|
||||
|
|
@ -51,11 +51,11 @@ inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T> > &list, const s
|
|||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
@ -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<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();
|
||||
shared_ptr<belcard::BelCardAddress> address;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ using namespace std;
|
|||
|
||||
#if LINPHONE_FRIDAY
|
||||
|
||||
inline bool isLinphoneFriday () {
|
||||
static inline bool isLinphoneFriday () {
|
||||
return QDate::currentDate().dayOfWeek() == 5;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue