00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "kalarm.h"
00022
00023 #include <stdlib.h>
00024
00025 #include <kdebug.h>
00026
00027 #include <libkpimidentities/identitymanager.h>
00028 #include <libkpimidentities/identity.h>
00029
00030 #include "alarmcalendar.h"
00031 #include "daemon.h"
00032 #include "functions.h"
00033 #include "kalarmapp.h"
00034 #include "kamail.h"
00035 #include "karecurrence.h"
00036 #include "mainwindow.h"
00037 #include "preferences.h"
00038 #include "dcophandler.moc"
00039
00040 static const char* DCOP_OBJECT_NAME = "request";
00041 #ifdef OLD_DCOP
00042 static const char* DCOP_OLD_OBJECT_NAME = "display";
00043 #endif
00044
00045
00046
00047
00048
00049
00050 DcopHandler::DcopHandler()
00051 : DCOPObject(DCOP_OBJECT_NAME),
00052 QWidget()
00053 {
00054 kdDebug(5950) << "DcopHandler::DcopHandler()\n";
00055 }
00056
00057
00058 bool DcopHandler::cancelEvent(const QString& url,const QString& eventId)
00059 {
00060 return theApp()->deleteEvent(url, eventId);
00061 }
00062
00063 bool DcopHandler::triggerEvent(const QString& url,const QString& eventId)
00064 {
00065 return theApp()->triggerEvent(url, eventId);
00066 }
00067
00068 bool DcopHandler::scheduleMessage(const QString& message, const QString& startDateTime, int lateCancel, unsigned flags,
00069 const QString& bgColor, const QString& fgColor, const QString& font,
00070 const KURL& audioFile, int reminderMins, const QString& recurrence,
00071 int repeatInterval, int repeatCount)
00072 {
00073 DateTime start;
00074 KARecurrence recur;
00075 if (!convertRecurrence(start, recur, startDateTime, recurrence))
00076 return false;
00077 return scheduleMessage(message, start, lateCancel, flags, bgColor, fgColor, font, audioFile, reminderMins, recur, repeatInterval, repeatCount);
00078 }
00079
00080 bool DcopHandler::scheduleMessage(const QString& message, const QString& startDateTime, int lateCancel, unsigned flags,
00081 const QString& bgColor, const QString& fgColor, const QString& font,
00082 const KURL& audioFile, int reminderMins,
00083 int recurType, int recurInterval, int recurCount)
00084 {
00085 DateTime start;
00086 KARecurrence recur;
00087 if (!convertRecurrence(start, recur, startDateTime, recurType, recurInterval, recurCount))
00088 return false;
00089 return scheduleMessage(message, start, lateCancel, flags, bgColor, fgColor, font, audioFile, reminderMins, recur);
00090 }
00091
00092 bool DcopHandler::scheduleMessage(const QString& message, const QString& startDateTime, int lateCancel, unsigned flags,
00093 const QString& bgColor, const QString& fgColor, const QString& font,
00094 const KURL& audioFile, int reminderMins,
00095 int recurType, int recurInterval, const QString& endDateTime)
00096 {
00097 DateTime start;
00098 KARecurrence recur;
00099 if (!convertRecurrence(start, recur, startDateTime, recurType, recurInterval, endDateTime))
00100 return false;
00101 return scheduleMessage(message, start, lateCancel, flags, bgColor, fgColor, font, audioFile, reminderMins, recur);
00102 }
00103
00104 bool DcopHandler::scheduleFile(const KURL& file, const QString& startDateTime, int lateCancel, unsigned flags, const QString& bgColor,
00105 const KURL& audioFile, int reminderMins, const QString& recurrence,
00106 int repeatInterval, int repeatCount)
00107 {
00108 DateTime start;
00109 KARecurrence recur;
00110 if (!convertRecurrence(start, recur, startDateTime, recurrence))
00111 return false;
00112 return scheduleFile(file, start, lateCancel, flags, bgColor, audioFile, reminderMins, recur, repeatInterval, repeatCount);
00113 }
00114
00115 bool DcopHandler::scheduleFile(const KURL& file, const QString& startDateTime, int lateCancel, unsigned flags, const QString& bgColor,
00116 const KURL& audioFile, int reminderMins, int recurType, int recurInterval, int recurCount)
00117 {
00118 DateTime start;
00119 KARecurrence recur;
00120 if (!convertRecurrence(start, recur, startDateTime, recurType, recurInterval, recurCount))
00121 return false;
00122 return scheduleFile(file, start, lateCancel, flags, bgColor, audioFile, reminderMins, recur);
00123 }
00124
00125 bool DcopHandler::scheduleFile(const KURL& file, const QString& startDateTime, int lateCancel, unsigned flags, const QString& bgColor,
00126 const KURL& audioFile, int reminderMins, int recurType, int recurInterval, const QString& endDateTime)
00127 {
00128 DateTime start;
00129 KARecurrence recur;
00130 if (!convertRecurrence(start, recur, startDateTime, recurType, recurInterval, endDateTime))
00131 return false;
00132 return scheduleFile(file, start, lateCancel, flags, bgColor, audioFile, reminderMins, recur);
00133 }
00134
00135 bool DcopHandler::scheduleCommand(const QString& commandLine, const QString& startDateTime, int lateCancel, unsigned flags,
00136 const QString& recurrence, int repeatInterval, int repeatCount)
00137 {
00138 DateTime start;
00139 KARecurrence recur;
00140 if (!convertRecurrence(start, recur, startDateTime, recurrence))
00141 return false;
00142 return scheduleCommand(commandLine, start, lateCancel, flags, recur, repeatInterval, repeatCount);
00143 }
00144
00145 bool DcopHandler::scheduleCommand(const QString& commandLine, const QString& startDateTime, int lateCancel, unsigned flags,
00146 int recurType, int recurInterval, int recurCount)
00147 {
00148 DateTime start = convertStartDateTime(startDateTime);
00149 if (!start.isValid())
00150 return false;
00151 KARecurrence recur;
00152 if (!convertRecurrence(start, recur, startDateTime, recurType, recurInterval, recurCount))
00153 return false;
00154 return scheduleCommand(commandLine, start, lateCancel, flags, recur);
00155 }
00156
00157 bool DcopHandler::scheduleCommand(const QString& commandLine, const QString& startDateTime, int lateCancel, unsigned flags,
00158 int recurType, int recurInterval, const QString& endDateTime)
00159 {
00160 DateTime start;
00161 KARecurrence recur;
00162 if (!convertRecurrence(start, recur, startDateTime, recurType, recurInterval, endDateTime))
00163 return false;
00164 return scheduleCommand(commandLine, start, lateCancel, flags, recur);
00165 }
00166
00167 bool DcopHandler::scheduleEmail(const QString& fromID, const QString& addresses, const QString& subject, const QString& message,
00168 const QString& attachments, const QString& startDateTime, int lateCancel, unsigned flags,
00169 const QString& recurrence, int repeatInterval, int repeatCount)
00170 {
00171 DateTime start;
00172 KARecurrence recur;
00173 if (!convertRecurrence(start, recur, startDateTime, recurrence))
00174 return false;
00175 return scheduleEmail(fromID, addresses, subject, message, attachments, start, lateCancel, flags, recur, repeatInterval, repeatCount);
00176 }
00177
00178 bool DcopHandler::scheduleEmail(const QString& fromID, const QString& addresses, const QString& subject, const QString& message,
00179 const QString& attachments, const QString& startDateTime, int lateCancel, unsigned flags,
00180 int recurType, int recurInterval, int recurCount)
00181 {
00182 DateTime start;
00183 KARecurrence recur;
00184 if (!convertRecurrence(start, recur, startDateTime, recurType, recurInterval, recurCount))
00185 return false;
00186 return scheduleEmail(fromID, addresses, subject, message, attachments, start, lateCancel, flags, recur);
00187 }
00188
00189 bool DcopHandler::scheduleEmail(const QString& fromID, const QString& addresses, const QString& subject, const QString& message,
00190 const QString& attachments, const QString& startDateTime, int lateCancel, unsigned flags,
00191 int recurType, int recurInterval, const QString& endDateTime)
00192 {
00193 DateTime start;
00194 KARecurrence recur;
00195 if (!convertRecurrence(start, recur, startDateTime, recurType, recurInterval, endDateTime))
00196 return false;
00197 return scheduleEmail(fromID, addresses, subject, message, attachments, start, lateCancel, flags, recur);
00198 }
00199
00200 bool DcopHandler::edit(const QString& eventID)
00201 {
00202 return KAlarm::edit(eventID);
00203 }
00204
00205 bool DcopHandler::editNew(const QString& templateName)
00206 {
00207 return KAlarm::editNew(templateName);
00208 }
00209
00210
00211
00212
00213
00214 bool DcopHandler::scheduleMessage(const QString& message, const DateTime& start, int lateCancel, unsigned flags,
00215 const QString& bgColor, const QString& fgColor, const QString& fontStr,
00216 const KURL& audioFile, int reminderMins, const KARecurrence& recurrence,
00217 int repeatInterval, int repeatCount)
00218 {
00219 unsigned kaEventFlags = convertStartFlags(start, flags);
00220 QColor bg = convertBgColour(bgColor);
00221 if (!bg.isValid())
00222 return false;
00223 QColor fg;
00224 if (fgColor.isEmpty())
00225 fg = Preferences::defaultFgColour();
00226 else
00227 {
00228 fg.setNamedColor(fgColor);
00229 if (!fg.isValid())
00230 {
00231 kdError(5950) << "DCOP call: invalid foreground color: " << fgColor << endl;
00232 return false;
00233 }
00234 }
00235 QFont font;
00236 if (fontStr.isEmpty())
00237 kaEventFlags |= KAEvent::DEFAULT_FONT;
00238 else
00239 {
00240 if (!font.fromString(fontStr))
00241 {
00242 kdError(5950) << "DCOP call: invalid font: " << fontStr << endl;
00243 return false;
00244 }
00245 }
00246 return theApp()->scheduleEvent(KAEvent::MESSAGE, message, start.dateTime(), lateCancel, kaEventFlags, bg, fg, font,
00247 audioFile.url(), -1, reminderMins, recurrence, repeatInterval, repeatCount);
00248 }
00249
00250
00251
00252
00253 bool DcopHandler::scheduleFile(const KURL& file,
00254 const DateTime& start, int lateCancel, unsigned flags, const QString& bgColor,
00255 const KURL& audioFile, int reminderMins, const KARecurrence& recurrence,
00256 int repeatInterval, int repeatCount)
00257 {
00258 unsigned kaEventFlags = convertStartFlags(start, flags);
00259 QColor bg = convertBgColour(bgColor);
00260 if (!bg.isValid())
00261 return false;
00262 return theApp()->scheduleEvent(KAEvent::FILE, file.url(), start.dateTime(), lateCancel, kaEventFlags, bg, Qt::black, QFont(),
00263 audioFile.url(), -1, reminderMins, recurrence, repeatInterval, repeatCount);
00264 }
00265
00266
00267
00268
00269 bool DcopHandler::scheduleCommand(const QString& commandLine,
00270 const DateTime& start, int lateCancel, unsigned flags,
00271 const KARecurrence& recurrence, int repeatInterval, int repeatCount)
00272 {
00273 unsigned kaEventFlags = convertStartFlags(start, flags);
00274 return theApp()->scheduleEvent(KAEvent::COMMAND, commandLine, start.dateTime(), lateCancel, kaEventFlags, Qt::black, Qt::black, QFont(),
00275 QString::null, -1, 0, recurrence, repeatInterval, repeatCount);
00276 }
00277
00278
00279
00280
00281 bool DcopHandler::scheduleEmail(const QString& fromID, const QString& addresses, const QString& subject,
00282 const QString& message, const QString& attachments,
00283 const DateTime& start, int lateCancel, unsigned flags,
00284 const KARecurrence& recurrence, int repeatInterval, int repeatCount)
00285 {
00286 unsigned kaEventFlags = convertStartFlags(start, flags);
00287 if (!fromID.isEmpty())
00288 {
00289 if (KAMail::identityManager()->identityForName(fromID).isNull())
00290 {
00291 kdError(5950) << "DCOP call scheduleEmail(): unknown sender ID: " << fromID << endl;
00292 return false;
00293 }
00294 }
00295 EmailAddressList addrs;
00296 QString bad = KAMail::convertAddresses(addresses, addrs);
00297 if (!bad.isEmpty())
00298 {
00299 kdError(5950) << "DCOP call scheduleEmail(): invalid email addresses: " << bad << endl;
00300 return false;
00301 }
00302 if (addrs.isEmpty())
00303 {
00304 kdError(5950) << "DCOP call scheduleEmail(): no email address\n";
00305 return false;
00306 }
00307 QStringList atts;
00308 bad = KAMail::convertAttachments(attachments, atts);
00309 if (!bad.isEmpty())
00310 {
00311 kdError(5950) << "DCOP call scheduleEmail(): invalid email attachment: " << bad << endl;
00312 return false;
00313 }
00314 return theApp()->scheduleEvent(KAEvent::EMAIL, message, start.dateTime(), lateCancel, kaEventFlags, Qt::black, Qt::black, QFont(),
00315 QString::null, -1, 0, recurrence, repeatInterval, repeatCount, fromID, addrs, subject, atts);
00316 }
00317
00318
00319
00320
00321
00322
00323 DateTime DcopHandler::convertStartDateTime(const QString& startDateTime)
00324 {
00325 DateTime start;
00326 if (startDateTime.length() > 10)
00327 {
00328
00329 start = QDateTime::fromString(startDateTime, Qt::ISODate);
00330 }
00331 else
00332 {
00333
00334 QString t;
00335 if (startDateTime[0] == 'T')
00336 t = startDateTime.mid(1);
00337 else if (!startDateTime[2].isDigit())
00338 t = startDateTime;
00339
00340 if (t.isEmpty())
00341 {
00342
00343 start = QDate::fromString(startDateTime, Qt::ISODate);
00344 }
00345 else
00346 {
00347
00348 start.set(QDate::currentDate(), QTime::fromString(t, Qt::ISODate));
00349 }
00350 }
00351 if (!start.isValid())
00352 kdError(5950) << "DCOP call: invalid start date/time: " << startDateTime << endl;
00353 return start;
00354 }
00355
00356
00357
00358
00359 unsigned DcopHandler::convertStartFlags(const DateTime& start, unsigned flags)
00360 {
00361 unsigned kaEventFlags = 0;
00362 if (flags & REPEAT_AT_LOGIN) kaEventFlags |= KAEvent::REPEAT_AT_LOGIN;
00363 if (flags & BEEP) kaEventFlags |= KAEvent::BEEP;
00364 if (flags & SPEAK) kaEventFlags |= KAEvent::SPEAK;
00365 if (flags & CONFIRM_ACK) kaEventFlags |= KAEvent::CONFIRM_ACK;
00366 if (flags & REPEAT_SOUND) kaEventFlags |= KAEvent::REPEAT_SOUND;
00367 if (flags & AUTO_CLOSE) kaEventFlags |= KAEvent::AUTO_CLOSE;
00368 if (flags & EMAIL_BCC) kaEventFlags |= KAEvent::EMAIL_BCC;
00369 if (flags & SCRIPT) kaEventFlags |= KAEvent::SCRIPT;
00370 if (flags & EXEC_IN_XTERM) kaEventFlags |= KAEvent::EXEC_IN_XTERM;
00371 if (flags & SHOW_IN_KORG) kaEventFlags |= KAEvent::COPY_KORGANIZER;
00372 if (flags & DISABLED) kaEventFlags |= KAEvent::DISABLED;
00373 if (start.isDateOnly()) kaEventFlags |= KAEvent::ANY_TIME;
00374 return kaEventFlags;
00375 }
00376
00377
00378
00379
00380 QColor DcopHandler::convertBgColour(const QString& bgColor)
00381 {
00382 if (bgColor.isEmpty())
00383 return Preferences::defaultBgColour();
00384 QColor bg(bgColor);
00385 if (!bg.isValid())
00386 kdError(5950) << "DCOP call: invalid background color: " << bgColor << endl;
00387 return bg;
00388 }
00389
00390 bool DcopHandler::convertRecurrence(DateTime& start, KARecurrence& recurrence,
00391 const QString& startDateTime, const QString& icalRecurrence)
00392 {
00393 start = convertStartDateTime(startDateTime);
00394 if (!start.isValid())
00395 return false;
00396 return recurrence.set(icalRecurrence);
00397 }
00398
00399 bool DcopHandler::convertRecurrence(DateTime& start, KARecurrence& recurrence, const QString& startDateTime,
00400 int recurType, int recurInterval, int recurCount)
00401 {
00402 start = convertStartDateTime(startDateTime);
00403 if (!start.isValid())
00404 return false;
00405 return convertRecurrence(recurrence, start, recurType, recurInterval, recurCount, QDateTime());
00406 }
00407
00408 bool DcopHandler::convertRecurrence(DateTime& start, KARecurrence& recurrence, const QString& startDateTime,
00409 int recurType, int recurInterval, const QString& endDateTime)
00410 {
00411 start = convertStartDateTime(startDateTime);
00412 if (!start.isValid())
00413 return false;
00414 QDateTime end;
00415 if (endDateTime.find('T') < 0)
00416 {
00417 if (!start.isDateOnly())
00418 {
00419 kdError(5950) << "DCOP call: alarm is date-only, but recurrence end is date/time" << endl;
00420 return false;
00421 }
00422 end.setDate(QDate::fromString(endDateTime, Qt::ISODate));
00423 }
00424 else
00425 {
00426 if (start.isDateOnly())
00427 {
00428 kdError(5950) << "DCOP call: alarm is timed, but recurrence end is date-only" << endl;
00429 return false;
00430 }
00431 end = QDateTime::fromString(endDateTime, Qt::ISODate);
00432 }
00433 if (!end.isValid())
00434 {
00435 kdError(5950) << "DCOP call: invalid recurrence end date/time: " << endDateTime << endl;
00436 return false;
00437 }
00438 return convertRecurrence(recurrence, start, recurType, recurInterval, 0, end);
00439 }
00440
00441 bool DcopHandler::convertRecurrence(KARecurrence& recurrence, const DateTime& start, int recurType,
00442 int recurInterval, int recurCount, const QDateTime& end)
00443 {
00444 KARecurrence::Type type;
00445 switch (recurType)
00446 {
00447 case MINUTELY: type = KARecurrence::MINUTELY; break;
00448 case DAILY: type = KARecurrence::DAILY; break;
00449 case WEEKLY: type = KARecurrence::WEEKLY; break;
00450 case MONTHLY: type = KARecurrence::MONTHLY_DAY; break;
00451 case YEARLY: type = KARecurrence::ANNUAL_DATE; break;
00452 break;
00453 default:
00454 kdError(5950) << "DCOP call: invalid repeat type: " << recurType << endl;
00455 return false;
00456 }
00457 recurrence.set(type, recurInterval, recurCount, start, end);
00458 return true;
00459 }
00460
00461
00462 #ifdef OLD_DCOP
00463
00464
00465
00466
00467 DcopHandlerOld::DcopHandlerOld()
00468 : QWidget(),
00469 DCOPObject(DCOP_OLD_OBJECT_NAME)
00470 {
00471 kdDebug(5950) << "DcopHandlerOld::DcopHandlerOld()\n";
00472 }
00473
00474
00475
00476
00477 bool DcopHandlerOld::process(const QCString& func, const QByteArray& data, QCString& replyType, QByteArray&)
00478 {
00479 kdDebug(5950) << "DcopHandlerOld::process(): " << func << endl;
00480 enum
00481 {
00482 ERR = 0,
00483 OPERATION = 0x0007,
00484 HANDLE = 0x0001,
00485 CANCEL = 0x0002,
00486 TRIGGER = 0x0003,
00487 SCHEDULE = 0x0004,
00488 ALARM_TYPE = 0x00F0,
00489 MESSAGE = 0x0010,
00490 FILE = 0x0020,
00491 COMMAND = 0x0030,
00492 EMAIL = 0x0040,
00493 SCH_FLAGS = 0x0F00,
00494 REP_COUNT = 0x0100,
00495 REP_END = 0x0200,
00496 FONT = 0x0400,
00497 PRE_096 = 0x1000,
00498 PRE_091 = 0x2000 | PRE_096
00499 };
00500 replyType = "void";
00501 int function;
00502 if (func == "handleEvent(const QString&,const QString&)"
00503 || func == "handleEvent(QString,QString)")
00504 function = HANDLE;
00505 else if (func == "cancelEvent(const QString&,const QString&)"
00506 || func == "cancelEvent(QString,QString)")
00507 function = CANCEL;
00508 else if (func == "triggerEvent(const QString&,const QString&)"
00509 || func == "triggerEvent(QString,QString)")
00510 function = TRIGGER;
00511
00512
00513 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,const QColor&,Q_UINT32,const QString&,Q_INT32,const QString&)"
00514 || func == "scheduleMessage(QString,QDateTime,QColor,QColor,Q_UINT32,QString,Q_UINT32,QString)")
00515 function = SCHEDULE | MESSAGE;
00516
00517 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,const QColor&,const QFont&,Q_UINT32,const QString&,Q_INT32,const QString&)"
00518 || func == "scheduleMessage(QString,QDateTime,QColor,QColor,QFont,Q_UINT32,QString,Q_UINT32,QString)")
00519 function = SCHEDULE | MESSAGE | FONT;
00520
00521 else if (func == "scheduleFile(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,const QString&)"
00522 || func == "scheduleFile(QString,QDateTime,QColor,Q_UINT32,QString,Q_UINT32,QString)")
00523 function = SCHEDULE | FILE;
00524
00525 else if (func == "scheduleCommand(const QString&,const QDateTime&,Q_UINT32,const QString&)"
00526 || func == "scheduleCommand(QString,QDateTime,Q_UINT32,QString)")
00527 function = SCHEDULE | COMMAND;
00528
00529 else if (func == "scheduleEmail(const QString&,const QString&,const QString&,const QString&,const QDateTime&,Q_UINT32,const QString&)"
00530 || func == "scheduleEmail(QString,QString,QString,QString,QDateTime,Q_UINT32,QString)")
00531 function = SCHEDULE | EMAIL;
00532
00533
00534 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,Q_INT32,Q_INT32)"
00535 || func == "scheduleMessage(QString,QDateTime,QColor,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,Q_INT32,Q_INT32)")
00536 function = SCHEDULE | MESSAGE | REP_COUNT;
00537
00538 else if (func == "scheduleFile(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,Q_INT32,Q_INT32)"
00539 || func == "scheduleFile(QString,QDateTime,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,Q_INT32,Q_INT32)")
00540 function = SCHEDULE | FILE | REP_COUNT;
00541
00542 else if (func == "scheduleCommand(const QString&,const QDateTime&,Q_UINT32,Q_INT32,Q_INT32,Q_INT32)"
00543 || func == "scheduleCommand(QString,QDateTime,Q_UINT32,Q_INT32,Q_INT32,Q_INT32)")
00544 function = SCHEDULE | COMMAND | REP_COUNT;
00545
00546 else if (func == "scheduleEmail(const QString&,const QString&,const QString&,const QString&,const QDateTime&,Q_UINT32,Q_INT32,Q_INT32,Q_INT32)"
00547 || func == "scheduleEmail(QString,QString,QString,QString,QDateTime,Q_UINT32,Q_INT32,Q_INT32,Q_INT32)")
00548 function = SCHEDULE | EMAIL | REP_COUNT;
00549
00550
00551 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,Q_INT32,const QDateTime&)"
00552 || func == "scheduleMessage(QString,QDateTime,QColor,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,Q_INT32,QDateTime)")
00553 function = SCHEDULE | MESSAGE | REP_END;
00554
00555 else if (func == "scheduleFile(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,Q_INT32,const QDateTime&)"
00556 || func == "scheduleFile(QString,QDateTime,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,Q_INT32,QDateTime)")
00557 function = SCHEDULE | FILE | REP_END;
00558
00559 else if (func == "scheduleCommand(const QString&,const QDateTime&,Q_UINT32,Q_INT32,Q_INT32,const QDateTime&)"
00560 || func == "scheduleCommand(QString,QDateTime,Q_UINT32,Q_INT32,Q_INT32,QDateTime)")
00561 function = SCHEDULE | COMMAND | REP_END;
00562
00563 else if (func == "scheduleEmail(const QString&,const QString&,const QString&,const QString&,const QDateTime&,Q_UINT32,Q_INT32,Q_INT32,const QDateTime&)"
00564 || func == "scheduleEmail(QString,QString,QString,QString,QDateTime,Q_UINT32,Q_INT32,Q_INT32,QDateTime)")
00565 function = SCHEDULE | EMAIL | REP_END;
00566
00567
00568
00569 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,const QString&)"
00570 || func == "scheduleMessage(QString,QDateTime,QColor,Q_UINT32,QString,Q_UINT32,QString)")
00571 function = SCHEDULE | MESSAGE | PRE_096;
00572
00573 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,const QFont&,Q_UINT32,const QString&,Q_INT32,const QString&)"
00574 || func == "scheduleMessage(QString,QDateTime,QColor,QFont,Q_UINT32,QString,Q_UINT32,QString)")
00575 function = SCHEDULE | MESSAGE | FONT | PRE_096;
00576
00577 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,Q_INT32,Q_INT32)"
00578 || func == "scheduleMessage(QString,QDateTime,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,Q_INT32,Q_INT32)")
00579 function = SCHEDULE | MESSAGE | REP_COUNT | PRE_096;
00580
00581 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,Q_INT32,const QDateTime&)"
00582 || func == "scheduleMessage(QString,QDateTime,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,Q_INT32,QDateTime)")
00583 function = SCHEDULE | MESSAGE | REP_END | PRE_096;
00584
00585
00586
00587 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&)"
00588 || func == "scheduleMessage(QString,QDateTime,QColor,Q_UINT32,QString)")
00589 function = SCHEDULE | MESSAGE | PRE_091;
00590
00591 else if (func == "scheduleFile(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&)"
00592 || func == "scheduleFile(QString,QDateTime,QColor,Q_UINT32,QString)")
00593 function = SCHEDULE | FILE | PRE_091;
00594
00595 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,Q_INT32)"
00596 || func == "scheduleMessage(QString,QDateTime,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,Q_INT32)")
00597 function = SCHEDULE | MESSAGE | REP_COUNT | PRE_091;
00598
00599 else if (func == "scheduleFile(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,Q_INT32)"
00600 || func == "scheduleFile(QString,QDateTime,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,Q_INT32)")
00601 function = SCHEDULE | FILE | REP_COUNT | PRE_091;
00602
00603 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,const QDateTime&)"
00604 || func == "scheduleMessage(QString,QDateTime,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,QDateTime)")
00605 function = SCHEDULE | MESSAGE | REP_END | PRE_091;
00606
00607 else if (func == "scheduleFile(const QString&,const QDateTime&,const QColor&,Q_UINT32,const QString&,Q_INT32,Q_INT32,const QDateTime&)"
00608 || func == "scheduleFile(QString,QDateTime,QColor,Q_UINT32,QString,Q_INT32,Q_INT32,QDateTime)")
00609 function = SCHEDULE | FILE | REP_END | PRE_091;
00610
00611
00612 else if (func == "scheduleMessage(const QString&,const QDateTime&,const QColor&,Q_UINT32,Q_INT32,Q_INT32)"
00613 || func == "scheduleMessage(QString,QDateTime,QColor,Q_UINT32,Q_INT32,Q_INT32)"
00614 || func == "scheduleFile(const QString&,const QDateTime&,const QColor&,Q_UINT32,Q_INT32,Q_INT32)"
00615 || func == "scheduleFile(QString,QDateTime,QColor,Q_UINT32,Q_INT32,Q_INT32)"
00616 || func == "scheduleCommand(const QString&,const QDateTime&,Q_UINT32,Q_INT32,Q_INT32)"
00617 || func == "scheduleCommand(QString,QDateTime,Q_UINT32,Q_INT32,Q_INT32)"
00618
00619 || func == "cancelMessage(const QString&,const QString&)"
00620 || func == "cancelMessage(QString,QString)"
00621 || func == "displayMessage(const QString&,const QString&)"
00622 || func == "displayMessage(QString,QString)")
00623 {
00624 kdError(5950) << "DcopHandlerOld::process(): obsolete DCOP function call: '" << func << "'" << endl;
00625 return false;
00626 }
00627 else
00628 {
00629 kdError(5950) << "DcopHandlerOld::process(): unknown DCOP function" << endl;
00630 return false;
00631 }
00632
00633 switch (function & OPERATION)
00634 {
00635 case HANDLE:
00636 case CANCEL:
00637 case TRIGGER:
00638 {
00639
00640 QDataStream arg(data, IO_ReadOnly);
00641 QString urlString, vuid;
00642 arg >> urlString >> vuid;
00643 switch (function)
00644 {
00645 case HANDLE:
00646 return theApp()->handleEvent(urlString, vuid);
00647 case CANCEL:
00648 return theApp()->deleteEvent(urlString, vuid);
00649 case TRIGGER:
00650 return theApp()->triggerEvent(urlString, vuid);
00651 }
00652 break;
00653 }
00654 case SCHEDULE:
00655 {
00656 KAEvent::Action action;
00657 switch (function & ALARM_TYPE)
00658 {
00659 case MESSAGE: action = KAEvent::MESSAGE; break;
00660 case FILE: action = KAEvent::FILE; break;
00661 case COMMAND: action = KAEvent::COMMAND; break;
00662 case EMAIL: action = KAEvent::EMAIL; break;
00663 default: return false;
00664 }
00665 QDataStream arg(data, IO_ReadOnly);
00666 QString text, audioFile, mailSubject;
00667 float audioVolume = -1;
00668 EmailAddressList mailAddresses;
00669 QStringList mailAttachments;
00670 QDateTime dateTime, endTime;
00671 QColor bgColour;
00672 QColor fgColour(Qt::black);
00673 QFont font;
00674 Q_UINT32 flags;
00675 int lateCancel = 0;
00676 KARecurrence recurrence;
00677 Q_INT32 reminderMinutes = 0;
00678 if (action == KAEvent::EMAIL)
00679 {
00680 QString addresses, attachments;
00681 arg >> addresses >> mailSubject >> text >> attachments;
00682 QString bad = KAMail::convertAddresses(addresses, mailAddresses);
00683 if (!bad.isEmpty())
00684 {
00685 kdError(5950) << "DcopHandlerOld::process(): invalid email addresses: " << bad << endl;
00686 return false;
00687 }
00688 if (mailAddresses.isEmpty())
00689 {
00690 kdError(5950) << "DcopHandlerOld::process(): no email address\n";
00691 return false;
00692 }
00693 bad = KAMail::convertAttachments(attachments, mailAttachments);
00694 if (!bad.isEmpty())
00695 {
00696 kdError(5950) << "DcopHandlerOld::process(): invalid email attachment: " << bad << endl;
00697 return false;
00698 }
00699 }
00700 else
00701 arg >> text;
00702 arg.readRawBytes((char*)&dateTime, sizeof(dateTime));
00703 if (action != KAEvent::COMMAND)
00704 arg.readRawBytes((char*)&bgColour, sizeof(bgColour));
00705 if (action == KAEvent::MESSAGE && !(function & PRE_096))
00706 arg.readRawBytes((char*)&fgColour, sizeof(fgColour));
00707 if (function & FONT)
00708 {
00709 arg.readRawBytes((char*)&font, sizeof(font));
00710 arg >> flags;
00711 }
00712 else
00713 {
00714 arg >> flags;
00715 flags |= KAEvent::DEFAULT_FONT;
00716 }
00717 if (flags & KAEvent::LATE_CANCEL)
00718 lateCancel = 1;
00719 if (action == KAEvent::MESSAGE || action == KAEvent::FILE)
00720 {
00721 arg >> audioFile;
00722 if (!(function & PRE_091))
00723 arg >> reminderMinutes;
00724 }
00725 if (function & (REP_COUNT | REP_END))
00726 {
00727 KARecurrence::Type recurType;
00728 Q_INT32 recurCount = 0;
00729 Q_INT32 recurInterval;
00730 Q_INT32 type;
00731 arg >> type >> recurInterval;
00732 switch (type)
00733 {
00734 case 1: recurType = KARecurrence::MINUTELY; break;
00735 case 3: recurType = KARecurrence::DAILY; break;
00736 case 4: recurType = KARecurrence::WEEKLY; break;
00737 case 6: recurType = KARecurrence::MONTHLY_DAY; break;
00738 case 7: recurType = KARecurrence::ANNUAL_DATE; break;
00739 default:
00740 kdError(5950) << "DcopHandlerOld::process(): invalid simple repetition type: " << type << endl;
00741 return false;
00742 }
00743 if (function & REP_COUNT)
00744 arg >> recurCount;
00745 else
00746 arg.readRawBytes((char*)&endTime, sizeof(endTime));
00747 recurrence.set(recurType, recurInterval, recurCount,
00748 DateTime(dateTime, flags & KAEvent::ANY_TIME), endTime);
00749 }
00750 else if (!(function & PRE_091))
00751 {
00752 QString rule;
00753 arg >> rule;
00754 recurrence.set(rule);
00755 }
00756 return theApp()->scheduleEvent(action, text, dateTime, lateCancel, flags, bgColour, fgColour, font, audioFile,
00757 audioVolume, reminderMinutes, recurrence, 0, 0, QString::null, mailAddresses, mailSubject, mailAttachments);
00758 }
00759 }
00760 return false;
00761 }
00762 #endif // OLD_DCOP