author | mickeyl <mickeyl> | 2004-02-24 20:15:06 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-24 20:15:06 (UTC) |
commit | a1a6a1013eae9a4ca4607f2d656c98821a30f431 (patch) (unidiff) | |
tree | 1622cd7992b061d9105965fcd3adbceda8504499 /libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | |
parent | 17eafbf019590393ccd01647c5c9d5d880b95e39 (diff) | |
download | opie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.zip opie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.tar.gz opie-a1a6a1013eae9a4ca4607f2d656c98821a30f431.tar.bz2 |
substitute hack with another hack to enforce LGPL compliance
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp | 15 |
1 files changed, 10 insertions, 5 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 | |||
@@ -1,156 +1,161 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) The Main Author <main-author@whereever.org> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
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 | /* | 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 () |
51 | { | 56 | { |
52 | m_map.clear(); | 57 | m_map.clear(); |
53 | m_dirty = false; | 58 | m_dirty = false; |
54 | 59 | ||
55 | VObject* obj = 0l; | 60 | VObject* obj = 0l; |
56 | 61 | ||
57 | if ( QFile::exists(m_file) ){ | 62 | if ( QFile::exists(m_file) ){ |
58 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); | 63 | obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); |
59 | if ( !obj ) | 64 | if ( !obj ) |
60 | return false; | 65 | return false; |
61 | }else{ | 66 | }else{ |
62 | qWarning("File \"%s\" not found !", m_file.latin1() ); | 67 | qWarning("File \"%s\" not found !", m_file.latin1() ); |
63 | return false; | 68 | return false; |
64 | } | 69 | } |
65 | 70 | ||
66 | while ( obj ) { | 71 | while ( obj ) { |
67 | OPimContact con = parseVObject( obj ); | 72 | OPimContact con = parseVObject( obj ); |
68 | /* | 73 | /* |
69 | * if uid is 0 assign a new one | 74 | * if uid is 0 assign a new one |
70 | * this at least happens on | 75 | * this at least happens on |
71 | * Nokia6210 | 76 | * Nokia6210 |
72 | */ | 77 | */ |
73 | if ( con.uid() == 0 ){ | 78 | if ( con.uid() == 0 ){ |
74 | con.setUid( 1 ); | 79 | con.setUid( 1 ); |
75 | qWarning("assigned new uid %d",con.uid() ); | 80 | qWarning("assigned new uid %d",con.uid() ); |
76 | } | 81 | } |
77 | 82 | ||
78 | m_map.insert( con.uid(), con ); | 83 | m_map.insert( con.uid(), con ); |
79 | 84 | ||
80 | VObject *t = obj; | 85 | VObject *t = obj; |
81 | obj = nextVObjectInList(obj); | 86 | obj = nextVObjectInList(obj); |
82 | cleanVObject( t ); | 87 | cleanVObject( t ); |
83 | } | 88 | } |
84 | 89 | ||
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 | { |
121 | m_map.clear(); | 126 | m_map.clear(); |
122 | m_dirty = true; // ??? sure ? (se) | 127 | m_dirty = true; // ??? sure ? (se) |
123 | } | 128 | } |
124 | 129 | ||
125 | bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact ) | 130 | bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact ) |
126 | { | 131 | { |
127 | m_map.insert( newcontact.uid(), newcontact ); | 132 | m_map.insert( newcontact.uid(), newcontact ); |
128 | m_dirty = true; | 133 | m_dirty = true; |
129 | return true; | 134 | return true; |
130 | } | 135 | } |
131 | 136 | ||
132 | bool OPimContactAccessBackend_VCard::remove ( int uid ) | 137 | bool OPimContactAccessBackend_VCard::remove ( int uid ) |
133 | { | 138 | { |
134 | m_map.remove( uid ); | 139 | m_map.remove( uid ); |
135 | m_dirty = true; | 140 | m_dirty = true; |
136 | return true; | 141 | return true; |
137 | } | 142 | } |
138 | 143 | ||
139 | bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact ) | 144 | bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact ) |
140 | { | 145 | { |
141 | m_map.replace( contact.uid(), contact ); | 146 | m_map.replace( contact.uid(), contact ); |
142 | m_dirty = true; | 147 | m_dirty = true; |
143 | return true; | 148 | return true; |
144 | } | 149 | } |
145 | 150 | ||
146 | OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const | 151 | OPimContact OPimContactAccessBackend_VCard::find ( int uid ) const |
147 | { | 152 | { |
148 | return m_map[uid]; | 153 | return m_map[uid]; |
149 | } | 154 | } |
150 | 155 | ||
151 | QArray<int> OPimContactAccessBackend_VCard::allRecords() const | 156 | QArray<int> OPimContactAccessBackend_VCard::allRecords() const |
152 | { | 157 | { |
153 | QArray<int> ar( m_map.count() ); | 158 | QArray<int> ar( m_map.count() ); |
154 | QMap<int, OPimContact>::ConstIterator it; | 159 | QMap<int, OPimContact>::ConstIterator it; |
155 | int i = 0; | 160 | int i = 0; |
156 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { | 161 | for ( it = m_map.begin(); it != m_map.end(); ++it ) { |