summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp18
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.h5
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp18
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.h5
4 files changed, 36 insertions, 10 deletions
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index 903c0b7..013f3af 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -1,46 +1,52 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 6 *
6 * ===================================================================== 7 * =====================================================================
7 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 12 * =====================================================================
12 * ToDo: 13 * ToDo:
13 * 14 *
14 * ===================================================================== 15 * =====================================================================
15 * Version: $Id$ 16 * Version: $Id$
16 * ===================================================================== 17 * =====================================================================
17 * History: 18 * History:
18 * $Log$ 19 * $Log$
20 * Revision 1.2 2002/11/10 15:41:53 eilers
21 * Bugfixes..
22 *
19 * Revision 1.1 2002/11/09 14:34:52 eilers 23 * Revision 1.1 2002/11/09 14:34:52 eilers
20 * Added VCard Backend. 24 * Added VCard Backend.
21 * 25 *
22 */ 26 */
23#include "ocontactaccessbackend_vcard.h" 27#include "ocontactaccessbackend_vcard.h"
24#include "../../library/backend/vobject_p.h" 28#include "../../library/backend/vobject_p.h"
25#include "../../library/backend/qfiledirect_p.h" 29#include "../../library/backend/qfiledirect_p.h"
26 30
27#include <qpe/timeconversion.h> 31#include <qpe/timeconversion.h>
28 32
29#include <qfile.h> 33#include <qfile.h>
30 34
31OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename = 0l ): 35OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename = 0l ):
32 m_dirty( false ), 36 m_dirty( false ),
33 m_file( filename ) 37 m_file( filename )
34{} 38{
39 load();
40}
35 41
36 42
37bool OContactAccessBackend_VCard::load () 43bool OContactAccessBackend_VCard::load ()
38{ 44{
39 m_map.clear(); 45 m_map.clear();
40 m_dirty = false; 46 m_dirty = false;
41 47
42 VObject* obj = 0l; 48 VObject* obj = 0l;
43 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 49 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
44 if ( !obj ) 50 if ( !obj )
45 return false; 51 return false;
46 52
@@ -77,29 +83,27 @@ bool OContactAccessBackend_VCard::save()
77 83
78 QFileDirect file( m_file ); 84 QFileDirect file( m_file );
79 if (!file.open(IO_WriteOnly ) ) 85 if (!file.open(IO_WriteOnly ) )
80 return false; 86 return false;
81 87
82 VObject *obj; 88 VObject *obj;
83 obj = newVObject( VCCalProp ); 89 obj = newVObject( VCCalProp );
84 addPropValue( obj, VCVersionProp, "1.0" ); 90 addPropValue( obj, VCVersionProp, "1.0" );
85 91
86 VObject *vo; 92 VObject *vo;
87 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 93 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
88 vo = createVObject( *it ); 94 vo = createVObject( *it );
89 addVObjectProp( obj, vo ); 95 writeVObject( file.directHandle() , vo );
96 cleanVObject( vo );
90 } 97 }
91 writeVObject( file.directHandle() , obj );
92 cleanVObject( obj );
93
94 cleanStrTbl(); 98 cleanStrTbl();
95 99
96 m_dirty = false; 100 m_dirty = false;
97 return true; 101 return true;
98 102
99 103
100} 104}
101void OContactAccessBackend_VCard::clear () 105void OContactAccessBackend_VCard::clear ()
102{ 106{
103 m_map.clear(); 107 m_map.clear();
104 m_dirty = true; // ??? sure ? (se) 108 m_dirty = true; // ??? sure ? (se)
105} 109}
@@ -157,24 +161,28 @@ QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
157} 161}
158 162
159const uint OContactAccessBackend_VCard::querySettings() 163const uint OContactAccessBackend_VCard::querySettings()
160{ 164{
161 return 0; // No search possible 165 return 0; // No search possible
162} 166}
163 167
164bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const 168bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const
165{ 169{
166 return false; // No search possible, therefore all settings invalid ;) 170 return false; // No search possible, therefore all settings invalid ;)
167} 171}
168 172
173bool OContactAccessBackend_VCard::wasChangedExternally()
174{
175 return false; // Don't expect concurrent access
176}
169 177
170// *** Private stuff *** 178// *** Private stuff ***
171 179
172 180
173OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) 181OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
174{ 182{
175 OContact c; 183 OContact c;
176 184
177 VObjectIterator it; 185 VObjectIterator it;
178 initPropIterator( &it, obj ); 186 initPropIterator( &it, obj );
179 while( moreIteration( &it ) ) { 187 while( moreIteration( &it ) ) {
180 VObject *o = nextVObject( &it ); 188 VObject *o = nextVObject( &it );
diff --git a/libopie/pim/ocontactaccessbackend_vcard.h b/libopie/pim/ocontactaccessbackend_vcard.h
index c1422b0..177ec24 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.h
+++ b/libopie/pim/ocontactaccessbackend_vcard.h
@@ -1,30 +1,34 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 6 *
6 * ===================================================================== 7 * =====================================================================
7 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 12 * =====================================================================
12 * ToDo: 13 * ToDo:
13 * 14 *
14 * ===================================================================== 15 * =====================================================================
15 * Version: $Id$ 16 * Version: $Id$
16 * ===================================================================== 17 * =====================================================================
17 * History: 18 * History:
18 * $Log$ 19 * $Log$
20 * Revision 1.2 2002/11/10 15:41:53 eilers
21 * Bugfixes..
22 *
19 * Revision 1.1 2002/11/09 14:34:52 eilers 23 * Revision 1.1 2002/11/09 14:34:52 eilers
20 * Added VCard Backend. 24 * Added VCard Backend.
21 * 25 *
22 */ 26 */
23#ifndef __OCONTACTACCESSBACKEND_VCARD_H_ 27#ifndef __OCONTACTACCESSBACKEND_VCARD_H_
24#define __OCONTACTACCESSBACKEND_VCARD_H_ 28#define __OCONTACTACCESSBACKEND_VCARD_H_
25 29
26#include <opie/ocontact.h> 30#include <opie/ocontact.h>
27 31
28#include "ocontactaccessbackend.h" 32#include "ocontactaccessbackend.h"
29 33
30class VObject; 34class VObject;
@@ -40,24 +44,25 @@ class OContactAccessBackend_VCard : public OContactAccessBackend {
40 44
41 bool add ( const OContact& newcontact ); 45 bool add ( const OContact& newcontact );
42 bool remove ( int uid ); 46 bool remove ( int uid );
43 bool replace ( const OContact& contact ); 47 bool replace ( const OContact& contact );
44 48
45 OContact find ( int uid ) const; 49 OContact find ( int uid ) const;
46 QArray<int> allRecords() const; 50 QArray<int> allRecords() const;
47 QArray<int> queryByExample ( const OContact &query, int settings ); 51 QArray<int> queryByExample ( const OContact &query, int settings );
48 QArray<int> matchRegexp( const QRegExp &r ) const; 52 QArray<int> matchRegexp( const QRegExp &r ) const;
49 53
50 const uint querySettings(); 54 const uint querySettings();
51 bool hasQuerySettings (uint querySettings) const; 55 bool hasQuerySettings (uint querySettings) const;
56 bool wasChangedExternally();
52 57
53private: 58private:
54 OContact parseVObject( VObject* obj ); 59 OContact parseVObject( VObject* obj );
55 VObject* createVObject( const OContact& c ); 60 VObject* createVObject( const OContact& c );
56 QDate convVCardDateToDate( const QString& datestr ); 61 QDate convVCardDateToDate( const QString& datestr );
57 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); 62 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value );
58 VObject *safeAddProp( VObject* o, const char* prop); 63 VObject *safeAddProp( VObject* o, const char* prop);
59 64
60 bool m_dirty : 1; 65 bool m_dirty : 1;
61 QString m_file; 66 QString m_file;
62 QMap<int, OContact> m_map; 67 QMap<int, OContact> m_map;
63}; 68};
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index 903c0b7..013f3af 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,46 +1,52 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 6 *
6 * ===================================================================== 7 * =====================================================================
7 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 12 * =====================================================================
12 * ToDo: 13 * ToDo:
13 * 14 *
14 * ===================================================================== 15 * =====================================================================
15 * Version: $Id$ 16 * Version: $Id$
16 * ===================================================================== 17 * =====================================================================
17 * History: 18 * History:
18 * $Log$ 19 * $Log$
20 * Revision 1.2 2002/11/10 15:41:53 eilers
21 * Bugfixes..
22 *
19 * Revision 1.1 2002/11/09 14:34:52 eilers 23 * Revision 1.1 2002/11/09 14:34:52 eilers
20 * Added VCard Backend. 24 * Added VCard Backend.
21 * 25 *
22 */ 26 */
23#include "ocontactaccessbackend_vcard.h" 27#include "ocontactaccessbackend_vcard.h"
24#include "../../library/backend/vobject_p.h" 28#include "../../library/backend/vobject_p.h"
25#include "../../library/backend/qfiledirect_p.h" 29#include "../../library/backend/qfiledirect_p.h"
26 30
27#include <qpe/timeconversion.h> 31#include <qpe/timeconversion.h>
28 32
29#include <qfile.h> 33#include <qfile.h>
30 34
31OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename = 0l ): 35OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename = 0l ):
32 m_dirty( false ), 36 m_dirty( false ),
33 m_file( filename ) 37 m_file( filename )
34{} 38{
39 load();
40}
35 41
36 42
37bool OContactAccessBackend_VCard::load () 43bool OContactAccessBackend_VCard::load ()
38{ 44{
39 m_map.clear(); 45 m_map.clear();
40 m_dirty = false; 46 m_dirty = false;
41 47
42 VObject* obj = 0l; 48 VObject* obj = 0l;
43 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 49 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
44 if ( !obj ) 50 if ( !obj )
45 return false; 51 return false;
46 52
@@ -77,29 +83,27 @@ bool OContactAccessBackend_VCard::save()
77 83
78 QFileDirect file( m_file ); 84 QFileDirect file( m_file );
79 if (!file.open(IO_WriteOnly ) ) 85 if (!file.open(IO_WriteOnly ) )
80 return false; 86 return false;
81 87
82 VObject *obj; 88 VObject *obj;
83 obj = newVObject( VCCalProp ); 89 obj = newVObject( VCCalProp );
84 addPropValue( obj, VCVersionProp, "1.0" ); 90 addPropValue( obj, VCVersionProp, "1.0" );
85 91
86 VObject *vo; 92 VObject *vo;
87 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 93 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
88 vo = createVObject( *it ); 94 vo = createVObject( *it );
89 addVObjectProp( obj, vo ); 95 writeVObject( file.directHandle() , vo );
96 cleanVObject( vo );
90 } 97 }
91 writeVObject( file.directHandle() , obj );
92 cleanVObject( obj );
93
94 cleanStrTbl(); 98 cleanStrTbl();
95 99
96 m_dirty = false; 100 m_dirty = false;
97 return true; 101 return true;
98 102
99 103
100} 104}
101void OContactAccessBackend_VCard::clear () 105void OContactAccessBackend_VCard::clear ()
102{ 106{
103 m_map.clear(); 107 m_map.clear();
104 m_dirty = true; // ??? sure ? (se) 108 m_dirty = true; // ??? sure ? (se)
105} 109}
@@ -157,24 +161,28 @@ QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
157} 161}
158 162
159const uint OContactAccessBackend_VCard::querySettings() 163const uint OContactAccessBackend_VCard::querySettings()
160{ 164{
161 return 0; // No search possible 165 return 0; // No search possible
162} 166}
163 167
164bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const 168bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const
165{ 169{
166 return false; // No search possible, therefore all settings invalid ;) 170 return false; // No search possible, therefore all settings invalid ;)
167} 171}
168 172
173bool OContactAccessBackend_VCard::wasChangedExternally()
174{
175 return false; // Don't expect concurrent access
176}
169 177
170// *** Private stuff *** 178// *** Private stuff ***
171 179
172 180
173OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) 181OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
174{ 182{
175 OContact c; 183 OContact c;
176 184
177 VObjectIterator it; 185 VObjectIterator it;
178 initPropIterator( &it, obj ); 186 initPropIterator( &it, obj );
179 while( moreIteration( &it ) ) { 187 while( moreIteration( &it ) ) {
180 VObject *o = nextVObject( &it ); 188 VObject *o = nextVObject( &it );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
index c1422b0..177ec24 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
@@ -1,30 +1,34 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 6 *
6 * ===================================================================== 7 * =====================================================================
7 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 12 * =====================================================================
12 * ToDo: 13 * ToDo:
13 * 14 *
14 * ===================================================================== 15 * =====================================================================
15 * Version: $Id$ 16 * Version: $Id$
16 * ===================================================================== 17 * =====================================================================
17 * History: 18 * History:
18 * $Log$ 19 * $Log$
20 * Revision 1.2 2002/11/10 15:41:53 eilers
21 * Bugfixes..
22 *
19 * Revision 1.1 2002/11/09 14:34:52 eilers 23 * Revision 1.1 2002/11/09 14:34:52 eilers
20 * Added VCard Backend. 24 * Added VCard Backend.
21 * 25 *
22 */ 26 */
23#ifndef __OCONTACTACCESSBACKEND_VCARD_H_ 27#ifndef __OCONTACTACCESSBACKEND_VCARD_H_
24#define __OCONTACTACCESSBACKEND_VCARD_H_ 28#define __OCONTACTACCESSBACKEND_VCARD_H_
25 29
26#include <opie/ocontact.h> 30#include <opie/ocontact.h>
27 31
28#include "ocontactaccessbackend.h" 32#include "ocontactaccessbackend.h"
29 33
30class VObject; 34class VObject;
@@ -40,24 +44,25 @@ class OContactAccessBackend_VCard : public OContactAccessBackend {
40 44
41 bool add ( const OContact& newcontact ); 45 bool add ( const OContact& newcontact );
42 bool remove ( int uid ); 46 bool remove ( int uid );
43 bool replace ( const OContact& contact ); 47 bool replace ( const OContact& contact );
44 48
45 OContact find ( int uid ) const; 49 OContact find ( int uid ) const;
46 QArray<int> allRecords() const; 50 QArray<int> allRecords() const;
47 QArray<int> queryByExample ( const OContact &query, int settings ); 51 QArray<int> queryByExample ( const OContact &query, int settings );
48 QArray<int> matchRegexp( const QRegExp &r ) const; 52 QArray<int> matchRegexp( const QRegExp &r ) const;
49 53
50 const uint querySettings(); 54 const uint querySettings();
51 bool hasQuerySettings (uint querySettings) const; 55 bool hasQuerySettings (uint querySettings) const;
56 bool wasChangedExternally();
52 57
53private: 58private:
54 OContact parseVObject( VObject* obj ); 59 OContact parseVObject( VObject* obj );
55 VObject* createVObject( const OContact& c ); 60 VObject* createVObject( const OContact& c );
56 QDate convVCardDateToDate( const QString& datestr ); 61 QDate convVCardDateToDate( const QString& datestr );
57 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); 62 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value );
58 VObject *safeAddProp( VObject* o, const char* prop); 63 VObject *safeAddProp( VObject* o, const char* prop);
59 64
60 bool m_dirty : 1; 65 bool m_dirty : 1;
61 QString m_file; 66 QString m_file;
62 QMap<int, OContact> m_map; 67 QMap<int, OContact> m_map;
63}; 68};