summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp5
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp5
2 files changed, 8 insertions, 2 deletions
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index 013f3af..faa72b4 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -1,163 +1,166 @@
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) 2000 Trolltech AS. All rights reserved.
5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * 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.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.3 2002/11/11 16:41:09 kergoth
21 * no default arguments in implementation
22 *
20 * Revision 1.2 2002/11/10 15:41:53 eilers 23 * Revision 1.2 2002/11/10 15:41:53 eilers
21 * Bugfixes.. 24 * Bugfixes..
22 * 25 *
23 * Revision 1.1 2002/11/09 14:34:52 eilers 26 * Revision 1.1 2002/11/09 14:34:52 eilers
24 * Added VCard Backend. 27 * Added VCard Backend.
25 * 28 *
26 */ 29 */
27#include "ocontactaccessbackend_vcard.h" 30#include "ocontactaccessbackend_vcard.h"
28#include "../../library/backend/vobject_p.h" 31#include "../../library/backend/vobject_p.h"
29#include "../../library/backend/qfiledirect_p.h" 32#include "../../library/backend/qfiledirect_p.h"
30 33
31#include <qpe/timeconversion.h> 34#include <qpe/timeconversion.h>
32 35
33#include <qfile.h> 36#include <qfile.h>
34 37
35OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename = 0l ): 38OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ):
36 m_dirty( false ), 39 m_dirty( false ),
37 m_file( filename ) 40 m_file( filename )
38{ 41{
39 load(); 42 load();
40} 43}
41 44
42 45
43bool OContactAccessBackend_VCard::load () 46bool OContactAccessBackend_VCard::load ()
44{ 47{
45 m_map.clear(); 48 m_map.clear();
46 m_dirty = false; 49 m_dirty = false;
47 50
48 VObject* obj = 0l; 51 VObject* obj = 0l;
49 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 52 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
50 if ( !obj ) 53 if ( !obj )
51 return false; 54 return false;
52 55
53 while ( obj ) { 56 while ( obj ) {
54 OContact con = parseVObject( obj ); 57 OContact con = parseVObject( obj );
55 /* 58 /*
56 * if uid is 0 assign a new one 59 * if uid is 0 assign a new one
57 * this at least happens on 60 * this at least happens on
58 * Nokia6210 61 * Nokia6210
59 */ 62 */
60 if ( con.uid() == 0 ){ 63 if ( con.uid() == 0 ){
61 con.setUid( 1 ); 64 con.setUid( 1 );
62 qWarning("assigned new uid %d",con.uid() ); 65 qWarning("assigned new uid %d",con.uid() );
63 } 66 }
64 67
65 m_map.insert( con.uid(), con ); 68 m_map.insert( con.uid(), con );
66 69
67 VObject *t = obj; 70 VObject *t = obj;
68 obj = nextVObjectInList(obj); 71 obj = nextVObjectInList(obj);
69 cleanVObject( t ); 72 cleanVObject( t );
70 } 73 }
71 74
72 return true; 75 return true;
73 76
74} 77}
75bool OContactAccessBackend_VCard::reload() 78bool OContactAccessBackend_VCard::reload()
76{ 79{
77 return load(); 80 return load();
78} 81}
79bool OContactAccessBackend_VCard::save() 82bool OContactAccessBackend_VCard::save()
80{ 83{
81 if (!m_dirty ) 84 if (!m_dirty )
82 return true; 85 return true;
83 86
84 QFileDirect file( m_file ); 87 QFileDirect file( m_file );
85 if (!file.open(IO_WriteOnly ) ) 88 if (!file.open(IO_WriteOnly ) )
86 return false; 89 return false;
87 90
88 VObject *obj; 91 VObject *obj;
89 obj = newVObject( VCCalProp ); 92 obj = newVObject( VCCalProp );
90 addPropValue( obj, VCVersionProp, "1.0" ); 93 addPropValue( obj, VCVersionProp, "1.0" );
91 94
92 VObject *vo; 95 VObject *vo;
93 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 96 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
94 vo = createVObject( *it ); 97 vo = createVObject( *it );
95 writeVObject( file.directHandle() , vo ); 98 writeVObject( file.directHandle() , vo );
96 cleanVObject( vo ); 99 cleanVObject( vo );
97 } 100 }
98 cleanStrTbl(); 101 cleanStrTbl();
99 102
100 m_dirty = false; 103 m_dirty = false;
101 return true; 104 return true;
102 105
103 106
104} 107}
105void OContactAccessBackend_VCard::clear () 108void OContactAccessBackend_VCard::clear ()
106{ 109{
107 m_map.clear(); 110 m_map.clear();
108 m_dirty = true; // ??? sure ? (se) 111 m_dirty = true; // ??? sure ? (se)
109} 112}
110 113
111bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) 114bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
112{ 115{
113 m_map.insert( newcontact.uid(), newcontact ); 116 m_map.insert( newcontact.uid(), newcontact );
114 m_dirty = true; 117 m_dirty = true;
115 return true; 118 return true;
116} 119}
117 120
118bool OContactAccessBackend_VCard::remove ( int uid ) 121bool OContactAccessBackend_VCard::remove ( int uid )
119{ 122{
120 m_map.remove( uid ); 123 m_map.remove( uid );
121 m_dirty = true; 124 m_dirty = true;
122 return true; 125 return true;
123} 126}
124 127
125bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 128bool OContactAccessBackend_VCard::replace ( const OContact &contact )
126{ 129{
127 m_map.replace( contact.uid(), contact ); 130 m_map.replace( contact.uid(), contact );
128 m_dirty = true; 131 m_dirty = true;
129 return true; 132 return true;
130} 133}
131 134
132OContact OContactAccessBackend_VCard::find ( int uid ) const 135OContact OContactAccessBackend_VCard::find ( int uid ) const
133{ 136{
134 return m_map[uid]; 137 return m_map[uid];
135} 138}
136 139
137QArray<int> OContactAccessBackend_VCard::allRecords() const 140QArray<int> OContactAccessBackend_VCard::allRecords() const
138{ 141{
139 QArray<int> ar( m_map.count() ); 142 QArray<int> ar( m_map.count() );
140 QMap<int, OContact>::ConstIterator it; 143 QMap<int, OContact>::ConstIterator it;
141 int i = 0; 144 int i = 0;
142 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 145 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
143 ar[i] = it.key(); 146 ar[i] = it.key();
144 i++; 147 i++;
145 } 148 }
146 return ar; 149 return ar;
147} 150}
148 151
149// Not implemented 152// Not implemented
150QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int ) 153QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int )
151{ 154{
152 QArray<int> ar(0); 155 QArray<int> ar(0);
153 return ar; 156 return ar;
154} 157}
155 158
156// Not implemented 159// Not implemented
157QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const 160QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
158{ 161{
159 QArray<int> ar(0); 162 QArray<int> ar(0);
160 return ar; 163 return ar;
161} 164}
162 165
163const uint OContactAccessBackend_VCard::querySettings() 166const uint OContactAccessBackend_VCard::querySettings()
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index 013f3af..faa72b4 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,163 +1,166 @@
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) 2000 Trolltech AS. All rights reserved.
5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * 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.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.3 2002/11/11 16:41:09 kergoth
21 * no default arguments in implementation
22 *
20 * Revision 1.2 2002/11/10 15:41:53 eilers 23 * Revision 1.2 2002/11/10 15:41:53 eilers
21 * Bugfixes.. 24 * Bugfixes..
22 * 25 *
23 * Revision 1.1 2002/11/09 14:34:52 eilers 26 * Revision 1.1 2002/11/09 14:34:52 eilers
24 * Added VCard Backend. 27 * Added VCard Backend.
25 * 28 *
26 */ 29 */
27#include "ocontactaccessbackend_vcard.h" 30#include "ocontactaccessbackend_vcard.h"
28#include "../../library/backend/vobject_p.h" 31#include "../../library/backend/vobject_p.h"
29#include "../../library/backend/qfiledirect_p.h" 32#include "../../library/backend/qfiledirect_p.h"
30 33
31#include <qpe/timeconversion.h> 34#include <qpe/timeconversion.h>
32 35
33#include <qfile.h> 36#include <qfile.h>
34 37
35OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename = 0l ): 38OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ):
36 m_dirty( false ), 39 m_dirty( false ),
37 m_file( filename ) 40 m_file( filename )
38{ 41{
39 load(); 42 load();
40} 43}
41 44
42 45
43bool OContactAccessBackend_VCard::load () 46bool OContactAccessBackend_VCard::load ()
44{ 47{
45 m_map.clear(); 48 m_map.clear();
46 m_dirty = false; 49 m_dirty = false;
47 50
48 VObject* obj = 0l; 51 VObject* obj = 0l;
49 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 52 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
50 if ( !obj ) 53 if ( !obj )
51 return false; 54 return false;
52 55
53 while ( obj ) { 56 while ( obj ) {
54 OContact con = parseVObject( obj ); 57 OContact con = parseVObject( obj );
55 /* 58 /*
56 * if uid is 0 assign a new one 59 * if uid is 0 assign a new one
57 * this at least happens on 60 * this at least happens on
58 * Nokia6210 61 * Nokia6210
59 */ 62 */
60 if ( con.uid() == 0 ){ 63 if ( con.uid() == 0 ){
61 con.setUid( 1 ); 64 con.setUid( 1 );
62 qWarning("assigned new uid %d",con.uid() ); 65 qWarning("assigned new uid %d",con.uid() );
63 } 66 }
64 67
65 m_map.insert( con.uid(), con ); 68 m_map.insert( con.uid(), con );
66 69
67 VObject *t = obj; 70 VObject *t = obj;
68 obj = nextVObjectInList(obj); 71 obj = nextVObjectInList(obj);
69 cleanVObject( t ); 72 cleanVObject( t );
70 } 73 }
71 74
72 return true; 75 return true;
73 76
74} 77}
75bool OContactAccessBackend_VCard::reload() 78bool OContactAccessBackend_VCard::reload()
76{ 79{
77 return load(); 80 return load();
78} 81}
79bool OContactAccessBackend_VCard::save() 82bool OContactAccessBackend_VCard::save()
80{ 83{
81 if (!m_dirty ) 84 if (!m_dirty )
82 return true; 85 return true;
83 86
84 QFileDirect file( m_file ); 87 QFileDirect file( m_file );
85 if (!file.open(IO_WriteOnly ) ) 88 if (!file.open(IO_WriteOnly ) )
86 return false; 89 return false;
87 90
88 VObject *obj; 91 VObject *obj;
89 obj = newVObject( VCCalProp ); 92 obj = newVObject( VCCalProp );
90 addPropValue( obj, VCVersionProp, "1.0" ); 93 addPropValue( obj, VCVersionProp, "1.0" );
91 94
92 VObject *vo; 95 VObject *vo;
93 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 96 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
94 vo = createVObject( *it ); 97 vo = createVObject( *it );
95 writeVObject( file.directHandle() , vo ); 98 writeVObject( file.directHandle() , vo );
96 cleanVObject( vo ); 99 cleanVObject( vo );
97 } 100 }
98 cleanStrTbl(); 101 cleanStrTbl();
99 102
100 m_dirty = false; 103 m_dirty = false;
101 return true; 104 return true;
102 105
103 106
104} 107}
105void OContactAccessBackend_VCard::clear () 108void OContactAccessBackend_VCard::clear ()
106{ 109{
107 m_map.clear(); 110 m_map.clear();
108 m_dirty = true; // ??? sure ? (se) 111 m_dirty = true; // ??? sure ? (se)
109} 112}
110 113
111bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) 114bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
112{ 115{
113 m_map.insert( newcontact.uid(), newcontact ); 116 m_map.insert( newcontact.uid(), newcontact );
114 m_dirty = true; 117 m_dirty = true;
115 return true; 118 return true;
116} 119}
117 120
118bool OContactAccessBackend_VCard::remove ( int uid ) 121bool OContactAccessBackend_VCard::remove ( int uid )
119{ 122{
120 m_map.remove( uid ); 123 m_map.remove( uid );
121 m_dirty = true; 124 m_dirty = true;
122 return true; 125 return true;
123} 126}
124 127
125bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 128bool OContactAccessBackend_VCard::replace ( const OContact &contact )
126{ 129{
127 m_map.replace( contact.uid(), contact ); 130 m_map.replace( contact.uid(), contact );
128 m_dirty = true; 131 m_dirty = true;
129 return true; 132 return true;
130} 133}
131 134
132OContact OContactAccessBackend_VCard::find ( int uid ) const 135OContact OContactAccessBackend_VCard::find ( int uid ) const
133{ 136{
134 return m_map[uid]; 137 return m_map[uid];
135} 138}
136 139
137QArray<int> OContactAccessBackend_VCard::allRecords() const 140QArray<int> OContactAccessBackend_VCard::allRecords() const
138{ 141{
139 QArray<int> ar( m_map.count() ); 142 QArray<int> ar( m_map.count() );
140 QMap<int, OContact>::ConstIterator it; 143 QMap<int, OContact>::ConstIterator it;
141 int i = 0; 144 int i = 0;
142 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 145 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
143 ar[i] = it.key(); 146 ar[i] = it.key();
144 i++; 147 i++;
145 } 148 }
146 return ar; 149 return ar;
147} 150}
148 151
149// Not implemented 152// Not implemented
150QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int ) 153QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int )
151{ 154{
152 QArray<int> ar(0); 155 QArray<int> ar(0);
153 return ar; 156 return ar;
154} 157}
155 158
156// Not implemented 159// Not implemented
157QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const 160QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
158{ 161{
159 QArray<int> ar(0); 162 QArray<int> ar(0);
160 return ar; 163 return ar;
161} 164}
162 165
163const uint OContactAccessBackend_VCard::querySettings() 166const uint OContactAccessBackend_VCard::querySettings()