summaryrefslogtreecommitdiff
path: root/libopie/todovcalresource.cpp
Unidiff
Diffstat (limited to 'libopie/todovcalresource.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/todovcalresource.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/libopie/todovcalresource.cpp b/libopie/todovcalresource.cpp
index 75f2197..80f8c60 100644
--- a/libopie/todovcalresource.cpp
+++ b/libopie/todovcalresource.cpp
@@ -1,115 +1,120 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org> 3             .=l. Copyright (c) 2002 Holger Freyther <freyther@kde.org>
4           .>+-= the use of vobject was inspired by libkcal 4           .>+-= the use of vobject was inspired by libkcal
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include <qfile.h> 29#include <qfile.h>
30#include <qvaluelist.h> 30#include <qvaluelist.h>
31#include <opie/todoevent.h> 31#include <opie/todoevent.h>
32#include <opie/todovcalresource.h> 32#include <opie/todovcalresource.h>
33 33
34#include "../library/backend/vobject_p.h" 34#include "../library/backend/vobject_p.h"
35#include "../library/backend/timeconversion.h" 35#include "../library/backend/timeconversion.h"
36#include "../library/backend/qfiledirect_p.h" 36#include "../library/backend/qfiledirect_p.h"
37 37
38static VObject *vobjByEvent( const ToDoEvent &event ) 38static VObject *vobjByEvent( const ToDoEvent &event )
39{ 39{
40 VObject *task = newVObject( VCTodoProp ); 40 VObject *task = newVObject( VCTodoProp );
41 if( task == 0 ) 41 if( task == 0 )
42 return 0l; 42 return 0l;
43 if( event.hasDate() ) 43 if( event.hasDate() )
44 addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) ); 44 addPropValue( task, VCDueProp, TimeConversion::toISO8601( event.date() ) );
45 45
46 if( event.isCompleted() ) 46 if( event.isCompleted() )
47 addPropValue( task, VCStatusProp, "COMPLETED"); 47 addPropValue( task, VCStatusProp, "COMPLETED");
48 48
49 QString string = QString::number(event.priority() ); 49 QString string = QString::number(event.priority() );
50 addPropValue( task, VCPriorityProp, string.local8Bit() ); 50 addPropValue( task, VCPriorityProp, string.local8Bit() );
51 addPropValue( task, VCCategoriesProp, event.allCategories().join(";").local8Bit() ); 51 addPropValue( task, VCCategoriesProp, event.allCategories().join(";").local8Bit() );
52 addPropValue( task, VCDescriptionProp, event.description().local8Bit() ); 52 addPropValue( task, VCDescriptionProp, event.description().local8Bit() );
53 addPropValue( task, VCSummaryProp, event.description().left(15).local8Bit() ); 53 addPropValue( task, VCSummaryProp, event.summary().left(15).local8Bit() );
54 return task; 54 return task;
55}; 55};
56 56
57static ToDoEvent eventByVObj( VObject *obj ){ 57static ToDoEvent eventByVObj( VObject *obj ){
58 ToDoEvent event; 58 ToDoEvent event;
59 VObject *ob; 59 VObject *ob;
60 QCString name; 60 QCString name;
61 // no uid, attendees, ... and no fun 61 // no uid, attendees, ... and no fun
62 // description 62 // description
63 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ 63 if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
64 name = vObjectStringZValue( ob ); 64 name = vObjectStringZValue( ob );
65 event.setDescription( name ); 65 event.setDescription( name );
66 } 66 }
67 // summary
68 if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
69 name = vObjectStringZValue( ob );
70 event.setSummary( name );
71 }
67 // completed 72 // completed
68 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){ 73 if( ( ob = isAPropertyOf( obj, VCStatusProp )) != 0 ){
69 name = vObjectStringZValue( ob ); 74 name = vObjectStringZValue( ob );
70 if( name == "COMPLETED" ){ 75 if( name == "COMPLETED" ){
71 event.setCompleted( true ); 76 event.setCompleted( true );
72 }else{ 77 }else{
73 event.setCompleted( false ); 78 event.setCompleted( false );
74 } 79 }
75 }else 80 }else
76 event.setCompleted( false ); 81 event.setCompleted( false );
77 // priority 82 // priority
78 if ((ob = isAPropertyOf(obj, VCPriorityProp))) { 83 if ((ob = isAPropertyOf(obj, VCPriorityProp))) {
79 name = vObjectStringZValue( ob ); 84 name = vObjectStringZValue( ob );
80 bool ok; 85 bool ok;
81 event.setPriority(name.toInt(&ok) ); 86 event.setPriority(name.toInt(&ok) );
82 } 87 }
83 //due date 88 //due date
84 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 89 if((ob = isAPropertyOf(obj, VCDueProp)) ){
85 event.setHasDate( true ); 90 event.setHasDate( true );
86 name = vObjectStringZValue( ob ); 91 name = vObjectStringZValue( ob );
87 event.setDate( TimeConversion::fromISO8601( name).date() ); 92 event.setDate( TimeConversion::fromISO8601( name).date() );
88 } 93 }
89 // categories 94 // categories
90 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 95 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
91 name = vObjectStringZValue( ob ); 96 name = vObjectStringZValue( ob );
92 qWarning("Categories:%s", name.data() ); 97 qWarning("Categories:%s", name.data() );
93 } 98 }
94 99
95 return event; 100 return event;
96}; 101};
97 102
98 103
99QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file) 104QValueList<ToDoEvent> ToDoVCalResource::load(const QString &file)
100{ 105{
101 QValueList<ToDoEvent> events; 106 QValueList<ToDoEvent> events;
102 VObject *vcal = 0l; 107 VObject *vcal = 0l;
103 vcal = Parse_MIME_FromFileName( (char *)file.utf8().data() ); // from vobject 108 vcal = Parse_MIME_FromFileName( (char *)file.utf8().data() ); // from vobject
104 if(!vcal ) 109 if(!vcal )
105 return events; 110 return events;
106 // start parsing 111 // start parsing
107 112
108 VObjectIterator it; 113 VObjectIterator it;
109 VObject *vobj; 114 VObject *vobj;
110 initPropIterator(&it, vcal); 115 initPropIterator(&it, vcal);
111 116
112 while( moreIteration( &it ) ) { 117 while( moreIteration( &it ) ) {
113 vobj = ::nextVObject( &it ); 118 vobj = ::nextVObject( &it );
114 QCString name = ::vObjectName( vobj ); 119 QCString name = ::vObjectName( vobj );
115 //QCString objVal = ::vObjectStringZValue( vobj ); 120 //QCString objVal = ::vObjectStringZValue( vobj );