summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiedb/osqlbackendmanager.cpp12
-rw-r--r--libopie2/opiedb/osqlitedriver.cpp6
-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.cpp64
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp18
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp32
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp43
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp42
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp48
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp10
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp65
-rw-r--r--libopie2/opiepim/core/opimcontact.cpp18
-rw-r--r--libopie2/opiepim/core/opimcontactfields.cpp22
-rw-r--r--libopie2/opiepim/core/opimdateconversion.cpp12
-rw-r--r--libopie2/opiepim/core/opimevent.cpp6
-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, 272 insertions, 208 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,16 +1,22 @@
1
2#include "osqlbackendmanager.h"
3
4/* OPIE */
5#include <opie2/odebug.h>
6
7/* QT */
1#include <qdir.h> 8#include <qdir.h>
2#include <qmap.h> 9#include <qmap.h>
3 10
4#include "osqlbackendmanager.h"
5 11
6/** 12/**
7 * \todo FIXME CONFIG!!! 13 * \todo FIXME CONFIG!!!
8 */ 14 */
9 15
10namespace { 16namespace {
11 class Config { 17 class Config {
12 typedef QMap<QString, QString> List; 18 typedef QMap<QString, QString> List;
13 public: 19 public:
14 Config( const QString& fileName ); 20 Config( const QString& fileName );
15 /** 21 /**
16 * Quite simple layout in nature 22 * Quite simple layout in nature
@@ -29,25 +35,25 @@ namespace {
29 35
30 bool Config::load() { 36 bool Config::load() {
31 if (!QFile::exists( m_fileName ) ) 37 if (!QFile::exists( m_fileName ) )
32 return false; 38 return false;
33 QFile file( m_fileName ); 39 QFile file( m_fileName );
34 if (!file.open(IO_ReadOnly ) ) 40 if (!file.open(IO_ReadOnly ) )
35 return false; 41 return false;
36 QStringList list = QStringList::split( '\n', file.readAll() ); 42 QStringList list = QStringList::split( '\n', file.readAll() );
37 QStringList::Iterator it; 43 QStringList::Iterator it;
38 QString line; 44 QString line;
39 for (it = list.begin(); it != list.end(); ++it ) { 45 for (it = list.begin(); it != list.end(); ++it ) {
40 line = (*it).stripWhiteSpace(); 46 line = (*it).stripWhiteSpace();
41 qWarning("Anonymous::Config:" + line ); 47 owarn << "Anonymous::Config:" + line << oendl;
42 QStringList test = QStringList::split(' ', line ); 48 QStringList test = QStringList::split(' ', line );
43 m_list.insert( test[0], test[2] ); 49 m_list.insert( test[0], test[2] );
44 } 50 }
45 return true; 51 return true;
46 } 52 }
47 QString Config::value( const QString& key ) { 53 QString Config::value( const QString& key ) {
48 return m_list[key]; 54 return m_list[key];
49 } 55 }
50}; 56};
51 57
52 58
53using namespace Opie::DB; 59using namespace Opie::DB;
@@ -83,24 +89,24 @@ OSQLBackEnd::ValueList OSQLBackEndManager::scanDir( const QString& dirName ) {
83 for ( it = files.begin(); it != files.end(); ++it ) { 89 for ( it = files.begin(); it != files.end(); ++it ) {
84 list.append( file2backend( (*it) ) ); 90 list.append( file2backend( (*it) ) );
85 } 91 }
86 } 92 }
87 return list; 93 return list;
88} 94}
89 95
90/** 96/**
91 * read a config file and convert it to a OSQLBackEnd 97 * read a config file and convert it to a OSQLBackEnd
92 */ 98 */
93OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) { 99OSQLBackEnd OSQLBackEndManager::file2backend( const QString& file ) {
94 OSQLBackEnd end; 100 OSQLBackEnd end;
95 qWarning("fileName: " + file ); 101 owarn << "fileName: " + file << oendl;
96 Config cfg( file ); 102 Config cfg( file );
97 if (cfg.load() ) { 103 if (cfg.load() ) {
98 end.setName( cfg.value( "Name") ); 104 end.setName( cfg.value( "Name") );
99 end.setVendor( cfg.value("Vendor") ); 105 end.setVendor( cfg.value("Vendor") );
100 end.setLicense( cfg.value("License") ); 106 end.setLicense( cfg.value("License") );
101 end.setLibrary( cfg.value("Library").local8Bit() ); 107 end.setLibrary( cfg.value("Library").local8Bit() );
102 end.setDefault( cfg.value("Default").toInt() ); 108 end.setDefault( cfg.value("Default").toInt() );
103 end.setPreference( cfg.value("Preference").toInt() ); 109 end.setPreference( cfg.value("Preference").toInt() );
104 } 110 }
105 return end; 111 return end;
106} 112}
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
@@ -115,33 +115,33 @@ void rlikeFunc(sqlite_func *context, int arg, const char **argv){
115 sqlite_set_result_int(context, 115 sqlite_set_result_int(context,
116 sqliteRlikeCompare((const char*)argv[0], 116 sqliteRlikeCompare((const char*)argv[0],
117 (const char*)argv[1], (sqregex *)sqlite_user_data(context) )); 117 (const char*)argv[1], (sqregex *)sqlite_user_data(context) ));
118} 118}
119 119
120/* 120/*
121 * try to open a db specified via setUrl 121 * try to open a db specified via setUrl
122 * and options 122 * and options
123 */ 123 */
124bool OSQLiteDriver::open() { 124bool OSQLiteDriver::open() {
125 char *error; 125 char *error;
126 126
127 qDebug("OSQLiteDriver::open: about to open"); 127 odebug << "OSQLiteDriver::open: about to open" << oendl;
128 m_sqlite = sqlite_open(m_url.local8Bit(), 128 m_sqlite = sqlite_open(m_url.local8Bit(),
129 0, 129 0,
130 &error ); 130 &error );
131 131
132 /* failed to open */ 132 /* failed to open */
133 if (m_sqlite == 0l ) { 133 if (m_sqlite == 0l ) {
134 // FIXME set the last error 134 // FIXME set the last error
135 qWarning("OSQLiteDriver::open: %s", error ); 135 owarn << "OSQLiteDriver::open: " << error << "" << oendl;
136 free( error ); 136 free( error );
137 return false; 137 return false;
138 } 138 }
139 if (sqlite_create_function(m_sqlite,"rlike",2,rlikeFunc,&sqreg) != 0) 139 if (sqlite_create_function(m_sqlite,"rlike",2,rlikeFunc,&sqreg) != 0)
140 odebug << "Unable to create user defined function!" << oendl; 140 odebug << "Unable to create user defined function!" << oendl;
141 if (sqlite_function_type(m_sqlite,"rlike",SQLITE_NUMERIC) != 0) 141 if (sqlite_function_type(m_sqlite,"rlike",SQLITE_NUMERIC) != 0)
142 odebug << "Unable to set rlike function result type!" << oendl; 142 odebug << "Unable to set rlike function result type!" << oendl;
143 sqreg.regex_raw = NULL; 143 sqreg.regex_raw = NULL;
144 return true; 144 return true;
145} 145}
146 146
147 147
@@ -165,25 +165,25 @@ bool OSQLiteDriver::close() {
165/* Query */ 165/* Query */
166OSQLResult OSQLiteDriver::query( OSQLQuery* qu) { 166OSQLResult OSQLiteDriver::query( OSQLQuery* qu) {
167 if ( !m_sqlite ) { 167 if ( !m_sqlite ) {
168 // FIXME set error code 168 // FIXME set error code
169 OSQLResult result( OSQLResult::Failure ); 169 OSQLResult result( OSQLResult::Failure );
170 return result; 170 return result;
171 } 171 }
172 Query query; 172 Query query;
173 query.driver = this; 173 query.driver = this;
174 char *err; 174 char *err;
175 /* SQLITE_OK 0 if return code > 0 == failure */ 175 /* SQLITE_OK 0 if return code > 0 == failure */
176 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) { 176 if ( sqlite_exec(m_sqlite, qu->query(),&call_back, &query, &err) > 0 ) {
177 qWarning("OSQLiteDriver::query: Error while executing %s",err); 177 owarn << "OSQLiteDriver::query: Error while executing " << err << "" << oendl;
178 free(err ); 178 free(err );
179 // FixMe Errors 179 // FixMe Errors
180 } 180 }
181 181
182 OSQLResult result(OSQLResult::Success, 182 OSQLResult result(OSQLResult::Success,
183 query.items, 183 query.items,
184 query.errors ); 184 query.errors );
185 return result; 185 return result;
186} 186}
187 187
188 188
189OSQLTable::ValueList OSQLiteDriver::tables() const { 189OSQLTable::ValueList OSQLiteDriver::tables() const {
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
@@ -73,25 +73,25 @@ void OSoundSystem::synchronize()
73 if ( !hasFile ) 73 if ( !hasFile )
74 { 74 {
75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl; 75 odebug << "OSoundSystem: /dev/sound not existing. No sound devices available" << oendl;
76 return; 76 return;
77 } 77 }
78 QTextStream s( &f ); 78 QTextStream s( &f );
79 s.readLine(); 79 s.readLine();
80 s.readLine(); 80 s.readLine();
81 while ( !s.atEnd() ) 81 while ( !s.atEnd() )
82 { 82 {
83 s >> str; 83 s >> str;
84 str.truncate( str.find( ':' ) ); 84 str.truncate( str.find( ':' ) );
85 qDebug( "OSoundSystem: found interface '%s'", (const char*) str ); 85 odebug << "OSoundSystem: found interface '" << str << "'" << oendl;
86 OAudioInterface* iface; 86 OAudioInterface* iface;
87 iface = new OAudioInterface( this, (const char*) str ); 87 iface = new OAudioInterface( this, (const char*) str );
88 88
89 _interfaces.insert( str, iface ); 89 _interfaces.insert( str, iface );
90 s.readLine(); 90 s.readLine();
91 } 91 }
92*/ 92*/
93} 93}
94 94
95 95
96int OSoundSystem::count() const 96int OSoundSystem::count() const
97{ 97{
@@ -228,26 +228,26 @@ void OMixerInterface::init()
228 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD ); 228 if ( devmask & ( 1 << SOUND_MIXER_CD ) ) _channels.insert( "RecCD", SOUND_MIXER_CD );
229 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX ); 229 if ( devmask & ( 1 << SOUND_MIXER_IMIX ) ) _channels.insert( "RecInputMix", SOUND_MIXER_IMIX );
230 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM ); 230 if ( devmask & ( 1 << SOUND_MIXER_ALTPCM ) ) _channels.insert( "RecAltPCM", SOUND_MIXER_ALTPCM );
231 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV ); 231 if ( devmask & ( 1 << SOUND_MIXER_RECLEV ) ) _channels.insert( "RecRecord", SOUND_MIXER_RECLEV );
232 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN ); 232 if ( devmask & ( 1 << SOUND_MIXER_IGAIN ) ) _channels.insert( "RecInputGain", SOUND_MIXER_IGAIN );
233 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN ); 233 if ( devmask & ( 1 << SOUND_MIXER_OGAIN ) ) _channels.insert( "RecOutputGain", SOUND_MIXER_OGAIN );
234 //odebug << "recmask available and constructed." << oendl; 234 //odebug << "recmask available and constructed." << oendl;
235 } 235 }
236 236
237/* ChannelIterator it; 237/* ChannelIterator it;
238 for ( it = _channels.begin(); it != _channels.end(); ++it ) 238 for ( it = _channels.begin(); it != _channels.end(); ++it )
239 { 239 {
240 qDebug( "Channel %s available (bit %d)", (const char*) it.key(), it.data() ); 240 odebug << "Channel " << it.key() << " available (bit " << it.data() << ")" << oendl;
241 qDebug( " +--- Volume: %02d | %02d", volume( it.key() ) & 0xff, volume( it.key() ) >> 8 ); 241 odebug << " +--- Volume: " << volume( it.key() ) & 0xff << " | " << volume( it.key() ) >> 8 << "" << oendl;
242 } 242 }
243*/ 243*/
244} 244}
245 245
246QStringList OMixerInterface::allChannels() const 246QStringList OMixerInterface::allChannels() const
247{ 247{
248 ChannelIterator it = _channels.begin(); 248 ChannelIterator it = _channels.begin();
249 QStringList channels; 249 QStringList channels;
250 while ( it != _channels.end() ) 250 while ( it != _channels.end() )
251 { 251 {
252 channels += it.key(); 252 channels += it.key();
253 it++; 253 it++;
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
@@ -596,28 +596,31 @@ void OWirelessNetworkInterface::buildPrivateList()
596 for ( int i = 0; i < _iwr.u.data.length; ++i ) 596 for ( int i = 0; i < _iwr.u.data.length; ++i )
597 { 597 {
598 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args ); 598 new OPrivateIOCTL( this, priv[i].name, priv[i].cmd, priv[i].get_args, priv[i].set_args );
599 } 599 }
600 odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl; 600 odebug << "OWirelessNetworkInterface::buildPrivateList(): Private ioctl list constructed." << oendl;
601} 601}
602 602
603 603
604void OWirelessNetworkInterface::dumpInformation() const 604void OWirelessNetworkInterface::dumpInformation() const
605{ 605{
606 odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl; 606 odebug << "OWirelessNetworkInterface::() -------------- dumping information block ----------------" << oendl;
607 607
608 qDebug( " - driver's idea of maximum throughput is %d bps = %d byte/s = %d Kb/s = %f.2 Mb/s", 608 odebug << " - driver's idea of maximum throughput is " << _range.throughput
609 _range.throughput, _range.throughput / 8, _range.throughput / 8 / 1024, float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 ); 609 << " bps = " << ( _range.throughput / 8 ) << " byte/s = " << ( _range.throughput / 8 / 1024 )
610 qDebug( " - driver for '%s' (V%d) has been compiled against WE V%d", 610 << " Kb/s = " << QString().sprintf("%f.2", float( _range.throughput ) / 8.0 / 1024.0 / 1024.0 )
611 name(), _range.we_version_source, _range.we_version_compiled ); 611 << " Mb/s" << oendl;
612
613 odebug << " - driver for '" << name() << "' (V" << _range.we_version_source
614 << ") has been compiled against WE V" << _range.we_version_compiled << oendl;
612 615
613 if ( _range.we_version_compiled != WIRELESS_EXT ) 616 if ( _range.we_version_compiled != WIRELESS_EXT )
614 { 617 {
615 owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl; 618 owarn << "Version mismatch! WE_DRIVER = " << _range.we_version_compiled << " and WE_OPIENET = " << WIRELESS_EXT << oendl;
616 } 619 }
617 620
618 odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl; 621 odebug << "OWirelessNetworkInterface::() ---------------------------------------------------------" << oendl;
619} 622}
620 623
621 624
622int OWirelessNetworkInterface::channel() const 625int OWirelessNetworkInterface::channel() const
623{ 626{
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
@@ -53,20 +53,20 @@ OStation::OStation()
53} 53}
54 54
55 55
56OStation::~OStation() 56OStation::~OStation()
57{ 57{
58 odebug << "OStation::~OStation()" << oendl; 58 odebug << "OStation::~OStation()" << oendl;
59} 59}
60 60
61 61
62void OStation::dump() 62void OStation::dump()
63{ 63{
64 odebug << "------- OStation::dump() ------------" << oendl; 64 odebug << "------- OStation::dump() ------------" << oendl;
65 qDebug( "type: %s", (const char*) type ); 65 odebug << "type: " << type << "" << oendl;
66 qDebug( "mac: %s", (const char*) macAddress.toString() ); 66 odebug << "mac: " << macAddress.toString() << "" << oendl;
67 qDebug( "ap: %s", (const char*) apAddress.toString() ); 67 odebug << "ap: " << apAddress.toString() << "" << oendl;
68 qDebug( "ip: %s", (const char*) ipAddress.toString() ); 68 odebug << "ip: " << ipAddress.toString() << "" << oendl;
69} 69}
70 70
71} 71}
72} 72}
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
@@ -23,38 +23,42 @@
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * SQL Backend for the OPIE-Contact Database. 30 * SQL Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33#include "ocontactaccessbackend_sql.h" 33#include "ocontactaccessbackend_sql.h"
34 34
35#include <qarray.h> 35/* OPIE */
36#include <qdatetime.h>
37#include <qstringlist.h>
38
39#include <qpe/global.h>
40#include <qpe/recordfields.h>
41
42#include <opie2/opimcontact.h> 36#include <opie2/opimcontact.h>
43#include <opie2/opimcontactfields.h> 37#include <opie2/opimcontactfields.h>
44#include <opie2/opimdateconversion.h> 38#include <opie2/opimdateconversion.h>
45#include <opie2/osqldriver.h> 39#include <opie2/osqldriver.h>
46#include <opie2/osqlresult.h> 40#include <opie2/osqlresult.h>
47#include <opie2/osqlmanager.h> 41#include <opie2/osqlmanager.h>
48#include <opie2/osqlquery.h> 42#include <opie2/osqlquery.h>
43#include <opie2/odebug.h>
44
45#include <qpe/global.h>
46#include <qpe/recordfields.h>
47
48/* QT */
49#include <qarray.h>
50#include <qdatetime.h>
51#include <qstringlist.h>
52
49 53
50using namespace Opie; 54using namespace Opie;
51using namespace Opie::DB; 55using namespace Opie::DB;
52 56
53 57
54/* 58/*
55 * Implementation of used query types * CREATE query 59 * Implementation of used query types * CREATE query
56 * LOAD query 60 * LOAD query
57 * INSERT 61 * INSERT
58 * REMOVE 62 * REMOVE
59 * CLEAR 63 * CLEAR
60 */ 64 */
@@ -259,25 +263,25 @@ namespace {
259 + QString::number( m_contact.uid() ) 263 + QString::number( m_contact.uid() )
260 + "," 264 + ","
261 + QString::number( id++ ) 265 + QString::number( id++ )
262 + ",'" 266 + ",'"
263 + it.key() 267 + it.key()
264 + "'," 268 + "',"
265 + "0" // Priority for future enhancements 269 + "0" // Priority for future enhancements
266 + ",'" 270 + ",'"
267 + it.data() 271 + it.data()
268 + "');"; 272 + "');";
269 } 273 }
270 // qu += "commit;"; 274 // qu += "commit;";
271 qDebug("add %s", qu.latin1() ); 275 odebug << "add " << qu << "" << oendl;
272 return qu; 276 return qu;
273 } 277 }
274 278
275 279
276 RemoveQuery::RemoveQuery(int uid ) 280 RemoveQuery::RemoveQuery(int uid )
277 : OSQLQuery(), m_uid( uid ) {} 281 : OSQLQuery(), m_uid( uid ) {}
278 RemoveQuery::~RemoveQuery() {} 282 RemoveQuery::~RemoveQuery() {}
279 QString RemoveQuery::query()const { 283 QString RemoveQuery::query()const {
280 QString qu = "DELETE from addressbook where uid = " 284 QString qu = "DELETE from addressbook where uid = "
281 + QString::number(m_uid) + ";"; 285 + QString::number(m_uid) + ";";
282 qu += "DELETE from custom_data where uid = " 286 qu += "DELETE from custom_data where uid = "
283 + QString::number(m_uid) + ";"; 287 + QString::number(m_uid) + ";";
@@ -307,25 +311,25 @@ namespace {
307 QString qu = "select uid, type, value from addressbook where"; 311 QString qu = "select uid, type, value from addressbook where";
308 for (uint i = 0; i < m_uids.count(); i++ ) { 312 for (uint i = 0; i < m_uids.count(); i++ ) {
309 qu += " UID = " + QString::number( m_uids[i] ) + " OR"; 313 qu += " UID = " + QString::number( m_uids[i] ) + " OR";
310 } 314 }
311 qu.remove( qu.length()-2, 2 ); // Hmmmm.. 315 qu.remove( qu.length()-2, 2 ); // Hmmmm..
312 return qu; 316 return qu;
313 } 317 }
314 */ 318 */
315 QString FindQuery::single()const{ 319 QString FindQuery::single()const{
316 QString qu = "select *"; 320 QString qu = "select *";
317 qu += " from addressbook where uid = " + QString::number(m_uid); 321 qu += " from addressbook where uid = " + QString::number(m_uid);
318 322
319 // qWarning("find query: %s", qu.latin1() ); 323 // owarn << "find query: " << qu << "" << oendl;
320 return qu; 324 return qu;
321 } 325 }
322 326
323 327
324 FindCustomQuery::FindCustomQuery(int uid) 328 FindCustomQuery::FindCustomQuery(int uid)
325 : OSQLQuery(), m_uid( uid ) { 329 : OSQLQuery(), m_uid( uid ) {
326 } 330 }
327 FindCustomQuery::FindCustomQuery(const QArray<int>& ints) 331 FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
328 : OSQLQuery(), m_uids( ints ){ 332 : OSQLQuery(), m_uids( ints ){
329 } 333 }
330 FindCustomQuery::~FindCustomQuery() { 334 FindCustomQuery::~FindCustomQuery() {
331 } 335 }
@@ -341,42 +345,42 @@ namespace {
341 345
342}; 346};
343 347
344 348
345/* --------------------------------------------------------------------------- */ 349/* --------------------------------------------------------------------------- */
346 350
347namespace Opie { 351namespace Opie {
348 352
349OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* appname */, 353OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* appname */,
350 const QString& filename ): 354 const QString& filename ):
351 OPimContactAccessBackend(), m_changed(false), m_driver( NULL ) 355 OPimContactAccessBackend(), m_changed(false), m_driver( NULL )
352{ 356{
353 qDebug("C'tor OPimContactAccessBackend_SQL starts"); 357 odebug << "C'tor OPimContactAccessBackend_SQL starts" << oendl;
354 QTime t; 358 QTime t;
355 t.start(); 359 t.start();
356 360
357 /* Expecting to access the default filename if nothing else is set */ 361 /* Expecting to access the default filename if nothing else is set */
358 if ( filename.isEmpty() ){ 362 if ( filename.isEmpty() ){
359 m_fileName = Global::applicationFileName( "addressbook","addressbook.db" ); 363 m_fileName = Global::applicationFileName( "addressbook","addressbook.db" );
360 } else 364 } else
361 m_fileName = filename; 365 m_fileName = filename;
362 366
363 // Get the standart sql-driver from the OSQLManager.. 367 // Get the standart sql-driver from the OSQLManager..
364 OSQLManager man; 368 OSQLManager man;
365 m_driver = man.standard(); 369 m_driver = man.standard();
366 m_driver->setUrl( m_fileName ); 370 m_driver->setUrl( m_fileName );
367 371
368 load(); 372 load();
369 373
370 qDebug("C'tor OPimContactAccessBackend_SQL ends: %d ms", t.elapsed() ); 374 odebug << "C'tor OPimContactAccessBackend_SQL ends: " << t.elapsed() << " ms" << oendl;
371} 375}
372 376
373OPimContactAccessBackend_SQL::~OPimContactAccessBackend_SQL () 377OPimContactAccessBackend_SQL::~OPimContactAccessBackend_SQL ()
374{ 378{
375 if( m_driver ) 379 if( m_driver )
376 delete m_driver; 380 delete m_driver;
377} 381}
378 382
379bool OPimContactAccessBackend_SQL::load () 383bool OPimContactAccessBackend_SQL::load ()
380{ 384{
381 if (!m_driver->open() ) 385 if (!m_driver->open() )
382 return false; 386 return false;
@@ -421,25 +425,25 @@ QArray<int> OPimContactAccessBackend_SQL::allRecords() const
421{ 425{
422 426
423 // FIXME: Think about cute handling of changed tables.. 427 // FIXME: Think about cute handling of changed tables..
424 // Thus, we don't have to call update here... 428 // Thus, we don't have to call update here...
425 if ( m_changed ) 429 if ( m_changed )
426 ((OPimContactAccessBackend_SQL*)this)->update(); 430 ((OPimContactAccessBackend_SQL*)this)->update();
427 431
428 return m_uids; 432 return m_uids;
429} 433}
430 434
431bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact ) 435bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact )
432{ 436{
433 qDebug("add in contact SQL-Backend"); 437 odebug << "add in contact SQL-Backend" << oendl;
434 InsertQuery ins( newcontact ); 438 InsertQuery ins( newcontact );
435 OSQLResult res = m_driver->query( &ins ); 439 OSQLResult res = m_driver->query( &ins );
436 440
437 if ( res.state() == OSQLResult::Failure ) 441 if ( res.state() == OSQLResult::Failure )
438 return false; 442 return false;
439 443
440 int c = m_uids.count(); 444 int c = m_uids.count();
441 m_uids.resize( c+1 ); 445 m_uids.resize( c+1 );
442 m_uids[c] = newcontact.uid(); 446 m_uids[c] = newcontact.uid();
443 447
444 return true; 448 return true;
445} 449}
@@ -460,32 +464,32 @@ bool OPimContactAccessBackend_SQL::remove ( int uid )
460 464
461bool OPimContactAccessBackend_SQL::replace ( const OPimContact &contact ) 465bool OPimContactAccessBackend_SQL::replace ( const OPimContact &contact )
462{ 466{
463 if ( !remove( contact.uid() ) ) 467 if ( !remove( contact.uid() ) )
464 return false; 468 return false;
465 469
466 return add( contact ); 470 return add( contact );
467} 471}
468 472
469 473
470OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const 474OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const
471{ 475{
472 qDebug("OPimContactAccessBackend_SQL::find()"); 476 odebug << "OPimContactAccessBackend_SQL::find()" << oendl;
473 QTime t; 477 QTime t;
474 t.start(); 478 t.start();
475 479
476 OPimContact retContact( requestNonCustom( uid ) ); 480 OPimContact retContact( requestNonCustom( uid ) );
477 retContact.setExtraMap( requestCustom( uid ) ); 481 retContact.setExtraMap( requestCustom( uid ) );
478 482
479 qDebug("OPimContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() ); 483 odebug << "OPimContactAccessBackend_SQL::find() needed: " << t.elapsed() << " ms" << oendl;
480 return retContact; 484 return retContact;
481} 485}
482 486
483 487
484 488
485QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, const QDateTime& qd ) 489QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &query, int settings, const QDateTime& qd )
486{ 490{
487 QString qu = "SELECT uid FROM addressbook WHERE"; 491 QString qu = "SELECT uid FROM addressbook WHERE";
488 QString searchQuery =""; 492 QString searchQuery ="";
489 493
490 QDate startDate; 494 QDate startDate;
491 495
@@ -576,25 +580,25 @@ QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &qu
576 searchQuery += "(\"" + *it + "\"" + " GLOB " + "'" 580 searchQuery += "(\"" + *it + "\"" + " GLOB " + "'"
577 + queryStr + "'" + ")"; 581 + queryStr + "'" + ")";
578 582
579 } 583 }
580 } 584 }
581 } 585 }
582 // Skip trailing "AND" 586 // Skip trailing "AND"
583 // if ( isAnyFieldSelected ) 587 // if ( isAnyFieldSelected )
584 // qu = qu.left( qu.length() - 4 ); 588 // qu = qu.left( qu.length() - 4 );
585 589
586 qu += searchQuery; 590 qu += searchQuery;
587 591
588 qDebug( "queryByExample query: %s", qu.latin1() ); 592 odebug << "queryByExample query: " << qu << "" << oendl;
589 593
590 // Execute query and return the received uid's 594 // Execute query and return the received uid's
591 OSQLRawQuery raw( qu ); 595 OSQLRawQuery raw( qu );
592 OSQLResult res = m_driver->query( &raw ); 596 OSQLResult res = m_driver->query( &raw );
593 if ( res.state() != OSQLResult::Success ){ 597 if ( res.state() != OSQLResult::Success ){
594 QArray<int> empty; 598 QArray<int> empty;
595 return empty; 599 return empty;
596 } 600 }
597 601
598 QArray<int> list = extractUids( res ); 602 QArray<int> list = extractUids( res );
599 603
600 return list; 604 return list;
@@ -611,25 +615,25 @@ QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
611 QString searchlist; 615 QString searchlist;
612 616
613 QStringList fieldList = OPimContactFields::untrfields( false ); 617 QStringList fieldList = OPimContactFields::untrfields( false );
614 // QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); 618 // QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
615 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 619 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
616 if ( !searchlist.isEmpty() ) 620 if ( !searchlist.isEmpty() )
617 searchlist += " OR "; 621 searchlist += " OR ";
618 searchlist += " rlike(\""+ r.pattern() + "\",\"" + *it + "\") "; 622 searchlist += " rlike(\""+ r.pattern() + "\",\"" + *it + "\") ";
619 } 623 }
620 624
621 qu = qu + searchlist + ")"; 625 qu = qu + searchlist + ")";
622 626
623 qDebug( "query: %s", qu.latin1() ); 627 odebug << "query: " << qu << "" << oendl;
624 628
625 OSQLRawQuery raw( qu ); 629 OSQLRawQuery raw( qu );
626 OSQLResult res = m_driver->query( &raw ); 630 OSQLResult res = m_driver->query( &raw );
627 631
628 return extractUids( res ); 632 return extractUids( res );
629 633
630 634
631#endif 635#endif
632} 636}
633 637
634const uint OPimContactAccessBackend_SQL::querySettings() 638const uint OPimContactAccessBackend_SQL::querySettings()
635{ 639{
@@ -692,77 +696,77 @@ bool OPimContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
692 696
693QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) 697QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int )
694{ 698{
695 QTime t; 699 QTime t;
696 t.start(); 700 t.start();
697 701
698 QString query = "SELECT uid FROM addressbook "; 702 QString query = "SELECT uid FROM addressbook ";
699 query += "ORDER BY \"Last Name\" "; 703 query += "ORDER BY \"Last Name\" ";
700 704
701 if ( !asc ) 705 if ( !asc )
702 query += "DESC"; 706 query += "DESC";
703 707
704 // qDebug("sorted query is: %s", query.latin1() ); 708 // odebug << "sorted query is: " << query << "" << oendl;
705 709
706 OSQLRawQuery raw( query ); 710 OSQLRawQuery raw( query );
707 OSQLResult res = m_driver->query( &raw ); 711 OSQLResult res = m_driver->query( &raw );
708 if ( res.state() != OSQLResult::Success ){ 712 if ( res.state() != OSQLResult::Success ){
709 QArray<int> empty; 713 QArray<int> empty;
710 return empty; 714 return empty;
711 } 715 }
712 716
713 QArray<int> list = extractUids( res ); 717 QArray<int> list = extractUids( res );
714 718
715 qDebug("sorted needed %d ms!", t.elapsed() ); 719 odebug << "sorted needed " << t.elapsed() << " ms!" << oendl;
716 return list; 720 return list;
717} 721}
718 722
719 723
720void OPimContactAccessBackend_SQL::update() 724void OPimContactAccessBackend_SQL::update()
721{ 725{
722 qDebug("Update starts"); 726 odebug << "Update starts" << oendl;
723 QTime t; 727 QTime t;
724 t.start(); 728 t.start();
725 729
726 // Now load the database set and extract the uid's 730 // Now load the database set and extract the uid's
727 // which will be held locally 731 // which will be held locally
728 732
729 LoadQuery lo; 733 LoadQuery lo;
730 OSQLResult res = m_driver->query(&lo); 734 OSQLResult res = m_driver->query(&lo);
731 if ( res.state() != OSQLResult::Success ) 735 if ( res.state() != OSQLResult::Success )
732 return; 736 return;
733 737
734 m_uids = extractUids( res ); 738 m_uids = extractUids( res );
735 739
736 m_changed = false; 740 m_changed = false;
737 741
738 qDebug("Update ends %d ms", t.elapsed() ); 742 odebug << "Update ends " << t.elapsed() << " ms" << oendl;
739} 743}
740 744
741QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const 745QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
742{ 746{
743 qDebug("extractUids"); 747 odebug << "extractUids" << oendl;
744 QTime t; 748 QTime t;
745 t.start(); 749 t.start();
746 OSQLResultItem::ValueList list = res.results(); 750 OSQLResultItem::ValueList list = res.results();
747 OSQLResultItem::ValueList::Iterator it; 751 OSQLResultItem::ValueList::Iterator it;
748 QArray<int> ints(list.count() ); 752 QArray<int> ints(list.count() );
749 qDebug(" count = %d", list.count() ); 753 odebug << " count = " << list.count() << "" << oendl;
750 754
751 int i = 0; 755 int i = 0;
752 for (it = list.begin(); it != list.end(); ++it ) { 756 for (it = list.begin(); it != list.end(); ++it ) {
753 ints[i] = (*it).data("uid").toInt(); 757 ints[i] = (*it).data("uid").toInt();
754 i++; 758 i++;
755 } 759 }
756 qDebug("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); 760 odebug << "extractUids ready: count2 = " << i << " needs " << t.elapsed() << " ms" << oendl;
757 761
758 return ints; 762 return ints;
759 763
760} 764}
761 765
762QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const 766QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) const
763{ 767{
764 QTime t; 768 QTime t;
765 t.start(); 769 t.start();
766 770
767 QMap<int, QString> nonCustomMap; 771 QMap<int, QString> nonCustomMap;
768 772
@@ -779,74 +783,74 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co
779 QTime t3; 783 QTime t3;
780 t3.start(); 784 t3.start();
781 // Now loop through all columns 785 // Now loop through all columns
782 QStringList fieldList = OPimContactFields::untrfields( false ); 786 QStringList fieldList = OPimContactFields::untrfields( false );
783 QMap<QString, int> translate = OPimContactFields::untrFieldsToId(); 787 QMap<QString, int> translate = OPimContactFields::untrFieldsToId();
784 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 788 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
785 // Get data for the selected column and store it with the 789 // Get data for the selected column and store it with the
786 // corresponding id into the map.. 790 // corresponding id into the map..
787 791
788 int id = translate[*it]; 792 int id = translate[*it];
789 QString value = resItem.data( (*it) ); 793 QString value = resItem.data( (*it) );
790 794
791 // qDebug("Reading %s... found: %s", (*it).latin1(), value.latin1() ); 795 // odebug << "Reading " << (*it) << "... found: " << value << "" << oendl;
792 796
793 switch( id ){ 797 switch( id ){
794 case Qtopia::Birthday: 798 case Qtopia::Birthday:
795 case Qtopia::Anniversary:{ 799 case Qtopia::Anniversary:{
796 // Birthday and Anniversary are encoded special ( yyyy-mm-dd ) 800 // Birthday and Anniversary are encoded special ( yyyy-mm-dd )
797 QStringList list = QStringList::split( '-', value ); 801 QStringList list = QStringList::split( '-', value );
798 QStringList::Iterator lit = list.begin(); 802 QStringList::Iterator lit = list.begin();
799 int year = (*lit).toInt(); 803 int year = (*lit).toInt();
800 int month = (*(++lit)).toInt(); 804 int month = (*(++lit)).toInt();
801 int day = (*(++lit)).toInt(); 805 int day = (*(++lit)).toInt();
802 if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){ 806 if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){
803 QDate date( year, month, day ); 807 QDate date( year, month, day );
804 nonCustomMap.insert( id, OPimDateConversion::dateToString( date ) ); 808 nonCustomMap.insert( id, OPimDateConversion::dateToString( date ) );
805 } 809 }
806 } 810 }
807 break; 811 break;
808 case Qtopia::AddressCategory: 812 case Qtopia::AddressCategory:
809 qDebug("Category is: %s", value.latin1() ); 813 odebug << "Category is: " << value << "" << oendl;
810 default: 814 default:
811 nonCustomMap.insert( id, value ); 815 nonCustomMap.insert( id, value );
812 } 816 }
813 } 817 }
814 818
815 // First insert uid 819 // First insert uid
816 nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) ); 820 nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) );
817 t3needed = t3.elapsed(); 821 t3needed = t3.elapsed();
818 822
819 // qDebug("Adding UID: %s", resItem.data( "uid" ).latin1() ); 823 // odebug << "Adding UID: " << resItem.data( "uid" ) << "" << oendl;
820 qDebug("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", 824 odebug << "RequestNonCustom needed: insg.:" << t.elapsed() << " ms, query: " << t2needed
821 t.elapsed(), t2needed, t3needed ); 825 << " ms, mapping: " << t3needed << " ms" << oendl;
822 826
823 return nonCustomMap; 827 return nonCustomMap;
824} 828}
825 829
826QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) const 830QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) const
827{ 831{
828 QTime t; 832 QTime t;
829 t.start(); 833 t.start();
830 834
831 QMap<QString, QString> customMap; 835 QMap<QString, QString> customMap;
832 836
833 FindCustomQuery query( uid ); 837 FindCustomQuery query( uid );
834 OSQLResult res_custom = m_driver->query( &query ); 838 OSQLResult res_custom = m_driver->query( &query );
835 839
836 if ( res_custom.state() == OSQLResult::Failure ) { 840 if ( res_custom.state() == OSQLResult::Failure ) {
837 qWarning("OSQLResult::Failure in find query !!"); 841 owarn << "OSQLResult::Failure in find query !!" << oendl;
838 QMap<QString, QString> empty; 842 QMap<QString, QString> empty;
839 return empty; 843 return empty;
840 } 844 }
841 845
842 OSQLResultItem::ValueList list = res_custom.results(); 846 OSQLResultItem::ValueList list = res_custom.results();
843 OSQLResultItem::ValueList::Iterator it = list.begin(); 847 OSQLResultItem::ValueList::Iterator it = list.begin();
844 for ( ; it != list.end(); ++it ) { 848 for ( ; it != list.end(); ++it ) {
845 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); 849 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
846 } 850 }
847 851
848 qDebug("RequestCustom needed: %d ms", t.elapsed() ); 852 odebug << "RequestCustom needed: " << t.elapsed() << " ms" << oendl;
849 return customMap; 853 return customMap;
850} 854}
851 855
852} 856}
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
@@ -26,24 +26,26 @@
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * VCard Backend for the OPIE-Contact Database. 30 * VCard Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33 33
34#include "vobject_p.h" 34#include "vobject_p.h"
35 35
36/* OPIE */ 36/* OPIE */
37#include <opie2/ocontactaccessbackend_vcard.h> 37#include <opie2/ocontactaccessbackend_vcard.h>
38#include <opie2/odebug.h>
39
38#include <qpe/timeconversion.h> 40#include <qpe/timeconversion.h>
39 41
40//FIXME: Hack to allow direct access to FILE* fh. Rewrite this! 42//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
41#define protected public 43#define protected public
42#include <qfile.h> 44#include <qfile.h>
43#undef protected 45#undef protected
44 46
45namespace Opie { 47namespace Opie {
46 48
47OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ): 49OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString& , const QString& filename ):
48 m_dirty( false ), 50 m_dirty( false ),
49 m_file( filename ) 51 m_file( filename )
@@ -55,38 +57,38 @@ OPimContactAccessBackend_VCard::OPimContactAccessBackend_VCard ( const QString&
55bool OPimContactAccessBackend_VCard::load () 57bool OPimContactAccessBackend_VCard::load ()
56{ 58{
57 m_map.clear(); 59 m_map.clear();
58 m_dirty = false; 60 m_dirty = false;
59 61
60 VObject* obj = 0l; 62 VObject* obj = 0l;
61 63
62 if ( QFile::exists(m_file) ){ 64 if ( QFile::exists(m_file) ){
63 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 65 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
64 if ( !obj ) 66 if ( !obj )
65 return false; 67 return false;
66 }else{ 68 }else{
67 qWarning("File \"%s\" not found !", m_file.latin1() ); 69 owarn << "File \"" << m_file << "\" not found !" << oendl;
68 return false; 70 return false;
69 } 71 }
70 72
71 while ( obj ) { 73 while ( obj ) {
72 OPimContact con = parseVObject( obj ); 74 OPimContact con = parseVObject( obj );
73 /* 75 /*
74 * if uid is 0 assign a new one 76 * if uid is 0 assign a new one
75 * this at least happens on 77 * this at least happens on
76 * Nokia6210 78 * Nokia6210
77 */ 79 */
78 if ( con.uid() == 0 ){ 80 if ( con.uid() == 0 ){
79 con.setUid( 1 ); 81 con.setUid( 1 );
80 qWarning("assigned new uid %d",con.uid() ); 82 owarn << "assigned new uid " << con.uid() << "" << oendl;
81 } 83 }
82 84
83 m_map.insert( con.uid(), con ); 85 m_map.insert( con.uid(), con );
84 86
85 VObject *t = obj; 87 VObject *t = obj;
86 obj = nextVObjectInList(obj); 88 obj = nextVObjectInList(obj);
87 cleanVObject( t ); 89 cleanVObject( t );
88 } 90 }
89 91
90 return true; 92 return true;
91 93
92} 94}
@@ -307,25 +309,25 @@ OPimContact OPimContactAccessBackend_VCard::parseVObject( VObject *obj )
307 type |= PAGER; 309 type |= PAGER;
308 else if ( name == VCPreferredProp ) 310 else if ( name == VCPreferredProp )
309 ; 311 ;
310 else 312 else
311 type |= UNKNOWN; 313 type |= UNKNOWN;
312 } 314 }
313 if ( (type & UNKNOWN) != UNKNOWN ) { 315 if ( (type & UNKNOWN) != UNKNOWN ) {
314 if ( ( type & (HOME|WORK) ) == 0 ) // default 316 if ( ( type & (HOME|WORK) ) == 0 ) // default
315 type |= HOME; 317 type |= HOME;
316 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 318 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
317 type |= VOICE; 319 type |= VOICE;
318 320
319 qWarning("value %s %d", value.data(), type ); 321 owarn << "value " << value.data() << " " << type << "" << oendl;
320 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) 322 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
321 c.setHomePhone( value ); 323 c.setHomePhone( value );
322 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 324 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
323 c.setHomeFax( value ); 325 c.setHomeFax( value );
324 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 326 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
325 c.setHomeMobile( value ); 327 c.setHomeMobile( value );
326 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) 328 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
327 c.setBusinessPhone( value ); 329 c.setBusinessPhone( value );
328 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 330 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
329 c.setBusinessFax( value ); 331 c.setBusinessFax( value );
330 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 332 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
331 c.setBusinessMobile( value ); 333 c.setBusinessMobile( value );
@@ -501,44 +503,44 @@ VObject* OPimContactAccessBackend_VCard::createVObject( const OPimContact &c )
501 503
502 QStringList emails = c.emailList(); 504 QStringList emails = c.emailList();
503 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 505 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
504 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 506 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
505 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 507 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
506 safeAddProp( email, VCInternetProp ); 508 safeAddProp( email, VCInternetProp );
507 } 509 }
508 510
509 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 511 safeAddPropValue( vcard, VCNoteProp, c.notes() );
510 512
511 // Exporting Birthday regarding RFC 2425 (5.8.4) 513 // Exporting Birthday regarding RFC 2425 (5.8.4)
512 if ( c.birthday().isValid() ){ 514 if ( c.birthday().isValid() ){
513 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 515 owarn << "Exporting birthday as: " << convDateToVCardDate( c.birthday() ) << "" << oendl;
514 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 516 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
515 } 517 }
516 518
517 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 519 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
518 VObject *org = safeAddProp( vcard, VCOrgProp ); 520 VObject *org = safeAddProp( vcard, VCOrgProp );
519 safeAddPropValue( org, VCOrgNameProp, c.company() ); 521 safeAddPropValue( org, VCOrgNameProp, c.company() );
520 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 522 safeAddPropValue( org, VCOrgUnitProp, c.department() );
521 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 523 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
522 } 524 }
523 525
524 // some values we have to export as custom fields 526 // some values we have to export as custom fields
525 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 527 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
526 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 528 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
527 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 529 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
528 530
529 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 531 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
530 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 532 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
531 if ( c.anniversary().isValid() ){ 533 if ( c.anniversary().isValid() ){
532 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); 534 owarn << "Exporting anniversary as: " << convDateToVCardDate( c.anniversary() ) << "" << oendl;
533 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 535 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
534 } 536 }
535 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 537 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
536 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 538 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
537 539
538 return vcard; 540 return vcard;
539} 541}
540 542
541QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const 543QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
542{ 544{
543 QString str_rfc2425 = QString("%1-%2-%3") 545 QString str_rfc2425 = QString("%1-%2-%3")
544 .arg( d.year() ) 546 .arg( d.year() )
@@ -549,39 +551,39 @@ QString OPimContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) co
549 while ( ( pos = str_rfc2425.find (' ') ) > 0 ) 551 while ( ( pos = str_rfc2425.find (' ') ) > 0 )
550 str_rfc2425.replace( pos, 1, "0" ); 552 str_rfc2425.replace( pos, 1, "0" );
551 553
552 return str_rfc2425; 554 return str_rfc2425;
553} 555}
554 556
555QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) 557QDate OPimContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
556{ 558{
557 int monthPos = datestr.find('-'); 559 int monthPos = datestr.find('-');
558 int dayPos = datestr.find('-', monthPos+1 ); 560 int dayPos = datestr.find('-', monthPos+1 );
559 int sep_ignore = 1; 561 int sep_ignore = 1;
560 if ( monthPos == -1 || dayPos == -1 ) { 562 if ( monthPos == -1 || dayPos == -1 ) {
561 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 563 odebug << "fromString didn't find - in str = " << datestr << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
562 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) 564 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
563 if ( datestr.length() == 8 ){ 565 if ( datestr.length() == 8 ){
564 monthPos = 4; 566 monthPos = 4;
565 dayPos = 6; 567 dayPos = 6;
566 sep_ignore = 0; 568 sep_ignore = 0;
567 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 569 odebug << "Try with follwing positions str = " << datestr << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
568 } else { 570 } else {
569 return QDate(); 571 return QDate();
570 } 572 }
571 } 573 }
572 int y = datestr.left( monthPos ).toInt(); 574 int y = datestr.left( monthPos ).toInt();
573 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); 575 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
574 int d = datestr.mid( dayPos + sep_ignore ).toInt(); 576 int d = datestr.mid( dayPos + sep_ignore ).toInt();
575 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); 577 odebug << "TimeConversion::fromString ymd = " << datestr << " => " << y << " " << m << " " << d << "; mpos = " << monthPos << " ypos = " << dayPos << "" << oendl;
576 QDate date ( y,m,d ); 578 QDate date ( y,m,d );
577 return date; 579 return date;
578} 580}
579 581
580VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) 582VObject* OPimContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value )
581{ 583{
582 VObject *ret = 0; 584 VObject *ret = 0;
583 if ( o && !value.isEmpty() ) 585 if ( o && !value.isEmpty() )
584 ret = addPropValue( o, prop, value.latin1() ); 586 ret = addPropValue( o, prop, value.latin1() );
585 return ret; 587 return ret;
586} 588}
587 589
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
@@ -21,39 +21,43 @@
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * XML Backend for the OPIE-Contact Database. 30 * XML Backend for the OPIE-Contact Database.
31 */ 31 */
32 32
33
34/* OPIE */
33#include <opie2/ocontactaccessbackend_xml.h> 35#include <opie2/ocontactaccessbackend_xml.h>
36#include <opie2/xmltree.h>
37#include <opie2/ocontactaccessbackend.h>
38#include <opie2/ocontactaccess.h>
39#include <opie2/odebug.h>
40
41#include <qpe/global.h>
34 42
43/* QT */
35#include <qasciidict.h> 44#include <qasciidict.h>
36#include <qfile.h> 45#include <qfile.h>
37#include <qfileinfo.h> 46#include <qfileinfo.h>
38#include <qregexp.h> 47#include <qregexp.h>
39#include <qarray.h> 48#include <qarray.h>
40#include <qmap.h> 49#include <qmap.h>
41 50
42#include <qpe/global.h> 51/* STD */
43
44#include <opie2/xmltree.h>
45#include <opie2/ocontactaccessbackend.h>
46#include <opie2/ocontactaccess.h>
47
48#include <stdlib.h> 52#include <stdlib.h>
49#include <errno.h> 53#include <errno.h>
50 54
51using namespace Opie::Core; 55using namespace Opie::Core;
52 56
53 57
54namespace Opie { 58namespace Opie {
55OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ): 59OPimContactAccessBackend_XML::OPimContactAccessBackend_XML ( const QString& appname, const QString& filename ):
56 m_changed( false ) 60 m_changed( false )
57{ 61{
58 // Just m_contactlist should call delete if an entry 62 // Just m_contactlist should call delete if an entry
59 // is removed. 63 // is removed.
@@ -95,25 +99,25 @@ bool OPimContactAccessBackend_XML::save()
95 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" 99 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
96 " <Groups>\n" 100 " <Groups>\n"
97 " </Groups>\n" 101 " </Groups>\n"
98 " <Contacts>\n"; 102 " <Contacts>\n";
99 QCString cstr = out.utf8(); 103 QCString cstr = out.utf8();
100 f.writeBlock( cstr.data(), cstr.length() ); 104 f.writeBlock( cstr.data(), cstr.length() );
101 idx_offset += cstr.length(); 105 idx_offset += cstr.length();
102 out = ""; 106 out = "";
103 107
104 // Write all contacts 108 // Write all contacts
105 QListIterator<OPimContact> it( m_contactList ); 109 QListIterator<OPimContact> it( m_contactList );
106 for ( ; it.current(); ++it ) { 110 for ( ; it.current(); ++it ) {
107 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); 111 // owarn << " Uid " << (*it)->uid() << " at Offset: " << idx_offset << "" << oendl;
108 out += "<Contact "; 112 out += "<Contact ";
109 (*it)->save( out ); 113 (*it)->save( out );
110 out += "/>\n"; 114 out += "/>\n";
111 cstr = out.utf8(); 115 cstr = out.utf8();
112 total_written = f.writeBlock( cstr.data(), cstr.length() ); 116 total_written = f.writeBlock( cstr.data(), cstr.length() );
113 idx_offset += cstr.length(); 117 idx_offset += cstr.length();
114 if ( total_written != int(cstr.length()) ) { 118 if ( total_written != int(cstr.length()) ) {
115 f.close(); 119 f.close();
116 QFile::remove( strNewFile ); 120 QFile::remove( strNewFile );
117 return false; 121 return false;
118 } 122 }
119 out = ""; 123 out = "";
@@ -450,49 +454,49 @@ QArray<int> OPimContactAccessBackend_XML::sorted( bool asc, int , int , int )
450 m_currentQuery[i++] = nameToUid[ (*it) ]; 454 m_currentQuery[i++] = nameToUid[ (*it) ];
451 }else{ 455 }else{
452 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it ) 456 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it )
453 m_currentQuery[i++] = nameToUid[ (*it) ]; 457 m_currentQuery[i++] = nameToUid[ (*it) ];
454 } 458 }
455 459
456 return m_currentQuery; 460 return m_currentQuery;
457 461
458} 462}
459 463
460bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact ) 464bool OPimContactAccessBackend_XML::add ( const OPimContact &newcontact )
461{ 465{
462 //qWarning("odefaultbackend: ACTION::ADD"); 466 //owarn << "odefaultbackend: ACTION::ADD" << oendl;
463 updateJournal (newcontact, ACTION_ADD); 467 updateJournal (newcontact, ACTION_ADD);
464 addContact_p( newcontact ); 468 addContact_p( newcontact );
465 469
466 m_changed = true; 470 m_changed = true;
467 471
468 return true; 472 return true;
469} 473}
470 474
471bool OPimContactAccessBackend_XML::replace ( const OPimContact &contact ) 475bool OPimContactAccessBackend_XML::replace ( const OPimContact &contact )
472{ 476{
473 m_changed = true; 477 m_changed = true;
474 478
475 OPimContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) ); 479 OPimContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) );
476 480
477 if ( found ) { 481 if ( found ) {
478 OPimContact* newCont = new OPimContact( contact ); 482 OPimContact* newCont = new OPimContact( contact );
479 483
480 updateJournal ( *newCont, ACTION_REPLACE); 484 updateJournal ( *newCont, ACTION_REPLACE);
481 m_contactList.removeRef ( found ); 485 m_contactList.removeRef ( found );
482 m_contactList.append ( newCont ); 486 m_contactList.append ( newCont );
483 m_uidToContact.remove( QString().setNum( contact.uid() ) ); 487 m_uidToContact.remove( QString().setNum( contact.uid() ) );
484 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont ); 488 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont );
485 489
486 qWarning("Nur zur Sicherheit: %d == %d ?",contact.uid(), newCont->uid()); 490 owarn << "Nur zur Sicherheit: " << contact.uid() << " == " << newCont->uid() << " ?" << oendl;
487 491
488 return true; 492 return true;
489 } else 493 } else
490 return false; 494 return false;
491} 495}
492 496
493bool OPimContactAccessBackend_XML::remove ( int uid ) 497bool OPimContactAccessBackend_XML::remove ( int uid )
494{ 498{
495 m_changed = true; 499 m_changed = true;
496 500
497 OPimContact* found = m_uidToContact.find ( QString().setNum( uid ) ); 501 OPimContact* found = m_uidToContact.find ( QString().setNum( uid ) );
498 502
@@ -580,33 +584,33 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
580 dict.insert( "Assistant", new int(Qtopia::Assistant) ); 584 dict.insert( "Assistant", new int(Qtopia::Assistant) );
581 dict.insert( "Manager", new int(Qtopia::Manager) ); 585 dict.insert( "Manager", new int(Qtopia::Manager) );
582 dict.insert( "Spouse", new int(Qtopia::Spouse) ); 586 dict.insert( "Spouse", new int(Qtopia::Spouse) );
583 dict.insert( "Children", new int(Qtopia::Children) ); 587 dict.insert( "Children", new int(Qtopia::Children) );
584 dict.insert( "Gender", new int(Qtopia::Gender) ); 588 dict.insert( "Gender", new int(Qtopia::Gender) );
585 dict.insert( "Birthday", new int(Qtopia::Birthday) ); 589 dict.insert( "Birthday", new int(Qtopia::Birthday) );
586 dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); 590 dict.insert( "Anniversary", new int(Qtopia::Anniversary) );
587 dict.insert( "Nickname", new int(Qtopia::Nickname) ); 591 dict.insert( "Nickname", new int(Qtopia::Nickname) );
588 dict.insert( "Notes", new int(Qtopia::Notes) ); 592 dict.insert( "Notes", new int(Qtopia::Notes) );
589 dict.insert( "action", new int(JOURNALACTION) ); 593 dict.insert( "action", new int(JOURNALACTION) );
590 dict.insert( "actionrow", new int(JOURNALROW) ); 594 dict.insert( "actionrow", new int(JOURNALROW) );
591 595
592 //qWarning( "OPimContactDefaultBackEnd::loading %s", filename.latin1() ); 596 //owarn << "OPimContactDefaultBackEnd::loading " << filename << "" << oendl;
593 597
594 XMLElement *root = XMLElement::load( filename ); 598 XMLElement *root = XMLElement::load( filename );
595 if(root != 0l ){ // start parsing 599 if(root != 0l ){ // start parsing
596 /* Parse all XML-Elements and put the data into the 600 /* Parse all XML-Elements and put the data into the
597 * Contact-Class 601 * Contact-Class
598 */ 602 */
599 XMLElement *element = root->firstChild(); 603 XMLElement *element = root->firstChild();
600 //qWarning("OPimContactAccess::load tagName(): %s", root->tagName().latin1() ); 604 //owarn << "OPimContactAccess::load tagName(): " << root->tagName() << "" << oendl;
601 element = element->firstChild(); 605 element = element->firstChild();
602 606
603 /* Search Tag "Contacts" which is the parent of all Contacts */ 607 /* Search Tag "Contacts" which is the parent of all Contacts */
604 while( element && !isJournal ){ 608 while( element && !isJournal ){
605 if( element->tagName() != QString::fromLatin1("Contacts") ){ 609 if( element->tagName() != QString::fromLatin1("Contacts") ){
606 //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s", 610 //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s",
607 // element->tagName().latin1()); 611 // element->tagName().latin1());
608 element = element->nextChild(); 612 element = element->nextChild();
609 } else { 613 } else {
610 element = element->firstChild(); 614 element = element->firstChild();
611 break; 615 break;
612 } 616 }
@@ -628,25 +632,25 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
628 foundAction = false; 632 foundAction = false;
629 633
630 XMLElement::AttributeMap aMap = element->attributes(); 634 XMLElement::AttributeMap aMap = element->attributes();
631 XMLElement::AttributeMap::Iterator it; 635 XMLElement::AttributeMap::Iterator it;
632 contactMap.clear(); 636 contactMap.clear();
633 customMap.clear(); 637 customMap.clear();
634 for( it = aMap.begin(); it != aMap.end(); ++it ){ 638 for( it = aMap.begin(); it != aMap.end(); ++it ){
635 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); 639 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
636 640
637 int *find = dict[ it.key() ]; 641 int *find = dict[ it.key() ];
638 /* Unknown attributes will be stored as "Custom" elements */ 642 /* Unknown attributes will be stored as "Custom" elements */
639 if ( !find ) { 643 if ( !find ) {
640 // qWarning("Attribute %s not known.", it.key().latin1()); 644 // owarn << "Attribute " << it.key() << " not known." << oendl;
641 //contact.setCustomField(it.key(), it.data()); 645 //contact.setCustomField(it.key(), it.data());
642 customMap.insert( it.key(), it.data() ); 646 customMap.insert( it.key(), it.data() );
643 continue; 647 continue;
644 } 648 }
645 649
646 /* Check if special conversion is needed and add attribute 650 /* Check if special conversion is needed and add attribute
647 * into Contact class 651 * into Contact class
648 */ 652 */
649 switch( *find ) { 653 switch( *find ) {
650 /* 654 /*
651 case Qtopia::AddressUid: 655 case Qtopia::AddressUid:
652 contact.setUid( it.data().toInt() ); 656 contact.setUid( it.data().toInt() );
@@ -695,28 +699,28 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal
695 qWarning ("Unknown action: ignored !"); 699 qWarning ("Unknown action: ignored !");
696 break; 700 break;
697 } 701 }
698 }else{ 702 }else{
699 /* Add contact to list */ 703 /* Add contact to list */
700 addContact_p (contact); 704 addContact_p (contact);
701 } 705 }
702 706
703 /* Move to next element */ 707 /* Move to next element */
704 element = element->nextChild(); 708 element = element->nextChild();
705 } 709 }
706 }else { 710 }else {
707 qWarning("ODefBack::could not load"); 711 owarn << "ODefBack::could not load" << oendl;
708 } 712 }
709 delete root; 713 delete root;
710 qWarning("returning from loading" ); 714 owarn << "returning from loading" << oendl;
711 return true; 715 return true;
712} 716}
713 717
714 718
715void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt, 719void OPimContactAccessBackend_XML::updateJournal( const OPimContact& cnt,
716 journal_action action ) 720 journal_action action )
717{ 721{
718 QFile f( m_journalName ); 722 QFile f( m_journalName );
719 bool created = !f.exists(); 723 bool created = !f.exists();
720 if ( !f.open(IO_WriteOnly|IO_Append) ) 724 if ( !f.open(IO_WriteOnly|IO_Append) )
721 return; 725 return;
722 726
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
@@ -22,38 +22,43 @@
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * SQL Backend for the OPIE-Calender Database. 30 * SQL Backend for the OPIE-Calender Database.
31 * 31 *
32 */ 32 */
33 33
34#include <stdio.h> 34/* OPIE */
35#include <stdlib.h>
36
37#include <qarray.h>
38#include <qstringlist.h>
39
40#include <qpe/global.h>
41
42#include <opie2/osqldriver.h> 35#include <opie2/osqldriver.h>
43#include <opie2/osqlmanager.h> 36#include <opie2/osqlmanager.h>
44#include <opie2/osqlquery.h> 37#include <opie2/osqlquery.h>
45 38
46#include <opie2/opimrecurrence.h> 39#include <opie2/opimrecurrence.h>
47#include <opie2/odatebookaccessbackend_sql.h> 40#include <opie2/odatebookaccessbackend_sql.h>
41#include <opie2/odebug.h>
42
43#include <qpe/global.h>
44
45/* QT */
46#include <qarray.h>
47#include <qstringlist.h>
48
49/* STD */
50#include <stdio.h>
51#include <stdlib.h>
52
48 53
49using namespace Opie::DB; 54using namespace Opie::DB;
50 55
51namespace { 56namespace {
52 /** 57 /**
53 * a find query for custom elements 58 * a find query for custom elements
54 */ 59 */
55 class FindCustomQuery : public OSQLQuery { 60 class FindCustomQuery : public OSQLQuery {
56 public: 61 public:
57 FindCustomQuery(int uid); 62 FindCustomQuery(int uid);
58 FindCustomQuery(const QArray<int>& ); 63 FindCustomQuery(const QArray<int>& );
59 ~FindCustomQuery(); 64 ~FindCustomQuery();
@@ -153,25 +158,25 @@ bool ODateBookAccessBackend_SQL::load()
153 // It is save here to create the table, even if it 158 // It is save here to create the table, even if it
154 // do exist. ( Is that correct for all databases ?? ) 159 // do exist. ( Is that correct for all databases ?? )
155 QStringqu = "create table datebook( uid INTEGER PRIMARY KEY "; 160 QStringqu = "create table datebook( uid INTEGER PRIMARY KEY ";
156 161
157 QMap<int, QString>::Iterator it; 162 QMap<int, QString>::Iterator it;
158 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 163 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
159 qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() ); 164 qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
160 } 165 }
161 qu += " );"; 166 qu += " );";
162 167
163 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );"; 168 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR(10), priority INTEGER, value VARCHAR(10), PRIMARY KEY /* identifier */ (uid, id) );";
164 169
165 qWarning( "command: %s", qu.latin1() ); 170 owarn << "command: " << qu << "" << oendl;
166 171
167 OSQLRawQuery raw( qu ); 172 OSQLRawQuery raw( qu );
168 OSQLResult res = m_driver->query( &raw ); 173 OSQLResult res = m_driver->query( &raw );
169 if ( res.state() != OSQLResult::Success ) 174 if ( res.state() != OSQLResult::Success )
170 return false; 175 return false;
171 176
172 update(); 177 update();
173 178
174 return true; 179 return true;
175} 180}
176 181
177void ODateBookAccessBackend_SQL::update() 182void ODateBookAccessBackend_SQL::update()
@@ -212,51 +217,51 @@ void ODateBookAccessBackend_SQL::clear()
212{ 217{
213 QString qu = "drop table datebook;"; 218 QString qu = "drop table datebook;";
214 qu += "drop table custom_data;"; 219 qu += "drop table custom_data;";
215 220
216 OSQLRawQuery raw( qu ); 221 OSQLRawQuery raw( qu );
217 OSQLResult res = m_driver->query( &raw ); 222 OSQLResult res = m_driver->query( &raw );
218 223
219 reload(); 224 reload();
220} 225}
221 226
222 227
223OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{ 228OPimEvent ODateBookAccessBackend_SQL::find( int uid ) const{
224 qDebug( "ODateBookAccessBackend_SQL::find( %d )", uid ); 229 odebug << "ODateBookAccessBackend_SQL::find( " << uid << " )" << oendl;
225 230
226 QString qu = "select *"; 231 QString qu = "select *";
227 qu += "from datebook where uid = " + QString::number(uid); 232 qu += "from datebook where uid = " + QString::number(uid);
228 233
229 qDebug( "Query: %s", qu.latin1() ); 234 odebug << "Query: " << qu << "" << oendl;
230 235
231 OSQLRawQuery raw( qu ); 236 OSQLRawQuery raw( qu );
232 OSQLResult res = m_driver->query( &raw ); 237 OSQLResult res = m_driver->query( &raw );
233 238
234 OSQLResultItem resItem = res.first(); 239 OSQLResultItem resItem = res.first();
235 240
236 // Create Map for date event and insert UID 241 // Create Map for date event and insert UID
237 QMap<int,QString> dateEventMap; 242 QMap<int,QString> dateEventMap;
238 dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) ); 243 dateEventMap.insert( OPimEvent::FUid, QString::number( uid ) );
239 244
240 // Now insert the data out of the columns into the map. 245 // Now insert the data out of the columns into the map.
241 QMapConstIterator<int, QString> it; 246 QMapConstIterator<int, QString> it;
242 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 247 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
243 dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); 248 dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) );
244 } 249 }
245 250
246 // Last step: Put map into date event, add custom map and return it 251 // Last step: Put map into date event, add custom map and return it
247 OPimEvent retDate( dateEventMap ); 252 OPimEvent retDate( dateEventMap );
248 retDate.setExtraMap( requestCustom( uid ) ); 253 retDate.setExtraMap( requestCustom( uid ) );
249 254
250 qDebug( "ODateBookAccessBackend_SQL::find( %d ) end", uid ); 255 odebug << "ODateBookAccessBackend_SQL::find( " << uid << " ) end" << oendl;
251 return retDate; 256 return retDate;
252} 257}
253 258
254// FIXME: Speed up update of uid's.. 259// FIXME: Speed up update of uid's..
255bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev ) 260bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
256{ 261{
257 QMap<int,QString> eventMap = ev.toMap(); 262 QMap<int,QString> eventMap = ev.toMap();
258 263
259 QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); 264 QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() );
260 QMap<int, QString>::Iterator it; 265 QMap<int, QString>::Iterator it;
261 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 266 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
262 if ( !eventMap[it.key()].isEmpty() ) 267 if ( !eventMap[it.key()].isEmpty() )
@@ -274,25 +279,25 @@ bool ODateBookAccessBackend_SQL::add( const OPimEvent& ev )
274 qu += "insert into custom_data VALUES(" 279 qu += "insert into custom_data VALUES("
275 + QString::number( ev.uid() ) 280 + QString::number( ev.uid() )
276 + "," 281 + ","
277 + QString::number( id++ ) 282 + QString::number( id++ )
278 + ",'" 283 + ",'"
279 + it.key() //.latin1() 284 + it.key() //.latin1()
280 + "'," 285 + "',"
281 + "0" // Priority for future enhancements 286 + "0" // Priority for future enhancements
282 + ",'" 287 + ",'"
283 + it.data() //.latin1() 288 + it.data() //.latin1()
284 + "');"; 289 + "');";
285 } 290 }
286 qWarning("add %s", qu.latin1() ); 291 owarn << "add " << qu << "" << oendl;
287 292
288 OSQLRawQuery raw( qu ); 293 OSQLRawQuery raw( qu );
289 OSQLResult res = m_driver->query( &raw ); 294 OSQLResult res = m_driver->query( &raw );
290 if ( res.state() != OSQLResult::Success ){ 295 if ( res.state() != OSQLResult::Success ){
291 return false; 296 return false;
292 } 297 }
293 298
294 // Update list of uid's 299 // Update list of uid's
295 update(); 300 update();
296 301
297 return true; 302 return true;
298} 303}
@@ -381,74 +386,74 @@ OPimEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
381 386
382QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const 387QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
383{ 388{
384 389
385 QString qu = "SELECT uid FROM datebook WHERE ("; 390 QString qu = "SELECT uid FROM datebook WHERE (";
386 391
387 // Do it make sense to search other fields, too ? 392 // Do it make sense to search other fields, too ?
388 qu += " rlike(\""+ r.pattern() + "\", Location ) OR"; 393 qu += " rlike(\""+ r.pattern() + "\", Location ) OR";
389 qu += " rlike(\""+ r.pattern() + "\", Note )"; 394 qu += " rlike(\""+ r.pattern() + "\", Note )";
390 395
391 qu += " )"; 396 qu += " )";
392 397
393 qDebug( "query: %s", qu.latin1() ); 398 odebug << "query: " << qu << "" << oendl;
394 399
395 OSQLRawQuery raw( qu ); 400 OSQLRawQuery raw( qu );
396 OSQLResult res = m_driver->query( &raw ); 401 OSQLResult res = m_driver->query( &raw );
397 402
398 return extractUids( res ); 403 return extractUids( res );
399 404
400 405
401 406
402} 407}
403 408
404/* ===== Private Functions ========================================== */ 409/* ===== Private Functions ========================================== */
405 410
406QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const 411QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const
407{ 412{
408 qWarning("extractUids"); 413 owarn << "extractUids" << oendl;
409 QTime t; 414 QTime t;
410 t.start(); 415 t.start();
411 OSQLResultItem::ValueList list = res.results(); 416 OSQLResultItem::ValueList list = res.results();
412 OSQLResultItem::ValueList::Iterator it; 417 OSQLResultItem::ValueList::Iterator it;
413 QArray<int> ints(list.count() ); 418 QArray<int> ints(list.count() );
414 qWarning(" count = %d", list.count() ); 419 owarn << " count = " << list.count() << "" << oendl;
415 420
416 int i = 0; 421 int i = 0;
417 for (it = list.begin(); it != list.end(); ++it ) { 422 for (it = list.begin(); it != list.end(); ++it ) {
418 ints[i] = (*it).data("uid").toInt(); 423 ints[i] = (*it).data("uid").toInt();
419 i++; 424 i++;
420 } 425 }
421 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); 426 owarn << "extractUids ready: count2 = " << i << " needs " << t.elapsed() << " ms" << oendl;
422 427
423 return ints; 428 return ints;
424 429
425} 430}
426 431
427QMap<QString, QString> ODateBookAccessBackend_SQL::requestCustom( int uid ) const 432QMap<QString, QString> ODateBookAccessBackend_SQL::requestCustom( int uid ) const
428{ 433{
429 QTime t; 434 QTime t;
430 t.start(); 435 t.start();
431 436
432 QMap<QString, QString> customMap; 437 QMap<QString, QString> customMap;
433 438
434 FindCustomQuery query( uid ); 439 FindCustomQuery query( uid );
435 OSQLResult res_custom = m_driver->query( &query ); 440 OSQLResult res_custom = m_driver->query( &query );
436 441
437 if ( res_custom.state() == OSQLResult::Failure ) { 442 if ( res_custom.state() == OSQLResult::Failure ) {
438 qWarning("OSQLResult::Failure in find query !!"); 443 owarn << "OSQLResult::Failure in find query !!" << oendl;
439 QMap<QString, QString> empty; 444 QMap<QString, QString> empty;
440 return empty; 445 return empty;
441 } 446 }
442 447
443 OSQLResultItem::ValueList list = res_custom.results(); 448 OSQLResultItem::ValueList list = res_custom.results();
444 OSQLResultItem::ValueList::Iterator it = list.begin(); 449 OSQLResultItem::ValueList::Iterator it = list.begin();
445 for ( ; it != list.end(); ++it ) { 450 for ( ; it != list.end(); ++it ) {
446 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); 451 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
447 } 452 }
448 453
449 qDebug("RequestCustom needed: %d ms", t.elapsed() ); 454 odebug << "RequestCustom needed: " << t.elapsed() << " ms" << oendl;
450 return customMap; 455 return customMap;
451} 456}
452 457
453 458
454} 459}
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
@@ -17,47 +17,53 @@
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29
30/* OPIE */
31#include <opie2/opimnotifymanager.h>
32#include <opie2/opimrecurrence.h>
33#include <opie2/opimtimezone.h>
34#include <opie2/odatebookaccessbackend_xml.h>
35#include <opie2/odebug.h>
36
37#include <qtopia/global.h>
38#include <qtopia/stringutil.h>
39#include <qtopia/timeconversion.h>
40
41/* QT */
42#include <qasciidict.h>
43#include <qfile.h>
44
45/* STD */
29#include <errno.h> 46#include <errno.h>
30#include <fcntl.h> 47#include <fcntl.h>
31 48
32#include <stdio.h> 49#include <stdio.h>
33#include <stdlib.h> 50#include <stdlib.h>
34 51
35#include <sys/types.h> 52#include <sys/types.h>
36#include <sys/mman.h> 53#include <sys/mman.h>
37#include <sys/stat.h> 54#include <sys/stat.h>
38 55
39#include <unistd.h> 56#include <unistd.h>
40 57
41#include <qasciidict.h>
42#include <qfile.h>
43
44#include <qtopia/global.h>
45#include <qtopia/stringutil.h>
46#include <qtopia/timeconversion.h>
47
48#include <opie2/opimnotifymanager.h>
49#include <opie2/opimrecurrence.h>
50#include <opie2/opimtimezone.h>
51#include <opie2/odatebookaccessbackend_xml.h>
52 58
53using namespace Opie; 59using namespace Opie;
54 60
55namespace { 61namespace {
56 // FROM TT again 62 // FROM TT again
57char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen) 63char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
58{ 64{
59 char needleChar; 65 char needleChar;
60 char haystackChar; 66 char haystackChar;
61 if (!needle || !haystack || !hLen || !nLen) 67 if (!needle || !haystack || !hLen || !nLen)
62 return 0; 68 return 0;
63 69
@@ -107,25 +113,25 @@ namespace {
107 FRStart, 113 FRStart,
108 FREnd, 114 FREnd,
109 FNote, 115 FNote,
110 FCreated, // Should't this be called FRCreated ? 116 FCreated, // Should't this be called FRCreated ?
111 FTimeZone, 117 FTimeZone,
112 FRecParent, 118 FRecParent,
113 FRecChildren, 119 FRecChildren,
114 FExceptions 120 FExceptions
115 }; 121 };
116 122
117 // FIXME: Use OPimEvent::toMap() here !! (eilers) 123 // FIXME: Use OPimEvent::toMap() here !! (eilers)
118 inline void save( const OPimEvent& ev, QString& buf ) { 124 inline void save( const OPimEvent& ev, QString& buf ) {
119 qWarning("Saving %d %s", ev.uid(), ev.description().latin1() ); 125 owarn << "Saving " << ev.uid() << " " << ev.description() << "" << oendl;
120 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\""; 126 buf += " description=\"" + Qtopia::escapeString(ev.description() ) + "\"";
121 if (!ev.location().isEmpty() ) 127 if (!ev.location().isEmpty() )
122 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\""; 128 buf += " location=\"" + Qtopia::escapeString(ev.location() ) + "\"";
123 129
124 buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\""; 130 buf += " categories=\""+ Qtopia::escapeString( Qtopia::Record::idsToString( ev.categories() ) ) + "\"";
125 buf += " uid=\"" + QString::number( ev.uid() ) + "\""; 131 buf += " uid=\"" + QString::number( ev.uid() ) + "\"";
126 132
127 if (ev.isAllDay() ) 133 if (ev.isAllDay() )
128 buf += " type=\"AllDay\""; // is that all ?? (eilers) 134 buf += " type=\"AllDay\""; // is that all ?? (eilers)
129 135
130 if (ev.hasNotifiers() ) { 136 if (ev.hasNotifiers() ) {
131 OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first 137 OPimAlarm alarm = ev.notifiers().alarms()[0]; // take only the first
@@ -481,60 +487,60 @@ bool ODateBookAccessBackend_XML::loadFile() {
481} 487}
482 488
483// FIXME: Use OPimEvent::fromMap() which makes this obsolete.. (eilers) 489// FIXME: Use OPimEvent::fromMap() which makes this obsolete.. (eilers)
484void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) { 490void ODateBookAccessBackend_XML::finalizeRecord( OPimEvent& ev ) {
485 /* AllDay is alway in UTC */ 491 /* AllDay is alway in UTC */
486 if ( ev.isAllDay() ) { 492 if ( ev.isAllDay() ) {
487 OPimTimeZone utc = OPimTimeZone::utc(); 493 OPimTimeZone utc = OPimTimeZone::utc();
488 ev.setStartDateTime( utc.fromUTCDateTime( start ) ); 494 ev.setStartDateTime( utc.fromUTCDateTime( start ) );
489 ev.setEndDateTime ( utc.fromUTCDateTime( end ) ); 495 ev.setEndDateTime ( utc.fromUTCDateTime( end ) );
490 ev.setTimeZone( "UTC"); // make sure it is really utc 496 ev.setTimeZone( "UTC"); // make sure it is really utc
491 }else { 497 }else {
492 /* to current date time */ 498 /* to current date time */
493 // qWarning(" Start is %d", start ); 499 // owarn << " Start is " << start << "" << oendl;
494 OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() ); 500 OPimTimeZone zone( ev.timeZone().isEmpty() ? OPimTimeZone::current() : ev.timeZone() );
495 QDateTime date = zone.toDateTime( start ); 501 QDateTime date = zone.toDateTime( start );
496 qWarning(" Start is %s", date.toString().latin1() ); 502 owarn << " Start is " << date.toString() << "" << oendl;
497 ev.setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); 503 ev.setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
498 504
499 date = zone.toDateTime( end ); 505 date = zone.toDateTime( end );
500 ev.setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); 506 ev.setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) );
501 } 507 }
502 if ( rec && rec->doesRecur() ) { 508 if ( rec && rec->doesRecur() ) {
503 OPimTimeZone utc = OPimTimeZone::utc(); 509 OPimTimeZone utc = OPimTimeZone::utc();
504 OPimRecurrence recu( *rec ); // call copy c'tor; 510 OPimRecurrence recu( *rec ); // call copy c'tor;
505 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() ); 511 recu.setEndDate ( utc.fromUTCDateTime( rp_end ).date() );
506 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) ); 512 recu.setCreatedDateTime( utc.fromUTCDateTime( created ) );
507 recu.setStart( ev.startDateTime().date() ); 513 recu.setStart( ev.startDateTime().date() );
508 ev.setRecurrence( recu ); 514 ev.setRecurrence( recu );
509 } 515 }
510 516
511 if (alarmTime != -1 ) { 517 if (alarmTime != -1 ) {
512 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 ); 518 QDateTime dt = ev.startDateTime().addSecs( -1*alarmTime*60 );
513 OPimAlarm al( snd , dt ); 519 OPimAlarm al( snd , dt );
514 ev.notifiers().add( al ); 520 ev.notifiers().add( al );
515 } 521 }
516 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) { 522 if ( m_raw.contains( ev.uid() ) || m_rep.contains( ev.uid() ) ) {
517 qWarning("already contains assign uid"); 523 owarn << "already contains assign uid" << oendl;
518 ev.setUid( 1 ); 524 ev.setUid( 1 );
519 } 525 }
520 qWarning("addind %d %s", ev.uid(), ev.description().latin1() ); 526 owarn << "addind " << ev.uid() << " " << ev.description() << "" << oendl;
521 if ( ev.hasRecurrence() ) 527 if ( ev.hasRecurrence() )
522 m_rep.insert( ev.uid(), ev ); 528 m_rep.insert( ev.uid(), ev );
523 else 529 else
524 m_raw.insert( ev.uid(), ev ); 530 m_raw.insert( ev.uid(), ev );
525 531
526} 532}
527void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) { 533void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString& value) {
528// qWarning(" setting %s", value.latin1() ); 534// owarn << " setting " << value << "" << oendl;
529 switch( id ) { 535 switch( id ) {
530 case FDescription: 536 case FDescription:
531 e.setDescription( value ); 537 e.setDescription( value );
532 break; 538 break;
533 case FLocation: 539 case FLocation:
534 e.setLocation( value ); 540 e.setLocation( value );
535 break; 541 break;
536 case FCategories: 542 case FCategories:
537 e.setCategories( e.idsFromString( value ) ); 543 e.setCategories( e.idsFromString( value ) );
538 break; 544 break;
539 case FUid: 545 case FUid:
540 e.setUid( value.toInt() ); 546 e.setUid( value.toInt() );
@@ -601,25 +607,25 @@ void ODateBookAccessBackend_XML::setField( OPimEvent& e, int id, const QString&
601 break; 607 break;
602 case FRecChildren:{ 608 case FRecChildren:{
603 QStringList list = QStringList::split(' ', value ); 609 QStringList list = QStringList::split(' ', value );
604 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 610 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
605 e.addChild( (*it).toInt() ); 611 e.addChild( (*it).toInt() );
606 } 612 }
607 } 613 }
608 break; 614 break;
609 case FExceptions:{ 615 case FExceptions:{
610 QStringList list = QStringList::split(' ', value ); 616 QStringList list = QStringList::split(' ', value );
611 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) { 617 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
612 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() ); 618 QDate date( (*it).left(4).toInt(), (*it).mid(4, 2).toInt(), (*it).right(2).toInt() );
613 qWarning("adding exception %s", date.toString().latin1() ); 619 owarn << "adding exception " << date.toString() << "" << oendl;
614 recur()->exceptions().append( date ); 620 recur()->exceptions().append( date );
615 } 621 }
616 } 622 }
617 break; 623 break;
618 case FTimeZone: 624 case FTimeZone:
619 if ( value != "None" ) 625 if ( value != "None" )
620 e.setTimeZone( value ); 626 e.setTimeZone( value );
621 break; 627 break;
622 default: 628 default:
623 break; 629 break;
624 } 630 }
625} 631}
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
@@ -19,39 +19,43 @@
19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
21++= -. .` .: details. 21++= -. .` .: details.
22 : = ...= . :.=- 22 : = ...= . :.=-
23 -. .:....=;==+<; You should have received a copy of the GNU 23 -. .:....=;==+<; You should have received a copy of the GNU
24 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
25 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29*/ 29*/
30 30
31#include <qdatetime.h> 31/* OPIE */
32#include <qmap.h>
33#include <qstring.h>
34
35#include <qpe/global.h>
36
37#include <opie2/osqldriver.h> 32#include <opie2/osqldriver.h>
38#include <opie2/osqlresult.h> 33#include <opie2/osqlresult.h>
39#include <opie2/osqlmanager.h> 34#include <opie2/osqlmanager.h>
40#include <opie2/osqlquery.h> 35#include <opie2/osqlquery.h>
41 36
42#include <opie2/otodoaccesssql.h> 37#include <opie2/otodoaccesssql.h>
43#include <opie2/opimstate.h> 38#include <opie2/opimstate.h>
44#include <opie2/opimnotifymanager.h> 39#include <opie2/opimnotifymanager.h>
45#include <opie2/opimrecurrence.h> 40#include <opie2/opimrecurrence.h>
41#include <opie2/odebug.h>
42
43#include <qpe/global.h>
44
45/* QT */
46#include <qdatetime.h>
47#include <qmap.h>
48#include <qstring.h>
49
46 50
47using namespace Opie::DB; 51using namespace Opie::DB;
48 52
49using namespace Opie; 53using namespace Opie;
50/* 54/*
51 * first some query 55 * first some query
52 * CREATE query 56 * CREATE query
53 * LOAD query 57 * LOAD query
54 * INSERT 58 * INSERT
55 * REMOVE 59 * REMOVE
56 * CLEAR 60 * CLEAR
57 */ 61 */
@@ -282,25 +286,25 @@ namespace {
282 + "," 286 + ","
283 + QString::number( id++ ) 287 + QString::number( id++ )
284 + ",'" 288 + ",'"
285 + it.key() 289 + it.key()
286 + "'," 290 + "',"
287 + "0" // Priority for future enhancements 291 + "0" // Priority for future enhancements
288 + ",'" 292 + ",'"
289 + it.data() 293 + it.data()
290 + "');"; 294 + "');";
291 } 295 }
292 296
293 297
294 qDebug("add %s", qu.latin1() ); 298 odebug << "add " << qu << "" << oendl;
295 return qu; 299 return qu;
296 } 300 }
297 301
298 RemoveQuery::RemoveQuery(int uid ) 302 RemoveQuery::RemoveQuery(int uid )
299 : OSQLQuery(), m_uid( uid ) {} 303 : OSQLQuery(), m_uid( uid ) {}
300 RemoveQuery::~RemoveQuery() {} 304 RemoveQuery::~RemoveQuery() {}
301 QString RemoveQuery::query()const { 305 QString RemoveQuery::query()const {
302 QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;"; 306 QString qu = "DELETE FROM todolist WHERE uid = " + QString::number(m_uid) + " ;";
303 qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid); 307 qu += "DELETE FROM custom_data WHERE uid = " + QString::number(m_uid);
304 return qu; 308 return qu;
305 } 309 }
306 310
@@ -447,35 +451,35 @@ QArray<int> OPimTodoAccessBackendSQL::allRecords()const {
447QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){ 451QArray<int> OPimTodoAccessBackendSQL::queryByExample( const OPimTodo& , int, const QDateTime& ){
448 QArray<int> ints(0); 452 QArray<int> ints(0);
449 return ints; 453 return ints;
450} 454}
451OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{ 455OPimTodo OPimTodoAccessBackendSQL::find(int uid ) const{
452 FindQuery query( uid ); 456 FindQuery query( uid );
453 return todo( m_driver->query(&query) ); 457 return todo( m_driver->query(&query) );
454 458
455} 459}
456OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints, 460OPimTodo OPimTodoAccessBackendSQL::find( int uid, const QArray<int>& ints,
457 uint cur, Frontend::CacheDirection dir ) const{ 461 uint cur, Frontend::CacheDirection dir ) const{
458 uint CACHE = readAhead(); 462 uint CACHE = readAhead();
459 qDebug("searching for %d", uid ); 463 odebug << "searching for " << uid << "" << oendl;
460 QArray<int> search( CACHE ); 464 QArray<int> search( CACHE );
461 uint size =0; 465 uint size =0;
462 OPimTodo to; 466 OPimTodo to;
463 467
464 // we try to cache CACHE items 468 // we try to cache CACHE items
465 switch( dir ) { 469 switch( dir ) {
466 /* forward */ 470 /* forward */
467 case 0: // FIXME: Not a good style to use magic numbers here (eilers) 471 case 0: // FIXME: Not a good style to use magic numbers here (eilers)
468 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) { 472 for (uint i = cur; i < ints.count() && size < CACHE; i++ ) {
469 qDebug("size %d %d", size, ints[i] ); 473 odebug << "size " << size << " " << ints[i] << "" << oendl;
470 search[size] = ints[i]; 474 search[size] = ints[i];
471 size++; 475 size++;
472 } 476 }
473 break; 477 break;
474 /* reverse */ 478 /* reverse */
475 case 1: // FIXME: Not a good style to use magic numbers here (eilers) 479 case 1: // FIXME: Not a good style to use magic numbers here (eilers)
476 for (uint i = cur; i != 0 && size < CACHE; i-- ) { 480 for (uint i = cur; i != 0 && size < CACHE; i-- ) {
477 search[size] = ints[i]; 481 search[size] = ints[i];
478 size++; 482 size++;
479 } 483 }
480 break; 484 break;
481 } 485 }
@@ -532,25 +536,25 @@ QArray<int> OPimTodoAccessBackendSQL::overDue() {
532} 536}
533QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s, 537QArray<int> OPimTodoAccessBackendSQL::effectiveToDos( const QDate& s,
534 const QDate& t, 538 const QDate& t,
535 bool u) { 539 bool u) {
536 EffQuery ef(s, t, u ); 540 EffQuery ef(s, t, u );
537 return uids (m_driver->query(&ef) ); 541 return uids (m_driver->query(&ef) );
538} 542}
539/* 543/*
540 * 544 *
541 */ 545 */
542QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder, 546QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
543 int sortFilter, int cat ) { 547 int sortFilter, int cat ) {
544 qDebug("sorted %d, %d", asc, sortOrder ); 548 odebug << "sorted " << asc << ", " << sortOrder << "" << oendl;
545 QString query; 549 QString query;
546 query = "select uid from todolist WHERE "; 550 query = "select uid from todolist WHERE ";
547 551
548 /* 552 /*
549 * Sort Filter stuff 553 * Sort Filter stuff
550 * not that straight forward 554 * not that straight forward
551 * FIXME: Replace magic numbers 555 * FIXME: Replace magic numbers
552 * 556 *
553 */ 557 */
554 /* Category */ 558 /* Category */
555 if ( sortFilter & 1 ) { 559 if ( sortFilter & 1 ) {
556 QString str; 560 QString str;
@@ -591,74 +595,74 @@ QArray<int> OPimTodoAccessBackendSQL::sorted( bool asc, int sortOrder,
591 case 1: 595 case 1:
592 query += "priority"; 596 query += "priority";
593 break; 597 break;
594 case 2: 598 case 2:
595 query += "summary"; 599 query += "summary";
596 break; 600 break;
597 case 3: 601 case 3:
598 query += "DueDate"; 602 query += "DueDate";
599 break; 603 break;
600 } 604 }
601 605
602 if ( !asc ) { 606 if ( !asc ) {
603 qDebug("not ascending!"); 607 odebug << "not ascending!" << oendl;
604 query += " DESC"; 608 query += " DESC";
605 } 609 }
606 610
607 qDebug( query ); 611 odebug << query << oendl;
608 OSQLRawQuery raw(query ); 612 OSQLRawQuery raw(query );
609 return uids( m_driver->query(&raw) ); 613 return uids( m_driver->query(&raw) );
610} 614}
611bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{ 615bool OPimTodoAccessBackendSQL::date( QDate& da, const QString& str ) const{
612 if ( str == "0-0-0" ) 616 if ( str == "0-0-0" )
613 return false; 617 return false;
614 else{ 618 else{
615 int day, year, month; 619 int day, year, month;
616 QStringList list = QStringList::split("-", str ); 620 QStringList list = QStringList::split("-", str );
617 year = list[0].toInt(); 621 year = list[0].toInt();
618 month = list[1].toInt(); 622 month = list[1].toInt();
619 day = list[2].toInt(); 623 day = list[2].toInt();
620 da.setYMD( year, month, day ); 624 da.setYMD( year, month, day );
621 return true; 625 return true;
622 } 626 }
623} 627}
624OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{ 628OPimTodo OPimTodoAccessBackendSQL::todo( const OSQLResult& res ) const{
625 if ( res.state() == OSQLResult::Failure ) { 629 if ( res.state() == OSQLResult::Failure ) {
626 OPimTodo to; 630 OPimTodo to;
627 return to; 631 return to;
628 } 632 }
629 633
630 OSQLResultItem::ValueList list = res.results(); 634 OSQLResultItem::ValueList list = res.results();
631 OSQLResultItem::ValueList::Iterator it = list.begin(); 635 OSQLResultItem::ValueList::Iterator it = list.begin();
632 qDebug("todo1"); 636 odebug << "todo1" << oendl;
633 OPimTodo to = todo( (*it) ); 637 OPimTodo to = todo( (*it) );
634 cache( to ); 638 cache( to );
635 ++it; 639 ++it;
636 640
637 for ( ; it != list.end(); ++it ) { 641 for ( ; it != list.end(); ++it ) {
638 qDebug("caching"); 642 odebug << "caching" << oendl;
639 cache( todo( (*it) ) ); 643 cache( todo( (*it) ) );
640 } 644 }
641 return to; 645 return to;
642} 646}
643OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const { 647OPimTodo OPimTodoAccessBackendSQL::todo( OSQLResultItem& item )const {
644 qDebug("todo(ResultItem)"); 648 odebug << "todo(ResultItem)" << oendl;
645 649
646 // Request information from addressbook table and create the OPimTodo-object. 650 // Request information from addressbook table and create the OPimTodo-object.
647 651
648 bool hasDueDate = false; QDate dueDate = QDate::currentDate(); 652 bool hasDueDate = false; QDate dueDate = QDate::currentDate();
649 hasDueDate = date( dueDate, item.data("DueDate") ); 653 hasDueDate = date( dueDate, item.data("DueDate") );
650 QStringList cats = QStringList::split(";", item.data("categories") ); 654 QStringList cats = QStringList::split(";", item.data("categories") );
651 655
652 qDebug("Item is completed: %d", item.data("completed").toInt() ); 656 odebug << "Item is completed: " << item.data("completed").toInt() << "" << oendl;
653 657
654 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(), 658 OPimTodo to( (bool)item.data("completed").toInt(), item.data("priority").toInt(),
655 cats, item.data("summary"), item.data("description"), 659 cats, item.data("summary"), item.data("description"),
656 item.data("progress").toUShort(), hasDueDate, dueDate, 660 item.data("progress").toUShort(), hasDueDate, dueDate,
657 item.data("uid").toInt() ); 661 item.data("uid").toInt() );
658 662
659 bool isOk; 663 bool isOk;
660 int prioInt = QString( item.data("priority") ).toInt( &isOk ); 664 int prioInt = QString( item.data("priority") ).toInt( &isOk );
661 if ( isOk ) 665 if ( isOk )
662 to.setPriority( prioInt ); 666 to.setPriority( prioInt );
663 667
664 bool hasStartDate = false; QDate startDate = QDate::currentDate(); 668 bool hasStartDate = false; QDate startDate = QDate::currentDate();
@@ -741,25 +745,25 @@ void OPimTodoAccessBackendSQL::update()const {
741 LoadQuery lo; 745 LoadQuery lo;
742 OSQLResult res = m_driver->query(&lo); 746 OSQLResult res = m_driver->query(&lo);
743 if ( res.state() != OSQLResult::Success ) 747 if ( res.state() != OSQLResult::Success )
744 return; 748 return;
745 749
746 ((OPimTodoAccessBackendSQL*)this)->m_uids = uids( res ); 750 ((OPimTodoAccessBackendSQL*)this)->m_uids = uids( res );
747} 751}
748QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{ 752QArray<int> OPimTodoAccessBackendSQL::uids( const OSQLResult& res) const{
749 753
750 OSQLResultItem::ValueList list = res.results(); 754 OSQLResultItem::ValueList list = res.results();
751 OSQLResultItem::ValueList::Iterator it; 755 OSQLResultItem::ValueList::Iterator it;
752 QArray<int> ints(list.count() ); 756 QArray<int> ints(list.count() );
753 qDebug(" count = %d", list.count() ); 757 odebug << " count = " << list.count() << "" << oendl;
754 758
755 int i = 0; 759 int i = 0;
756 for (it = list.begin(); it != list.end(); ++it ) { 760 for (it = list.begin(); it != list.end(); ++it ) {
757 ints[i] = (*it).data("uid").toInt(); 761 ints[i] = (*it).data("uid").toInt();
758 i++; 762 i++;
759 } 763 }
760 return ints; 764 return ints;
761} 765}
762 766
763QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const 767QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
764{ 768{
765 769
@@ -767,25 +771,25 @@ QArray<int> OPimTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
767 QArray<int> empty; 771 QArray<int> empty;
768 return empty; 772 return empty;
769 773
770#else 774#else
771 QString qu = "SELECT uid FROM todolist WHERE ("; 775 QString qu = "SELECT uid FROM todolist WHERE (";
772 776
773 // Do it make sense to search other fields, too ? 777 // Do it make sense to search other fields, too ?
774 qu += " rlike(\""+ r.pattern() + "\",\"description\") OR"; 778 qu += " rlike(\""+ r.pattern() + "\",\"description\") OR";
775 qu += " rlike(\""+ r.pattern() + "\",\"summary\")"; 779 qu += " rlike(\""+ r.pattern() + "\",\"summary\")";
776 780
777 qu += ")"; 781 qu += ")";
778 782
779 qDebug( "query: %s", qu.latin1() ); 783 odebug << "query: " << qu << "" << oendl;
780 784
781 OSQLRawQuery raw( qu ); 785 OSQLRawQuery raw( qu );
782 OSQLResult res = m_driver->query( &raw ); 786 OSQLResult res = m_driver->query( &raw );
783 787
784 return uids( res ); 788 return uids( res );
785 789
786 790
787#endif 791#endif
788 792
789} 793}
790QBitArray OPimTodoAccessBackendSQL::supports()const { 794QBitArray OPimTodoAccessBackendSQL::supports()const {
791 795
@@ -807,25 +811,25 @@ QBitArray OPimTodoAccessBackendSQL::sup() const{
807 811
808void OPimTodoAccessBackendSQL::removeAllCompleted(){ 812void OPimTodoAccessBackendSQL::removeAllCompleted(){
809 // First we need the uids from all entries which are 813 // First we need the uids from all entries which are
810 // completed. Then, we just have to remove them... 814 // completed. Then, we just have to remove them...
811 815
812 QString qu = "SELECT uid FROM todolist WHERE completed = 1"; 816 QString qu = "SELECT uid FROM todolist WHERE completed = 1";
813 817
814 OSQLRawQuery raw( qu ); 818 OSQLRawQuery raw( qu );
815 OSQLResult res = m_driver->query( &raw ); 819 OSQLResult res = m_driver->query( &raw );
816 820
817 QArray<int> completed_uids = uids( res ); 821 QArray<int> completed_uids = uids( res );
818 822
819 qDebug( "Number of completed: %d", completed_uids.size() ); 823 odebug << "Number of completed: " << completed_uids.size() << "" << oendl;
820 824
821 if ( completed_uids.size() == 0 ) 825 if ( completed_uids.size() == 0 )
822 return; 826 return;
823 827
824 qu = "DELETE FROM todolist WHERE ("; 828 qu = "DELETE FROM todolist WHERE (";
825 QString query; 829 QString query;
826 830
827 for ( int i = 0; i < completed_uids.size(); i++ ){ 831 for ( int i = 0; i < completed_uids.size(); i++ ){
828 if ( !query.isEmpty() ) 832 if ( !query.isEmpty() )
829 query += " OR "; 833 query += " OR ";
830 query += QString( "uid = %1" ).arg( completed_uids[i] ); 834 query += QString( "uid = %1" ).arg( completed_uids[i] );
831 } 835 }
@@ -833,43 +837,43 @@ void OPimTodoAccessBackendSQL::removeAllCompleted(){
833 837
834 // Put remove of custom entries in this query to speed up.. 838 // Put remove of custom entries in this query to speed up..
835 qu += "DELETE FORM custom_data WHERE ("; 839 qu += "DELETE FORM custom_data WHERE (";
836 query = ""; 840 query = "";
837 841
838 for ( int i = 0; i < completed_uids.size(); i++ ){ 842 for ( int i = 0; i < completed_uids.size(); i++ ){
839 if ( !query.isEmpty() ) 843 if ( !query.isEmpty() )
840 query += " OR "; 844 query += " OR ";
841 query += QString( "uid = %1" ).arg( completed_uids[i] ); 845 query += QString( "uid = %1" ).arg( completed_uids[i] );
842 } 846 }
843 qu += query + " );"; 847 qu += query + " );";
844 848
845 qDebug( "query: %s", qu.latin1() ); 849 odebug << "query: " << qu << "" << oendl;
846 850
847 OSQLRawQuery raw2( qu ); 851 OSQLRawQuery raw2( qu );
848 res = m_driver->query( &raw2 ); 852 res = m_driver->query( &raw2 );
849 if ( res.state() == OSQLResult::Failure ) { 853 if ( res.state() == OSQLResult::Failure ) {
850 qWarning("OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: %s", qu.latin1() ); 854 owarn << "OPimTodoAccessBackendSQL::removeAllCompleted():Failure in query: " << qu << "" << oendl;
851 } 855 }
852} 856}
853 857
854 858
855QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const 859QMap<QString, QString> OPimTodoAccessBackendSQL::requestCustom( int uid ) const
856{ 860{
857 QMap<QString, QString> customMap; 861 QMap<QString, QString> customMap;
858 862
859 FindCustomQuery query( uid ); 863 FindCustomQuery query( uid );
860 OSQLResult res_custom = m_driver->query( &query ); 864 OSQLResult res_custom = m_driver->query( &query );
861 865
862 if ( res_custom.state() == OSQLResult::Failure ) { 866 if ( res_custom.state() == OSQLResult::Failure ) {
863 qWarning("OSQLResult::Failure in find query !!"); 867 owarn << "OSQLResult::Failure in find query !!" << oendl;
864 QMap<QString, QString> empty; 868 QMap<QString, QString> empty;
865 return empty; 869 return empty;
866 } 870 }
867 871
868 OSQLResultItem::ValueList list = res_custom.results(); 872 OSQLResultItem::ValueList list = res_custom.results();
869 OSQLResultItem::ValueList::Iterator it = list.begin(); 873 OSQLResultItem::ValueList::Iterator it = list.begin();
870 for ( ; it != list.end(); ++it ) { 874 for ( ; it != list.end(); ++it ) {
871 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); 875 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
872 } 876 }
873 877
874 return customMap; 878 return customMap;
875} 879}
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
@@ -18,29 +18,33 @@
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30/* OPIE */
31#include "vobject_p.h" 30#include "vobject_p.h"
32#include <qpe/timeconversion.h> 31
32/* OPIE */
33#include <opie2/otodoaccessvcal.h> 33#include <opie2/otodoaccessvcal.h>
34#include <opie2/odebug.h>
35
36#include <qpe/timeconversion.h>
34 37
38/* QT */
35//FIXME: Hack to allow direct access to FILE* fh. Rewrite this! 39//FIXME: Hack to allow direct access to FILE* fh. Rewrite this!
36#define protected public 40#define protected public
37#include <qfile.h> 41#include <qfile.h>
38#undef protected 42#undef protected
39 43
40using namespace Opie; 44using namespace Opie;
41 45
42namespace { 46namespace {
43 static OPimTodo eventByVObj( VObject *obj ){ 47 static OPimTodo eventByVObj( VObject *obj ){
44 OPimTodo event; 48 OPimTodo event;
45 VObject *ob; 49 VObject *ob;
46 QCString name; 50 QCString name;
@@ -79,25 +83,25 @@ namespace {
79 bool ok; 83 bool ok;
80 event.setPriority(name.toInt(&ok) ); 84 event.setPriority(name.toInt(&ok) );
81 } 85 }
82 //due date 86 //due date
83 if((ob = isAPropertyOf(obj, VCDueProp)) ){ 87 if((ob = isAPropertyOf(obj, VCDueProp)) ){
84 event.setHasDueDate( true ); 88 event.setHasDueDate( true );
85 name = vObjectStringZValue( ob ); 89 name = vObjectStringZValue( ob );
86 event.setDueDate( TimeConversion::fromISO8601( name).date() ); 90 event.setDueDate( TimeConversion::fromISO8601( name).date() );
87 } 91 }
88 // categories 92 // categories
89 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){ 93 if((ob = isAPropertyOf( obj, VCCategoriesProp )) != 0 ){
90 name = vObjectStringZValue( ob ); 94 name = vObjectStringZValue( ob );
91 qWarning("Categories:%s", name.data() ); 95 owarn << "Categories:" << name.data() << "" << oendl;
92 } 96 }
93 97
94 event.setUid( 1 ); 98 event.setUid( 1 );
95 return event; 99 return event;
96 }; 100 };
97 static VObject *vobjByEvent( const OPimTodo &event ) { 101 static VObject *vobjByEvent( const OPimTodo &event ) {
98 VObject *task = newVObject( VCTodoProp ); 102 VObject *task = newVObject( VCTodoProp );
99 if( task == 0 ) 103 if( task == 0 )
100 return 0l; 104 return 0l;
101 105
102 if( event.hasDueDate() ) { 106 if( event.hasDueDate() ) {
103 QTime time(0, 0, 0); 107 QTime time(0, 0, 0);
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
@@ -17,48 +17,53 @@
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29
30/* OPIE */
31#include <opie2/opimdateconversion.h>
32#include <opie2/opimstate.h>
33#include <opie2/opimtimezone.h>
34#include <opie2/opimnotifymanager.h>
35#include <opie2/opimrecurrence.h>
36#include <opie2/otodoaccessxml.h>
37#include <opie2/odebug.h>
38
39#include <qpe/global.h>
40#include <qpe/stringutil.h>
41#include <qpe/timeconversion.h>
42
43/* QT */
44#include <qfile.h>
45#include <qvector.h>
46
47/* STD */
29#include <errno.h> 48#include <errno.h>
30#include <fcntl.h> 49#include <fcntl.h>
31 50
32#include <sys/mman.h> 51#include <sys/mman.h>
33#include <sys/stat.h> 52#include <sys/stat.h>
34#include <sys/types.h> 53#include <sys/types.h>
35 54
36#include <unistd.h> 55#include <unistd.h>
37 56
38 57
39#include <qfile.h>
40#include <qvector.h>
41
42#include <qpe/global.h>
43#include <qpe/stringutil.h>
44#include <qpe/timeconversion.h>
45
46#include <opie2/opimdateconversion.h>
47#include <opie2/opimstate.h>
48#include <opie2/opimtimezone.h>
49#include <opie2/opimnotifymanager.h>
50#include <opie2/opimrecurrence.h>
51#include <opie2/otodoaccessxml.h>
52
53using namespace Opie; 58using namespace Opie;
54 59
55namespace { 60namespace {
56 time_t rp_end; 61 time_t rp_end;
57 OPimRecurrence* rec; 62 OPimRecurrence* rec;
58 OPimRecurrence *recur() { 63 OPimRecurrence *recur() {
59 if (!rec ) rec = new OPimRecurrence; 64 if (!rec ) rec = new OPimRecurrence;
60 return rec; 65 return rec;
61 } 66 }
62 int snd; 67 int snd;
63 enum MoreAttributes { 68 enum MoreAttributes {
64 FRType = OPimTodo::CompletedDate + 2, 69 FRType = OPimTodo::CompletedDate + 2,
@@ -168,25 +173,25 @@ bool OPimTodoAccessXML::load() {
168 /* we do not the file any more */ 173 /* we do not the file any more */
169 ::close( fd ); 174 ::close( fd );
170 175
171 char* dt = (char*)map_addr; 176 char* dt = (char*)map_addr;
172 int len = attribut.st_size; 177 int len = attribut.st_size;
173 int i = 0; 178 int i = 0;
174 char *point; 179 char *point;
175 const char* collectionString = "<Task "; 180 const char* collectionString = "<Task ";
176 int strLen = strlen(collectionString); 181 int strLen = strlen(collectionString);
177 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) { 182 while ( ( point = strstrlen( dt+i, len -i, collectionString, strLen ) ) != 0l ) {
178 i = point -dt; 183 i = point -dt;
179 i+= strLen; 184 i+= strLen;
180 qWarning("Found a start at %d %d", i, (point-dt) ); 185 owarn << "Found a start at " << i << " " << (point-dt) << "" << oendl;
181 186
182 OPimTodo ev; 187 OPimTodo ev;
183 m_year = m_month = m_day = 0; 188 m_year = m_month = m_day = 0;
184 189
185 while ( TRUE ) { 190 while ( TRUE ) {
186 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') ) 191 while ( i < len && (dt[i] == ' ' || dt[i] == '\n' || dt[i] == '\r') )
187 ++i; 192 ++i;
188 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') ) 193 if ( i >= len-2 || (dt[i] == '/' && dt[i+1] == '>') )
189 break; 194 break;
190 195
191 // we have another attribute, read it. 196 // we have another attribute, read it.
192 int j = i; 197 int j = i;
@@ -224,58 +229,58 @@ bool OPimTodoAccessXML::load() {
224 if ( haveEnt ) 229 if ( haveEnt )
225 str = Qtopia::plainString( str ); 230 str = Qtopia::plainString( str );
226 231
227 /* 232 /*
228 * add key + value 233 * add key + value
229 */ 234 */
230 todo( &dict, ev, attr, str ); 235 todo( &dict, ev, attr, str );
231 236
232 } 237 }
233 /* 238 /*
234 * now add it 239 * now add it
235 */ 240 */
236 qWarning("End at %d", i ); 241 owarn << "End at " << i << "" << oendl;
237 if (m_events.contains( ev.uid() ) || ev.uid() == 0) { 242 if (m_events.contains( ev.uid() ) || ev.uid() == 0) {
238 ev.setUid( 1 ); 243 ev.setUid( 1 );
239 m_changed = true; 244 m_changed = true;
240 } 245 }
241 if ( ev.hasDueDate() ) { 246 if ( ev.hasDueDate() ) {
242 ev.setDueDate( QDate(m_year, m_month, m_day) ); 247 ev.setDueDate( QDate(m_year, m_month, m_day) );
243 } 248 }
244 if ( rec && rec->doesRecur() ) { 249 if ( rec && rec->doesRecur() ) {
245 OPimTimeZone utc = OPimTimeZone::utc(); 250 OPimTimeZone utc = OPimTimeZone::utc();
246 OPimRecurrence recu( *rec ); // call copy c'tor 251 OPimRecurrence recu( *rec ); // call copy c'tor
247 recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() ); 252 recu.setEndDate( utc.fromUTCDateTime( rp_end ).date() );
248 recu.setStart( ev.dueDate() ); 253 recu.setStart( ev.dueDate() );
249 ev.setRecurrence( recu ); 254 ev.setRecurrence( recu );
250 } 255 }
251 m_events.insert(ev.uid(), ev ); 256 m_events.insert(ev.uid(), ev );
252 m_year = m_month = m_day = -1; 257 m_year = m_month = m_day = -1;
253 delete rec; 258 delete rec;
254 rec = 0; 259 rec = 0;
255 } 260 }
256 261
257 munmap(map_addr, attribut.st_size ); 262 munmap(map_addr, attribut.st_size );
258 263
259 qWarning("counts %d records loaded!", m_events.count() ); 264 owarn << "counts " << m_events.count() << " records loaded!" << oendl;
260 return true; 265 return true;
261} 266}
262bool OPimTodoAccessXML::reload() { 267bool OPimTodoAccessXML::reload() {
263 m_events.clear(); 268 m_events.clear();
264 return load(); 269 return load();
265} 270}
266bool OPimTodoAccessXML::save() { 271bool OPimTodoAccessXML::save() {
267// qWarning("saving"); 272// owarn << "saving" << oendl;
268 if (!m_opened || !m_changed ) { 273 if (!m_opened || !m_changed ) {
269// qWarning("not saving"); 274// owarn << "not saving" << oendl;
270 return true; 275 return true;
271 } 276 }
272 QString strNewFile = m_file + ".new"; 277 QString strNewFile = m_file + ".new";
273 QFile f( strNewFile ); 278 QFile f( strNewFile );
274 if (!f.open( IO_WriteOnly|IO_Raw ) ) 279 if (!f.open( IO_WriteOnly|IO_Raw ) )
275 return false; 280 return false;
276 281
277 int written; 282 int written;
278 QString out; 283 QString out;
279 out = "<!DOCTYPE Tasks>\n<Tasks>\n"; 284 out = "<!DOCTYPE Tasks>\n<Tasks>\n";
280 285
281 // for all todos 286 // for all todos
@@ -298,25 +303,25 @@ bool OPimTodoAccessXML::save() {
298 QCString cstr = out.utf8(); 303 QCString cstr = out.utf8();
299 written = f.writeBlock( cstr.data(), cstr.length() ); 304 written = f.writeBlock( cstr.data(), cstr.length() );
300 305
301 if ( written != (int)cstr.length() ) { 306 if ( written != (int)cstr.length() ) {
302 f.close(); 307 f.close();
303 QFile::remove( strNewFile ); 308 QFile::remove( strNewFile );
304 return false; 309 return false;
305 } 310 }
306 /* flush before renaming */ 311 /* flush before renaming */
307 f.close(); 312 f.close();
308 313
309 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) { 314 if( ::rename( strNewFile.latin1(), m_file.latin1() ) < 0 ) {
310// qWarning("error renaming"); 315// owarn << "error renaming" << oendl;
311 QFile::remove( strNewFile ); 316 QFile::remove( strNewFile );
312 } 317 }
313 318
314 m_changed = false; 319 m_changed = false;
315 return true; 320 return true;
316} 321}
317QArray<int> OPimTodoAccessXML::allRecords()const { 322QArray<int> OPimTodoAccessXML::allRecords()const {
318 QArray<int> ids( m_events.count() ); 323 QArray<int> ids( m_events.count() );
319 QMap<int, OPimTodo>::ConstIterator it; 324 QMap<int, OPimTodo>::ConstIterator it;
320 int i = 0; 325 int i = 0;
321 326
322 for ( it = m_events.begin(); it != m_events.end(); ++it ) { 327 for ( it = m_events.begin(); it != m_events.end(); ++it ) {
@@ -336,25 +341,25 @@ OPimTodo OPimTodoAccessXML::find( int uid )const {
336 if ( it != m_events.end() ) 341 if ( it != m_events.end() )
337 todo = it.data(); 342 todo = it.data();
338 343
339 return todo; 344 return todo;
340} 345}
341void OPimTodoAccessXML::clear() { 346void OPimTodoAccessXML::clear() {
342 if (m_opened ) 347 if (m_opened )
343 m_changed = true; 348 m_changed = true;
344 349
345 m_events.clear(); 350 m_events.clear();
346} 351}
347bool OPimTodoAccessXML::add( const OPimTodo& todo ) { 352bool OPimTodoAccessXML::add( const OPimTodo& todo ) {
348// qWarning("add"); 353// owarn << "add" << oendl;
349 m_changed = true; 354 m_changed = true;
350 m_events.insert( todo.uid(), todo ); 355 m_events.insert( todo.uid(), todo );
351 356
352 return true; 357 return true;
353} 358}
354bool OPimTodoAccessXML::remove( int uid ) { 359bool OPimTodoAccessXML::remove( int uid ) {
355 m_changed = true; 360 m_changed = true;
356 m_events.remove( uid ); 361 m_events.remove( uid );
357 362
358 return true; 363 return true;
359} 364}
360bool OPimTodoAccessXML::replace( const OPimTodo& todo) { 365bool OPimTodoAccessXML::replace( const OPimTodo& todo) {
@@ -395,31 +400,31 @@ QArray<int> OPimTodoAccessXML::overDue() {
395 ids[i] = it.key(); 400 ids[i] = it.key();
396 i++; 401 i++;
397 } 402 }
398 } 403 }
399 ids.resize( i ); 404 ids.resize( i );
400 return ids; 405 return ids;
401} 406}
402 407
403 408
404/* private */ 409/* private */
405void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev, 410void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
406 const QCString& attr, const QString& val) { 411 const QCString& attr, const QString& val) {
407// qWarning("parse to do from XMLElement" ); 412// owarn << "parse to do from XMLElement" << oendl;
408 413
409 int *find=0; 414 int *find=0;
410 415
411 find = (*dict)[ attr.data() ]; 416 find = (*dict)[ attr.data() ];
412 if (!find ) { 417 if (!find ) {
413// qWarning("Unknown option" + it.key() ); 418// owarn << "Unknown option" + it.key() << oendl;
414 ev.setCustomField( attr, val ); 419 ev.setCustomField( attr, val );
415 return; 420 return;
416 } 421 }
417 422
418 switch( *find ) { 423 switch( *find ) {
419 case OPimTodo::Uid: 424 case OPimTodo::Uid:
420 ev.setUid( val.toInt() ); 425 ev.setUid( val.toInt() );
421 break; 426 break;
422 case OPimTodo::Category: 427 case OPimTodo::Category:
423 ev.setCategories( ev.idsFromString( val ) ); 428 ev.setCategories( ev.idsFromString( val ) );
424 break; 429 break;
425 case OPimTodo::HasDate: 430 case OPimTodo::HasDate:
@@ -454,26 +459,26 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
454 break; 459 break;
455 case OPimTodo::StartDate: 460 case OPimTodo::StartDate:
456 ev.setStartDate( OPimDateConversion::dateFromString( val ) ); 461 ev.setStartDate( OPimDateConversion::dateFromString( val ) );
457 break; 462 break;
458 case OPimTodo::State: 463 case OPimTodo::State:
459 ev.setState( val.toInt() ); 464 ev.setState( val.toInt() );
460 break; 465 break;
461 case OPimTodo::Alarms:{ 466 case OPimTodo::Alarms:{
462 OPimNotifyManager &manager = ev.notifiers(); 467 OPimNotifyManager &manager = ev.notifiers();
463 QStringList als = QStringList::split(";", val ); 468 QStringList als = QStringList::split(";", val );
464 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) { 469 for (QStringList::Iterator it = als.begin(); it != als.end(); ++it ) {
465 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty 470 QStringList alarm = QStringList::split(":", (*it), TRUE ); // allow empty
466 qWarning("alarm: %s", alarm.join("___").latin1() ); 471 owarn << "alarm: " << alarm.join("___") << "" << oendl;
467 qWarning("alarm[0]: %s %s", alarm[0].latin1(), OPimDateConversion::dateTimeFromString( alarm[0] ).toString().latin1() ); 472 owarn << "alarm[0]: " << alarm[0] << " " << OPimDateConversion::dateTimeFromString( alarm[0] ).toString() << "" << oendl;
468 OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() ); 473 OPimAlarm al( alarm[2].toInt(), OPimDateConversion::dateTimeFromString( alarm[0] ), alarm[1].toInt() );
469 manager.add( al ); 474 manager.add( al );
470 } 475 }
471 } 476 }
472 break; 477 break;
473 case OPimTodo::Reminders:{ 478 case OPimTodo::Reminders:{
474 OPimNotifyManager &manager = ev.notifiers(); 479 OPimNotifyManager &manager = ev.notifiers();
475 QStringList rems = QStringList::split(";", val ); 480 QStringList rems = QStringList::split(";", val );
476 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) { 481 for (QStringList::Iterator it = rems.begin(); it != rems.end(); ++it ) {
477 OPimReminder rem( (*it).toInt() ); 482 OPimReminder rem( (*it).toInt() );
478 manager.add( rem ); 483 manager.add( rem );
479 } 484 }
@@ -528,29 +533,29 @@ void OPimTodoAccessXML::todo( QAsciiDict<int>* dict, OPimTodo& ev,
528 break; 533 break;
529 } 534 }
530 default: 535 default:
531 ev.setCustomField( attr, val ); 536 ev.setCustomField( attr, val );
532 break; 537 break;
533 } 538 }
534} 539}
535 540
536// from PalmtopRecord... GPL ### FIXME 541// from PalmtopRecord... GPL ### FIXME
537namespace { 542namespace {
538QString customToXml(const QMap<QString, QString>& customMap ) 543QString customToXml(const QMap<QString, QString>& customMap )
539{ 544{
540 //qWarning(QString("writing custom %1").arg(customMap.count())); 545 //owarn << QString("writing custom %1").arg(customMap.count()) << oendl;
541 QString buf(" "); 546 QString buf(" ");
542 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin(); 547 for ( QMap<QString, QString>::ConstIterator cit = customMap.begin();
543 cit != customMap.end(); ++cit) { 548 cit != customMap.end(); ++cit) {
544 // qWarning(".ITEM."); 549// owarn << ".ITEM." << oendl;
545 buf += cit.key(); 550 buf += cit.key();
546 buf += "=\""; 551 buf += "=\"";
547 buf += Qtopia::escapeString(cit.data()); 552 buf += Qtopia::escapeString(cit.data());
548 buf += "\" "; 553 buf += "\" ";
549 } 554 }
550 return buf; 555 return buf;
551} 556}
552 557
553 558
554} 559}
555 560
556QString OPimTodoAccessXML::toString( const OPimTodo& ev )const { 561QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
@@ -561,25 +566,25 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
561 str += "Priority=\"" + QString::number( ev.priority() ) + "\" "; 566 str += "Priority=\"" + QString::number( ev.priority() ) + "\" ";
562 str += "Progress=\"" + QString::number(ev.progress() ) + "\" "; 567 str += "Progress=\"" + QString::number(ev.progress() ) + "\" ";
563 568
564 str += "Categories=\"" + toString( ev.categories() ) + "\" "; 569 str += "Categories=\"" + toString( ev.categories() ) + "\" ";
565 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" "; 570 str += "Description=\"" + Qtopia::escapeString( ev.description() ) + "\" ";
566 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" "; 571 str += "Summary=\"" + Qtopia::escapeString( ev.summary() ) + "\" ";
567 572
568 if ( ev.hasDueDate() ) { 573 if ( ev.hasDueDate() ) {
569 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" "; 574 str += "DateYear=\"" + QString::number( ev.dueDate().year() ) + "\" ";
570 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" "; 575 str += "DateMonth=\"" + QString::number( ev.dueDate().month() ) + "\" ";
571 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" "; 576 str += "DateDay=\"" + QString::number( ev.dueDate().day() ) + "\" ";
572 } 577 }
573// qWarning( "Uid %d", ev.uid() ); 578// owarn << "Uid " << ev.uid() << "" << oendl;
574 str += "Uid=\"" + QString::number( ev.uid() ) + "\" "; 579 str += "Uid=\"" + QString::number( ev.uid() ) + "\" ";
575 580
576// append the extra options 581// append the extra options
577 /* FIXME Qtopia::Record this is currently not 582 /* FIXME Qtopia::Record this is currently not
578 * possible you can set custom fields 583 * possible you can set custom fields
579 * but don' iterate over the list 584 * but don' iterate over the list
580 * I may do #define private protected 585 * I may do #define private protected
581 * for this case - cough --zecke 586 * for this case - cough --zecke
582 */ 587 */
583 /* 588 /*
584 QMap<QString, QString> extras = ev.extras(); 589 QMap<QString, QString> extras = ev.extras();
585 QMap<QString, QString>::Iterator extIt; 590 QMap<QString, QString>::Iterator extIt;
@@ -608,25 +613,25 @@ QString OPimTodoAccessXML::toString( const OPimTodo& ev )const {
608 QStringList als; 613 QStringList als;
609 OPimNotifyManager::Alarms::Iterator it = alarms.begin(); 614 OPimNotifyManager::Alarms::Iterator it = alarms.begin();
610 for ( ; it != alarms.end(); ++it ) { 615 for ( ; it != alarms.end(); ++it ) {
611 /* only if time is valid */ 616 /* only if time is valid */
612 if ( (*it).dateTime().isValid() ) { 617 if ( (*it).dateTime().isValid() ) {
613 als << OPimDateConversion::dateTimeToString( (*it).dateTime() ) 618 als << OPimDateConversion::dateTimeToString( (*it).dateTime() )
614 + ":" + QString::number( (*it).duration() ) 619 + ":" + QString::number( (*it).duration() )
615 + ":" + QString::number( (*it).sound() ) 620 + ":" + QString::number( (*it).sound() )
616 + ":"; 621 + ":";
617 } 622 }
618 } 623 }
619 // now write the list 624 // now write the list
620 qWarning("als: %s", als.join("____________").latin1() ); 625 owarn << "als: " << als.join("____________") << "" << oendl;
621 str += "Alarms=\""+als.join(";") +"\" "; 626 str += "Alarms=\""+als.join(";") +"\" ";
622 } 627 }
623 628
624 /* 629 /*
625 * now the same for reminders but more easy. We just save the uid of the OPimEvent. 630 * now the same for reminders but more easy. We just save the uid of the OPimEvent.
626 */ 631 */
627 OPimNotifyManager::Reminders reminders = manager.reminders(); 632 OPimNotifyManager::Reminders reminders = manager.reminders();
628 if (!reminders.isEmpty() ) { 633 if (!reminders.isEmpty() ) {
629 OPimNotifyManager::Reminders::Iterator it = reminders.begin(); 634 OPimNotifyManager::Reminders::Iterator it = reminders.begin();
630 QStringList records; 635 QStringList records;
631 for ( ; it != reminders.end(); ++it ) { 636 for ( ; it != reminders.end(); ++it ) {
632 records << QString::number( (*it).recordUid() ); 637 records << QString::number( (*it).recordUid() );
@@ -829,25 +834,25 @@ QArray<int> OPimTodoAccessXML::sorted( bool asc, int sortOrder,
829 834
830 /* show category */ 835 /* show category */
831 /* -1 == unfiled */ 836 /* -1 == unfiled */
832 if ( bCat && cat == -1 ) { 837 if ( bCat && cat == -1 ) {
833 if(!(*it).categories().isEmpty() ) 838 if(!(*it).categories().isEmpty() )
834 continue; 839 continue;
835 }else if ( bCat && cat != 0) 840 }else if ( bCat && cat != 0)
836 if (!(*it).categories().contains( cat ) ) { 841 if (!(*it).categories().contains( cat ) ) {
837 continue; 842 continue;
838 } 843 }
839 /* isOverdue but we should not show overdue - why?*/ 844 /* isOverdue but we should not show overdue - why?*/
840/* if ( (*it).isOverdue() && !bOnly ) { 845/* if ( (*it).isOverdue() && !bOnly ) {
841 qWarning("item is overdue but !bOnly"); 846 owarn << "item is overdue but !bOnly" << oendl;
842 continue; 847 continue;
843 } 848 }
844*/ 849*/
845 if ( !(*it).isOverdue() && bOnly ) { 850 if ( !(*it).isOverdue() && bOnly ) {
846 continue; 851 continue;
847 } 852 }
848 853
849 if ((*it).isCompleted() && comp ) { 854 if ((*it).isCompleted() && comp ) {
850 continue; 855 continue;
851 } 856 }
852 857
853 858
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
@@ -25,24 +25,26 @@
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#define QTOPIA_INTERNAL_CONTACT_MRE 30#define QTOPIA_INTERNAL_CONTACT_MRE
31 31
32#include "opimcontact.h" 32#include "opimcontact.h"
33 33
34/* OPIE */ 34/* OPIE */
35#include <opie2/opimresolver.h> 35#include <opie2/opimresolver.h>
36#include <opie2/opimdateconversion.h> 36#include <opie2/opimdateconversion.h>
37#include <opie2/odebug.h>
38
37#include <qpe/stringutil.h> 39#include <qpe/stringutil.h>
38#include <qpe/timestring.h> 40#include <qpe/timestring.h>
39#include <qpe/config.h> 41#include <qpe/config.h>
40 42
41/* QT */ 43/* QT */
42#include <qstylesheet.h> 44#include <qstylesheet.h>
43 45
44/* STD */ 46/* STD */
45#include <stdio.h> 47#include <stdio.h>
46 48
47/*! 49/*!
48 \class Contact contact.h 50 \class Contact contact.h
@@ -70,25 +72,25 @@ OPimContact::OPimContact():OPimRecord(), mMap(), d( 0 )
70 set from \a fromMap. 72 set from \a fromMap.
71*/ 73*/
72OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 ) 74OPimContact::OPimContact( const QMap<int, QString> &fromMap ):OPimRecord(), mMap( fromMap ), d( 0 )
73{ 75{
74 QString cats = mMap[ Qtopia::AddressCategory ]; 76 QString cats = mMap[ Qtopia::AddressCategory ];
75 if ( !cats.isEmpty() ) 77 if ( !cats.isEmpty() )
76 setCategories( idsFromString( cats ) ); 78 setCategories( idsFromString( cats ) );
77 79
78 QString uidStr = find( Qtopia::AddressUid ); 80 QString uidStr = find( Qtopia::AddressUid );
79 81
80 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) ) 82 if ( uidStr.isEmpty() || ( uidStr.toInt() == 0 ) )
81 { 83 {
82 qWarning( "Invalid UID found. Generate new one.." ); 84 owarn << "Invalid UID found. Generate new one.." << oendl;
83 setUid( uidGen().generate() ); 85 setUid( uidGen().generate() );
84 } 86 }
85 else 87 else
86 setUid( uidStr.toInt() ); 88 setUid( uidStr.toInt() );
87 89
88 // if ( !uidStr.isEmpty() ) 90 // if ( !uidStr.isEmpty() )
89 // setUid( uidStr.toInt() ); 91 // setUid( uidStr.toInt() );
90} 92}
91 93
92/*! 94/*!
93 Destroys a contact. 95 Destroys a contact.
94*/ 96*/
@@ -922,25 +924,25 @@ QStringList OPimContact::childrenList() const
922 924
923/*! 925/*!
924 Returns a list of email addresses belonging to the contact, including 926 Returns a list of email addresses belonging to the contact, including
925 the default email address. 927 the default email address.
926*/ 928*/
927QStringList OPimContact::emailList() const 929QStringList OPimContact::emailList() const
928{ 930{
929 QString emailStr = emails(); 931 QString emailStr = emails();
930 932
931 QStringList r; 933 QStringList r;
932 if ( !emailStr.isEmpty() ) 934 if ( !emailStr.isEmpty() )
933 { 935 {
934 qDebug( " emailstr " ); 936 odebug << " emailstr " << oendl;
935 QStringList l = QStringList::split( emailSeparator(), emailStr ); 937 QStringList l = QStringList::split( emailSeparator(), emailStr );
936 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it ) 938 for ( QStringList::ConstIterator it = l.begin();it != l.end();++it )
937 r += ( *it ).simplifyWhiteSpace(); 939 r += ( *it ).simplifyWhiteSpace();
938 } 940 }
939 941
940 return r; 942 return r;
941} 943}
942 944
943/*! 945/*!
944 \overload 946 \overload
945 947
946 Generates the string for the contact to be filed as from the first, 948 Generates the string for the contact to be filed as from the first,
@@ -1127,44 +1129,44 @@ class QString OPimContact::recordField( int pos ) const
1127// In future releases, we should store birthday and anniversary 1129// In future releases, we should store birthday and anniversary
1128// internally as QDate instead of QString ! 1130// internally as QDate instead of QString !
1129// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se) 1131// QString is always too complicate to interprete (DD.MM.YY, DD/MM/YY, MM/DD/YY, etc..)(se)
1130 1132
1131/*! \fn void OPimContact::setBirthday( const QDate& date ) 1133/*! \fn void OPimContact::setBirthday( const QDate& date )
1132 Sets the birthday for the contact to \a date. If date is null 1134 Sets the birthday for the contact to \a date. If date is null
1133 the current stored date will be removed. 1135 the current stored date will be removed.
1134*/ 1136*/
1135void OPimContact::setBirthday( const QDate &v ) 1137void OPimContact::setBirthday( const QDate &v )
1136{ 1138{
1137 if ( v.isNull() ) 1139 if ( v.isNull() )
1138 { 1140 {
1139 qWarning( "Remove Birthday" ); 1141 owarn << "Remove Birthday" << oendl;
1140 replace( Qtopia::Birthday, QString::null ); 1142 replace( Qtopia::Birthday, QString::null );
1141 return ; 1143 return ;
1142 } 1144 }
1143 1145
1144 if ( v.isValid() ) 1146 if ( v.isValid() )
1145 replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) ); 1147 replace( Qtopia::Birthday, OPimDateConversion::dateToString( v ) );
1146 1148
1147} 1149}
1148 1150
1149 1151
1150/*! \fn void OPimContact::setAnniversary( const QDate &date ) 1152/*! \fn void OPimContact::setAnniversary( const QDate &date )
1151 Sets the anniversary of the contact to \a date. If date is 1153 Sets the anniversary of the contact to \a date. If date is
1152 null, the current stored date will be removed. 1154 null, the current stored date will be removed.
1153*/ 1155*/
1154void OPimContact::setAnniversary( const QDate &v ) 1156void OPimContact::setAnniversary( const QDate &v )
1155{ 1157{
1156 if ( v.isNull() ) 1158 if ( v.isNull() )
1157 { 1159 {
1158 qWarning( "Remove Anniversary" ); 1160 owarn << "Remove Anniversary" << oendl;
1159 replace( Qtopia::Anniversary, QString::null ); 1161 replace( Qtopia::Anniversary, QString::null );
1160 return ; 1162 return ;
1161 } 1163 }
1162 1164
1163 if ( v.isValid() ) 1165 if ( v.isValid() )
1164 replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) ); 1166 replace( Qtopia::Anniversary, OPimDateConversion::dateToString( v ) );
1165} 1167}
1166 1168
1167 1169
1168/*! \fn QDate OPimContact::birthday() const 1170/*! \fn QDate OPimContact::birthday() const
1169 Returns the birthday of the contact. 1171 Returns the birthday of the contact.
1170*/ 1172*/
@@ -1187,25 +1189,25 @@ QDate OPimContact::anniversary() const
1187 QDate empty; 1189 QDate empty;
1188 QString str = find( Qtopia::Anniversary ); 1190 QString str = find( Qtopia::Anniversary );
1189 // qWarning ("Anniversary %s", str.latin1() ); 1191 // qWarning ("Anniversary %s", str.latin1() );
1190 if ( !str.isEmpty() ) 1192 if ( !str.isEmpty() )
1191 return OPimDateConversion::dateFromString ( str ); 1193 return OPimDateConversion::dateFromString ( str );
1192 else 1194 else
1193 return empty; 1195 return empty;
1194} 1196}
1195 1197
1196 1198
1197void OPimContact::insertEmail( const QString &v ) 1199void OPimContact::insertEmail( const QString &v )
1198{ 1200{
1199 //qDebug("insertEmail %s", v.latin1()); 1201 //odebug << "insertEmail " << v << "" << oendl;
1200 QString e = v.simplifyWhiteSpace(); 1202 QString e = v.simplifyWhiteSpace();
1201 QString def = defaultEmail(); 1203 QString def = defaultEmail();
1202 1204
1203 // if no default, set it as the default email and don't insert 1205 // if no default, set it as the default email and don't insert
1204 if ( def.isEmpty() ) 1206 if ( def.isEmpty() )
1205 { 1207 {
1206 setDefaultEmail( e ); // will insert into the list for us 1208 setDefaultEmail( e ); // will insert into the list for us
1207 return ; 1209 return ;
1208 } 1210 }
1209 1211
1210 // otherwise, insert assuming doesn't already exist 1212 // otherwise, insert assuming doesn't already exist
1211 QString emailsStr = find( Qtopia::Emails ); 1213 QString emailsStr = find( Qtopia::Emails );
@@ -1221,54 +1223,54 @@ void OPimContact::insertEmail( const QString &v )
1221 void OPimContact::removeEmail( const QString &v ) 1223 void OPimContact::removeEmail( const QString &v )
1222{ 1224{
1223 QString e = v.simplifyWhiteSpace(); 1225 QString e = v.simplifyWhiteSpace();
1224 QString def = defaultEmail(); 1226 QString def = defaultEmail();
1225 QString emailsStr = find( Qtopia::Emails ); 1227 QString emailsStr = find( Qtopia::Emails );
1226 QStringList emails = emailList(); 1228 QStringList emails = emailList();
1227 1229
1228 // otherwise, must first contain it 1230 // otherwise, must first contain it
1229 if ( !emailsStr.contains( e ) ) 1231 if ( !emailsStr.contains( e ) )
1230 return ; 1232 return ;
1231 1233
1232 // remove it 1234 // remove it
1233 //qDebug(" removing email from list %s", e.latin1()); 1235 //odebug << " removing email from list " << e << "" << oendl;
1234 emails.remove( e ); 1236 emails.remove( e );
1235 // reset the string 1237 // reset the string
1236 emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator 1238 emailsStr = emails.join( emailSeparator() ); // Sharp's brain dead separator
1237 replace( Qtopia::Emails, emailsStr ); 1239 replace( Qtopia::Emails, emailsStr );
1238 1240
1239 // if default, then replace the default email with the first one 1241 // if default, then replace the default email with the first one
1240 if ( def == e ) 1242 if ( def == e )
1241 { 1243 {
1242 //qDebug("removeEmail is default; setting new default"); 1244 //odebug << "removeEmail is default; setting new default" << oendl;
1243 if ( !emails.count() ) 1245 if ( !emails.count() )
1244 clearEmails(); 1246 clearEmails();
1245 else // setDefaultEmail will remove e from the list 1247 else // setDefaultEmail will remove e from the list
1246 setDefaultEmail( emails.first() ); 1248 setDefaultEmail( emails.first() );
1247 } 1249 }
1248} 1250}
1249 1251
1250 1252
1251void OPimContact::clearEmails() 1253void OPimContact::clearEmails()
1252{ 1254{
1253 mMap.remove( Qtopia::DefaultEmail ); 1255 mMap.remove( Qtopia::DefaultEmail );
1254 mMap.remove( Qtopia::Emails ); 1256 mMap.remove( Qtopia::Emails );
1255} 1257}
1256 1258
1257 1259
1258void OPimContact::setDefaultEmail( const QString &v ) 1260void OPimContact::setDefaultEmail( const QString &v )
1259{ 1261{
1260 QString e = v.simplifyWhiteSpace(); 1262 QString e = v.simplifyWhiteSpace();
1261 1263
1262 //qDebug("OPimContact::setDefaultEmail %s", e.latin1()); 1264 //odebug << "OPimContact::setDefaultEmail " << e << "" << oendl;
1263 replace( Qtopia::DefaultEmail, e ); 1265 replace( Qtopia::DefaultEmail, e );
1264 1266
1265 if ( !e.isEmpty() ) 1267 if ( !e.isEmpty() )
1266 insertEmail( e ); 1268 insertEmail( e );
1267 1269
1268} 1270}
1269 1271
1270 1272
1271void OPimContact::insertEmails( const QStringList &v ) 1273void OPimContact::insertEmails( const QStringList &v )
1272{ 1274{
1273 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it ) 1275 for ( QStringList::ConstIterator it = v.begin(); it != v.end(); ++it )
1274 insertEmail( *it ); 1276 insertEmail( *it );
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
@@ -22,24 +22,26 @@
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimcontactfields.h" 30#include "opimcontactfields.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimcontact.h> 33#include <opie2/opimcontact.h>
34#include <opie2/odebug.h>
35
34#include <qpe/config.h> 36#include <qpe/config.h>
35 37
36/* QT */ 38/* QT */
37#include <qobject.h> 39#include <qobject.h>
38 40
39 41
40namespace Opie 42namespace Opie
41{ 43{
42/*! 44/*!
43 \internal 45 \internal
44 Returns a list of personal field names for a contact. 46 Returns a list of personal field names for a contact.
45*/ 47*/
@@ -433,84 +435,84 @@ OPimContactFields::~OPimContactFields()
433 { 435 {
434 Config cfg ( "AddressBook" ); 436 Config cfg ( "AddressBook" );
435 cfg.setGroup( "ContactFieldOrder" ); 437 cfg.setGroup( "ContactFieldOrder" );
436 cfg.writeEntry( "General", globalFieldOrder ); 438 cfg.writeEntry( "General", globalFieldOrder );
437 } 439 }
438} 440}
439 441
440 442
441 443
442void OPimContactFields::saveToRecord( OPimContact &cnt ) 444void OPimContactFields::saveToRecord( OPimContact &cnt )
443{ 445{
444 446
445 qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() ); 447 odebug << "ocontactfields saveToRecord: >" << fieldOrder << "<" << oendl;
446 448
447 // Store fieldorder into this contact. 449 // Store fieldorder into this contact.
448 cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); 450 cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder );
449 451
450 globalFieldOrder = fieldOrder; 452 globalFieldOrder = fieldOrder;
451 changedFieldOrder = true; 453 changedFieldOrder = true;
452 454
453} 455}
454 456
455void OPimContactFields::loadFromRecord( const OPimContact &cnt ) 457void OPimContactFields::loadFromRecord( const OPimContact &cnt )
456{ 458{
457 qDebug( "ocontactfields loadFromRecord" ); 459 odebug << "ocontactfields loadFromRecord" << oendl;
458 qDebug( "loading >%s<", cnt.fullName().latin1() ); 460 odebug << "loading >" << cnt.fullName() << "<" << oendl;
459 461
460 // Get fieldorder for this contact. If none is defined, 462 // Get fieldorder for this contact. If none is defined,
461 // we will use the global one from the config file.. 463 // we will use the global one from the config file..
462 464
463 fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); 465 fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME );
464 466
465 qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() ); 467 odebug << "fieldOrder from contact>" << fieldOrder << "<" << oendl;
466 468
467 if ( fieldOrder.isEmpty() ) 469 if ( fieldOrder.isEmpty() )
468 { 470 {
469 fieldOrder = globalFieldOrder; 471 fieldOrder = globalFieldOrder;
470 } 472 }
471 473
472 474
473 qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() ); 475 odebug << "effective fieldOrder in loadFromRecord >" << fieldOrder << "<" << oendl;
474} 476}
475 477
476void OPimContactFields::setFieldOrder( int num, int index ) 478void OPimContactFields::setFieldOrder( int num, int index )
477{ 479{
478 qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index ); 480 odebug << "qcontactfields setfieldorder pos " << num << " -> " << index << "" << oendl;
479 481
480 fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ]; 482 fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ];
481 483
482 // We will store this new fieldorder globally to 484 // We will store this new fieldorder globally to
483 // remember it for contacts which have none 485 // remember it for contacts which have none
484 globalFieldOrder = fieldOrder; 486 globalFieldOrder = fieldOrder;
485 changedFieldOrder = true; 487 changedFieldOrder = true;
486 488
487 qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); 489 odebug << "fieldOrder >" << fieldOrder << "<" << oendl;
488} 490}
489 491
490int OPimContactFields::getFieldOrder( int num, int defIndex ) 492int OPimContactFields::getFieldOrder( int num, int defIndex )
491{ 493{
492 qDebug( "ocontactfields getFieldOrder" ); 494 odebug << "ocontactfields getFieldOrder" << oendl;
493 qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); 495 odebug << "fieldOrder >" << fieldOrder << "<" << oendl;
494 496
495 // Get index of combo as char.. 497 // Get index of combo as char..
496 QChar poschar = fieldOrder[ num ]; 498 QChar poschar = fieldOrder[ num ];
497 499
498 bool ok; 500 bool ok;
499 int ret = 0; 501 int ret = 0;
500 // Convert char to number.. 502 // Convert char to number..
501 if ( !( poschar == QChar::null ) ) 503 if ( !( poschar == QChar::null ) )
502 ret = QString( poschar ).toInt( &ok, 16 ); 504 ret = QString( poschar ).toInt( &ok, 16 );
503 else 505 else
504 ok = false; 506 ok = false;
505 507
506 // Return default value if index for 508 // Return default value if index for
507 // num was not set or if anything else happened.. 509 // num was not set or if anything else happened..
508 if ( !ok ) ret = defIndex; 510 if ( !ok ) ret = defIndex;
509 511
510 qDebug( "returning >%i<", ret ); 512 odebug << "returning >" << ret << "<" << oendl;
511 513
512 return ret; 514 return ret;
513 515
514} 516}
515 517
516} 518}
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
@@ -19,43 +19,45 @@ _;:, .> :=|. This program is free software; you can
19++= -. .` .: details. 19++= -. .` .: details.
20: = ...= . :.=- 20: = ...= . :.=-
21-. .:....=;==+<; You should have received a copy of the GNU 21-. .:....=;==+<; You should have received a copy of the GNU
22 -_. . . )=. = Library General Public License along with 22 -_. . . )=. = Library General Public License along with
23 -- :-=` this library; see the file COPYING.LIB. 23 -- :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28 28
29/* OPIE */ 29/* OPIE */
30#include <opie2/opimdateconversion.h> 30#include <opie2/opimdateconversion.h>
31#include <opie2/odebug.h>
32
31#include <qpe/timeconversion.h> 33#include <qpe/timeconversion.h>
32 34
33namespace Opie 35namespace Opie
34{ 36{
35 37
36QString OPimDateConversion::dateToString( const QDate &d ) 38QString OPimDateConversion::dateToString( const QDate &d )
37{ 39{
38 if ( d.isNull() || !d.isValid() ) 40 if ( d.isNull() || !d.isValid() )
39 return QString::null; 41 return QString::null;
40 42
41 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231 43 // ISO format in year, month, day (YYYYMMDD); e.g. 20021231
42 QString year = QString::number( d.year() ); 44 QString year = QString::number( d.year() );
43 QString month = QString::number( d.month() ); 45 QString month = QString::number( d.month() );
44 month = month.rightJustify( 2, '0' ); 46 month = month.rightJustify( 2, '0' );
45 QString day = QString::number( d.day() ); 47 QString day = QString::number( d.day() );
46 day = day.rightJustify( 2, '0' ); 48 day = day.rightJustify( 2, '0' );
47 49
48 QString str = year + month + day; 50 QString str = year + month + day;
49 //qDebug( "\tPimContact dateToStr = %s", str.latin1() ); 51 //odebug << "\tPimContact dateToStr = " << str << "" << oendl;
50 52
51 return str; 53 return str;
52} 54}
53 55
54 56
55QDate OPimDateConversion::dateFromString( const QString& s ) 57QDate OPimDateConversion::dateFromString( const QString& s )
56{ 58{
57 QDate date; 59 QDate date;
58 60
59 if ( s.isEmpty() ) 61 if ( s.isEmpty() )
60 return date; 62 return date;
61 63
@@ -65,42 +67,42 @@ QDate OPimDateConversion::dateFromString( const QString& s )
65 if ( date.isValid() ) 67 if ( date.isValid() )
66 return date; 68 return date;
67 69
68 // Read ISO-Format (YYYYMMDD) 70 // Read ISO-Format (YYYYMMDD)
69 int year = s.mid( 0, 4 ).toInt(); 71 int year = s.mid( 0, 4 ).toInt();
70 int month = s.mid( 4, 2 ).toInt(); 72 int month = s.mid( 4, 2 ).toInt();
71 int day = s.mid( 6, 2 ).toInt(); 73 int day = s.mid( 6, 2 ).toInt();
72 74
73 // do some quick sanity checking -eilers 75 // do some quick sanity checking -eilers
74 // but we isValid() again? -zecke 76 // but we isValid() again? -zecke
75 if ( year < 1900 || year > 3000 ) 77 if ( year < 1900 || year > 3000 )
76 { 78 {
77 qWarning( "PimContact year is not in range" ); 79 owarn << "PimContact year is not in range" << oendl;
78 return date; 80 return date;
79 } 81 }
80 if ( month < 0 || month > 12 ) 82 if ( month < 0 || month > 12 )
81 { 83 {
82 qWarning( "PimContact month is not in range" ); 84 owarn << "PimContact month is not in range" << oendl;
83 return date; 85 return date;
84 } 86 }
85 if ( day < 0 || day > 31 ) 87 if ( day < 0 || day > 31 )
86 { 88 {
87 qWarning( "PimContact day is not in range" ); 89 owarn << "PimContact day is not in range" << oendl;
88 return date; 90 return date;
89 } 91 }
90 92
91 date.setYMD( year, month, day ); 93 date.setYMD( year, month, day );
92 if ( !date.isValid() ) 94 if ( !date.isValid() )
93 { 95 {
94 qWarning( "PimContact date is not valid" ); 96 owarn << "PimContact date is not valid" << oendl;
95 return date; 97 return date;
96 } 98 }
97 99
98 return date; 100 return date;
99} 101}
100 102
101 103
102QString OPimDateConversion::dateTimeToString( const QDateTime& dt ) 104QString OPimDateConversion::dateTimeToString( const QDateTime& dt )
103{ 105{
104 if ( !dt.isValid() || dt.isNull() ) 106 if ( !dt.isValid() || dt.isNull() )
105 return QString::null; 107 return QString::null;
106 108
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
@@ -24,24 +24,26 @@
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimevent.h" 30#include "opimevent.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimrecurrence.h> 33#include <opie2/opimrecurrence.h>
34#include <opie2/opimresolver.h> 34#include <opie2/opimresolver.h>
35#include <opie2/opimnotifymanager.h> 35#include <opie2/opimnotifymanager.h>
36#include <opie2/odebug.h>
37
36#include <qpe/categories.h> 38#include <qpe/categories.h>
37#include <qpe/stringutil.h> 39#include <qpe/stringutil.h>
38 40
39/* QT */ 41/* QT */
40 42
41namespace Opie 43namespace Opie
42{ 44{
43 45
44int OCalendarHelper::week( const QDate& date ) 46int OCalendarHelper::week( const QDate& date )
45{ 47{
46 // Calculates the week this date is in within that 48 // Calculates the week this date is in within that
47 // month. Equals the "row" is is in in the month view 49 // month. Equals the "row" is is in in the month view
@@ -632,28 +634,28 @@ void OPimEvent::fromMap( const QMap<int, QString>& map )
632 634
633 /* AllDay is always in UTC */ 635 /* AllDay is always in UTC */
634 if ( isAllDay() ) 636 if ( isAllDay() )
635 { 637 {
636 OPimTimeZone utc = OPimTimeZone::utc(); 638 OPimTimeZone utc = OPimTimeZone::utc();
637 setStartDateTime( utc.fromUTCDateTime( start ) ); 639 setStartDateTime( utc.fromUTCDateTime( start ) );
638 setEndDateTime ( utc.fromUTCDateTime( end ) ); 640 setEndDateTime ( utc.fromUTCDateTime( end ) );
639 setTimeZone( "UTC" ); // make sure it is really utc 641 setTimeZone( "UTC" ); // make sure it is really utc
640 } 642 }
641 else 643 else
642 { 644 {
643 /* to current date time */ 645 /* to current date time */
644 // qWarning(" Start is %d", start ); 646 // owarn << " Start is " << start << "" << oendl;
645 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() ); 647 OPimTimeZone zone( timeZone().isEmpty() ? OPimTimeZone::current() : timeZone() );
646 QDateTime date = zone.toDateTime( start ); 648 QDateTime date = zone.toDateTime( start );
647 qWarning( " Start is %s", date.toString().latin1() ); 649 owarn << " Start is " << date.toString() << "" << oendl;
648 setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) ); 650 setStartDateTime( zone.toDateTime( date, OPimTimeZone::current() ) );
649 651
650 date = zone.toDateTime( end ); 652 date = zone.toDateTime( end );
651 setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) ); 653 setEndDateTime ( zone.toDateTime( date, OPimTimeZone::current() ) );
652 } 654 }
653 655
654 int alarmTime = -1; 656 int alarmTime = -1;
655 if ( !map[ OPimEvent::FAlarm ].isEmpty() ) 657 if ( !map[ OPimEvent::FAlarm ].isEmpty() )
656 alarmTime = map[ OPimEvent::FAlarm ].toInt(); 658 alarmTime = map[ OPimEvent::FAlarm ].toInt();
657 659
658 int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent ); 660 int sound = ( ( map[ OPimEvent::FSound ] == "loud" ) ? OPimAlarm::Loud : OPimAlarm::Silent );
659 if ( ( alarmTime != -1 ) ) 661 if ( ( alarmTime != -1 ) )
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
@@ -22,24 +22,25 @@
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimnotifymanager.h" 30#include "opimnotifymanager.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimdateconversion.h> 33#include <opie2/opimdateconversion.h>
34#include <opie2/odebug.h>
34 35
35/* QT */ 36/* QT */
36#include <qstringlist.h> 37#include <qstringlist.h>
37 38
38namespace Opie 39namespace Opie
39{ 40{
40 41
41OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al ) 42OPimNotifyManager::OPimNotifyManager( const Reminders& rem, const Alarms& al )
42 : m_rem( rem ), m_al( al ) 43 : m_rem( rem ), m_al( al )
43{} 44{}
44 45
45 46
@@ -154,25 +155,25 @@ void OPimNotifyManager::registerNotify( const OPimNotify& )
154/** 155/**
155 * same as above... 156 * same as above...
156 * Also implement Url model 157 * Also implement Url model
157 * have a MainWindow.... 158 * have a MainWindow....
158 */ 159 */
159void OPimNotifyManager::deregister( const OPimNotify& ) 160void OPimNotifyManager::deregister( const OPimNotify& )
160{ 161{
161} 162}
162 163
163 164
164bool OPimNotifyManager::isEmpty() const 165bool OPimNotifyManager::isEmpty() const
165{ 166{
166 qWarning( "is Empty called on OPimNotifyManager %d %d", m_rem.count(), m_al.count() ); 167 owarn << "is Empty called on OPimNotifyManager " << m_rem.count() << " " << m_al.count() << "" << oendl;
167 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true; 168 if ( m_rem.isEmpty() && m_al.isEmpty() ) return true;
168 else return false; 169 else return false;
169} 170}
170 171
171 172
172// Taken from otodoaccessxml.. code duplication bad. any alternative? 173// Taken from otodoaccessxml.. code duplication bad. any alternative?
173QString OPimNotifyManager::alarmsToString() const 174QString OPimNotifyManager::alarmsToString() const
174{ 175{
175 QString str; 176 QString str;
176 177
177 OPimNotifyManager::Alarms alarms = m_al; 178 OPimNotifyManager::Alarms alarms = m_al;
178 if ( !alarms.isEmpty() ) 179 if ( !alarms.isEmpty() )
@@ -182,25 +183,25 @@ QString OPimNotifyManager::alarmsToString() const
182 for ( ; it != alarms.end(); ++it ) 183 for ( ; it != alarms.end(); ++it )
183 { 184 {
184 /* only if time is valid */ 185 /* only if time is valid */
185 if ( ( *it ).dateTime().isValid() ) 186 if ( ( *it ).dateTime().isValid() )
186 { 187 {
187 als << OPimDateConversion::dateTimeToString( ( *it ).dateTime() ) 188 als << OPimDateConversion::dateTimeToString( ( *it ).dateTime() )
188 + ":" + QString::number( ( *it ).duration() ) 189 + ":" + QString::number( ( *it ).duration() )
189 + ":" + QString::number( ( *it ).sound() ) 190 + ":" + QString::number( ( *it ).sound() )
190 + ":"; 191 + ":";
191 } 192 }
192 } 193 }
193 // now write the list 194 // now write the list
194 qWarning( "als: %s", als.join( "____________" ).latin1() ); 195 owarn << "als: " << als.join( "____________" ) << "" << oendl;
195 str = als.join( ";" ); 196 str = als.join( ";" );
196 } 197 }
197 198
198 return str; 199 return str;
199} 200}
200 201
201 202
202QString OPimNotifyManager::remindersToString() const 203QString OPimNotifyManager::remindersToString() const
203{ 204{
204 QString str; 205 QString str;
205 206
206 OPimNotifyManager::Reminders reminders = m_rem; 207 OPimNotifyManager::Reminders reminders = m_rem;
@@ -216,25 +217,25 @@ QString OPimNotifyManager::remindersToString() const
216 } 217 }
217 218
218 return str; 219 return str;
219} 220}
220 221
221 222
222void OPimNotifyManager::alarmsFromString( const QString& str ) 223void OPimNotifyManager::alarmsFromString( const QString& str )
223{ 224{
224 QStringList als = QStringList::split( ";", str ); 225 QStringList als = QStringList::split( ";", str );
225 for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it ) 226 for ( QStringList::Iterator it = als.begin(); it != als.end(); ++it )
226 { 227 {
227 QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty 228 QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty
228 qWarning( "alarm: %s", alarm.join( "___" ).latin1() ); 229 owarn << "alarm: " << alarm.join( "___" ) << "" << oendl;
229 qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(), 230 qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(),
230 OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() ); 231 OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() );
231 OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ), 232 OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ),
232 alarm[ 1 ].toInt() ); 233 alarm[ 1 ].toInt() );
233 add( al ); 234 add( al );
234 } 235 }
235} 236}
236 237
237 238
238void OPimNotifyManager::remindersFromString( const QString& str ) 239void OPimNotifyManager::remindersFromString( const QString& str )
239{ 240{
240 241
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
@@ -112,25 +112,25 @@ bool OPimRecord::isEmpty() const
112 112
113 113
114/*QString OPimRecord::crossToString()const { 114/*QString OPimRecord::crossToString()const {
115 QString str; 115 QString str;
116 QMap<QString, QArray<int> >::ConstIterator it; 116 QMap<QString, QArray<int> >::ConstIterator it;
117 for (it = m_relations.begin(); it != m_relations.end(); ++it ) { 117 for (it = m_relations.begin(); it != m_relations.end(); ++it ) {
118 QArray<int> id = it.data(); 118 QArray<int> id = it.data();
119 for ( uint i = 0; i < id.size(); ++i ) { 119 for ( uint i = 0; i < id.size(); ++i ) {
120 str += it.key() + "," + QString::number( i ) + ";"; 120 str += it.key() + "," + QString::number( i ) + ";";
121 } 121 }
122 } 122 }
123 str = str.remove( str.length()-1, 1); // strip the ; 123 str = str.remove( str.length()-1, 1); // strip the ;
124 //qWarning("IDS " + str ); 124 //owarn << "IDS " + str << oendl;
125 125
126 return str; 126 return str;
127 }*/ 127 }*/
128/* if uid = 1 assign a new one */ 128/* if uid = 1 assign a new one */
129void OPimRecord::setUid( int uid ) 129void OPimRecord::setUid( int uid )
130{ 130{
131 if ( uid == 1 ) 131 if ( uid == 1 )
132 uid = uidGen().generate(); 132 uid = uidGen().generate();
133 133
134 Qtopia::Record::setUid( uid ); 134 Qtopia::Record::setUid( uid );
135}; 135};
136 136
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
@@ -20,24 +20,27 @@
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimtimezone.h" 30#include "opimtimezone.h"
31 31
32/* OPIE */
33#include <opie2/odebug.h>
34
32/* STD */ 35/* STD */
33#include <stdio.h> 36#include <stdio.h>
34#include <stdlib.h> 37#include <stdlib.h>
35#include <sys/types.h> 38#include <sys/types.h>
36 39
37namespace Opie 40namespace Opie
38{ 41{
39 42
40QDateTime utcTime( time_t t ) 43QDateTime utcTime( time_t t )
41{ 44{
42 tm * broken = ::gmtime( &t ); 45 tm * broken = ::gmtime( &t );
43 QDateTime ret; 46 QDateTime ret;
@@ -140,25 +143,25 @@ QDateTime OPimTimeZone::toDateTime( time_t t )
140{ 143{
141 return utcTime( t, m_name ); 144 return utcTime( t, m_name );
142} 145}
143 146
144 147
145/* 148/*
146 * convert dt to utc using zone.m_name 149 * convert dt to utc using zone.m_name
147 * convert utc -> timeZoneDT using this->m_name 150 * convert utc -> timeZoneDT using this->m_name
148 */ 151 */
149QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zone ) 152QDateTime OPimTimeZone::toDateTime( const QDateTime& dt, const OPimTimeZone& zone )
150{ 153{
151 time_t utc = to_Time_t( dt, zone.m_name ); 154 time_t utc = to_Time_t( dt, zone.m_name );
152 qWarning( "%d %s", utc, zone.m_name.latin1() ); 155 owarn << "" << utc << " " << zone.m_name << "" << oendl;
153 return utcTime( utc, m_name ); 156 return utcTime( utc, m_name );
154} 157}
155 158
156 159
157time_t OPimTimeZone::fromDateTime( const QDateTime& time ) 160time_t OPimTimeZone::fromDateTime( const QDateTime& time )
158{ 161{
159 return to_Time_t( time, m_name ); 162 return to_Time_t( time, m_name );
160} 163}
161 164
162 165
163time_t OPimTimeZone::fromUTCDateTime( const QDateTime& time ) 166time_t OPimTimeZone::fromUTCDateTime( const QDateTime& time )
164{ 167{
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
@@ -26,24 +26,26 @@
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimtodo.h" 30#include "opimtodo.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimstate.h> 33#include <opie2/opimstate.h>
34#include <opie2/opimrecurrence.h> 34#include <opie2/opimrecurrence.h>
35#include <opie2/opimmaintainer.h> 35#include <opie2/opimmaintainer.h>
36#include <opie2/opimnotifymanager.h> 36#include <opie2/opimnotifymanager.h>
37#include <opie2/opimresolver.h> 37#include <opie2/opimresolver.h>
38#include <opie2/odebug.h>
39
38#include <qpe/palmtopuidgen.h> 40#include <qpe/palmtopuidgen.h>
39#include <qpe/palmtoprecord.h> 41#include <qpe/palmtoprecord.h>
40#include <qpe/categories.h> 42#include <qpe/categories.h>
41#include <qpe/categoryselect.h> 43#include <qpe/categoryselect.h>
42#include <qpe/stringutil.h> 44#include <qpe/stringutil.h>
43 45
44/* QT */ 46/* QT */
45#include <qobject.h> 47#include <qobject.h>
46#include <qshared.h> 48#include <qshared.h>
47 49
48namespace Opie 50namespace Opie
49{ 51{
@@ -76,73 +78,73 @@ struct OPimTodo::OPimTodoData : public QShared
76 OPimRecurrence *recur; 78 OPimRecurrence *recur;
77 OPimMaintainer *maintainer; 79 OPimMaintainer *maintainer;
78 QDate start; 80 QDate start;
79 QDate completed; 81 QDate completed;
80 OPimNotifyManager *notifiers; 82 OPimNotifyManager *notifiers;
81}; 83};
82 84
83 85
84OPimTodo::OPimTodo( const OPimTodo &event ) 86OPimTodo::OPimTodo( const OPimTodo &event )
85 : OPimRecord( event ), data( event.data ) 87 : OPimRecord( event ), data( event.data )
86{ 88{
87 data->ref(); 89 data->ref();
88 // qWarning("ref up"); 90 // owarn << "ref up" << oendl;
89} 91}
90 92
91 93
92OPimTodo::~OPimTodo() 94OPimTodo::~OPimTodo()
93{ 95{
94 96
95 // qWarning("~OPimTodo " ); 97 // owarn << "~OPimTodo " << oendl;
96 if ( data->deref() ) 98 if ( data->deref() )
97 { 99 {
98 // qWarning("OPimTodo::dereffing"); 100 // owarn << "OPimTodo::dereffing" << oendl;
99 delete data; 101 delete data;
100 data = 0l; 102 data = 0l;
101 } 103 }
102} 104}
103 105
104 106
105OPimTodo::OPimTodo( bool completed, int priority, 107OPimTodo::OPimTodo( bool completed, int priority,
106 const QArray<int> &category, 108 const QArray<int> &category,
107 const QString& summary, 109 const QString& summary,
108 const QString &description, 110 const QString &description,
109 ushort progress, 111 ushort progress,
110 bool hasDate, QDate date, int uid ) 112 bool hasDate, QDate date, int uid )
111 : OPimRecord( uid ) 113 : OPimRecord( uid )
112{ 114{
113 // qWarning("OPimTodoData " + summary); 115 // owarn << "OPimTodoData " + summary << oendl;
114 setCategories( category ); 116 setCategories( category );
115 117
116 data = new OPimTodoData; 118 data = new OPimTodoData;
117 119
118 data->date = date; 120 data->date = date;
119 data->isCompleted = completed; 121 data->isCompleted = completed;
120 data->hasDate = hasDate; 122 data->hasDate = hasDate;
121 data->priority = priority; 123 data->priority = priority;
122 data->sum = summary; 124 data->sum = summary;
123 data->prog = progress; 125 data->prog = progress;
124 data->desc = Qtopia::simplifyMultiLineSpace( description ); 126 data->desc = Qtopia::simplifyMultiLineSpace( description );
125} 127}
126 128
127 129
128OPimTodo::OPimTodo( bool completed, int priority, 130OPimTodo::OPimTodo( bool completed, int priority,
129 const QStringList &category, 131 const QStringList &category,
130 const QString& summary, 132 const QString& summary,
131 const QString &description, 133 const QString &description,
132 ushort progress, 134 ushort progress,
133 bool hasDate, QDate date, int uid ) 135 bool hasDate, QDate date, int uid )
134 : OPimRecord( uid ) 136 : OPimRecord( uid )
135{ 137{
136 // qWarning("OPimTodoData" + summary); 138 // owarn << "OPimTodoData" + summary << oendl;
137 setCategories( idsFromString( category.join( ";" ) ) ); 139 setCategories( idsFromString( category.join( ";" ) ) );
138 140
139 data = new OPimTodoData; 141 data = new OPimTodoData;
140 142
141 data->date = date; 143 data->date = date;
142 data->isCompleted = completed; 144 data->isCompleted = completed;
143 data->hasDate = hasDate; 145 data->hasDate = hasDate;
144 data->priority = priority; 146 data->priority = priority;
145 data->sum = summary; 147 data->sum = summary;
146 data->prog = progress; 148 data->prog = progress;
147 data->desc = Qtopia::simplifyMultiLineSpace( description ); 149 data->desc = Qtopia::simplifyMultiLineSpace( description );
148} 150}
@@ -297,25 +299,25 @@ void OPimTodo::setCompleted( bool completed )
297} 299}
298 300
299 301
300void OPimTodo::setHasDueDate( bool hasDate ) 302void OPimTodo::setHasDueDate( bool hasDate )
301{ 303{
302 changeOrModify(); 304 changeOrModify();
303 data->hasDate = hasDate; 305 data->hasDate = hasDate;
304} 306}
305 307
306 308
307void OPimTodo::setDescription( const QString &desc ) 309void OPimTodo::setDescription( const QString &desc )
308{ 310{
309 // qWarning( "desc " + desc ); 311 // owarn << "desc " + desc << oendl;
310 changeOrModify(); 312 changeOrModify();
311 data->desc = Qtopia::simplifyMultiLineSpace( desc ); 313 data->desc = Qtopia::simplifyMultiLineSpace( desc );
312} 314}
313 315
314 316
315void OPimTodo::setSummary( const QString& sum ) 317void OPimTodo::setSummary( const QString& sum )
316{ 318{
317 changeOrModify(); 319 changeOrModify();
318 data->sum = sum; 320 data->sum = sum;
319} 321}
320 322
321 323
@@ -582,40 +584,40 @@ bool OPimTodo::operator==( const OPimTodo &toDoEvent ) const
582 if ( data->sum != toDoEvent.data->sum ) return false; 584 if ( data->sum != toDoEvent.data->sum ) return false;
583 if ( data->desc != toDoEvent.data->desc ) return false; 585 if ( data->desc != toDoEvent.data->desc ) return false;
584 if ( data->maintainer != toDoEvent.data->maintainer ) 586 if ( data->maintainer != toDoEvent.data->maintainer )
585 return false; 587 return false;
586 588
587 return OPimRecord::operator==( toDoEvent ); 589 return OPimRecord::operator==( toDoEvent );
588} 590}
589 591
590 592
591void OPimTodo::deref() 593void OPimTodo::deref()
592{ 594{
593 595
594 // qWarning("deref in ToDoEvent"); 596 // owarn << "deref in ToDoEvent" << oendl;
595 if ( data->deref() ) 597 if ( data->deref() )
596 { 598 {
597 // qWarning("deleting"); 599 // owarn << "deleting" << oendl;
598 delete data; 600 delete data;
599 data = 0; 601 data = 0;
600 } 602 }
601} 603}
602 604
603 605
604OPimTodo &OPimTodo::operator=( const OPimTodo &item ) 606OPimTodo &OPimTodo::operator=( const OPimTodo &item )
605{ 607{
606 if ( this == &item ) return * this; 608 if ( this == &item ) return * this;
607 609
608 OPimRecord::operator=( item ); 610 OPimRecord::operator=( item );
609 //qWarning("operator= ref "); 611 //owarn << "operator= ref " << oendl;
610 item.data->ref(); 612 item.data->ref();
611 deref(); 613 deref();
612 data = item.data; 614 data = item.data;
613 615
614 return *this; 616 return *this;
615} 617}
616 618
617 619
618QMap<int, QString> OPimTodo::toMap() const 620QMap<int, QString> OPimTodo::toMap() const
619{ 621{
620 QMap<int, QString> map; 622 QMap<int, QString> map;
621 623
@@ -640,25 +642,25 @@ QMap<int, QString> OPimTodo::toMap() const
640} 642}
641 643
642 644
643/** 645/**
644 * change or modify looks at the ref count and either 646 * change or modify looks at the ref count and either
645 * creates a new QShared Object or it can modify it 647 * creates a new QShared Object or it can modify it
646 * right in place 648 * right in place
647 */ 649 */
648void OPimTodo::changeOrModify() 650void OPimTodo::changeOrModify()
649{ 651{
650 if ( data->count != 1 ) 652 if ( data->count != 1 )
651 { 653 {
652 qWarning( "changeOrModify" ); 654 owarn << "changeOrModify" << oendl;
653 data->deref(); 655 data->deref();
654 OPimTodoData* d2 = new OPimTodoData(); 656 OPimTodoData* d2 = new OPimTodoData();
655 copy( data, d2 ); 657 copy( data, d2 );
656 data = d2; 658 data = d2;
657 } 659 }
658} 660}
659 661
660 662
661// WATCHOUT 663// WATCHOUT
662/* 664/*
663 * if you add something to the Data struct 665 * if you add something to the Data struct
664 * be sure to copy it here 666 * be sure to copy it here
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
@@ -41,25 +41,25 @@ OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access )
41 : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) 41 : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end )
42{ 42{
43// if (end == 0l ) 43// if (end == 0l )
44// m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); 44// m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null);
45 45
46 // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! 46 // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben !
47 if (end == 0l ) 47 if (end == 0l )
48 m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::defaultBackend (OPimGlobal::TODOLIST, QString::null); 48 m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::defaultBackend (OPimGlobal::TODOLIST, QString::null);
49 49
50 setBackEnd( m_todoBackEnd ); 50 setBackEnd( m_todoBackEnd );
51} 51}
52OPimTodoAccess::~OPimTodoAccess() { 52OPimTodoAccess::~OPimTodoAccess() {
53// qWarning("~OPimTodoAccess"); 53// owarn << "~OPimTodoAccess" << oendl;
54} 54}
55void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) { 55void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) {
56 QValueList<OPimTodo>::ConstIterator it; 56 QValueList<OPimTodo>::ConstIterator it;
57 for ( it = list.begin(); it != list.end(); ++it ) { 57 for ( it = list.begin(); it != list.end(); ++it ) {
58 replace( (*it) ); 58 replace( (*it) );
59 } 59 }
60} 60}
61OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, 61OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
62 const QDate& end, 62 const QDate& end,
63 bool includeNoDates ) { 63 bool includeNoDates ) {
64 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); 64 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
65 65
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
@@ -17,34 +17,41 @@
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qapplication.h> 29
30#include <qdatetime.h> 30#include "opimmainwindow.h"
31#include <qcopchannel_qws.h> 31
32/* OPIE */
33#include <opie2/opimresolver.h>
34#include <opie2/odebug.h>
32 35
33#include <qpe/sound.h> 36#include <qpe/sound.h>
34#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
35#include <qpe/qpeapplication.h> 38#include <qpe/qpeapplication.h>
36 39
37#include <opie2/opimresolver.h> 40/* QT */
38#include "opimmainwindow.h" 41#include <qapplication.h>
42#include <qdatetime.h>
43#include <qcopchannel_qws.h>
44
45
39 46
40namespace Opie { 47namespace Opie {
41OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent, 48OPimMainWindow::OPimMainWindow( const QString& service, QWidget* parent,
42 const char* name, WFlags flag ) 49 const char* name, WFlags flag )
43 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) { 50 : QMainWindow( parent, name, flag ), m_rtti(-1), m_service( service ), m_fallBack(0l) {
44 51
45 /* 52 /*
46 * let's generate our QCopChannel 53 * let's generate our QCopChannel
47 */ 54 */
48 m_str = QString("QPE/"+m_service).local8Bit(); 55 m_str = QString("QPE/"+m_service).local8Bit();
49 m_channel= new QCopChannel(m_str, this ); 56 m_channel= new QCopChannel(m_str, this );
50 connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&) ), 57 connect(m_channel, SIGNAL(received(const QCString&,const QByteArray&) ),
@@ -107,25 +114,25 @@ void OPimMainWindow::appMessage( const QCString& cmd, const QByteArray& array )
107 QByteArray array; 114 QByteArray array;
108 stream >> rtti; 115 stream >> rtti;
109 stream >> array; 116 stream >> array;
110 m_fallBack = record(rtti, array ); 117 m_fallBack = record(rtti, array );
111 if (!m_fallBack) return; 118 if (!m_fallBack) return;
112 add( *m_fallBack ); 119 add( *m_fallBack );
113 delete m_fallBack; 120 delete m_fallBack;
114 }else if ( cmd == "alarm(QDateTime,int)" ) { 121 }else if ( cmd == "alarm(QDateTime,int)" ) {
115 raise(); 122 raise();
116 QDateTime dt; int uid; 123 QDateTime dt; int uid;
117 stream >> dt; 124 stream >> dt;
118 stream >> uid; 125 stream >> uid;
119 qWarning(" Date: %s Uid: %d", dt.toString().latin1(), uid ); 126 owarn << " Date: " << dt.toString() << " Uid: " << uid << "" << oendl;
120 QDateTime current = QDateTime::currentDateTime(); 127 QDateTime current = QDateTime::currentDateTime();
121 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() ) 128 if ( current.time().hour() != dt.time().hour() && current.time().minute() != dt.time().minute() )
122 return; 129 return;
123 doAlarm( dt, uid ); 130 doAlarm( dt, uid );
124 needShow = true; 131 needShow = true;
125 } 132 }
126 133
127 if (needShow ) 134 if (needShow )
128 QPEApplication::setKeepRunning(); 135 QPEApplication::setKeepRunning();
129} 136}
130/* implement the url scripting here */ 137/* implement the url scripting here */
131void OPimMainWindow::setDocument( const QString& str) { 138void OPimMainWindow::setDocument( const QString& str) {