Commit ddf0db43 authored by Laurent Montel's avatar Laurent Montel 😁

Astyle kdelibs

parent b08719c5
......@@ -36,7 +36,6 @@
#include "statusadaptor.h"
#include "private/standarddirs_p.h"
#include "akonadiagentbase_debug.h"
#include <KLocalizedString>
......@@ -466,7 +465,7 @@ void AgentBasePrivate::setProgramName()
// ugly, really ugly, if you find another solution, change it and blame me for this code (Andras)
QString programName = mResourceTypeName;
if (!mName.isEmpty()) {
programName = i18nc("Name and type of Akonadi resource", "%1 of type %2", mName, mResourceTypeName) ;
programName = i18nc("Name and type of Akonadi resource", "%1 of type %2", mName, mResourceTypeName);
}
QGuiApplication::setApplicationDisplayName(programName);
......
......@@ -1015,7 +1015,7 @@ void ResourceBasePrivate::slotPrepareItemRetrieval(const Item &item)
auto fetch = new ItemFetchJob(item, this);
// we always need at least parent so we can use ItemCreateJob to merge
fetch->fetchScope().setAncestorRetrieval(qMax(ItemFetchScope::Parent,
q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
fetch->fetchScope().setCacheOnly(true);
fetch->fetchScope().setFetchRemoteIdentification(true);
......@@ -1055,7 +1055,7 @@ void ResourceBasePrivate::slotPrepareItemsRetrieval(const QVector<Item> &items)
ItemFetchJob *fetch = new ItemFetchJob(items, this);
// we always need at least parent so we can use ItemCreateJob to merge
fetch->fetchScope().setAncestorRetrieval(qMax(ItemFetchScope::Parent,
q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
q->changeRecorder()->itemFetchScope().ancestorRetrieval()));
fetch->fetchScope().setCacheOnly(true);
fetch->fetchScope().setFetchRemoteIdentification(true);
// It's possible that one or more items were removed before this task was
......@@ -1454,7 +1454,7 @@ bool ResourceBase::retrieveItem(const Akonadi::Item &item, const QSet<QByteArray
return false;
}
bool ResourceBase::retrieveItems(const Akonadi::Item::List& items, const QSet<QByteArray>& parts)
bool ResourceBase::retrieveItems(const Akonadi::Item::List &items, const QSet<QByteArray> &parts)
{
Q_D(ResourceBase);
......@@ -1470,7 +1470,6 @@ bool ResourceBase::retrieveItems(const Akonadi::Item::List& items, const QSet<QB
return true;
}
void Akonadi::ResourceBase::abortActivity()
{
}
......
......@@ -125,7 +125,7 @@ void ResourceScheduler::scheduleAttributesSync(const Collection &collection)
}
void ResourceScheduler::scheduleItemFetch(const Akonadi::Item &item, const QSet<QByteArray> &parts,
const QList<QDBusMessage> &msgs, qint64 parentId)
const QList<QDBusMessage> &msgs, qint64 parentId)
{
Task t;
......@@ -142,7 +142,6 @@ void ResourceScheduler::scheduleItemFetch(const Akonadi::Item &item, const QSet<
scheduleNext();
}
void ResourceScheduler::scheduleItemsFetch(const Item::List &items, const QSet<QByteArray> &parts, const QDBusMessage &msg)
{
Task t;
......@@ -342,7 +341,6 @@ void ResourceScheduler::itemFetchDone(const QString &msg)
taskDone();
}
void ResourceScheduler::deferTask()
{
if (mCurrentTask.type == Invalid) {
......
......@@ -44,10 +44,10 @@ int main(int argc, char *argv[])
QObject *instance = nullptr;
const bool invokeSucceeded = QMetaObject::invokeMethod(factory->instance(),
"createInstance",
Qt::DirectConnection,
Q_RETURN_ARG(QObject *, instance),
Q_ARG(QString, agentIdentifier));
"createInstance",
Qt::DirectConnection,
Q_RETURN_ARG(QObject *, instance),
Q_ARG(QString, agentIdentifier));
if (invokeSucceeded) {
qCDebug(AKONADIAGENTSERVER_LOG) << "Agent instance created in separate process.";
} else {
......
......@@ -38,7 +38,7 @@ AgentServer::AgentServer(QObject *parent)
, m_quiting(false)
{
QDBusConnection::sessionBus().registerObject(QStringLiteral(AKONADI_DBUS_AGENTSERVER_PATH),
this, QDBusConnection::ExportScriptableSlots);
this, QDBusConnection::ExportScriptableSlots);
}
AgentServer::~AgentServer()
......
......@@ -26,7 +26,8 @@
#include <QObject>
#include <QQueue>
namespace Akonadi {
namespace Akonadi
{
class AgentThread;
......
......@@ -40,10 +40,10 @@ AgentThread::AgentThread(const QString &identifier, QObject *factory, QObject *p
void AgentThread::run()
{
const bool invokeSucceeded = QMetaObject::invokeMethod(m_factory,
"createInstance",
Qt::DirectConnection,
Q_RETURN_ARG(QObject *, m_instance),
Q_ARG(QString, m_identifier));
"createInstance",
Qt::DirectConnection,
Q_RETURN_ARG(QObject *, m_instance),
Q_ARG(QString, m_identifier));
if (invokeSucceeded) {
qCDebug(AKONADIAGENTSERVER_LOG) << Q_FUNC_INFO << "agent instance created: " << m_instance;
} else {
......
......@@ -22,7 +22,8 @@
#include <QThread>
namespace Akonadi {
namespace Akonadi
{
/**
* @short A class that encapsulates an agent instance inside a thread.
......
......@@ -210,7 +210,7 @@ void AgentInstance::refreshResourceStatus()
void AgentInstance::errorHandler(const QDBusError &error)
{
//avoid using the server tracer, can result in D-BUS lockups
qCCritical(AKONADICONTROL_LOG) << QStringLiteral("D-Bus communication error '%1': '%2'").arg(error.name(), error.message()) ;
qCCritical(AKONADICONTROL_LOG) << QStringLiteral("D-Bus communication error '%1': '%2'").arg(error.name(), error.message());
// TODO try again after some time, esp. on timeout errors
}
......
......@@ -157,14 +157,14 @@ void AgentManager::cleanup()
mStorageController->setCrashPolicy(ProcessControl::StopOnCrash);
org::freedesktop::Akonadi::Server *serverIface =
new org::freedesktop::Akonadi::Server(Akonadi::DBus::serviceName(Akonadi::DBus::Server), QStringLiteral("/Server"),
QDBusConnection::sessionBus(), this);
QDBusConnection::sessionBus(), this);
serverIface->quit();
if (mAgentServer) {
mAgentServer->setCrashPolicy(ProcessControl::StopOnCrash);
org::freedesktop::Akonadi::AgentServer *agentServerIface =
new org::freedesktop::Akonadi::AgentServer(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer),
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus(), this);
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus(), this);
agentServerIface->quit();
}
......@@ -635,7 +635,7 @@ void AgentManager::serviceOwnerChanged(const QString &name, const QString &oldOw
if ((name == Akonadi::DBus::serviceName(Akonadi::DBus::Server) || name == Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer)) && !newOwner.isEmpty()) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::Server))
&& (!mAgentServer || QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer)))) {
&& (!mAgentServer || QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer)))) {
// server is operational, start agents
continueStartup();
}
......@@ -681,61 +681,61 @@ void AgentManager::serviceOwnerChanged(const QString &name, const QString &oldOw
break;
}
case Akonadi::DBus::Preprocessor: {
// A preprocessor service went up or down
// A preprocessor service went up or down
// If the preprocessor is going up then the org.freedesktop.Akonadi.Agent.* interface
// should be already up (as it's registered before the preprocessor one).
// So if we don't know about the preprocessor as agent instance
// then it's not our preprocessor.
// If the preprocessor is going up then the org.freedesktop.Akonadi.Agent.* interface
// should be already up (as it's registered before the preprocessor one).
// So if we don't know about the preprocessor as agent instance
// then it's not our preprocessor.
// If the preprocessor is going down then either the agent interface already
// went down (and it has been already unregistered on the manager side)
// or it's still registered as agent and WE have to unregister it.
// The order of interface deletions depends on Qt but we handle both cases.
// If the preprocessor is going down then either the agent interface already
// went down (and it has been already unregistered on the manager side)
// or it's still registered as agent and WE have to unregister it.
// The order of interface deletions depends on Qt but we handle both cases.
// Check if we "know" about it.
qCDebug(AKONADICONTROL_LOG) << "Preprocessor " << agentIdentifier << " is going up or down...";
// Check if we "know" about it.
qCDebug(AKONADICONTROL_LOG) << "Preprocessor " << agentIdentifier << " is going up or down...";
if (!mAgentInstances.contains(agentIdentifier)) {
qCDebug(AKONADICONTROL_LOG) << "But it isn't registered as agent... not mine (anymore?)";
return; // not our agent (?)
}
if (!mAgentInstances.contains(agentIdentifier)) {
qCDebug(AKONADICONTROL_LOG) << "But it isn't registered as agent... not mine (anymore?)";
return; // not our agent (?)
}
org::freedesktop::Akonadi::PreprocessorManager preProcessorManager(
Akonadi::DBus::serviceName(Akonadi::DBus::Server),
QStringLiteral("/PreprocessorManager"),
QDBusConnection::sessionBus(),
this);
org::freedesktop::Akonadi::PreprocessorManager preProcessorManager(
Akonadi::DBus::serviceName(Akonadi::DBus::Server),
QStringLiteral("/PreprocessorManager"),
QDBusConnection::sessionBus(),
this);
if (!preProcessorManager.isValid()) {
qCWarning(AKONADICONTROL_LOG) << "Could not connect to PreprocessorManager via D-Bus:" << preProcessorManager.lastError().message();
} else {
if (newOwner.isEmpty()) {
// The preprocessor went down. Unregister it on server side.
if (!preProcessorManager.isValid()) {
qCWarning(AKONADICONTROL_LOG) << "Could not connect to PreprocessorManager via D-Bus:" << preProcessorManager.lastError().message();
} else {
if (newOwner.isEmpty()) {
// The preprocessor went down. Unregister it on server side.
preProcessorManager.unregisterInstance(agentIdentifier);
preProcessorManager.unregisterInstance(agentIdentifier);
} else {
} else {
// The preprocessor went up. Register it on server side.
// The preprocessor went up. Register it on server side.
if (!mAgentInstances.value(agentIdentifier)->obtainPreprocessorInterface()) {
// Hm.. couldn't hook up its preprocessor interface..
// Make sure we don't have it in the preprocessor chain
qCWarning(AKONADICONTROL_LOG) << "Couldn't obtain preprocessor interface for instance" << agentIdentifier;
if (!mAgentInstances.value(agentIdentifier)->obtainPreprocessorInterface()) {
// Hm.. couldn't hook up its preprocessor interface..
// Make sure we don't have it in the preprocessor chain
qCWarning(AKONADICONTROL_LOG) << "Couldn't obtain preprocessor interface for instance" << agentIdentifier;
preProcessorManager.unregisterInstance(agentIdentifier);
return;
}
preProcessorManager.unregisterInstance(agentIdentifier);
return;
}
qCDebug(AKONADICONTROL_LOG) << "Registering preprocessor instance" << agentIdentifier;
qCDebug(AKONADICONTROL_LOG) << "Registering preprocessor instance" << agentIdentifier;
// Add to the preprocessor chain
preProcessorManager.registerInstance(agentIdentifier);
}
}
// Add to the preprocessor chain
preProcessorManager.registerInstance(agentIdentifier);
}
}
break;
break;
}
default:
break;
......@@ -764,7 +764,7 @@ bool AgentManager::checkResourceInterface(const QString &identifier, const QStri
if (!mAgentInstances[identifier]->hasResourceInterface()) {
qCWarning(AKONADICONTROL_LOG) << QLatin1String("AgentManager::") + method << " Agent instance "
<< identifier << " has no resource interface!";
<< identifier << " has no resource interface!";
return false;
}
......@@ -802,10 +802,10 @@ void AgentManager::ensureAutoStart(const AgentType &info)
}
org::freedesktop::Akonadi::AgentServer agentServer(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer),
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus(), this);
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus(), this);
if (mAgentInstances.contains(info.identifier) ||
(agentServer.isValid() && agentServer.started(info.identifier))) {
(agentServer.isValid() && agentServer.started(info.identifier))) {
return; // already running
}
......@@ -840,8 +840,8 @@ void AgentManager::registerAgentAtServer(const QString &agentIdentifier, const A
if (type.capabilities.contains(AgentType::CapabilityResource)) {
QScopedPointer<org::freedesktop::Akonadi::ResourceManager> resmanager(
new org::freedesktop::Akonadi::ResourceManager(Akonadi::DBus::serviceName(Akonadi::DBus::Server),
QStringLiteral("/ResourceManager"),
QDBusConnection::sessionBus(), this));
QStringLiteral("/ResourceManager"),
QDBusConnection::sessionBus(), this));
resmanager->addResourceInstance(agentIdentifier, type.capabilities);
}
}
......
......@@ -33,7 +33,8 @@ class QDir;
class QFileSystemWatcher;
#endif
namespace Akonadi {
namespace Akonadi
{
class ProcessControl;
}
......
......@@ -23,7 +23,8 @@
#include "agentinstance.h"
namespace Akonadi {
namespace Akonadi
{
class ProcessControl;
......
......@@ -32,8 +32,8 @@ AgentThreadInstance::AgentThreadInstance(AgentManager *manager)
: AgentInstance(manager)
{
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer),
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration, this);
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForRegistration, this);
connect(watcher, &QDBusServiceWatcher::serviceRegistered,
this, &AgentThreadInstance::agentServerRegistered);
}
......@@ -49,7 +49,7 @@ bool AgentThreadInstance::start(const AgentType &agentInfo)
mAgentType = agentInfo;
org::freedesktop::Akonadi::AgentServer agentServer(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer),
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus());
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus());
if (!agentServer.isValid()) {
qCDebug(AKONADICONTROL_LOG) << "AgentServer not up (yet?)";
return false;
......@@ -65,7 +65,7 @@ void AgentThreadInstance::quit()
AgentInstance::quit();
org::freedesktop::Akonadi::AgentServer agentServer(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer),
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus());
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus());
agentServer.stopAgent(identifier());
}
......@@ -73,7 +73,7 @@ void AgentThreadInstance::restartWhenIdle()
{
if (status() != 1 && !identifier().isEmpty()) {
org::freedesktop::Akonadi::AgentServer agentServer(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer),
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus());
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus());
agentServer.stopAgent(identifier());
agentServer.startAgent(identifier(), agentType(), mAgentType.exec);
}
......@@ -87,6 +87,6 @@ void AgentThreadInstance::agentServerRegistered()
void Akonadi::AgentThreadInstance::configure(qlonglong windowId)
{
org::freedesktop::Akonadi::AgentServer agentServer(Akonadi::DBus::serviceName(Akonadi::DBus::AgentServer),
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus());
QStringLiteral("/AgentServer"), QDBusConnection::sessionBus());
agentServer.agentInstanceConfigure(identifier(), windowId);
}
......@@ -22,7 +22,8 @@
#include "agentinstance.h"
#include "agenttype.h"
namespace Akonadi {
namespace Akonadi
{
class AgentThreadInstance : public AgentInstance
{
......
......@@ -82,7 +82,7 @@ int main(int argc, char **argv)
QGuiApplication::setFallbackSessionManagementEnabled(false);
// akonadi_control is started on-demand, no need to auto restart by session.
auto disableSessionManagement = [](QSessionManager &sm) {
auto disableSessionManagement = [](QSessionManager & sm) {
sm.setRestartHint(QSessionManager::RestartNever);
};
QObject::connect(qApp, &QGuiApplication::commitDataRequest, disableSessionManagement);
......
......@@ -131,7 +131,7 @@ void ProcessControl::slotFinished(int exitCode, QProcess::ExitStatus exitStatus)
} else {
if (exitCode != 0) {
qCWarning(AKONADICONTROL_LOG, "ProcessControl: Application '%s' returned with exit code %d (%s)",
qPrintable(mApplication), exitCode, qPrintable(mProcess.errorString()));
qPrintable(mApplication), exitCode, qPrintable(mProcess.errorString()));
if (mPolicy == RestartOnCrash) {
if (mCrashCount > s_maxCrashCount) {
qCWarning(AKONADICONTROL_LOG) << mApplication << "crashed too often and will not be restarted!";
......
......@@ -23,7 +23,8 @@
#include <QObject>
#include <QProcess>
namespace Akonadi {
namespace Akonadi
{
/**
* This class starts and observes a process. Depending on the
......@@ -82,7 +83,8 @@ public:
/**
* Restart the application the next time it exits normally.
*/
void restartOnceWhenFinished() {
void restartOnceWhenFinished()
{
mRestartOnceOnExit = true;
}
......
......@@ -38,8 +38,8 @@ AkonadiStarter::AkonadiStarter(QObject *parent)
, mRegistered(false)
{
QDBusServiceWatcher *watcher = new QDBusServiceWatcher(Akonadi::DBus::serviceName(Akonadi::DBus::ControlLock),
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForOwnerChange, this);
QDBusConnection::sessionBus(),
QDBusServiceWatcher::WatchForOwnerChange, this);
connect(watcher, &QDBusServiceWatcher::serviceOwnerChanged,
this, &AkonadiStarter::serviceOwnerChanged);
......
......@@ -27,7 +27,6 @@
#include <shared/akapplication.h>
#include "controlmanagerinterface.h"
#include "janitorinterface.h"
#include "akonadistarter.h"
......@@ -49,7 +48,7 @@
static bool startServer(bool verbose)
{
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::Control))
|| QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::Server))) {
|| QDBusConnection::sessionBus().interface()->isServiceRegistered(Akonadi::DBus::serviceName(Akonadi::DBus::Server))) {
std::cerr << "Akonadi is already running." << std::endl;
return false;
}
......@@ -60,8 +59,8 @@ static bool startServer(bool verbose)
static bool stopServer()
{
org::freedesktop::Akonadi::ControlManager iface(Akonadi::DBus::serviceName(Akonadi::DBus::Control),
QStringLiteral("/ControlManager"),
QDBusConnection::sessionBus(), nullptr);
QStringLiteral("/ControlManager"),
QDBusConnection::sessionBus(), nullptr);
if (!iface.isValid()) {
std::cerr << "Akonadi is not running." << std::endl;
return false;
......@@ -159,16 +158,16 @@ static bool statusServer()
static void runJanitor(const QString &operation)
{
org::freedesktop::Akonadi::Janitor janitor(Akonadi::DBus::serviceName(Akonadi::DBus::StorageJanitor),
QStringLiteral(AKONADI_DBUS_STORAGEJANITOR_PATH),
QDBusConnection::sessionBus());
QStringLiteral(AKONADI_DBUS_STORAGEJANITOR_PATH),
QDBusConnection::sessionBus());
QObject::connect(&janitor, &org::freedesktop::Akonadi::Janitor::information,
[](const QString &msg) {
std::cerr << msg.toStdString() << std::endl;
});
[](const QString & msg) {
std::cerr << msg.toStdString() << std::endl;
});
QObject::connect(&janitor, &org::freedesktop::Akonadi::Janitor::done,
[]() {
qApp->exit();
});
[]() {
qApp->exit();
});
janitor.asyncCall(operation);
qApp->exec();
}
......@@ -178,16 +177,15 @@ int main(int argc, char **argv)
AkCoreApplication app(argc, argv);
app.setDescription(QStringLiteral("Akonadi server manipulation tool\n\n"
"Commands:\n"
" start Starts the Akonadi server with all its processes\n"
" stop Stops the Akonadi server and all its processes cleanly\n"
" restart Restart Akonadi server with all its processes\n"
" status Shows a status overview of the Akonadi server\n"
" vacuum Vacuum internal storage (WARNING: needs a lot of time and disk\n"
" space