summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp135
1 files changed, 33 insertions, 102 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index aae7fca..4c3da0c 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -1,138 +1,68 @@
1/* 1/*
2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29/*
2 * XML Backend for the OPIE-Contact Database. 30 * XML Backend for the OPIE-Contact Database.
3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 *
6 * =====================================================================
7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 * =====================================================================
12 *
13 * =====================================================================
14 * Version: $Id$
15 * =====================================================================
16 * History:
17 * $Log$
18 * Revision 1.9 2003/09/22 14:31:16 eilers
19 * Added first experimental incarnation of sql-backend for addressbook.
20 * Some modifications to be able to compile the todo sql-backend.
21 * A lot of changes fill follow...
22 *
23 * Revision 1.8 2003/08/30 15:28:26 eilers
24 * Removed some unimportant debug output which causes slow down..
25 *
26 * Revision 1.7 2003/08/01 12:30:16 eilers
27 * Merging changes from BRANCH_1_0 to HEAD
28 *
29 * Revision 1.6 2003/07/07 16:19:47 eilers
30 * Fixing serious bug in hasQuerySettings()
31 *
32 * Revision 1.5 2003/04/13 18:07:10 zecke
33 * More API doc
34 * QString -> const QString&
35 * QString = 0l -> QString::null
36 *
37 * Revision 1.4 2003/03/21 14:32:54 mickeyl
38 * g++ compliance fix: default arguments belong into the declaration, but not the definition
39 *
40 * Revision 1.3 2003/03/21 12:26:28 eilers
41 * Fixing small bug: If we search a birthday from today to today, it returned
42 * every contact ..
43 *
44 * Revision 1.2 2003/03/21 10:33:09 eilers
45 * Merged speed optimized xml backend for contacts to main.
46 * Added QDateTime to querybyexample. For instance, it is now possible to get
47 * all Birthdays/Anniversaries between two dates. This should be used
48 * to show all birthdays in the datebook..
49 * This change is sourcecode backward compatible but you have to upgrade
50 * the binaries for today-addressbook.
51 *
52 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers
53 * Speed optimization. Removed the sequential search loops.
54 *
55 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers
56 * Writing offsets to debug output..
57 *
58 * Revision 1.1 2003/02/09 15:05:01 eilers
59 * Nothing happened.. Just some cleanup before I will start..
60 *
61 * Revision 1.12 2003/01/03 16:58:03 eilers
62 * Reenable debug output
63 *
64 * Revision 1.11 2003/01/03 12:31:28 eilers
65 * Bugfix for calculating data diffs..
66 *
67 * Revision 1.10 2003/01/02 14:27:12 eilers
68 * Improved query by example: Search by date is possible.. First step
69 * for a today plugin for birthdays..
70 *
71 * Revision 1.9 2002/12/08 12:48:57 eilers
72 * Moved journal-enum from ocontact into i the xml-backend..
73 *
74 * Revision 1.8 2002/11/14 17:04:24 eilers
75 * Sorting will now work if fullname is identical on some entries
76 *
77 * Revision 1.7 2002/11/13 15:02:46 eilers
78 * Small Bug in sorted fixed
79 *
80 * Revision 1.6 2002/11/13 14:14:51 eilers
81 * Added sorted for Contacts..
82 *
83 * Revision 1.5 2002/11/01 15:10:42 eilers
84 * Added regExp-search in database for all fields in a contact.
85 *
86 * Revision 1.4 2002/10/16 10:52:40 eilers
87 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
88 *
89 * Revision 1.3 2002/10/14 16:21:54 eilers
90 * Some minor interface updates
91 *
92 * Revision 1.2 2002/10/07 17:34:24 eilers
93 * added OBackendFactory for advanced backend access
94 *
95 * Revision 1.1 2002/09/27 17:11:44 eilers
96 * Added API for accessing the Contact-Database ! It is compiling, but
97 * please do not expect that anything is working !
98 * I will debug that stuff in the next time ..
99 * Please read README_COMPILE for compiling !
100 *
101 *
102 */ 31 */
103 32
104#include "ocontactaccessbackend_xml.h" 33#include <opie2/ocontactaccessbackend_xml.h>
105 34
106#include <qasciidict.h> 35#include <qasciidict.h>
107#include <qdatetime.h> 36#include <qdatetime.h>
108#include <qfile.h> 37#include <qfile.h>
109#include <qfileinfo.h> 38#include <qfileinfo.h>
110#include <qregexp.h> 39#include <qregexp.h>
111#include <qarray.h> 40#include <qarray.h>
112#include <qmap.h> 41#include <qmap.h>
113#include <qdatetime.h> 42#include <qdatetime.h>
114 43
115#include <qpe/global.h> 44#include <qpe/global.h>
116 45
117#include <opie/xmltree.h> 46#include <opie/xmltree.h>
118#include "ocontactaccessbackend.h" 47#include <opie2/ocontactaccessbackend.h>
119#include "ocontactaccess.h" 48#include <opie2/ocontactaccess.h>
120 49
121#include <stdlib.h> 50#include <stdlib.h>
122#include <errno.h> 51#include <errno.h>
123 52
124using namespace Opie; 53using namespace Opie;
125 54
126 55
56namespace Opie {
127OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ): 57OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ):
128 m_changed( false ) 58 m_changed( false )
129{ 59{
130 // Just m_contactlist should call delete if an entry 60 // Just m_contactlist should call delete if an entry
131 // is removed. 61 // is removed.
132 m_contactList.setAutoDelete( true ); 62 m_contactList.setAutoDelete( true );
133 m_uidToContact.setAutoDelete( false ); 63 m_uidToContact.setAutoDelete( false );
134 64
135 m_appName = appname; 65 m_appName = appname;
136 66
137 /* Set journalfile name ... */ 67 /* Set journalfile name ... */
138 m_journalName = getenv("HOME"); 68 m_journalName = getenv("HOME");
@@ -809,12 +739,13 @@ void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
809 buf += "/>\n"; 739 buf += "/>\n";
810 QCString cstr = buf.utf8(); 740 QCString cstr = buf.utf8();
811 f.writeBlock( cstr.data(), cstr.length() ); 741 f.writeBlock( cstr.data(), cstr.length() );
812} 742}
813 743
814void OContactAccessBackend_XML::removeJournal() 744void OContactAccessBackend_XML::removeJournal()
815{ 745{
816 QFile f ( m_journalName ); 746 QFile f ( m_journalName );
817 if ( f.exists() ) 747 if ( f.exists() )
818 f.remove(); 748 f.remove();
819} 749}
820 750
751}