summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/ocontactaccess.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/ocontactaccess.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp117
1 files changed, 61 insertions, 56 deletions
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index a372267..7a3d7cb 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -38,2 +38,12 @@
38 38
39/* OPIE */
40#include <opie2/ocontactaccessbackend_xml.h>
41#include <opie2/opimresolver.h>
42#include <opie2/opimglobal.h>
43#include <opie2/odebug.h>
44
45//#include <qpe/qcopenvelope_qws.h>
46#include <qpe/global.h>
47
48/* QT */
39#include <qasciidict.h> 49#include <qasciidict.h>
@@ -45,5 +55,3 @@
45 55
46//#include <qpe/qcopenvelope_qws.h> 56/* STD */
47#include <qpe/global.h>
48
49#include <errno.h> 57#include <errno.h>
@@ -53,5 +61,2 @@
53 61
54#include <opie2/ocontactaccessbackend_xml.h>
55#include <opie2/opimresolver.h>
56#include <opie2/opimglobal.h>
57 62
@@ -60,26 +65,26 @@ namespace Opie {
60OPimContactAccess::OPimContactAccess ( const QString appname, const QString , 65OPimContactAccess::OPimContactAccess ( const QString appname, const QString ,
61 OPimContactAccessBackend* end, bool autosync ): 66 OPimContactAccessBackend* end, bool autosync ):
62 OPimAccessTemplate<OPimContact>( end ) 67 OPimAccessTemplate<OPimContact>( end )
63{ 68{
64 /* take care of the backend. If there is no one defined, we 69 /* take care of the backend. If there is no one defined, we
65 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 70 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
66 */ 71 */
67 if( end == 0 ) { 72 if( end == 0 ) {
68 qWarning ("Using BackendFactory !"); 73 owarn << "Using BackendFactory !" << oendl;
69 end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname ); 74 end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( OPimGlobal::CONTACTLIST, appname );
70 } 75 }
71 // Set backend locally and in template 76 // Set backend locally and in template
72 m_backEnd = end; 77 m_backEnd = end;
73 OPimAccessTemplate<OPimContact>::setBackEnd (end); 78 OPimAccessTemplate<OPimContact>::setBackEnd (end);
74 79
75 80
76 /* Connect signal of external db change to function */ 81 /* Connect signal of external db change to function */
77 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 82 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
78 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), 83 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)),
79 this, SLOT(copMessage(const QCString&,const QByteArray&)) ); 84 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
80 if ( autosync ){ 85 if ( autosync ){
81 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 86 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
82 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), 87 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)),
83 this, SLOT(copMessage(const QCString&,const QByteArray&)) ); 88 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
84 } 89 }
85 90
@@ -89,7 +94,7 @@ OPimContactAccess::~OPimContactAccess ()
89{ 94{
90 /* The user may forget to save the changed database, therefore try to 95 /* The user may forget to save the changed database, therefore try to
91 * do it for him.. 96 * do it for him..
92 */ 97 */
93 save(); 98 save();
94 // delete m_backEnd; is done by template.. 99 // delete m_backEnd; is done by template..
95} 100}
@@ -99,17 +104,17 @@ bool OPimContactAccess::save ()
99{ 104{
100 /* If the database was changed externally, we could not save the 105 /* If the database was changed externally, we could not save the
101 * Data. This will remove added items which is unacceptable ! 106 * Data. This will remove added items which is unacceptable !
102 * Therefore: Reload database and merge the data... 107 * Therefore: Reload database and merge the data...
103 */ 108 */
104 if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) 109 if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() )
105 reload(); 110 reload();
106 111
107 bool status = OPimAccessTemplate<OPimContact>::save(); 112 bool status = OPimAccessTemplate<OPimContact>::save();
108 if ( !status ) return false; 113 if ( !status ) return false;
109 114
110 /* Now tell everyone that new data is available. 115 /* Now tell everyone that new data is available.
111 */ 116 */
112 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 117 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
113 118
114 return true; 119 return true;
115} 120}
@@ -118,3 +123,3 @@ const uint OPimContactAccess::querySettings()
118{ 123{
119 return ( m_backEnd->querySettings() ); 124 return ( m_backEnd->querySettings() );
120} 125}
@@ -123,3 +128,3 @@ bool OPimContactAccess::hasQuerySettings ( int querySettings ) const
123{ 128{
124 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 129 return ( m_backEnd->hasQuerySettings ( querySettings ) );
125} 130}
@@ -127,4 +132,4 @@ OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortO
127{ 132{
128 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 133 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
129 return ( OPimRecordList<OPimContact>(matchingContacts, this) ); 134 return ( OPimRecordList<OPimContact>(matchingContacts, this) );
130} 135}
@@ -134,3 +139,3 @@ bool OPimContactAccess::wasChangedExternally()const
134{ 139{
135 return ( m_backEnd->wasChangedExternally() ); 140 return ( m_backEnd->wasChangedExternally() );
136} 141}
@@ -140,13 +145,13 @@ void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & )
140{ 145{
141 if ( msg == "addressbookUpdated()" ){ 146 if ( msg == "addressbookUpdated()" ){
142 qWarning ("OPimContactAccess: Received addressbokUpdated()"); 147 owarn << "OPimContactAccess: Received addressbokUpdated()" << oendl;
143 emit signalChanged ( this ); 148 emit signalChanged ( this );
144 } else if ( msg == "flush()" ) { 149 } else if ( msg == "flush()" ) {
145 qWarning ("OPimContactAccess: Received flush()"); 150 owarn << "OPimContactAccess: Received flush()" << oendl;
146 save (); 151 save ();
147 } else if ( msg == "reload()" ) { 152 } else if ( msg == "reload()" ) {
148 qWarning ("OPimContactAccess: Received reload()"); 153 owarn << "OPimContactAccess: Received reload()" << oendl;
149 reload (); 154 reload ();
150 emit signalChanged ( this ); 155 emit signalChanged ( this );
151 } 156 }
152} 157}
@@ -155,3 +160,3 @@ int OPimContactAccess::rtti() const
155{ 160{
156 return OPimResolver::AddressBook; 161 return OPimResolver::AddressBook;
157} 162}