author | eilers <eilers> | 2002-12-08 12:48:57 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-12-08 12:48:57 (UTC) |
commit | a88b210e6895614027c821bb5cedabc9b06117d3 (patch) (unidiff) | |
tree | 1c38097b1935713d165c1087268701657a38fa11 /libopie | |
parent | 6e52c7ae78769be8427b01201aa77c78aef90647 (diff) | |
download | opie-a88b210e6895614027c821bb5cedabc9b06117d3.zip opie-a88b210e6895614027c821bb5cedabc9b06117d3.tar.gz opie-a88b210e6895614027c821bb5cedabc9b06117d3.tar.bz2 |
Moved journal-enum from ocontact into i the xml-backend..
-rw-r--r-- | libopie/pim/ocontact.h | 2 | ||||
-rw-r--r-- | libopie/pim/ocontactaccessbackend_xml.h | 24 |
2 files changed, 15 insertions, 11 deletions
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h index 65ba43e..1fd1c75 100644 --- a/libopie/pim/ocontact.h +++ b/libopie/pim/ocontact.h | |||
@@ -1,112 +1,110 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) | 3 | ** Copyright (C) 2002 by Stefan Eilers (eilers.stefan@epost.de) |
4 | ** | 4 | ** |
5 | ** This file is part of the Qtopia Environment. | 5 | ** This file is part of the Qtopia Environment. |
6 | ** | 6 | ** |
7 | ** This file may be distributed and/or modified under the terms of the | 7 | ** This file may be distributed and/or modified under the terms of the |
8 | ** GNU General Public License version 2 as published by the Free Software | 8 | ** GNU General Public License version 2 as published by the Free Software |
9 | ** Foundation and appearing in the file LICENSE.GPL included in the | 9 | ** Foundation and appearing in the file LICENSE.GPL included in the |
10 | ** packaging of this file. | 10 | ** packaging of this file. |
11 | ** | 11 | ** |
12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 12 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 13 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
14 | ** | 14 | ** |
15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 15 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
16 | ** | 16 | ** |
17 | ** Contact info@trolltech.com if any conditions of this licensing are | 17 | ** Contact info@trolltech.com if any conditions of this licensing are |
18 | ** not clear to you. | 18 | ** not clear to you. |
19 | ** | 19 | ** |
20 | **********************************************************************/ | 20 | **********************************************************************/ |
21 | 21 | ||
22 | #ifndef __OCONTACT_H__ | 22 | #ifndef __OCONTACT_H__ |
23 | #define __OCONTACT_H__ | 23 | #define __OCONTACT_H__ |
24 | 24 | ||
25 | #include <opie/opimrecord.h> | 25 | #include <opie/opimrecord.h> |
26 | #include <qpe/recordfields.h> | 26 | #include <qpe/recordfields.h> |
27 | 27 | ||
28 | #include <qdatetime.h> | 28 | #include <qdatetime.h> |
29 | #include <qstringlist.h> | 29 | #include <qstringlist.h> |
30 | 30 | ||
31 | #if defined(QPC_TEMPLATEDLL) | 31 | #if defined(QPC_TEMPLATEDLL) |
32 | // MOC_SKIP_BEGIN | 32 | // MOC_SKIP_BEGIN |
33 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; | 33 | QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>; |
34 | // MOC_SKIP_END | 34 | // MOC_SKIP_END |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | class ContactPrivate; | 37 | class ContactPrivate; |
38 | 38 | ||
39 | class QPC_EXPORT OContact : public OPimRecord | 39 | class QPC_EXPORT OContact : public OPimRecord |
40 | { | 40 | { |
41 | friend class DataSet; | 41 | friend class DataSet; |
42 | public: | 42 | public: |
43 | OContact(); | 43 | OContact(); |
44 | OContact( const QMap<int, QString> &fromMap ); | 44 | OContact( const QMap<int, QString> &fromMap ); |
45 | virtual ~OContact(); | 45 | virtual ~OContact(); |
46 | 46 | ||
47 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | ||
48 | |||
49 | /* | 47 | /* |
50 | * do we need to inline them | 48 | * do we need to inline them |
51 | * if yes do we need to inline them this way? | 49 | * if yes do we need to inline them this way? |
52 | * -zecke | 50 | * -zecke |
53 | */ | 51 | */ |
54 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } | 52 | void setTitle( const QString &v ) { replace( Qtopia::Title, v ); } |
55 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } | 53 | void setFirstName( const QString &v ) { replace( Qtopia::FirstName, v ); } |
56 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } | 54 | void setMiddleName( const QString &v ) { replace( Qtopia::MiddleName, v ); } |
57 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } | 55 | void setLastName( const QString &v ) { replace( Qtopia::LastName, v ); } |
58 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } | 56 | void setSuffix( const QString &v ) { replace( Qtopia::Suffix, v ); } |
59 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } | 57 | void setFileAs( const QString &v ) { replace( Qtopia::FileAs, v ); } |
60 | void setFileAs(); | 58 | void setFileAs(); |
61 | 59 | ||
62 | // default email address | 60 | // default email address |
63 | void setDefaultEmail( const QString &v ); | 61 | void setDefaultEmail( const QString &v ); |
64 | // inserts email to list and ensure's doesn't already exist | 62 | // inserts email to list and ensure's doesn't already exist |
65 | void insertEmail( const QString &v ); | 63 | void insertEmail( const QString &v ); |
66 | void removeEmail( const QString &v ); | 64 | void removeEmail( const QString &v ); |
67 | void clearEmails(); | 65 | void clearEmails(); |
68 | void insertEmails( const QStringList &v ); | 66 | void insertEmails( const QStringList &v ); |
69 | 67 | ||
70 | // home | 68 | // home |
71 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } | 69 | void setHomeStreet( const QString &v ) { replace( Qtopia::HomeStreet, v ); } |
72 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } | 70 | void setHomeCity( const QString &v ) { replace( Qtopia::HomeCity, v ); } |
73 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } | 71 | void setHomeState( const QString &v ) { replace( Qtopia::HomeState, v ); } |
74 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } | 72 | void setHomeZip( const QString &v ) { replace( Qtopia::HomeZip, v ); } |
75 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } | 73 | void setHomeCountry( const QString &v ) { replace( Qtopia::HomeCountry, v ); } |
76 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } | 74 | void setHomePhone( const QString &v ) { replace( Qtopia::HomePhone, v ); } |
77 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } | 75 | void setHomeFax( const QString &v ) { replace( Qtopia::HomeFax, v ); } |
78 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } | 76 | void setHomeMobile( const QString &v ) { replace( Qtopia::HomeMobile, v ); } |
79 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } | 77 | void setHomeWebpage( const QString &v ) { replace( Qtopia::HomeWebPage, v ); } |
80 | 78 | ||
81 | // business | 79 | // business |
82 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } | 80 | void setCompany( const QString &v ) { replace( Qtopia::Company, v ); } |
83 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } | 81 | void setBusinessStreet( const QString &v ) { replace( Qtopia::BusinessStreet, v ); } |
84 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } | 82 | void setBusinessCity( const QString &v ) { replace( Qtopia::BusinessCity, v ); } |
85 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } | 83 | void setBusinessState( const QString &v ) { replace( Qtopia::BusinessState, v ); } |
86 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } | 84 | void setBusinessZip( const QString &v ) { replace( Qtopia::BusinessZip, v ); } |
87 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } | 85 | void setBusinessCountry( const QString &v ) { replace( Qtopia::BusinessCountry, v ); } |
88 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } | 86 | void setBusinessWebpage( const QString &v ) { replace( Qtopia::BusinessWebPage, v ); } |
89 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } | 87 | void setJobTitle( const QString &v ) { replace( Qtopia::JobTitle, v ); } |
90 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } | 88 | void setDepartment( const QString &v ) { replace( Qtopia::Department, v ); } |
91 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } | 89 | void setOffice( const QString &v ) { replace( Qtopia::Office, v ); } |
92 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } | 90 | void setBusinessPhone( const QString &v ) { replace( Qtopia::BusinessPhone, v ); } |
93 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } | 91 | void setBusinessFax( const QString &v ) { replace( Qtopia::BusinessFax, v ); } |
94 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } | 92 | void setBusinessMobile( const QString &v ) { replace( Qtopia::BusinessMobile, v ); } |
95 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } | 93 | void setBusinessPager( const QString &v ) { replace( Qtopia::BusinessPager, v ); } |
96 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } | 94 | void setProfession( const QString &v ) { replace( Qtopia::Profession, v ); } |
97 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } | 95 | void setAssistant( const QString &v ) { replace( Qtopia::Assistant, v ); } |
98 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } | 96 | void setManager( const QString &v ) { replace( Qtopia::Manager, v ); } |
99 | 97 | ||
100 | // personal | 98 | // personal |
101 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } | 99 | void setSpouse( const QString &v ) { replace( Qtopia::Spouse, v ); } |
102 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } | 100 | void setGender( const QString &v ) { replace( Qtopia::Gender, v ); } |
103 | void setBirthday( const QDate &v ); | 101 | void setBirthday( const QDate &v ); |
104 | void setAnniversary( const QDate &v ); | 102 | void setAnniversary( const QDate &v ); |
105 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } | 103 | void setNickname( const QString &v ) { replace( Qtopia::Nickname, v ); } |
106 | void setChildren( const QString &v ); | 104 | void setChildren( const QString &v ); |
107 | 105 | ||
108 | // other | 106 | // other |
109 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } | 107 | void setNotes( const QString &v ) { replace( Qtopia::Notes, v); } |
110 | 108 | ||
111 | bool match( const QString ®exp ) const; | 109 | bool match( const QString ®exp ) const; |
112 | bool match( const QRegExp ®exp ) const; | 110 | bool match( const QRegExp ®exp ) const; |
diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h index ae6ec9e..c765ff5 100644 --- a/libopie/pim/ocontactaccessbackend_xml.h +++ b/libopie/pim/ocontactaccessbackend_xml.h | |||
@@ -1,83 +1,86 @@ | |||
1 | /* | 1 | /* |
2 | * XML Backend for the OPIE-Contact Database. | 2 | * XML Backend for the OPIE-Contact Database. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; either | 9 | * License as published by the Free Software Foundation; either |
10 | * version 2 of the License, or (at your option) any later version. | 10 | * version 2 of the License, or (at your option) any later version. |
11 | * ===================================================================== | 11 | * ===================================================================== |
12 | * ToDo: XML-Backend: Automatic reload if something was changed... | 12 | * ToDo: XML-Backend: Automatic reload if something was changed... |
13 | * | 13 | * |
14 | * | 14 | * |
15 | * ===================================================================== | 15 | * ===================================================================== |
16 | * Version: $Id$ | 16 | * Version: $Id$ |
17 | * ===================================================================== | 17 | * ===================================================================== |
18 | * History: | 18 | * History: |
19 | * $Log$ | 19 | * $Log$ |
20 | * Revision 1.9 2002/12/08 12:48:57 eilers | ||
21 | * Moved journal-enum from ocontact into i the xml-backend.. | ||
22 | * | ||
20 | * Revision 1.8 2002/11/14 17:04:24 eilers | 23 | * Revision 1.8 2002/11/14 17:04:24 eilers |
21 | * Sorting will now work if fullname is identical on some entries | 24 | * Sorting will now work if fullname is identical on some entries |
22 | * | 25 | * |
23 | * Revision 1.7 2002/11/13 15:02:46 eilers | 26 | * Revision 1.7 2002/11/13 15:02:46 eilers |
24 | * Small Bug in sorted fixed | 27 | * Small Bug in sorted fixed |
25 | * | 28 | * |
26 | * Revision 1.6 2002/11/13 14:14:51 eilers | 29 | * Revision 1.6 2002/11/13 14:14:51 eilers |
27 | * Added sorted for Contacts.. | 30 | * Added sorted for Contacts.. |
28 | * | 31 | * |
29 | * Revision 1.5 2002/11/01 15:10:42 eilers | 32 | * Revision 1.5 2002/11/01 15:10:42 eilers |
30 | * Added regExp-search in database for all fields in a contact. | 33 | * Added regExp-search in database for all fields in a contact. |
31 | * | 34 | * |
32 | * Revision 1.4 2002/10/16 10:52:40 eilers | 35 | * Revision 1.4 2002/10/16 10:52:40 eilers |
33 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | 36 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) |
34 | * | 37 | * |
35 | * Revision 1.3 2002/10/14 16:21:54 eilers | 38 | * Revision 1.3 2002/10/14 16:21:54 eilers |
36 | * Some minor interface updates | 39 | * Some minor interface updates |
37 | * | 40 | * |
38 | * Revision 1.2 2002/10/07 17:34:24 eilers | 41 | * Revision 1.2 2002/10/07 17:34:24 eilers |
39 | * added OBackendFactory for advanced backend access | 42 | * added OBackendFactory for advanced backend access |
40 | * | 43 | * |
41 | * Revision 1.1 2002/09/27 17:11:44 eilers | 44 | * Revision 1.1 2002/09/27 17:11:44 eilers |
42 | * Added API for accessing the Contact-Database ! It is compiling, but | 45 | * Added API for accessing the Contact-Database ! It is compiling, but |
43 | * please do not expect that anything is working ! | 46 | * please do not expect that anything is working ! |
44 | * I will debug that stuff in the next time .. | 47 | * I will debug that stuff in the next time .. |
45 | * Please read README_COMPILE for compiling ! | 48 | * Please read README_COMPILE for compiling ! |
46 | * | 49 | * |
47 | * | 50 | * |
48 | */ | 51 | */ |
49 | 52 | ||
50 | #ifndef _OContactAccessBackend_XML_ | 53 | #ifndef _OContactAccessBackend_XML_ |
51 | #define _OContactAccessBackend_XML_ | 54 | #define _OContactAccessBackend_XML_ |
52 | 55 | ||
53 | #include <qasciidict.h> | 56 | #include <qasciidict.h> |
54 | #include <qdatetime.h> | 57 | #include <qdatetime.h> |
55 | #include <qfile.h> | 58 | #include <qfile.h> |
56 | #include <qfileinfo.h> | 59 | #include <qfileinfo.h> |
57 | #include <qregexp.h> | 60 | #include <qregexp.h> |
58 | #include <qarray.h> | 61 | #include <qarray.h> |
59 | #include <qmap.h> | 62 | #include <qmap.h> |
60 | 63 | ||
61 | #include <qpe/global.h> | 64 | #include <qpe/global.h> |
62 | 65 | ||
63 | #include <opie/xmltree.h> | 66 | #include <opie/xmltree.h> |
64 | #include "ocontactaccessbackend.h" | 67 | #include "ocontactaccessbackend.h" |
65 | #include "ocontactaccess.h" | 68 | #include "ocontactaccess.h" |
66 | 69 | ||
67 | #include <stdlib.h> | 70 | #include <stdlib.h> |
68 | #include <errno.h> | 71 | #include <errno.h> |
69 | 72 | ||
70 | using namespace Opie; | 73 | using namespace Opie; |
71 | 74 | ||
72 | /* the default xml implementation */ | 75 | /* the default xml implementation */ |
73 | class OContactAccessBackend_XML : public OContactAccessBackend { | 76 | class OContactAccessBackend_XML : public OContactAccessBackend { |
74 | public: | 77 | public: |
75 | OContactAccessBackend_XML ( QString appname, QString filename = 0l ): | 78 | OContactAccessBackend_XML ( QString appname, QString filename = 0l ): |
76 | m_changed( false ) | 79 | m_changed( false ) |
77 | { | 80 | { |
78 | m_appName = appname; | 81 | m_appName = appname; |
79 | 82 | ||
80 | /* Set journalfile name ... */ | 83 | /* Set journalfile name ... */ |
81 | m_journalName = getenv("HOME"); | 84 | m_journalName = getenv("HOME"); |
82 | m_journalName +="/.abjournal" + appname; | 85 | m_journalName +="/.abjournal" + appname; |
83 | 86 | ||
@@ -281,360 +284,363 @@ class OContactAccessBackend_XML : public OContactAccessBackend { | |||
281 | } | 284 | } |
282 | // Shrink to fit.. | 285 | // Shrink to fit.. |
283 | m_currentQuery.resize(arraycounter); | 286 | m_currentQuery.resize(arraycounter); |
284 | 287 | ||
285 | return m_currentQuery; | 288 | return m_currentQuery; |
286 | } | 289 | } |
287 | 290 | ||
288 | const uint querySettings() | 291 | const uint querySettings() |
289 | { | 292 | { |
290 | return ( OContactAccess::WildCards | 293 | return ( OContactAccess::WildCards |
291 | & OContactAccess::IgnoreCase | 294 | & OContactAccess::IgnoreCase |
292 | & OContactAccess::RegExp | 295 | & OContactAccess::RegExp |
293 | & OContactAccess::ExactMatch ); | 296 | & OContactAccess::ExactMatch ); |
294 | } | 297 | } |
295 | 298 | ||
296 | bool hasQuerySettings (uint querySettings) const | 299 | bool hasQuerySettings (uint querySettings) const |
297 | { | 300 | { |
298 | /* OContactAccess::IgnoreCase may be added with one | 301 | /* OContactAccess::IgnoreCase may be added with one |
299 | * of the other settings, but never used alone. | 302 | * of the other settings, but never used alone. |
300 | * The other settings are just valid alone... | 303 | * The other settings are just valid alone... |
301 | */ | 304 | */ |
302 | switch ( querySettings & ~OContactAccess::IgnoreCase ){ | 305 | switch ( querySettings & ~OContactAccess::IgnoreCase ){ |
303 | case OContactAccess::RegExp: | 306 | case OContactAccess::RegExp: |
304 | return ( true ); | 307 | return ( true ); |
305 | case OContactAccess::WildCards: | 308 | case OContactAccess::WildCards: |
306 | return ( true ); | 309 | return ( true ); |
307 | case OContactAccess::ExactMatch: | 310 | case OContactAccess::ExactMatch: |
308 | return ( true ); | 311 | return ( true ); |
309 | default: | 312 | default: |
310 | return ( false ); | 313 | return ( false ); |
311 | } | 314 | } |
312 | } | 315 | } |
313 | 316 | ||
314 | // Currently only asc implemented.. | 317 | // Currently only asc implemented.. |
315 | QArray<int> sorted( bool asc, int , int , int ) | 318 | QArray<int> sorted( bool asc, int , int , int ) |
316 | { | 319 | { |
317 | QMap<QString, int> nameToUid; | 320 | QMap<QString, int> nameToUid; |
318 | QStringList names; | 321 | QStringList names; |
319 | QArray<int> m_currentQuery( m_contactList.count() ); | 322 | QArray<int> m_currentQuery( m_contactList.count() ); |
320 | 323 | ||
321 | // First fill map and StringList with all Names | 324 | // First fill map and StringList with all Names |
322 | // Afterwards sort namelist and use map to fill array to return.. | 325 | // Afterwards sort namelist and use map to fill array to return.. |
323 | QValueListConstIterator<OContact> it; | 326 | QValueListConstIterator<OContact> it; |
324 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ | 327 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ |
325 | names.append( (*it).fileAs() + QString::number( (*it).uid() ) ); | 328 | names.append( (*it).fileAs() + QString::number( (*it).uid() ) ); |
326 | nameToUid.insert( (*it).fileAs() + QString::number( (*it).uid() ), (*it).uid() ); | 329 | nameToUid.insert( (*it).fileAs() + QString::number( (*it).uid() ), (*it).uid() ); |
327 | } | 330 | } |
328 | names.sort(); | 331 | names.sort(); |
329 | 332 | ||
330 | int i = 0; | 333 | int i = 0; |
331 | if ( asc ){ | 334 | if ( asc ){ |
332 | for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) | 335 | for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) |
333 | m_currentQuery[i++] = nameToUid[ (*it) ]; | 336 | m_currentQuery[i++] = nameToUid[ (*it) ]; |
334 | }else{ | 337 | }else{ |
335 | for ( QStringList::Iterator it = names.end(); it != names.begin(); --it ) | 338 | for ( QStringList::Iterator it = names.end(); it != names.begin(); --it ) |
336 | m_currentQuery[i++] = nameToUid[ (*it) ]; | 339 | m_currentQuery[i++] = nameToUid[ (*it) ]; |
337 | } | 340 | } |
338 | 341 | ||
339 | return m_currentQuery; | 342 | return m_currentQuery; |
340 | 343 | ||
341 | } | 344 | } |
342 | bool add ( const OContact &newcontact ) | 345 | bool add ( const OContact &newcontact ) |
343 | { | 346 | { |
344 | //qWarning("odefaultbackend: ACTION::ADD"); | 347 | //qWarning("odefaultbackend: ACTION::ADD"); |
345 | updateJournal (newcontact, OContact::ACTION_ADD); | 348 | updateJournal (newcontact, ACTION_ADD); |
346 | addContact_p( newcontact ); | 349 | addContact_p( newcontact ); |
347 | 350 | ||
348 | m_changed = true; | 351 | m_changed = true; |
349 | 352 | ||
350 | return true; | 353 | return true; |
351 | } | 354 | } |
352 | 355 | ||
353 | bool replace ( const OContact &contact ) | 356 | bool replace ( const OContact &contact ) |
354 | { | 357 | { |
355 | m_changed = true; | 358 | m_changed = true; |
356 | 359 | ||
357 | bool found = false; | 360 | bool found = false; |
358 | 361 | ||
359 | QValueListIterator<OContact> it; | 362 | QValueListIterator<OContact> it; |
360 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ | 363 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ |
361 | if ( (*it).uid() == contact.uid() ){ | 364 | if ( (*it).uid() == contact.uid() ){ |
362 | found = true; | 365 | found = true; |
363 | break; | 366 | break; |
364 | } | 367 | } |
365 | } | 368 | } |
366 | if (found) { | 369 | if (found) { |
367 | updateJournal (contact, OContact::ACTION_REPLACE); | 370 | updateJournal (contact, ACTION_REPLACE); |
368 | m_contactList.remove (it); | 371 | m_contactList.remove (it); |
369 | m_contactList.append (contact); | 372 | m_contactList.append (contact); |
370 | return true; | 373 | return true; |
371 | } else | 374 | } else |
372 | return false; | 375 | return false; |
373 | } | 376 | } |
374 | 377 | ||
375 | bool remove ( int uid ) | 378 | bool remove ( int uid ) |
376 | { | 379 | { |
377 | m_changed = true; | 380 | m_changed = true; |
378 | 381 | ||
379 | bool found = false; | 382 | bool found = false; |
380 | QValueListIterator<OContact> it; | 383 | QValueListIterator<OContact> it; |
381 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ | 384 | for( it = m_contactList.begin(); it != m_contactList.end(); ++it ){ |
382 | if ((*it).uid() == uid){ | 385 | if ((*it).uid() == uid){ |
383 | found = true; | 386 | found = true; |
384 | break; | 387 | break; |
385 | } | 388 | } |
386 | } | 389 | } |
387 | if (found) { | 390 | if (found) { |
388 | updateJournal ( *it, OContact::ACTION_REMOVE); | 391 | updateJournal ( *it, ACTION_REMOVE); |
389 | m_contactList.remove (it); | 392 | m_contactList.remove (it); |
390 | return true; | 393 | return true; |
391 | } else | 394 | } else |
392 | return false; | 395 | return false; |
393 | } | 396 | } |
394 | 397 | ||
395 | bool reload(){ | 398 | bool reload(){ |
396 | /* Reload is the same as load in this implementation */ | 399 | /* Reload is the same as load in this implementation */ |
397 | return ( load() ); | 400 | return ( load() ); |
398 | } | 401 | } |
399 | 402 | ||
400 | private: | 403 | private: |
404 | |||
405 | enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; | ||
406 | |||
401 | void addContact_p( const OContact &newcontact ){ | 407 | void addContact_p( const OContact &newcontact ){ |
402 | m_contactList.append (newcontact); | 408 | m_contactList.append (newcontact); |
403 | } | 409 | } |
404 | 410 | ||
405 | /* This function loads the xml-database and the journalfile */ | 411 | /* This function loads the xml-database and the journalfile */ |
406 | bool load( const QString filename, bool isJournal ) { | 412 | bool load( const QString filename, bool isJournal ) { |
407 | 413 | ||
408 | /* We use the time of the last read to check if the file was | 414 | /* We use the time of the last read to check if the file was |
409 | * changed externally. | 415 | * changed externally. |
410 | */ | 416 | */ |
411 | if ( !isJournal ){ | 417 | if ( !isJournal ){ |
412 | QFileInfo fi( filename ); | 418 | QFileInfo fi( filename ); |
413 | m_readtime = fi.lastModified (); | 419 | m_readtime = fi.lastModified (); |
414 | } | 420 | } |
415 | 421 | ||
416 | const int JOURNALACTION = Qtopia::Notes + 1; | 422 | const int JOURNALACTION = Qtopia::Notes + 1; |
417 | const int JOURNALROW = JOURNALACTION + 1; | 423 | const int JOURNALROW = JOURNALACTION + 1; |
418 | 424 | ||
419 | bool foundAction = false; | 425 | bool foundAction = false; |
420 | OContact::journal_action action = OContact::ACTION_ADD; | 426 | journal_action action = ACTION_ADD; |
421 | int journalKey = 0; | 427 | int journalKey = 0; |
422 | QMap<int, QString> contactMap; | 428 | QMap<int, QString> contactMap; |
423 | QMap<QString, QString> customMap; | 429 | QMap<QString, QString> customMap; |
424 | QMap<QString, QString>::Iterator customIt; | 430 | QMap<QString, QString>::Iterator customIt; |
425 | QAsciiDict<int> dict( 47 ); | 431 | QAsciiDict<int> dict( 47 ); |
426 | 432 | ||
427 | dict.setAutoDelete( TRUE ); | 433 | dict.setAutoDelete( TRUE ); |
428 | dict.insert( "Uid", new int(Qtopia::AddressUid) ); | 434 | dict.insert( "Uid", new int(Qtopia::AddressUid) ); |
429 | dict.insert( "Title", new int(Qtopia::Title) ); | 435 | dict.insert( "Title", new int(Qtopia::Title) ); |
430 | dict.insert( "FirstName", new int(Qtopia::FirstName) ); | 436 | dict.insert( "FirstName", new int(Qtopia::FirstName) ); |
431 | dict.insert( "MiddleName", new int(Qtopia::MiddleName) ); | 437 | dict.insert( "MiddleName", new int(Qtopia::MiddleName) ); |
432 | dict.insert( "LastName", new int(Qtopia::LastName) ); | 438 | dict.insert( "LastName", new int(Qtopia::LastName) ); |
433 | dict.insert( "Suffix", new int(Qtopia::Suffix) ); | 439 | dict.insert( "Suffix", new int(Qtopia::Suffix) ); |
434 | dict.insert( "FileAs", new int(Qtopia::FileAs) ); | 440 | dict.insert( "FileAs", new int(Qtopia::FileAs) ); |
435 | dict.insert( "Categories", new int(Qtopia::AddressCategory) ); | 441 | dict.insert( "Categories", new int(Qtopia::AddressCategory) ); |
436 | dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) ); | 442 | dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) ); |
437 | dict.insert( "Emails", new int(Qtopia::Emails) ); | 443 | dict.insert( "Emails", new int(Qtopia::Emails) ); |
438 | dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) ); | 444 | dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) ); |
439 | dict.insert( "HomeCity", new int(Qtopia::HomeCity) ); | 445 | dict.insert( "HomeCity", new int(Qtopia::HomeCity) ); |
440 | dict.insert( "HomeState", new int(Qtopia::HomeState) ); | 446 | dict.insert( "HomeState", new int(Qtopia::HomeState) ); |
441 | dict.insert( "HomeZip", new int(Qtopia::HomeZip) ); | 447 | dict.insert( "HomeZip", new int(Qtopia::HomeZip) ); |
442 | dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) ); | 448 | dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) ); |
443 | dict.insert( "HomePhone", new int(Qtopia::HomePhone) ); | 449 | dict.insert( "HomePhone", new int(Qtopia::HomePhone) ); |
444 | dict.insert( "HomeFax", new int(Qtopia::HomeFax) ); | 450 | dict.insert( "HomeFax", new int(Qtopia::HomeFax) ); |
445 | dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) ); | 451 | dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) ); |
446 | dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) ); | 452 | dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) ); |
447 | dict.insert( "Company", new int(Qtopia::Company) ); | 453 | dict.insert( "Company", new int(Qtopia::Company) ); |
448 | dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) ); | 454 | dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) ); |
449 | dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) ); | 455 | dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) ); |
450 | dict.insert( "BusinessState", new int(Qtopia::BusinessState) ); | 456 | dict.insert( "BusinessState", new int(Qtopia::BusinessState) ); |
451 | dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) ); | 457 | dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) ); |
452 | dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) ); | 458 | dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) ); |
453 | dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) ); | 459 | dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) ); |
454 | dict.insert( "JobTitle", new int(Qtopia::JobTitle) ); | 460 | dict.insert( "JobTitle", new int(Qtopia::JobTitle) ); |
455 | dict.insert( "Department", new int(Qtopia::Department) ); | 461 | dict.insert( "Department", new int(Qtopia::Department) ); |
456 | dict.insert( "Office", new int(Qtopia::Office) ); | 462 | dict.insert( "Office", new int(Qtopia::Office) ); |
457 | dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) ); | 463 | dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) ); |
458 | dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) ); | 464 | dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) ); |
459 | dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) ); | 465 | dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) ); |
460 | dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) ); | 466 | dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) ); |
461 | dict.insert( "Profession", new int(Qtopia::Profession) ); | 467 | dict.insert( "Profession", new int(Qtopia::Profession) ); |
462 | dict.insert( "Assistant", new int(Qtopia::Assistant) ); | 468 | dict.insert( "Assistant", new int(Qtopia::Assistant) ); |
463 | dict.insert( "Manager", new int(Qtopia::Manager) ); | 469 | dict.insert( "Manager", new int(Qtopia::Manager) ); |
464 | dict.insert( "Spouse", new int(Qtopia::Spouse) ); | 470 | dict.insert( "Spouse", new int(Qtopia::Spouse) ); |
465 | dict.insert( "Children", new int(Qtopia::Children) ); | 471 | dict.insert( "Children", new int(Qtopia::Children) ); |
466 | dict.insert( "Gender", new int(Qtopia::Gender) ); | 472 | dict.insert( "Gender", new int(Qtopia::Gender) ); |
467 | dict.insert( "Birthday", new int(Qtopia::Birthday) ); | 473 | dict.insert( "Birthday", new int(Qtopia::Birthday) ); |
468 | dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); | 474 | dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); |
469 | dict.insert( "Nickname", new int(Qtopia::Nickname) ); | 475 | dict.insert( "Nickname", new int(Qtopia::Nickname) ); |
470 | dict.insert( "Notes", new int(Qtopia::Notes) ); | 476 | dict.insert( "Notes", new int(Qtopia::Notes) ); |
471 | dict.insert( "action", new int(JOURNALACTION) ); | 477 | dict.insert( "action", new int(JOURNALACTION) ); |
472 | dict.insert( "actionrow", new int(JOURNALROW) ); | 478 | dict.insert( "actionrow", new int(JOURNALROW) ); |
473 | 479 | ||
474 | //qWarning( "OContactDefaultBackEnd::loading %s", filename.latin1() ); | 480 | //qWarning( "OContactDefaultBackEnd::loading %s", filename.latin1() ); |
475 | 481 | ||
476 | XMLElement *root = XMLElement::load( filename ); | 482 | XMLElement *root = XMLElement::load( filename ); |
477 | if(root != 0l ){ // start parsing | 483 | if(root != 0l ){ // start parsing |
478 | /* Parse all XML-Elements and put the data into the | 484 | /* Parse all XML-Elements and put the data into the |
479 | * Contact-Class | 485 | * Contact-Class |
480 | */ | 486 | */ |
481 | XMLElement *element = root->firstChild(); | 487 | XMLElement *element = root->firstChild(); |
482 | //qWarning("OContactAccess::load tagName(): %s", root->tagName().latin1() ); | 488 | //qWarning("OContactAccess::load tagName(): %s", root->tagName().latin1() ); |
483 | element = element->firstChild(); | 489 | element = element->firstChild(); |
484 | 490 | ||
485 | /* Search Tag "Contacts" which is the parent of all Contacts */ | 491 | /* Search Tag "Contacts" which is the parent of all Contacts */ |
486 | while( element && !isJournal ){ | 492 | while( element && !isJournal ){ |
487 | if( element->tagName() != QString::fromLatin1("Contacts") ){ | 493 | if( element->tagName() != QString::fromLatin1("Contacts") ){ |
488 | //qWarning ("OContactDefBack::Searching for Tag \"Contacts\"! Found: %s", | 494 | //qWarning ("OContactDefBack::Searching for Tag \"Contacts\"! Found: %s", |
489 | // element->tagName().latin1()); | 495 | // element->tagName().latin1()); |
490 | element = element->nextChild(); | 496 | element = element->nextChild(); |
491 | } else { | 497 | } else { |
492 | element = element->firstChild(); | 498 | element = element->firstChild(); |
493 | break; | 499 | break; |
494 | } | 500 | } |
495 | } | 501 | } |
496 | /* Parse all Contacts and ignore unknown tags */ | 502 | /* Parse all Contacts and ignore unknown tags */ |
497 | while( element ){ | 503 | while( element ){ |
498 | if( element->tagName() != QString::fromLatin1("Contact") ){ | 504 | if( element->tagName() != QString::fromLatin1("Contact") ){ |
499 | //qWarning ("OContactDefBack::Searching for Tag \"Contact\"! Found: %s", | 505 | //qWarning ("OContactDefBack::Searching for Tag \"Contact\"! Found: %s", |
500 | // element->tagName().latin1()); | 506 | // element->tagName().latin1()); |
501 | element = element->nextChild(); | 507 | element = element->nextChild(); |
502 | continue; | 508 | continue; |
503 | } | 509 | } |
504 | /* Found alement with tagname "contact", now parse and store all | 510 | /* Found alement with tagname "contact", now parse and store all |
505 | * attributes contained | 511 | * attributes contained |
506 | */ | 512 | */ |
507 | //qWarning("OContactDefBack::load element tagName() : %s", | 513 | //qWarning("OContactDefBack::load element tagName() : %s", |
508 | // element->tagName().latin1() ); | 514 | // element->tagName().latin1() ); |
509 | QString dummy; | 515 | QString dummy; |
510 | foundAction = false; | 516 | foundAction = false; |
511 | 517 | ||
512 | XMLElement::AttributeMap aMap = element->attributes(); | 518 | XMLElement::AttributeMap aMap = element->attributes(); |
513 | XMLElement::AttributeMap::Iterator it; | 519 | XMLElement::AttributeMap::Iterator it; |
514 | contactMap.clear(); | 520 | contactMap.clear(); |
515 | customMap.clear(); | 521 | customMap.clear(); |
516 | for( it = aMap.begin(); it != aMap.end(); ++it ){ | 522 | for( it = aMap.begin(); it != aMap.end(); ++it ){ |
517 | // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); | 523 | // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); |
518 | 524 | ||
519 | int *find = dict[ it.key() ]; | 525 | int *find = dict[ it.key() ]; |
520 | /* Unknown attributes will be stored as "Custom" elements */ | 526 | /* Unknown attributes will be stored as "Custom" elements */ |
521 | if ( !find ) { | 527 | if ( !find ) { |
522 | qWarning("Attribute %s not known.", it.key().latin1()); | 528 | qWarning("Attribute %s not known.", it.key().latin1()); |
523 | //contact.setCustomField(it.key(), it.data()); | 529 | //contact.setCustomField(it.key(), it.data()); |
524 | customMap.insert( it.key(), it.data() ); | 530 | customMap.insert( it.key(), it.data() ); |
525 | continue; | 531 | continue; |
526 | } | 532 | } |
527 | 533 | ||
528 | /* Check if special conversion is needed and add attribute | 534 | /* Check if special conversion is needed and add attribute |
529 | * into Contact class | 535 | * into Contact class |
530 | */ | 536 | */ |
531 | switch( *find ) { | 537 | switch( *find ) { |
532 | /* | 538 | /* |
533 | case Qtopia::AddressUid: | 539 | case Qtopia::AddressUid: |
534 | contact.setUid( it.data().toInt() ); | 540 | contact.setUid( it.data().toInt() ); |
535 | break; | 541 | break; |
536 | case Qtopia::AddressCategory: | 542 | case Qtopia::AddressCategory: |
537 | contact.setCategories( Qtopia::Record::idsFromString( it.data( ))); | 543 | contact.setCategories( Qtopia::Record::idsFromString( it.data( ))); |
538 | break; | 544 | break; |
539 | */ | 545 | */ |
540 | case JOURNALACTION: | 546 | case JOURNALACTION: |
541 | action = OContact::journal_action(it.data().toInt()); | 547 | action = journal_action(it.data().toInt()); |
542 | foundAction = true; | 548 | foundAction = true; |
543 | qWarning ("ODefBack(journal)::ACTION found: %d", action); | 549 | qWarning ("ODefBack(journal)::ACTION found: %d", action); |
544 | break; | 550 | break; |
545 | case JOURNALROW: | 551 | case JOURNALROW: |
546 | journalKey = it.data().toInt(); | 552 | journalKey = it.data().toInt(); |
547 | break; | 553 | break; |
548 | default: // no conversion needed add them to the map | 554 | default: // no conversion needed add them to the map |
549 | contactMap.insert( *find, it.data() ); | 555 | contactMap.insert( *find, it.data() ); |
550 | break; | 556 | break; |
551 | } | 557 | } |
552 | } | 558 | } |
553 | /* now generate the Contact contact */ | 559 | /* now generate the Contact contact */ |
554 | OContact contact( contactMap ); | 560 | OContact contact( contactMap ); |
555 | 561 | ||
556 | for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { | 562 | for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { |
557 | contact.setCustomField( customIt.key(), customIt.data() ); | 563 | contact.setCustomField( customIt.key(), customIt.data() ); |
558 | } | 564 | } |
559 | 565 | ||
560 | if (foundAction){ | 566 | if (foundAction){ |
561 | foundAction = false; | 567 | foundAction = false; |
562 | switch ( action ) { | 568 | switch ( action ) { |
563 | case OContact::ACTION_ADD: | 569 | case ACTION_ADD: |
564 | addContact_p (contact); | 570 | addContact_p (contact); |
565 | break; | 571 | break; |
566 | case OContact::ACTION_REMOVE: | 572 | case ACTION_REMOVE: |
567 | if ( !remove (contact.uid()) ) | 573 | if ( !remove (contact.uid()) ) |
568 | qWarning ("ODefBack(journal)::Unable to remove uid: %d", | 574 | qWarning ("ODefBack(journal)::Unable to remove uid: %d", |
569 | contact.uid() ); | 575 | contact.uid() ); |
570 | break; | 576 | break; |
571 | case OContact::ACTION_REPLACE: | 577 | case ACTION_REPLACE: |
572 | if ( !replace ( contact ) ) | 578 | if ( !replace ( contact ) ) |
573 | qWarning ("ODefBack(journal)::Unable to replace uid: %d", | 579 | qWarning ("ODefBack(journal)::Unable to replace uid: %d", |
574 | contact.uid() ); | 580 | contact.uid() ); |
575 | break; | 581 | break; |
576 | default: | 582 | default: |
577 | qWarning ("Unknown action: ignored !"); | 583 | qWarning ("Unknown action: ignored !"); |
578 | break; | 584 | break; |
579 | } | 585 | } |
580 | }else{ | 586 | }else{ |
581 | /* Add contact to list */ | 587 | /* Add contact to list */ |
582 | addContact_p (contact); | 588 | addContact_p (contact); |
583 | } | 589 | } |
584 | 590 | ||
585 | /* Move to next element */ | 591 | /* Move to next element */ |
586 | element = element->nextChild(); | 592 | element = element->nextChild(); |
587 | } | 593 | } |
588 | }else { | 594 | }else { |
589 | qWarning("ODefBack::could not load"); | 595 | qWarning("ODefBack::could not load"); |
590 | } | 596 | } |
591 | delete root; | 597 | delete root; |
592 | qWarning("returning from loading" ); | 598 | qWarning("returning from loading" ); |
593 | return true; | 599 | return true; |
594 | } | 600 | } |
595 | 601 | ||
596 | 602 | ||
597 | void updateJournal( const OContact& cnt, | 603 | void updateJournal( const OContact& cnt, |
598 | OContact::journal_action action ) { | 604 | journal_action action ) { |
599 | QFile f( m_journalName ); | 605 | QFile f( m_journalName ); |
600 | bool created = !f.exists(); | 606 | bool created = !f.exists(); |
601 | if ( !f.open(IO_WriteOnly|IO_Append) ) | 607 | if ( !f.open(IO_WriteOnly|IO_Append) ) |
602 | return; | 608 | return; |
603 | 609 | ||
604 | QString buf; | 610 | QString buf; |
605 | QCString str; | 611 | QCString str; |
606 | 612 | ||
607 | // if the file was created, we have to set the Tag "<CONTACTS>" to | 613 | // if the file was created, we have to set the Tag "<CONTACTS>" to |
608 | // get a XML-File which is readable by our parser. | 614 | // get a XML-File which is readable by our parser. |
609 | // This is just a cheat, but better than rewrite the parser. | 615 | // This is just a cheat, but better than rewrite the parser. |
610 | if ( created ){ | 616 | if ( created ){ |
611 | buf = "<Contacts>"; | 617 | buf = "<Contacts>"; |
612 | QCString cstr = buf.utf8(); | 618 | QCString cstr = buf.utf8(); |
613 | f.writeBlock( cstr.data(), cstr.length() ); | 619 | f.writeBlock( cstr.data(), cstr.length() ); |
614 | } | 620 | } |
615 | 621 | ||
616 | buf = "<Contact "; | 622 | buf = "<Contact "; |
617 | cnt.save( buf ); | 623 | cnt.save( buf ); |
618 | buf += " action=\"" + QString::number( (int)action ) + "\" "; | 624 | buf += " action=\"" + QString::number( (int)action ) + "\" "; |
619 | buf += "/>\n"; | 625 | buf += "/>\n"; |
620 | QCString cstr = buf.utf8(); | 626 | QCString cstr = buf.utf8(); |
621 | f.writeBlock( cstr.data(), cstr.length() ); | 627 | f.writeBlock( cstr.data(), cstr.length() ); |
622 | } | 628 | } |
623 | 629 | ||
624 | void removeJournal() | 630 | void removeJournal() |
625 | { | 631 | { |
626 | QFile f ( m_journalName ); | 632 | QFile f ( m_journalName ); |
627 | if ( f.exists() ) | 633 | if ( f.exists() ) |
628 | f.remove(); | 634 | f.remove(); |
629 | } | 635 | } |
630 | 636 | ||
631 | protected: | 637 | protected: |
632 | bool m_changed; | 638 | bool m_changed; |
633 | QString m_journalName; | 639 | QString m_journalName; |
634 | QString m_fileName; | 640 | QString m_fileName; |
635 | QString m_appName; | 641 | QString m_appName; |
636 | QValueList<OContact> m_contactList; | 642 | QValueList<OContact> m_contactList; |
637 | QDateTime m_readtime; | 643 | QDateTime m_readtime; |
638 | }; | 644 | }; |
639 | 645 | ||
640 | #endif | 646 | #endif |