Diffstat (limited to 'libopie2/opiepim/backend/otodoaccessxml.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/otodoaccessxml.cpp | 191 |
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 @@ -27,4 +27,23 @@ Boston, MA 02111-1307, USA. */ + +/* OPIE */ +#include <opie2/opimdateconversion.h> +#include <opie2/opimstate.h> +#include <opie2/opimtimezone.h> +#include <opie2/opimnotifymanager.h> +#include <opie2/opimrecurrence.h> +#include <opie2/otodoaccessxml.h> +#include <opie2/odebug.h> + +#include <qpe/global.h> +#include <qpe/stringutil.h> +#include <qpe/timeconversion.h> + +/* QT */ +#include <qfile.h> +#include <qvector.h> + +/* STD */ #include <errno.h> #include <fcntl.h> @@ -37,18 +56,4 @@ -#include <qfile.h> -#include <qvector.h> - -#include <qpe/global.h> -#include <qpe/stringutil.h> -#include <qpe/timeconversion.h> - -#include <opie2/opimdateconversion.h> -#include <opie2/opimstate.h> -#include <opie2/opimtimezone.h> -#include <opie2/opimnotifymanager.h> -#include <opie2/opimrecurrence.h> -#include <opie2/otodoaccessxml.h> - using namespace Opie; @@ -77,19 +82,19 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) char haystackChar; if (!needle || !haystack || !hLen || !nLen) - return 0; + return 0; const char* hsearch = haystack; if ((needleChar = *needle++) != 0) { - nLen--; //(to make up for needle++) - do { - do { - if ((haystackChar = *hsearch++) == 0) - return (0); - if (hsearch >= haystack + hLen) - return (0); - } while (haystackChar != needleChar); - } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); - hsearch--; + nLen--; //(to make up for needle++) + do { + do { + if ((haystackChar = *hsearch++) == 0) + return (0); + if (hsearch >= haystack + hLen) + return (0); + } while (haystackChar != needleChar); + } while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0); + hsearch--; } return ((char *)hsearch); @@ -178,5 +183,5 @@ bool OPimTodoAccessXML::load() { i = point -dt; i+= strLen; - qWarning("Found a start at %d %d", i, (point-dt) ); + owarn << "Found a start at " << i << " " << (point-dt) << "" << oendl; OPimTodo ev; @@ -185,43 +190,43 @@ bool OPimTodoAccessXML::load() { while ( TRUE ) { while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) - ++i; - if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) - break; - - // we have another attribute, read it. - int j = i; - while ( j < len && dt[j] != '=' ) - ++j; - QCString attr( dt+i, j-i+1); - - i = ++j; // skip = - - // find the start of quotes - while ( i < len && dt[i] != '"' ) - ++i; - j = ++i; - - bool haveUtf = FALSE; - bool haveEnt = FALSE; - while ( j < len && dt[j] != '"' ) { - if ( ((unsigned char)dt[j]) > 0x7f ) - haveUtf = TRUE; - if ( dt[j] == '&' ) - haveEnt = TRUE; - ++j; - } - if ( i == j ) { - // empty value - i = j + 1; - continue; - } - - QCString value( dt+i, j-i+1 ); - i = j + 1; - - QString str = (haveUtf ? QString::fromUtf8( value ) - : QString::fromLatin1( value ) ); - if ( haveEnt ) - str = Qtopia::plainString( str ); + ++i; + if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) + break; + + // we have another attribute, read it. + int j = i; + while ( j < len && dt[j] != '=' ) + ++j; + QCString attr( dt+i, j-i+1); + + i = ++j; // skip = + + // find the start of quotes + while ( i < len && dt[i] != '"' ) + ++i; + j = ++i; + + bool haveUtf = FALSE; + bool haveEnt = FALSE; + while ( j < len && dt[j] != '"' ) { + if ( ((unsigned char)dt[j]) > 0x7f ) + haveUtf = TRUE; + if ( dt[j] == '&' ) + haveEnt = TRUE; + ++j; + } + if ( i == j ) { + // empty value + i = j + 1; + continue; + } + + QCString value( dt+i, j-i+1 ); + i = j + 1; + + QString str = (haveUtf ? QString::fromUtf8( value ) + : QString::fromLatin1( value ) ); + if ( haveEnt ) + str = Qtopia::plainString( str ); /* @@ -234,5 +239,5 @@ bool OPimTodoAccessXML::load() { * now add it */ - qWarning("End at %d", i ); + owarn << "End at " << i << "" << oendl; if (m_events.contains( ev.uid() ) || ev.uid() == 0) { ev.setUid( 1 ); @@ -257,5 +262,5 @@ bool OPimTodoAccessXML::load() { munmap(map_addr, attribut.st_size ); - qWarning("counts %d records loaded!", m_events.count() ); + owarn << "counts " << m_events.count() << " records loaded!" << oendl; return true; } @@ -265,7 +270,7 @@ bool OPimTodoAccessXML::reload() { } bool OPimTodoAccessXML::save() { -// qWarning("saving"); +// owarn << "saving" << oendl; if (!m_opened || !m_changed ) { -// qWarning("not saving"); +// owarn << "not saving" << oendl; return true; } @@ -308,5 +313,5 @@ bool OPimTodoAccessXML::save() { if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { -// qWarning("error renaming"); +// owarn << "error renaming" << oendl; QFile::remove( strNewFile ); } @@ -346,5 +351,5 @@ void OPimTodoAccessXML::clear() { } bool OPimTodoAccessXML::add( const OPimTodo& todo ) { -// qWarning("add"); +// owarn << "add" << oendl; m_changed = true; m_events.insert( todo.uid(), todo ); @@ -405,5 +410,5 @@ QArray<int> OPimTodoAccessXML::overDue() { void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, const QCString& attr, const QString& val) { -// qWarning("parse to do from XMLElement" ); +// owarn << "parse to do from XMLElement" << oendl; int *find=0; @@ -411,5 +416,5 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, find = (*dict)[ attr.data() ]; if (!find ) { -// qWarning("Unknown option" + it.key() ); +// owarn << "Unknown option" + it.key() << oendl; ev.setCustomField( attr, val ); return; @@ -464,6 +469,6 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty - qWarning("alarm: %s", alarm.join("___").latin1() ); - qWarning("alarm[0]: %s %s", alarm[0].latin1(), OPimDateConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); + owarn << "alarm: " << alarm.join("___") << "" << oendl; + owarn << "alarm[0]: " << alarm[0] << " " << OPimDateConversion::dateTimeFromString( alarm[0] ).toString() << "" << oendl; OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); manager.add( al ); @@ -538,13 +543,13 @@ namespace { QString customToXml(const QMap<QString, QString>& customMap ) { - //qWarning(QString("writing custom %1").arg(customMap.count())); + //owarn << QString("writing custom %1").arg(customMap.count()) << oendl; QString buf(" "); for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); - cit != customMap.end(); ++cit) { -// qWarning(".ITEM."); - buf += cit.key(); - buf += "=\""; - buf += Qtopia::escapeString(cit.data()); - buf += "\" "; + cit != customMap.end(); ++cit) { +// owarn << ".ITEM." << oendl; + buf += cit.key(); + buf += "=\""; + buf += Qtopia::escapeString(cit.data()); + buf += "\" "; } return buf; @@ -571,5 +576,5 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; } -// qWarning( "Uid %d", ev.uid() ); +// owarn << "Uid " << ev.uid() << "" << oendl; str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; @@ -618,5 +623,5 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { } // now write the list - qWarning("als: %s", als.join("____________").latin1() ); + owarn << "als: " << als.join("____________") << "" << oendl; str += "Alarms=\""+als.join(";") +"\" "; } @@ -839,5 +844,5 @@ QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder, /* isOverdue but we should not show overdue - why?*/ /* if ( (*it).isOverdue() && !bOnly ) { - qWarning("item is overdue but !bOnly"); + owarn << "item is overdue but !bOnly" << oendl; continue; } @@ -892,17 +897,17 @@ QBitArray OPimTodoAccessXML::sup() { QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const { - QArray<int> m_currentQuery( m_events.count() ); - uint arraycounter = 0; + QArray<int> m_currentQuery( m_events.count() ); + uint arraycounter = 0; QMap<int, OPimTodo>::ConstIterator it; for (it = m_events.begin(); it != m_events.end(); ++it ) { - if ( it.data().match( r ) ) - m_currentQuery[arraycounter++] = it.data().uid(); + if ( it.data().match( r ) ) + m_currentQuery[arraycounter++] = it.data().uid(); - } - // Shrink to fit.. - m_currentQuery.resize(arraycounter); + } + // Shrink to fit.. + m_currentQuery.resize(arraycounter); - return m_currentQuery; + return m_currentQuery; } |