From 9d818066a774543e752bc323be9fcadfd509b8a3 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Tue, 4 Jul 2017 16:41:40 +0200 Subject: [PATCH] SocketApi: Improve logging --- src/gui/guiutility.cpp | 41 +++++++++++++++++++++++++---------------- src/gui/socketapi.cpp | 9 ++------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/gui/guiutility.cpp b/src/gui/guiutility.cpp index 27fe54897..f4b31a7af 100644 --- a/src/gui/guiutility.cpp +++ b/src/gui/guiutility.cpp @@ -17,20 +17,26 @@ #include #include #include +#include #include using namespace OCC; +Q_LOGGING_CATEGORY(lcUtility, "gui.utility", QtInfoMsg) + bool Utility::openBrowser(const QUrl &url, QWidget *errorWidgetParent) { - if (!QDesktopServices::openUrl(url) && errorWidgetParent) { - QMessageBox::warning( - errorWidgetParent, - QCoreApplication::translate("utility", "Could not open browser"), - QCoreApplication::translate("utility", - "There was an error when launching the browser to go to " - "URL %1. Maybe no default browser is configured?") - .arg(url.toString())); + if (!QDesktopServices::openUrl(url)) { + if (errorWidgetParent) { + QMessageBox::warning( + errorWidgetParent, + QCoreApplication::translate("utility", "Could not open browser"), + QCoreApplication::translate("utility", + "There was an error when launching the browser to go to " + "URL %1. Maybe no default browser is configured?") + .arg(url.toString())); + } + qCWarning(lcUtility) << "QDesktopServices::openUrl failed for" << url; return false; } return true; @@ -42,14 +48,17 @@ bool Utility::openEmailComposer(const QString &subject, const QString &body, QWi url.setQueryItems({ { QLatin1String("subject"), subject }, { QLatin1String("body"), body } }); - if (!QDesktopServices::openUrl(url) && errorWidgetParent) { - QMessageBox::warning( - errorWidgetParent, - QCoreApplication::translate("utility", "Could not open email client"), - QCoreApplication::translate("utility", - "There was an error when launching the email client to " - "create a new message. Maybe no default email client is " - "configured?")); + if (!QDesktopServices::openUrl(url)) { + if (errorWidgetParent) { + QMessageBox::warning( + errorWidgetParent, + QCoreApplication::translate("utility", "Could not open email client"), + QCoreApplication::translate("utility", + "There was an error when launching the email client to " + "create a new message. Maybe no default email client is " + "configured?")); + } + qCWarning(lcUtility) << "QDesktopServices::openUrl failed for" << url; return false; } return true; diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index bf4e75d3b..ccfe5167e 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -128,7 +128,7 @@ public: void sendMessage(const QString &message, bool doWait = false) const { - qCInfo(lcSocketApi) << "Sending SocketAPI message: " << message << "to" << socket; + qCInfo(lcSocketApi) << "Sending SocketAPI message -->" << message << "to" << socket; QString localMessage = message; if (!localMessage.endsWith(QLatin1Char('\n'))) { localMessage.append(QLatin1Char('\n')); @@ -282,6 +282,7 @@ void SocketApi::slotReadSocket() // make sure that the path will match, especially on OS X. QString line = QString::fromUtf8(socket->readLine()).normalized(QString::NormalizationForm_C); line.chop(1); // remove the '\n' + qCInfo(lcSocketApi) << "Received SocketAPI message <--" << line << "from" << socket; QByteArray command = line.split(":").value(0).toAscii(); QByteArray functionWithArguments = "command_" + command + "(QString,SocketListener*)"; int indexOfMethod = staticMetaObject.indexOfMethod(functionWithArguments); @@ -373,8 +374,6 @@ void SocketApi::command_RETRIEVE_FOLDER_STATUS(const QString &argument, SocketLi void SocketApi::command_RETRIEVE_FILE_STATUS(const QString &argument, SocketListener *listener) { - qCDebug(lcSocketApi) << argument; - QString statusString; Folder *syncFolder = FolderMan::instance()->folderForPath(argument); @@ -403,8 +402,6 @@ void SocketApi::command_RETRIEVE_FILE_STATUS(const QString &argument, SocketList void SocketApi::command_SHARE(const QString &localFile, SocketListener *listener) { - qCDebug(lcSocketApi) << localFile; - auto theme = Theme::instance(); Folder *shareFolder = FolderMan::instance()->folderForPath(localFile); @@ -454,8 +451,6 @@ void SocketApi::command_VERSION(const QString &, SocketListener *listener) void SocketApi::command_SHARE_STATUS(const QString &localFile, SocketListener *listener) { - qCDebug(lcSocketApi) << localFile; - Folder *shareFolder = FolderMan::instance()->folderForPath(localFile); if (!shareFolder) { -- 2.30.2