summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index 929d004..0ebda98 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -1,35 +1,65 @@
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*/
1#include <errno.h> 29#include <errno.h>
2#include <fcntl.h> 30#include <fcntl.h>
3 31
4#include <stdio.h> 32#include <stdio.h>
5#include <stdlib.h> 33#include <stdlib.h>
6 34
7#include <sys/types.h> 35#include <sys/types.h>
8#include <sys/mman.h> 36#include <sys/mman.h>
9#include <sys/stat.h> 37#include <sys/stat.h>
10 38
11#include <unistd.h> 39#include <unistd.h>
12 40
13#include <qasciidict.h> 41#include <qasciidict.h>
14#include <qfile.h> 42#include <qfile.h>
15 43
16#include <qtopia/global.h> 44#include <qtopia/global.h>
17#include <qtopia/stringutil.h> 45#include <qtopia/stringutil.h>
18#include <qtopia/timeconversion.h> 46#include <qtopia/timeconversion.h>
19 47
20#include "opimnotifymanager.h" 48#include <opie2/opimnotifymanager.h>
21#include "orecur.h" 49#include <opie2/orecur.h>
22#include "otimezone.h" 50#include <opie2/otimezone.h>
23#include "odatebookaccessbackend_xml.h" 51#include <opie2/odatebookaccessbackend_xml.h>
52
53using namespace Opie;
24 54
25namespace { 55namespace {
26 // FROM TT again 56 // FROM TT again
27char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) 57char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
28{ 58{
29 char needleChar; 59 char needleChar;
30 char haystackChar; 60 char haystackChar;
31 if (!needle || !haystack || !hLen || !nLen) 61 if (!needle || !haystack || !hLen || !nLen)
32 return 0; 62 return 0;
33 63
34 const char* hsearch = haystack; 64 const char* hsearch = haystack;
35 65
@@ -157,24 +187,25 @@ namespace {
157 save( it.data(), buf ); 187 save( it.data(), buf );
158 buf += " />\n"; 188 buf += " />\n";
159 str = buf.utf8(); 189 str = buf.utf8();
160 190
161 total_written = file.writeBlock(str.data(), str.length() ); 191 total_written = file.writeBlock(str.data(), str.length() );
162 if ( total_written != int(str.length() ) ) 192 if ( total_written != int(str.length() ) )
163 return false; 193 return false;
164 } 194 }
165 return true; 195 return true;
166 } 196 }
167} 197}
168 198
199namespace Opie {
169ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& , 200ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& ,
170 const QString& fileName ) 201 const QString& fileName )
171 : ODateBookAccessBackend() { 202 : ODateBookAccessBackend() {
172 m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName; 203 m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName;
173 m_changed = false; 204 m_changed = false;
174} 205}
175ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() { 206ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() {
176} 207}
177bool ODateBookAccessBackend_XML::load() { 208bool ODateBookAccessBackend_XML::load() {
178 return loadFile(); 209 return loadFile();
179} 210}
180bool ODateBookAccessBackend_XML::reload() { 211bool ODateBookAccessBackend_XML::reload() {
@@ -601,12 +632,14 @@ QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
601 for ( it = m_raw.begin(); it != m_raw.end(); ++it ) 632 for ( it = m_raw.begin(); it != m_raw.end(); ++it )
602 if ( it.data().match( r ) ) 633 if ( it.data().match( r ) )
603 m_currentQuery[arraycounter++] = it.data().uid(); 634 m_currentQuery[arraycounter++] = it.data().uid();
604 for ( it = m_rep.begin(); it != m_rep.end(); ++it ) 635 for ( it = m_rep.begin(); it != m_rep.end(); ++it )
605 if ( it.data().match( r ) ) 636 if ( it.data().match( r ) )
606 m_currentQuery[arraycounter++] = it.data().uid(); 637 m_currentQuery[arraycounter++] = it.data().uid();
607 638
608 // Shrink to fit.. 639 // Shrink to fit..
609 m_currentQuery.resize(arraycounter); 640 m_currentQuery.resize(arraycounter);
610 641
611 return m_currentQuery; 642 return m_currentQuery;
612} 643}
644
645}