summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend/otodoaccessxml.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp191
1 files changed, 98 insertions, 93 deletions
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index cce6111..3e06d88 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -28,2 +28,21 @@
28*/ 28*/
29
30/* OPIE */
31#include <opie2/opimdateconversion.h>
32#include <opie2/opimstate.h>
33#include <opie2/opimtimezone.h>
34#include <opie2/opimnotifymanager.h>
35#include <opie2/opimrecurrence.h>
36#include <opie2/otodoaccessxml.h>
37#include <opie2/odebug.h>
38
39#include <qpe/global.h>
40#include <qpe/stringutil.h>
41#include <qpe/timeconversion.h>
42
43/* QT */
44#include <qfile.h>
45#include <qvector.h>
46
47/* STD */
29#include <errno.h> 48#include <errno.h>
@@ -38,16 +57,2 @@
38 57
39#include <qfile.h>
40#include <qvector.h>
41
42#include <qpe/global.h>
43#include <qpe/stringutil.h>
44#include <qpe/timeconversion.h>
45
46#include <opie2/opimdateconversion.h>
47#include <opie2/opimstate.h>
48#include <opie2/opimtimezone.h>
49#include <opie2/opimnotifymanager.h>
50#include <opie2/opimrecurrence.h>
51#include <opie2/otodoaccessxml.h>
52
53using namespace Opie; 58using namespace Opie;
@@ -78,3 +83,3 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
78 if (!needle || !haystack || !hLen || !nLen) 83 if (!needle || !haystack || !hLen || !nLen)
79 return 0; 84 return 0;
80 85
@@ -83,12 +88,12 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
83 if ((needleChar = *needle++) != 0) { 88 if ((needleChar = *needle++) != 0) {
84 nLen--; //(to make up for needle++) 89 nLen--; //(to make up for needle++)
85 do { 90 do {
86 do { 91 do {
87 if ((haystackChar = *hsearch++) == 0) 92 if ((haystackChar = *hsearch++) == 0)
88 return (0); 93 return (0);
89 if (hsearch >= haystack + hLen) 94 if (hsearch >= haystack + hLen)
90 return (0); 95 return (0);
91 } while (haystackChar != needleChar); 96 } while (haystackChar != needleChar);
92 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); 97 } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
93 hsearch--; 98 hsearch--;
94 } 99 }
@@ -179,3 +184,3 @@ bool OPimTodoAccessXML::load() {
179 i+= strLen; 184 i+= strLen;
180 qWarning("Found a start at %d %d", i, (point-dt) ); 185 owarn << "Found a start at " << i << " " << (point-dt) << "" << oendl;
181 186
@@ -186,41 +191,41 @@ bool OPimTodoAccessXML::load() {
186 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 191 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
187 ++i; 192 ++i;
188 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) 193 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
189 break; 194 break;
190 195
191 // we have another attribute, read it. 196 // we have another attribute, read it.
192 int j = i; 197 int j = i;
193 while ( j < len && dt[j] != '=' ) 198 while ( j < len && dt[j] != '=' )
194 ++j; 199 ++j;
195 QCString attr( dt+i, j-i+1); 200 QCString attr( dt+i, j-i+1);
196 201
197 i = ++j; // skip = 202 i = ++j; // skip =
198 203
199 // find the start of quotes 204 // find the start of quotes
200 while ( i < len && dt[i] != '"' ) 205 while ( i < len && dt[i] != '"' )
201 ++i; 206 ++i;
202 j = ++i; 207 j = ++i;
203 208
204 bool haveUtf = FALSE; 209 bool haveUtf = FALSE;
205 bool haveEnt = FALSE; 210 bool haveEnt = FALSE;
206 while ( j < len && dt[j] != '"' ) { 211 while ( j < len && dt[j] != '"' ) {
207 if ( ((unsigned char)dt[j]) > 0x7f ) 212 if ( ((unsigned char)dt[j]) > 0x7f )
208 haveUtf = TRUE; 213 haveUtf = TRUE;
209 if ( dt[j] == '&' ) 214 if ( dt[j] == '&' )
210 haveEnt = TRUE; 215 haveEnt = TRUE;
211 ++j; 216 ++j;
212 } 217 }
213 if ( i == j ) { 218 if ( i == j ) {
214 // empty value 219 // empty value
215 i = j + 1; 220 i = j + 1;
216 continue; 221 continue;
217 } 222 }
218 223
219 QCString value( dt+i, j-i+1 ); 224 QCString value( dt+i, j-i+1 );
220 i = j + 1; 225 i = j + 1;
221 226
222 QString str = (haveUtf ? QString::fromUtf8( value ) 227 QString str = (haveUtf ? QString::fromUtf8( value )
223 : QString::fromLatin1( value ) ); 228 : QString::fromLatin1( value ) );
224 if ( haveEnt ) 229 if ( haveEnt )
225 str = Qtopia::plainString( str ); 230 str = Qtopia::plainString( str );
226 231
@@ -235,3 +240,3 @@ bool OPimTodoAccessXML::load() {
235 */ 240 */
236 qWarning("End at %d", i ); 241 owarn << "End at " << i << "" << oendl;
237 if (m_events.contains( ev.uid() ) || ev.uid() == 0) { 242 if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
@@ -258,3 +263,3 @@ bool OPimTodoAccessXML::load() {
258 263
259 qWarning("counts %d records loaded!", m_events.count() ); 264 owarn << "counts " << m_events.count() << " records loaded!" << oendl;
260 return true; 265 return true;
@@ -266,5 +271,5 @@ bool OPimTodoAccessXML::reload() {
266bool OPimTodoAccessXML::save() { 271bool OPimTodoAccessXML::save() {
267// qWarning("saving"); 272// owarn << "saving" << oendl;
268 if (!m_opened || !m_changed ) { 273 if (!m_opened || !m_changed ) {
269// qWarning("not saving"); 274// owarn << "not saving" << oendl;
270 return true; 275 return true;
@@ -309,3 +314,3 @@ bool OPimTodoAccessXML::save() {
309 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { 314 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
310// qWarning("error renaming"); 315// owarn << "error renaming" << oendl;
311 QFile::remove( strNewFile ); 316 QFile::remove( strNewFile );
@@ -347,3 +352,3 @@ void OPimTodoAccessXML::clear() {
347bool OPimTodoAccessXML::add( const OPimTodo& todo ) { 352bool OPimTodoAccessXML::add( const OPimTodo& todo ) {
348// qWarning("add"); 353// owarn << "add" << oendl;
349 m_changed = true; 354 m_changed = true;
@@ -406,3 +411,3 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
406 const QCString& attr, const QString& val) { 411 const QCString& attr, const QString& val) {
407// qWarning("parse to do from XMLElement" ); 412// owarn << "parse to do from XMLElement" << oendl;
408 413
@@ -412,3 +417,3 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
412 if (!find ) { 417 if (!find ) {
413// qWarning("Unknown option" + it.key() ); 418// owarn << "Unknown option" + it.key() << oendl;
414 ev.setCustomField( attr, val ); 419 ev.setCustomField( attr, val );
@@ -465,4 +470,4 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
465 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty 470 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
466 qWarning("alarm: %s", alarm.join("___").latin1() ); 471 owarn << "alarm: " << alarm.join("___") << "" << oendl;
467 qWarning("alarm[0]: %s %s", alarm[0].latin1(), OPimDateConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); 472 owarn << "alarm[0]: " << alarm[0] << " " << OPimDateConversion::dateTimeFromString( alarm[0] ).toString() << "" << oendl;
468 OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); 473 OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() );
@@ -539,11 +544,11 @@ QString customToXml(const QMap<QString, QString>& customMap )
539{ 544{
540 //qWarning(QString("writing custom %1").arg(customMap.count())); 545 //owarn << QString("writing custom %1").arg(customMap.count()) << oendl;
541 QString buf(" "); 546 QString buf(" ");
542 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); 547 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
543 cit != customMap.end(); ++cit) { 548 cit != customMap.end(); ++cit) {
544 // qWarning(".ITEM."); 549// owarn << ".ITEM." << oendl;
545 buf += cit.key(); 550 buf += cit.key();
546 buf += "=\""; 551 buf += "=\"";
547 buf += Qtopia::escapeString(cit.data()); 552 buf += Qtopia::escapeString(cit.data());
548 buf += "\" "; 553 buf += "\" ";
549 } 554 }
@@ -572,3 +577,3 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
572 } 577 }
573// qWarning( "Uid %d", ev.uid() ); 578// owarn << "Uid " << ev.uid() << "" << oendl;
574 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 579 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
@@ -619,3 +624,3 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
619 // now write the list 624 // now write the list
620 qWarning("als: %s", als.join("____________").latin1() ); 625 owarn << "als: " << als.join("____________") << "" << oendl;
621 str += "Alarms=\""+als.join(";") +"\" "; 626 str += "Alarms=\""+als.join(";") +"\" ";
@@ -840,3 +845,3 @@ QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder,
840/* if ( (*it).isOverdue() && !bOnly ) { 845/* if ( (*it).isOverdue() && !bOnly ) {
841 qWarning("item is overdue but !bOnly"); 846 owarn << "item is overdue but !bOnly" << oendl;
842 continue; 847 continue;
@@ -893,4 +898,4 @@ QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const
893{ 898{
894 QArray<int> m_currentQuery( m_events.count() ); 899 QArray<int> m_currentQuery( m_events.count() );
895 uint arraycounter = 0; 900 uint arraycounter = 0;
896 901
@@ -898,10 +903,10 @@ QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const
898 for (it = m_events.begin(); it != m_events.end(); ++it ) { 903 for (it = m_events.begin(); it != m_events.end(); ++it ) {
899 if ( it.data().match( r ) ) 904 if ( it.data().match( r ) )
900 m_currentQuery[arraycounter++] = it.data().uid(); 905 m_currentQuery[arraycounter++] = it.data().uid();
901 906
902 } 907 }
903 // Shrink to fit.. 908 // Shrink to fit..
904 m_currentQuery.resize(arraycounter); 909 m_currentQuery.resize(arraycounter);
905 910
906 return m_currentQuery; 911 return m_currentQuery;
907} 912}