Commit a3940fff authored by David Jarvie's avatar David Jarvie
Browse files

Improve debug messages

parent fe40ba8a
/*
* kalarmresource.cpp - Akonadi resource for KAlarm
* Program: kalarm
* Copyright © 2009-2019 by David Jarvie <djarvie@kde.org>
* Copyright © 2009-2019 David Jarvie <djarvie@kde.org>
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Library General Public License as published by
......@@ -52,7 +52,7 @@ KAlarmResource::KAlarmResource(const QString &id)
, mHaveReadFile(false)
, mFetchedAttributes(false)
{
qCDebug(KALARMRESOURCE_LOG) << id;
qCDebug(KALARMRESOURCE_LOG) << "Starting:" << id;
KAlarmResourceCommon::initialise(this);
initialise(mSettings->alarmTypes(), QStringLiteral("kalarm"));
connect(mSettings, &Settings::configChanged, this, &KAlarmResource::settingsChanged);
......@@ -70,7 +70,7 @@ KAlarmResource::~KAlarmResource()
*/
void KAlarmResource::retrieveCollections()
{
qCDebug(KALARMRESOURCE_LOG);
qCDebug(KALARMRESOURCE_LOG) << "retrieveCollections";
mSupportedMimetypes = mSettings->alarmTypes();
ICalResourceBase::retrieveCollections();
fetchCollection(SLOT(collectionFetchResult(KJob*)));
......@@ -85,23 +85,23 @@ void KAlarmResource::collectionFetchResult(KJob *j)
if (j->error()) {
// An error occurred. Note that if it's a new resource, it will complain
// about an invalid collection if the collection has not yet been created.
qCDebug(KALARMRESOURCE_LOG) << "Error: " << j->errorString();
qCDebug(KALARMRESOURCE_LOG) << "Error: collectionFetchResult:" << j->errorString();
} else {
bool firstTime = !mFetchedAttributes;
mFetchedAttributes = true;
CollectionFetchJob *job = static_cast<CollectionFetchJob *>(j);
const Collection::List collections = job->collections();
if (collections.isEmpty()) {
qCDebug(KALARMRESOURCE_LOG) << "Error: resource's collection not found";
qCDebug(KALARMRESOURCE_LOG) << "collectionFetchResult: resource's collection not found";
} else {
// Check whether calendar file format needs to be updated
qCDebug(KALARMRESOURCE_LOG) << "Fetched collection";
const Collection &c(collections[0]);
qCDebug(KALARMRESOURCE_LOG) << "collectionFetchResult: Fetched collection" << c.id();
if (firstTime && mSettings->path().isEmpty()) {
// Initialising a resource which seems to have no stored
// settings config file. Recreate the settings.
static const Collection::Rights writableRights = Collection::CanChangeItem | Collection::CanCreateItem | Collection::CanDeleteItem;
qCDebug(KALARMRESOURCE_LOG) << "Recreating config for remote id:" << c.remoteId();
qCDebug(KALARMRESOURCE_LOG) << "collectionFetchResult: Recreating config for remote id:" << c.remoteId();
mSettings->setPath(c.remoteId());
mSettings->setDisplayName(c.name());
mSettings->setAlarmTypes(c.contentMimeTypes());
......@@ -124,7 +124,7 @@ void KAlarmResource::collectionFetchResult(KJob *j)
*/
bool KAlarmResource::readFromFile(const QString &fileName)
{
qCDebug(KALARMRESOURCE_LOG) << fileName;
qCDebug(KALARMRESOURCE_LOG) << "readFromFile:" << fileName;
//TODO Notify user if error occurs on next line
if (!ICalResourceBase::readFromFile(fileName)) {
return false;
......@@ -187,9 +187,9 @@ void KAlarmResource::setCompatibility(KJob *j)
{
CollectionFetchJob *job = static_cast<CollectionFetchJob *>(j);
if (j->error()) {
qCDebug(KALARMRESOURCE_LOG) << "Error: " << j->errorString();
qCDebug(KALARMRESOURCE_LOG) << "Error: setCompatibility:" << j->errorString();
} else if (job->collections().isEmpty()) {
qCDebug(KALARMRESOURCE_LOG) << "Error: resource's collection not found";
qCDebug(KALARMRESOURCE_LOG) << "Error: setCompatibility: resource's collection not found";
} else {
KAlarmResourceCommon::setCollectionCompatibility(job->collections().at(0), mCompatibility, mVersion);
}
......@@ -201,7 +201,7 @@ void KAlarmResource::setCompatibility(KJob *j)
*/
bool KAlarmResource::writeToFile(const QString &fileName)
{
qCDebug(KALARMRESOURCE_LOG) << fileName;
qCDebug(KALARMRESOURCE_LOG) << "writeToFile:" << fileName;
if (calendar() && calendar()->incidences().isEmpty()) {
// It's an empty file. Set up the KAlarm custom property.
KACalendar::setKAlarmVersion(calendar());
......@@ -221,13 +221,13 @@ bool KAlarmResource::doRetrieveItem(const Akonadi::Item &item, const QSet<QByteA
const QString rid = item.remoteId();
const KCalCore::Event::Ptr kcalEvent = calendar()->event(rid);
if (!kcalEvent) {
qCWarning(KALARMRESOURCE_LOG) << "Event not found:" << rid;
qCWarning(KALARMRESOURCE_LOG) << "doRetrieveItem: Event not found:" << rid;
Q_EMIT error(errorMessage(KAlarmResourceCommon::UidNotFound, rid));
return false;
}
if (kcalEvent->alarms().isEmpty()) {
qCWarning(KALARMRESOURCE_LOG) << "KCalCore::Event has no alarms:" << rid;
qCWarning(KALARMRESOURCE_LOG) << "doRetrieveItem: KCalCore::Event has no alarms:" << rid;
Q_EMIT error(errorMessage(KAlarmResourceCommon::EventNoAlarms, rid));
return false;
}
......@@ -235,7 +235,7 @@ bool KAlarmResource::doRetrieveItem(const Akonadi::Item &item, const QSet<QByteA
KAEvent event(kcalEvent);
const QString mime = CalEvent::mimeType(event.category());
if (mime.isEmpty()) {
qCWarning(KALARMRESOURCE_LOG) << "KAEvent has no alarms:" << rid;
qCWarning(KALARMRESOURCE_LOG) << "doRetrieveItem: KAEvent has no alarms:" << rid;
Q_EMIT error(errorMessage(KAlarmResourceCommon::EventNoAlarms, rid));
return false;
}
......@@ -252,7 +252,7 @@ bool KAlarmResource::doRetrieveItem(const Akonadi::Item &item, const QSet<QByteA
*/
void KAlarmResource::settingsChanged()
{
qCDebug(KALARMRESOURCE_LOG);
qCDebug(KALARMRESOURCE_LOG) << "settingsChanged";
const QStringList mimeTypes = mSettings->alarmTypes();
if (mimeTypes != mSupportedMimetypes) {
mSupportedMimetypes = mimeTypes;
......@@ -274,38 +274,38 @@ void KAlarmResource::updateFormat(KJob *j)
{
CollectionFetchJob *job = static_cast<CollectionFetchJob *>(j);
if (j->error()) {
qCDebug(KALARMRESOURCE_LOG) << "Error: " << j->errorString();
qCDebug(KALARMRESOURCE_LOG) << "Error: updateFormat:" << j->errorString();
} else if (job->collections().isEmpty()) {
qCDebug(KALARMRESOURCE_LOG) << "Error: resource's collection not found";
qCDebug(KALARMRESOURCE_LOG) << "Error: updateFormat: resource's collection not found";
} else {
const Collection c(job->collections().at(0));
if (c.hasAttribute<CompatibilityAttribute>()) {
const CompatibilityAttribute *attr = c.attribute<CompatibilityAttribute>();
if (attr->compatibility() != mCompatibility) {
qCDebug(KALARMRESOURCE_LOG) << "Compatibility changed:" << mCompatibility << "->" << attr->compatibility();
qCDebug(KALARMRESOURCE_LOG) << "updateFormat: Compatibility changed:" << mCompatibility << "->" << attr->compatibility();
}
}
switch (mCompatibility) {
case KACalendar::Current:
qCWarning(KALARMRESOURCE_LOG) << "Already current storage format";
qCWarning(KALARMRESOURCE_LOG) << "updateFormat: Already current storage format";
break;
case KACalendar::Incompatible:
default:
qCWarning(KALARMRESOURCE_LOG) << "Incompatible storage format: compat=" << mCompatibility;
qCWarning(KALARMRESOURCE_LOG) << "updateFormat: Incompatible storage format: compat=" << mCompatibility;
break;
case KACalendar::Converted:
case KACalendar::Convertible:
{
if (mSettings->readOnly()) {
qCWarning(KALARMRESOURCE_LOG) << "Cannot update storage format for a read-only resource";
qCWarning(KALARMRESOURCE_LOG) << "updateFormat: Cannot update storage format for a read-only resource";
break;
}
// Update the backend storage format to the current KAlarm format
const QString filename = fileStorage()->fileName();
qCDebug(KALARMRESOURCE_LOG) << "Updating storage for" << filename;
qCDebug(KALARMRESOURCE_LOG) << "updateFormat: Updating storage for" << filename;
KACalendar::setKAlarmVersion(fileStorage()->calendar());
if (!writeToFile(filename)) {
qCWarning(KALARMRESOURCE_LOG) << "Error updating calendar storage format";
qCWarning(KALARMRESOURCE_LOG) << "updateFormat: Error updating calendar storage format";
break;
}
// Prevent a new file read being triggered by writeToFile(), which
......@@ -334,7 +334,7 @@ void KAlarmResource::itemAdded(const Akonadi::Item &item, const Akonadi::Collect
return;
}
if (mCompatibility != KACalendar::Current) {
qCWarning(KALARMRESOURCE_LOG) << "Calendar not in current format";
qCWarning(KALARMRESOURCE_LOG) << "itemAdded: Calendar not in current format";
cancelTask(errorMessage(KAlarmResourceCommon::NotCurrentFormat));
return;
}
......@@ -365,7 +365,7 @@ void KAlarmResource::itemChanged(const Akonadi::Item &item, const QSet<QByteArra
}
QString errorMsg;
if (mCompatibility != KACalendar::Current) {
qCWarning(KALARMRESOURCE_LOG) << "Calendar not in current format";
qCWarning(KALARMRESOURCE_LOG) << "itemChanged: Calendar not in current format";
cancelTask(errorMessage(KAlarmResourceCommon::NotCurrentFormat));
return;
}
......@@ -382,7 +382,7 @@ void KAlarmResource::itemChanged(const Akonadi::Item &item, const QSet<QByteArra
KCalCore::Incidence::Ptr incidence = calendar()->incidence(item.remoteId());
if (incidence) {
if (incidence->isReadOnly()) {
qCWarning(KALARMRESOURCE_LOG) << "Event is read only:" << event.id();
qCWarning(KALARMRESOURCE_LOG) << "itemChanged: Event is read only:" << event.id();
cancelTask(errorMessage(KAlarmResourceCommon::EventReadOnly, event.id()));
return;
}
......@@ -430,7 +430,7 @@ void KAlarmResource::collectionChanged(const Akonadi::Collection &collection)
*/
void KAlarmResource::doRetrieveItems(const Akonadi::Collection &collection)
{
qCDebug(KALARMRESOURCE_LOG);
qCDebug(KALARMRESOURCE_LOG) << "doRetrieveItems";
// Set the collection's compatibility status
KAlarmResourceCommon::setCollectionCompatibility(collection, mCompatibility, mVersion);
......@@ -440,14 +440,14 @@ void KAlarmResource::doRetrieveItems(const Akonadi::Collection &collection)
Item::List items;
for (const KCalCore::Event::Ptr &kcalEvent : qAsConst(events)) {
if (kcalEvent->alarms().isEmpty()) {
qCWarning(KALARMRESOURCE_LOG) << "KCalCore::Event has no alarms:" << kcalEvent->uid();
qCWarning(KALARMRESOURCE_LOG) << "doRetrieveItems: KCalCore::Event has no alarms:" << kcalEvent->uid();
continue; // ignore events without alarms
}
const KAEvent event(kcalEvent);
const QString mime = CalEvent::mimeType(event.category());
if (mime.isEmpty()) {
qCWarning(KALARMRESOURCE_LOG) << "KAEvent has no alarms:" << event.id();
qCWarning(KALARMRESOURCE_LOG) << "doRetrieveItems: KAEvent has no alarms:" << event.id();
continue; // event has no usable alarms
}
......
/*
* kalarmdirresource.cpp - Akonadi directory resource for KAlarm
* Program: kalarm
* Copyright © 2011-2016 by David Jarvie <djarvie@kde.org>
* Copyright © 2011-2019 David Jarvie <djarvie@kde.org>
* Copyright (c) 2008 Tobias Koenig <tokoe@kde.org>
* Copyright (c) 2008 Bertjan Broeksema <broeksema@kde.org>
*
......@@ -60,8 +60,8 @@ using KAlarmResourceCommon::errorMessage;
static const char warningFile[] = "WARNING_README.txt";
#define DEBUG_DATA \
qCDebug(KALARMDIRRESOURCE_LOG)<<"ID:Files:"; \
#define DEBUG_DATA(func) \
qCDebug(KALARMDIRRESOURCE_LOG)<<func<<"ID:Files:"; \
foreach (const QString &id, mEvents.uniqueKeys()) { qCDebug(KALARMDIRRESOURCE_LOG)<<id<<":"<<mEvents[id].files; } \
qCDebug(KALARMDIRRESOURCE_LOG)<<"File:IDs:"; \
foreach (const QString &f, mFileEventIds.uniqueKeys()) { qCDebug(KALARMDIRRESOURCE_LOG)<<f<<":"<<mFileEventIds[f]; }
......@@ -74,7 +74,7 @@ KAlarmDirResource::KAlarmDirResource(const QString &id)
, mCollectionFetched(false)
, mWaitingToRetrieve(false)
{
qCDebug(KALARMDIRRESOURCE_LOG) << id;
qCDebug(KALARMDIRRESOURCE_LOG) << "Starting:" << id;
KAlarmResourceCommon::initialise(this);
// Set up the resource
......@@ -118,12 +118,12 @@ void KAlarmDirResource::collectionFetchResult(KJob *j)
{
qCDebug(KALARMDIRRESOURCE_LOG);
if (j->error()) {
qCritical() << "CollectionFetchJob error: " << j->errorString();
qCritical() << "Error: collectionFetchResult: " << j->errorString();
} else {
CollectionFetchJob *job = static_cast<CollectionFetchJob *>(j);
Collection::List collections = job->collections();
int count = collections.count();
qCDebug(KALARMDIRRESOURCE_LOG) << "Count:" << count;
qCDebug(KALARMDIRRESOURCE_LOG) << "collectionFetchResult: count:" << count;
if (!count) {
qCritical() << "Cannot retrieve this resource's collection";
} else {
......@@ -131,7 +131,7 @@ void KAlarmDirResource::collectionFetchResult(KJob *j)
qCritical() << "Multiple collections for this resource:" << count;
}
Collection &c(collections[0]);
qCDebug(KALARMDIRRESOURCE_LOG) << "Id:" << c.id() << ", remote id:" << c.remoteId();
qCDebug(KALARMDIRRESOURCE_LOG) << "collectionFetchResult: id:" << c.id() << ", remote id:" << c.remoteId();
if (!mCollectionFetched) {
bool recreate = mSettings->path().isEmpty();
if (!recreate) {
......@@ -149,7 +149,7 @@ void KAlarmDirResource::collectionFetchResult(KJob *j)
// Initialising a resource which seems to have no stored
// settings config file. Recreate the settings.
static const Collection::Rights writableRights = Collection::CanChangeItem | Collection::CanCreateItem | Collection::CanDeleteItem;
qCDebug(KALARMDIRRESOURCE_LOG) << "Recreating config for remote id:" << c.remoteId();
qCDebug(KALARMDIRRESOURCE_LOG) << "collectionFetchResult: Recreating config for remote id:" << c.remoteId();
mSettings->setPath(c.remoteId());
mSettings->setDisplayName(c.name());
mSettings->setAlarmTypes(c.contentMimeTypes());
......@@ -179,7 +179,7 @@ void KAlarmDirResource::collectionFetchResult(KJob *j)
*/
void KAlarmDirResource::configure(WId windowId)
{
qCDebug(KALARMDIRRESOURCE_LOG);
qCDebug(KALARMDIRRESOURCE_LOG) << "configure";
// Keep note of the old configuration settings
QString path = mSettings->path();
QString name = mSettings->displayName();
......@@ -238,9 +238,9 @@ void KAlarmDirResource::configure(WId windowId)
*/
void KAlarmDirResource::changeAlarmTypes(CalEvent::Types removed)
{
DEBUG_DATA;
DEBUG_DATA("changeAlarmTypes:");
const QString dirPath = directoryName();
qCDebug(KALARMDIRRESOURCE_LOG) << dirPath;
qCDebug(KALARMDIRRESOURCE_LOG) << "changeAlarmTypes:" << dirPath;
const QDir dir(dirPath);
// Read and parse each file in turn
......@@ -296,7 +296,7 @@ void KAlarmDirResource::changeAlarmTypes(CalEvent::Types removed)
removeEventFile(fileEventId, file);
}
}
DEBUG_DATA;
DEBUG_DATA("changeAlarmTypes exit:");
setCompatibility();
}
......@@ -310,7 +310,7 @@ void KAlarmDirResource::changeAlarmTypes(CalEvent::Types removed)
*/
void KAlarmDirResource::settingsChanged()
{
qCDebug(KALARMDIRRESOURCE_LOG);
qCDebug(KALARMDIRRESOURCE_LOG) << "settingsChanged";
const QString display = mSettings->displayName();
if (display != name()) {
setName(display);
......@@ -380,7 +380,7 @@ bool KAlarmDirResource::loadFiles(bool sync)
if (dirPath.isEmpty()) {
return false;
}
qCDebug(KALARMDIRRESOURCE_LOG) << dirPath;
qCDebug(KALARMDIRRESOURCE_LOG) << "loadFiles:" << dirPath;
const QDir dir(dirPath);
// Create the directory if it doesn't exist.
......@@ -416,7 +416,7 @@ bool KAlarmDirResource::loadFiles(bool sync)
}
}
}
DEBUG_DATA;
DEBUG_DATA("loadFiles:");
setCompatibility(false); // don't write compatibility - no collection exists yet
......@@ -443,7 +443,7 @@ bool KAlarmDirResource::loadFiles(bool sync)
*/
KAEvent KAlarmDirResource::loadFile(const QString &path, const QString &file)
{
qCDebug(KALARMDIRRESOURCE_LOG) << path;
qCDebug(KALARMDIRRESOURCE_LOG) << "loadFile:" << path;
MemoryCalendar::Ptr calendar(new MemoryCalendar(QTimeZone::utc()));
FileStorage::Ptr fileStorage(new FileStorage(calendar, path, new ICalFormat()));
if (!fileStorage->load()) {
......@@ -479,11 +479,11 @@ KAEvent KAlarmDirResource::loadFile(const QString &path, const QString &file)
KAEvent event(kcalEvent);
const QString mime = CalEvent::mimeType(event.category());
if (mime.isEmpty()) {
qCWarning(KALARMDIRRESOURCE_LOG) << "KAEvent has no usable alarms:" << event.id();
qCWarning(KALARMDIRRESOURCE_LOG) << "loadFile: KAEvent has no usable alarms:" << event.id();
return KAEvent();
}
if (!mSettings->alarmTypes().contains(mime)) {
qCWarning(KALARMDIRRESOURCE_LOG) << "KAEvent has wrong alarm type for resource:" << mime;
qCWarning(KALARMDIRRESOURCE_LOG) << "loadFile: KAEvent has wrong alarm type for resource:" << mime;
return KAEvent();
}
event.setCompatibility(compat);
......@@ -523,7 +523,7 @@ bool KAlarmDirResource::retrieveItem(const Akonadi::Item &item, const QSet<QByte
const QString rid = item.remoteId();
QHash<QString, EventFile>::ConstIterator it = mEvents.constFind(rid);
if (it == mEvents.constEnd()) {
qCWarning(KALARMDIRRESOURCE_LOG) << "Event not found:" << rid;
qCWarning(KALARMDIRRESOURCE_LOG) << "retrieveItem: Event not found:" << rid;
Q_EMIT error(errorMessage(KAlarmResourceCommon::UidNotFound, rid));
return false;
}
......@@ -540,7 +540,7 @@ bool KAlarmDirResource::retrieveItem(const Akonadi::Item &item, const QSet<QByte
*/
void KAlarmDirResource::itemAdded(const Akonadi::Item &item, const Akonadi::Collection &)
{
qCDebug(KALARMDIRRESOURCE_LOG) << item.id();
qCDebug(KALARMDIRRESOURCE_LOG) << "itemAdded:" << item.id();
if (cancelIfReadOnly()) {
return;
}
......@@ -574,7 +574,7 @@ void KAlarmDirResource::itemAdded(const Akonadi::Item &item, const Akonadi::Coll
*/
void KAlarmDirResource::itemChanged(const Akonadi::Item &item, const QSet<QByteArray> &)
{
qCDebug(KALARMDIRRESOURCE_LOG) << item.id() << ", remote ID:" << item.remoteId();
qCDebug(KALARMDIRRESOURCE_LOG) << "itemChanged:" << item.id() << ", remote ID:" << item.remoteId();
if (cancelIfReadOnly()) {
return;
}
......@@ -632,7 +632,7 @@ void KAlarmDirResource::itemChanged(const Akonadi::Item &item, const QSet<QByteA
*/
void KAlarmDirResource::itemRemoved(const Akonadi::Item &item)
{
qCDebug(KALARMDIRRESOURCE_LOG) << item.id();
qCDebug(KALARMDIRRESOURCE_LOG) << "itemRemoved:" << item.id();
if (cancelIfReadOnly()) {
return;
}
......@@ -654,7 +654,7 @@ void KAlarmDirResource::removeEvent(const QString &eventId, bool deleteFile)
file = it.value().files[0];
nextFile = removeEventFile(eventId, file);
mFileEventIds.remove(file);
DEBUG_DATA;
DEBUG_DATA("removeEvent:");
}
if (deleteFile) {
QFile::remove(filePath(file));
......@@ -697,7 +697,7 @@ bool KAlarmDirResource::writeToFile(const KAEvent &event)
mChangedFiles += event.id(); // suppress KDirWatch processing for this write
const QString path = filePath(event.id());
qCDebug(KALARMDIRRESOURCE_LOG) << event.id() << " File:" << path;
qCDebug(KALARMDIRRESOURCE_LOG) << "writeToFile:" << event.id() << " File:" << path;
FileStorage::Ptr fileStorage(new FileStorage(calendar, path, new ICalFormat()));
if (!fileStorage->save()) {
Q_EMIT error(i18nc("@info", "Failed to save event file: %1", path));
......@@ -720,7 +720,7 @@ void KAlarmDirResource::retrieveCollections()
return;
}
qCDebug(KALARMDIRRESOURCE_LOG);
qCDebug(KALARMDIRRESOURCE_LOG) << "retrieveCollections";
Collection c;
c.setParentCollection(Collection::root());
c.setRemoteId(rid);
......@@ -741,7 +741,7 @@ void KAlarmDirResource::retrieveCollections()
*/
void KAlarmDirResource::setNameRights(Collection &c)
{
qCDebug(KALARMDIRRESOURCE_LOG);
qCDebug(KALARMDIRRESOURCE_LOG) << "setNameRights";
const QString display = mSettings->displayName();
c.setName(display.isEmpty() ? name() : display);
EntityDisplayAttribute *attr = c.attribute<EntityDisplayAttribute>(Collection::AddIfMissing);
......@@ -757,7 +757,7 @@ void KAlarmDirResource::setNameRights(Collection &c)
rights |= Collection::CanChangeCollection;
c.setRights(rights);
}
qCDebug(KALARMDIRRESOURCE_LOG) << "end";
qCDebug(KALARMDIRRESOURCE_LOG) << "setNameRights: end";
}
/******************************************************************************
......@@ -773,7 +773,7 @@ void KAlarmDirResource::setNameRights(Collection &c)
void KAlarmDirResource::retrieveItems(const Akonadi::Collection &collection)
{
mCollectionId = collection.id(); // note the one and only collection for this resource
qCDebug(KALARMDIRRESOURCE_LOG) << "Collection id:" << mCollectionId;
qCDebug(KALARMDIRRESOURCE_LOG) << "retrieveItems: collection" << mCollectionId;
// Set the collection's compatibility status
KAlarmResourceCommon::setCollectionCompatibility(collection, mCompatibility, mVersion);
......@@ -787,7 +787,7 @@ void KAlarmDirResource::retrieveItems(const Akonadi::Collection &collection)
const KAEvent &event = data.event;
const QString mime = CalEvent::mimeType(event.category());
if (mime.isEmpty()) {
qCWarning(KALARMDIRRESOURCE_LOG) << "KAEvent has no alarms:" << event.id();
qCWarning(KALARMDIRRESOURCE_LOG) << "retrieveItems: KAEvent has no alarms:" << event.id();
continue; // event has no usable alarms
}
if (!mimeTypes.contains(mime)) {
......@@ -809,7 +809,7 @@ void KAlarmDirResource::retrieveItems(const Akonadi::Collection &collection)
*/
void KAlarmDirResource::collectionChanged(const Akonadi::Collection &collection)
{
qCDebug(KALARMDIRRESOURCE_LOG);
qCDebug(KALARMDIRRESOURCE_LOG) << "collectionChanged";
// If the collection has a new display name, set the resource's display
// name the same, and save to the settings.
const QString newName = collection.displayName();
......@@ -829,7 +829,7 @@ void KAlarmDirResource::collectionChanged(const Akonadi::Collection &collection)
*/
void KAlarmDirResource::fileCreated(const QString &path)
{
qCDebug(KALARMDIRRESOURCE_LOG) << path;
qCDebug(KALARMDIRRESOURCE_LOG) << "fileCreated:" << path;
if (path == directoryName()) {
// The directory has been created. Load all files in it, and
// tell the Akonadi server to create an Item for each event.
......@@ -846,7 +846,7 @@ void KAlarmDirResource::fileCreated(const QString &path)
if (createItemAndIndex(path, file)) {
setCompatibility();
}
DEBUG_DATA;
DEBUG_DATA("fileCreated:");
}
}
}
......@@ -857,7 +857,7 @@ void KAlarmDirResource::fileCreated(const QString &path)
void KAlarmDirResource::fileChanged(const QString &path)
{
if (path != directoryName()) {
qCDebug(KALARMDIRRESOURCE_LOG) << path;
qCDebug(KALARMDIRRESOURCE_LOG) << "fileChanged:" << path;
const QString file = fileName(path);
int i = mChangedFiles.indexOf(file);
if (i >= 0) {
......@@ -905,7 +905,7 @@ void KAlarmDirResource::fileChanged(const QString &path)
} else {
modifyItem(event);
}
DEBUG_DATA;
DEBUG_DATA("fileChanged:");
}
}
}
......@@ -915,7 +915,7 @@ void KAlarmDirResource::fileChanged(const QString &path)
*/
void KAlarmDirResource::fileDeleted(const QString &path)
{
qCDebug(KALARMDIRRESOURCE_LOG) << path;
qCDebug(KALARMDIRRESOURCE_LOG) << "fileDeleted:" << path;
if (path == directoryName()) {
// The directory has been deleted
mEvents.clear();
......@@ -946,7 +946,7 @@ void KAlarmDirResource::fileDeleted(const QString &path)
// Tell the Akonadi server to delete the Item for the event
deleteItem(event);
}
DEBUG_DATA;
DEBUG_DATA("fileDeleted:");
}
}
}
......@@ -978,7 +978,7 @@ bool KAlarmDirResource::createItem(const KAEvent &event)
{
Item item;
if (!event.setItemPayload(item, mSettings->alarmTypes())) {
qCWarning(KALARMDIRRESOURCE_LOG) << "Invalid mime type for collection";
qCWarning(KALARMDIRRESOURCE_LOG) << "createItem: Invalid mime type for collection";
return false;
}
Collection c(mCollectionId);
......@@ -996,7 +996,7 @@ bool KAlarmDirResource::modifyItem(const KAEvent &event)
{
Item item;
if (!event.setItemPayload(item, mSettings->alarmTypes())) {
qCWarning(KALARMDIRRESOURCE_LOG) << "Invalid mime type for collection";
qCWarning(KALARMDIRRESOURCE_LOG) << "modifyItem: Invalid mime type for collection";
return false;
}
Collection c(mCollectionId);
......@@ -1038,13 +1038,13 @@ void KAlarmDirResource::jobDone(KJob *j)
*/
void KAlarmDirResource::initializeDirectory() const
{
qCDebug(KALARMDIRRESOURCE_LOG);
const QDir dir(directoryName());
const QString dirPath = dir.absolutePath();
qCDebug(KALARMDIRRESOURCE_LOG) << "initializeDirectory" << dirPath;
// If folder does not exist, create it
if (!dir.exists()) {
qCDebug(KALARMDIRRESOURCE_LOG) << "Creating" << dirPath;
qCDebug(KALARMDIRRESOURCE_LOG) << "initializeDirectory: creating" << dirPath;
QDir::root().mkpath(dirPath);
}
......
......@@ -192,7 +192,7 @@ void Private::modifyCollectionJobDone(KJob *j)
qDebug();
if (j->error()) {
Collection collection = static_cast<CollectionModifyJob *>(j)->collection();
qCritical() << "Error: collection id" << collection.id() << ":" << j->errorString();
qCritical() << "Error: modifyCollectionJobDone: collection" << collection.id() << ":" << j->errorString();
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment