-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | 15 | ||||
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessvcal.cpp | 17 |
2 files changed, 20 insertions, 12 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp index b569f8b..ffa6a7d 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | |||
@@ -20,31 +20,36 @@ | |||
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | /* | 29 | /* |
30 | * VCard Backend for the OPIE-Contact Database. | 30 | * VCard Backend for the OPIE-Contact Database. |
31 | */ | 31 | */ |
32 | #include <opie2/ocontactaccessbackend_vcard.h> | ||
33 | #include "../../../../library/backend/vobject_p.h" | ||
34 | #include "../../../../library/backend/qfiledirect_p.h" | ||
35 | 32 | ||
33 | |||
34 | #include "vobject_p.h" | ||
35 | |||
36 | /* OPIE */ | ||
37 | #include <opie2/ocontactaccessbackend_vcard.h> | ||
36 | #include <qpe/timeconversion.h> | 38 | #include <qpe/timeconversion.h> |
37 | 39 | ||
40 | //FIXME: Hack to allow direct access to FILE* fh. Rewrite this! | ||
41 | #define protected public | ||
38 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #undef protected | ||
39 | 44 | ||
40 | namespace Opie { | 45 | namespace Opie { |
41 | 46 | ||
42 | OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ): | 47 | OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ): |
43 | m_dirty( false ), | 48 | m_dirty( false ), |
44 | m_file( filename ) | 49 | m_file( filename ) |
45 | { | 50 | { |
46 | load(); | 51 | load(); |
47 | } | 52 | } |
48 | 53 | ||
49 | 54 | ||
50 | bool OPimContactAccessBackend_VCard::load () | 55 | bool OPimContactAccessBackend_VCard::load () |
@@ -85,36 +90,36 @@ bool OPimContactAccessBackend_VCard::load () | |||
85 | return true; | 90 | return true; |
86 | 91 | ||
87 | } | 92 | } |
88 | bool OPimContactAccessBackend_VCard::reload() | 93 | bool OPimContactAccessBackend_VCard::reload() |
89 | { | 94 | { |
90 | return load(); | 95 | return load(); |
91 | } | 96 | } |
92 | bool OPimContactAccessBackend_VCard::save() | 97 | bool OPimContactAccessBackend_VCard::save() |
93 | { | 98 | { |
94 | if (!m_dirty ) | 99 | if (!m_dirty ) |
95 | return true; | 100 | return true; |
96 | 101 | ||
97 | QFileDirect file( m_file ); | 102 | QFile file( m_file ); |
98 | if (!file.open(IO_WriteOnly ) ) | 103 | if (!file.open(IO_WriteOnly ) ) |
99 | return false; | 104 | return false; |
100 | 105 | ||
101 | VObject *obj; | 106 | VObject *obj; |
102 | obj = newVObject( VCCalProp ); | 107 | obj = newVObject( VCCalProp ); |
103 | addPropValue( obj, VCVersionProp, "1.0" ); | 108 | addPropValue( obj, VCVersionProp, "1.0" ); |
104 | 109 | ||
105 | VObject *vo; | 110 | VObject *vo; |
106 | for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 111 | for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
107 | vo = createVObject( *it ); | 112 | vo = createVObject( *it ); |
108 | writeVObject( file.directHandle() , vo ); | 113 | writeVObject( file.fh, vo ); //FIXME: HACK!!! |
109 | cleanVObject( vo ); | 114 | cleanVObject( vo ); |
110 | } | 115 | } |
111 | cleanStrTbl(); | 116 | cleanStrTbl(); |
112 | deleteVObject( obj ); | 117 | deleteVObject( obj ); |
113 | 118 | ||
114 | m_dirty = false; | 119 | m_dirty = false; |
115 | return true; | 120 | return true; |
116 | 121 | ||
117 | 122 | ||
118 | } | 123 | } |
119 | void OPimContactAccessBackend_VCard::clear () | 124 | void OPimContactAccessBackend_VCard::clear () |
120 | { | 125 | { |
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp index 0a1baf9..03d4479 100644 --- a/libopie2/opiepim/backend/otodoaccessvcal.cpp +++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp | |||
@@ -17,32 +17,35 @@ | |||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | #include <qfile.h> | ||
30 | |||
31 | #include <qtopia/private/vobject_p.h> | ||
32 | #include <qtopia/timeconversion.h> | ||
33 | #include <qtopia/private/qfiledirect_p.h> | ||
34 | 29 | ||
30 | /* OPIE */ | ||
31 | #include "vobject_p.h" | ||
32 | #include <qpe/timeconversion.h> | ||
35 | #include <opie2/otodoaccessvcal.h> | 33 | #include <opie2/otodoaccessvcal.h> |
36 | 34 | ||
35 | //FIXME: Hack to allow direct access to FILE* fh. Rewrite this! | ||
36 | #define protected public | ||
37 | #include <qfile.h> | ||
38 | #undef protected | ||
39 | |||
37 | using namespace Opie; | 40 | using namespace Opie; |
38 | 41 | ||
39 | namespace { | 42 | namespace { |
40 | static OPimTodo eventByVObj( VObject *obj ){ | 43 | static OPimTodo eventByVObj( VObject *obj ){ |
41 | OPimTodo event; | 44 | OPimTodo event; |
42 | VObject *ob; | 45 | VObject *ob; |
43 | QCString name; | 46 | QCString name; |
44 | // no uid, attendees, ... and no fun | 47 | // no uid, attendees, ... and no fun |
45 | // description | 48 | // description |
46 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ | 49 | if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){ |
47 | name = vObjectStringZValue( ob ); | 50 | name = vObjectStringZValue( ob ); |
48 | #if 0 | 51 | #if 0 |
@@ -170,37 +173,37 @@ bool OPimTodoAccessVCal::load() { | |||
170 | 173 | ||
171 | // Should I do a delete vcal? | 174 | // Should I do a delete vcal? |
172 | 175 | ||
173 | return true; | 176 | return true; |
174 | } | 177 | } |
175 | bool OPimTodoAccessVCal::reload() { | 178 | bool OPimTodoAccessVCal::reload() { |
176 | return load(); | 179 | return load(); |
177 | } | 180 | } |
178 | bool OPimTodoAccessVCal::save() { | 181 | bool OPimTodoAccessVCal::save() { |
179 | if (!m_dirty ) | 182 | if (!m_dirty ) |
180 | return true; | 183 | return true; |
181 | 184 | ||
182 | QFileDirect file( m_file ); | 185 | QFile file( m_file ); |
183 | if (!file.open(IO_WriteOnly ) ) | 186 | if (!file.open(IO_WriteOnly ) ) |
184 | return false; | 187 | return false; |
185 | 188 | ||
186 | VObject *obj; | 189 | VObject *obj; |
187 | obj = newVObject( VCCalProp ); | 190 | obj = newVObject( VCCalProp ); |
188 | addPropValue( obj, VCVersionProp, "1.0" ); | 191 | addPropValue( obj, VCVersionProp, "1.0" ); |
189 | VObject *vo; | 192 | VObject *vo; |
190 | for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ | 193 | for(QMap<int, OPimTodo>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ |
191 | vo = vobjByEvent( it.data() ); | 194 | vo = vobjByEvent( it.data() ); |
192 | addVObjectProp(obj, vo ); | 195 | addVObjectProp(obj, vo ); |
193 | } | 196 | } |
194 | writeVObject( file.directHandle(), obj ); | 197 | writeVObject( file.fh, obj ); //FIXME: HACK!!! |
195 | cleanVObject( obj ); | 198 | cleanVObject( obj ); |
196 | cleanStrTbl(); | 199 | cleanStrTbl(); |
197 | 200 | ||
198 | m_dirty = false; | 201 | m_dirty = false; |
199 | return true; | 202 | return true; |
200 | } | 203 | } |
201 | void OPimTodoAccessVCal::clear() { | 204 | void OPimTodoAccessVCal::clear() { |
202 | m_map.clear(); | 205 | m_map.clear(); |
203 | m_dirty = true; | 206 | m_dirty = true; |
204 | } | 207 | } |
205 | bool OPimTodoAccessVCal::add( const OPimTodo& to ) { | 208 | bool OPimTodoAccessVCal::add( const OPimTodo& to ) { |
206 | m_map.insert( to.uid(), to ); | 209 | m_map.insert( to.uid(), to ); |