Commit c0e09906 authored by David Jarvie's avatar David Jarvie

Ensure default Akonadi archived calendar is purged on startup

parent c0133486
......@@ -27,7 +27,9 @@
#include "commandoptions.h"
#include "dbushandler.h"
#include "editdlgtypes.h"
#ifndef USE_AKONADI
#ifdef USE_AKONADI
#include "collectionmodel.h"
#else
#include "eventlistmodel.h"
#endif
#include "functions.h"
......@@ -154,6 +156,8 @@ KAlarmApp::KAlarmApp()
connect(AlarmCalendar::resources(), SIGNAL(earliestAlarmChanged()), SLOT(checkNextDueAlarm()));
#ifdef USE_AKONADI
connect(AlarmCalendar::resources(), SIGNAL(atLoginEventAdded(KAEvent)), SLOT(atLoginEventAdded(KAEvent)));
connect(AkonadiModel::instance(), SIGNAL(collectionAdded(Akonadi::Collection)),
SLOT(slotCollectionAdded(Akonadi::Collection)));
#endif
KConfigGroup config(KGlobal::config(), "General");
......@@ -1027,6 +1031,40 @@ bool KAlarmApp::wantShowInSystemTray() const
return Preferences::showInSystemTray() && KSystemTrayIcon::isSystemTrayAvailable();
}
#ifdef USE_AKONADI
/******************************************************************************
* Called when a new collection has been added.
* If it is the default archived calendar, purge its old alarms if necessary.
*/
void KAlarmApp::slotCollectionAdded(const Akonadi::Collection& collection)
{
Akonadi::Collection col(collection);
if (CollectionControlModel::isStandard(col, KAlarm::CalEvent::ARCHIVED))
{
// Allow time (1 minute) for AkonadiModel to be populated with the
// collection's events before purging it.
kDebug() << collection.id() << ": standard archived...";
QTimer::singleShot(60000, this, SLOT(purgeAfterDelay()));
}
}
/******************************************************************************
* Called after a delay, after the default archived calendar has been added to
* AkonadiModel.
* Purge old alarms from it if necessary.
*/
void KAlarmApp::purgeAfterDelay()
{
#ifdef __GNUC__
#warning Purge after selecting a new default archived calendar
#endif
if (mArchivedPurgeDays >= 0)
purge(mArchivedPurgeDays);
else
setArchivePurgeDays();
}
#endif
/******************************************************************************
* Called when the length of time to keep archived alarms changes in KAlarm's
* preferences.
......
......@@ -28,7 +28,6 @@
#include "preferences.h"
#include <kuniqueapplication.h>
#include <kurl.h>
#include <QPointer>
#include <QQueue>
......@@ -36,6 +35,9 @@
class KDateTime;
namespace KCal { class Event; }
#ifdef USE_AKONADI
namespace Akonadi { class Collection; }
#endif
class DBusHandler;
class MainWindow;
class TrayWindow;
......@@ -130,6 +132,10 @@ class KAlarmApp : public KUniqueApplication
void slotMessageFontChanged(const QFont&);
void setArchivePurgeDays();
void slotPurge() { purge(mArchivedPurgeDays); }
#ifdef USE_AKONADI
void slotCollectionAdded(const Akonadi::Collection&);
void purgeAfterDelay();
#endif
void slotCommandExited(ShellProcess*);
void slotDBusServiceUnregistered(const QString& serviceName);
......
Markdown is supported
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