Commit cc3f4845 authored by David Jarvie's avatar David Jarvie

Bug 316338: show warning if no writable active alarm calendars

If there are no enabled, writable active alarm calendars at startup,
display a warning message to explain why alarms can't be created or
changed.
parent db24d3e2
KAlarm Change Log
=== Version 2.10.2 --- 28 March 2013 ===
- Show startup warning message if no writable active alarm calendar is enabled.
=== Version 2.10.1 --- 10 December 2012 ===
- [Akonadi] Fix memory leak when an alarm message window is displayed.
- [Akonadi] Fix memory leak on alarm edit.
=== Version 2.10.0 (KDE 4.10 beta1)--- 13 November 2012 ===
=== Version 2.10.0 (KDE 4.10 beta1) --- 13 November 2012 ===
- Add --list command line option to list scheduled alarms to stdout.
- Add 'list' D-Bus command to return list of scheduled alarms.
- [Akonadi] Wait until calendars are populated before using them at startup.
......
/*
* kalarm.h - global header file
* Program: kalarm
* Copyright © 2001-2012 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2013 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -28,7 +28,7 @@
#else
#define VERSION_SUFFIX "-res"
#endif
#define KALARM_VERSION "2.10.1" VERSION_SUFFIX
#define KALARM_VERSION "2.10.2" VERSION_SUFFIX
#define KALARM_NAME "KAlarm"
#define KALARM_DBUS_SERVICE "org.kde.kalarm" // D-Bus service name of KAlarm application
......
/*
* kalarmapp.cpp - the KAlarm application object
* Program: kalarm
* Copyright © 2001-2012 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2013 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -115,6 +115,7 @@ KAlarmApp::KAlarmApp()
: KUniqueApplication(),
mInitialised(false),
mQuitting(false),
mReadOnly(false),
mLoginAlarmsDone(false),
mDBusHandler(new DBusHandler()),
mTrayWindow(0),
......@@ -167,6 +168,8 @@ KAlarmApp::KAlarmApp()
connect(AlarmCalendar::resources(), SIGNAL(atLoginEventAdded(KAEvent)), SLOT(atLoginEventAdded(KAEvent)));
connect(AkonadiModel::instance(), SIGNAL(collectionAdded(Akonadi::Collection)),
SLOT(purgeNewArchivedDefault(Akonadi::Collection)));
connect(AkonadiModel::instance(), SIGNAL(collectionTreeFetched(Akonadi::Collection::List)),
SLOT(checkWritableCalendar()));
#endif
KConfigGroup config(KGlobal::config(), "General");
......@@ -364,6 +367,7 @@ int KAlarmApp::newInstance()
// Output a list of scheduled alarms to stdout.
// Open the calendar, don't start processing execution queue yet,
// and wait for all Akonadi collections to be populated.
mReadOnly = true; // don't need write access to calendars
#ifdef USE_AKONADI
if (!initCheck(true, true))
#else
......@@ -526,6 +530,7 @@ int KAlarmApp::newInstance()
break;
case CommandOptions::CMD_ERROR:
mReadOnly = true; // don't need write access to calendars
exitCode = 1;
break;
}
......@@ -1105,6 +1110,41 @@ bool KAlarmApp::wantShowInSystemTray() const
return Preferences::showInSystemTray() && KSystemTrayIcon::isSystemTrayAvailable();
}
/******************************************************************************
* Called when all calendars have been fetched at startup.
* Check whether there are any writable active calendars, and if not, warn the
* user.
*/
void KAlarmApp::checkWritableCalendar()
{
kDebug();
if (mReadOnly)
return; // don't need write access to calendars
#ifdef USE_AKONADI
if (!AkonadiModel::instance()->isCollectionTreeFetched())
return;
#endif
static bool done = false;
if (done)
return;
done = true;
kDebug()<<"checking";
// Find whether there are any writable active alarm calendars
#ifdef USE_AKONADI
bool active = !CollectionControlModel::enabledCollections(CalEvent::ACTIVE, true).isEmpty();
#else
bool active = AlarmResources::instance()->activeCount(CalEvent::ACTIVE, true);
#endif
if (!active)
{
kWarning() << "No writable active calendar";
KAMessageBox::information(MainWindow::mainMainWindow(),
i18nc("@info", "Alarms cannot be created or updated, because no writable active alarm calendar is enabled.<nl/><nl/>"
"To fix this, use <interface>View | Show Calendars</interface> to check or change calendar statuses."),
QString(), QLatin1String("noWritableCal"));
}
}
#ifdef USE_AKONADI
/******************************************************************************
* Called when a new collection has been added, or when a collection has been
......@@ -2344,6 +2384,9 @@ bool KAlarmApp::initCheck(bool calendarOnly)
return false;
setArchivePurgeDays();
// Warn the user if there are no writable active alarm calendars
checkWritableCalendar();
firstTime = false;
}
......
/*
* kalarmapp.h - the KAlarm application object
* Program: kalarm
* Copyright © 2001-2012 by David Jarvie <djarvie@kde.org>
* Copyright © 2001-2013 by David Jarvie <djarvie@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -141,6 +141,7 @@ class KAlarmApp : public KUniqueApplication
void slotWorkTimeChanged(const QTime& start, const QTime& end, const QBitArray& days);
void slotHolidaysChanged(const KHolidays::HolidayRegion&);
void slotFeb29TypeChanged(Feb29Type);
void checkWritableCalendar();
void slotMessageFontChanged(const QFont&);
void setArchivePurgeDays();
void slotPurge() { purge(mArchivedPurgeDays); }
......@@ -230,6 +231,7 @@ class KAlarmApp : public KUniqueApplication
static QString mFatalMessage; // fatal error message to output
bool mInitialised; // initialisation complete: ready to process execution queue
bool mQuitting; // a forced quit is in progress
bool mReadOnly; // only read-only access to calendars is needed
bool mLoginAlarmsDone; // alarms repeated at login have been processed
DBusHandler* mDBusHandler; // the parent of the main DCOP receiver object
TrayWindow* mTrayWindow; // active system tray icon
......
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