summaryrefslogtreecommitdiffabout
path: root/libkcal/icalformatimpl.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) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkcal/icalformatimpl.cpp
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz
kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'libkcal/icalformatimpl.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/icalformatimpl.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 65eabc8..ea144ee 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -15,18 +15,21 @@
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <q3ptrlist.h>
24#include <qfile.h> 24#include <qfile.h>
25//Added by qt3to4:
26#include <Q3ValueList>
27#include <Q3CString>
25 28
26#include <kdebug.h> 29#include <kdebug.h>
27#include <klocale.h> 30#include <klocale.h>
28#include <kglobal.h> 31#include <kglobal.h>
29 32
30extern "C" { 33extern "C" {
31 #include <ical.h> 34 #include <ical.h>
32 #include <icalss.h> 35 #include <icalss.h>
@@ -216,18 +219,18 @@ icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy,
216 writeICalDateTime(freebusy->dtEnd()))); 219 writeICalDateTime(freebusy->dtEnd())));
217 220
218 if (method == Scheduler::Request) { 221 if (method == Scheduler::Request) {
219 icalcomponent_add_property(vfreebusy,icalproperty_new_uid( 222 icalcomponent_add_property(vfreebusy,icalproperty_new_uid(
220 freebusy->uid().utf8())); 223 freebusy->uid().utf8()));
221 } 224 }
222 225
223 //Loops through all the periods in the freebusy object 226 //Loops through all the periods in the freebusy object
224 QValueList<Period> list = freebusy->busyPeriods(); 227 Q3ValueList<Period> list = freebusy->busyPeriods();
225 QValueList<Period>::Iterator it; 228 Q3ValueList<Period>::Iterator it;
226 icalperiodtype period; 229 icalperiodtype period;
227 for (it = list.begin(); it!= list.end(); ++it) { 230 for (it = list.begin(); it!= list.end(); ++it) {
228 period.start = writeICalDateTime((*it).start()); 231 period.start = writeICalDateTime((*it).start());
229 period.end = writeICalDateTime((*it).end()); 232 period.end = writeICalDateTime((*it).end());
230 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); 233 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) );
231 } 234 }
232 235
233 return vfreebusy; 236 return vfreebusy;
@@ -379,22 +382,22 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
379 DateList::ConstIterator exIt; 382 DateList::ConstIterator exIt;
380 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 383 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
381 icalcomponent_add_property(parent,icalproperty_new_exdate( 384 icalcomponent_add_property(parent,icalproperty_new_exdate(
382 writeICalDate(*exIt))); 385 writeICalDate(*exIt)));
383 } 386 }
384 } 387 }
385 388
386 // attachments 389 // attachments
387 QPtrList<Attachment> attachments = incidence->attachments(); 390 Q3PtrList<Attachment> attachments = incidence->attachments();
388 for (Attachment *at = attachments.first(); at; at = attachments.next()) 391 for (Attachment *at = attachments.first(); at; at = attachments.next())
389 icalcomponent_add_property(parent,writeAttachment(at)); 392 icalcomponent_add_property(parent,writeAttachment(at));
390 393
391 // alarms 394 // alarms
392 QPtrList<Alarm> alarms = incidence->alarms(); 395 Q3PtrList<Alarm> alarms = incidence->alarms();
393 Alarm* alarm; 396 Alarm* alarm;
394 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
395 if (alarm->enabled()) { 398 if (alarm->enabled()) {
396 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
397 icalcomponent_add_component(parent,writeAlarm(alarm)); 400 icalcomponent_add_component(parent,writeAlarm(alarm));
398 } 401 }
399 } 402 }
400 if( incidence->hasRecurrenceID() ) { 403 if( incidence->hasRecurrenceID() ) {
@@ -418,31 +421,31 @@ void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *inc
418 writeICalDateTime(QDateTime::currentDateTime()))); 421 writeICalDateTime(QDateTime::currentDateTime())));
419 422
420 // organizer stuff 423 // organizer stuff
421 icalcomponent_add_property(parent,icalproperty_new_organizer( 424 icalcomponent_add_property(parent,icalproperty_new_organizer(
422 ("MAILTO:" + incidenceBase->organizer()).utf8())); 425 ("MAILTO:" + incidenceBase->organizer()).utf8()));
423 426
424 // attendees 427 // attendees
425 if (incidenceBase->attendeeCount() != 0) { 428 if (incidenceBase->attendeeCount() != 0) {
426 QPtrList<Attendee> al = incidenceBase->attendees(); 429 Q3PtrList<Attendee> al = incidenceBase->attendees();
427 QPtrListIterator<Attendee> ai(al); 430 Q3PtrListIterator<Attendee> ai(al);
428 for (; ai.current(); ++ai) { 431 for (; ai.current(); ++ai) {
429 icalcomponent_add_property(parent,writeAttendee(ai.current())); 432 icalcomponent_add_property(parent,writeAttendee(ai.current()));
430 } 433 }
431 } 434 }
432 435
433 // custom properties 436 // custom properties
434 writeCustomProperties(parent, incidenceBase); 437 writeCustomProperties(parent, incidenceBase);
435} 438}
436 439
437void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) 440void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties)
438{ 441{
439 QMap<QCString, QString> custom = properties->customProperties(); 442 QMap<Q3CString, QString> custom = properties->customProperties();
440 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 443 for (QMap<Q3CString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
441 icalproperty *p = icalproperty_new_x(c.data().utf8()); 444 icalproperty *p = icalproperty_new_x(c.data().utf8());
442 icalproperty_set_x_name(p,c.key()); 445 icalproperty_set_x_name(p,c.key());
443 icalcomponent_add_property(parent,p); 446 icalcomponent_add_property(parent,p);
444 } 447 }
445} 448}
446 449
447icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) 450icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee)
448{ 451{
@@ -541,18 +544,18 @@ icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur)
541 544
542 icalrecurrencetype r; 545 icalrecurrencetype r;
543 546
544 icalrecurrencetype_clear(&r); 547 icalrecurrencetype_clear(&r);
545 548
546 int index = 0; 549 int index = 0;
547 int index2 = 0; 550 int index2 = 0;
548 551
549 QPtrList<Recurrence::rMonthPos> tmpPositions; 552 Q3PtrList<Recurrence::rMonthPos> tmpPositions;
550 QPtrList<int> tmpDays; 553 Q3PtrList<int> tmpDays;
551 int *tmpDay; 554 int *tmpDay;
552 Recurrence::rMonthPos *tmpPos; 555 Recurrence::rMonthPos *tmpPos;
553 bool datetime = false; 556 bool datetime = false;
554 int day; 557 int day;
555 int i; 558 int i;
556 559
557 switch(recur->doesRecur()) { 560 switch(recur->doesRecur()) {
558 case Recurrence::rMinutely: 561 case Recurrence::rMinutely:
@@ -699,18 +702,18 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm)
699 if (!alarm->audioFile().isEmpty()) { 702 if (!alarm->audioFile().isEmpty()) {
700 attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); 703 attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data());
701 icalcomponent_add_property(a,icalproperty_new_attach(attach)); 704 icalcomponent_add_property(a,icalproperty_new_attach(attach));
702 icalattach_unref( attach ); 705 icalattach_unref( attach );
703 } 706 }
704 break; 707 break;
705 case Alarm::Email: { 708 case Alarm::Email: {
706 action = ICAL_ACTION_EMAIL; 709 action = ICAL_ACTION_EMAIL;
707 QValueList<Person> addresses = alarm->mailAddresses(); 710 Q3ValueList<Person> addresses = alarm->mailAddresses();
708 for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { 711 for (Q3ValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) {
709 icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); 712 icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8());
710 if (!(*ad).name().isEmpty()) { 713 if (!(*ad).name().isEmpty()) {
711 icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); 714 icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8()));
712 } 715 }
713 icalcomponent_add_property(a,p); 716 icalcomponent_add_property(a,p);
714 } 717 }
715 icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); 718 icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8()));
716 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); 719 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8()));
@@ -758,18 +761,18 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm)
758 // Repeat count and duration 761 // Repeat count and duration
759 if (alarm->repeatCount()) { 762 if (alarm->repeatCount()) {
760 icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); 763 icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount()));
761 icalcomponent_add_property(a,icalproperty_new_duration( 764 icalcomponent_add_property(a,icalproperty_new_duration(
762 icaldurationtype_from_int(alarm->snoozeTime()*60))); 765 icaldurationtype_from_int(alarm->snoozeTime()*60)));
763 } 766 }
764 767
765 // Custom properties 768 // Custom properties
766 QMap<QCString, QString> custom = alarm->customProperties(); 769 QMap<Q3CString, QString> custom = alarm->customProperties();
767 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 770 for (QMap<Q3CString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
768 icalproperty *p = icalproperty_new_x(c.data().utf8()); 771 icalproperty *p = icalproperty_new_x(c.data().utf8());
769 icalproperty_set_x_name(p,c.key()); 772 icalproperty_set_x_name(p,c.key());
770 icalcomponent_add_property(a,p); 773 icalcomponent_add_property(a,p);
771 } 774 }
772 775
773 return a; 776 return a;
774} 777}
775 778
@@ -1334,17 +1337,17 @@ void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *inci
1334 } 1337 }
1335 1338
1336 // custom properties 1339 // custom properties
1337 readCustomProperties(parent, incidenceBase); 1340 readCustomProperties(parent, incidenceBase);
1338} 1341}
1339 1342
1340void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) 1343void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties)
1341{ 1344{
1342 QMap<QCString, QString> customProperties; 1345 QMap<Q3CString, QString> customProperties;
1343 1346
1344 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); 1347 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY);
1345 1348
1346 while (p) { 1349 while (p) {
1347 QString value = QString::fromUtf8(icalproperty_get_x(p)); 1350 QString value = QString::fromUtf8(icalproperty_get_x(p));
1348 customProperties[icalproperty_get_x_name(p)] = value; 1351 customProperties[icalproperty_get_x_name(p)] = value;
1349 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); 1352 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) );
1350 1353