summaryrefslogtreecommitdiff
authorar <ar>2004-06-01 21:38:07 (UTC)
committer ar <ar>2004-06-01 21:38:07 (UTC)
commitbaed1d5ab8589aef14440009bc4e7380bcc5a741 (patch) (side-by-side diff)
treec636e892c5eec0df2b36d16cb601a7da41a2ef0f
parent4438393d8eef624565e840b798429071829adea8 (diff)
downloadopie-baed1d5ab8589aef14440009bc4e7380bcc5a741.zip
opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.tar.gz
opie-baed1d5ab8589aef14440009bc4e7380bcc5a741.tar.bz2
- convert to odebug framework
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiedb/osqlbackendmanager.cpp12
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp78
-rw-r--r--libopie2/opiemm/osoundsystem.cpp6
-rw-r--r--libopie2/opienet/onetwork.cpp11
-rw-r--r--libopie2/opienet/ostation.cpp8
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp1326
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp894
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp1182
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp579
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp170
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp444
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp20
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp191
-rw-r--r--libopie2/opiepim/core/opimcontact.cpp20
-rw-r--r--libopie2/opiepim/core/opimcontactfields.cpp22
-rw-r--r--libopie2/opiepim/core/opimdateconversion.cpp12
-rw-r--r--libopie2/opiepim/core/opimevent.cpp24
-rw-r--r--libopie2/opiepim/core/opimnotifymanager.cpp7
-rw-r--r--libopie2/opiepim/core/opimrecord.cpp2
-rw-r--r--libopie2/opiepim/core/opimtimezone.cpp5
-rw-r--r--libopie2/opiepim/core/opimtodo.cpp22
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp2
-rw-r--r--libopie2/opiepim/ui/opimmainwindow.cpp19
23 files changed, 2560 insertions, 2496 deletions
diff --git a/libopie2/opiedb/osqlbackendmanager.cpp b/libopie2/opiedb/osqlbackendmanager.cpp
index fc18e07..bbfbf3d 100644
--- a/libopie2/opiedb/osqlbackendmanager.cpp
+++ b/libopie2/opiedb/osqlbackendmanager.cpp
@@ -1 +1,8 @@
+
+#include "osqlbackendmanager.h"
+
+/* OPIE */
+#include <opie2/odebug.h>
+
+/* QT */
#include <qdir.h>
@@ -3,3 +10,2 @@
-#include "osqlbackendmanager.h"
@@ -40,3 +46,3 @@ namespace {
line = (*it).stripWhiteSpace();
- qWarning("Anonymous::Config:" + line );
+ owarn << "Anonymous::Config:" + line << oendl;
QStringList test = QStringList::split(' ', line );
@@ -94,3 +100,3 @@ OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) {
OSQLBackEnd end;
- qWarning("fileName: " + file );
+ owarn << "fileName: " + file << oendl;
Config cfg( file );
diff --git a/libopie2/opiedb/osqlitedriver.cpp b/libopie2/opiedb/osqlitedriver.cpp
index 588fc8f..69eddfe 100644
--- a/libopie2/opiedb/osqlitedriver.cpp
+++ b/libopie2/opiedb/osqlitedriver.cpp
@@ -42,4 +42,4 @@
-namespace Opie {
-namespace DB {
+namespace Opie {
+namespace DB {
namespace Internal {
@@ -89,20 +89,20 @@ void OSQLiteDriver::setOptions( const QStringList& ) {
int sqliteRlikeCompare(const char *zPattern, const char *zString, sqregex *reg){
- int res;
- if (reg->regex_raw == NULL || (strcmp (zPattern, reg->regex_raw) != 0)){
- if (reg->regex_raw != NULL) {
- free(reg->regex_raw);
- regfree(&reg->regex_c);
- }
- reg->regex_raw = (char *)malloc(strlen(zPattern)+1);
- strncpy(reg->regex_raw, zPattern, strlen(zPattern)+1);
- res = regcomp(&reg->regex_c, zPattern, REG_EXTENDED);
- if ( res != 0 ) {
- printf("Regcomp failed with code %u on string %s\n",res,zPattern);
- free(reg->regex_raw);
- reg->regex_raw=NULL;
- return 0;
- }
- }
- res = (regexec(&reg->regex_c, zString, 0, NULL, 0)==0);
- return res;
+ int res;
+ if (reg->regex_raw == NULL || (strcmp (zPattern, reg->regex_raw) != 0)){
+ if (reg->regex_raw != NULL) {
+ free(reg->regex_raw);
+ regfree(&reg->regex_c);
+ }
+ reg->regex_raw = (char *)malloc(strlen(zPattern)+1);
+ strncpy(reg->regex_raw, zPattern, strlen(zPattern)+1);
+ res = regcomp(&reg->regex_c, zPattern, REG_EXTENDED);
+ if ( res != 0 ) {
+ printf("Regcomp failed with code %u on string %s\n",res,zPattern);
+ free(reg->regex_raw);
+ reg->regex_raw=NULL;
+ return 0;
+ }
+ }
+ res = (regexec(&reg->regex_c, zString, 0, NULL, 0)==0);
+ return res;
}
@@ -110,9 +110,9 @@ int sqliteRlikeCompare(const char *zPattern, const char *zString, sqregex *reg){
void rlikeFunc(sqlite_func *context, int arg, const char **argv){
- if( argv[0]==0 || argv[1]==0 ){
- printf("One of arguments Null!!\n");
- return;
- }
- sqlite_set_result_int(context,
- sqliteRlikeCompare((const char*)argv[0],
- (const char*)argv[1], (sqregex *)sqlite_user_data(context) ));
+ if( argv[0]==0 || argv[1]==0 ){
+ printf("One of arguments Null!!\n");
+ return;
+ }
+ sqlite_set_result_int(context,
+ sqliteRlikeCompare((const char*)argv[0],
+ (const char*)argv[1], (sqregex *)sqlite_user_data(context) ));
}
@@ -125,4 +125,4 @@ bool OSQLiteDriver::open() {
char *error;
-
- qDebug("OSQLiteDriver::open: about to open");
+
+ odebug << "OSQLiteDriver::open: about to open" << oendl;
m_sqlite = sqlite_open(m_url.local8Bit(),
@@ -134,3 +134,3 @@ bool OSQLiteDriver::open() {
// FIXME set the last error
- qWarning("OSQLiteDriver::open: %s", error );
+ owarn << "OSQLiteDriver::open: " << error << "" << oendl;
free( error );
@@ -139,5 +139,5 @@ bool OSQLiteDriver::open() {
if (sqlite_create_function(m_sqlite,"rlike",2,rlikeFunc,&sqreg) != 0)
- odebug << "Unable to create user defined function!" << oendl;
+ odebug << "Unable to create user defined function!" << oendl;
if (sqlite_function_type(m_sqlite,"rlike",SQLITE_NUMERIC) != 0)
- odebug << "Unable to set rlike function result type!" << oendl;
+ odebug << "Unable to set rlike function result type!" << oendl;
sqreg.regex_raw = NULL;
@@ -154,8 +154,8 @@ bool OSQLiteDriver::close() {
sqlite_close( m_sqlite ), m_sqlite=0l;
- if (sqreg.regex_raw != NULL){
- odebug << "Freeing regex on close" << oendl;
- free(sqreg.regex_raw);
- sqreg.regex_raw=NULL;
- regfree(&sqreg.regex_c);
- }
+ if (sqreg.regex_raw != NULL){
+ odebug << "Freeing regex on close" << oendl;
+ free(sqreg.regex_raw);
+ sqreg.regex_raw=NULL;
+ regfree(&sqreg.regex_c);
+ }
return true;
@@ -176,3 +176,3 @@ OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) {
- qWarning("OSQLiteDriver::query: Error while executing %s",err);
+ owarn << "OSQLiteDriver::query: Error while executing " << err << "" << oendl;
free(err );
diff --git a/libopie2/opiemm/osoundsystem.cpp b/libopie2/opiemm/osoundsystem.cpp
index c00585d..2b17230 100644
--- a/libopie2/opiemm/osoundsystem.cpp
+++ b/libopie2/opiemm/osoundsystem.cpp
@@ -84,3 +84,3 @@ void OSoundSystem::synchronize()
str.truncate( str.find( ':' ) );
- qDebug( "OSoundSystem: found interface '%s'", (const char*) str );
+ odebug << "OSoundSystem: found interface '" << str << "'" << oendl;
OAudioInterface* iface;
@@ -239,4 +239,4 @@ void OMixerInterface::init()
{
- qDebug( "Channel %s available (bit %d)", (const char*) it.key(), it.data() );
- qDebug( " +--- Volume: %02d | %02d", volume( it.key() ) & 0xff, volume( it.key() ) >> 8 );
+ odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl;
+ odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl;
}
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp
index e141097..67718ba 100644
--- a/libopie2/opienet/onetwork.cpp
+++ b/libopie2/opienet/onetwork.cpp
@@ -607,6 +607,9 @@ void OWirelessNetworkInterface::dumpInformation() const
- qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s",
- _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 );
- qDebug( " - driver for '%s' (V%d) has been compiled against WE V%d",
- name(), _range.we_version_source, _range.we_version_compiled );
+ odebug << " - driver's idea of maximum throughput is " << _range.throughput
+ << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 )
+ << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 )
+ << " Mb/s" << oendl;
+
+ odebug << " - driver for '" << name() << "' (V" << _range.we_version_source
+ << ") has been compiled against WE V" << _range.we_version_compiled << oendl;
diff --git a/libopie2/opienet/ostation.cpp b/libopie2/opienet/ostation.cpp
index ce0995b..b5ac325 100644
--- a/libopie2/opienet/ostation.cpp
+++ b/libopie2/opienet/ostation.cpp
@@ -64,6 +64,6 @@ void OStation::dump()
odebug << "------- OStation::dump() ------------" << oendl;
- qDebug( "type: %s", (const char*) type );
- qDebug( "mac: %s", (const char*) macAddress.toString() );
- qDebug( "ap: %s", (const char*) apAddress.toString() );
- qDebug( "ip: %s", (const char*) ipAddress.toString() );
+ odebug << "type: " << type << "" << oendl;
+ odebug << "mac: " << macAddress.toString() << "" << oendl;
+ odebug << "ap: " << apAddress.toString() << "" << oendl;
+ odebug << "ip: " << ipAddress.toString() << "" << oendl;
}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index 14207be..dda23cc 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -34,9 +34,3 @@
-#include <qarray.h>
-#include <qdatetime.h>
-#include <qstringlist.h>
-
-#include <qpe/global.h>
-#include <qpe/recordfields.h>
-
+/* OPIE */
#include <opie2/opimcontact.h>
@@ -48,2 +42,12 @@
#include <opie2/osqlquery.h>
+#include <opie2/odebug.h>
+
+#include <qpe/global.h>
+#include <qpe/recordfields.h>
+
+/* QT */
+#include <qarray.h>
+#include <qdatetime.h>
+#include <qstringlist.h>
+
@@ -61,281 +65,281 @@ using namespace Opie::DB;
namespace {
- /**
- * CreateQuery for the Todolist Table
- */
- class CreateQuery : public OSQLQuery {
- public:
- CreateQuery();
- ~CreateQuery();
- QString query()const;
- };
-
- /**
- * Clears (delete) a Table
- */
- class ClearQuery : public OSQLQuery {
- public:
- ClearQuery();
- ~ClearQuery();
- QString query()const;
-
- };
-
-
- /**
- * LoadQuery
- * this one queries for all uids
- */
- class LoadQuery : public OSQLQuery {
- public:
- LoadQuery();
- ~LoadQuery();
- QString query()const;
- };
-
- /**
- * inserts/adds a OPimContact to the table
- */
- class InsertQuery : public OSQLQuery {
- public:
- InsertQuery(const OPimContact& );
- ~InsertQuery();
- QString query()const;
- private:
- OPimContact m_contact;
- };
-
-
- /**
- * removes one from the table
- */
- class RemoveQuery : public OSQLQuery {
- public:
- RemoveQuery(int uid );
- ~RemoveQuery();
- QString query()const;
- private:
- int m_uid;
- };
-
- /**
- * a find query for noncustom elements
- */
- class FindQuery : public OSQLQuery {
- public:
- FindQuery(int uid);
- FindQuery(const QArray<int>& );
- ~FindQuery();
- QString query()const;
- private:
- QString single()const;
- QString multi()const;
- QArray<int> m_uids;
- int m_uid;
- };
-
- /**
- * a find query for custom elements
- */
- class FindCustomQuery : public OSQLQuery {
- public:
- FindCustomQuery(int uid);
- FindCustomQuery(const QArray<int>& );
- ~FindCustomQuery();
- QString query()const;
- private:
- QString single()const;
- QString multi()const;
- QArray<int> m_uids;
- int m_uid;
- };
-
-
-
- // We using two tables to store the information:
- // 1. addressbook : It contains General information about the contact (non custom)
- // 2. custom_data : Not official supported entries
- // All tables are connected by the uid of the contact.
- // Maybe I should add a table for meta-information ?
- CreateQuery::CreateQuery() : OSQLQuery() {}
- CreateQuery::~CreateQuery() {}
- QString CreateQuery::query()const {
- QString qu;
-
- qu += "create table addressbook( uid PRIMARY KEY ";
-
- QStringList fieldList = OPimContactFields::untrfields( false );
- for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
- qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it );
- }
- qu += " );";
-
- qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
-
- return qu;
- }
-
- ClearQuery::ClearQuery()
- : OSQLQuery() {}
- ClearQuery::~ClearQuery() {}
- QString ClearQuery::query()const {
- QString qu = "drop table addressbook;";
- qu += "drop table custom_data;";
-// qu += "drop table dates;";
- return qu;
- }
-
-
- LoadQuery::LoadQuery() : OSQLQuery() {}
- LoadQuery::~LoadQuery() {}
- QString LoadQuery::query()const {
- QString qu;
- qu += "select uid from addressbook";
-
- return qu;
- }
-
-
- InsertQuery::InsertQuery( const OPimContact& contact )
- : OSQLQuery(), m_contact( contact ) {
- }
-
- InsertQuery::~InsertQuery() {
- }
-
- /*
- * converts from a OPimContact to a query
- */
- QString InsertQuery::query()const{
-
- QString qu;
- qu += "insert into addressbook VALUES( " +
- QString::number( m_contact.uid() );
-
- // Get all information out of the contact-class
- // Remember: The category is stored in contactMap, too !
- QMap<int, QString> contactMap = m_contact.toMap();
-
- QStringList fieldList = OPimContactFields::untrfields( false );
- QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
- for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
- // Convert Column-String to Id and get value for this id..
- // Hmmm.. Maybe not very cute solution..
- int id = translate[*it];
- switch ( id ){
- case Qtopia::Birthday:
- case Qtopia::Anniversary:{
- QDate day;
- if ( id == Qtopia::Birthday ){
- day = m_contact.birthday();
- } else {
- day = m_contact.anniversary();
- }
- // These entries should stored in a special format
- // year-month-day
- if ( day.isValid() ){
- qu += QString(",\"%1-%2-%3\"")
- .arg( QString::number( day.year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( day.month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( day.day() ).rightJustify( 2, '0' ) );
- } else {
- qu += ",\"\"";
- }
- }
- break;
- default:
- qu += QString( ",\"%1\"" ).arg( contactMap[id] );
- }
- }
- qu += " );";
-
-
- // Now add custom data..
- int id = 0;
- id = 0;
- QMap<QString, QString> customMap = m_contact.toExtraMap();
- for( QMap<QString, QString>::Iterator it = customMap.begin();
- it != customMap.end(); ++it ){
- qu += "insert into custom_data VALUES("
- + QString::number( m_contact.uid() )
- + ","
- + QString::number( id++ )
- + ",'"
- + it.key()
- + "',"
- + "0" // Priority for future enhancements
- + ",'"
- + it.data()
- + "');";
- }
- // qu += "commit;";
- qDebug("add %s", qu.latin1() );
- return qu;
- }
-
-
- RemoveQuery::RemoveQuery(int uid )
- : OSQLQuery(), m_uid( uid ) {}
- RemoveQuery::~RemoveQuery() {}
- QString RemoveQuery::query()const {
- QString qu = "DELETE from addressbook where uid = "
- + QString::number(m_uid) + ";";
- qu += "DELETE from custom_data where uid = "
- + QString::number(m_uid) + ";";
- return qu;
- }
-
-
-
-
- FindQuery::FindQuery(int uid)
- : OSQLQuery(), m_uid( uid ) {
- }
- FindQuery::FindQuery(const QArray<int>& ints)
- : OSQLQuery(), m_uids( ints ){
- }
- FindQuery::~FindQuery() {
- }
- QString FindQuery::query()const{
-// if ( m_uids.count() == 0 )
- return single();
- }
- /*
- else
- return multi();
- }
+ /**
+ * CreateQuery for the Todolist Table
+ */
+ class CreateQuery : public OSQLQuery {
+ public:
+ CreateQuery();
+ ~CreateQuery();
+ QString query()const;
+ };
+
+ /**
+ * Clears (delete) a Table
+ */
+ class ClearQuery : public OSQLQuery {
+ public:
+ ClearQuery();
+ ~ClearQuery();
+ QString query()const;
+
+ };
+
+
+ /**
+ * LoadQuery
+ * this one queries for all uids
+ */
+ class LoadQuery : public OSQLQuery {
+ public:
+ LoadQuery();
+ ~LoadQuery();
+ QString query()const;
+ };
+
+ /**
+ * inserts/adds a OPimContact to the table
+ */
+ class InsertQuery : public OSQLQuery {
+ public:
+ InsertQuery(const OPimContact& );
+ ~InsertQuery();
+ QString query()const;
+ private:
+ OPimContact m_contact;
+ };
+
+
+ /**
+ * removes one from the table
+ */
+ class RemoveQuery : public OSQLQuery {
+ public:
+ RemoveQuery(int uid );
+ ~RemoveQuery();
+ QString query()const;
+ private:
+ int m_uid;
+ };
+
+ /**
+ * a find query for noncustom elements
+ */
+ class FindQuery : public OSQLQuery {
+ public:
+ FindQuery(int uid);
+ FindQuery(const QArray<int>& );
+ ~FindQuery();
+ QString query()const;
+ private:
+ QString single()const;
+ QString multi()const;
+ QArray<int> m_uids;
+ int m_uid;
+ };
+
+ /**
+ * a find query for custom elements
+ */
+ class FindCustomQuery : public OSQLQuery {
+ public:
+ FindCustomQuery(int uid);
+ FindCustomQuery(const QArray<int>& );
+ ~FindCustomQuery();
+ QString query()const;
+ private:
+ QString single()const;
+ QString multi()const;
+ QArray<int> m_uids;
+ int m_uid;
+ };
+
+
+
+ // We using two tables to store the information:
+ // 1. addressbook : It contains General information about the contact (non custom)
+ // 2. custom_data : Not official supported entries
+ // All tables are connected by the uid of the contact.
+ // Maybe I should add a table for meta-information ?
+ CreateQuery::CreateQuery() : OSQLQuery() {}
+ CreateQuery::~CreateQuery() {}
+ QString CreateQuery::query()const {
+ QString qu;
+
+ qu += "create table addressbook( uid PRIMARY KEY ";
+
+ QStringList fieldList = OPimContactFields::untrfields( false );
+ for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
+ qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it );
+ }
+ qu += " );";
+
+ qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
+
+ return qu;
+ }
+
+ ClearQuery::ClearQuery()
+ : OSQLQuery() {}
+ ClearQuery::~ClearQuery() {}
+ QString ClearQuery::query()const {
+ QString qu = "drop table addressbook;";
+ qu += "drop table custom_data;";
+// qu += "drop table dates;";
+ return qu;
+ }
+
+
+ LoadQuery::LoadQuery() : OSQLQuery() {}
+ LoadQuery::~LoadQuery() {}
+ QString LoadQuery::query()const {
+ QString qu;
+ qu += "select uid from addressbook";
+
+ return qu;
+ }
+
+
+ InsertQuery::InsertQuery( const OPimContact& contact )
+ : OSQLQuery(), m_contact( contact ) {
+ }
+
+ InsertQuery::~InsertQuery() {
+ }
+
+ /*
+ * converts from a OPimContact to a query
+ */
+ QString InsertQuery::query()const{
+
+ QString qu;
+ qu += "insert into addressbook VALUES( " +
+ QString::number( m_contact.uid() );
+
+ // Get all information out of the contact-class
+ // Remember: The category is stored in contactMap, too !
+ QMap<int, QString> contactMap = m_contact.toMap();
+
+ QStringList fieldList = OPimContactFields::untrfields( false );
+ QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
+ for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
+ // Convert Column-String to Id and get value for this id..
+ // Hmmm.. Maybe not very cute solution..
+ int id = translate[*it];
+ switch ( id ){
+ case Qtopia::Birthday:
+ case Qtopia::Anniversary:{
+ QDate day;
+ if ( id == Qtopia::Birthday ){
+ day = m_contact.birthday();
+ } else {
+ day = m_contact.anniversary();
+ }
+ // These entries should stored in a special format
+ // year-month-day
+ if ( day.isValid() ){
+ qu += QString(",\"%1-%2-%3\"")
+ .arg( QString::number( day.year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( day.month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( day.day() ).rightJustify( 2, '0' ) );
+ } else {
+ qu += ",\"\"";
+ }
+ }
+ break;
+ default:
+ qu += QString( ",\"%1\"" ).arg( contactMap[id] );
+ }
+ }
+ qu += " );";
+
+
+ // Now add custom data..
+ int id = 0;
+ id = 0;
+ QMap<QString, QString> customMap = m_contact.toExtraMap();
+ for( QMap<QString, QString>::Iterator it = customMap.begin();
+ it != customMap.end(); ++it ){
+ qu += "insert into custom_data VALUES("
+ + QString::number( m_contact.uid() )
+ + ","
+ + QString::number( id++ )
+ + ",'"
+ + it.key()
+ + "',"
+ + "0" // Priority for future enhancements
+ + ",'"
+ + it.data()
+ + "');";
+ }
+ // qu += "commit;";
+ odebug << "add " << qu << "" << oendl;
+ return qu;
+ }
+
+
+ RemoveQuery::RemoveQuery(int uid )
+ : OSQLQuery(), m_uid( uid ) {}
+ RemoveQuery::~RemoveQuery() {}
+ QString RemoveQuery::query()const {
+ QString qu = "DELETE from addressbook where uid = "
+ + QString::number(m_uid) + ";";
+ qu += "DELETE from custom_data where uid = "
+ + QString::number(m_uid) + ";";
+ return qu;
+ }
+
+
+
+
+ FindQuery::FindQuery(int uid)
+ : OSQLQuery(), m_uid( uid ) {
+ }
+ FindQuery::FindQuery(const QArray<int>& ints)
+ : OSQLQuery(), m_uids( ints ){
+ }
+ FindQuery::~FindQuery() {
+ }
+ QString FindQuery::query()const{
+// if ( m_uids.count() == 0 )
+ return single();
+ }
+ /*
+ else
+ return multi();
+ }
QString FindQuery::multi()const {
- QString qu = "select uid, type, value from addressbook where";
- for (uint i = 0; i < m_uids.count(); i++ ) {
- qu += " UID = " + QString::number( m_uids[i] ) + " OR";
- }
- qu.remove( qu.length()-2, 2 ); // Hmmmm..
- return qu;
- }
- */
- QString FindQuery::single()const{
- QString qu = "select *";
- qu += " from addressbook where uid = " + QString::number(m_uid);
-
- // qWarning("find query: %s", qu.latin1() );
- return qu;
- }
-
-
- FindCustomQuery::FindCustomQuery(int uid)
- : OSQLQuery(), m_uid( uid ) {
- }
- FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
- : OSQLQuery(), m_uids( ints ){
- }
- FindCustomQuery::~FindCustomQuery() {
- }
- QString FindCustomQuery::query()const{
-// if ( m_uids.count() == 0 )
- return single();
- }
- QString FindCustomQuery::single()const{
- QString qu = "select uid, type, value from custom_data where uid = ";
- qu += QString::number(m_uid);
- return qu;
- }
+ QString qu = "select uid, type, value from addressbook where";
+ for (uint i = 0; i < m_uids.count(); i++ ) {
+ qu += " UID = " + QString::number( m_uids[i] ) + " OR";
+ }
+ qu.remove( qu.length()-2, 2 ); // Hmmmm..
+ return qu;
+ }
+ */
+ QString FindQuery::single()const{
+ QString qu = "select *";
+ qu += " from addressbook where uid = " + QString::number(m_uid);
+
+ // owarn << "find query: " << qu << "" << oendl;
+ return qu;
+ }
+
+
+ FindCustomQuery::FindCustomQuery(int uid)
+ : OSQLQuery(), m_uid( uid ) {
+ }
+ FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
+ : OSQLQuery(), m_uids( ints ){
+ }
+ FindCustomQuery::~FindCustomQuery() {
+ }
+ QString FindCustomQuery::query()const{
+// if ( m_uids.count() == 0 )
+ return single();
+ }
+ QString FindCustomQuery::single()const{
+ QString qu = "select uid, type, value from custom_data where uid = ";
+ qu += QString::number(m_uid);
+ return qu;
+ }
@@ -348,24 +352,24 @@ namespace Opie {
-OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* appname */,
- const QString& filename ):
- OPimContactAccessBackend(), m_changed(false), m_driver( NULL )
+OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* appname */,
+ const QString& filename ):
+ OPimContactAccessBackend(), m_changed(false), m_driver( NULL )
{
- qDebug("C'tor OPimContactAccessBackend_SQL starts");
- QTime t;
- t.start();
+ odebug << "C'tor OPimContactAccessBackend_SQL starts" << oendl;
+ QTime t;
+ t.start();
- /* Expecting to access the default filename if nothing else is set */
- if ( filename.isEmpty() ){
- m_fileName = Global::applicationFileName( "addressbook","addressbook.db" );
- } else
- m_fileName = filename;
+ /* Expecting to access the default filename if nothing else is set */
+ if ( filename.isEmpty() ){
+ m_fileName = Global::applicationFileName( "addressbook","addressbook.db" );
+ } else
+ m_fileName = filename;
- // Get the standart sql-driver from the OSQLManager..
- OSQLManager man;
- m_driver = man.standard();
- m_driver->setUrl( m_fileName );
+ // Get the standart sql-driver from the OSQLManager..
+ OSQLManager man;
+ m_driver = man.standard();
+ m_driver->setUrl( m_fileName );
- load();
+ load();
- qDebug("C'tor OPimContactAccessBackend_SQL ends: %d ms", t.elapsed() );
+ odebug << "C'tor OPimContactAccessBackend_SQL ends: " << t.elapsed() << " ms" << oendl;
}
@@ -374,4 +378,4 @@ OPimContactAccessBackend_SQL::~OPimContactAccessBackend_SQL ()
{
- if( m_driver )
- delete m_driver;
+ if( m_driver )
+ delete m_driver;
}
@@ -380,14 +384,14 @@ bool OPimContactAccessBackend_SQL::load ()
{
- if (!m_driver->open() )
- return false;
+ if (!m_driver->open() )
+ return false;
- // Don't expect that the database exists.
- // It is save here to create the table, even if it
- // do exist. ( Is that correct for all databases ?? )
- CreateQuery creat;
- OSQLResult res = m_driver->query( &creat );
+ // Don't expect that the database exists.
+ // It is save here to create the table, even if it
+ // do exist. ( Is that correct for all databases ?? )
+ CreateQuery creat;
+ OSQLResult res = m_driver->query( &creat );
- update();
+ update();
- return true;
+ return true;
@@ -397,3 +401,3 @@ bool OPimContactAccessBackend_SQL::reload()
{
- return load();
+ return load();
}
@@ -402,3 +406,3 @@ bool OPimContactAccessBackend_SQL::save()
{
- return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
+ return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
}
@@ -408,6 +412,6 @@ void OPimContactAccessBackend_SQL::clear ()
{
- ClearQuery cle;
- OSQLResult res = m_driver->query( &cle );
+ ClearQuery cle;
+ OSQLResult res = m_driver->query( &cle );
- reload();
+ reload();
}
@@ -416,3 +420,3 @@ bool OPimContactAccessBackend_SQL::wasChangedExternally()
{
- return false;
+ return false;
}
@@ -422,8 +426,8 @@ QArray<int> OPimContactAccessBackend_SQL::allRecords() const
- // FIXME: Think about cute handling of changed tables..
- // Thus, we don't have to call update here...
- if ( m_changed )
- ((OPimContactAccessBackend_SQL*)this)->update();
-
- return m_uids;
+ // FIXME: Think about cute handling of changed tables..
+ // Thus, we don't have to call update here...
+ if ( m_changed )
+ ((OPimContactAccessBackend_SQL*)this)->update();
+
+ return m_uids;
}
@@ -432,14 +436,14 @@ bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact )
{
- qDebug("add in contact SQL-Backend");
- InsertQuery ins( newcontact );
- OSQLResult res = m_driver->query( &ins );
-
- if ( res.state() == OSQLResult::Failure )
- return false;
-
- int c = m_uids.count();
- m_uids.resize( c+1 );
- m_uids[c] = newcontact.uid();
-
- return true;
+ odebug << "add in contact SQL-Backend" << oendl;
+ InsertQuery ins( newcontact );
+ OSQLResult res = m_driver->query( &ins );
+
+ if ( res.state() == OSQLResult::Failure )
+ return false;
+
+ int c = m_uids.count();
+ m_uids.resize( c+1 );
+ m_uids[c] = newcontact.uid();
+
+ return true;
}
@@ -449,11 +453,11 @@ bool OPimContactAccessBackend_SQL::remove ( int uid )
{
- RemoveQuery rem( uid );
- OSQLResult res = m_driver->query(&rem );
+ RemoveQuery rem( uid );
+ OSQLResult res = m_driver->query(&rem );
- if ( res.state() == OSQLResult::Failure )
- return false;
+ if ( res.state() == OSQLResult::Failure )
+ return false;
- m_changed = true;
+ m_changed = true;
- return true;
+ return true;
}
@@ -462,6 +466,6 @@ bool OPimContactAccessBackend_SQL::replace ( const OPimContact &contact )
{
- if ( !remove( contact.uid() ) )
- return false;
-
- return add( contact );
+ if ( !remove( contact.uid() ) )
+ return false;
+
+ return add( contact );
}
@@ -471,11 +475,11 @@ OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const
{
- qDebug("OPimContactAccessBackend_SQL::find()");
- QTime t;
- t.start();
+ odebug << "OPimContactAccessBackend_SQL::find()" << oendl;
+ QTime t;
+ t.start();
- OPimContact retContact( requestNonCustom( uid ) );
- retContact.setExtraMap( requestCustom( uid ) );
+ OPimContact retContact( requestNonCustom( uid ) );
+ retContact.setExtraMap( requestCustom( uid ) );
- qDebug("OPimContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() );
- return retContact;
+ odebug << "OPimContactAccessBackend_SQL::find() needed: " << t.elapsed() << " ms" << oendl;
+ return retContact;
}
@@ -486,116 +490,116 @@ QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &qu
{
- QString qu = "SELECT uid FROM addressbook WHERE";
- QString searchQuery ="";
-
- QDate startDate;
-
- if ( qd.isValid() )
- startDate = qd.date();
- else
- startDate = QDate::currentDate();
-
-
- QMap<int, QString> queryFields = query.toMap();
- QStringList fieldList = OPimContactFields::untrfields( false );
- QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
-
- // Convert every filled field to a SQL-Query
-// bool isAnyFieldSelected = false;
- for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
-
- int id = translate[*it];
- QString queryStr = queryFields[id];
- QDate* endDate = 0l;
-
- if ( !queryStr.isEmpty() ){
- // If something is alredy stored in the query, add an "AND"
- // to the end of the string to prepare for the next ..
- if ( !searchQuery.isEmpty() )
- searchQuery += " AND";
-
-// isAnyFieldSelected = true;
- switch( id ){
- case Qtopia::Birthday:
- endDate = new QDate( query.birthday() );
- // Fall through !
- case Qtopia::Anniversary:
- if ( endDate == 0l )
- endDate = new QDate( query.anniversary() );
-
- if ( settings & OPimContactAccess::DateDiff ) {
- searchQuery += QString( " (\"%1\" <= '%2-%3-%4\' AND \"%5\" >= '%6-%7-%8')" )
- .arg( *it )
- .arg( QString::number( endDate->year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( endDate->month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( endDate->day() ).rightJustify( 2, '0' ) )
- .arg( *it )
- .arg( QString::number( startDate.year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( startDate.month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( startDate.day() ).rightJustify( 2, '0' ) ) ;
- }
-
- if ( settings & OPimContactAccess::DateYear ){
- if ( settings & OPimContactAccess::DateDiff )
- searchQuery += " AND";
-
- searchQuery += QString( " (\"%1\" LIKE '%2-%')" )
- .arg( *it )
- .arg( QString::number( endDate->year() ).rightJustify( 4, '0' ) );
- }
-
- if ( settings & OPimContactAccess::DateMonth ){
- if ( ( settings & OPimContactAccess::DateDiff )
- || ( settings & OPimContactAccess::DateYear ) )
- searchQuery += " AND";
-
- searchQuery += QString( " (\"%1\" LIKE '%-%2-%')" )
- .arg( *it )
- .arg( QString::number( endDate->month() ).rightJustify( 2, '0' ) );
- }
-
- if ( settings & OPimContactAccess::DateDay ){
- if ( ( settings & OPimContactAccess::DateDiff )
- || ( settings & OPimContactAccess::DateYear )
- || ( settings & OPimContactAccess::DateMonth ) )
- searchQuery += " AND";
-
- searchQuery += QString( " (\"%1\" LIKE '%-%-%2')" )
- .arg( *it )
- .arg( QString::number( endDate->day() ).rightJustify( 2, '0' ) );
- }
-
- break;
- default:
- // Switching between case sensitive and insensitive...
- // LIKE is not case sensitive, GLOB is case sensitive
- // Do exist a better solution to switch this ?
- if ( settings & OPimContactAccess::IgnoreCase )
- searchQuery += "(\"" + *it + "\"" + " LIKE " + "'"
- + queryStr.replace(QRegExp("\\*"),"%") + "'" + ")";
- else
- searchQuery += "(\"" + *it + "\"" + " GLOB " + "'"
- + queryStr + "'" + ")";
-
- }
- }
- }
- // Skip trailing "AND"
-// if ( isAnyFieldSelected )
-// qu = qu.left( qu.length() - 4 );
-
- qu += searchQuery;
-
- qDebug( "queryByExample query: %s", qu.latin1() );
-
- // Execute query and return the received uid's
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
- if ( res.state() != OSQLResult::Success ){
- QArray<int> empty;
- return empty;
- }
-
- QArray<int> list = extractUids( res );
-
- return list;
+ QString qu = "SELECT uid FROM addressbook WHERE";
+ QString searchQuery ="";
+
+ QDate startDate;
+
+ if ( qd.isValid() )
+ startDate = qd.date();
+ else
+ startDate = QDate::currentDate();
+
+
+ QMap<int, QString> queryFields = query.toMap();
+ QStringList fieldList = OPimContactFields::untrfields( false );
+ QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
+
+ // Convert every filled field to a SQL-Query
+// bool isAnyFieldSelected = false;
+ for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
+
+ int id = translate[*it];
+ QString queryStr = queryFields[id];
+ QDate* endDate = 0l;
+
+ if ( !queryStr.isEmpty() ){
+ // If something is alredy stored in the query, add an "AND"
+ // to the end of the string to prepare for the next ..
+ if ( !searchQuery.isEmpty() )
+ searchQuery += " AND";
+
+// isAnyFieldSelected = true;
+ switch( id ){
+ case Qtopia::Birthday:
+ endDate = new QDate( query.birthday() );
+ // Fall through !
+ case Qtopia::Anniversary:
+ if ( endDate == 0l )
+ endDate = new QDate( query.anniversary() );
+
+ if ( settings & OPimContactAccess::DateDiff ) {
+ searchQuery += QString( " (\"%1\" <= '%2-%3-%4\' AND \"%5\" >= '%6-%7-%8')" )
+ .arg( *it )
+ .arg( QString::number( endDate->year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( endDate->month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( endDate->day() ).rightJustify( 2, '0' ) )
+ .arg( *it )
+ .arg( QString::number( startDate.year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( startDate.month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( startDate.day() ).rightJustify( 2, '0' ) ) ;
+ }
+
+ if ( settings & OPimContactAccess::DateYear ){
+ if ( settings & OPimContactAccess::DateDiff )
+ searchQuery += " AND";
+
+ searchQuery += QString( " (\"%1\" LIKE '%2-%')" )
+ .arg( *it )
+ .arg( QString::number( endDate->year() ).rightJustify( 4, '0' ) );
+ }
+
+ if ( settings & OPimContactAccess::DateMonth ){
+ if ( ( settings & OPimContactAccess::DateDiff )
+ || ( settings & OPimContactAccess::DateYear ) )
+ searchQuery += " AND";
+
+ searchQuery += QString( " (\"%1\" LIKE '%-%2-%')" )
+ .arg( *it )
+ .arg( QString::number( endDate->month() ).rightJustify( 2, '0' ) );
+ }
+
+ if ( settings & OPimContactAccess::DateDay ){
+ if ( ( settings & OPimContactAccess::DateDiff )
+ || ( settings & OPimContactAccess::DateYear )
+ || ( settings & OPimContactAccess::DateMonth ) )
+ searchQuery += " AND";
+
+ searchQuery += QString( " (\"%1\" LIKE '%-%-%2')" )
+ .arg( *it )
+ .arg( QString::number( endDate->day() ).rightJustify( 2, '0' ) );
+ }
+
+ break;
+ default:
+ // Switching between case sensitive and insensitive...
+ // LIKE is not case sensitive, GLOB is case sensitive
+ // Do exist a better solution to switch this ?
+ if ( settings & OPimContactAccess::IgnoreCase )
+ searchQuery += "(\"" + *it + "\"" + " LIKE " + "'"
+ + queryStr.replace(QRegExp("\\*"),"%") + "'" + ")";
+ else
+ searchQuery += "(\"" + *it + "\"" + " GLOB " + "'"
+ + queryStr + "'" + ")";
+
+ }
+ }
+ }
+ // Skip trailing "AND"
+// if ( isAnyFieldSelected )
+// qu = qu.left( qu.length() - 4 );
+
+ qu += searchQuery;
+
+ odebug << "queryByExample query: " << qu << "" << oendl;
+
+ // Execute query and return the received uid's
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+ if ( res.state() != OSQLResult::Success ){
+ QArray<int> empty;
+ return empty;
+ }
+
+ QArray<int> list = extractUids( res );
+
+ return list;
}
@@ -605,25 +609,25 @@ QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
#if 0
- QArray<int> nix(0);
- return nix;
+ QArray<int> nix(0);
+ return nix;
#else
- QString qu = "SELECT uid FROM addressbook WHERE (";
- QString searchlist;
+ QString qu = "SELECT uid FROM addressbook WHERE (";
+ QString searchlist;
- QStringList fieldList = OPimContactFields::untrfields( false );
- // QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
- for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
- if ( !searchlist.isEmpty() )
- searchlist += " OR ";
- searchlist += " rlike(\""+ r.pattern() + "\",\"" + *it + "\") ";
- }
-
- qu = qu + searchlist + ")";
+ QStringList fieldList = OPimContactFields::untrfields( false );
+ // QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
+ for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
+ if ( !searchlist.isEmpty() )
+ searchlist += " OR ";
+ searchlist += " rlike(\""+ r.pattern() + "\",\"" + *it + "\") ";
+ }
- qDebug( "query: %s", qu.latin1() );
+ qu = qu + searchlist + ")";
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
+ odebug << "query: " << qu << "" << oendl;
- return extractUids( res );
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+
+ return extractUids( res );
@@ -635,9 +639,9 @@ const uint OPimContactAccessBackend_SQL::querySettings()
{
- return OPimContactAccess::IgnoreCase
- | OPimContactAccess::WildCards
- | OPimContactAccess::DateDiff
- | OPimContactAccess::DateYear
- | OPimContactAccess::DateMonth
- | OPimContactAccess::DateDay
- ;
+ return OPimContactAccess::IgnoreCase
+ | OPimContactAccess::WildCards
+ | OPimContactAccess::DateDiff
+ | OPimContactAccess::DateYear
+ | OPimContactAccess::DateMonth
+ | OPimContactAccess::DateDay
+ ;
}
@@ -646,45 +650,45 @@ bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
{
- /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
- * may be added with any of the other settings. IgnoreCase should never used alone.
- * Wildcards, RegExp, ExactMatch should never used at the same time...
- */
-
- // Step 1: Check whether the given settings are supported by this backend
- if ( ( querySettings & (
- OPimContactAccess::IgnoreCase
- | OPimContactAccess::WildCards
- | OPimContactAccess::DateDiff
- | OPimContactAccess::DateYear
- | OPimContactAccess::DateMonth
- | OPimContactAccess::DateDay
-// | OPimContactAccess::RegExp
-// | OPimContactAccess::ExactMatch
- ) ) != querySettings )
- return false;
-
- // Step 2: Check whether the given combinations are ok..
-
- // IngoreCase alone is invalid
- if ( querySettings == OPimContactAccess::IgnoreCase )
- return false;
-
- // WildCards, RegExp and ExactMatch should never used at the same time
- switch ( querySettings & ~( OPimContactAccess::IgnoreCase
- | OPimContactAccess::DateDiff
- | OPimContactAccess::DateYear
- | OPimContactAccess::DateMonth
- | OPimContactAccess::DateDay
- )
- ){
- case OPimContactAccess::RegExp:
- return ( true );
- case OPimContactAccess::WildCards:
- return ( true );
- case OPimContactAccess::ExactMatch:
- return ( true );
- case 0: // one of the upper removed bits were set..
- return ( true );
- default:
- return ( false );
- }
+ /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
+ * may be added with any of the other settings. IgnoreCase should never used alone.
+ * Wildcards, RegExp, ExactMatch should never used at the same time...
+ */
+
+ // Step 1: Check whether the given settings are supported by this backend
+ if ( ( querySettings & (
+ OPimContactAccess::IgnoreCase
+ | OPimContactAccess::WildCards
+ | OPimContactAccess::DateDiff
+ | OPimContactAccess::DateYear
+ | OPimContactAccess::DateMonth
+ | OPimContactAccess::DateDay
+// | OPimContactAccess::RegExp
+// | OPimContactAccess::ExactMatch
+ ) ) != querySettings )
+ return false;
+
+ // Step 2: Check whether the given combinations are ok..
+
+ // IngoreCase alone is invalid
+ if ( querySettings == OPimContactAccess::IgnoreCase )
+ return false;
+
+ // WildCards, RegExp and ExactMatch should never used at the same time
+ switch ( querySettings & ~( OPimContactAccess::IgnoreCase
+ | OPimContactAccess::DateDiff
+ | OPimContactAccess::DateYear
+ | OPimContactAccess::DateMonth
+ | OPimContactAccess::DateDay
+ )
+ ){
+ case OPimContactAccess::RegExp:
+ return ( true );
+ case OPimContactAccess::WildCards:
+ return ( true );
+ case OPimContactAccess::ExactMatch:
+ return ( true );
+ case 0: // one of the upper removed bits were set..
+ return ( true );
+ default:
+ return ( false );
+ }
@@ -694,24 +698,24 @@ QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int )
{
- QTime t;
- t.start();
+ QTime t;
+ t.start();
- QString query = "SELECT uid FROM addressbook ";
- query += "ORDER BY \"Last Name\" ";
+ QString query = "SELECT uid FROM addressbook ";
+ query += "ORDER BY \"Last Name\" ";
- if ( !asc )
- query += "DESC";
+ if ( !asc )
+ query += "DESC";
- // qDebug("sorted query is: %s", query.latin1() );
+ // odebug << "sorted query is: " << query << "" << oendl;
- OSQLRawQuery raw( query );
- OSQLResult res = m_driver->query( &raw );
- if ( res.state() != OSQLResult::Success ){
- QArray<int> empty;
- return empty;
- }
+ OSQLRawQuery raw( query );
+ OSQLResult res = m_driver->query( &raw );
+ if ( res.state() != OSQLResult::Success ){
+ QArray<int> empty;
+ return empty;
+ }
- QArray<int> list = extractUids( res );
+ QArray<int> list = extractUids( res );
- qDebug("sorted needed %d ms!", t.elapsed() );
- return list;
+ odebug << "sorted needed " << t.elapsed() << " ms!" << oendl;
+ return list;
}
@@ -721,19 +725,19 @@ void OPimContactAccessBackend_SQL::update()
{
- qDebug("Update starts");
- QTime t;
- t.start();
+ odebug << "Update starts" << oendl;
+ QTime t;
+ t.start();
- // Now load the database set and extract the uid's
- // which will be held locally
+ // Now load the database set and extract the uid's
+ // which will be held locally
- LoadQuery lo;
- OSQLResult res = m_driver->query(&lo);
- if ( res.state() != OSQLResult::Success )
- return;
+ LoadQuery lo;
+ OSQLResult res = m_driver->query(&lo);
+ if ( res.state() != OSQLResult::Success )
+ return;
- m_uids = extractUids( res );
+ m_uids = extractUids( res );
- m_changed = false;
+ m_changed = false;
- qDebug("Update ends %d ms", t.elapsed() );
+ odebug << "Update ends " << t.elapsed() << " ms" << oendl;
}
@@ -742,18 +746,18 @@ QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
{
- qDebug("extractUids");
- QTime t;
- t.start();
- OSQLResultItem::ValueList list = res.results();
- OSQLResultItem::ValueList::Iterator it;
- QArray<int> ints(list.count() );
- qDebug(" count = %d", list.count() );
-
- int i = 0;
- for (it = list.begin(); it != list.end(); ++it ) {
- ints[i] = (*it).data("uid").toInt();
- i++;
- }
- qDebug("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() );
-
- return ints;
+ odebug << "extractUids" << oendl;
+ QTime t;
+ t.start();
+ OSQLResultItem::ValueList list = res.results();
+ OSQLResultItem::ValueList::Iterator it;
+ QArray<int> ints(list.count() );
+ odebug << " count = " << list.count() << "" << oendl;
+
+ int i = 0;
+ for (it = list.begin(); it != list.end(); ++it ) {
+ ints[i] = (*it).data("uid").toInt();
+ i++;
+ }
+ odebug << "extractUids ready: count2 = " << i << " needs " << t.elapsed() << " ms" << oendl;
+
+ return ints;
@@ -763,62 +767,62 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co
{
- QTime t;
- t.start();
-
- QMap<int, QString> nonCustomMap;
-
- int t2needed = 0;
- int t3needed = 0;
- QTime t2;
- t2.start();
- FindQuery query( uid );
- OSQLResult res_noncustom = m_driver->query( &query );
- t2needed = t2.elapsed();
-
- OSQLResultItem resItem = res_noncustom.first();
-
- QTime t3;
- t3.start();
- // Now loop through all columns
- QStringList fieldList = OPimContactFields::untrfields( false );
- QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
- for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
- // Get data for the selected column and store it with the
- // corresponding id into the map..
-
- int id = translate[*it];
- QString value = resItem.data( (*it) );
-
- // qDebug("Reading %s... found: %s", (*it).latin1(), value.latin1() );
-
- switch( id ){
- case Qtopia::Birthday:
- case Qtopia::Anniversary:{
- // Birthday and Anniversary are encoded special ( yyyy-mm-dd )
- QStringList list = QStringList::split( '-', value );
- QStringList::Iterator lit = list.begin();
- int year = (*lit).toInt();
- int month = (*(++lit)).toInt();
- int day = (*(++lit)).toInt();
- if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){
- QDate date( year, month, day );
- nonCustomMap.insert( id, OPimDateConversion::dateToString( date ) );
- }
- }
- break;
- case Qtopia::AddressCategory:
- qDebug("Category is: %s", value.latin1() );
- default:
- nonCustomMap.insert( id, value );
- }
- }
-
- // First insert uid
- nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) );
- t3needed = t3.elapsed();
-
- // qDebug("Adding UID: %s", resItem.data( "uid" ).latin1() );
- qDebug("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms",
- t.elapsed(), t2needed, t3needed );
-
- return nonCustomMap;
+ QTime t;
+ t.start();
+
+ QMap<int, QString> nonCustomMap;
+
+ int t2needed = 0;
+ int t3needed = 0;
+ QTime t2;
+ t2.start();
+ FindQuery query( uid );
+ OSQLResult res_noncustom = m_driver->query( &query );
+ t2needed = t2.elapsed();
+
+ OSQLResultItem resItem = res_noncustom.first();
+
+ QTime t3;
+ t3.start();
+ // Now loop through all columns
+ QStringList fieldList = OPimContactFields::untrfields( false );
+ QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
+ for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
+ // Get data for the selected column and store it with the
+ // corresponding id into the map..
+
+ int id = translate[*it];
+ QString value = resItem.data( (*it) );
+
+ // odebug << "Reading " << (*it) << "... found: " << value << "" << oendl;
+
+ switch( id ){
+ case Qtopia::Birthday:
+ case Qtopia::Anniversary:{
+ // Birthday and Anniversary are encoded special ( yyyy-mm-dd )
+ QStringList list = QStringList::split( '-', value );
+ QStringList::Iterator lit = list.begin();
+ int year = (*lit).toInt();
+ int month = (*(++lit)).toInt();
+ int day = (*(++lit)).toInt();
+ if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){
+ QDate date( year, month, day );
+ nonCustomMap.insert( id, OPimDateConversion::dateToString( date ) );
+ }
+ }
+ break;
+ case Qtopia::AddressCategory:
+ odebug << "Category is: " << value << "" << oendl;
+ default:
+ nonCustomMap.insert( id, value );
+ }
+ }
+
+ // First insert uid
+ nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) );
+ t3needed = t3.elapsed();
+
+ // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl;
+ odebug << "RequestNonCustom needed: insg.:" << t.elapsed() << " ms, query: " << t2needed
+ << " ms, mapping: " << t3needed << " ms" << oendl;
+
+ return nonCustomMap;
}
@@ -827,24 +831,24 @@ QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) c
{
- QTime t;
- t.start();
-
- QMap<QString, QString> customMap;
-
- FindCustomQuery query( uid );
- OSQLResult res_custom = m_driver->query( &query );
-
- if ( res_custom.state() == OSQLResult::Failure ) {
- qWarning("OSQLResult::Failure in find query !!");
- QMap<QString, QString> empty;
- return empty;
- }
-
- OSQLResultItem::ValueList list = res_custom.results();
- OSQLResultItem::ValueList::Iterator it = list.begin();
- for ( ; it != list.end(); ++it ) {
- customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
- }
-
- qDebug("RequestCustom needed: %d ms", t.elapsed() );
- return customMap;
+ QTime t;
+ t.start();
+
+ QMap<QString, QString> customMap;
+
+ FindCustomQuery query( uid );
+ OSQLResult res_custom = m_driver->query( &query );
+
+ if ( res_custom.state() == OSQLResult::Failure ) {
+ owarn << "OSQLResult::Failure in find query !!" << oendl;
+ QMap<QString, QString> empty;
+ return empty;
+ }
+
+ OSQLResultItem::ValueList list = res_custom.results();
+ OSQLResultItem::ValueList::Iterator it = list.begin();
+ for ( ; it != list.end(); ++it ) {
+ customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
+ }
+
+ odebug << "RequestCustom needed: " << t.elapsed() << " ms" << oendl;
+ return customMap;
}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index ffa6a7d..b6ea461 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -37,2 +37,4 @@
#include <opie2/ocontactaccessbackend_vcard.h>
+#include <opie2/odebug.h>
+
#include <qpe/timeconversion.h>
@@ -47,6 +49,6 @@ namespace Opie {
OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ):
- m_dirty( false ),
- m_file( filename )
+ m_dirty( false ),
+ m_file( filename )
{
- load();
+ load();
}
@@ -56,36 +58,36 @@ bool OPimContactAccessBackend_VCard::load ()
{
- m_map.clear();
- m_dirty = false;
-
- VObject* obj = 0l;
-
- if ( QFile::exists(m_file) ){
- obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
- if ( !obj )
- return false;
- }else{
- qWarning("File \"%s\" not found !", m_file.latin1() );
- return false;
- }
-
- while ( obj ) {
- OPimContact con = parseVObject( obj );
- /*
- * if uid is 0 assign a new one
- * this at least happens on
- * Nokia6210
- */
- if ( con.uid() == 0 ){
- con.setUid( 1 );
- qWarning("assigned new uid %d",con.uid() );
- }
-
- m_map.insert( con.uid(), con );
-
- VObject *t = obj;
- obj = nextVObjectInList(obj);
- cleanVObject( t );
- }
-
- return true;
+ m_map.clear();
+ m_dirty = false;
+
+ VObject* obj = 0l;
+
+ if ( QFile::exists(m_file) ){
+ obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
+ if ( !obj )
+ return false;
+ }else{
+ owarn << "File \"" << m_file << "\" not found !" << oendl;
+ return false;
+ }
+
+ while ( obj ) {
+ OPimContact con = parseVObject( obj );
+ /*
+ * if uid is 0 assign a new one
+ * this at least happens on
+ * Nokia6210
+ */
+ if ( con.uid() == 0 ){
+ con.setUid( 1 );
+ owarn << "assigned new uid " << con.uid() << "" << oendl;
+ }
+
+ m_map.insert( con.uid(), con );
+
+ VObject *t = obj;
+ obj = nextVObjectInList(obj);
+ cleanVObject( t );
+ }
+
+ return true;
@@ -94,3 +96,3 @@ bool OPimContactAccessBackend_VCard::reload()
{
- return load();
+ return load();
}
@@ -98,24 +100,24 @@ bool OPimContactAccessBackend_VCard::save()
{
- if (!m_dirty )
- return true;
+ if (!m_dirty )
+ return true;
- QFile file( m_file );
- if (!file.open(IO_WriteOnly ) )
- return false;
+ QFile file( m_file );
+ if (!file.open(IO_WriteOnly ) )
+ return false;
- VObject *obj;
- obj = newVObject( VCCalProp );
- addPropValue( obj, VCVersionProp, "1.0" );
+ VObject *obj;
+ obj = newVObject( VCCalProp );
+ addPropValue( obj, VCVersionProp, "1.0" );
- VObject *vo;
- for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
- vo = createVObject( *it );
- writeVObject( file.fh, vo ); //FIXME: HACK!!!
- cleanVObject( vo );
- }
- cleanStrTbl();
- deleteVObject( obj );
+ VObject *vo;
+ for(QMap<int, OPimContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
+ vo = createVObject( *it );
+ writeVObject( file.fh, vo ); //FIXME: HACK!!!
+ cleanVObject( vo );
+ }
+ cleanStrTbl();
+ deleteVObject( obj );
- m_dirty = false;
- return true;
+ m_dirty = false;
+ return true;
@@ -125,4 +127,4 @@ void OPimContactAccessBackend_VCard::clear ()
{
- m_map.clear();
- m_dirty = true; // ??? sure ? (se)
+ m_map.clear();
+ m_dirty = true; // ??? sure ? (se)
}
@@ -131,5 +133,5 @@ bool OPimContactAccessBackend_VCard::add ( const OPimContact& newcontact )
{
- m_map.insert( newcontact.uid(), newcontact );
- m_dirty = true;
- return true;
+ m_map.insert( newcontact.uid(), newcontact );
+ m_dirty = true;
+ return true;
}
@@ -138,5 +140,5 @@ bool OPimContactAccessBackend_VCard::remove ( int uid )
{
- m_map.remove( uid );
- m_dirty = true;
- return true;
+ m_map.remove( uid );
+ m_dirty = true;
+ return true;
}
@@ -145,5 +147,5 @@ bool OPimContactAccessBackend_VCard::replace ( const OPimContact &contact )
{
- m_map.replace( contact.uid(), contact );
- m_dirty = true;
- return true;
+ m_map.replace( contact.uid(), contact );
+ m_dirty = true;
+ return true;
}
@@ -157,10 +159,10 @@ QArray<int> OPimContactAccessBackend_VCard::allRecords() const
{
- QArray<int> ar( m_map.count() );
- QMap<int, OPimContact>::ConstIterator it;
- int i = 0;
- for ( it = m_map.begin(); it != m_map.end(); ++it ) {
- ar[i] = it.key();
- i++;
- }
- return ar;
+ QArray<int> ar( m_map.count() );
+ QMap<int, OPimContact>::ConstIterator it;
+ int i = 0;
+ for ( it = m_map.begin(); it != m_map.end(); ++it ) {
+ ar[i] = it.key();
+ i++;
+ }
+ return ar;
}
@@ -170,4 +172,4 @@ QArray<int> OPimContactAccessBackend_VCard::queryByExample ( const OPimContact&,
{
- QArray<int> ar(0);
- return ar;
+ QArray<int> ar(0);
+ return ar;
}
@@ -177,4 +179,4 @@ QArray<int> OPimContactAccessBackend_VCard::matchRegexp( const QRegExp& ) cons
{
- QArray<int> ar(0);
- return ar;
+ QArray<int> ar(0);
+ return ar;
}
@@ -183,3 +185,3 @@ const uint OPimContactAccessBackend_VCard::querySettings()
{
- return 0; // No search possible
+ return 0; // No search possible
}
@@ -188,3 +190,3 @@ bool OPimContactAccessBackend_VCard::hasQuerySettings (uint ) const
{
- return false; // No search possible, therefore all settings invalid ;)
+ return false; // No search possible, therefore all settings invalid ;)
}
@@ -193,3 +195,3 @@ bool OPimContactAccessBackend_VCard::wasChangedExternally()
{
- return false; // Don't expect concurrent access
+ return false; // Don't expect concurrent access
}
@@ -199,4 +201,4 @@ QArray<int> OPimContactAccessBackend_VCard::sorted( bool , int, int, int )
{
- QArray<int> ar(0);
- return ar;
+ QArray<int> ar(0);
+ return ar;
}
@@ -208,225 +210,225 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
{
- OPimContact c;
-
- VObjectIterator it;
- initPropIterator( &it, obj );
- while( moreIteration( &it ) ) {
- VObject *o = nextVObject( &it );
- QCString name = vObjectName( o );
- QCString value = vObjectStringZValue( o );
- if ( name == VCNameProp ) {
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectTypeInfo( o );
- QString value = vObjectStringZValue( o );
- if ( name == VCNamePrefixesProp )
- c.setTitle( value );
- else if ( name == VCNameSuffixesProp )
- c.setSuffix( value );
- else if ( name == VCFamilyNameProp )
- c.setLastName( value );
- else if ( name == VCGivenNameProp )
- c.setFirstName( value );
- else if ( name == VCAdditionalNamesProp )
- c.setMiddleName( value );
- }
- }
- else if ( name == VCAdrProp ) {
- bool work = TRUE; // default address is work address
- QString street;
- QString city;
- QString region;
- QString postal;
- QString country;
-
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectName( o );
- QString value = vObjectStringZValue( o );
- if ( name == VCHomeProp )
- work = FALSE;
- else if ( name == VCWorkProp )
- work = TRUE;
- else if ( name == VCStreetAddressProp )
- street = value;
- else if ( name == VCCityProp )
- city = value;
- else if ( name == VCRegionProp )
- region = value;
- else if ( name == VCPostalCodeProp )
- postal = value;
- else if ( name == VCCountryNameProp )
- country = value;
- }
- if ( work ) {
- c.setBusinessStreet( street );
- c.setBusinessCity( city );
- c.setBusinessCountry( country );
- c.setBusinessZip( postal );
- c.setBusinessState( region );
- } else {
- c.setHomeStreet( street );
- c.setHomeCity( city );
- c.setHomeCountry( country );
- c.setHomeZip( postal );
- c.setHomeState( region );
- }
- }
- else if ( name == VCTelephoneProp ) {
- enum {
- HOME = 0x01,
- WORK = 0x02,
- VOICE = 0x04,
- CELL = 0x08,
- FAX = 0x10,
- PAGER = 0x20,
- UNKNOWN = 0x80
- };
- int type = 0;
-
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectTypeInfo( o );
- if ( name == VCHomeProp )
- type |= HOME;
- else if ( name == VCWorkProp )
- type |= WORK;
- else if ( name == VCVoiceProp )
- type |= VOICE;
- else if ( name == VCCellularProp )
- type |= CELL;
- else if ( name == VCFaxProp )
- type |= FAX;
- else if ( name == VCPagerProp )
- type |= PAGER;
- else if ( name == VCPreferredProp )
- ;
- else
- type |= UNKNOWN;
- }
- if ( (type & UNKNOWN) != UNKNOWN ) {
- if ( ( type & (HOME|WORK) ) == 0 ) // default
- type |= HOME;
- if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
- type |= VOICE;
-
- qWarning("value %s %d", value.data(), type );
- if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
- c.setHomePhone( value );
- if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
- c.setHomeFax( value );
- if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
- c.setHomeMobile( value );
- if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
- c.setBusinessPhone( value );
- if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
- c.setBusinessFax( value );
- if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
- c.setBusinessMobile( value );
- if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
- c.setBusinessPager( value );
- }
- }
- else if ( name == VCEmailAddressProp ) {
- QString email = vObjectStringZValue( o );
- bool valid = TRUE;
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectTypeInfo( o );
- if ( name != VCInternetProp && name != VCHomeProp &&
- name != VCWorkProp &&
- name != VCPreferredProp )
- // ### preffered should map to default email
- valid = FALSE;
- }
- if ( valid ) {
- c.insertEmail( email );
- }
- }
- else if ( name == VCURLProp ) {
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectTypeInfo( o );
- if ( name == VCHomeProp )
- c.setHomeWebpage( value );
- else if ( name == VCWorkProp )
- c.setBusinessWebpage( value );
- }
- }
- else if ( name == VCOrgProp ) {
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectName( o );
- QString value = vObjectStringZValue( o );
- if ( name == VCOrgNameProp )
- c.setCompany( value );
- else if ( name == VCOrgUnitProp )
- c.setDepartment( value );
- else if ( name == VCOrgUnit2Prop )
- c.setOffice( value );
- }
- }
- else if ( name == VCTitleProp ) {
- c.setJobTitle( value );
- }
- else if ( name == "X-Qtopia-Profession" ) {
- c.setProfession( value );
- }
- else if ( name == "X-Qtopia-Manager" ) {
- c.setManager( value );
- }
- else if ( name == "X-Qtopia-Assistant" ) {
- c.setAssistant( value );
- }
- else if ( name == "X-Qtopia-Spouse" ) {
- c.setSpouse( value );
- }
- else if ( name == "X-Qtopia-Gender" ) {
- c.setGender( value );
- }
- else if ( name == "X-Qtopia-Anniversary" ) {
- c.setAnniversary( convVCardDateToDate( value ) );
- }
- else if ( name == "X-Qtopia-Nickname" ) {
- c.setNickname( value );
- }
- else if ( name == "X-Qtopia-Children" ) {
- c.setChildren( value );
- }
- else if ( name == VCBirthDateProp ) {
- // Reading Birthdate regarding RFC 2425 (5.8.4)
- c.setBirthday( convVCardDateToDate( value ) );
-
- }
- else if ( name == VCCommentProp ) {
- c.setNotes( value );
- }
+ OPimContact c;
+
+ VObjectIterator it;
+ initPropIterator( &it, obj );
+ while( moreIteration( &it ) ) {
+ VObject *o = nextVObject( &it );
+ QCString name = vObjectName( o );
+ QCString value = vObjectStringZValue( o );
+ if ( name == VCNameProp ) {
+ VObjectIterator nit;
+ initPropIterator( &nit, o );
+ while( moreIteration( &nit ) ) {
+ VObject *o = nextVObject( &nit );
+ QCString name = vObjectTypeInfo( o );
+ QString value = vObjectStringZValue( o );
+ if ( name == VCNamePrefixesProp )
+ c.setTitle( value );
+ else if ( name == VCNameSuffixesProp )
+ c.setSuffix( value );
+ else if ( name == VCFamilyNameProp )
+ c.setLastName( value );
+ else if ( name == VCGivenNameProp )
+ c.setFirstName( value );
+ else if ( name == VCAdditionalNamesProp )
+ c.setMiddleName( value );
+ }
+ }
+ else if ( name == VCAdrProp ) {
+ bool work = TRUE; // default address is work address
+ QString street;
+ QString city;
+ QString region;
+ QString postal;
+ QString country;
+
+ VObjectIterator nit;
+ initPropIterator( &nit, o );
+ while( moreIteration( &nit ) ) {
+ VObject *o = nextVObject( &nit );
+ QCString name = vObjectName( o );
+ QString value = vObjectStringZValue( o );
+ if ( name == VCHomeProp )
+ work = FALSE;
+ else if ( name == VCWorkProp )
+ work = TRUE;
+ else if ( name == VCStreetAddressProp )
+ street = value;
+ else if ( name == VCCityProp )
+ city = value;
+ else if ( name == VCRegionProp )
+ region = value;
+ else if ( name == VCPostalCodeProp )
+ postal = value;
+ else if ( name == VCCountryNameProp )
+ country = value;
+ }
+ if ( work ) {
+ c.setBusinessStreet( street );
+ c.setBusinessCity( city );
+ c.setBusinessCountry( country );
+ c.setBusinessZip( postal );
+ c.setBusinessState( region );
+ } else {
+ c.setHomeStreet( street );
+ c.setHomeCity( city );
+ c.setHomeCountry( country );
+ c.setHomeZip( postal );
+ c.setHomeState( region );
+ }
+ }
+ else if ( name == VCTelephoneProp ) {
+ enum {
+ HOME = 0x01,
+ WORK = 0x02,
+ VOICE = 0x04,
+ CELL = 0x08,
+ FAX = 0x10,
+ PAGER = 0x20,
+ UNKNOWN = 0x80
+ };
+ int type = 0;
+
+ VObjectIterator nit;
+ initPropIterator( &nit, o );
+ while( moreIteration( &nit ) ) {
+ VObject *o = nextVObject( &nit );
+ QCString name = vObjectTypeInfo( o );
+ if ( name == VCHomeProp )
+ type |= HOME;
+ else if ( name == VCWorkProp )
+ type |= WORK;
+ else if ( name == VCVoiceProp )
+ type |= VOICE;
+ else if ( name == VCCellularProp )
+ type |= CELL;
+ else if ( name == VCFaxProp )
+ type |= FAX;
+ else if ( name == VCPagerProp )
+ type |= PAGER;
+ else if ( name == VCPreferredProp )
+ ;
+ else
+ type |= UNKNOWN;
+ }
+ if ( (type & UNKNOWN) != UNKNOWN ) {
+ if ( ( type & (HOME|WORK) ) == 0 ) // default
+ type |= HOME;
+ if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
+ type |= VOICE;
+
+ owarn << "value " << value.data() << " " << type << "" << oendl;
+ if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
+ c.setHomePhone( value );
+ if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
+ c.setHomeFax( value );
+ if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
+ c.setHomeMobile( value );
+ if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
+ c.setBusinessPhone( value );
+ if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
+ c.setBusinessFax( value );
+ if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
+ c.setBusinessMobile( value );
+ if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
+ c.setBusinessPager( value );
+ }
+ }
+ else if ( name == VCEmailAddressProp ) {
+ QString email = vObjectStringZValue( o );
+ bool valid = TRUE;
+ VObjectIterator nit;
+ initPropIterator( &nit, o );
+ while( moreIteration( &nit ) ) {
+ VObject *o = nextVObject( &nit );
+ QCString name = vObjectTypeInfo( o );
+ if ( name != VCInternetProp && name != VCHomeProp &&
+ name != VCWorkProp &&
+ name != VCPreferredProp )
+ // ### preffered should map to default email
+ valid = FALSE;
+ }
+ if ( valid ) {
+ c.insertEmail( email );
+ }
+ }
+ else if ( name == VCURLProp ) {
+ VObjectIterator nit;
+ initPropIterator( &nit, o );
+ while( moreIteration( &nit ) ) {
+ VObject *o = nextVObject( &nit );
+ QCString name = vObjectTypeInfo( o );
+ if ( name == VCHomeProp )
+ c.setHomeWebpage( value );
+ else if ( name == VCWorkProp )
+ c.setBusinessWebpage( value );
+ }
+ }
+ else if ( name == VCOrgProp ) {
+ VObjectIterator nit;
+ initPropIterator( &nit, o );
+ while( moreIteration( &nit ) ) {
+ VObject *o = nextVObject( &nit );
+ QCString name = vObjectName( o );
+ QString value = vObjectStringZValue( o );
+ if ( name == VCOrgNameProp )
+ c.setCompany( value );
+ else if ( name == VCOrgUnitProp )
+ c.setDepartment( value );
+ else if ( name == VCOrgUnit2Prop )
+ c.setOffice( value );
+ }
+ }
+ else if ( name == VCTitleProp ) {
+ c.setJobTitle( value );
+ }
+ else if ( name == "X-Qtopia-Profession" ) {
+ c.setProfession( value );
+ }
+ else if ( name == "X-Qtopia-Manager" ) {
+ c.setManager( value );
+ }
+ else if ( name == "X-Qtopia-Assistant" ) {
+ c.setAssistant( value );
+ }
+ else if ( name == "X-Qtopia-Spouse" ) {
+ c.setSpouse( value );
+ }
+ else if ( name == "X-Qtopia-Gender" ) {
+ c.setGender( value );
+ }
+ else if ( name == "X-Qtopia-Anniversary" ) {
+ c.setAnniversary( convVCardDateToDate( value ) );
+ }
+ else if ( name == "X-Qtopia-Nickname" ) {
+ c.setNickname( value );
+ }
+ else if ( name == "X-Qtopia-Children" ) {
+ c.setChildren( value );
+ }
+ else if ( name == VCBirthDateProp ) {
+ // Reading Birthdate regarding RFC 2425 (5.8.4)
+ c.setBirthday( convVCardDateToDate( value ) );
+
+ }
+ else if ( name == VCCommentProp ) {
+ c.setNotes( value );
+ }
#if 0
- else {
- printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
- VObjectIterator nit;
- initPropIterator( &nit, o );
- while( moreIteration( &nit ) ) {
- VObject *o = nextVObject( &nit );
- QCString name = vObjectName( o );
- QString value = vObjectStringZValue( o );
- printf(" subprop: %s = %s\n", name.data(), value.latin1() );
- }
- }
+ else {
+ printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
+ VObjectIterator nit;
+ initPropIterator( &nit, o );
+ while( moreIteration( &nit ) ) {
+ VObject *o = nextVObject( &nit );
+ QCString name = vObjectName( o );
+ QString value = vObjectStringZValue( o );
+ printf(" subprop: %s = %s\n", name.data(), value.latin1() );
+ }
+ }
#endif
- }
- c.setFileAs();
- return c;
+ }
+ c.setFileAs();
+ return c;
}
@@ -436,104 +438,104 @@ VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
{
- VObject *vcard = newVObject( VCCardProp );
- safeAddPropValue( vcard, VCVersionProp, "2.1" );
- safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
- safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
-
- // full name
- safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
-
- // name properties
- VObject *name = safeAddProp( vcard, VCNameProp );
- safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
- safeAddPropValue( name, VCGivenNameProp, c.firstName() );
- safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
- safeAddPropValue( name, VCNamePrefixesProp, c.title() );
- safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
-
- // home properties
- VObject *home_adr= safeAddProp( vcard, VCAdrProp );
- safeAddProp( home_adr, VCHomeProp );
- safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
- safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
- safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
- safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
- safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
-
- VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
- safeAddProp( home_phone, VCHomeProp );
- home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
- safeAddProp( home_phone, VCHomeProp );
- safeAddProp( home_phone, VCCellularProp );
- home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
- safeAddProp( home_phone, VCHomeProp );
- safeAddProp( home_phone, VCFaxProp );
-
- VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
- safeAddProp( url, VCHomeProp );
-
- // work properties
- VObject *work_adr= safeAddProp( vcard, VCAdrProp );
- safeAddProp( work_adr, VCWorkProp );
- safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
- safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
- safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
- safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
- safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
-
- VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
- safeAddProp( work_phone, VCWorkProp );
- work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
- safeAddProp( work_phone, VCWorkProp );
- safeAddProp( work_phone, VCCellularProp );
- work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
- safeAddProp( work_phone, VCWorkProp );
- safeAddProp( work_phone, VCFaxProp );
- work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
- safeAddProp( work_phone, VCWorkProp );
- safeAddProp( work_phone, VCPagerProp );
-
- url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
- safeAddProp( url, VCWorkProp );
-
- VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
- safeAddProp( title, VCWorkProp );
-
-
- QStringList emails = c.emailList();
- // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
- for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
- VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
- safeAddProp( email, VCInternetProp );
- }
-
- safeAddPropValue( vcard, VCNoteProp, c.notes() );
-
- // Exporting Birthday regarding RFC 2425 (5.8.4)
- if ( c.birthday().isValid() ){
- qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
- safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
- }
-
- if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
- VObject *org = safeAddProp( vcard, VCOrgProp );
- safeAddPropValue( org, VCOrgNameProp, c.company() );
- safeAddPropValue( org, VCOrgUnitProp, c.department() );
- safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
- }
-
- // some values we have to export as custom fields
- safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
- safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
- safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
-
- safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
- safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
- if ( c.anniversary().isValid() ){
- qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() );
- safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
- }
- safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
- safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
-
- return vcard;
+ VObject *vcard = newVObject( VCCardProp );
+ safeAddPropValue( vcard, VCVersionProp, "2.1" );
+ safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
+ safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
+
+ // full name
+ safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
+
+ // name properties
+ VObject *name = safeAddProp( vcard, VCNameProp );
+ safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
+ safeAddPropValue( name, VCGivenNameProp, c.firstName() );
+ safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
+ safeAddPropValue( name, VCNamePrefixesProp, c.title() );
+ safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
+
+ // home properties
+ VObject *home_adr= safeAddProp( vcard, VCAdrProp );
+ safeAddProp( home_adr, VCHomeProp );
+ safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
+ safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
+ safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
+ safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
+ safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
+
+ VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
+ safeAddProp( home_phone, VCHomeProp );
+ home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
+ safeAddProp( home_phone, VCHomeProp );
+ safeAddProp( home_phone, VCCellularProp );
+ home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
+ safeAddProp( home_phone, VCHomeProp );
+ safeAddProp( home_phone, VCFaxProp );
+
+ VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
+ safeAddProp( url, VCHomeProp );
+
+ // work properties
+ VObject *work_adr= safeAddProp( vcard, VCAdrProp );
+ safeAddProp( work_adr, VCWorkProp );
+ safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
+ safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
+ safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
+ safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
+ safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
+
+ VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
+ safeAddProp( work_phone, VCWorkProp );
+ work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
+ safeAddProp( work_phone, VCWorkProp );
+ safeAddProp( work_phone, VCCellularProp );
+ work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
+ safeAddProp( work_phone, VCWorkProp );
+ safeAddProp( work_phone, VCFaxProp );
+ work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
+ safeAddProp( work_phone, VCWorkProp );
+ safeAddProp( work_phone, VCPagerProp );
+
+ url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
+ safeAddProp( url, VCWorkProp );
+
+ VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
+ safeAddProp( title, VCWorkProp );
+
+
+ QStringList emails = c.emailList();
+ // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
+ for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
+ VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
+ safeAddProp( email, VCInternetProp );
+ }
+
+ safeAddPropValue( vcard, VCNoteProp, c.notes() );
+
+ // Exporting Birthday regarding RFC 2425 (5.8.4)
+ if ( c.birthday().isValid() ){
+ owarn << "Exporting birthday as: " << convDateToVCardDate( c.birthday() ) << "" << oendl;
+ safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
+ }
+
+ if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
+ VObject *org = safeAddProp( vcard, VCOrgProp );
+ safeAddPropValue( org, VCOrgNameProp, c.company() );
+ safeAddPropValue( org, VCOrgUnitProp, c.department() );
+ safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
+ }
+
+ // some values we have to export as custom fields
+ safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
+ safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
+ safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
+
+ safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
+ safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
+ if ( c.anniversary().isValid() ){
+ owarn << "Exporting anniversary as: " << convDateToVCardDate( c.anniversary() ) << "" << oendl;
+ safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
+ }
+ safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
+ safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
+
+ return vcard;
}
@@ -542,12 +544,12 @@ QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) co
{
- QString str_rfc2425 = QString("%1-%2-%3")
- .arg( d.year() )
- .arg( d.month(), 2 )
- .arg( d.day(), 2 );
- // Now replace spaces with "0"...
- int pos = 0;
- while ( ( pos = str_rfc2425.find (' ') ) > 0 )
- str_rfc2425.replace( pos, 1, "0" );
-
- return str_rfc2425;
+ QString str_rfc2425 = QString("%1-%2-%3")
+ .arg( d.year() )
+ .arg( d.month(), 2 )
+ .arg( d.day(), 2 );
+ // Now replace spaces with "0"...
+ int pos = 0;
+ while ( ( pos = str_rfc2425.find (' ') ) > 0 )
+ str_rfc2425.replace( pos, 1, "0" );
+
+ return str_rfc2425;
}
@@ -556,23 +558,23 @@ QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datest
{
- int monthPos = datestr.find('-');
- int dayPos = datestr.find('-', monthPos+1 );
- int sep_ignore = 1;
- if ( monthPos == -1 || dayPos == -1 ) {
- qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
- // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
- if ( datestr.length() == 8 ){
- monthPos = 4;
- dayPos = 6;
- sep_ignore = 0;
- qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
- } else {
- return QDate();
- }
- }
- int y = datestr.left( monthPos ).toInt();
- int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
- int d = datestr.mid( dayPos + sep_ignore ).toInt();
- qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
- QDate date ( y,m,d );
- return date;
+ int monthPos = datestr.find('-');
+ int dayPos = datestr.find('-', monthPos+1 );
+ int sep_ignore = 1;
+ if ( monthPos == -1 || dayPos == -1 ) {
+ odebug << "fromString didn't find - in str = " << datestr << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
+ // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
+ if ( datestr.length() == 8 ){
+ monthPos = 4;
+ dayPos = 6;
+ sep_ignore = 0;
+ odebug << "Try with follwing positions str = " << datestr << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
+ } else {
+ return QDate();
+ }
+ }
+ int y = datestr.left( monthPos ).toInt();
+ int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
+ int d = datestr.mid( dayPos + sep_ignore ).toInt();
+ odebug << "TimeConversion::fromString ymd = " << datestr << " => " << y << " " << m << " " << d << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
+ QDate date ( y,m,d );
+ return date;
}
@@ -581,6 +583,6 @@ VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const cha
{
- VObject *ret = 0;
- if ( o && !value.isEmpty() )
- ret = addPropValue( o, prop, value.latin1() );
- return ret;
+ VObject *ret = 0;
+ if ( o && !value.isEmpty() )
+ ret = addPropValue( o, prop, value.latin1() );
+ return ret;
}
@@ -589,6 +591,6 @@ VObject* OPimContactAccessBackend_VCard::safeAddProp( VObject *o, const char *pr
{
- VObject *ret = 0;
- if ( o )
- ret = addProp( o, prop );
- return ret;
+ VObject *ret = 0;
+ if ( o )
+ ret = addProp( o, prop );
+ return ret;
}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index 7b4d81f..5ffcb11 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -32,4 +32,13 @@
+
+/* OPIE */
#include <opie2/ocontactaccessbackend_xml.h>
+#include <opie2/xmltree.h>
+#include <opie2/ocontactaccessbackend.h>
+#include <opie2/ocontactaccess.h>
+#include <opie2/odebug.h>
+
+#include <qpe/global.h>
+/* QT */
#include <qasciidict.h>
@@ -41,8 +50,3 @@
-#include <qpe/global.h>
-
-#include <opie2/xmltree.h>
-#include <opie2/ocontactaccessbackend.h>
-#include <opie2/ocontactaccess.h>
-
+/* STD */
#include <stdlib.h>
@@ -55,23 +59,23 @@ namespace Opie {
OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ):
- m_changed( false )
+ m_changed( false )
{
- // Just m_contactlist should call delete if an entry
- // is removed.
- m_contactList.setAutoDelete( true );
- m_uidToContact.setAutoDelete( false );
+ // Just m_contactlist should call delete if an entry
+ // is removed.
+ m_contactList.setAutoDelete( true );
+ m_uidToContact.setAutoDelete( false );
- m_appName = appname;
+ m_appName = appname;
- /* Set journalfile name ... */
- m_journalName = getenv("HOME");
- m_journalName +="/.abjournal" + appname;
+ /* Set journalfile name ... */
+ m_journalName = getenv("HOME");
+ m_journalName +="/.abjournal" + appname;
- /* Expecting to access the default filename if nothing else is set */
- if ( filename.isEmpty() ){
- m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
- } else
- m_fileName = filename;
+ /* Expecting to access the default filename if nothing else is set */
+ if ( filename.isEmpty() ){
+ m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
+ } else
+ m_fileName = filename;
- /* Load Database now */
- load ();
+ /* Load Database now */
+ load ();
}
@@ -81,67 +85,67 @@ bool OPimContactAccessBackend_XML::save()
- if ( !m_changed )
- return true;
-
- QString strNewFile = m_fileName + ".new";
- QFile f( strNewFile );
- if ( !f.open( IO_WriteOnly|IO_Raw ) )
- return false;
-
- int total_written;
- int idx_offset = 0;
- QString out;
-
- // Write Header
- out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
- " <Groups>\n"
- " </Groups>\n"
- " <Contacts>\n";
- QCString cstr = out.utf8();
- f.writeBlock( cstr.data(), cstr.length() );
- idx_offset += cstr.length();
- out = "";
-
- // Write all contacts
- QListIterator<OPimContact> it( m_contactList );
- for ( ; it.current(); ++it ) {
- // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset );
- out += "<Contact ";
- (*it)->save( out );
- out += "/>\n";
- cstr = out.utf8();
- total_written = f.writeBlock( cstr.data(), cstr.length() );
- idx_offset += cstr.length();
- if ( total_written != int(cstr.length()) ) {
- f.close();
- QFile::remove( strNewFile );
- return false;
- }
- out = "";
- }
- out += " </Contacts>\n</AddressBook>\n";
-
- // Write Footer
- cstr = out.utf8();
- total_written = f.writeBlock( cstr.data(), cstr.length() );
- if ( total_written != int( cstr.length() ) ) {
- f.close();
- QFile::remove( strNewFile );
- return false;
- }
- f.close();
-
- // move the file over, I'm just going to use the system call
- // because, I don't feel like using QDir.
- if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) {
- qWarning( "problem renaming file %s to %s, errno: %d",
- strNewFile.latin1(), m_journalName.latin1(), errno );
- // remove the tmp file...
- QFile::remove( strNewFile );
- }
-
- /* The journalfile should be removed now... */
- removeJournal();
-
- m_changed = false;
- return true;
+ if ( !m_changed )
+ return true;
+
+ QString strNewFile = m_fileName + ".new";
+ QFile f( strNewFile );
+ if ( !f.open( IO_WriteOnly|IO_Raw ) )
+ return false;
+
+ int total_written;
+ int idx_offset = 0;
+ QString out;
+
+ // Write Header
+ out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
+ " <Groups>\n"
+ " </Groups>\n"
+ " <Contacts>\n";
+ QCString cstr = out.utf8();
+ f.writeBlock( cstr.data(), cstr.length() );
+ idx_offset += cstr.length();
+ out = "";
+
+ // Write all contacts
+ QListIterator<OPimContact> it( m_contactList );
+ for ( ; it.current(); ++it ) {
+ // owarn << " Uid " << (*it)->uid() << " at Offset: " << idx_offset << "" << oendl;
+ out += "<Contact ";
+ (*it)->save( out );
+ out += "/>\n";
+ cstr = out.utf8();
+ total_written = f.writeBlock( cstr.data(), cstr.length() );
+ idx_offset += cstr.length();
+ if ( total_written != int(cstr.length()) ) {
+ f.close();
+ QFile::remove( strNewFile );
+ return false;
+ }
+ out = "";
+ }
+ out += " </Contacts>\n</AddressBook>\n";
+
+ // Write Footer
+ cstr = out.utf8();
+ total_written = f.writeBlock( cstr.data(), cstr.length() );
+ if ( total_written != int( cstr.length() ) ) {
+ f.close();
+ QFile::remove( strNewFile );
+ return false;
+ }
+ f.close();
+
+ // move the file over, I'm just going to use the system call
+ // because, I don't feel like using QDir.
+ if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) {
+ qWarning( "problem renaming file %s to %s, errno: %d",
+ strNewFile.latin1(), m_journalName.latin1(), errno );
+ // remove the tmp file...
+ QFile::remove( strNewFile );
+ }
+
+ /* The journalfile should be removed now... */
+ removeJournal();
+
+ m_changed = false;
+ return true;
}
@@ -150,17 +154,17 @@ bool OPimContactAccessBackend_XML::load ()
{
- m_contactList.clear();
- m_uidToContact.clear();
-
- /* Load XML-File and journal if it exists */
- if ( !load ( m_fileName, false ) )
- return false;
- /* The returncode of the journalfile is ignored due to the
- * fact that it does not exist when this class is instantiated !
- * But there may such a file exist, if the application crashed.
- * Therefore we try to load it to get the changes before the #
- * crash happened...
- */
- load (m_journalName, true);
-
- return true;
+ m_contactList.clear();
+ m_uidToContact.clear();
+
+ /* Load XML-File and journal if it exists */
+ if ( !load ( m_fileName, false ) )
+ return false;
+ /* The returncode of the journalfile is ignored due to the
+ * fact that it does not exist when this class is instantiated !
+ * But there may such a file exist, if the application crashed.
+ * Therefore we try to load it to get the changes before the #
+ * crash happened...
+ */
+ load (m_journalName, true);
+
+ return true;
}
@@ -169,6 +173,6 @@ void OPimContactAccessBackend_XML::clear ()
{
- m_contactList.clear();
- m_uidToContact.clear();
+ m_contactList.clear();
+ m_uidToContact.clear();
- m_changed = false;
+ m_changed = false;
}
@@ -177,7 +181,7 @@ bool OPimContactAccessBackend_XML::wasChangedExternally()
{
- QFileInfo fi( m_fileName );
+ QFileInfo fi( m_fileName );
- QDateTime lastmod = fi.lastModified ();
+ QDateTime lastmod = fi.lastModified ();
- return (lastmod != m_readtime);
+ return (lastmod != m_readtime);
}
@@ -186,11 +190,11 @@ QArray<int> OPimContactAccessBackend_XML::allRecords() const
{
- QArray<int> uid_list( m_contactList.count() );
+ QArray<int> uid_list( m_contactList.count() );
- uint counter = 0;
- QListIterator<OPimContact> it( m_contactList );
- for( ; it.current(); ++it ){
- uid_list[counter++] = (*it)->uid();
- }
+ uint counter = 0;
+ QListIterator<OPimContact> it( m_contactList );
+ for( ; it.current(); ++it ){
+ uid_list[counter++] = (*it)->uid();
+ }
- return ( uid_list );
+ return ( uid_list );
}
@@ -199,11 +203,11 @@ OPimContact OPimContactAccessBackend_XML::find ( int uid ) const
{
- OPimContact foundContact; //Create empty contact
+ OPimContact foundContact; //Create empty contact
- OPimContact* found = m_uidToContact.find( QString().setNum( uid ) );
+ OPimContact* found = m_uidToContact.find( QString().setNum( uid ) );
- if ( found ){
- foundContact = *found;
- }
+ if ( found ){
+ foundContact = *found;
+ }
- return ( foundContact );
+ return ( foundContact );
}
@@ -211,141 +215,141 @@ OPimContact OPimContactAccessBackend_XML::find ( int uid ) const
QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &query, int settings,
- const QDateTime& d )
+ const QDateTime& d )
{
- QArray<int> m_currentQuery( m_contactList.count() );
- QListIterator<OPimContact> it( m_contactList );
- uint arraycounter = 0;
-
- for( ; it.current(); ++it ){
- /* Search all fields and compare them with query object. Store them into list
- * if all fields matches.
- */
- QDate* queryDate = 0l;
- QDate* checkDate = 0l;
- bool allcorrect = true;
- for ( int i = 0; i < Qtopia::Groups; i++ ) {
- // Birthday and anniversary are special nonstring fields and should
- // be handled specially
- switch ( i ){
- case Qtopia::Birthday:
- queryDate = new QDate( query.birthday() );
- checkDate = new QDate( (*it)->birthday() );
- // fall through
- case Qtopia::Anniversary:
- if ( queryDate == 0l ){
- queryDate = new QDate( query.anniversary() );
- checkDate = new QDate( (*it)->anniversary() );
- }
-
- if ( queryDate->isValid() ){
- if( checkDate->isValid() ){
- if ( settings & OPimContactAccess::DateYear ){
- if ( queryDate->year() != checkDate->year() )
- allcorrect = false;
- }
- if ( settings & OPimContactAccess::DateMonth ){
- if ( queryDate->month() != checkDate->month() )
- allcorrect = false;
- }
- if ( settings & OPimContactAccess::DateDay ){
- if ( queryDate->day() != checkDate->day() )
- allcorrect = false;
- }
- if ( settings & OPimContactAccess::DateDiff ) {
- QDate current;
- // If we get an additional date, we
- // will take this date instead of
- // the current one..
- if ( !d.date().isValid() )
- current = QDate::currentDate();
- else
- current = d.date();
-
- // We have to equalize the year, otherwise
- // the search will fail..
- checkDate->setYMD( current.year(),
- checkDate->month(),
- checkDate->day() );
- if ( *checkDate < current )
- checkDate->setYMD( current.year()+1,
- checkDate->month(),
- checkDate->day() );
-
- // Check whether the birthday/anniversary date is between
- // the current/given date and the maximum date
- // ( maximum time range ) !
- qWarning("Checking if %s is between %s and %s ! ",
- checkDate->toString().latin1(),
- current.toString().latin1(),
- queryDate->toString().latin1() );
- if ( current.daysTo( *queryDate ) >= 0 ){
- if ( !( ( *checkDate >= current ) &&
- ( *checkDate <= *queryDate ) ) ){
- allcorrect = false;
- qWarning (" Nope!..");
- }
- }
- }
- } else{
- // checkDate is invalid. Therefore this entry is always rejected
- allcorrect = false;
- }
- }
-
- delete queryDate;
- queryDate = 0l;
- delete checkDate;
- checkDate = 0l;
- break;
- default:
- /* Just compare fields which are not empty in the query object */
- if ( !query.field(i).isEmpty() ){
- switch ( settings & ~( OPimContactAccess::IgnoreCase
- | OPimContactAccess::DateDiff
- | OPimContactAccess::DateYear
- | OPimContactAccess::DateMonth
- | OPimContactAccess::DateDay
- | OPimContactAccess::MatchOne
- ) ){
-
- case OPimContactAccess::RegExp:{
- QRegExp expr ( query.field(i),
- !(settings & OPimContactAccess::IgnoreCase),
- false );
- if ( expr.find ( (*it)->field(i), 0 ) == -1 )
- allcorrect = false;
- }
- break;
- case OPimContactAccess::WildCards:{
- QRegExp expr ( query.field(i),
- !(settings & OPimContactAccess::IgnoreCase),
- true );
- if ( expr.find ( (*it)->field(i), 0 ) == -1 )
- allcorrect = false;
- }
- break;
- case OPimContactAccess::ExactMatch:{
- if (settings & OPimContactAccess::IgnoreCase){
- if ( query.field(i).upper() !=
- (*it)->field(i).upper() )
- allcorrect = false;
- }else{
- if ( query.field(i) != (*it)->field(i) )
- allcorrect = false;
- }
- }
- break;
- }
- }
- }
- }
- if ( allcorrect ){
- m_currentQuery[arraycounter++] = (*it)->uid();
- }
- }
-
- // Shrink to fit..
- m_currentQuery.resize(arraycounter);
-
- return m_currentQuery;
+ QArray<int> m_currentQuery( m_contactList.count() );
+ QListIterator<OPimContact> it( m_contactList );
+ uint arraycounter = 0;
+
+ for( ; it.current(); ++it ){
+ /* Search all fields and compare them with query object. Store them into list
+ * if all fields matches.
+ */
+ QDate* queryDate = 0l;
+ QDate* checkDate = 0l;
+ bool allcorrect = true;
+ for ( int i = 0; i < Qtopia::Groups; i++ ) {
+ // Birthday and anniversary are special nonstring fields and should
+ // be handled specially
+ switch ( i ){
+ case Qtopia::Birthday:
+ queryDate = new QDate( query.birthday() );
+ checkDate = new QDate( (*it)->birthday() );
+ // fall through
+ case Qtopia::Anniversary:
+ if ( queryDate == 0l ){
+ queryDate = new QDate( query.anniversary() );
+ checkDate = new QDate( (*it)->anniversary() );
+ }
+
+ if ( queryDate->isValid() ){
+ if( checkDate->isValid() ){
+ if ( settings & OPimContactAccess::DateYear ){
+ if ( queryDate->year() != checkDate->year() )
+ allcorrect = false;
+ }
+ if ( settings & OPimContactAccess::DateMonth ){
+ if ( queryDate->month() != checkDate->month() )
+ allcorrect = false;
+ }
+ if ( settings & OPimContactAccess::DateDay ){
+ if ( queryDate->day() != checkDate->day() )
+ allcorrect = false;
+ }
+ if ( settings & OPimContactAccess::DateDiff ) {
+ QDate current;
+ // If we get an additional date, we
+ // will take this date instead of
+ // the current one..
+ if ( !d.date().isValid() )
+ current = QDate::currentDate();
+ else
+ current = d.date();
+
+ // We have to equalize the year, otherwise
+ // the search will fail..
+ checkDate->setYMD( current.year(),
+ checkDate->month(),
+ checkDate->day() );
+ if ( *checkDate < current )
+ checkDate->setYMD( current.year()+1,
+ checkDate->month(),
+ checkDate->day() );
+
+ // Check whether the birthday/anniversary date is between
+ // the current/given date and the maximum date
+ // ( maximum time range ) !
+ qWarning("Checking if %s is between %s and %s ! ",
+ checkDate->toString().latin1(),
+ current.toString().latin1(),
+ queryDate->toString().latin1() );
+ if ( current.daysTo( *queryDate ) >= 0 ){
+ if ( !( ( *checkDate >= current ) &&
+ ( *checkDate <= *queryDate ) ) ){
+ allcorrect = false;
+ qWarning (" Nope!..");
+ }
+ }
+ }
+ } else{
+ // checkDate is invalid. Therefore this entry is always rejected
+ allcorrect = false;
+ }
+ }
+
+ delete queryDate;
+ queryDate = 0l;
+ delete checkDate;
+ checkDate = 0l;
+ break;
+ default:
+ /* Just compare fields which are not empty in the query object */
+ if ( !query.field(i).isEmpty() ){
+ switch ( settings & ~( OPimContactAccess::IgnoreCase
+ | OPimContactAccess::DateDiff
+ | OPimContactAccess::DateYear
+ | OPimContactAccess::DateMonth
+ | OPimContactAccess::DateDay
+ | OPimContactAccess::MatchOne
+ ) ){
+
+ case OPimContactAccess::RegExp:{
+ QRegExp expr ( query.field(i),
+ !(settings & OPimContactAccess::IgnoreCase),
+ false );
+ if ( expr.find ( (*it)->field(i), 0 ) == -1 )
+ allcorrect = false;
+ }
+ break;
+ case OPimContactAccess::WildCards:{
+ QRegExp expr ( query.field(i),
+ !(settings & OPimContactAccess::IgnoreCase),
+ true );
+ if ( expr.find ( (*it)->field(i), 0 ) == -1 )
+ allcorrect = false;
+ }
+ break;
+ case OPimContactAccess::ExactMatch:{
+ if (settings & OPimContactAccess::IgnoreCase){
+ if ( query.field(i).upper() !=
+ (*it)->field(i).upper() )
+ allcorrect = false;
+ }else{
+ if ( query.field(i) != (*it)->field(i) )
+ allcorrect = false;
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ if ( allcorrect ){
+ m_currentQuery[arraycounter++] = (*it)->uid();
+ }
+ }
+
+ // Shrink to fit..
+ m_currentQuery.resize(arraycounter);
+
+ return m_currentQuery;
}
@@ -354,16 +358,16 @@ QArray<int> OPimContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const
{
- QArray<int> m_currentQuery( m_contactList.count() );
- QListIterator<OPimContact> it( m_contactList );
- uint arraycounter = 0;
+ QArray<int> m_currentQuery( m_contactList.count() );
+ QListIterator<OPimContact> it( m_contactList );
+ uint arraycounter = 0;
- for( ; it.current(); ++it ){
- if ( (*it)->match( r ) ){
- m_currentQuery[arraycounter++] = (*it)->uid();
- }
+ for( ; it.current(); ++it ){
+ if ( (*it)->match( r ) ){
+ m_currentQuery[arraycounter++] = (*it)->uid();
+ }
- }
- // Shrink to fit..
- m_currentQuery.resize(arraycounter);
+ }
+ // Shrink to fit..
+ m_currentQuery.resize(arraycounter);
- return m_currentQuery;
+ return m_currentQuery;
}
@@ -372,11 +376,11 @@ const uint OPimContactAccessBackend_XML::querySettings()
{
- return ( OPimContactAccess::WildCards
- | OPimContactAccess::IgnoreCase
- | OPimContactAccess::RegExp
- | OPimContactAccess::ExactMatch
- | OPimContactAccess::DateDiff
- | OPimContactAccess::DateYear
- | OPimContactAccess::DateMonth
- | OPimContactAccess::DateDay
- );
+ return ( OPimContactAccess::WildCards
+ | OPimContactAccess::IgnoreCase
+ | OPimContactAccess::RegExp
+ | OPimContactAccess::ExactMatch
+ | OPimContactAccess::DateDiff
+ | OPimContactAccess::DateYear
+ | OPimContactAccess::DateMonth
+ | OPimContactAccess::DateDay
+ );
}
@@ -385,45 +389,45 @@ bool OPimContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
{
- /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
- * may be added with any of the other settings. IgnoreCase should never used alone.
- * Wildcards, RegExp, ExactMatch should never used at the same time...
- */
-
- // Step 1: Check whether the given settings are supported by this backend
- if ( ( querySettings & (
- OPimContactAccess::IgnoreCase
- | OPimContactAccess::WildCards
- | OPimContactAccess::DateDiff
- | OPimContactAccess::DateYear
- | OPimContactAccess::DateMonth
- | OPimContactAccess::DateDay
- | OPimContactAccess::RegExp
- | OPimContactAccess::ExactMatch
- ) ) != querySettings )
- return false;
-
- // Step 2: Check whether the given combinations are ok..
-
- // IngoreCase alone is invalid
- if ( querySettings == OPimContactAccess::IgnoreCase )
- return false;
-
- // WildCards, RegExp and ExactMatch should never used at the same time
- switch ( querySettings & ~( OPimContactAccess::IgnoreCase
- | OPimContactAccess::DateDiff
- | OPimContactAccess::DateYear
- | OPimContactAccess::DateMonth
- | OPimContactAccess::DateDay
- )
- ){
- case OPimContactAccess::RegExp:
- return ( true );
- case OPimContactAccess::WildCards:
- return ( true );
- case OPimContactAccess::ExactMatch:
- return ( true );
- case 0: // one of the upper removed bits were set..
- return ( true );
- default:
- return ( false );
- }
+ /* OPimContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
+ * may be added with any of the other settings. IgnoreCase should never used alone.
+ * Wildcards, RegExp, ExactMatch should never used at the same time...
+ */
+
+ // Step 1: Check whether the given settings are supported by this backend
+ if ( ( querySettings & (
+ OPimContactAccess::IgnoreCase
+ | OPimContactAccess::WildCards
+ | OPimContactAccess::DateDiff
+ | OPimContactAccess::DateYear
+ | OPimContactAccess::DateMonth
+ | OPimContactAccess::DateDay
+ | OPimContactAccess::RegExp
+ | OPimContactAccess::ExactMatch
+ ) ) != querySettings )
+ return false;
+
+ // Step 2: Check whether the given combinations are ok..
+
+ // IngoreCase alone is invalid
+ if ( querySettings == OPimContactAccess::IgnoreCase )
+ return false;
+
+ // WildCards, RegExp and ExactMatch should never used at the same time
+ switch ( querySettings & ~( OPimContactAccess::IgnoreCase
+ | OPimContactAccess::DateDiff
+ | OPimContactAccess::DateYear
+ | OPimContactAccess::DateMonth
+ | OPimContactAccess::DateDay
+ )
+ ){
+ case OPimContactAccess::RegExp:
+ return ( true );
+ case OPimContactAccess::WildCards:
+ return ( true );
+ case OPimContactAccess::ExactMatch:
+ return ( true );
+ case 0: // one of the upper removed bits were set..
+ return ( true );
+ default:
+ return ( false );
+ }
}
@@ -433,25 +437,25 @@ QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int )
{
- QMap<QString, int> nameToUid;
- QStringList names;
- QArray<int> m_currentQuery( m_contactList.count() );
-
- // First fill map and StringList with all Names
- // Afterwards sort namelist and use map to fill array to return..
- QListIterator<OPimContact> it( m_contactList );
- for( ; it.current(); ++it ){
- names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) );
- nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() );
- }
- names.sort();
-
- int i = 0;
- if ( asc ){
- for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it )
- m_currentQuery[i++] = nameToUid[ (*it) ];
- }else{
- for ( QStringList::Iterator it = names.end(); it != names.begin(); --it )
- m_currentQuery[i++] = nameToUid[ (*it) ];
- }
-
- return m_currentQuery;
+ QMap<QString, int> nameToUid;
+ QStringList names;
+ QArray<int> m_currentQuery( m_contactList.count() );
+
+ // First fill map and StringList with all Names
+ // Afterwards sort namelist and use map to fill array to return..
+ QListIterator<OPimContact> it( m_contactList );
+ for( ; it.current(); ++it ){
+ names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) );
+ nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() );
+ }
+ names.sort();
+
+ int i = 0;
+ if ( asc ){
+ for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it )
+ m_currentQuery[i++] = nameToUid[ (*it) ];
+ }else{
+ for ( QStringList::Iterator it = names.end(); it != names.begin(); --it )
+ m_currentQuery[i++] = nameToUid[ (*it) ];
+ }
+
+ return m_currentQuery;
@@ -461,9 +465,9 @@ bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact )
{
- //qWarning("odefaultbackend: ACTION::ADD");
- updateJournal (newcontact, ACTION_ADD);
- addContact_p( newcontact );
+ //owarn << "odefaultbackend: ACTION::ADD" << oendl;
+ updateJournal (newcontact, ACTION_ADD);
+ addContact_p( newcontact );
- m_changed = true;
+ m_changed = true;
- return true;
+ return true;
}
@@ -472,20 +476,20 @@ bool OPimContactAccessBackend_XML::replace ( const OPimContact &contact )
{
- m_changed = true;
+ m_changed = true;
- OPimContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) );
+ OPimContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) );
- if ( found ) {
- OPimContact* newCont = new OPimContact( contact );
+ if ( found ) {
+ OPimContact* newCont = new OPimContact( contact );
- updateJournal ( *newCont, ACTION_REPLACE);
- m_contactList.removeRef ( found );
- m_contactList.append ( newCont );
- m_uidToContact.remove( QString().setNum( contact.uid() ) );
- m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont );
+ updateJournal ( *newCont, ACTION_REPLACE);
+ m_contactList.removeRef ( found );
+ m_contactList.append ( newCont );
+ m_uidToContact.remove( QString().setNum( contact.uid() ) );
+ m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont );
- qWarning("Nur zur Sicherheit: %d == %d ?",contact.uid(), newCont->uid());
+ owarn << "Nur zur Sicherheit: " << contact.uid() << " == " << newCont->uid() << " ?" << oendl;
- return true;
- } else
- return false;
+ return true;
+ } else
+ return false;
}
@@ -494,14 +498,14 @@ bool OPimContactAccessBackend_XML::remove ( int uid )
{
- m_changed = true;
+ m_changed = true;
- OPimContact* found = m_uidToContact.find ( QString().setNum( uid ) );
+ OPimContact* found = m_uidToContact.find ( QString().setNum( uid ) );
- if ( found ) {
- updateJournal ( *found, ACTION_REMOVE);
- m_contactList.removeRef ( found );
- m_uidToContact.remove( QString().setNum( uid ) );
+ if ( found ) {
+ updateJournal ( *found, ACTION_REMOVE);
+ m_contactList.removeRef ( found );
+ m_uidToContact.remove( QString().setNum( uid ) );
- return true;
- } else
- return false;
+ return true;
+ } else
+ return false;
}
@@ -509,4 +513,4 @@ bool OPimContactAccessBackend_XML::remove ( int uid )
bool OPimContactAccessBackend_XML::reload(){
- /* Reload is the same as load in this implementation */
- return ( load() );
+ /* Reload is the same as load in this implementation */
+ return ( load() );
}
@@ -515,6 +519,6 @@ void OPimContactAccessBackend_XML::addContact_p( const OPimContact &newcontact )
{
- OPimContact* contRef = new OPimContact( newcontact );
+ OPimContact* contRef = new OPimContact( newcontact );
- m_contactList.append ( contRef );
- m_uidToContact.insert( QString().setNum( newcontact.uid() ), contRef );
+ m_contactList.append ( contRef );
+ m_uidToContact.insert( QString().setNum( newcontact.uid() ), contRef );
}
@@ -525,188 +529,188 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
- /* We use the time of the last read to check if the file was
- * changed externally.
- */
- if ( !isJournal ){
- QFileInfo fi( filename );
- m_readtime = fi.lastModified ();
- }
-
- const int JOURNALACTION = Qtopia::Notes + 1;
- const int JOURNALROW = JOURNALACTION + 1;
-
- bool foundAction = false;
- journal_action action = ACTION_ADD;
- int journalKey = 0;
- QMap<int, QString> contactMap;
- QMap<QString, QString> customMap;
- QMap<QString, QString>::Iterator customIt;
- QAsciiDict<int> dict( 47 );
-
- dict.setAutoDelete( TRUE );
- dict.insert( "Uid", new int(Qtopia::AddressUid) );
- dict.insert( "Title", new int(Qtopia::Title) );
- dict.insert( "FirstName", new int(Qtopia::FirstName) );
- dict.insert( "MiddleName", new int(Qtopia::MiddleName) );
- dict.insert( "LastName", new int(Qtopia::LastName) );
- dict.insert( "Suffix", new int(Qtopia::Suffix) );
- dict.insert( "FileAs", new int(Qtopia::FileAs) );
- dict.insert( "Categories", new int(Qtopia::AddressCategory) );
- dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) );
- dict.insert( "Emails", new int(Qtopia::Emails) );
- dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) );
- dict.insert( "HomeCity", new int(Qtopia::HomeCity) );
- dict.insert( "HomeState", new int(Qtopia::HomeState) );
- dict.insert( "HomeZip", new int(Qtopia::HomeZip) );
- dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) );
- dict.insert( "HomePhone", new int(Qtopia::HomePhone) );
- dict.insert( "HomeFax", new int(Qtopia::HomeFax) );
- dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) );
- dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) );
- dict.insert( "Company", new int(Qtopia::Company) );
- dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) );
- dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) );
- dict.insert( "BusinessState", new int(Qtopia::BusinessState) );
- dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) );
- dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) );
- dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) );
- dict.insert( "JobTitle", new int(Qtopia::JobTitle) );
- dict.insert( "Department", new int(Qtopia::Department) );
- dict.insert( "Office", new int(Qtopia::Office) );
- dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) );
- dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) );
- dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) );
- dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) );
- dict.insert( "Profession", new int(Qtopia::Profession) );
- dict.insert( "Assistant", new int(Qtopia::Assistant) );
- dict.insert( "Manager", new int(Qtopia::Manager) );
- dict.insert( "Spouse", new int(Qtopia::Spouse) );
- dict.insert( "Children", new int(Qtopia::Children) );
- dict.insert( "Gender", new int(Qtopia::Gender) );
- dict.insert( "Birthday", new int(Qtopia::Birthday) );
- dict.insert( "Anniversary", new int(Qtopia::Anniversary) );
- dict.insert( "Nickname", new int(Qtopia::Nickname) );
- dict.insert( "Notes", new int(Qtopia::Notes) );
- dict.insert( "action", new int(JOURNALACTION) );
- dict.insert( "actionrow", new int(JOURNALROW) );
-
- //qWarning( "OPimContactDefaultBackEnd::loading %s", filename.latin1() );
-
- XMLElement *root = XMLElement::load( filename );
- if(root != 0l ){ // start parsing
- /* Parse all XML-Elements and put the data into the
- * Contact-Class
- */
- XMLElement *element = root->firstChild();
- //qWarning("OPimContactAccess::load tagName(): %s", root->tagName().latin1() );
- element = element->firstChild();
-
- /* Search Tag "Contacts" which is the parent of all Contacts */
- while( element && !isJournal ){
- if( element->tagName() != QString::fromLatin1("Contacts") ){
- //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s",
- // element->tagName().latin1());
- element = element->nextChild();
- } else {
- element = element->firstChild();
- break;
- }
- }
- /* Parse all Contacts and ignore unknown tags */
- while( element ){
- if( element->tagName() != QString::fromLatin1("Contact") ){
- //qWarning ("OPimContactDefBack::Searching for Tag \"Contact\"! Found: %s",
- // element->tagName().latin1());
- element = element->nextChild();
- continue;
- }
- /* Found alement with tagname "contact", now parse and store all
- * attributes contained
- */
- //qWarning("OPimContactDefBack::load element tagName() : %s",
- // element->tagName().latin1() );
- QString dummy;
- foundAction = false;
-
- XMLElement::AttributeMap aMap = element->attributes();
- XMLElement::AttributeMap::Iterator it;
- contactMap.clear();
- customMap.clear();
- for( it = aMap.begin(); it != aMap.end(); ++it ){
- // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
-
- int *find = dict[ it.key() ];
- /* Unknown attributes will be stored as "Custom" elements */
- if ( !find ) {
- // qWarning("Attribute %s not known.", it.key().latin1());
- //contact.setCustomField(it.key(), it.data());
- customMap.insert( it.key(), it.data() );
- continue;
- }
-
- /* Check if special conversion is needed and add attribute
- * into Contact class
- */
- switch( *find ) {
- /*
- case Qtopia::AddressUid:
- contact.setUid( it.data().toInt() );
- break;
- case Qtopia::AddressCategory:
- contact.setCategories( Qtopia::Record::idsFromString( it.data( )));
- break;
- */
- case JOURNALACTION:
- action = journal_action(it.data().toInt());
- foundAction = true;
- qWarning ("ODefBack(journal)::ACTION found: %d", action);
- break;
- case JOURNALROW:
- journalKey = it.data().toInt();
- break;
- default: // no conversion needed add them to the map
- contactMap.insert( *find, it.data() );
- break;
- }
- }
- /* now generate the Contact contact */
- OPimContact contact( contactMap );
-
- for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) {
- contact.setCustomField( customIt.key(), customIt.data() );
- }
-
- if (foundAction){
- foundAction = false;
- switch ( action ) {
- case ACTION_ADD:
- addContact_p (contact);
- break;
- case ACTION_REMOVE:
- if ( !remove (contact.uid()) )
- qWarning ("ODefBack(journal)::Unable to remove uid: %d",
- contact.uid() );
- break;
- case ACTION_REPLACE:
- if ( !replace ( contact ) )
- qWarning ("ODefBack(journal)::Unable to replace uid: %d",
- contact.uid() );
- break;
- default:
- qWarning ("Unknown action: ignored !");
- break;
- }
- }else{
- /* Add contact to list */
- addContact_p (contact);
- }
-
- /* Move to next element */
- element = element->nextChild();
- }
- }else {
- qWarning("ODefBack::could not load");
- }
- delete root;
- qWarning("returning from loading" );
- return true;
+ /* We use the time of the last read to check if the file was
+ * changed externally.
+ */
+ if ( !isJournal ){
+ QFileInfo fi( filename );
+ m_readtime = fi.lastModified ();
+ }
+
+ const int JOURNALACTION = Qtopia::Notes + 1;
+ const int JOURNALROW = JOURNALACTION + 1;
+
+ bool foundAction = false;
+ journal_action action = ACTION_ADD;
+ int journalKey = 0;
+ QMap<int, QString> contactMap;
+ QMap<QString, QString> customMap;
+ QMap<QString, QString>::Iterator customIt;
+ QAsciiDict<int> dict( 47 );
+
+ dict.setAutoDelete( TRUE );
+ dict.insert( "Uid", new int(Qtopia::AddressUid) );
+ dict.insert( "Title", new int(Qtopia::Title) );
+ dict.insert( "FirstName", new int(Qtopia::FirstName) );
+ dict.insert( "MiddleName", new int(Qtopia::MiddleName) );
+ dict.insert( "LastName", new int(Qtopia::LastName) );
+ dict.insert( "Suffix", new int(Qtopia::Suffix) );
+ dict.insert( "FileAs", new int(Qtopia::FileAs) );
+ dict.insert( "Categories", new int(Qtopia::AddressCategory) );
+ dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) );
+ dict.insert( "Emails", new int(Qtopia::Emails) );
+ dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) );
+ dict.insert( "HomeCity", new int(Qtopia::HomeCity) );
+ dict.insert( "HomeState", new int(Qtopia::HomeState) );
+ dict.insert( "HomeZip", new int(Qtopia::HomeZip) );
+ dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) );
+ dict.insert( "HomePhone", new int(Qtopia::HomePhone) );
+ dict.insert( "HomeFax", new int(Qtopia::HomeFax) );
+ dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) );
+ dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) );
+ dict.insert( "Company", new int(Qtopia::Company) );
+ dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) );
+ dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) );
+ dict.insert( "BusinessState", new int(Qtopia::BusinessState) );
+ dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) );
+ dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) );
+ dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) );
+ dict.insert( "JobTitle", new int(Qtopia::JobTitle) );
+ dict.insert( "Department", new int(Qtopia::Department) );
+ dict.insert( "Office", new int(Qtopia::Office) );
+ dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) );
+ dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) );
+ dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) );
+ dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) );
+ dict.insert( "Profession", new int(Qtopia::Profession) );
+ dict.insert( "Assistant", new int(Qtopia::Assistant) );
+ dict.insert( "Manager", new int(Qtopia::Manager) );
+ dict.insert( "Spouse", new int(Qtopia::Spouse) );
+ dict.insert( "Children", new int(Qtopia::Children) );
+ dict.insert( "Gender", new int(Qtopia::Gender) );
+ dict.insert( "Birthday", new int(Qtopia::Birthday) );
+ dict.insert( "Anniversary", new int(Qtopia::Anniversary) );
+ dict.insert( "Nickname", new int(Qtopia::Nickname) );
+ dict.insert( "Notes", new int(Qtopia::Notes) );
+ dict.insert( "action", new int(JOURNALACTION) );
+ dict.insert( "actionrow", new int(JOURNALROW) );
+
+ //owarn << "OPimContactDefaultBackEnd::loading " << filename << "" << oendl;
+
+ XMLElement *root = XMLElement::load( filename );
+ if(root != 0l ){ // start parsing
+ /* Parse all XML-Elements and put the data into the
+ * Contact-Class
+ */
+ XMLElement *element = root->firstChild();
+ //owarn << "OPimContactAccess::load tagName(): " << root->tagName() << "" << oendl;
+ element = element->firstChild();
+
+ /* Search Tag "Contacts" which is the parent of all Contacts */
+ while( element && !isJournal ){
+ if( element->tagName() != QString::fromLatin1("Contacts") ){
+ //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s",
+ // element->tagName().latin1());
+ element = element->nextChild();
+ } else {
+ element = element->firstChild();
+ break;
+ }
+ }
+ /* Parse all Contacts and ignore unknown tags */
+ while( element ){
+ if( element->tagName() != QString::fromLatin1("Contact") ){
+ //qWarning ("OPimContactDefBack::Searching for Tag \"Contact\"! Found: %s",
+ // element->tagName().latin1());
+ element = element->nextChild();
+ continue;
+ }
+ /* Found alement with tagname "contact", now parse and store all
+ * attributes contained
+ */
+ //qWarning("OPimContactDefBack::load element tagName() : %s",
+ // element->tagName().latin1() );
+ QString dummy;
+ foundAction = false;
+
+ XMLElement::AttributeMap aMap = element->attributes();
+ XMLElement::AttributeMap::Iterator it;
+ contactMap.clear();
+ customMap.clear();
+ for( it = aMap.begin(); it != aMap.end(); ++it ){
+ // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
+
+ int *find = dict[ it.key() ];
+ /* Unknown attributes will be stored as "Custom" elements */
+ if ( !find ) {
+ // owarn << "Attribute " << it.key() << " not known." << oendl;
+ //contact.setCustomField(it.key(), it.data());
+ customMap.insert( it.key(), it.data() );
+ continue;
+ }
+
+ /* Check if special conversion is needed and add attribute
+ * into Contact class
+ */
+ switch( *find ) {
+ /*
+ case Qtopia::AddressUid:
+ contact.setUid( it.data().toInt() );
+ break;
+ case Qtopia::AddressCategory:
+ contact.setCategories( Qtopia::Record::idsFromString( it.data( )));
+ break;
+ */
+ case JOURNALACTION:
+ action = journal_action(it.data().toInt());
+ foundAction = true;
+ qWarning ("ODefBack(journal)::ACTION found: %d", action);
+ break;
+ case JOURNALROW:
+ journalKey = it.data().toInt();
+ break;
+ default: // no conversion needed add them to the map
+ contactMap.insert( *find, it.data() );
+ break;
+ }
+ }
+ /* now generate the Contact contact */
+ OPimContact contact( contactMap );
+
+ for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) {
+ contact.setCustomField( customIt.key(), customIt.data() );
+ }
+
+ if (foundAction){
+ foundAction = false;
+ switch ( action ) {
+ case ACTION_ADD:
+ addContact_p (contact);
+ break;
+ case ACTION_REMOVE:
+ if ( !remove (contact.uid()) )
+ qWarning ("ODefBack(journal)::Unable to remove uid: %d",
+ contact.uid() );
+ break;
+ case ACTION_REPLACE:
+ if ( !replace ( contact ) )
+ qWarning ("ODefBack(journal)::Unable to replace uid: %d",
+ contact.uid() );
+ break;
+ default:
+ qWarning ("Unknown action: ignored !");
+ break;
+ }
+ }else{
+ /* Add contact to list */
+ addContact_p (contact);
+ }
+
+ /* Move to next element */
+ element = element->nextChild();
+ }
+ }else {
+ owarn << "ODefBack::could not load" << oendl;
+ }
+ delete root;
+ owarn << "returning from loading" << oendl;
+ return true;
}
@@ -715,27 +719,27 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt,
- journal_action action )
+ journal_action action )
{
- QFile f( m_journalName );
- bool created = !f.exists();
- if ( !f.open(IO_WriteOnly|IO_Append) )
- return;
-
- QString buf;
- QCString str;
-
- // if the file was created, we have to set the Tag "<CONTACTS>" to
- // get a XML-File which is readable by our parser.
- // This is just a cheat, but better than rewrite the parser.
- if ( created ){
- buf = "<Contacts>";
- QCString cstr = buf.utf8();
- f.writeBlock( cstr.data(), cstr.length() );
- }
-
- buf = "<Contact ";
- cnt.save( buf );
- buf += " action=\"" + QString::number( (int)action ) + "\" ";
- buf += "/>\n";
- QCString cstr = buf.utf8();
- f.writeBlock( cstr.data(), cstr.length() );
+ QFile f( m_journalName );
+ bool created = !f.exists();
+ if ( !f.open(IO_WriteOnly|IO_Append) )
+ return;
+
+ QString buf;
+ QCString str;
+
+ // if the file was created, we have to set the Tag "<CONTACTS>" to
+ // get a XML-File which is readable by our parser.
+ // This is just a cheat, but better than rewrite the parser.
+ if ( created ){
+ buf = "<Contacts>";
+ QCString cstr = buf.utf8();
+ f.writeBlock( cstr.data(), cstr.length() );
+ }
+
+ buf = "<Contact ";
+ cnt.save( buf );
+ buf += " action=\"" + QString::number( (int)action ) + "\" ";
+ buf += "/>\n";
+ QCString cstr = buf.utf8();
+ f.writeBlock( cstr.data(), cstr.length() );
}
@@ -744,5 +748,5 @@ void OPimContactAccessBackend_XML::removeJournal()
{
- QFile f ( m_journalName );
- if ( f.exists() )
- f.remove();
+ QFile f ( m_journalName );
+ if ( f.exists() )
+ f.remove();
}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index f4f3c94..105c106 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -33,10 +33,3 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <qarray.h>
-#include <qstringlist.h>
-
-#include <qpe/global.h>
-
+/* OPIE */
#include <opie2/osqldriver.h>
@@ -47,2 +40,14 @@
#include <opie2/odatebookaccessbackend_sql.h>
+#include <opie2/odebug.h>
+
+#include <qpe/global.h>
+
+/* QT */
+#include <qarray.h>
+#include <qstringlist.h>
+
+/* STD */
+#include <stdio.h>
+#include <stdlib.h>
+
@@ -51,35 +56,35 @@ using namespace Opie::DB;
namespace {
- /**
- * a find query for custom elements
- */
- class FindCustomQuery : public OSQLQuery {
- public:
- FindCustomQuery(int uid);
- FindCustomQuery(const QArray<int>& );
- ~FindCustomQuery();
- QString query()const;
- private:
- QString single()const;
- QString multi()const;
- QArray<int> m_uids;
- int m_uid;
- };
-
- FindCustomQuery::FindCustomQuery(int uid)
- : OSQLQuery(), m_uid( uid ) {
- }
- FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
- : OSQLQuery(), m_uids( ints ){
- }
- FindCustomQuery::~FindCustomQuery() {
- }
- QString FindCustomQuery::query()const{
-// if ( m_uids.count() == 0 )
- return single();
- }
- QString FindCustomQuery::single()const{
- QString qu = "select uid, type, value from custom_data where uid = ";
- qu += QString::number(m_uid);
- return qu;
- }
+ /**
+ * a find query for custom elements
+ */
+ class FindCustomQuery : public OSQLQuery {
+ public:
+ FindCustomQuery(int uid);
+ FindCustomQuery(const QArray<int>& );
+ ~FindCustomQuery();
+ QString query()const;
+ private:
+ QString single()const;
+ QString multi()const;
+ QArray<int> m_uids;
+ int m_uid;
+ };
+
+ FindCustomQuery::FindCustomQuery(int uid)
+ : OSQLQuery(), m_uid( uid ) {
+ }
+ FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
+ : OSQLQuery(), m_uids( ints ){
+ }
+ FindCustomQuery::~FindCustomQuery() {
+ }
+ QString FindCustomQuery::query()const{
+// if ( m_uids.count() == 0 )
+ return single();
+ }
+ QString FindCustomQuery::single()const{
+ QString qu = "select uid, type, value from custom_data where uid = ";
+ qu += QString::number(m_uid);
+ return qu;
+ }
}
@@ -92,5 +97,5 @@ ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
const QString& fileName )
- : ODateBookAccessBackend(), m_driver( NULL )
+ : ODateBookAccessBackend(), m_driver( NULL )
{
- m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
+ m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
@@ -107,4 +112,4 @@ ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() {
- if( m_driver )
- delete m_driver;
+ if( m_driver )
+ delete m_driver;
}
@@ -114,62 +119,62 @@ void ODateBookAccessBackend_SQL::initFields()
- // This map contains the translation of the fieldtype id's to
- // the names of the table columns
- m_fieldMap.insert( OPimEvent::FUid, "uid" );
- m_fieldMap.insert( OPimEvent::FCategories, "Categories" );
- m_fieldMap.insert( OPimEvent::FDescription, "Description" );
- m_fieldMap.insert( OPimEvent::FLocation, "Location" );
- m_fieldMap.insert( OPimEvent::FType, "Type" );
- m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" );
- m_fieldMap.insert( OPimEvent::FSound, "Sound" );
- m_fieldMap.insert( OPimEvent::FRType, "RType" );
- m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" );
- m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" );
- m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" );
- m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" );
- m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" );
- m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" );
- m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" );
- m_fieldMap.insert( OPimEvent::FStart, "Start" );
- m_fieldMap.insert( OPimEvent::FEnd, "End" );
- m_fieldMap.insert( OPimEvent::FNote, "Note" );
- m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" );
- m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" );
- m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" );
-
- // Create a map that maps the column name to the id
- QMapConstIterator<int, QString> it;
- for ( it = m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
- m_reverseFieldMap.insert( it.data(), it.key() );
- }
-
+ // This map contains the translation of the fieldtype id's to
+ // the names of the table columns
+ m_fieldMap.insert( OPimEvent::FUid, "uid" );
+ m_fieldMap.insert( OPimEvent::FCategories, "Categories" );
+ m_fieldMap.insert( OPimEvent::FDescription, "Description" );
+ m_fieldMap.insert( OPimEvent::FLocation, "Location" );
+ m_fieldMap.insert( OPimEvent::FType, "Type" );
+ m_fieldMap.insert( OPimEvent::FAlarm, "Alarm" );
+ m_fieldMap.insert( OPimEvent::FSound, "Sound" );
+ m_fieldMap.insert( OPimEvent::FRType, "RType" );
+ m_fieldMap.insert( OPimEvent::FRWeekdays, "RWeekdays" );
+ m_fieldMap.insert( OPimEvent::FRPosition, "RPosition" );
+ m_fieldMap.insert( OPimEvent::FRFreq, "RFreq" );
+ m_fieldMap.insert( OPimEvent::FRHasEndDate, "RHasEndDate" );
+ m_fieldMap.insert( OPimEvent::FREndDate, "REndDate" );
+ m_fieldMap.insert( OPimEvent::FRCreated, "RCreated" );
+ m_fieldMap.insert( OPimEvent::FRExceptions, "RExceptions" );
+ m_fieldMap.insert( OPimEvent::FStart, "Start" );
+ m_fieldMap.insert( OPimEvent::FEnd, "End" );
+ m_fieldMap.insert( OPimEvent::FNote, "Note" );
+ m_fieldMap.insert( OPimEvent::FTimeZone, "TimeZone" );
+ m_fieldMap.insert( OPimEvent::FRecParent, "RecParent" );
+ m_fieldMap.insert( OPimEvent::FRecChildren, "Recchildren" );
+
+ // Create a map that maps the column name to the id
+ QMapConstIterator<int, QString> it;
+ for ( it = m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
+ m_reverseFieldMap.insert( it.data(), it.key() );
+ }
+
}
-bool ODateBookAccessBackend_SQL::load()
+bool ODateBookAccessBackend_SQL::load()
{
- if (!m_driver->open() )
- return false;
-
- // Don't expect that the database exists.
- // It is save here to create the table, even if it
- // do exist. ( Is that correct for all databases ?? )
- QString qu = "create table datebook( uid INTEGER PRIMARY KEY ";
-
- QMap<int, QString>::Iterator it;
- for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
- qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
- }
- qu += " );";
-
- qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
-
- qWarning( "command: %s", qu.latin1() );
-
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
- if ( res.state() != OSQLResult::Success )
- return false;
-
- update();
-
- return true;
+ if (!m_driver->open() )
+ return false;
+
+ // Don't expect that the database exists.
+ // It is save here to create the table, even if it
+ // do exist. ( Is that correct for all databases ?? )
+ QString qu = "create table datebook( uid INTEGER PRIMARY KEY ";
+
+ QMap<int, QString>::Iterator it;
+ for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
+ qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
+ }
+ qu += " );";
+
+ qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
+
+ owarn << "command: " << qu << "" << oendl;
+
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+ if ( res.state() != OSQLResult::Success )
+ return false;
+
+ update();
+
+ return true;
}
@@ -179,27 +184,27 @@ void ODateBookAccessBackend_SQL::update()
- QString qu = "select uid from datebook";
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
- if ( res.state() != OSQLResult::Success ){
- // m_uids.clear();
- return;
- }
-
- m_uids = extractUids( res );
-
+ QString qu = "select uid from datebook";
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+ if ( res.state() != OSQLResult::Success ){
+ // m_uids.clear();
+ return;
+ }
+
+ m_uids = extractUids( res );
+
}
-bool ODateBookAccessBackend_SQL::reload()
+bool ODateBookAccessBackend_SQL::reload()
{
- return load();
+ return load();
}
-bool ODateBookAccessBackend_SQL::save()
+bool ODateBookAccessBackend_SQL::save()
{
- return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
+ return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
}
-QArray<int> ODateBookAccessBackend_SQL::allRecords()const
+QArray<int> ODateBookAccessBackend_SQL::allRecords()const
{
- return m_uids;
+ return m_uids;
}
@@ -207,14 +212,14 @@ QArray<int> ODateBookAccessBackend_SQL::allRecords()const
QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OPimEvent&, int, const QDateTime& ) {
- return QArray<int>();
+ return QArray<int>();
}
-void ODateBookAccessBackend_SQL::clear()
+void ODateBookAccessBackend_SQL::clear()
{
- QString qu = "drop table datebook;";
- qu += "drop table custom_data;";
+ QString qu = "drop table datebook;";
+ qu += "drop table custom_data;";
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
- reload();
+ reload();
}
@@ -223,30 +228,30 @@ void ODateBookAccessBackend_SQL::clear()
OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{
- qDebug( "ODateBookAccessBackend_SQL::find( %d )", uid );
+ odebug << "ODateBookAccessBackend_SQL::find( " << uid << " )" << oendl;
- QString qu = "select *";
- qu += "from datebook where uid = " + QString::number(uid);
+ QString qu = "select *";
+ qu += "from datebook where uid = " + QString::number(uid);
- qDebug( "Query: %s", qu.latin1() );
+ odebug << "Query: " << qu << "" << oendl;
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
- OSQLResultItem resItem = res.first();
+ OSQLResultItem resItem = res.first();
- // Create Map for date event and insert UID
- QMap<int,QString> dateEventMap;
- dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) );
+ // Create Map for date event and insert UID
+ QMap<int,QString> dateEventMap;
+ dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) );
- // Now insert the data out of the columns into the map.
- QMapConstIterator<int, QString> it;
- for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
- dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) );
- }
+ // Now insert the data out of the columns into the map.
+ QMapConstIterator<int, QString> it;
+ for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
+ dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) );
+ }
- // Last step: Put map into date event, add custom map and return it
- OPimEvent retDate( dateEventMap );
- retDate.setExtraMap( requestCustom( uid ) );
+ // Last step: Put map into date event, add custom map and return it
+ OPimEvent retDate( dateEventMap );
+ retDate.setExtraMap( requestCustom( uid ) );
- qDebug( "ODateBookAccessBackend_SQL::find( %d ) end", uid );
- return retDate;
+ odebug << "ODateBookAccessBackend_SQL::find( " << uid << " ) end" << oendl;
+ return retDate;
}
@@ -254,45 +259,45 @@ OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{
// FIXME: Speed up update of uid's..
-bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
+bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
{
- QMap<int,QString> eventMap = ev.toMap();
-
- QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() );
- QMap<int, QString>::Iterator it;
- for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
- if ( !eventMap[it.key()].isEmpty() )
- qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] );
- else
- qu += QString( ",\"\"" );
- }
- qu += " );";
-
- // Add custom entries
- int id = 0;
- QMap<QString, QString> customMap = ev.toExtraMap();
- for( QMap<QString, QString>::Iterator it = customMap.begin();
- it != customMap.end(); ++it ){
- qu += "insert into custom_data VALUES("
- + QString::number( ev.uid() )
- + ","
- + QString::number( id++ )
- + ",'"
- + it.key() //.latin1()
- + "',"
- + "0" // Priority for future enhancements
- + ",'"
- + it.data() //.latin1()
- + "');";
- }
- qWarning("add %s", qu.latin1() );
-
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
- if ( res.state() != OSQLResult::Success ){
- return false;
- }
-
- // Update list of uid's
- update();
-
- return true;
+ QMap<int,QString> eventMap = ev.toMap();
+
+ QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() );
+ QMap<int, QString>::Iterator it;
+ for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
+ if ( !eventMap[it.key()].isEmpty() )
+ qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] );
+ else
+ qu += QString( ",\"\"" );
+ }
+ qu += " );";
+
+ // Add custom entries
+ int id = 0;
+ QMap<QString, QString> customMap = ev.toExtraMap();
+ for( QMap<QString, QString>::Iterator it = customMap.begin();
+ it != customMap.end(); ++it ){
+ qu += "insert into custom_data VALUES("
+ + QString::number( ev.uid() )
+ + ","
+ + QString::number( id++ )
+ + ",'"
+ + it.key() //.latin1()
+ + "',"
+ + "0" // Priority for future enhancements
+ + ",'"
+ + it.data() //.latin1()
+ + "');";
+ }
+ owarn << "add " << qu << "" << oendl;
+
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+ if ( res.state() != OSQLResult::Success ){
+ return false;
+ }
+
+ // Update list of uid's
+ update();
+
+ return true;
}
@@ -300,22 +305,22 @@ bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
// FIXME: Speed up update of uid's..
-bool ODateBookAccessBackend_SQL::remove( int uid )
+bool ODateBookAccessBackend_SQL::remove( int uid )
{
- QString qu = "DELETE from datebook where uid = "
- + QString::number( uid ) + ";";
- qu += "DELETE from custom_data where uid = "
- + QString::number( uid ) + ";";
-
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
- if ( res.state() != OSQLResult::Success ){
- return false;
- }
-
- // Update list of uid's
- update();
-
- return true;
+ QString qu = "DELETE from datebook where uid = "
+ + QString::number( uid ) + ";";
+ qu += "DELETE from custom_data where uid = "
+ + QString::number( uid ) + ";";
+
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+ if ( res.state() != OSQLResult::Success ){
+ return false;
+ }
+
+ // Update list of uid's
+ update();
+
+ return true;
}
-bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev )
+bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev )
{
@@ -325,3 +330,3 @@ bool ODateBookAccessBackend_SQL::replace( const OPimEvent& ev )
-QArray<int> ODateBookAccessBackend_SQL::rawEvents()const
+QArray<int> ODateBookAccessBackend_SQL::rawEvents()const
{
@@ -330,50 +335,50 @@ QArray<int> ODateBookAccessBackend_SQL::rawEvents()const
-QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const
+QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const
{
- QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\"";
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
- if ( res.state() != OSQLResult::Success ){
- QArray<int> nix;
- return nix;
- }
-
- return extractUids( res );
+ QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\"";
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+ if ( res.state() != OSQLResult::Success ){
+ QArray<int> nix;
+ return nix;
+ }
+
+ return extractUids( res );
}
-QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const
+QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const
{
- QString qu = "select uid from datebook where RType=\"\" or RType=\"NoRepeat\"";
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
- if ( res.state() != OSQLResult::Success ){
- QArray<int> nix;
- return nix;
- }
-
- return extractUids( res );
+ QString qu = "select uid from datebook where RType=\"\" or RType=\"NoRepeat\"";
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+ if ( res.state() != OSQLResult::Success ){
+ QArray<int> nix;
+ return nix;
+ }
+
+ return extractUids( res );
}
-OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()
+OPimEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()
{
- QArray<int> nonRepUids = nonRepeats();
- OPimEvent::ValueList list;
+ QArray<int> nonRepUids = nonRepeats();
+ OPimEvent::ValueList list;
- for (uint i = 0; i < nonRepUids.count(); ++i ){
- list.append( find( nonRepUids[i] ) );
- }
+ for (uint i = 0; i < nonRepUids.count(); ++i ){
+ list.append( find( nonRepUids[i] ) );
+ }
- return list;
+ return list;
}
-OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
+OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
{
- QArray<int> rawRepUids = rawRepeats();
- OPimEvent::ValueList list;
+ QArray<int> rawRepUids = rawRepeats();
+ OPimEvent::ValueList list;
- for (uint i = 0; i < rawRepUids.count(); ++i ){
- list.append( find( rawRepUids[i] ) );
- }
+ for (uint i = 0; i < rawRepUids.count(); ++i ){
+ list.append( find( rawRepUids[i] ) );
+ }
- return list;
+ return list;
}
@@ -384,16 +389,16 @@ QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
- QString qu = "SELECT uid FROM datebook WHERE (";
+ QString qu = "SELECT uid FROM datebook WHERE (";
- // Do it make sense to search other fields, too ?
- qu += " rlike(\""+ r.pattern() + "\", Location ) OR";
- qu += " rlike(\""+ r.pattern() + "\", Note )";
-
- qu += " )";
+ // Do it make sense to search other fields, too ?
+ qu += " rlike(\""+ r.pattern() + "\", Location ) OR";
+ qu += " rlike(\""+ r.pattern() + "\", Note )";
- qDebug( "query: %s", qu.latin1() );
+ qu += " )";
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
+ odebug << "query: " << qu << "" << oendl;
- return extractUids( res );
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
+
+ return extractUids( res );
@@ -407,18 +412,18 @@ QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const
{
- qWarning("extractUids");
- QTime t;
- t.start();
- OSQLResultItem::ValueList list = res.results();
- OSQLResultItem::ValueList::Iterator it;
- QArray<int> ints(list.count() );
- qWarning(" count = %d", list.count() );
-
- int i = 0;
- for (it = list.begin(); it != list.end(); ++it ) {
- ints[i] = (*it).data("uid").toInt();
- i++;
- }
- qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() );
-
- return ints;
+ owarn << "extractUids" << oendl;
+ QTime t;
+ t.start();
+ OSQLResultItem::ValueList list = res.results();
+ OSQLResultItem::ValueList::Iterator it;
+ QArray<int> ints(list.count() );
+ owarn << " count = " << list.count() << "" << oendl;
+
+ int i = 0;
+ for (it = list.begin(); it != list.end(); ++it ) {
+ ints[i] = (*it).data("uid").toInt();
+ i++;
+ }
+ owarn << "extractUids ready: count2 = " << i << " needs " << t.elapsed() << " ms" << oendl;
+
+ return ints;
@@ -428,24 +433,24 @@ QMap<QString, QString> ODateBookAccessBackend_SQL::requestCustom( int uid ) cons
{
- QTime t;
- t.start();
-
- QMap<QString, QString> customMap;
-
- FindCustomQuery query( uid );
- OSQLResult res_custom = m_driver->query( &query );
-
- if ( res_custom.state() == OSQLResult::Failure ) {
- qWarning("OSQLResult::Failure in find query !!");
- QMap<QString, QString> empty;
- return empty;
- }
-
- OSQLResultItem::ValueList list = res_custom.results();
- OSQLResultItem::ValueList::Iterator it = list.begin();
- for ( ; it != list.end(); ++it ) {
- customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
- }
-
- qDebug("RequestCustom needed: %d ms", t.elapsed() );
- return customMap;
+ QTime t;
+ t.start();
+
+ QMap<QString, QString> customMap;
+
+ FindCustomQuery query( uid );
+ OSQLResult res_custom = m_driver->query( &query );
+
+ if ( res_custom.state() == OSQLResult::Failure ) {
+ owarn << "OSQLResult::Failure in find query !!" << oendl;
+ QMap<QString, QString> empty;
+ return empty;
+ }
+
+ OSQLResultItem::ValueList list = res_custom.results();
+ OSQLResultItem::ValueList::Iterator it = list.begin();
+ for ( ; it != list.end(); ++it ) {
+ customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
+ }
+
+ odebug << "RequestCustom needed: " << t.elapsed() << " ms" << oendl;
+ return customMap;
}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index 77c0253..2ff36e3 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -28,2 +28,19 @@
*/
+
+/* OPIE */
+#include <opie2/opimnotifymanager.h>
+#include <opie2/opimrecurrence.h>
+#include <opie2/opimtimezone.h>
+#include <opie2/odatebookaccessbackend_xml.h>
+#include <opie2/odebug.h>
+
+#include <qtopia/global.h>
+#include <qtopia/stringutil.h>
+#include <qtopia/timeconversion.h>
+
+/* QT */
+#include <qasciidict.h>
+#include <qfile.h>
+
+/* STD */
#include <errno.h>
@@ -40,13 +57,2 @@
-#include <qasciidict.h>
-#include <qfile.h>
-
-#include <qtopia/global.h>
-#include <qtopia/stringutil.h>
-#include <qtopia/timeconversion.h>
-
-#include <opie2/opimnotifymanager.h>
-#include <opie2/opimrecurrence.h>
-#include <opie2/opimtimezone.h>
-#include <opie2/odatebookaccessbackend_xml.h>
@@ -61,3 +67,3 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
if (!needle || !haystack || !hLen || !nLen)
- return 0;
+ return 0;
@@ -66,12 +72,12 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
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--;
}
@@ -98,14 +104,14 @@ namespace {
FType,
- FAlarm,
- FSound,
- FRType,
- FRWeekdays,
- FRPosition,
- FRFreq,
- FRHasEndDate,
- FREndDate,
- FRStart,
- FREnd,
- FNote,
- FCreated, // Should't this be called FRCreated ?
+ FAlarm,
+ FSound,
+ FRType,
+ FRWeekdays,
+ FRPosition,
+ FRFreq,
+ FRHasEndDate,
+ FREndDate,
+ FRStart,
+ FREnd,
+ FNote,
+ FCreated, // Should't this be called FRCreated ?
FTimeZone,
@@ -118,3 +124,3 @@ namespace {
inline void save( const OPimEvent& ev, QString& buf ) {
- qWarning("Saving %d %s", ev.uid(), ev.description().latin1() );
+ owarn << "Saving " << ev.uid() << " " << ev.description() << "" << oendl;
buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\"";
@@ -127,3 +133,3 @@ namespace {
if (ev.isAllDay() )
- buf += " type=\"AllDay\""; // is that all ?? (eilers)
+ buf += " type=\"AllDay\""; // is that all ?? (eilers)
@@ -421,42 +427,42 @@ bool ODateBookAccessBackend_XML::loadFile() {
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 );
@@ -492,6 +498,6 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
/* to current date time */
- // qWarning(" Start is %d", start );
+ // owarn << " Start is " << start << "" << oendl;
OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() );
QDateTime date = zone.toDateTime( start );
- qWarning(" Start is %s", date.toString().latin1() );
+ owarn << " Start is " << date.toString() << "" << oendl;
ev.setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
@@ -516,6 +522,6 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
- qWarning("already contains assign uid");
+ owarn << "already contains assign uid" << oendl;
ev.setUid( 1 );
}
- qWarning("addind %d %s", ev.uid(), ev.description().latin1() );
+ owarn << "addind " << ev.uid() << " " << ev.description() << "" << oendl;
if ( ev.hasRecurrence() )
@@ -527,3 +533,3 @@ void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) {
-// qWarning(" setting %s", value.latin1() );
+// owarn << " setting " << value << "" << oendl;
switch( id ) {
@@ -612,3 +618,3 @@ void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString&
QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
- qWarning("adding exception %s", date.toString().latin1() );
+ owarn << "adding exception " << date.toString() << "" << oendl;
recur()->exceptions().append( date );
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 132b5a6..6f65c48 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -30,8 +30,3 @@
-#include <qdatetime.h>
-#include <qmap.h>
-#include <qstring.h>
-
-#include <qpe/global.h>
-
+/* OPIE */
#include <opie2/osqldriver.h>
@@ -45,2 +40,11 @@
#include <opie2/opimrecurrence.h>
+#include <opie2/odebug.h>
+
+#include <qpe/global.h>
+
+/* QT */
+#include <qdatetime.h>
+#include <qmap.h>
+#include <qstring.h>
+
@@ -153,17 +157,17 @@ namespace {
- /**
- * a find query for custom elements
- */
- class FindCustomQuery : public OSQLQuery {
- public:
- FindCustomQuery(int uid);
- FindCustomQuery(const QArray<int>& );
- ~FindCustomQuery();
- QString query()const;
- private:
- QString single()const;
- QString multi()const;
- QArray<int> m_uids;
- int m_uid;
- };
+ /**
+ * a find query for custom elements
+ */
+ class FindCustomQuery : public OSQLQuery {
+ public:
+ FindCustomQuery(int uid);
+ FindCustomQuery(const QArray<int>& );
+ ~FindCustomQuery();
+ QString query()const;
+ private:
+ QString single()const;
+ QString multi()const;
+ QArray<int> m_uids;
+ int m_uid;
+ };
@@ -177,6 +181,6 @@ namespace {
qu += "description, summary, priority, DueDate, progress , state, ";
- // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers)
- qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, ";
- qu += "reminders, alarms, maintainer, startdate, completeddate);";
- qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
+ // This is the recurrance-stuff .. Exceptions are currently not supported (see OPimRecurrence.cpp) ! (eilers)
+ qu += "RType, RWeekdays, RPosition, RFreq, RHasEndDate, EndDate, Created, Exceptions, ";
+ qu += "reminders, alarms, maintainer, startdate, completeddate);";
+ qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
return qu;
@@ -188,3 +192,3 @@ namespace {
QString qu;
- // We do not need "distinct" here. The primary key is always unique..
+ // We do not need "distinct" here. The primary key is always unique..
//qu += "select distinct uid from todolist";
@@ -215,81 +219,81 @@ namespace {
day = date.day();
- }
- int sYear = 0, sMonth = 0, sDay = 0;
- if( m_todo.hasStartDate() ){
- QDate sDate = m_todo.startDate();
- sYear = sDate.year();
- sMonth= sDate.month();
- sDay = sDate.day();
- }
-
- int eYear = 0, eMonth = 0, eDay = 0;
- if( m_todo.hasCompletedDate() ){
- QDate eDate = m_todo.completedDate();
- eYear = eDate.year();
- eMonth= eDate.month();
- eDay = eDate.day();
- }
+ }
+ int sYear = 0, sMonth = 0, sDay = 0;
+ if( m_todo.hasStartDate() ){
+ QDate sDate = m_todo.startDate();
+ sYear = sDate.year();
+ sMonth= sDate.month();
+ sDay = sDate.day();
+ }
+
+ int eYear = 0, eMonth = 0, eDay = 0;
+ if( m_todo.hasCompletedDate() ){
+ QDate eDate = m_todo.completedDate();
+ eYear = eDate.year();
+ eMonth= eDate.month();
+ eDay = eDate.day();
+ }
QString qu;
- QMap<int, QString> recMap = m_todo.recurrence().toMap();
+ QMap<int, QString> recMap = m_todo.recurrence().toMap();
qu = "insert into todolist VALUES("
- + QString::number( m_todo.uid() ) + ","
- + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + ","
- + QString::number( m_todo.isCompleted() ) + ","
- + "'" + m_todo.description() + "'" + ","
- + "'" + m_todo.summary() + "'" + ","
- + QString::number(m_todo.priority() ) + ","
- + "'" + QString::number(year).rightJustify( 4, '0' ) + "-"
- + QString::number(month).rightJustify( 2, '0' )
- + "-" + QString::number( day ).rightJustify( 2, '0' )+ "'" + ","
- + QString::number( m_todo.progress() ) + ","
- + QString::number( m_todo.state().state() ) + ","
- + "'" + recMap[ OPimRecurrence::RType ] + "'" + ","
- + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + ","
- + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + ","
- + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + ","
- + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + ","
- + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + ","
- + "'" + recMap[ OPimRecurrence::Created ] + "'" + ","
- + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ",";
-
- if ( m_todo.hasNotifiers() ) {
- OPimNotifyManager manager = m_todo.notifiers();
- qu += "'" + manager.remindersToString() + "'" + ","
- + "'" + manager.alarmsToString() + "'" + ",";
- }
- else{
- qu += QString( "''" ) + ","
- + "''" + ",";
- }
-
- qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !)
- + "'" + QString::number(sYear).rightJustify( 4, '0' ) + "-"
- + QString::number(sMonth).rightJustify( 2, '0' )
- + "-" + QString::number(sDay).rightJustify( 2, '0' )+ "'" + ","
- + "'" + QString::number(eYear).rightJustify( 4, '0' ) + "-"
- + QString::number(eMonth).rightJustify( 2, '0' )
- + "-"+QString::number(eDay).rightJustify( 2, '0' ) + "'"
- + "); ";
-
- // Save custom Entries:
- int id = 0;
- id = 0;
- QMap<QString, QString> customMap = m_todo.toExtraMap();
- for( QMap<QString, QString>::Iterator it = customMap.begin();
- it != customMap.end(); ++it ){
- qu += "insert into custom_data VALUES("
- + QString::number( m_todo.uid() )
- + ","
- + QString::number( id++ )
- + ",'"
- + it.key()
- + "',"
- + "0" // Priority for future enhancements
- + ",'"
- + it.data()
- + "');";
- }
-
-
- qDebug("add %s", qu.latin1() );
+ + QString::number( m_todo.uid() ) + ","
+ + "'" + m_todo.idsToString( m_todo.categories() ) + "'" + ","
+ + QString::number( m_todo.isCompleted() ) + ","
+ + "'" + m_todo.description() + "'" + ","
+ + "'" + m_todo.summary() + "'" + ","
+ + QString::number(m_todo.priority() ) + ","
+ + "'" + QString::number(year).rightJustify( 4, '0' ) + "-"
+ + QString::number(month).rightJustify( 2, '0' )
+ + "-" + QString::number( day ).rightJustify( 2, '0' )+ "'" + ","
+ + QString::number( m_todo.progress() ) + ","
+ + QString::number( m_todo.state().state() ) + ","
+ + "'" + recMap[ OPimRecurrence::RType ] + "'" + ","
+ + "'" + recMap[ OPimRecurrence::RWeekdays ] + "'" + ","
+ + "'" + recMap[ OPimRecurrence::RPosition ] + "'" + ","
+ + "'" + recMap[ OPimRecurrence::RFreq ] + "'" + ","
+ + "'" + recMap[ OPimRecurrence::RHasEndDate ] + "'" + ","
+ + "'" + recMap[ OPimRecurrence::EndDate ] + "'" + ","
+ + "'" + recMap[ OPimRecurrence::Created ] + "'" + ","
+ + "'" + recMap[ OPimRecurrence::Exceptions ] + "'" + ",";
+
+ if ( m_todo.hasNotifiers() ) {
+ OPimNotifyManager manager = m_todo.notifiers();
+ qu += "'" + manager.remindersToString() + "'" + ","
+ + "'" + manager.alarmsToString() + "'" + ",";
+ }
+ else{
+ qu += QString( "''" ) + ","
+ + "''" + ",";
+ }
+
+ qu += QString( "''" ) + QString( "," ) // Maintainers (cur. not supported !)
+ + "'" + QString::number(sYear).rightJustify( 4, '0' ) + "-"
+ + QString::number(sMonth).rightJustify( 2, '0' )
+ + "-" + QString::number(sDay).rightJustify( 2, '0' )+ "'" + ","
+ + "'" + QString::number(eYear).rightJustify( 4, '0' ) + "-"
+ + QString::number(eMonth).rightJustify( 2, '0' )
+ + "-"+QString::number(eDay).rightJustify( 2, '0' ) + "'"
+ + "); ";
+
+ // Save custom Entries:
+ int id = 0;
+ id = 0;
+ QMap<QString, QString> customMap = m_todo.toExtraMap();
+ for( QMap<QString, QString>::Iterator it = customMap.begin();
+ it != customMap.end(); ++it ){
+ qu += "insert into custom_data VALUES("
+ + QString::number( m_todo.uid() )
+ + ","
+ + QString::number( id++ )
+ + ",'"
+ + it.key()
+ + "',"
+ + "0" // Priority for future enhancements
+ + ",'"
+ + it.data()
+ + "');";
+ }
+
+
+ odebug << "add " << qu << "" << oendl;
return qu;
@@ -302,3 +306,3 @@ namespace {
QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;";
- qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid);
+ qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid);
return qu;
@@ -347,5 +351,5 @@ namespace {
str = QString("select uid from todolist where DueDate ='%1-%2-%3'")
- .arg( QString::number( date.year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( date.month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( date.day() ) .rightJustify( 2, '0' ) );
+ .arg( QString::number( date.year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( date.month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( date.day() ) .rightJustify( 2, '0' ) );
@@ -364,8 +368,8 @@ namespace {
str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ")
- .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) )
- .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) );
+ .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) );
return str;
@@ -375,8 +379,8 @@ namespace {
str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'")
- .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) )
- .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) );
+ .arg( QString::number( m_start.year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( m_start.month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( m_start.day() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( m_end.year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( m_end.month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( m_end.day() ).rightJustify( 2, '0' ) );
@@ -385,18 +389,18 @@ namespace {
- FindCustomQuery::FindCustomQuery(int uid)
- : OSQLQuery(), m_uid( uid ) {
- }
- FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
- : OSQLQuery(), m_uids( ints ){
- }
- FindCustomQuery::~FindCustomQuery() {
- }
- QString FindCustomQuery::query()const{
- return single(); // Multiple requests not supported !
- }
- QString FindCustomQuery::single()const{
- QString qu = "select uid, type, value from custom_data where uid = ";
- qu += QString::number(m_uid);
- return qu;
- }
+ FindCustomQuery::FindCustomQuery(int uid)
+ : OSQLQuery(), m_uid( uid ) {
+ }
+ FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
+ : OSQLQuery(), m_uids( ints ){
+ }
+ FindCustomQuery::~FindCustomQuery() {
+ }
+ QString FindCustomQuery::query()const{
+ return single(); // Multiple requests not supported !
+ }
+ QString FindCustomQuery::single()const{
+ QString qu = "select uid, type, value from custom_data where uid = ";
+ qu += QString::number(m_uid);
+ return qu;
+ }
@@ -407,3 +411,3 @@ namespace Opie {
OPimTodoAccessBackendSQL::OPimTodoAccessBackendSQL( const QString& file )
- : OPimTodoAccessBackend(),/* m_dict(15),*/ m_driver(NULL), m_dirty(true)
+ : OPimTodoAccessBackend(),/* m_dict(15),*/ m_driver(NULL), m_dirty(true)
{
@@ -419,4 +423,4 @@ OPimTodoAccessBackendSQL::OPimTodoAccessBackendSQL( const QString& file )
OPimTodoAccessBackendSQL::~OPimTodoAccessBackendSQL(){
- if( m_driver )
- delete m_driver;
+ if( m_driver )
+ delete m_driver;
}
@@ -458,3 +462,3 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
uint CACHE = readAhead();
- qDebug("searching for %d", uid );
+ odebug << "searching for " << uid << "" << oendl;
QArray<int> search( CACHE );
@@ -468,3 +472,3 @@ OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
- qDebug("size %d %d", size, ints[i] );
+ odebug << "size " << size << " " << ints[i] << "" << oendl;
search[size] = ints[i];
@@ -543,3 +547,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
int sortFilter, int cat ) {
- qDebug("sorted %d, %d", asc, sortOrder );
+ odebug << "sorted " << asc << ", " << sortOrder << "" << oendl;
QString query;
@@ -565,5 +569,5 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
base = QString("DueDate <= '%1-%2-%3' AND completed = 0")
- .arg( QString::number( date.year() ).rightJustify( 4, '0' ) )
- .arg( QString::number( date.month() ).rightJustify( 2, '0' ) )
- .arg( QString::number( date.day() ).rightJustify( 2, '0' ) );
+ .arg( QString::number( date.year() ).rightJustify( 4, '0' ) )
+ .arg( QString::number( date.month() ).rightJustify( 2, '0' ) )
+ .arg( QString::number( date.day() ).rightJustify( 2, '0' ) );
query += " " + base + " AND";
@@ -602,3 +606,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
if ( !asc ) {
- qDebug("not ascending!");
+ odebug << "not ascending!" << oendl;
query += " DESC";
@@ -606,3 +610,3 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
- qDebug( query );
+ odebug << query << oendl;
OSQLRawQuery raw(query );
@@ -631,3 +635,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
OSQLResultItem::ValueList::Iterator it = list.begin();
- qDebug("todo1");
+ odebug << "todo1" << oendl;
OPimTodo to = todo( (*it) );
@@ -637,3 +641,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
for ( ; it != list.end(); ++it ) {
- qDebug("caching");
+ odebug << "caching" << oendl;
cache( todo( (*it) ) );
@@ -643,3 +647,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
- qDebug("todo(ResultItem)");
+ odebug << "todo(ResultItem)" << oendl;
@@ -651,3 +655,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
- qDebug("Item is completed: %d", item.data("completed").toInt() );
+ odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl;
@@ -661,3 +665,3 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
if ( isOk )
- to.setPriority( prioInt );
+ to.setPriority( prioInt );
@@ -669,5 +673,5 @@ OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
if ( hasStartDate )
- to.setStartDate( startDate );
+ to.setStartDate( startDate );
if ( hasCompletedDate )
- to.setCompletedDate( completedDate );
+ to.setCompletedDate( completedDate );
@@ -752,3 +756,3 @@ QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{
QArray<int> ints(list.count() );
- qDebug(" count = %d", list.count() );
+ odebug << " count = " << list.count() << "" << oendl;
@@ -766,20 +770,20 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
#if 0
- QArray<int> empty;
- return empty;
+ QArray<int> empty;
+ return empty;
#else
- QString qu = "SELECT uid FROM todolist WHERE (";
+ QString qu = "SELECT uid FROM todolist WHERE (";
- // Do it make sense to search other fields, too ?
- qu += " rlike(\""+ r.pattern() + "\",\"description\") OR";
- qu += " rlike(\""+ r.pattern() + "\",\"summary\")";
+ // Do it make sense to search other fields, too ?
+ qu += " rlike(\""+ r.pattern() + "\",\"description\") OR";
+ qu += " rlike(\""+ r.pattern() + "\",\"summary\")";
- qu += ")";
+ qu += ")";
- qDebug( "query: %s", qu.latin1() );
+ odebug << "query: " << qu << "" << oendl;
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
- return uids( res );
+ return uids( res );
@@ -791,3 +795,3 @@ QBitArray OPimTodoAccessBackendSQL::supports()const {
- return sup();
+ return sup();
}
@@ -796,11 +800,11 @@ QBitArray OPimTodoAccessBackendSQL::sup() const{
- QBitArray ar( OPimTodo::CompletedDate + 1 );
- ar.fill( true );
- ar[OPimTodo::CrossReference] = false;
- ar[OPimTodo::State ] = false;
- ar[OPimTodo::Reminders] = false;
- ar[OPimTodo::Notifiers] = false;
- ar[OPimTodo::Maintainer] = false;
+ QBitArray ar( OPimTodo::CompletedDate + 1 );
+ ar.fill( true );
+ ar[OPimTodo::CrossReference] = false;
+ ar[OPimTodo::State ] = false;
+ ar[OPimTodo::Reminders] = false;
+ ar[OPimTodo::Notifiers] = false;
+ ar[OPimTodo::Maintainer] = false;
- return ar;
+ return ar;
}
@@ -808,45 +812,45 @@ QBitArray OPimTodoAccessBackendSQL::sup() const{
void OPimTodoAccessBackendSQL::removeAllCompleted(){
- // First we need the uids from all entries which are
- // completed. Then, we just have to remove them...
+ // First we need the uids from all entries which are
+ // completed. Then, we just have to remove them...
- QString qu = "SELECT uid FROM todolist WHERE completed = 1";
+ QString qu = "SELECT uid FROM todolist WHERE completed = 1";
- OSQLRawQuery raw( qu );
- OSQLResult res = m_driver->query( &raw );
+ OSQLRawQuery raw( qu );
+ OSQLResult res = m_driver->query( &raw );
- QArray<int> completed_uids = uids( res );
+ QArray<int> completed_uids = uids( res );
- qDebug( "Number of completed: %d", completed_uids.size() );
+ odebug << "Number of completed: " << completed_uids.size() << "" << oendl;
- if ( completed_uids.size() == 0 )
- return;
+ if ( completed_uids.size() == 0 )
+ return;
- qu = "DELETE FROM todolist WHERE (";
- QString query;
+ qu = "DELETE FROM todolist WHERE (";
+ QString query;
- for ( int i = 0; i < completed_uids.size(); i++ ){
- if ( !query.isEmpty() )
- query += " OR ";
- query += QString( "uid = %1" ).arg( completed_uids[i] );
- }
- qu += query + " );";
+ for ( int i = 0; i < completed_uids.size(); i++ ){
+ if ( !query.isEmpty() )
+ query += " OR ";
+ query += QString( "uid = %1" ).arg( completed_uids[i] );
+ }
+ qu += query + " );";
- // Put remove of custom entries in this query to speed up..
- qu += "DELETE FORM custom_data WHERE (";
- query = "";
+ // Put remove of custom entries in this query to speed up..
+ qu += "DELETE FORM custom_data WHERE (";
+ query = "";
- for ( int i = 0; i < completed_uids.size(); i++ ){
- if ( !query.isEmpty() )
- query += " OR ";
- query += QString( "uid = %1" ).arg( completed_uids[i] );
- }
- qu += query + " );";
+ for ( int i = 0; i < completed_uids.size(); i++ ){
+ if ( !query.isEmpty() )
+ query += " OR ";
+ query += QString( "uid = %1" ).arg( completed_uids[i] );
+ }
+ qu += query + " );";
- qDebug( "query: %s", qu.latin1() );
+ odebug << "query: " << qu << "" << oendl;
- OSQLRawQuery raw2( qu );
- res = m_driver->query( &raw2 );
- if ( res.state() == OSQLResult::Failure ) {
- qWarning("OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: %s", qu.latin1() );
- }
+ OSQLRawQuery raw2( qu );
+ res = m_driver->query( &raw2 );
+ if ( res.state() == OSQLResult::Failure ) {
+ owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl;
+ }
}
@@ -856,20 +860,20 @@ QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
{
- QMap<QString, QString> customMap;
+ QMap<QString, QString> customMap;
- FindCustomQuery query( uid );
- OSQLResult res_custom = m_driver->query( &query );
+ FindCustomQuery query( uid );
+ OSQLResult res_custom = m_driver->query( &query );
- if ( res_custom.state() == OSQLResult::Failure ) {
- qWarning("OSQLResult::Failure in find query !!");
- QMap<QString, QString> empty;
- return empty;
- }
+ if ( res_custom.state() == OSQLResult::Failure ) {
+ owarn << "OSQLResult::Failure in find query !!" << oendl;
+ QMap<QString, QString> empty;
+ return empty;
+ }
- OSQLResultItem::ValueList list = res_custom.results();
- OSQLResultItem::ValueList::Iterator it = list.begin();
- for ( ; it != list.end(); ++it ) {
- customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
- }
+ OSQLResultItem::ValueList list = res_custom.results();
+ OSQLResultItem::ValueList::Iterator it = list.begin();
+ for ( ; it != list.end(); ++it ) {
+ customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
+ }
- return customMap;
+ return customMap;
}
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 03d4479..14a325e 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -29,7 +29,11 @@
-/* OPIE */
#include "vobject_p.h"
-#include <qpe/timeconversion.h>
+
+/* OPIE */
#include <opie2/otodoaccessvcal.h>
+#include <opie2/odebug.h>
+#include <qpe/timeconversion.h>
+
+/* QT */
//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
@@ -90,3 +94,3 @@ namespace {
name = vObjectStringZValue( ob );
- qWarning("Categories:%s", name.data() );
+ owarn << "Categories:" << name.data() << "" << oendl;
}
@@ -119,6 +123,6 @@ namespace {
- // There seems a misrepresentation between summary in otodoevent
- // and summary in vcard.
- // The same with description..
- // Description is summary and vice versa.. Argh.. (eilers)
+ // There seems a misrepresentation between summary in otodoevent
+ // and summary in vcard.
+ // The same with description..
+ // Description is summary and vice versa.. Argh.. (eilers)
@@ -137,3 +141,3 @@ namespace {
event.description().local8Bit() );
-#endif
+#endif
return task;
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 @@
*/
+
+/* 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>
@@ -38,16 +57,2 @@
-#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;
@@ -78,3 +83,3 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
if (!needle || !haystack || !hLen || !nLen)
- return 0;
+ return 0;
@@ -83,12 +88,12 @@ char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
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--;
}
@@ -179,3 +184,3 @@ bool OPimTodoAccessXML::load() {
i+= strLen;
- qWarning("Found a start at %d %d", i, (point-dt) );
+ owarn << "Found a start at " << i << " " << (point-dt) << "" << oendl;
@@ -186,41 +191,41 @@ bool OPimTodoAccessXML::load() {
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 );
@@ -235,3 +240,3 @@ bool OPimTodoAccessXML::load() {
*/
- qWarning("End at %d", i );
+ owarn << "End at " << i << "" << oendl;
if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
@@ -258,3 +263,3 @@ bool OPimTodoAccessXML::load() {
- qWarning("counts %d records loaded!", m_events.count() );
+ owarn << "counts " << m_events.count() << " records loaded!" << oendl;
return true;
@@ -266,5 +271,5 @@ 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;
@@ -309,3 +314,3 @@ bool OPimTodoAccessXML::save() {
if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
-// qWarning("error renaming");
+// owarn << "error renaming" << oendl;
QFile::remove( strNewFile );
@@ -347,3 +352,3 @@ void OPimTodoAccessXML::clear() {
bool OPimTodoAccessXML::add( const OPimTodo& todo ) {
-// qWarning("add");
+// owarn << "add" << oendl;
m_changed = true;
@@ -406,3 +411,3 @@ 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;
@@ -412,3 +417,3 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
if (!find ) {
-// qWarning("Unknown option" + it.key() );
+// owarn << "Unknown option" + it.key() << oendl;
ev.setCustomField( attr, val );
@@ -465,4 +470,4 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
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() );
@@ -539,11 +544,11 @@ 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 += "\" ";
}
@@ -572,3 +577,3 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
}
-// qWarning( "Uid %d", ev.uid() );
+// owarn << "Uid " << ev.uid() << "" << oendl;
str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
@@ -619,3 +624,3 @@ 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(";") +"\" ";
@@ -840,3 +845,3 @@ QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder,
/* if ( (*it).isOverdue() && !bOnly ) {
- qWarning("item is overdue but !bOnly");
+ owarn << "item is overdue but !bOnly" << oendl;
continue;
@@ -893,4 +898,4 @@ 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;
@@ -898,10 +903,10 @@ QArray<int> OPimTodoAccessXML::matchRegexp( const QRegExp &r ) const
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;
}
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp
index c1e06c8..48a74d0 100644
--- a/libopie2/opiepim/core/opimcontact.cpp
+++ b/libopie2/opiepim/core/opimcontact.cpp
@@ -36,2 +36,4 @@
#include <opie2/opimdateconversion.h>
+#include <opie2/odebug.h>
+
#include <qpe/stringutil.h>
@@ -81,3 +83,3 @@ OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap
{
- qWarning( "Invalid UID found. Generate new one.." );
+ owarn << "Invalid UID found. Generate new one.." << oendl;
setUid( uidGen().generate() );
@@ -88,3 +90,3 @@ OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap
// if ( !uidStr.isEmpty() )
- // setUid( uidStr.toInt() );
+ // setUid( uidStr.toInt() );
}
@@ -933,3 +935,3 @@ QStringList OPimContact::emailList() const
{
- qDebug( " emailstr " );
+ odebug << " emailstr " << oendl;
QStringList l = QStringList::split( emailSeparator(), emailStr );
@@ -1138,3 +1140,3 @@ void OPimContact::setBirthday( const QDate &v )
{
- qWarning( "Remove Birthday" );
+ owarn << "Remove Birthday" << oendl;
replace( Qtopia::Birthday, QString::null );
@@ -1157,3 +1159,3 @@ void OPimContact::setAnniversary( const QDate &v )
{
- qWarning( "Remove Anniversary" );
+ owarn << "Remove Anniversary" << oendl;
replace( Qtopia::Anniversary, QString::null );
@@ -1198,3 +1200,3 @@ void OPimContact::insertEmail( const QString &v )
{
- //qDebug("insertEmail %s", v.latin1());
+ //odebug << "insertEmail " << v << "" << oendl;
QString e = v.simplifyWhiteSpace();
@@ -1232,3 +1234,3 @@ void OPimContact::insertEmail( const QString &v )
// remove it
- //qDebug(" removing email from list %s", e.latin1());
+ //odebug << " removing email from list " << e << "" << oendl;
emails.remove( e );
@@ -1241,3 +1243,3 @@ void OPimContact::insertEmail( const QString &v )
{
- //qDebug("removeEmail is default; setting new default");
+ //odebug << "removeEmail is default; setting new default" << oendl;
if ( !emails.count() )
@@ -1261,3 +1263,3 @@ void OPimContact::setDefaultEmail( const QString &v )
- //qDebug("OPimContact::setDefaultEmail %s", e.latin1());
+ //odebug << "OPimContact::setDefaultEmail " << e << "" << oendl;
replace( Qtopia::DefaultEmail, e );
diff --git a/libopie2/opiepim/core/opimcontactfields.cpp b/libopie2/opiepim/core/opimcontactfields.cpp
index 120beb6..5d45d1f 100644
--- a/libopie2/opiepim/core/opimcontactfields.cpp
+++ b/libopie2/opiepim/core/opimcontactfields.cpp
@@ -33,2 +33,4 @@
#include <opie2/opimcontact.h>
+#include <opie2/odebug.h>
+
#include <qpe/config.h>
@@ -444,3 +446,3 @@ void OPimContactFields::saveToRecord( OPimContact &cnt )
- qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() );
+ odebug << "ocontactfields saveToRecord: >" << fieldOrder << "<" << oendl;
@@ -456,4 +458,4 @@ void OPimContactFields::loadFromRecord( const OPimContact &cnt )
{
- qDebug( "ocontactfields loadFromRecord" );
- qDebug( "loading >%s<", cnt.fullName().latin1() );
+ odebug << "ocontactfields loadFromRecord" << oendl;
+ odebug << "loading >" << cnt.fullName() << "<" << oendl;
@@ -464,3 +466,3 @@ void OPimContactFields::loadFromRecord( const OPimContact &cnt )
- qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() );
+ odebug << "fieldOrder from contact>" << fieldOrder << "<" << oendl;
@@ -472,3 +474,3 @@ void OPimContactFields::loadFromRecord( const OPimContact &cnt )
- qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() );
+ odebug << "effective fieldOrder in loadFromRecord >" << fieldOrder << "<" << oendl;
}
@@ -477,3 +479,3 @@ void OPimContactFields::setFieldOrder( int num, int index )
{
- qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index );
+ odebug << "qcontactfields setfieldorder pos " << num << " -> " << index << "" << oendl;
@@ -486,3 +488,3 @@ void OPimContactFields::setFieldOrder( int num, int index )
- qDebug( "fieldOrder >%s<", fieldOrder.latin1() );
+ odebug << "fieldOrder >" << fieldOrder << "<" << oendl;
}
@@ -491,4 +493,4 @@ int OPimContactFields::getFieldOrder( int num, int defIndex )
{
- qDebug( "ocontactfields getFieldOrder" );
- qDebug( "fieldOrder >%s<", fieldOrder.latin1() );
+ odebug << "ocontactfields getFieldOrder" << oendl;
+ odebug << "fieldOrder >" << fieldOrder << "<" << oendl;
@@ -509,3 +511,3 @@ int OPimContactFields::getFieldOrder( int num, int defIndex )
- qDebug( "returning >%i<", ret );
+ odebug << "returning >" << ret << "<" << oendl;
diff --git a/libopie2/opiepim/core/opimdateconversion.cpp b/libopie2/opiepim/core/opimdateconversion.cpp
index 8bf891b..c93e178 100644
--- a/libopie2/opiepim/core/opimdateconversion.cpp
+++ b/libopie2/opiepim/core/opimdateconversion.cpp
@@ -30,2 +30,4 @@ _;:, .> :=|. This program is free software; you can
#include <opie2/opimdateconversion.h>
+#include <opie2/odebug.h>
+
#include <qpe/timeconversion.h>
@@ -48,3 +50,3 @@ QString OPimDateConversion::dateToString( const QDate &d )
QString str = year + month + day;
- //qDebug( "\tPimContact dateToStr = %s", str.latin1() );
+ //odebug << "\tPimContact dateToStr = " << str << "" << oendl;
@@ -76,3 +78,3 @@ QDate OPimDateConversion::dateFromString( const QString& s )
{
- qWarning( "PimContact year is not in range" );
+ owarn << "PimContact year is not in range" << oendl;
return date;
@@ -81,3 +83,3 @@ QDate OPimDateConversion::dateFromString( const QString& s )
{
- qWarning( "PimContact month is not in range" );
+ owarn << "PimContact month is not in range" << oendl;
return date;
@@ -86,3 +88,3 @@ QDate OPimDateConversion::dateFromString( const QString& s )
{
- qWarning( "PimContact day is not in range" );
+ owarn << "PimContact day is not in range" << oendl;
return date;
@@ -93,3 +95,3 @@ QDate OPimDateConversion::dateFromString( const QString& s )
{
- qWarning( "PimContact date is not valid" );
+ owarn << "PimContact date is not valid" << oendl;
return date;
diff --git a/libopie2/opiepim/core/opimevent.cpp b/libopie2/opiepim/core/opimevent.cpp
index 9d46651..8752fce 100644
--- a/libopie2/opiepim/core/opimevent.cpp
+++ b/libopie2/opiepim/core/opimevent.cpp
@@ -35,2 +35,4 @@
#include <opie2/opimnotifymanager.h>
+#include <opie2/odebug.h>
+
#include <qpe/categories.h>
@@ -557,7 +559,7 @@ QMap<int, QString> OPimEvent::toMap() const
retMap.insert( OPimEvent::FType, isAllDay() ? "AllDay" : "" );
- if ( notifiers().alarms().count() ){
- // Currently we just support one alarm.. (eilers)
- OPimAlarm alarm = notifiers().alarms() [ 0 ];
- retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
- retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" );
+ if ( notifiers().alarms().count() ){
+ // Currently we just support one alarm.. (eilers)
+ OPimAlarm alarm = notifiers().alarms() [ 0 ];
+ retMap.insert( OPimEvent::FAlarm, QString::number( alarm.dateTime().secsTo( startDateTime() ) / 60 ) );
+ retMap.insert( OPimEvent::FSound, ( alarm.sound() == OPimAlarm::Loud ) ? "loud" : "silent" );
}
@@ -643,6 +645,6 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
/* to current date time */
- // qWarning(" Start is %d", start );
+ // owarn << " Start is " << start << "" << oendl;
OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() );
QDateTime date = zone.toDateTime( start );
- qWarning( " Start is %s", date.toString().latin1() );
+ owarn << " Start is " << date.toString() << "" << oendl;
setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
@@ -660,5 +662,5 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
{
- QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 );
- OPimAlarm al( sound , dt );
- notifiers().add( al );
+ QDateTime dt = startDateTime().addSecs( -1 * alarmTime * 60 );
+ OPimAlarm al( sound , dt );
+ notifiers().add( al );
}
@@ -667,3 +669,3 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
if ( !map[ OPimEvent::FNote ].isEmpty() )
- setNote( map[ OPimEvent::FNote ] );
+ setNote( map[ OPimEvent::FNote ] );
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp
index 573340a..0f863aa 100644
--- a/libopie2/opiepim/core/opimnotifymanager.cpp
+++ b/libopie2/opiepim/core/opimnotifymanager.cpp
@@ -33,2 +33,3 @@
#include <opie2/opimdateconversion.h>
+#include <opie2/odebug.h>
@@ -165,3 +166,3 @@ bool OPimNotifyManager::isEmpty() const
{
- qWarning( "is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() );
+ owarn << "is Empty called on OPimNotifyManager " << m_rem.count() << " " << m_al.count() << "" << oendl;
if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
@@ -193,3 +194,3 @@ QString OPimNotifyManager::alarmsToString() const
// now write the list
- qWarning( "als: %s", als.join( "____________" ).latin1() );
+ owarn << "als: " << als.join( "____________" ) << "" << oendl;
str = als.join( ";" );
@@ -227,3 +228,3 @@ void OPimNotifyManager::alarmsFromString( const QString& str )
QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty
- qWarning( "alarm: %s", alarm.join( "___" ).latin1() );
+ owarn << "alarm: " << alarm.join( "___" ) << "" << oendl;
qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(),
diff --git a/libopie2/opiepim/core/opimrecord.cpp b/libopie2/opiepim/core/opimrecord.cpp
index c783092..6546d99 100644
--- a/libopie2/opiepim/core/opimrecord.cpp
+++ b/libopie2/opiepim/core/opimrecord.cpp
@@ -123,3 +123,3 @@ bool OPimRecord::isEmpty() const
str = str.remove( str.length()-1, 1); // strip the ;
- //qWarning("IDS " + str );
+ //owarn << "IDS " + str << oendl;
diff --git a/libopie2/opiepim/core/opimtimezone.cpp b/libopie2/opiepim/core/opimtimezone.cpp
index be21b1b..fefceb5 100644
--- a/libopie2/opiepim/core/opimtimezone.cpp
+++ b/libopie2/opiepim/core/opimtimezone.cpp
@@ -31,2 +31,5 @@
+/* OPIE */
+#include <opie2/odebug.h>
+
/* STD */
@@ -151,3 +154,3 @@ QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zon
time_t utc = to_Time_t( dt, zone.m_name );
- qWarning( "%d %s", utc, zone.m_name.latin1() );
+ owarn << "" << utc << " " << zone.m_name << "" << oendl;
return utcTime( utc, m_name );
diff --git a/libopie2/opiepim/core/opimtodo.cpp b/libopie2/opiepim/core/opimtodo.cpp
index 47433e0..27b36a6 100644
--- a/libopie2/opiepim/core/opimtodo.cpp
+++ b/libopie2/opiepim/core/opimtodo.cpp
@@ -37,2 +37,4 @@
#include <opie2/opimresolver.h>
+#include <opie2/odebug.h>
+
#include <qpe/palmtopuidgen.h>
@@ -87,3 +89,3 @@ OPimTodo::OPimTodo( const OPimTodo &event )
data->ref();
- // qWarning("ref up");
+ // owarn << "ref up" << oendl;
}
@@ -94,6 +96,6 @@ OPimTodo::~OPimTodo()
- // qWarning("~OPimTodo " );
+ // owarn << "~OPimTodo " << oendl;
if ( data->deref() )
{
- // qWarning("OPimTodo::dereffing");
+ // owarn << "OPimTodo::dereffing" << oendl;
delete data;
@@ -112,3 +114,3 @@ OPimTodo::OPimTodo( bool completed, int priority,
{
- // qWarning("OPimTodoData " + summary);
+ // owarn << "OPimTodoData " + summary << oendl;
setCategories( category );
@@ -135,3 +137,3 @@ OPimTodo::OPimTodo( bool completed, int priority,
{
- // qWarning("OPimTodoData" + summary);
+ // owarn << "OPimTodoData" + summary << oendl;
setCategories( idsFromString( category.join( ";" ) ) );
@@ -308,3 +310,3 @@ void OPimTodo::setDescription( const QString &desc )
{
- // qWarning( "desc " + desc );
+ // owarn << "desc " + desc << oendl;
changeOrModify();
@@ -593,6 +595,6 @@ void OPimTodo::deref()
- // qWarning("deref in ToDoEvent");
+ // owarn << "deref in ToDoEvent" << oendl;
if ( data->deref() )
{
- // qWarning("deleting");
+ // owarn << "deleting" << oendl;
delete data;
@@ -608,3 +610,3 @@ OPimTodo &OPimTodo::operator=( const OPimTodo &item )
OPimRecord::operator=( item );
- //qWarning("operator= ref ");
+ //owarn << "operator= ref " << oendl;
item.data->ref();
@@ -651,3 +653,3 @@ void OPimTodo::changeOrModify()
{
- qWarning( "changeOrModify" );
+ owarn << "changeOrModify" << oendl;
data->deref();
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp
index c4adbbd..26a68a0 100644
--- a/libopie2/opiepim/core/otodoaccess.cpp
+++ b/libopie2/opiepim/core/otodoaccess.cpp
@@ -52,3 +52,3 @@ OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access )
OPimTodoAccess::~OPimTodoAccess() {
-// qWarning("~OPimTodoAccess");
+// owarn << "~OPimTodoAccess" << oendl;
}
diff --git a/libopie2/opiepim/ui/opimmainwindow.cpp b/libopie2/opiepim/ui/opimmainwindow.cpp
index 40dc297..8ce2062 100644
--- a/libopie2/opiepim/ui/opimmainwindow.cpp
+++ b/libopie2/opiepim/ui/opimmainwindow.cpp
@@ -28,5 +28,8 @@
*/
-#include <qapplication.h>
-#include <qdatetime.h>
-#include <qcopchannel_qws.h>
+
+#include "opimmainwindow.h"
+
+/* OPIE */
+#include <opie2/opimresolver.h>
+#include <opie2/odebug.h>
@@ -36,4 +39,8 @@
-#include <opie2/opimresolver.h>
-#include "opimmainwindow.h"
+/* QT */
+#include <qapplication.h>
+#include <qdatetime.h>
+#include <qcopchannel_qws.h>
+
+
@@ -118,3 +125,3 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array )
stream >> uid;
- qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid );
+ owarn << " Date: " << dt.toString() << " Uid: " << uid << "" << oendl;
QDateTime current = QDateTime::currentDateTime();