From ea6ad4123861b508131d04e7c119e4f02c470542 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Tue, 25 Jun 2024 23:08:21 -0600 Subject: [PATCH] Clean up logging (#360) * Clean up logging * Version bump * Remove timezone FAQ --- applications/system-service/apibase.cpp | 6 +- applications/system-service/application.cpp | 130 ++++++------- applications/system-service/appsapi.cpp | 122 ++++++------ applications/system-service/bss.cpp | 6 +- applications/system-service/buttonhandler.cpp | 22 +-- applications/system-service/dbusservice.cpp | 20 +- .../system-service/digitizerhandler.cpp | 16 +- .../system-service/keyboardhandler.cpp | 2 +- applications/system-service/main.cpp | 24 +-- applications/system-service/network.cpp | 10 +- applications/system-service/notification.cpp | 16 +- .../system-service/notificationapi.cpp | 10 +- applications/system-service/powerapi.cpp | 2 +- applications/system-service/screenapi.cpp | 18 +- applications/system-service/screenshot.cpp | 16 +- applications/system-service/systemapi.cpp | 180 ++++++++---------- applications/system-service/wifiapi.cpp | 60 +++--- applications/system-service/wlan.cpp | 55 +++--- qmake/common.pri | 2 +- shared/liboxide/debug.h | 6 + shared/liboxide/meta.h | 2 +- web/src/faq.rst | 14 -- 22 files changed, 344 insertions(+), 395 deletions(-) diff --git a/applications/system-service/apibase.cpp b/applications/system-service/apibase.cpp index 8e71ce3f4..d3b393bac 100644 --- a/applications/system-service/apibase.cpp +++ b/applications/system-service/apibase.cpp @@ -5,7 +5,7 @@ int APIBase::hasPermission(QString permission, const char* sender){ if(getpgid(getpid()) == getSenderPgid()){ return true; } - qDebug() << "Checking permission" << permission << "from" << sender; + O_INFO("Checking permission" << permission << "from" << sender); for(auto name : appsAPI->runningApplicationsNoSecurityCheck().keys()){ auto app = appsAPI->getApplication(name); if(app == nullptr){ @@ -13,11 +13,11 @@ int APIBase::hasPermission(QString permission, const char* sender){ } if(app->processId() == getSenderPgid()){ auto result = app->permissions().contains(permission); - qDebug() << app->name() << result; + O_INFO(app->name() << result); return result; } } - qDebug() << "app not found, permission granted"; + O_INFO("app not found, permission granted"); return true; } diff --git a/applications/system-service/application.cpp b/applications/system-service/application.cpp index 622bc9148..e187376a5 100644 --- a/applications/system-service/application.cpp +++ b/applications/system-service/application.cpp @@ -46,7 +46,7 @@ void Application::launchNoSecurityCheck(){ Q_UNUSED(t); #endif appsAPI->recordPreviousApplication(); - qDebug() << "Launching " << path(); + O_INFO("Launching " << path()); appsAPI->pauseAll(); if(!flags().contains("nosplash")){ showSplashScreen(); @@ -70,15 +70,15 @@ void Application::launchNoSecurityCheck(){ p_stdout_fd = sd_journal_stream_fd(name().toStdString().c_str(), LOG_INFO, 1); if (p_stdout_fd < 0) { errno = -p_stdout_fd; - qDebug() << "Failed to create stdout fd:" << -p_stdout_fd; + O_WARNING("Failed to create stdout fd:" << -p_stdout_fd); }else{ FILE* log = fdopen(p_stdout_fd, "w"); if(!log){ - qDebug() << "Failed to create stdout FILE:" << errno; + O_WARNING("Failed to create stdout FILE:" << errno); close(p_stdout_fd); }else{ p_stdout = new QTextStream(log); - qDebug() << "Opened stdout for " << name(); + O_DEBUG("Opened stdout for " << name()); } } } @@ -86,15 +86,15 @@ void Application::launchNoSecurityCheck(){ p_stderr_fd = sd_journal_stream_fd(name().toStdString().c_str(), LOG_ERR, 1); if (p_stderr_fd < 0) { errno = -p_stderr_fd; - qDebug() << "Failed to create sterr fd:" << -p_stderr_fd; + O_WARNING("Failed to create sterr fd:" << -p_stderr_fd); }else{ FILE* log = fdopen(p_stderr_fd, "w"); if(!log){ - qDebug() << "Failed to create stderr FILE:" << errno; + O_WARNING("Failed to create stderr FILE:" << errno); close(p_stderr_fd); }else{ p_stderr = new QTextStream(log); - qDebug() << "Opened stderr for " << name(); + O_DEBUG("Opened stderr for " << name()); } } } @@ -122,7 +122,7 @@ void Application::pauseNoSecurityCheck(bool startIfNone){ ){ return; } - qDebug() << "Pausing " << path(); + O_INFO("Pausing " << path()); Oxide::Sentry::sentry_transaction("application", "pause", [this, startIfNone](Oxide::Sentry::Transaction* t){ #ifdef SENTRY if(t != nullptr){ @@ -141,7 +141,7 @@ void Application::pauseNoSecurityCheck(bool startIfNone){ emit paused(); emit appsAPI->applicationPaused(qPath()); }); - qDebug() << "Paused " << path(); + O_INFO("Paused " << path()); } void Application::interruptApplication(){ if( @@ -171,22 +171,22 @@ void Application::interruptApplication(){ startSpan("background", "Application is in the background"); return; case Backgroundable: - qDebug() << "Waiting for SIGUSR2 ack"; + O_INFO("Waiting for SIGUSR2 ack"); appsAPI->connectSignals(this, 2); kill(-m_process->processId(), SIGUSR2); timer.restart(); delayUpTo(1000); appsAPI->disconnectSignals(this, 2); if(stateNoSecurityCheck() == Inactive){ - qDebug() << "Application crashed while pausing"; + O_INFO("Application crashed while pausing"); }else if(timer.isValid()){ - qDebug() << "Application took too long to background" << name(); + O_INFO("Application took too long to background" << name()); kill(-m_process->processId(), SIGSTOP); waitForPause(); startSpan("stopped", "Application is stopped"); }else{ m_backgrounded = true; - qDebug() << "SIGUSR2 ack recieved"; + O_INFO("SIGUSR2 ack recieved"); startSpan("background", "Application is in the background"); } break; @@ -233,7 +233,7 @@ void Application::resumeNoSecurityCheck(){ || stateNoSecurityCheck() == InForeground || (type() == Background && stateNoSecurityCheck() == InBackground) ){ - qDebug() << "Can't Resume" << path() << "Already running!"; + O_DEBUG("Can't Resume" << path() << "Already running!"); return; } Oxide::Sentry::sentry_transaction("application", "resume", [this](Oxide::Sentry::Transaction* t){ @@ -245,7 +245,7 @@ void Application::resumeNoSecurityCheck(){ Q_UNUSED(t); #endif appsAPI->recordPreviousApplication(); - qDebug() << "Resuming " << path(); + O_INFO("Resuming " << path()); appsAPI->pauseAll(); if(!flags().contains("nosavescreen") && (type() != Backgroundable || stateNoSecurityCheck() == Paused)){ recallScreen(); @@ -255,7 +255,7 @@ void Application::resumeNoSecurityCheck(){ emit resumed(); emit appsAPI->applicationResumed(qPath()); }); - qDebug() << "Resumed " << path(); + O_INFO("Resumed " << path()); } void Application::uninterruptApplication(){ if( @@ -286,16 +286,16 @@ void Application::uninterruptApplication(){ systemAPI->clearDeviceBuffers(); kill(-m_process->processId(), SIGCONT); } - qDebug() << "Waiting for SIGUSR1 ack"; + O_INFO("Waiting for SIGUSR1 ack"); appsAPI->connectSignals(this, 1); kill(-m_process->processId(), SIGUSR1); delayUpTo(1000); appsAPI->disconnectSignals(this, 1); if(timer.isValid()){ // No need to fall through, we've just assumed it continued - qDebug() << "Warning: application took too long to forground" << name(); + O_INFO("Warning: application took too long to forground" << name()); }else{ - qDebug() << "SIGUSR1 ack recieved"; + O_INFO("SIGUSR1 ack recieved"); } m_backgrounded = false; startSpan("background", "Application is in the background"); @@ -328,11 +328,11 @@ void Application::stopNoSecurityCheck(){ #else Q_UNUSED(t); #endif - qDebug() << "Stopping " << path(); + O_INFO("Stopping " << path()); if(!onStop().isEmpty()){ Oxide::Sentry::sentry_span(t, "onStop", "Run onStop action", [this](){ - qDebug() << "onStop: " << onStop(); - qDebug() << "exit code: " << QProcess::execute(onStop(), QStringList()); + O_INFO("onStop: " << onStop()); + O_INFO("exit code: " << QProcess::execute(onStop(), QStringList())); }); } Application* pausedApplication = nullptr; @@ -469,7 +469,7 @@ void Application::setEnvironment(QVariantMap environment){ for(auto key : environment.keys()){ auto value = environment.value(key, QVariant()); if(!value.isValid()){ - qDebug() << key << " has invalid value: " << value; + O_INFO(key << " has invalid value: " << value); return; } } @@ -537,7 +537,7 @@ void Application::saveScreen(){ return; } Oxide::Sentry::sentry_transaction("application", "saveScreen", [this](Oxide::Sentry::Transaction* t){ - qDebug() << "Saving screen..."; + O_INFO("Saving screen..."); QByteArray bytes; Oxide::Sentry::sentry_span(t, "save", "Save the framebuffer", [&bytes]{ QBuffer buffer(&bytes); @@ -548,11 +548,11 @@ void Application::saveScreen(){ } }); }); - qDebug() << "Compressing data..."; + O_DEBUG("Compressing data..."); Oxide::Sentry::sentry_span(t, "compress", "Compress the framebuffer", [this, bytes]{ m_screenCapture = new QByteArray(qCompress(bytes)); }); - qDebug() << "Screen saved " << m_screenCapture->size() << "bytes"; + O_INFO("Screen saved " << m_screenCapture->size() << "bytes"); }); } void Application::started(){ @@ -560,7 +560,7 @@ void Application::started(){ emit appsAPI->applicationLaunched(qPath()); } void Application::finished(int exitCode){ - qDebug() << "Application" << name() << "exit code" << exitCode; + O_INFO("Application" << name() << "exit code" << exitCode); emit exited(exitCode); appsAPI->resumeIfNone(); emit appsAPI->applicationExited(qPath(), exitCode); @@ -603,13 +603,13 @@ void Application::readyReadStandardOutput(){ void Application::stateChanged(QProcess::ProcessState state){ switch(state){ case QProcess::Starting: - qDebug() << "Application" << name() << "is starting."; + O_INFO("Application" << name() << "is starting."); break; case QProcess::Running: - qDebug() << "Application" << name() << "is running."; + O_INFO("Application" << name() << "is running."); break; case QProcess::NotRunning: - qDebug() << "Application" << name() << "is not running."; + O_INFO("Application" << name() << "is not running."); if(sharedSettings.applicationUsage()){ if(span != nullptr){ Oxide::Sentry::stop_span(span); @@ -624,13 +624,13 @@ void Application::stateChanged(QProcess::ProcessState state){ } break; default: - qDebug() << "Application" << name() << "unknown state" << state; + O_WARNING("Application" << name() << "unknown state" << state); } } void Application::errorOccurred(QProcess::ProcessError error){ switch(error){ case QProcess::FailedToStart: - qDebug() << "Application" << name() << "failed to start."; + O_INFO("Application" << name() << "failed to start."); emit exited(-1); emit appsAPI->applicationExited(qPath(), -1); if(transient()){ @@ -638,20 +638,20 @@ void Application::errorOccurred(QProcess::ProcessError error){ } break; case QProcess::Crashed: - qDebug() << "Application" << name() << "crashed."; + O_INFO("Application" << name() << "crashed."); break; case QProcess::Timedout: - qDebug() << "Application" << name() << "timed out."; + O_INFO("Application" << name() << "timed out."); break; case QProcess::WriteError: - qDebug() << "Application" << name() << "unable to write to stdin."; + O_INFO("Application" << name() << "unable to write to stdin."); break; case QProcess::ReadError: - qDebug() << "Application" << name() << "unable to read from stdout or stderr."; + O_INFO("Application" << name() << "unable to read from stdout or stderr."); break; case QProcess::UnknownError: default: - qDebug() << "Application" << name() << "unknown error."; + O_WARNING("Application" << name() << "unknown error."); } } bool Application::hasPermission(QString permission, const char* sender){ return appsAPI->hasPermission(permission, sender); } @@ -715,7 +715,7 @@ void Application::bind(const QString& source, const QString& target, bool readOn } auto ctarget = target.toStdString(); auto csource = source.toStdString(); - qDebug() << "mount" << source << target; + O_DEBUG("mount" << source << target); if(mount(csource.c_str(), ctarget.c_str(), NULL, MS_BIND, NULL)){ O_WARNING("Failed to create bindmount: " << ::strerror(errno)); return; @@ -726,13 +726,13 @@ void Application::bind(const QString& source, const QString& target, bool readOn if(mount(csource.c_str(), ctarget.c_str(), NULL, MS_REMOUNT | MS_BIND | MS_RDONLY, NULL)){ O_WARNING("Failed to remount bindmount read only: " << ::strerror(errno)); } - qDebug() << "mount ro" << source << target; + O_DEBUG("mount ro" << source << target); } void Application::sysfs(const QString& path){ mkdirs(path, 744); umount(path); - qDebug() << "sysfs" << path; + O_DEBUG("sysfs" << path); if(mount("none", path.toStdString().c_str(), "sysfs", 0, "")){ O_WARNING("Failed to mount sysfs: " << ::strerror(errno)); } @@ -741,7 +741,7 @@ void Application::sysfs(const QString& path){ void Application::ramdisk(const QString& path){ mkdirs(path, 744); umount(path); - qDebug() << "ramdisk" << path; + O_DEBUG("ramdisk" << path); if(mount("tmpfs", path.toStdString().c_str(), "tmpfs", 0, "size=249m,mode=755")){ O_WARNING("Failed to create ramdisk: " << ::strerror(errno)); } @@ -754,14 +754,14 @@ void Application::umount(const QString& path){ auto cpath = path.toStdString(); auto ret = ::umount2(cpath.c_str(), MNT_DETACH); if((ret && ret != EINVAL && ret != ENOENT) || isMounted(path)){ - qDebug() << "umount failed" << path; + O_WARNING("umount failed" << path); return; } QDir dir(path); if(dir.exists()){ rmdir(cpath.c_str()); } - qDebug() << "umount" << path; + O_DEBUG("umount" << path); } FifoHandler* Application::mkfifo(const QString& name, const QString& target){ @@ -781,18 +781,18 @@ FifoHandler* Application::mkfifo(const QString& name, const QString& target){ } bind(source, target); if(!fifos.contains(name)){ - qDebug() << "Creating fifo thread for" << source; + O_DEBUG("Creating fifo thread for" << source); auto handler = new FifoHandler(name, source.toStdString().c_str(), this); - qDebug() << "Connecting fifo thread events for" << source; + O_DEBUG("Connecting fifo thread events for" << source); connect(handler, &FifoHandler::finished, [this, name]{ if(fifos.contains(name)){ fifos.take(name); } }); fifos[name] = handler; - qDebug() << "Starting fifo thread for" << source; + O_DEBUG("Starting fifo thread for" << source); handler->start(); - qDebug() << "Fifo thread for " << source << "started"; + O_DEBUG("Fifo thread for " << source << "started"); } return fifos[name]; } @@ -801,7 +801,7 @@ void Application::symlink(const QString& source, const QString& target){ if(QFile::exists(source)){ return; } - qDebug() << "symlink" << source << target; + O_DEBUG("symlink" << source << target); if(::symlink(target.toStdString().c_str(), source.toStdString().c_str())){ O_WARNING("Failed to create symlink: " << ::strerror(errno)); return; @@ -820,7 +820,7 @@ void Application::mountAll(){ } #endif auto path = chrootPath(); - qDebug() << "Setting up chroot" << path; + O_DEBUG("Setting up chroot" << path); Oxide::Sentry::sentry_span(t, "bind", "Bind directories", [this, path]{ // System tmpfs folders bind("/dev", path + "/dev"); @@ -887,7 +887,7 @@ void Application::umountAll(){ if(!dir.exists()){ return; } - qDebug() << "Tearing down chroot" << path; + O_DEBUG("Tearing down chroot" << path); Oxide::Sentry::sentry_span(t, "dirs", "Remove directories", [dir]{ for(auto file : dir.entryList(QDir::Files)){ QFile::remove(file); @@ -899,7 +899,7 @@ void Application::umountAll(){ } }); if(!getActiveApplicationMounts().isEmpty()){ - qDebug() << "Some items are still mounted in chroot" << path; + O_WARNING("Some items are still mounted in chroot" << path); return; } Oxide::Sentry::sentry_span(t, "rm", "Remove final folder", [&dir]{ @@ -921,7 +921,7 @@ QStringList Application::getActiveApplicationMounts(){ QStringList Application::getActiveMounts(){ QFile mounts("/proc/mounts"); if(!mounts.open(QIODevice::ReadOnly)){ - qDebug() << "Unable to open /proc/mounts"; + O_WARNING("Unable to open /proc/mounts"); return QStringList(); } QString line; @@ -939,7 +939,7 @@ QStringList Application::getActiveMounts(){ } void Application::showSplashScreen(){ auto frameBuffer = EPFrameBuffer::framebuffer(); - qDebug() << "Waiting for other painting to finish..."; + O_DEBUG("Waiting for other painting to finish..."); Oxide::Sentry::sentry_transaction("application", "showSplashScreen", [this, frameBuffer](Oxide::Sentry::Transaction* t){ #ifdef SENTRY if(t != nullptr){ @@ -955,7 +955,7 @@ void Application::showSplashScreen(){ } }); }); - qDebug() << "Displaying splashscreen for" << name(); + O_INFO("Displaying splashscreen for" << name()); Oxide::Sentry::sentry_span(t, "paint", "Draw splash screen", [this, frameBuffer](){ dispatchToMainThread([this, frameBuffer]{ QPainter painter(frameBuffer); @@ -968,7 +968,7 @@ void Application::showSplashScreen(){ splashPath = icon(); } if(!splashPath.isEmpty() && QFile::exists(splashPath)){ - qDebug() << "Using image" << splashPath; + O_INFO("Using image" << splashPath); int splashWidth = size.width() / 2; QSize splashSize(splashWidth, splashWidth); QImage splash = QImage(splashPath); @@ -990,14 +990,14 @@ void Application::showSplashScreen(){ notificationAPI->drawNotificationText("Loading " + displayName() + "..."); }); }); - qDebug() << "Waitng for screen to finish..."; + O_DEBUG("Waiting for screen to finish..."); Oxide::Sentry::sentry_span(t, "wait", "Wait for screen finish updating", [](){ dispatchToMainThread([]{ EPFrameBuffer::waitForLastUpdate(); }); }); }); - qDebug() << "Finished painting splash screen for" << name(); + O_INFO("Finished painting splash screen for" << name()); } void Application::powerStateDataRecieved(FifoHandler* handler, const QString& data){ Q_UNUSED(handler); @@ -1032,19 +1032,19 @@ void Application::recallScreen() { } Oxide::Sentry::sentry_transaction( "application", "recallScreen", [this](Oxide::Sentry::Transaction *t) { - qDebug() << "Uncompressing screen..."; + O_DEBUG("Uncompressing screen..."); QImage img; Oxide::Sentry::sentry_span( t, "decompress", "Decompress the framebuffer", [this, &img] { img = QImage::fromData(screenCaptureNoSecurityCheck(), "JPG"); }); if (img.isNull()) { - qDebug() << "Screen capture was corrupt"; - qDebug() << m_screenCapture->size(); + O_WARNING("Screen capture was corrupt"); + O_DEBUG(m_screenCapture->size()); delete m_screenCapture; return; } - qDebug() << "Recalling screen..."; + O_INFO("Recalling screen..."); Oxide::Sentry::sentry_span( t, "recall", "Recall the screen", [this, img] { dispatchToMainThread([img] { @@ -1065,7 +1065,7 @@ void Application::recallScreen() { delete m_screenCapture; m_screenCapture = nullptr; }); - qDebug() << "Screen recalled."; + O_INFO("Screen recalled."); }); } @@ -1143,15 +1143,15 @@ void Application::registerPath() { auto bus = QDBusConnection::systemBus(); bus.unregisterObject(path(), QDBusConnection::UnregisterTree); if (bus.registerObject(path(), this, QDBusConnection::ExportAllContents)) { - qDebug() << "Registered" << path() << OXIDE_APPLICATION_INTERFACE; + O_INFO("Registered" << path() << OXIDE_APPLICATION_INTERFACE); } else { - qDebug() << "Failed to register" << path(); + O_WARNING("Failed to register" << path()); } } void Application::unregisterPath() { auto bus = QDBusConnection::systemBus(); if (bus.objectRegisteredAt(path()) != nullptr) { - qDebug() << "Unregistered" << path(); + O_INFO("Unregistered" << path()); bus.unregisterObject(path()); } } diff --git a/applications/system-service/appsapi.cpp b/applications/system-service/appsapi.cpp index e369147cb..6094f36d3 100644 --- a/applications/system-service/appsapi.cpp +++ b/applications/system-service/appsapi.cpp @@ -106,18 +106,18 @@ AppsAPI::AppsAPI(QObject* parent) void AppsAPI::startup(){ Oxide::Sentry::sentry_transaction("apps", "startup", [this](Oxide::Sentry::Transaction* t){ if(applications.isEmpty()){ - qDebug() << "No applications found"; + O_INFO("No applications found"); notificationAPI->errorNotification(_noApplicationsMessage); return; } Oxide::Sentry::sentry_span(t, "autoStart", "Launching auto start applications", [this](Oxide::Sentry::Span* s){ for(auto app : applications){ if(app->autoStart()){ - qDebug() << "Auto starting" << app->name(); + O_INFO("Auto starting" << app->name()); Oxide::Sentry::sentry_span(s, app->name().toStdString(), "Launching application", [app]{ app->launchNoSecurityCheck(); if(app->type() == Backgroundable){ - qDebug() << " Pausing auto started app" << app->name(); + O_INFO(" Pausing auto started app" << app->name()); app->pauseNoSecurityCheck(); } }); @@ -127,20 +127,20 @@ void AppsAPI::startup(){ Oxide::Sentry::sentry_span(t, "start", "Launching initial application", [this]{ auto app = getApplication(m_lockscreenApplication); if(app == nullptr){ - qDebug() << "Could not find lockscreen application"; + O_WARNING("Could not find lockscreen application"); app = getApplication(m_startupApplication); } if(app == nullptr){ - qDebug() << "Could not find startup application"; - qDebug() << "Using xochitl due to invalid configuration"; + O_WARNING("Could not find startup application"); + O_WARNING("Using xochitl due to invalid configuration"); app = getApplication("xochitl"); } if(app == nullptr){ - qDebug() << "Could not find xochitl"; - qWarning() << "Using the first application in the list due to invalid configuration"; + O_WARNING("Could not find xochitl"); + O_WARNING("Using the first application in the list due to invalid configuration"); app = applications.first(); } - qDebug() << "Starting initial application" << app->name(); + O_INFO("Starting initial application" << app->name()); app->launchNoSecurityCheck(); ensureForegroundApp(); }); @@ -148,7 +148,7 @@ void AppsAPI::startup(){ } void AppsAPI::setEnabled(bool enabled){ - qDebug() << "Apps API" << enabled; + O_INFO("Apps API" << enabled); for(auto app : applications){ if(enabled){ app->registerPath(); @@ -170,19 +170,19 @@ QDBusObjectPath AppsAPI::registerApplicationNoSecurityCheck(QVariantMap properti QString bin = properties.value("bin", "").toString(); int type = properties.value("type", ApplicationType::Foreground).toInt(); if(type < ApplicationType::Foreground || type > ApplicationType::Backgroundable){ - qDebug() << "Invalid configuration: Invalid type" << type; + O_WARNING("Invalid configuration: Invalid type" << type); return QDBusObjectPath("/"); } if(name.isEmpty()){ - qDebug() << "Invalid configuration: Name is empty"; + O_WARNING("Invalid configuration: Name is empty"); return QDBusObjectPath("/"); } if(bin.isEmpty() || !QFile::exists(bin)){ - qDebug() << "Invalid configuration: " << name << " has invalid bin" << bin; + O_WARNING("Invalid configuration: " << name << " has invalid bin" << bin); return QDBusObjectPath("/"); } if(!QFileInfo(bin).isExecutable()){ - qDebug() << "Invalid configuration: " << name << " has bin that is not executable" << bin; + O_WARNING("Invalid configuration: " << name << " has bin that is not executable" << bin); return QDBusObjectPath("/"); } if(applications.contains(name)){ @@ -391,7 +391,7 @@ void AppsAPI::resumeIfNone(){ } if(app == nullptr){ if(applications.isEmpty()){ - qDebug() << "No applications found"; + O_WARNING("No applications found"); notificationAPI->errorNotification(_noApplicationsMessage); return; } @@ -465,7 +465,7 @@ bool AppsAPI::previousApplicationNoSecurityCheck(){ return false; } if(previousApplications.isEmpty()){ - qDebug() << "No previous applications"; + O_DEBUG("No previous applications"); return false; } bool found = false; @@ -483,11 +483,11 @@ bool AppsAPI::previousApplicationNoSecurityCheck(){ currentApplication->pauseNoSecurityCheck(false); } application->launchNoSecurityCheck(); - qDebug() << "Resuming previous application" << application->name(); + O_INFO("Resuming previous application" << application->name()); found = true; break; } - qDebug() << "Previous Applications" << previousApplications; + O_DEBUG("Previous Applications" << previousApplications); return found; } @@ -500,7 +500,7 @@ void AppsAPI::forceRecordPreviousApplication(){ auto name = currentApplication->name(); previousApplications.removeAll(name); previousApplications.append(name); - qDebug() << "Previous Applications" << previousApplications; + O_DEBUG("Previous Applications" << previousApplications); } void AppsAPI::recordPreviousApplication(){ @@ -518,7 +518,7 @@ void AppsAPI::recordPreviousApplication(){ auto name = currentApplication->name(); removeFromPreviousApplications(name); previousApplications.append(name); - qDebug() << "Previous Applications" << previousApplications; + O_DEBUG("Previous Applications" << previousApplications); } void AppsAPI::removeFromPreviousApplications(QString name){ previousApplications.removeAll(name); } @@ -537,16 +537,16 @@ void AppsAPI::openDefaultApplication(){ && currentApplication->stateNoSecurityCheck() != Application::Inactive && (path == m_startupApplication || path == m_lockscreenApplication) ){ - qDebug() << "Already in default application"; + O_DEBUG("Already in default application"); return; } } auto app = getApplication(m_startupApplication); if(app == nullptr){ - qDebug() << "Unable to find default application"; + O_WARNING("Unable to find default application"); return; } - qDebug() << "Opening default application"; + O_INFO("Opening default application"); app->launchNoSecurityCheck(); } @@ -564,16 +564,16 @@ void AppsAPI::openTaskManager(){ && currentApplication->stateNoSecurityCheck() != Application::Inactive && path == m_lockscreenApplication ){ - qDebug() << "Can't open task manager, on the lockscreen"; + O_WARNING("Can't open task manager, on the lockscreen"); return; } } auto app = getApplication(m_processManagerApplication); if(app == nullptr){ - qDebug() << "Unable to find task manager"; + O_WARNING("Unable to find task manager"); return; } - qDebug() << "Opening task manager"; + O_INFO("Opening task manager"); app->launchNoSecurityCheck(); } @@ -589,16 +589,16 @@ void AppsAPI::openLockScreen(){ && currentApplication->stateNoSecurityCheck() != Application::Inactive && path == m_lockscreenApplication ){ - qDebug() << "Already on the lockscreen"; + O_DEBUG("Already on the lockscreen"); return; } } auto app = getApplication(m_lockscreenApplication); if(app == nullptr){ - qDebug() << "Unable to find lockscreen"; + O_WARNING("Unable to find lockscreen"); return; } - qDebug() << "Opening lock screen"; + O_INFO("Opening lock screen"); app->launchNoSecurityCheck(); } @@ -614,11 +614,11 @@ void AppsAPI::openTaskSwitcher(){ && currentApplication->stateNoSecurityCheck() != Application::Inactive ){ if(path == m_lockscreenApplication){ - qDebug() << "Can't open task switcher, on the lockscreen"; + O_WARNING("Can't open task switcher, on the lockscreen"); return; } if(path == m_taskSwitcherApplication){ - qDebug() << "Already on the task switcher"; + O_WARNING("Already on the task switcher"); return; } } @@ -630,10 +630,10 @@ void AppsAPI::openTaskSwitcher(){ } app = getApplication(m_startupApplication); if(app == nullptr){ - qDebug() << "Unable to find default application"; + O_WARNING("Unable to find default application"); return; } - qDebug() << "Opening task switcher"; + O_INFO("Opening task switcher"); app->launchNoSecurityCheck(); } @@ -649,7 +649,7 @@ void AppsAPI::openTerminal(){ && currentApplication->stateNoSecurityCheck() != Application::Inactive ){ if(path == m_lockscreenApplication){ - qDebug() << "Can't open task switcher, on the lockscreen"; + O_WARNING("Can't open task switcher, on the lockscreen"); return; } } @@ -661,10 +661,10 @@ void AppsAPI::openTerminal(){ } app = getApplication("fingerterm"); if(app == nullptr){ - qDebug() << "Unable to find terminal application"; + O_WARNING("Unable to find terminal application"); return; } - qDebug() << "Opening terminal"; + O_INFO("Opening terminal"); app->launchNoSecurityCheck(); } @@ -722,9 +722,7 @@ void AppsAPI::readApplications(){ auto type = settings.value("type", Foreground).toInt(); auto bin = settings.value("bin").toString(); if(type < Foreground || type > Backgroundable || name.isEmpty() || bin.isEmpty()){ -#ifdef DEBUG - qDebug() << "Invalid configuration " << name; -#endif + O_DEBUG("Invalid configuration " << name); continue; } QVariantMap properties { @@ -751,16 +749,12 @@ void AppsAPI::readApplications(){ properties.insert("group", settings.value("group", "").toString()); } if(applications.contains(name)){ -#ifdef DEBUG - qDebug() << "Updating " << name; - qDebug() << properties; -#endif + O_DEBUG("Updating " << name); + O_DEBUG(properties); applications[name]->setConfig(properties); }else{ - qDebug() << name; -#ifdef DEBUG - qDebug() << properties; -#endif + O_INFO(name); + O_DEBUG(properties); registerApplicationNoSecurityCheck(properties); } } @@ -772,7 +766,7 @@ void AppsAPI::readApplications(){ for(auto entry : dir.entryInfoList()){ auto app = getRegistration(entry.filePath()); if(app.isEmpty()){ - qDebug() << "Invalid file " << entry.filePath(); + O_WARNING("Invalid file " << entry.filePath()); continue; } auto name = entry.completeBaseName(); @@ -783,7 +777,7 @@ void AppsAPI::readApplications(){ for(auto application : applications.values()){ auto name = application->name(); if(!apps.contains(name) && application->systemApp()){ - qDebug() << name << "Is no longer found on disk"; + O_WARNING(name << "Is no longer found on disk"); application->unregisterNoSecurityCheck(); } } @@ -792,10 +786,8 @@ void AppsAPI::readApplications(){ auto name = app["name"].toString(); auto bin = app["bin"].toString(); if(bin.isEmpty() || !QFile::exists(bin)){ - qDebug() << name << "Can't find application binary:" << bin; -#ifdef DEBUG - qDebug() << app; -#endif + O_WARNING(name << "Can't find application binary:" << bin); + O_DEBUG(app); continue; } if(!app.contains("flags") || !app["flags"].isArray()){ @@ -806,16 +798,12 @@ void AppsAPI::readApplications(){ app["flags"] = flags; auto properties = registrationToMap(app); if(applications.contains(name)){ -#ifdef DEBUG - qDebug() << "Updating " << name; - qDebug() << properties; -#endif + O_DEBUG("Updating " << name); + O_DEBUG(properties); applications[name]->setConfig(properties); }else{ - qDebug() << "New system app" << name; -#ifdef DEBUG - qDebug() << properties; -#endif + O_INFO("New system app" << name); + O_DEBUG(properties); registerApplicationNoSecurityCheck(properties); } } @@ -854,37 +842,37 @@ AppsAPI::~AppsAPI() { settings.sync(); dispatchToMainThread([this] { auto frameBuffer = EPFrameBuffer::framebuffer(); - qDebug() << "Waiting for other painting to finish..."; + O_DEBUG("Waiting for other painting to finish..."); while (frameBuffer->paintingActive()) { EPFrameBuffer::waitForLastUpdate(); } QPainter painter(frameBuffer); auto rect = frameBuffer->rect(); auto fm = painter.fontMetrics(); - qDebug() << "Clearing screen..."; + O_INFO("Clearing screen..."); painter.setPen(Qt::white); painter.fillRect(rect, Qt::black); EPFrameBuffer::sendUpdate(rect, EPFrameBuffer::Mono, EPFrameBuffer::FullUpdate, true); EPFrameBuffer::waitForLastUpdate(); painter.end(); - qDebug() << "Stopping applications..."; + O_DEBUG("Stopping applications..."); for (auto app : applications) { if (app->stateNoSecurityCheck() != Application::Inactive) { auto text = "Stopping " + app->displayName() + "..."; - qDebug() << text.toStdString().c_str(); + O_DEBUG(text.toStdString().c_str()); notificationAPI->drawNotificationText(text, Qt::white, Qt::black); EPFrameBuffer::waitForLastUpdate(); } app->stopNoSecurityCheck(); } - qDebug() << "Ensuring all applications have stopped..."; + O_INFO("Ensuring all applications have stopped..."); for (auto app : applications) { app->waitForFinished(); app->deleteLater(); } applications.clear(); QPainter painter2(frameBuffer); - qDebug() << "Displaying final quit message..."; + O_INFO("Displaying final quit message..."); painter2.fillRect(rect, Qt::black); painter2.setPen(Qt::white); if(systemAPI->landscape()){ diff --git a/applications/system-service/bss.cpp b/applications/system-service/bss.cpp index c0221a25e..56c260eb1 100644 --- a/applications/system-service/bss.cpp +++ b/applications/system-service/bss.cpp @@ -20,16 +20,16 @@ void BSS::registerPath(){ auto bus = QDBusConnection::systemBus(); bus.unregisterObject(path(), QDBusConnection::UnregisterTree); if(bus.registerObject(path(), this, QDBusConnection::ExportAllContents)){ - qDebug() << "Registered" << path() << OXIDE_BSS_INTERFACE; + O_DEBUG("Registered" << path() << OXIDE_BSS_INTERFACE); }else{ - qDebug() << "Failed to register" << path(); + O_WARNING("Failed to register" << path()); } } void BSS::unregisterPath(){ auto bus = QDBusConnection::systemBus(); if(bus.objectRegisteredAt(path()) != nullptr){ - qDebug() << "Unregistered" << path(); + O_DEBUG("Unregistered" << path()); bus.unregisterObject(path()); } } diff --git a/applications/system-service/buttonhandler.cpp b/applications/system-service/buttonhandler.cpp index d076c023c..9c1892817 100644 --- a/applications/system-service/buttonhandler.cpp +++ b/applications/system-service/buttonhandler.cpp @@ -16,9 +16,7 @@ void flush_stream(istream* stream){ stream->read((char*)&ie, sie); } void press_button(event_device& evdev, int code, istream* stream){ -#ifdef DEBUG - qDebug() << "inject button " << code; -#endif + O_DEBUG("inject button " << code); evdev.unlock(); evdev.write(EV_KEY, code, 1); flush_stream(stream); @@ -38,7 +36,7 @@ ButtonHandler* ButtonHandler::init(){ } // Get event devices if(buttons.fd == -1){ - qDebug() << "Failed to open event device: " << buttons.device.c_str(); + O_WARNING("Failed to open event device: " << buttons.device.c_str()); throw QException(); } if(atexit(button_exit_handler)){ @@ -66,9 +64,7 @@ void ButtonHandler::clear_buffer(){ if(buttons.fd == -1){ return; } -#ifdef DEBUG - qDebug() << "Clearing event buffer on" << buttons.device.c_str(); -#endif + O_DEBUG("Clearing event buffer on" << buttons.device.c_str()); ::write(buttons.fd, flood, EVENT_FLOOD_SIZE); } @@ -78,9 +74,9 @@ void ButtonHandler::run(){ char name[256]; memset(name, 0, sizeof(name)); ioctl(buttons.fd, EVIOCGNAME(sizeof(name)), name); - qDebug() << "Reading From : " << buttons.device.c_str() << " (" << name << ")"; + O_INFO("Reading From : " << buttons.device.c_str() << " (" << name << ")"); buttons.lock(); - qDebug() << "Registering exit handler..."; + O_DEBUG("Registering exit handler..."); // Mapping the correct button IDs. unordered_map map; map[105] = PressRecord("Left", Qt::Key_Left); @@ -88,7 +84,7 @@ void ButtonHandler::run(){ map[106] = PressRecord("Right", Qt::Key_Right); map[116] = PressRecord("Power", Qt::Key_PowerOff); - qDebug() << "Listening for keypresses..."; + O_DEBUG("Listening for keypresses..."); // Get the size of an input event in the right format! input_event ie; streamsize sie = static_cast(sizeof(struct input_event)); @@ -162,7 +158,7 @@ void ButtonHandler::keyDown(Qt::Key key){ if(!m_enabled){ return; } - qDebug() << "Down" << key; + O_DEBUG("Down" << key); if(validKeys.contains(key) && !pressed.contains(key)){ QElapsedTimer timer; timer.start(); @@ -174,7 +170,7 @@ void ButtonHandler::keyUp(Qt::Key key){ if(!m_enabled){ return; } - qDebug() << "Up" << key; + O_DEBUG("Up" << key); if(!pressed.contains(key)){ // This should never happen return; @@ -201,7 +197,7 @@ void ButtonHandler::timeout(){ if(!pressed.value(key).hasExpired(700)){ continue; } - qDebug() << "Key held" << key; + O_DEBUG("Key held" << key); switch(key){ case Qt::Key_Left: emit leftHeld(); diff --git a/applications/system-service/dbusservice.cpp b/applications/system-service/dbusservice.cpp index 26ecf59e5..1cbbf169d 100644 --- a/applications/system-service/dbusservice.cpp +++ b/applications/system-service/dbusservice.cpp @@ -12,14 +12,14 @@ DBusService* DBusService::singleton(){ static DBusService* instance; if(instance == nullptr){ qRegisterMetaType>(); - qDebug() << "Creating DBusService instance"; + O_INFO("Creating DBusService instance"); instance = new DBusService(qApp); connect(qApp, &QGuiApplication::aboutToQuit, [=]{ if(instance == nullptr){ return; } emit instance->aboutToQuit(); - qDebug() << "Killing dbus service "; + O_INFO("Killing dbus service"); delete instance; qApp->processEvents(); instance = nullptr; @@ -32,7 +32,7 @@ DBusService* DBusService::singleton(){ qFatal("Failed to connect to system bus."); } QDBusConnectionInterface* interface = bus.interface(); - qDebug() << "Registering service..."; + O_INFO("Registering service..."); auto reply = interface->registerService(OXIDE_SERVICE); bus.registerService(OXIDE_SERVICE); if(!reply.isValid()){ @@ -42,7 +42,7 @@ DBusService* DBusService::singleton(){ #endif qFatal("Unable to register service: %s", ex.message().toStdString().c_str()); } - qDebug() << "Registering object..."; + O_DEBUG("Registering object..."); if(!bus.registerObject(OXIDE_SERVICE_PATH, instance, QDBusConnection::ExportAllContents)){ #ifdef SENTRY sentry_breadcrumb("dbusservice", "Unable to register interface", "error"); @@ -51,7 +51,7 @@ DBusService* DBusService::singleton(){ } connect(bus.interface(), SIGNAL(serviceOwnerChanged(QString,QString,QString)), instance, SLOT(serviceOwnerChanged(QString,QString,QString))); - qDebug() << "Registered"; + O_DEBUG("Registered"); } return instance; } @@ -130,7 +130,7 @@ DBusService::DBusService(QObject* parent) : APIBase(parent), apis(){ } auto currentApplication = appsAPI->getApplication(appsAPI->currentApplicationNoSecurityCheck()); if(currentApplication != nullptr && currentApplication->path() == appsAPI->lockscreenApplication().path()){ - qDebug() << "Left Action cancelled. On lockscreen"; + O_DEBUG("Left Action cancelled. On lockscreen"); return; } if(!appsAPI->previousApplicationNoSecurityCheck()){ @@ -160,7 +160,7 @@ DBusService::~DBusService(){ #ifdef SENTRY sentry_breadcrumb("dbusservice", "Disconnecting APIs", "info"); #endif - qDebug() << "Removing all APIs"; + O_INFO("Removing all APIs"); auto bus = QDBusConnection::systemBus(); for(auto api : apis){ api.instance->setEnabled(false); @@ -202,7 +202,7 @@ QDBusObjectPath DBusService::requestAPI(QString name, QDBusMessage message) { bus.registerObject(api.path, api.instance, QDBusConnection::ExportAllContents); } if(!api.dependants->size()){ - qDebug() << "Registering " << api.path; + O_INFO("Registering " << api.path); api.instance->setEnabled(true); emit apiAvailable(QDBusObjectPath(api.path)); } @@ -221,7 +221,7 @@ void DBusService::releaseAPI(QString name, QDBusMessage message) { auto client = message.service(); api.dependants->removeAll(client); if(!api.dependants->size()){ - qDebug() << "Unregistering " << api.path; + O_INFO("Unregistering " << api.path); api.instance->setEnabled(false); QDBusConnection::systemBus().unregisterObject(api.path, QDBusConnection::UnregisterNode); emit apiUnavailable(QDBusObjectPath(api.path)); @@ -257,7 +257,7 @@ void DBusService::serviceOwnerChanged(const QString& name, const QString& oldOwn auto api = apis[key]; api.dependants->removeAll(name); if(!api.dependants->size() && bus.objectRegisteredAt(api.path) != nullptr){ - qDebug() << "Automatically unregistering " << api.path; + O_INFO("Automatically unregistering " << api.path); api.instance->setEnabled(false); bus.unregisterObject(api.path, QDBusConnection::UnregisterNode); apiUnavailable(QDBusObjectPath(api.path)); diff --git a/applications/system-service/digitizerhandler.cpp b/applications/system-service/digitizerhandler.cpp index 7e77364db..e32711fd3 100644 --- a/applications/system-service/digitizerhandler.cpp +++ b/applications/system-service/digitizerhandler.cpp @@ -8,7 +8,7 @@ DigitizerHandler* DigitizerHandler::singleton_touchScreen(){ // Get event devices event_device touchScreen_device(deviceSettings.getTouchDevicePath(), O_RDWR); if(touchScreen_device.fd == -1){ - qDebug() << "Failed to open event device: " << touchScreen_device.device.c_str(); + O_WARNING("Failed to open event device: " << touchScreen_device.device.c_str()); throw QException(); } instance = new DigitizerHandler(touchScreen_device); @@ -24,7 +24,7 @@ DigitizerHandler* DigitizerHandler::singleton_wacom(){ // Get event devices event_device wacom_device(deviceSettings.getWacomDevicePath(), O_RDWR); if(wacom_device.fd == -1){ - qDebug() << "Failed to open event device: " << wacom_device.device.c_str(); + O_WARNING("Failed to open event device: " << wacom_device.device.c_str()); throw QException(); } instance = new DigitizerHandler(wacom_device); @@ -72,9 +72,7 @@ bool DigitizerHandler::grabbed() { return device.locked; } void DigitizerHandler::write(ushort type, ushort code, int value){ auto event = createEvent(type, code, value); ::write(device.fd, &event, sizeof(input_event)); -#ifdef DEBUG - qDebug() << "Emitted event " << event.time.tv_sec << event.time.tv_usec << type << code << value; -#endif + O_DEBUG("Emitted event " << event.time.tv_sec << event.time.tv_usec << type << code << value); } void DigitizerHandler::write(input_event* events, size_t size){ @@ -89,9 +87,7 @@ void DigitizerHandler::clear_buffer(){ if(device.fd == -1){ return; } -#ifdef DEBUG - qDebug() << "Clearing event buffer on" << device.device.c_str(); -#endif + O_DEBUG("Clearing event buffer on" << device.device.c_str()); write(flood, 512 * 8 * 4 * sizeof(input_event)); } @@ -122,8 +118,8 @@ void DigitizerHandler::run(){ char name[256]; memset(name, 0, sizeof(name)); ioctl(device.fd, EVIOCGNAME(sizeof(name)), name); - qDebug() << "Reading From : " << device.device.c_str() << " (" << name << ")"; - qDebug() << "Listening for events..."; + O_INFO("Reading From : " << device.device.c_str() << " (" << name << ")"); + O_DEBUG("Listening for events..."); while(handle_events()){ qApp->processEvents(QEventLoop::AllEvents, 100); QThread::yieldCurrentThread(); diff --git a/applications/system-service/keyboardhandler.cpp b/applications/system-service/keyboardhandler.cpp index 5f25cc82a..4a22139d9 100644 --- a/applications/system-service/keyboardhandler.cpp +++ b/applications/system-service/keyboardhandler.cpp @@ -619,7 +619,7 @@ KeyboardHandler::~KeyboardHandler(){ } void KeyboardHandler::flood(){ - qDebug() << "Flooding"; + O_DEBUG("Flooding"); for(int i = 0; i < 512 * 8; i+=4){ writeEvent(EV_KEY, KEY_ROTATE_LOCK_TOGGLE, 1); writeEvent(EV_SYN, SYN_REPORT, 0); diff --git a/applications/system-service/main.cpp b/applications/system-service/main.cpp index 5c51b5ff5..c362f7dc9 100755 --- a/applications/system-service/main.cpp +++ b/applications/system-service/main.cpp @@ -28,16 +28,16 @@ bool stopProcess(pid_t pid){ if(pid <= 1){ return false; } - qDebug() << "Waiting for other instance to stop..."; + O_INFO("Waiting for other instance to stop..."); kill(pid, SIGTERM); int tries = 0; while(0 == kill(pid, 0)){ std::this_thread::sleep_for(std::chrono::milliseconds(100)); if(++tries == 50){ - qDebug() << "Instance is taking too long, killing..."; + O_INFO("Instance is taking too long, killing..."); kill(pid, SIGKILL); }else if(tries == 60){ - qDebug() << "Unable to kill process"; + O_INFO("Unable to kill process"); return false; } } @@ -87,27 +87,27 @@ int main(int argc, char* argv[]){ ).trimmed(); if(pid != "0" && pid != actualPid){ if(!parser.isSet(breakLockOption)){ - qDebug() << "tarnish.service is already running"; + O_INFO("tarnish.service is already running"); return EXIT_FAILURE; } if(QProcess::execute("systemctl", QStringList() << "stop" << "tarnish")){ - qDebug() << "tarnish.service is already running"; - qDebug() << "Unable to stop service"; + O_INFO("tarnish.service is already running"); + O_INFO("Unable to stop service"); return EXIT_FAILURE; } } - qDebug() << "Creating lock file" << lockPath; + O_INFO("Creating lock file" << lockPath); if(!QFile::exists(QString::fromStdString(runPath)) && !std::filesystem::create_directories(runPath)){ - qDebug() << "Failed to create" << runPath.c_str(); + O_INFO("Failed to create" << runPath.c_str()); return EXIT_FAILURE; } int lock = Oxide::tryGetLock(lockPath); if(lock < 0){ - qDebug() << "Unable to establish lock on" << lockPath << strerror(errno); + O_INFO("Unable to establish lock on" << lockPath << strerror(errno)); if(!parser.isSet(breakLockOption)){ return EXIT_FAILURE; } - qDebug() << "Attempting to stop all other instances of tarnish" << lockPath; + O_INFO("Attempting to stop all other instances of tarnish" << lockPath); for(auto lockingPid : Oxide::lsof(lockPath)){ if(Oxide::processExists(lockingPid)){ stopProcess(lockingPid); @@ -115,13 +115,13 @@ int main(int argc, char* argv[]){ } lock = Oxide::tryGetLock(lockPath); if(lock < 0){ - qDebug() << "Unable to establish lock on" << lockPath << strerror(errno); + O_INFO("Unable to establish lock on" << lockPath << strerror(errno)); return EXIT_FAILURE; } } QObject::connect(&app, &QGuiApplication::aboutToQuit, [lock]{ - qDebug() << "Releasing lock " << lockPath; + O_INFO("Releasing lock " << lockPath); Oxide::releaseLock(lock, lockPath); }); diff --git a/applications/system-service/network.cpp b/applications/system-service/network.cpp index b8c9266ac..6e6cac1be 100644 --- a/applications/system-service/network.cpp +++ b/applications/system-service/network.cpp @@ -52,16 +52,16 @@ void Network::registerPath(){ auto bus = QDBusConnection::systemBus(); bus.unregisterObject(path(), QDBusConnection::UnregisterTree); if(bus.registerObject(path(), this, QDBusConnection::ExportAllContents)){ - qDebug() << "Registered" << path() << OXIDE_NETWORK_INTERFACE; + O_DEBUG("Registered" << path() << OXIDE_NETWORK_INTERFACE); }else{ - qDebug() << "Failed to register" << path(); + O_WARNING("Failed to register" << path()); } } void Network::unregisterPath(){ auto bus = QDBusConnection::systemBus(); if(bus.objectRegisteredAt(path()) != nullptr){ - qDebug() << "Unregistered" << path(); + O_DEBUG("Unregistered" << path()); bus.unregisterObject(path()); } } @@ -94,9 +94,7 @@ void Network::registerNetwork(){ } } if(!found){ -#ifdef DEBUG - qDebug() << realProps(); -#endif + O_DEBUG(realProps()); QDBusObjectPath path = interface->AddNetwork(realProps()); auto network = new INetwork(WPA_SUPPLICANT_SERVICE, path.path(), QDBusConnection::systemBus(), interface); networks.append(network); diff --git a/applications/system-service/notification.cpp b/applications/system-service/notification.cpp index bf3de86bb..d18ea3e31 100644 --- a/applications/system-service/notification.cpp +++ b/applications/system-service/notification.cpp @@ -35,16 +35,16 @@ void Notification::registerPath(){ auto bus = QDBusConnection::systemBus(); bus.unregisterObject(path(), QDBusConnection::UnregisterTree); if(bus.registerObject(path(), this, QDBusConnection::ExportAllContents)){ - qDebug() << "Registered" << path() << OXIDE_APPLICATION_INTERFACE; + O_INFO("Registered" << path() << OXIDE_APPLICATION_INTERFACE); }else{ - qDebug() << "Failed to register" << path(); + O_WARNING("Failed to register" << path()); } } void Notification::unregisterPath(){ auto bus = QDBusConnection::systemBus(); if(bus.objectRegisteredAt(path()) != nullptr){ - qDebug() << "Unregistered" << path(); + O_INFO("Unregistered" << path()); bus.unregisterObject(path()); } } @@ -104,13 +104,13 @@ void Notification::display(){ return; } if(notificationAPI->locked()){ - qDebug() << "Queueing notification display"; + O_INFO("Queueing notification display"); notificationAPI->notificationDisplayQueue.append(this); return; } notificationAPI->lock(); Oxide::dispatchToMainThread([this]{ - qDebug() << "Displaying notification" << identifier(); + O_INFO("Displaying notification" << identifier()); auto path = appsAPI->currentApplicationNoSecurityCheck(); Application* resumeApp = nullptr; if(path.path() != "/"){ @@ -174,10 +174,10 @@ void Notification::setOwner(QString owner){ bool Notification::hasPermission(QString permission, const char* sender){ return notificationAPI->hasPermission(permission, sender); } void Notification::paintNotification(Application *resumeApp) { - qDebug() << "Painting notification" << identifier(); + O_INFO("Painting notification" << identifier()); dispatchToMainThread([this] { screenBackup = screenAPI->copy(); }); updateRect = notificationAPI->paintNotification(text(), m_icon); - qDebug() << "Painted notification" << identifier(); + O_INFO("Painted notification" << identifier()); emit displayed(); QTimer::singleShot(2000, [this, resumeApp] { dispatchToMainThread([this] { @@ -191,7 +191,7 @@ void Notification::paintNotification(Application *resumeApp) { EPFrameBuffer::FullUpdate, true ); - qDebug() << "Finished displaying notification" << identifier(); + O_INFO("Finished displaying notification" << identifier()); EPFrameBuffer::waitForLastUpdate(); }); if (!notificationAPI->notificationDisplayQueue.isEmpty()) { diff --git a/applications/system-service/notificationapi.cpp b/applications/system-service/notificationapi.cpp index 6f2751cdf..98ca91eca 100644 --- a/applications/system-service/notificationapi.cpp +++ b/applications/system-service/notificationapi.cpp @@ -25,7 +25,7 @@ bool NotificationAPI::enabled(){ return m_enabled; } void NotificationAPI::setEnabled(bool enabled){ m_enabled = enabled; - qDebug() << "Notification API" << enabled; + O_INFO("Notification API" << enabled); for(auto notification : m_notifications.values()){ if(enabled){ notification->registerPath(); @@ -98,7 +98,7 @@ Notification* NotificationAPI::getByIdentifier(const QString& identifier){ QRect NotificationAPI::paintNotification(const QString &text, const QString &iconPath){ QImage notification = notificationImage(text, iconPath); return dispatchToMainThread([¬ification]{ - qDebug() << "Painting to framebuffer..."; + O_DEBUG("Painting to framebuffer..."); auto frameBuffer = EPFrameBuffer::framebuffer(); QPainter painter(frameBuffer); QPoint pos(0, frameBuffer->height() - notification.height()); @@ -110,7 +110,7 @@ QRect NotificationAPI::paintNotification(const QString &text, const QString &ico auto updateRect = notification.rect().translated(pos); painter.drawImage(updateRect, notification); painter.end(); - qDebug() << "Updating screen " << updateRect << "..."; + O_DEBUG("Updating screen " << updateRect << "..."); EPFrameBuffer::sendUpdate( updateRect, EPFrameBuffer::Grayscale, @@ -124,11 +124,11 @@ QRect NotificationAPI::paintNotification(const QString &text, const QString &ico void NotificationAPI::errorNotification(const QString &text) { dispatchToMainThread([] { auto frameBuffer = EPFrameBuffer::framebuffer(); - qDebug() << "Waiting for other painting to finish..."; + O_DEBUG("Waiting for other painting to finish..."); while (frameBuffer->paintingActive()) { EPFrameBuffer::waitForLastUpdate(); } - qDebug() << "Displaying error text"; + O_DEBUG("Displaying error text"); QPainter painter(frameBuffer); painter.fillRect(frameBuffer->rect(), Qt::white); painter.end(); diff --git a/applications/system-service/powerapi.cpp b/applications/system-service/powerapi.cpp index 0a88f2faf..78d4847ec 100644 --- a/applications/system-service/powerapi.cpp +++ b/applications/system-service/powerapi.cpp @@ -33,7 +33,7 @@ PowerAPI::PowerAPI(QObject* parent) } PowerAPI::~PowerAPI(){ - qDebug() << "Killing timer"; + O_DEBUG("Killing timer"); timer->stop(); delete timer; } diff --git a/applications/system-service/screenapi.cpp b/applications/system-service/screenapi.cpp index abba365e8..ffd4b49b7 100644 --- a/applications/system-service/screenapi.cpp +++ b/applications/system-service/screenapi.cpp @@ -8,11 +8,9 @@ QDBusObjectPath ScreenAPI::screenshot(){ if(!hasPermission("screen")){ return QDBusObjectPath("/"); } - qDebug() << "Taking screenshot"; + O_INFO("Taking screenshot"); auto filePath = getNextPath(); -#ifdef DEBUG - qDebug() << "Using path" << filePath; -#endif + O_DEBUG("Using path" << filePath); return dispatchToMainThread([this, filePath]{ QImage screen = copy(); QRect rect = notificationAPI->paintNotification("Taking Screenshot...", ""); @@ -24,7 +22,7 @@ QDBusObjectPath ScreenAPI::screenshot(){ : screen ).save(filePath); if(!saved){ - qDebug() << "Failed to take screenshot"; + O_WARNING("Failed to take screenshot"); }else{ path = addScreenshot(filePath)->qPath(); } @@ -47,7 +45,7 @@ QDBusObjectPath ScreenAPI::screenshot(){ QImage ScreenAPI::copy(){ return Oxide::dispatchToMainThread([]{ auto frameBuffer = EPFrameBuffer::framebuffer(); - qDebug() << "Waiting for other painting to finish..."; + O_DEBUG("Waiting for other painting to finish..."); while(frameBuffer->paintingActive()){ EPFrameBuffer::waitForLastUpdate(); } @@ -59,7 +57,7 @@ QDBusObjectPath ScreenAPI::addScreenshot(QByteArray blob){ if(!hasPermission("screen")){ return QDBusObjectPath("/"); } - qDebug() << "Adding external screenshot"; + O_INFO("Adding external screenshot"); mutex.lock(); auto filePath = getNextPath(); QFile file(filePath); @@ -159,7 +157,7 @@ ScreenAPI::~ScreenAPI(){} void ScreenAPI::setEnabled(bool enabled){ m_enabled = enabled; - qDebug() << "Screen API" << enabled; + O_INFO("Screen API" << enabled); for(auto screenshot : m_screenshots){ if(enabled){ screenshot->registerPath(); @@ -192,12 +190,12 @@ bool ScreenAPI::drawFullscreenImage(QString path, double rotate) { return false; } if (!QFile(path).exists()) { - qDebug() << "Can't find image" << path; + O_WARNING("Can't find image" << path); return false; } QImage img(path); if (img.isNull()) { - qDebug() << "Image data invalid" << path; + O_WARNING("Image data invalid" << path); return false; } if(rotate){ diff --git a/applications/system-service/screenshot.cpp b/applications/system-service/screenshot.cpp index 580bbbab4..71ee7cc1a 100644 --- a/applications/system-service/screenshot.cpp +++ b/applications/system-service/screenshot.cpp @@ -4,7 +4,7 @@ Screenshot::Screenshot(QString path, QString filePath, QObject* parent) : QObject(parent), m_path(path), mutex() { m_file = new QFile(filePath); if(!m_file->open(QIODevice::ReadWrite)){ - qDebug() << "Unable to open screenshot file" << m_file->fileName(); + O_WARNING("Unable to open screenshot file" << m_file->fileName()); } } @@ -24,16 +24,16 @@ void Screenshot::registerPath(){ auto bus = QDBusConnection::systemBus(); bus.unregisterObject(path(), QDBusConnection::UnregisterTree); if(bus.registerObject(path(), this, QDBusConnection::ExportAllContents)){ - qDebug() << "Registered" << path() << OXIDE_APPLICATION_INTERFACE; + O_INFO("Registered" << path() << OXIDE_APPLICATION_INTERFACE); }else{ - qDebug() << "Failed to register" << path(); + O_WARNING("Failed to register" << path()); } } void Screenshot::unregisterPath(){ auto bus = QDBusConnection::systemBus(); if(bus.objectRegisteredAt(path()) != nullptr){ - qDebug() << "Unregistered" << path(); + O_INFO("Unregistered" << path()); bus.unregisterObject(path()); } } @@ -48,7 +48,7 @@ QByteArray Screenshot::blob(){ } mutex.lock(); if(!m_file->isOpen() && !m_file->open(QIODevice::ReadWrite)){ - qDebug() << "Unable to open screenshot file" << m_file->fileName(); + O_WARNING("Unable to open screenshot file" << m_file->fileName()); mutex.unlock(); return QByteArray(); } @@ -64,7 +64,7 @@ void Screenshot::setBlob(QByteArray blob){ } mutex.lock(); if(!m_file->isOpen() && !m_file->open(QIODevice::ReadWrite)){ - qDebug() << "Unable to open screenshot file" << m_file->fileName(); + O_WARNING("Unable to open screenshot file" << m_file->fileName()); mutex.unlock(); return; } @@ -93,7 +93,7 @@ void Screenshot::remove(){ } mutex.lock(); if(m_file->exists() && !m_file->remove()){ - qDebug() << "Failed to remove screenshot" << path(); + O_INFO("Failed to remove screenshot" << path()); mutex.unlock(); return; } @@ -101,7 +101,7 @@ void Screenshot::remove(){ m_file->close(); } mutex.unlock(); - qDebug() << "Removed screenshot" << path(); + O_INFO("Removed screenshot" << path()); emit removed(); } diff --git a/applications/system-service/systemapi.cpp b/applications/system-service/systemapi.cpp index 92b5f3ae5..94981a0e8 100644 --- a/applications/system-service/systemapi.cpp +++ b/applications/system-service/systemapi.cpp @@ -24,9 +24,9 @@ void SystemAPI::PrepareForSleep(bool suspending){ Oxide::Sentry::sentry_transaction("system", "suspend", [this, device](Oxide::Sentry::Transaction* t){ if(autoLock()){ lockTimestamp = QDateTime::currentMSecsSinceEpoch() + lockTimer.remainingTime(); - qDebug() << "Auto Lock timestamp:" << lockTimestamp; + O_DEBUG("Auto Lock timestamp:" << lockTimestamp); } - qDebug() << "Preparing for suspend..."; + O_INFO("Preparing for suspend..."); Oxide::Sentry::sentry_span(t, "prepare", "Prepare for suspend", [this]{ wifiAPI->stopUpdating(); emit deviceSuspending(); @@ -35,9 +35,9 @@ void SystemAPI::PrepareForSleep(bool suspending){ if(path.path() != "/"){ resumeApp = appsAPI->getApplication(path); resumeApp->pauseNoSecurityCheck(false); - qDebug() << "Resume app set to " << resumeApp->name(); + O_INFO("Resume app set to " << resumeApp->name()); }else{ - qDebug() << "Unable to set resume app"; + O_INFO("Unable to set resume app"); resumeApp = nullptr; } }); @@ -63,14 +63,14 @@ void SystemAPI::PrepareForSleep(bool suspending){ Oxide::Sentry::sentry_span(t, "clear-input", "Clear input buffers", [this]{ clearDeviceBuffers(); }); - qDebug() << "Suspending..."; + O_INFO("Suspending..."); }); }else{ Oxide::Sentry::sentry_transaction("system", "resume", [this, device](Oxide::Sentry::Transaction* t){ Oxide::Sentry::sentry_span(t, "inhibit", "Inhibit sleep", [this]{ inhibitSleep(); }); - qDebug() << "Resuming..."; + O_INFO("Resuming..."); Oxide::Sentry::sentry_span(t, "process", "Process events", []{ QCoreApplication::processEvents(QEventLoop::AllEvents, 100); }); @@ -78,40 +78,40 @@ void SystemAPI::PrepareForSleep(bool suspending){ auto now = QDateTime::currentMSecsSinceEpoch(); bool lockTimeout = autoLock(); if(lockTimeout){ - qDebug() << "Current timestamp:" << now; + O_DEBUG("Current timestamp:" << now); lockTimeout = now >= lockTimestamp; } if(lockOnSuspend() || lockTimeout){ if(lockTimeout){ - qDebug() << "Lock timer expired while suspended"; + O_DEBUG("Lock timer expired while suspended"); }else{ - qDebug() << "Always locking after suspend"; + O_DEBUG("Always locking after suspend"); } auto lockscreenApp = appsAPI->getApplication(appsAPI->lockscreenApplication()); if(lockscreenApp != nullptr){ - qDebug() << "Resume app set to lockscreen application"; + O_DEBUG("Resume app set to lockscreen application"); resumeApp = lockscreenApp; } } if(resumeApp == nullptr){ - qDebug() << "Resume app set to startup application"; + O_DEBUG("Resume app set to startup application"); resumeApp = appsAPI->getApplication(appsAPI->startupApplication()); } if(resumeApp != nullptr){ resumeApp->resumeNoSecurityCheck(); }else{ - qDebug() << "Unable to find an app to resume"; + O_WARNING("Unable to find an app to resume"); } }); Oxide::Sentry::sentry_span(t, "enable", "Enable various services", [this, device]{ buttonHandler->setEnabled(true); emit deviceResuming(); if(autoSleep() && powerAPI->chargerState() != PowerAPI::ChargerConnected){ - qDebug() << "Suspend timer re-enabled due to resume"; + O_DEBUG("Suspend timer re-enabled due to resume"); suspendTimer.start(autoSleep() * 60 * 1000); } if(autoLock()){ - qDebug() << "Lock timer re-enabled due to resume"; + O_DEBUG("Lock timer re-enabled due to resume"); lockTimer.start(autoLock() * 60 * 1000); } if(device == Oxide::DeviceSettings::DeviceType::RM2){ @@ -173,10 +173,10 @@ SystemAPI::SystemAPI(QObject* parent) Oxide::Sentry::sentry_span(t, "autoSleep", "Setup automatic sleep", [this](Oxide::Sentry::Span* s){ QSettings settings; if(QFile::exists(settings.fileName())){ - qDebug() << "Importing old settings"; + O_INFO("Importing old settings"); settings.sync(); if(settings.contains("autoSleep")){ - qDebug() << "Importing old autoSleep"; + O_DEBUG("Importing old autoSleep"); sharedSettings.set_autoSleep(settings.value("autoSleep").toInt()); } int size = settings.beginReadArray("swipes"); @@ -185,7 +185,7 @@ SystemAPI::SystemAPI(QObject* parent) for(short i = Right; i <= Down && i < size; i++){ settings.setArrayIndex(i); sharedSettings.setArrayIndex(i); - qDebug() << QString("Importing old swipe[%1]").arg(i); + O_DEBUG(QString("Importing old swipe[%1]").arg(i)); sharedSettings.setValue("enabled", settings.value("enabled", true)); sharedSettings.setValue("length", settings.value("length", 30)); } @@ -201,7 +201,7 @@ SystemAPI::SystemAPI(QObject* parent) }else if(autoSleep() > 10){ sharedSettings.set_autoSleep(10); } - qDebug() << "Auto Sleep" << autoSleep(); + O_DEBUG("Auto Sleep" << autoSleep()); Oxide::Sentry::sentry_span(s, "timer", "Setup timers", [this]{ if(autoSleep()){ suspendTimer.start(autoSleep() * 60 * 1000); @@ -278,12 +278,12 @@ SystemAPI::SystemAPI(QObject* parent) }); keyboardHandler; }); - qDebug() << "System API ready to use"; + O_INFO("System API ready to use"); }); } SystemAPI::~SystemAPI(){ - qDebug() << "Removing all inhibitors"; + O_INFO("Removing all inhibitors"); rguard(false); QMutableListIterator i(inhibitors); while(i.hasNext()){ @@ -295,7 +295,7 @@ SystemAPI::~SystemAPI(){ } void SystemAPI::setEnabled(bool enabled){ - qDebug() << "System API" << enabled; + O_INFO("System API" << enabled); } int SystemAPI::autoSleep(){return sharedSettings.autoSleep(); } @@ -304,7 +304,7 @@ void SystemAPI::setAutoSleep(int _autoSleep){ if(_autoSleep < 0 || _autoSleep > 360){ return; } - qDebug() << "Auto Sleep" << _autoSleep; + O_INFO("Auto Sleep" << _autoSleep); sharedSettings.set_autoSleep(_autoSleep); if(_autoSleep && powerAPI->chargerState() != PowerAPI::ChargerConnected){ suspendTimer.setInterval(_autoSleep * 60 * 1000); @@ -320,7 +320,7 @@ void SystemAPI::setAutoLock(int _autoLock){ if(_autoLock < 0 || _autoLock > 360){ return; } - qDebug() << "Auto Lock" << _autoLock; + O_INFO("Auto Lock" << _autoLock); sharedSettings.set_autoLock(_autoLock); lockTimer.setInterval(_autoLock * 60 * 1000); sharedSettings.sync(); @@ -330,7 +330,7 @@ void SystemAPI::setAutoLock(int _autoLock){ bool SystemAPI::lockOnSuspend(){return sharedSettings.lockOnSuspend(); } void SystemAPI::setLockOnSuspend(bool _lockOnSuspend){ sharedSettings.set_lockOnSuspend(_lockOnSuspend); - qDebug() << "Lock on Suspend" << _lockOnSuspend; + O_INFO("Lock on Suspend" << _lockOnSuspend); sharedSettings.sync(); emit lockOnSuspendChanged(_lockOnSuspend); } @@ -354,29 +354,29 @@ void SystemAPI::uninhibitAll(QString name){ } } if(!sleepInhibited() && autoSleep() && powerAPI->chargerState() != PowerAPI::ChargerConnected && !suspendTimer.isActive()){ - qDebug() << "Suspend timer re-enabled due to uninhibit" << name; + O_DEBUG("Suspend timer re-enabled due to uninhibit" << name); suspendTimer.start(autoSleep() * 60 * 1000); } } void SystemAPI::stopSuspendTimer(){ - qDebug() << "Suspend timer disabled"; + O_DEBUG("Suspend timer disabled"); suspendTimer.stop(); } void SystemAPI::stopLockTimer(){ - qDebug() << "Lock timer disabled"; + O_DEBUG("Lock timer disabled"); lockTimer.stop(); } void SystemAPI::startSuspendTimer(){ if(autoSleep() && powerAPI->chargerState() != PowerAPI::ChargerConnected && !suspendTimer.isActive()){ - qDebug() << "Suspend timer re-enabled due to start Suspend timer"; + O_DEBUG("Suspend timer re-enabled due to start Suspend timer"); suspendTimer.start(autoSleep() * 60 * 1000); } } void SystemAPI::startLockTimer(){ if(autoLock() && !lockTimer.isActive()){ - qDebug() << "Lock timer re-enabled due to start lock timer"; + O_DEBUG("Lock timer re-enabled due to start lock timer"); lockTimer.start(autoSleep() * 60 * 1000); } } @@ -398,7 +398,7 @@ void SystemAPI::setSwipeEnabled(int direction, bool enabled){ return; } if(direction <= SwipeDirection::None || direction > SwipeDirection::Down){ - qDebug() << "Invalid swipe direction: " << direction; + O_WARNING("Invalid swipe direction: " << direction); return; } setSwipeEnabled((SwipeDirection)direction, enabled); @@ -410,16 +410,16 @@ void SystemAPI::setSwipeEnabled(SwipeDirection direction, bool enabled){ } switch(direction){ case Left: - qDebug() << "Swipe Left: " << enabled; + O_INFO("Swipe Left: " << enabled); break; case Right: - qDebug() << "Swipe Right: " << enabled; + O_INFO("Swipe Right: " << enabled); break; case Up: - qDebug() << "Swipe Up: " << enabled; + O_INFO("Swipe Up: " << enabled); break; case Down: - qDebug() << "Swipe Down: " << enabled; + O_INFO("Swipe Down: " << enabled); break; default: return; @@ -440,7 +440,7 @@ bool SystemAPI::getSwipeEnabled(int direction){ return false; } if(direction <= SwipeDirection::None || direction > SwipeDirection::Down){ - qDebug() << "Invalid swipe direction: " << direction; + O_WARNING("Invalid swipe direction: " << direction); return false; } return getSwipeEnabled(direction); @@ -453,7 +453,7 @@ void SystemAPI::toggleSwipeEnabled(int direction){ return; } if(direction <= SwipeDirection::None || direction > SwipeDirection::Down){ - qDebug() << "Invalid swipe direction: " << direction; + O_WARNING("Invalid swipe direction: " << direction); return; } toggleSwipeEnabled((SwipeDirection)direction); @@ -467,7 +467,7 @@ void SystemAPI::setSwipeLength(int direction, int length){ return; } if(direction <= SwipeDirection::None || direction > SwipeDirection::Down){ - qDebug() << "Invalid swipe direction: " << direction; + O_WARNING("Invalid swipe direction: " << direction); return; } if(direction == SwipeDirection::Up || direction == SwipeDirection::Down){ @@ -476,7 +476,7 @@ void SystemAPI::setSwipeLength(int direction, int length){ maxLength = deviceSettings.getTouchWidth(); } if(length < 0 || length > maxLength){ - qDebug() << "Invalid swipe length: " << direction; + O_WARNING("Invalid swipe length: " << direction); return; } setSwipeLength((SwipeDirection)direction, length); @@ -488,16 +488,16 @@ void SystemAPI::setSwipeLength(SwipeDirection direction, int length){ } switch(direction){ case Left: - qDebug() << "Swipe Left Length: " << length; + O_INFO("Swipe Left Length: " << length); break; case Right: - qDebug() << "Swipe Right Length: " << length; + O_INFO("Swipe Right Length: " << length); break; case Up: - qDebug() << "Swipe Up Length: " << length; + O_INFO("Swipe Up Length: " << length); break; case Down: - qDebug() << "Swipe Down Length: " << length; + O_INFO("Swipe Down Length: " << length); break; default: return; @@ -519,7 +519,7 @@ int SystemAPI::getSwipeLength(int direction){ return -1; } if(direction <= SwipeDirection::None || direction > SwipeDirection::Down){ - qDebug() << "Invalid swipe direction: " << direction; + O_WARNING("Invalid swipe direction: " << direction); return -1; } return getSwipeLength((SwipeDirection)direction); @@ -529,56 +529,56 @@ int SystemAPI::getSwipeLength(SwipeDirection direction){ return swipeLengths[dir void SystemAPI::suspend(){ if(sleepInhibited()){ - qDebug() << "Unable to suspend. Action is currently inhibited."; + O_INFO("Unable to suspend. Action is currently inhibited."); return; } - qDebug() << "Requesting Suspend..."; + O_INFO("Requesting Suspend..."); systemd->Suspend(false).waitForFinished(); - qDebug() << "Suspend requested."; + O_INFO("Suspend requested."); } void SystemAPI::powerOff() { if(powerOffInhibited()){ - qDebug() << "Unable to power off. Action is currently inhibited."; + O_INFO("Unable to power off. Action is currently inhibited."); return; } - qDebug() << "Requesting Power off..."; + O_INFO("Requesting Power off..."); releasePowerOffInhibitors(true); rguard(false); systemd->PowerOff(false).waitForFinished(); - qDebug() << "Power off requested"; + O_INFO("Power off requested"); } void SystemAPI::reboot() { if(powerOffInhibited()){ - qDebug() << "Unable to reboot. Action is currently inhibited."; + O_INFO("Unable to reboot. Action is currently inhibited."); return; } - qDebug() << "Requesting Reboot..."; + O_INFO("Requesting Reboot..."); releasePowerOffInhibitors(true); rguard(false); systemd->Reboot(false).waitForFinished(); - qDebug() << "Reboot requested"; + O_INFO("Reboot requested"); } void SystemAPI::activity(){ auto active = suspendTimer.isActive(); suspendTimer.stop(); if(autoSleep() && powerAPI->chargerState() != PowerAPI::ChargerConnected){ if(!active){ - qDebug() << "Suspend timer re-enabled due to activity"; + O_DEBUG("Suspend timer re-enabled due to activity"); } suspendTimer.start(autoSleep() * 60 * 1000); }else if(active){ - qDebug() << "Suspend timer disabled"; + O_DEBUG("Suspend timer disabled"); } active = lockTimer.isActive(); if(autoLock()){ if(!active){ - qDebug() << "Lock timer re-enabled due to activity"; + O_DEBUG("Lock timer re-enabled due to activity"); } lockTimer.start(autoLock() * 60 * 1000); }else if(active){ - qDebug() << "Lock timer disabled"; + O_DEBUG("Lock timer disabled"); } } @@ -598,7 +598,7 @@ void SystemAPI::uninhibitSleep(QDBusMessage message){ sleepInhibitors.removeAll(message.service()); if(!sleepInhibited() && autoSleep() && powerAPI->chargerState() != PowerAPI::ChargerConnected){ if(!suspendTimer.isActive()){ - qDebug() << "Suspend timer re-enabled due to uninhibit sleep" << message.service(); + O_DEBUG("Suspend timer re-enabled due to uninhibit sleep" << message.service()); suspendTimer.start(autoSleep() * 60 * 1000); } releaseSleepInhibitors(true); @@ -627,7 +627,7 @@ void SystemAPI::uninhibitPowerOff(QDBusMessage message){ } void SystemAPI::suspendTimeout(){ if(autoSleep() && powerAPI->chargerState() != PowerAPI::ChargerConnected){ - qDebug() << "Automatic suspend due to inactivity..."; + O_INFO("Automatic suspend due to inactivity..."); suspend(); } } @@ -635,7 +635,7 @@ void SystemAPI::lockTimeout(){ if(autoLock()){ auto lockscreenApp = appsAPI->getApplication(appsAPI->lockscreenApplication()); if(lockscreenApp != nullptr){ - qDebug() << "Automatic lock due to inactivity..."; + O_INFO("Automatic lock due to inactivity..."); lockscreenApp->resumeNoSecurityCheck(); } } @@ -675,9 +675,7 @@ void SystemAPI::touchEvent(const input_event& event){ touchUp(released); } }else if(swipeDirection != None){ - if(Oxide::debugEnabled()){ - qDebug() << "Swiping cancelled due to pen activity"; - } + O_DEBUG("Swiping cancelled due to pen activity"); swipeDirection = None; } // Cleanup released touches @@ -746,9 +744,7 @@ void SystemAPI::penEvent(const input_event& event){ return; } penActive = event.value; - if(Oxide::debugEnabled()){ - qDebug() << "Pen state: " << (penActive ? "Active" : "Inactive"); - } + O_DEBUG("Pen state: " << (penActive ? "Active" : "Inactive")); } void SystemAPI::inhibitSleep(){ @@ -812,9 +808,7 @@ void SystemAPI::touchDown(QList touches){ if(penActive){ return; } - if(Oxide::debugEnabled()){ - qDebug() << "DOWN" << touches; - } + O_DEBUG("DOWN" << touches); if(getCurrentFingers() != 1){ return; } @@ -845,20 +839,14 @@ void SystemAPI::touchDown(QList touches){ }else{ return; } - if(Oxide::debugEnabled()){ - qDebug() << "Swipe started" << swipeDirection; - } + O_DEBUG("Swipe started" << swipeDirection); startLocation = location = QPoint(touch->x, touch->y); } void SystemAPI::touchUp(QList touches){ - if(Oxide::debugEnabled()){ - qDebug() << "UP" << touches; - } + O_DEBUG("UP" << touches); if(swipeDirection == None){ - if(Oxide::debugEnabled()){ - qDebug() << "Not swiping"; - } + O_DEBUG("Not swiping"); if(touchHandler->grabbed()){ for(auto touch : touches){ writeTouchUp(touch); @@ -868,9 +856,7 @@ void SystemAPI::touchUp(QList touches){ return; } if(getCurrentFingers()){ - if(Oxide::debugEnabled()){ - qDebug() << "Still swiping"; - } + O_DEBUG("Still swiping"); if(touchHandler->grabbed()){ for(auto touch : touches){ writeTouchUp(touch); @@ -879,9 +865,7 @@ void SystemAPI::touchUp(QList touches){ return; } if(touches.length() > 1){ - if(Oxide::debugEnabled()){ - qDebug() << "Too many fingers"; - } + O_DEBUG("Too many fingers"); if(touchHandler->grabbed()){ for(auto touch : touches){ writeTouchUp(touch); @@ -893,9 +877,7 @@ void SystemAPI::touchUp(QList touches){ } auto touch = touches.first(); if(touch->x == NULL_TOUCH_COORD || touch->y == NULL_TOUCH_COORD){ - if(Oxide::debugEnabled()){ - qDebug() << "Invalid touch event"; - } + O_DEBUG("Invalid touch event"); swipeDirection = None; return; } @@ -953,15 +935,11 @@ void SystemAPI::touchUp(QList touches){ touch->x = -1; touch->y = -1; writeTouchUp(touch); - if(Oxide::debugEnabled()){ - qDebug() << "Swipe direction" << swipeDirection; - } + O_DEBUG("Swipe direction" << swipeDirection); } void SystemAPI::touchMove(QList touches){ - if(Oxide::debugEnabled()){ - qDebug() << "MOVE" << touches; - } + O_DEBUG("MOVE" << touches); if(swipeDirection == None){ if(touchHandler->grabbed()){ for(auto touch : touches){ @@ -972,9 +950,7 @@ void SystemAPI::touchMove(QList touches){ return; } if(touches.length() > 1){ - if(Oxide::debugEnabled()){ - qDebug() << "Too many fingers"; - } + O_DEBUG("Too many fingers"); if(touchHandler->grabbed()){ for(auto touch : touches){ writeTouchMove(touch); @@ -991,9 +967,7 @@ void SystemAPI::touchMove(QList touches){ } void SystemAPI::cancelSwipe(Touch* touch){ - if(Oxide::debugEnabled()){ - qDebug() << "Swipe Cancelled"; - } + O_DEBUG("Swipe Cancelled"); swipeDirection = None; touchHandler->ungrab(); writeTouchUp(touch); @@ -1005,9 +979,7 @@ void SystemAPI::writeTouchUp(Touch* touch){ touchHandler->ungrab(); } writeTouchMove(touch); - if(Oxide::debugEnabled()){ - qDebug() << "Write touch up" << touch; - } + O_DEBUG("Write touch up" << touch); int size = sizeof(input_event) * 3; input_event* events = (input_event*)malloc(size); events[0] = DigitizerHandler::createEvent(EV_ABS, ABS_MT_SLOT, touch->slot); @@ -1025,9 +997,7 @@ void SystemAPI::writeTouchMove(Touch* touch){ if(grabbed){ touchHandler->ungrab(); } - if(Oxide::debugEnabled()){ - qDebug() << "Write touch move" << touch; - } + O_DEBUG("Write touch move" << touch); int count = 8; if(touch->x == NULL_TOUCH_COORD){ count--; @@ -1075,7 +1045,7 @@ void SystemAPI::toggleSwipes(){ setSwipeEnabled(Right, state); setSwipeEnabled(Up, state); QString message = state ? "Swipes Enabled" : "Swipes Disabled"; - qDebug() << message; + O_INFO(message); const QString& id = "system-swipe-toggle"; auto notification = notificationAPI->add(id, OXIDE_SERVICE, "tarnish", message, ""); if(notification == nullptr){ diff --git a/applications/system-service/wifiapi.cpp b/applications/system-service/wifiapi.cpp index 061695058..6f4a6a132 100644 --- a/applications/system-service/wifiapi.cpp +++ b/applications/system-service/wifiapi.cpp @@ -24,15 +24,15 @@ WifiAPI::WifiAPI(QObject* parent) }); Oxide::Sentry::sentry_span(t, "sysfs", "Finding wireless devices", [this](Oxide::Sentry::Span* s){ QDir dir("/sys/class/net"); - qDebug() << "Looking for wireless devices..."; + O_DEBUG("Looking for wireless devices..."); for(auto path : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::Readable)){ - qDebug() << (" Checking " + path + "...").toStdString().c_str(); + O_DEBUG((" Checking " + path + "...").toStdString().c_str()); Wlan* item = new Wlan(dir.path() + "/" + path, this); if(!item->hasDirectory("wireless")){ - qDebug() << " Not a wireless device"; + O_DEBUG(" Not a wireless device"); continue; } - qDebug() << " Wireless device found!"; + O_DEBUG(" Wireless device found!"); Oxide::Sentry::sentry_span(s, path.toStdString(), "Connect to wireless device", [this, item]{ wlans.append(item); connect(item, &Wlan::BSSAdded, this, &WifiAPI::BSSAdded, Qt::QueuedConnection); @@ -148,21 +148,21 @@ WifiAPI::WifiAPI(QObject* parent) } WifiAPI::~WifiAPI(){ - qDebug() << "Unregistering all networks"; + O_DEBUG("Unregistering all networks"); while(!networks.isEmpty()){ networks.takeFirst()->deleteLater(); } - qDebug() << "Unregistering all BSSs"; + O_DEBUG("Unregistering all BSSs"); while(!bsss.isEmpty()){ bsss.takeFirst()->deleteLater(); } - qDebug() << "Killing timer"; + O_DEBUG("Killing timer"); timer->stop(); timer->deleteLater(); } void WifiAPI::setEnabled(bool enabled){ - qDebug() << "Wifi API" << enabled; + O_INFO("Wifi API" << enabled); m_enabled = enabled; if(enabled){ for(auto network : networks){ @@ -209,17 +209,17 @@ bool WifiAPI::enable(){ if(!hasPermission("wifi")){ return false; } - qDebug() << "Turning wifi on"; + O_INFO("Turning wifi on"); if(m_state == Off){ setState(Disconnected); } if(system("/usr/sbin/rfkill unblock wifi")){ - qDebug() << "Failed to enable wifi devices"; + O_INFO("Failed to enable wifi devices"); return false; } for(auto wlan : wlans){ if(!wlan->isUp() && !wlan->up()){ - qDebug() << "Failed to enable " + wlan->iface(); + O_INFO("Failed to enable " + wlan->iface()); continue; } } @@ -228,7 +228,7 @@ bool WifiAPI::enable(){ auto state = getCurrentState(); m_state = state; if(state != Online){ - qDebug() << "State:" << state; + O_INFO("State:" << state); reconnect(); } return true; @@ -238,15 +238,15 @@ void WifiAPI::disable(){ if(!hasPermission("wifi")){ return; } - qDebug() << "Turning wifi off"; + O_INFO("Turning wifi off"); setState(Off); for(auto wlan : wlans){ if(wlan->isUp() && !wlan->down()){ - qDebug() << "Failed to disable " + wlan->iface(); + O_INFO("Failed to disable " + wlan->iface()); } } if(system("/usr/sbin/rfkill block wifi")){ - qDebug() << "Failed to disable wifi devices"; + O_INFO("Failed to disable wifi devices"); } flushBSSCache(0); xochitlSettings.set_wifion(false); @@ -344,7 +344,7 @@ void WifiAPI::reconnect(){ if(!hasPermission("wifi")){ return; } - qDebug() << "Reconnecting to wifi"; + O_INFO("Reconnecting to wifi"); QList> replies; for(auto interface : interfaces()){ replies.append(interface->Reconnect()); @@ -546,7 +546,7 @@ void WifiAPI::BSSAdded(Wlan* wlan, const QDBusObjectPath& path, const QVariantMa return; } } - qDebug() << "BSS added " << bssid.toUtf8().toHex() << ssid; + O_DEBUG("BSS added " << bssid.toUtf8().toHex() << ssid); auto bss = new BSS(getPath("bss", bssid), bssid, ssid, this); if(m_enabled){ bss->registerPath(); @@ -599,7 +599,7 @@ void WifiAPI::NetworkAdded(Wlan* wlan, const QDBusObjectPath& path, const QVaria return; } } - qDebug() << "Network added " << ssid; + O_INFO("Network added " << ssid); auto network = new Network(getPath("network", ssid), properties, this); network->addNetwork(path.path(), wlan->interface()); if(m_enabled){ @@ -620,7 +620,7 @@ void WifiAPI::NetworkRemoved(Wlan* wlan, const QDBusObjectPath& path){ i.remove(); emit network->removed(); emit networkRemoved(QDBusObjectPath(network->path())); - qDebug() << "Network removed " << network->ssid(); + O_INFO("Network removed " << network->ssid()); network->deleteLater(); } } @@ -630,7 +630,7 @@ void WifiAPI::NetworkSelected(Wlan* wlan, const QDBusObjectPath& path){ Q_UNUSED(wlan); for(auto network : networks){ if(network->paths().contains(path.path())){ - qDebug() << "Network selected" << path.path(); + O_INFO("Network selected" << path.path()); break; } } @@ -674,7 +674,7 @@ void WifiAPI::InterfaceRemoved(const QDBusObjectPath& path){ if(network->paths().empty()){ emit network->removed(); emit networkRemoved(QDBusObjectPath(network->path())); - qDebug() << "Network removed " << network->ssid(); + O_INFO("Network removed " << network->ssid()); } } wlan->removeInterface(); @@ -701,13 +701,13 @@ void WifiAPI::validateSupplicant(){ QStringList serviceNames = bus.interface()->registeredServiceNames(); if (!serviceNames.contains(WPA_SUPPLICANT_SERVICE)){ if(system("/bin/systemctl --quiet is-active wpa_supplicant")){ - qDebug() << "Starting wpa_supplicant..."; + O_INFO("Starting wpa_supplicant..."); if(system("/bin/systemctl --quiet start wpa_supplicant")){ qCritical() << "Failed to start wpa_supplicant"; throw QException(); } } - qDebug() << "Waiting for wpa_supplicant dbus service..."; + O_INFO("Waiting for wpa_supplicant dbus service..."); while(!serviceNames.contains(WPA_SUPPLICANT_SERVICE)){ struct timespec args{ .tv_sec = 1, @@ -720,16 +720,16 @@ void WifiAPI::validateSupplicant(){ } void WifiAPI::loadNetworks(){ - qDebug() << "Loading networks from settings..."; + O_INFO("Loading networks from settings..."); QList> registeredNetworks = xochitlSettings.wifinetworks().values(); - qDebug() << "Registering networks..."; + O_INFO("Registering networks..."); for(auto registration : registeredNetworks){ bool found = false; auto ssid = registration["ssid"].toString(); auto protocol = registration["protocol"].toString(); for(auto network : networks){ if(network->ssid() == ssid && network->protocol() == protocol){ - qDebug() << " Found network" << network->ssid(); + O_INFO(" Found network" << network->ssid()); found = true; if(network->password() != registration["password"].toString()){ network->setPassword(registration["password"].toString()); @@ -754,10 +754,10 @@ void WifiAPI::loadNetworks(){ } networks.append(network); emit networkAdded(QDBusObjectPath(network->path())); - qDebug() << " Registered network" << ssid; + O_INFO(" Registered network" << ssid); } } - qDebug() << "Loaded networks."; + O_INFO("Loaded networks."); } void WifiAPI::update(){ @@ -772,11 +772,11 @@ void WifiAPI::update(){ } auto path = network().path(); if((state == Online || state == Offline) && m_currentNetwork.path() != path){ - qDebug() << "Connected to" << path; + O_INFO("Connected to" << path); m_currentNetwork.setPath(path); emit networkConnected(m_currentNetwork); }else if((state == Disconnected || state == Off) && m_currentNetwork.path() != "/"){ - qDebug() << "Disconnected from" << m_currentNetwork.path(); + O_INFO("Disconnected from" << m_currentNetwork.path()); m_currentNetwork.setPath("/"); emit disconnected(); } diff --git a/applications/system-service/wlan.cpp b/applications/system-service/wlan.cpp index a3019090c..b92d37d45 100644 --- a/applications/system-service/wlan.cpp +++ b/applications/system-service/wlan.cpp @@ -40,7 +40,7 @@ bool Wlan::up() { return !system(("/sbin/ifconfig " + iface() + " up").toStdStri bool Wlan::down() { return !system(("/sbin/ifconfig " + iface() + " down").toStdString().c_str()); } -bool Wlan::isUp(){ return !system(("/sbin/ip addr show " + iface() + " | /bin/grep UP > /dev/null").toStdString().c_str()); } +bool Wlan::isUp(){ return !system(("/sbin/ip addr show " + iface() + " 2>&1 | /bin/grep UP > /dev/null").toStdString().c_str()); } Interface* Wlan::interface() { return m_interface; } @@ -68,8 +68,12 @@ bool Wlan::pingIP(std::string ip, const char* port) { } bool Wlan::isConnected(){ - auto ip = exec("/sbin/ip r | /bin/grep " + iface() + " | /bin/grep default | /usr/bin/awk '{print $3}'"); - return ip != "" && (pingIP(ip, "53") || pingIP(ip, "80")); + try{ + auto ip = exec("/sbin/ip r | /bin/grep " + iface() + " | /bin/grep default | /usr/bin/awk '{print $3}'"); + return ip != "" && (pingIP(ip, "53") || pingIP(ip, "80")); + }catch(const std::runtime_error&){ + return false; + } } int Wlan::link(){ @@ -84,15 +88,18 @@ int Wlan::link(){ return result; } O_WARNING("SignalPoll error: " << res.error()); - auto out = exec("/bin/grep " + iface() + " /proc/net/wireless | /usr/bin/awk '{print $3}'"); - if(QString(out.c_str()).isEmpty()){ - return 0; - } - try { - return std::stoi(out); - } - catch (const std::invalid_argument& e) { - qDebug() << "link failed: " << out.c_str(); + try{ + auto out = exec("/bin/grep " + iface() + " /proc/net/wireless | /usr/bin/awk '{print $3}'"); + if(QString(out.c_str()).isEmpty()){ + return 0; + } + try{ + return std::stoi(out); + }catch(const std::invalid_argument& e){ + O_WARNING("link failed: " << out.c_str()); + return 0; + } + }catch(const std::runtime_error&){ return 0; } return -100; @@ -110,15 +117,19 @@ signed int Wlan::rssi(){ return result; } O_WARNING("SignalPoll error: " << res.error()); - auto out = exec("/bin/grep " + iface() + " /proc/net/wireless | /usr/bin/awk '{print $4}'"); - if(QString(out.c_str()).isEmpty()){ - return 0; - } - try { - return std::stoi(out); - } - catch (const std::invalid_argument& e) { - qDebug() << "signal failed: " << out.c_str(); + try{ + auto out = exec("/bin/grep " + iface() + " /proc/net/wireless | /usr/bin/awk '{print $4}'"); + if(QString(out.c_str()).isEmpty()){ + return 0; + } + try { + return std::stoi(out); + } + catch (const std::invalid_argument& e) { + O_WARNING("signal failed: " << out.c_str()); + return 0; + } + }catch(const std::runtime_error&){ return 0; } return -100; @@ -159,7 +170,7 @@ std::string Wlan::exec(QString cmd) { std::array buffer; std::string result; std::unique_ptr pipe(popen(cmd.toStdString().c_str(), "r"), pclose); - if (!pipe) { + if(!pipe){ throw std::runtime_error("popen() failed!"); } while (fgets(buffer.data(), buffer.size(), pipe.get()) != nullptr) { diff --git a/qmake/common.pri b/qmake/common.pri index b5d623485..fcea1da5c 100644 --- a/qmake/common.pri +++ b/qmake/common.pri @@ -1,4 +1,4 @@ -VERSION = 2.8.2 +VERSION = 2.8.3 !contains(DEFINES, QT_DEPRECATED_WARNINGS){ DEFINES += QT_DEPRECATED_WARNINGS diff --git a/shared/liboxide/debug.h b/shared/liboxide/debug.h index 7a12cec5f..a1647080b 100644 --- a/shared/liboxide/debug.h +++ b/shared/liboxide/debug.h @@ -29,6 +29,12 @@ * \param msg Warning message to log */ #define O_WARNING(msg) if(Oxide::debugEnabled()){ qWarning() << msg; } +/*! + * \def O_INFO(msg) + * \brief Log an informational message + * \param msg Informational message to log + */ +#define O_INFO(msg) qInfo() << msg; namespace Oxide { /*! diff --git a/shared/liboxide/meta.h b/shared/liboxide/meta.h index 1e2038c22..530af2cd8 100644 --- a/shared/liboxide/meta.h +++ b/shared/liboxide/meta.h @@ -30,7 +30,7 @@ * \def OXIDE_VERSION * \brief Version of Tarnish and liboxide */ -#define OXIDE_VERSION "2.8.2" +#define OXIDE_VERSION "2.8.3" /*! * \def OXIDE_INTERFACE_VERSION * \brief Version of Tarnish and liboxide for dbus diff --git a/web/src/faq.rst b/web/src/faq.rst index 45e930c66..f6171d80d 100644 --- a/web/src/faq.rst +++ b/web/src/faq.rst @@ -50,20 +50,6 @@ On 2.5 or earlier you can use the following commands to disable telemetry: Alternatively, you can compile the applications manually without the ``sentry`` feature enabled. -How can I get the time to display in my timezone? -================================================= - -You can use `timedatectl `_ -to change your timezone. You can see available timezones by looking into ``/usr/share/zoneinfo/``. -Do not trust the output of ``timedatectl get-timezones`` as it reports more timezones than are -actually installed on the device by default. You can install more timezones on the device through -`Toltec `_ by installing one of the ``zoneinfo-*`` packages. - -.. code:: bash - - timedatectl set-timezone America/Denver - - I'm installing without `Toltec `_ and nothing displays? ===============================================================================