kalarmd Library API Documentation

koalarmclient.cpp

00001 /*
00002     KOrganizer Alarm Daemon Client.
00003 
00004     This file is part of KOrganizer.
00005     Copyright (c) 2002 Cornelius Schumacher
00006 
00007     This program is free software; you can redistribute it and/or modify
00008     it under the terms of the GNU General Public License as published by
00009     the Free Software Foundation; either version 2 of the License, or
00010     (at your option) any later version.
00011 
00012     This program is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015     GNU General Public License for more details.
00016 
00017     You should have received a copy of the GNU General Public License
00018     along with this program; if not, write to the Free Software
00019     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020 
00021     As a special exception, permission is given to link this program
00022     with any edition of Qt, and distribute the resulting executable,
00023     without including the source code for Qt in the source distribution.
00024 */
00025 
00026 #include <kdebug.h>
00027 #include <klocale.h>
00028 
00029 #include <libkcal/calendarlocal.h>
00030 #include <libkcal/icalformat.h>
00031 
00032 #include "alarmdockwindow.h"
00033 #include "alarmdialog.h"
00034 
00035 #include "koalarmclient.h"
00036 #include "koalarmclient.moc"
00037 
00038 KOAlarmClient::KOAlarmClient(QObject *parent, const char *name)
00039   : QObject(parent, name),
00040     DCOPObject("ac"),
00041     mSuspendTimer(this)
00042 {
00043   kdDebug(5900) << "KOAlarmClient::KOAlarmClient()" << endl;
00044 
00045   mDocker = new AlarmDockWindow(this);
00046   mDocker->show();
00047 
00048   mAlarmDialog = new AlarmDialog;
00049   connect(mAlarmDialog, SIGNAL(suspendSignal(int)), SLOT(suspend(int)));
00050 }
00051 
00052 KOAlarmClient::~KOAlarmClient()
00053 {
00054 }
00055 
00056 void KOAlarmClient::handleEvent( const QString &iCalendarString )
00057 {
00058 //  kdDebug(5900) << "KOAlarmClient::handleEvent()" << endl;
00059   
00060 //  kdDebug(5900) << "-- iCalendar-String:" << iCalendarString << endl;
00061 
00062   CalendarLocal cal;
00063   ICalFormat format;
00064   format.fromString( &cal, iCalendarString );
00065   
00066   QPtrList<Event> events = cal.events();
00067 
00068   Event *ev;
00069   for( ev = events.first(); ev; ev = events.next() ) {
00070     mAlarmDialog->appendEvent( new Event( *ev ) );
00071   }
00072 
00073   QPtrList<Todo> todos = cal.todos();
00074 
00075   Todo *todo;
00076   for( todo = todos.first(); todo; todo = todos.next() ) {
00077     mAlarmDialog->appendTodo( new Todo( *todo ) );
00078   }
00079   
00080   showAlarmDialog();
00081 }
00082 
00083 /* Schedule the alarm dialog for redisplay after a specified number of minutes */
00084 void KOAlarmClient::suspend(int minutes)
00085 {
00086 //  kdDebug(5900) << "KOAlarmClient::suspend() " << minutes << " minutes" << endl;
00087   connect(&mSuspendTimer, SIGNAL(timeout()), SLOT(showAlarmDialog()));
00088   mSuspendTimer.start(1000*60*minutes, true);
00089 }
00090 
00091 /* Display the alarm dialog (showing KOrganizer-type events) */
00092 void KOAlarmClient::showAlarmDialog()
00093 {
00094   mAlarmDialog->show();
00095   mAlarmDialog->eventNotification();
00096 }
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:22 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001