summaryrefslogtreecommitdiffabout
path: root/libkcal/scheduler.cpp
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (side-by-side diff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkcal/scheduler.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-p1.zip
kdepimpi-p1.tar.gz
kdepimpi-p1.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'libkcal/scheduler.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/scheduler.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/libkcal/scheduler.cpp b/libkcal/scheduler.cpp
index 253d8b7..234cfcf 100644
--- a/libkcal/scheduler.cpp
+++ b/libkcal/scheduler.cpp
@@ -1,71 +1,73 @@
/*
This file is part of libkcal.
Copyright (c) 2001 Cornelius Schumacher <schumacher@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 the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qdir.h>
#include <qfile.h>
-#include <qtextstream.h>
+#include <q3textstream.h>
+//Added by qt3to4:
+#include <Q3PtrList>
#include <klocale.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include "event.h"
#include "todo.h"
#include "freebusy.h"
#include "icalformat.h"
#include "calendar.h"
#include "scheduler.h"
using namespace KCal;
ScheduleMessage::ScheduleMessage(IncidenceBase *incidence,int method,ScheduleMessage::Status status)
{
mIncidence = incidence;
mMethod = method;
mStatus = status;
}
QString ScheduleMessage::statusName(ScheduleMessage::Status status)
{
switch (status) {
case PublishNew:
return i18n("Publish");
case Obsolete:
return i18n("Obsolete");
case RequestNew:
return i18n("New Request");
case RequestUpdate:
return i18n("Updated Request");
default:
return i18n("Unknown Status: %1").arg(QString::number(status));
}
}
Scheduler::Scheduler(Calendar *calendar)
{
mCalendar = calendar;
mFormat = new ICalFormat();
}
Scheduler::~Scheduler()
{
delete mFormat;
}
@@ -219,137 +221,137 @@ bool Scheduler::acceptRequest(IncidenceBase *incidence,ScheduleMessage::Status s
bool Scheduler::acceptAdd(IncidenceBase *incidence,ScheduleMessage::Status status)
{
deleteTransaction(incidence);
return false;
}
bool Scheduler::acceptCancel(IncidenceBase *incidence,ScheduleMessage::Status status)
{
bool ret = false;
Event *even = mCalendar->event(incidence->uid());
if (even) {
mCalendar->deleteEvent(even);
ret = true;
} else {
Todo *todo = mCalendar->todo(incidence->uid());
if (todo) {
mCalendar->deleteTodo(todo);
ret = true;
}
}
deleteTransaction(incidence);
return ret;
}
bool Scheduler::acceptDeclineCounter(IncidenceBase *incidence,ScheduleMessage::Status status)
{
deleteTransaction(incidence);
return false;
}
//bool Scheduler::acceptFreeBusy(Incidence *incidence,ScheduleMessage::Status status)
//{
// deleteTransaction(incidence);
// return false;
//}
bool Scheduler::acceptReply(IncidenceBase *incidence,ScheduleMessage::Status status, Method method)
{
if(incidence->type()=="FreeBusy") {
return acceptFreeBusy(incidence, method);
}
bool ret = false;
Event *ev = mCalendar->event(incidence->uid());
Todo *to = mCalendar->todo(incidence->uid());
if (ev || to) {
//get matching attendee in calendar
kdDebug(5800) << "Scheduler::acceptTransaction match found!" << endl;
- QPtrList<Attendee> attendeesIn = incidence->attendees();
- QPtrList<Attendee> attendeesEv;
+ Q3PtrList<Attendee> attendeesIn = incidence->attendees();
+ Q3PtrList<Attendee> attendeesEv;
if (ev) attendeesEv = ev->attendees();
if (to) attendeesEv = to->attendees();
Attendee *attIn;
Attendee *attEv;
for ( attIn = attendeesIn.first(); attIn; attIn = attendeesIn.next() ) {
for ( attEv = attendeesEv.first(); attEv; attEv = attendeesEv.next() ) {
if (attIn->email()==attEv->email()) {
//update attendee-info
kdDebug(5800) << "Scheduler::acceptTransaction update attendee" << endl;
attEv->setStatus(attIn->status());
attEv->setRSVP(false);
// better to not update the sequence number with replys
//if (ev) ev->setRevision(ev->revision()+1);
//if (to) to->setRevision(to->revision()+1);
ret = true;
}
}
}
}
if (ret) deleteTransaction(incidence);
return ret;
}
bool Scheduler::acceptRefresh(IncidenceBase *incidence,ScheduleMessage::Status status)
{
// handled in korganizer's IncomingDialog
deleteTransaction(incidence);
return false;
}
bool Scheduler::acceptCounter(IncidenceBase *incidence,ScheduleMessage::Status status)
{
deleteTransaction(incidence);
return false;
}
bool Scheduler::acceptFreeBusy(IncidenceBase *incidence, Method method)
{
FreeBusy *freebusy = static_cast<FreeBusy *>(incidence);
QString freeBusyDirName = locateLocal("appdata","freebusy");
kdDebug() << "acceptFreeBusy:: freeBusyDirName: " << freeBusyDirName << endl;
QString from;
if(method == Scheduler::Publish) {
from = freebusy->organizer();
}
if((method == Scheduler::Reply) && (freebusy->attendeeCount() == 1)) {
Attendee *attendee = freebusy->attendees().first();
from = attendee->email();
}
QDir freeBusyDir(freeBusyDirName);
if (!freeBusyDir.exists()) {
kdDebug() << "Directory " << freeBusyDirName << " does not exist!" << endl;
kdDebug() << "Creating directory: " << freeBusyDirName << endl;
if(!freeBusyDir.mkdir(freeBusyDirName, TRUE)) {
kdDebug() << "Could not create directory: " << freeBusyDirName << endl;
return false;
}
}
QString filename(freeBusyDirName);
filename += "/";
filename += from;
filename += ".ifb";
QFile f(filename);
kdDebug() << "acceptFreeBusy: filename" << filename << endl;
freebusy->clearAttendees();
freebusy->setOrganizer(from);
QString messageText = mFormat->createScheduleMessage(freebusy, Publish);
- if (!f.open(IO_ReadWrite)) {
+ if (!f.open(QIODevice::ReadWrite)) {
kdDebug() << "acceptFreeBusy: Can't open:" << filename << " for writing" << endl;
return false;
}
- QTextStream t(&f);
+ Q3TextStream t(&f);
t << messageText;
f.close();
deleteTransaction(incidence);
return true;
}