diff --git a/Linphone/core/path/Paths.cpp b/Linphone/core/path/Paths.cpp index 94a0ea260..09b6ac7d3 100644 --- a/Linphone/core/path/Paths.cpp +++ b/Linphone/core/path/Paths.cpp @@ -283,6 +283,11 @@ QString Paths::getLogsDirPath() { Constants::PathLogs); } +QString Paths::getMetricsDirPath() { + return getWritableDirPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + + Constants::PathMetrics); +} + QString Paths::getMessageHistoryFilePath() { return getReadableFilePath( getAppMessageHistoryFilePath()); // No need to ensure that the file exists as this DB is deprecated diff --git a/Linphone/core/path/Paths.hpp b/Linphone/core/path/Paths.hpp index 753fcc3eb..ba5e10c90 100644 --- a/Linphone/core/path/Paths.hpp +++ b/Linphone/core/path/Paths.hpp @@ -43,6 +43,7 @@ QString getFactoryConfigFilePath(); QString getFriendsListFilePath(); QString getLimeDatabasePath(); QString getLogsDirPath(); +QString getMetricsDirPath(); QString getMessageHistoryFilePath(); QString getPackageDataDirPath(); QString getPackageMsPluginsDirPath(); diff --git a/Linphone/main.cpp b/Linphone/main.cpp index da8ed7682..84194d471 100644 --- a/Linphone/main.cpp +++ b/Linphone/main.cpp @@ -3,6 +3,7 @@ #include "core/App.hpp" #include "core/logger/QtLogger.hpp" +#include "core/path/Paths.hpp" #include #include #include @@ -43,27 +44,6 @@ void cleanStream() { int main(int argc, char *argv[]) { - // Set up Crashpad - std::vector arguments; - - base::FilePath handler_path("/home/parallels/Projects/linphone-desktop/build/" // TODO change this - "crashpad/out/crashpad_handler"); - base::FilePath database_path("/home/parallels/Projects/linphone-desktop/crashes"); // TODO same place as logs. - base::FilePath metrics_path("/home/parallels/Projects/linphone-desktop/metrics_path"); - - std::map annotations; - annotations["product"] = "Linphone"; // TODO from CMake - annotations["version"] = "1.0.0"; // TODO from CMAKE - - crashpad::CrashpadClient crashpad_client; - if (!crashpad_client.StartHandler(handler_path, database_path, metrics_path, - "https://files.linphone.org:443/http-file-transfer-server/hft.php", annotations, - arguments, true, true, {})) { - std::cerr << "Failed to start Crashpad handler. Crashes will not be logged." << std::endl; - } else { - std::cout << "Started Crashpad handler" << std::endl; - } - /* #if defined _WIN32 // log in console only if launched from console @@ -88,6 +68,29 @@ int main(int argc, char *argv[]) { setlocale(LC_CTYPE, ".UTF8"); lDebug() << "[Main] Creating application"; auto app = QSharedPointer::create(argc, argv); + + // Set up Crashpad + std::vector arguments; + + base::FilePath handler_path("/home/parallels/Projects/linphone-desktop/build/" // TODO change this + "crashpad/out/crashpad_handler"); + base::FilePath database_path(Utils::appStringToCoreString(Paths::getLogsDirPath())); + base::FilePath metrics_path(Utils::appStringToCoreString(Paths::getMetricsDirPath())); + + std::map annotations; + annotations["product"] = APPLICATION_NAME; + annotations["version"] = (Utils::appStringToCoreString(app->getShortApplicationVersion())); + + crashpad::CrashpadClient crashpad_client; + if (!crashpad_client.StartHandler(handler_path, database_path, metrics_path, + "https://files.linphone.org:443/http-file-transfer-server/hft.php", annotations, + arguments, true, true, {})) { + lWarning() << "Failed to start Crashpad handler. Crashes will not be logged."; + } else { + lDebug() << "Started Crashpad handler"; + } + // End set up crashpad + #ifdef ACCESSBILITY_WORKAROUND QAccessible::installUpdateHandler(DummyUpdateHandler); QAccessible::installRootObjectHandler(DummyRootObjectHandler); diff --git a/Linphone/tool/Constants.hpp b/Linphone/tool/Constants.hpp index 527f6b45d..f4bba198a 100644 --- a/Linphone/tool/Constants.hpp +++ b/Linphone/tool/Constants.hpp @@ -146,6 +146,7 @@ public: static constexpr char PathTools[] = "/tools/"; static constexpr char PathLogs[] = "/logs/"; static constexpr char PathVCards[] = "/vcards/"; + static constexpr char PathMetrics[] = "/metrics/"; #ifdef APPLE static constexpr char PathPlugins[] = "/Plugins/"; #else