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