Commit c6418d66 authored by Allen Winter's avatar Allen Winter
Browse files

Move korgac up 1-level and out from under KOrganizer's source tree.

parent c6775eba
......@@ -36,7 +36,6 @@ if(NOT WINCE)
add_subdirectory(kcmconfigs)
endif()
endif()
add_subdirectory(korgac)
if(NOT WINCE)
set(PERL ${PERL_EXECUTABLE})
......@@ -253,7 +252,7 @@ if(NOT WINCE)
)
qt4_add_dbus_interfaces(korganizerprivate_LIB_SRCS
${CMAKE_SOURCE_DIR}/korganizer/korgac/org.kde.korganizer.KOrgac.xml
${CMAKE_SOURCE_DIR}/korgac/org.kde.korganizer.KOrgac.xml
)
qt4_add_dbus_interfaces(korganizerprivate_LIB_SRCS
......
remove_definitions(-DKDE_DEFAULT_DEBUG_AREA=5850) #remove korganizer debug area
add_definitions(-DKDE_DEFAULT_DEBUG_AREA=5890)
option(KORGAC_AKONADI_AGENT FALSE "Build Korgac as Akonadi agent instead of a stand-alone process")
if(KORGAC_AKONADI_AGENT)
add_definitions(-DKORGAC_AKONADI_AGENT)
endif()
add_subdirectory(pixmaps)
add_subdirectory(tests)
include_directories(
${CMAKE_SOURCE_DIR}/korganizer
${CMAKE_BINARY_DIR}/korganizer
)
########### next target ###############
set(korgac_SRCS
koalarmclient.cpp
)
if(KORGAC_AKONADI_AGENT)
set(korgac_SRCS ${korgac_SRCS} korgacagent.cpp)
else()
set(korgac_SRCS ${korgac_SRCS} korgacmain.cpp)
endif()
if(NOT WINCE)
set(korgac_SRCS
${korgac_SRCS}
alarmdialog.cpp
alarmdockwindow.cpp
mailclient.cpp
)
endif()
set(korganizer_xml ${CMAKE_SOURCE_DIR}/korganizer/org.kde.korganizer.Korganizer.xml)
qt4_add_dbus_interface(korgac_SRCS ${korganizer_xml}
korganizer_interface
)
qt4_add_dbus_adaptor(korgac_SRCS org.kde.korganizer.KOrgac.xml koalarmclient.h
KOAlarmClient
)
if(RUNTIME_PLUGINS_STATIC)
add_definitions(-DSERIALIZER_PLUGIN_STATIC)
endif()
kde4_add_app_icon(korgac_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/pixmap/hi*-apps-korganizer.png")
if(KORGAC_AKONADI_AGENT)
if(NOT WINCE)
kde4_add_plugin(korgac ${korgac_SRCS})
else()
kde4_add_plugin(korgac STATIC ${korgac_SRCS})
endif()
else()
kde4_add_executable(korgac ${korgac_SRCS})
if(Q_WS_MAC)
set_target_properties(korgac PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/Info.plist.template
)
set_target_properties(korgac PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER "org.kde.pim.korgac"
)
set_target_properties(korgac PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "KOrganizer Reminder Client"
)
endif()
endif()
target_link_libraries(korgac
akonadi-calendar
akonadi-kmime
calendarsupport
incidenceeditorsng
kdepim
kdepimdbusinterfaces
${KDEPIMLIBS_AKONADI_LIBS}
${KDEPIMLIBS_KCALCORE_LIBS}
${KDEPIMLIBS_KCALUTILS_LIBS}
${KDEPIMLIBS_KPIMIDENTITIES_LIBS}
${KDEPIMLIBS_MAILTRANSPORT_LIBS}
${KDE4_KDEUI_LIBS}
${KDE4_PHONON_LIBS}
)
if(RUNTIME_PLUGINS_STATIC)
target_link_libraries(korgac akonadi_serializer_kcalcore)
endif()
if(NOT WINCE)
target_link_libraries(korgac korganizer_core)
endif()
# TODO: move this to FindQt4.cmake
find_library(QT_QMAEMO5_LIBRARY QtMaemo5 HINTS ${QT_LIBRARY_DIR})
if(QT_QMAEMO5_LIBRARY)
target_link_libraries(korgac ${QT_QMAEMO5_LIBRARY})
endif()
if(KORGAC_AKONADI_AGENT)
install(TARGETS
korgac
DESTINATION ${PLUGIN_INSTALL_DIR}
)
install(FILES
korgacagent.desktop
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/akonadi/agents
)
else()
install(TARGETS
korgac ${INSTALL_TARGETS_DEFAULT_ARGS}
)
endif()
########### install files ###############
install(PROGRAMS
korgac.desktop
DESTINATION ${AUTOSTART_INSTALL_DIR}
)
install(FILES
org.kde.korganizer.KOrgac.xml
DESTINATION ${DBUS_INTERFACES_INSTALL_DIR}
)
// DOXYGEN_REFERENCES = kdecore kdeui
This diff is collapsed.
/*
This file is part of the KDE reminder agent.
Copyright (c) 2000 Cornelius Schumacher <schumacher@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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KORGAC_ALARMDIALOG_H
#define KORGAC_ALARMDIALOG_H
#include <Akonadi/Calendar/ETMCalendar>
#include <Akonadi/Item>
#include <KDialog>
#include <KCalCore/Incidence>
#include <KDateTime>
#include <QPoint>
#include <QTimer>
namespace CalendarSupport {
class IncidenceViewer;
}
namespace Akonadi {
class Item;
}
class ReminderListItem;
class KComboBox;
class QDateTime;
class QTreeWidget;
class QTreeWidgetItem;
class QSpinBox;
class QVBoxLayout;
class AlarmDialog : public KDialog
{
Q_OBJECT
public:
explicit AlarmDialog( const Akonadi::ETMCalendar::Ptr &calendar, QWidget *parent = 0 );
~AlarmDialog();
void addIncidence( const Akonadi::Item &incidence, const QDateTime &reminderAt,
const QString &displayText );
void setRemindAt( const QDateTime &dt );
void eventNotification();
public slots:
void slotOk(); // suspend
void slotUser1(); // edit
void slotUser2(); // dismiss all
void slotUser3(); // dismiss selected
void slotSave();
void wakeUp();
void show();
void edit();
void suspend();
void suspendAll();
void dismissAll();
void dismissCurrent();
/*reimp*/
void accept();
/**
If an incidence changed, for example in korg, we must update
the date and summary shown in the list view.
*/
void slotCalendarChanged();
signals:
void reminderCount( int count );
private Q_SLOTS:
void update();
void toggleDetails( QTreeWidgetItem *item, int column );
protected:
void keyPressEvent( QKeyEvent *e );
void closeEvent( QCloseEvent * );
private:
static KDateTime triggerDateForIncidence( const KCalCore::Incidence::Ptr &inc,
const QDateTime &reminderAt,
QString &displayStr );
// Removes each Incidence-X group that has one of the specified uids
void removeFromConfig( const QList<Akonadi::Item::Id> & );
// Opens through dbus, @deprecated
bool openIncidenceEditorThroughKOrganizer( const KCalCore::Incidence::Ptr &incidence );
// opens directly
bool openIncidenceEditorNG( const Akonadi::Item &incidence );
bool startKOrganizer();
ReminderListItem *searchByItem( const Akonadi::Item &incidence );
void setTimer();
void dismiss( QList<ReminderListItem *> selections );
int activeCount();
QList<ReminderListItem *> selectedItems() const;
void updateButtons();
void showDetails();
Akonadi::ETMCalendar::Ptr mCalendar;
QVBoxLayout *mTopLayout;
QTreeWidget *mIncidenceTree;
CalendarSupport::IncidenceViewer *mDetailView;
QPoint mPos;
QSpinBox *mSuspendSpin;
KComboBox *mSuspendUnit;
QTimer mSuspendTimer;
QTreeWidgetItem *mLastItem;
};
#endif
/*
This file is part of KOrganizer.
This file is part of the KDE reminder agent.
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2008-2009 Allen Winter <winter@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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include "alarmdockwindow.h"
#include <KAction>
#include <KActionCollection>
#include <KConfigGroup>
#include <KDebug>
#include <KIconEffect>
#include <KIconLoader>
#include <KLocale>
#include <KMessageBox>
#include <KMenu>
#include <KStandardAction>
#include <KToolInvocation>
AlarmDockWindow::AlarmDockWindow()
: KStatusNotifierItem( 0 )
{
// Read the autostart status from the config file
KConfigGroup config( KGlobal::config(), "General" );
bool autostartSet = config.hasKey( "Autostart" );
bool autostart = config.readEntry( "Autostart", true );
bool alarmsEnabled = config.readEntry( "Enabled", true );
mName = i18nc( "@title:window", "KOrganizer Reminder Daemon" );
setToolTipTitle( mName );
setToolTipIconByName( QLatin1String("korgac") );
// Set up icons
KIconLoader::global()->addAppDir( QLatin1String("korgac") );
KIconLoader::global()->addAppDir( QLatin1String("kdepim") );
QString iconPath = KIconLoader::global()->iconPath( QLatin1String("korgac"), KIconLoader::Panel );
QIcon iconEnabled = QIcon( iconPath );
if ( iconEnabled.isNull() ) {
KMessageBox::sorry( associatedWidget(),
i18nc( "@info", "Cannot load system tray icon." ) );
} else {
KIconLoader loader;
QImage iconDisabled =
iconEnabled.pixmap( loader.currentSize( KIconLoader::Panel ) ).toImage();
KIconEffect::toGray( iconDisabled, 1.0 );
mIconDisabled = QIcon( QPixmap::fromImage( iconDisabled ) );
}
changeSystrayIcon( alarmsEnabled );
// Set up the context menu
mSuspendAll =
contextMenu()->addAction( i18nc( "@action:inmenu", "Suspend All Reminders" ), this,
SLOT(slotSuspendAll()) );
mDismissAll =
contextMenu()->addAction( i18nc( "@action:inmenu", "Dismiss All Reminders" ), this,
SLOT(slotDismissAll()) );
mSuspendAll->setEnabled( false );
mDismissAll->setEnabled( false );
contextMenu()->addSeparator();
mAlarmsEnabled =
contextMenu()->addAction( i18nc( "@action:inmenu", "Enable Reminders" ) );
connect( mAlarmsEnabled, SIGNAL(toggled(bool)), SLOT(toggleAlarmsEnabled(bool)) );
mAlarmsEnabled->setCheckable( true );
mAutostart =
contextMenu()->addAction( i18nc( "@action:inmenu", "Start Reminder Daemon at Login" ) );
connect( mAutostart, SIGNAL(toggled(bool)), SLOT(toggleAutostart(bool)) );
mAutostart->setCheckable( true );
mAlarmsEnabled->setChecked( alarmsEnabled );
mAutostart->setChecked( autostart );
// Disable standard quit behaviour. We have to intercept the quit even,
// if the main window is hidden.
KActionCollection *ac = actionCollection();
const char *quitName = KStandardAction::name( KStandardAction::Quit );
QAction *quit = ac->action( QLatin1String(quitName) );
if ( !quit ) {
kDebug() << "No Quit standard action.";
} else {
quit->disconnect( SIGNAL(triggered(bool)), this, SLOT(maybeQuit()) );
connect( quit, SIGNAL(activated()), SLOT(slotQuit()) );
}
mAutostartSet = autostartSet;
}
AlarmDockWindow::~AlarmDockWindow()
{
}
void AlarmDockWindow::slotUpdate( int reminders )
{
bool actif = ( reminders > 0 );
mSuspendAll->setEnabled( actif );
mDismissAll->setEnabled( actif );
if ( actif ) {
setToolTip( QLatin1String("korgac"), mName, i18ncp( "@info:status",
"There is 1 active reminder.",
"There are %1 active reminders.", reminders ) );
} else {
setToolTip( QLatin1String("korgac"), mName, i18nc( "@info:status", "No active reminders." ) );
}
}
void AlarmDockWindow::toggleAlarmsEnabled( bool checked )
{
changeSystrayIcon( checked );
KConfigGroup config( KGlobal::config(), "General" );
config.writeEntry( "Enabled", checked );
config.sync();
}
void AlarmDockWindow::toggleAutostart( bool checked )
{
kDebug();
mAutostartSet = true;
enableAutostart( checked );
}
void AlarmDockWindow::slotSuspendAll()
{
emit suspendAllSignal();
}
void AlarmDockWindow::slotDismissAll()
{
emit dismissAllSignal();
}
void AlarmDockWindow::enableAutostart( bool enable )
{
KConfigGroup config( KGlobal::config(), "General" );
config.writeEntry( "Autostart", enable );
config.sync();
}
void AlarmDockWindow::activate( const QPoint &pos )
{
Q_UNUSED( pos );
KToolInvocation::startServiceByDesktopName( QLatin1String("korganizer"), QString() );
}
void AlarmDockWindow::slotQuit()
{
if ( mAutostartSet == true ) {
int result = KMessageBox::warningContinueCancel(
associatedWidget(),
i18nc( "@info",
"Do you want to quit the KOrganizer reminder daemon?<nl/>"
"<note> you will not get calendar reminders unless the daemon is running.</note>" ),
i18nc( "@title:window", "Close KOrganizer Reminder Daemon" ),
KStandardGuiItem::quit() );
if ( result == KMessageBox::Continue ) {
emit quitSignal();
}
} else {
int result = KMessageBox::questionYesNoCancel(
associatedWidget(),
i18nc( "@info",
"Do you want to start the KOrganizer reminder daemon at login?<nl/>"
"<note> you will not get calendar reminders unless the daemon is running.</note>" ),
i18nc( "@title:window", "Close KOrganizer Reminder Daemon" ),
KGuiItem( i18nc( "@action:button start the reminder daemon", "Start" ) ),
KGuiItem( i18nc( "@action:button do not start the reminder daemon", "Do Not Start" ) ),
KStandardGuiItem::cancel(),
QString::fromLatin1( "AskForStartAtLogin" ) );
bool autostart = true;
if ( result == KMessageBox::No ) {
autostart = false;
}
enableAutostart( autostart );
if ( result != KMessageBox::Cancel ) {
emit quitSignal();
}
}
}
void AlarmDockWindow::changeSystrayIcon( bool alarmsEnabled )
{
if ( alarmsEnabled ) {
setIconByName( QLatin1String("korgac") );
} else {
setIconByPixmap( mIconDisabled.pixmap( 22, 22 ) );
}
}
#include "alarmdockwindow.moc"
/*
This file is part of the KDE reminder agent.
Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
Copyright (c) 2008-2009 Allen Winter <winter@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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef KORGAC_ALARMDOCKWINDOW_H
#define KORGAC_ALARMDOCKWINDOW_H
#include <KStatusNotifierItem>
#include <QAction>
#include <QIcon>
class AlarmDockWindow : public KStatusNotifierItem
{
Q_OBJECT
public:
AlarmDockWindow();
virtual ~AlarmDockWindow();
void enableAutostart( bool enabled );
public slots:
void toggleAlarmsEnabled( bool checked );
void toggleAutostart( bool checked );
void slotUpdate( int reminders );
signals:
void quitSignal();
void suspendAllSignal();
void dismissAllSignal();
protected slots:
virtual void activate( const QPoint &pos );
void slotQuit();
void slotSuspendAll();
void slotDismissAll();
private:
void changeSystrayIcon( bool alarmsEnabled );
QIcon mIconDisabled;
QString mName;
QAction *mAlarmsEnabled;
QAction *mAutostart;
QAction *mSuspendAll;
QAction *mDismissAll;
bool mAutostartSet;
};
#endif
/*
This file is part of the KDE reminder agent.
Copyright (c) 2002,2003 Cornelius Schumacher <schumacher@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
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
//krazy:excludeall=kdebug because we use the korgac(check) debug area in here
#include "koalarmclient.h"
#if !defined(KORGAC_AKONADI_AGENT)
#include "alarmdialog.h"
#include "alarmdockwindow.h"
#else
#include <KNotification>
#endif
#include "korgacadaptor.h"
#include <calendarsupport/utils.h>
#include <Akonadi/Item>
#include <Akonadi/EntityTreeModel>
#include <Akonadi/ChangeRecorder>
#include <Akonadi/Session>
#include <Akonadi/Collection>
#include <Akonadi/ItemFetchScope>
#include <akonadi/dbusconnectionpool.h> // fix when forwarding header is there
#include <KCalCore/Calendar>
#include <KApplication>
#include <KCheckableProxyModel>
#include <KConfig>
#include <KConfigGroup>
#include <KDebug>
#include <KStandardDirs>
#include <KSystemTimeZones>
#ifdef Q_WS_MAEMO_5