Diffstat (limited to 'libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp | 64 |
1 files changed, 34 insertions, 30 deletions
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 | |||
@@ -32,13 +32,7 @@ | |||
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> |
@@ -46,6 +40,16 @@ | |||
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 | ||
50 | using namespace Opie; | 54 | using namespace Opie; |
51 | using namespace Opie::DB; | 55 | using namespace Opie::DB; |
@@ -268,7 +272,7 @@ namespace { | |||
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 | ||
@@ -316,7 +320,7 @@ namespace { | |||
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 | ||
@@ -350,7 +354,7 @@ OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* a | |||
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 | ||
@@ -367,7 +371,7 @@ OPimContactAccessBackend_SQL::OPimContactAccessBackend_SQL ( const QString& /* a | |||
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 | ||
373 | OPimContactAccessBackend_SQL::~OPimContactAccessBackend_SQL () | 377 | OPimContactAccessBackend_SQL::~OPimContactAccessBackend_SQL () |
@@ -430,7 +434,7 @@ QArray<int> OPimContactAccessBackend_SQL::allRecords() const | |||
430 | 434 | ||
431 | bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact ) | 435 | bool 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 | ||
@@ -469,14 +473,14 @@ bool OPimContactAccessBackend_SQL::replace ( const OPimContact &contact ) | |||
469 | 473 | ||
470 | OPimContact OPimContactAccessBackend_SQL::find ( int uid ) const | 474 | OPimContact 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 | ||
@@ -585,7 +589,7 @@ QArray<int> OPimContactAccessBackend_SQL::queryByExample ( const OPimContact &qu | |||
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 ); |
@@ -620,7 +624,7 @@ QArray<int> OPimContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const | |||
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 ); |
@@ -701,7 +705,7 @@ QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | |||
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 ); |
@@ -712,14 +716,14 @@ QArray<int> OPimContactAccessBackend_SQL::sorted( bool asc, int , int , int ) | |||
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 | ||
720 | void OPimContactAccessBackend_SQL::update() | 724 | void 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 | ||
@@ -735,25 +739,25 @@ void OPimContactAccessBackend_SQL::update() | |||
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 | ||
741 | QArray<int> OPimContactAccessBackend_SQL::extractUids( OSQLResult& res ) const | 745 | QArray<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 | ||
@@ -788,7 +792,7 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co | |||
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: |
@@ -806,7 +810,7 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co | |||
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 | } |
@@ -816,9 +820,9 @@ QMap<int, QString> OPimContactAccessBackend_SQL::requestNonCustom( int uid ) co | |||
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 | } |
@@ -834,7 +838,7 @@ QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) c | |||
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 | } |
@@ -845,7 +849,7 @@ QMap<QString, QString> OPimContactAccessBackend_SQL::requestCustom( int uid ) c | |||
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 | ||