author | ar <ar> | 2004-06-01 22:21:23 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-01 22:21:23 (UTC) |
commit | d4fe7d53ddf8f3e7ae046a511f0dc061f30d45ce (patch) (unidiff) | |
tree | 4bab082304716df1ec924ef040161e3cf9c10366 /libopie2/opiepim/core/ocontactaccess.cpp | |
parent | baed1d5ab8589aef14440009bc4e7380bcc5a741 (diff) | |
download | opie-d4fe7d53ddf8f3e7ae046a511f0dc061f30d45ce.zip opie-d4fe7d53ddf8f3e7ae046a511f0dc061f30d45ce.tar.gz opie-d4fe7d53ddf8f3e7ae046a511f0dc061f30d45ce.tar.bz2 |
- convert to odebug framework
Diffstat (limited to 'libopie2/opiepim/core/ocontactaccess.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 117 |
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 | |||
@@ -37,4 +37,14 @@ | |||
37 | #include "obackendfactory.h" | 37 | #include "obackendfactory.h" |
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> |
40 | #include <qdatetime.h> | 50 | #include <qdatetime.h> |
@@ -44,7 +54,5 @@ | |||
44 | #include <qcopchannel_qws.h> | 54 | #include <qcopchannel_qws.h> |
45 | 55 | ||
46 | //#include <qpe/qcopenvelope_qws.h> | 56 | /* STD */ |
47 | #include <qpe/global.h> | ||
48 | |||
49 | #include <errno.h> | 57 | #include <errno.h> |
50 | #include <fcntl.h> | 58 | #include <fcntl.h> |
@@ -52,35 +60,32 @@ | |||
52 | #include <stdlib.h> | 60 | #include <stdlib.h> |
53 | 61 | ||
54 | #include <opie2/ocontactaccessbackend_xml.h> | ||
55 | #include <opie2/opimresolver.h> | ||
56 | #include <opie2/opimglobal.h> | ||
57 | 62 | ||
58 | namespace Opie { | 63 | namespace Opie { |
59 | 64 | ||
60 | OPimContactAccess::OPimContactAccess ( const QString appname, const QString , | 65 | OPimContactAccess::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 | ||
86 | 91 | ||
@@ -88,9 +93,9 @@ OPimContactAccess::OPimContactAccess ( const QString appname, const QString , | |||
88 | OPimContactAccess::~OPimContactAccess () | 93 | 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 | } |
96 | 101 | ||
@@ -98,34 +103,34 @@ OPimContactAccess::~OPimContactAccess () | |||
98 | bool OPimContactAccess::save () | 103 | 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 | } |
116 | 121 | ||
117 | const uint OPimContactAccess::querySettings() | 122 | const uint OPimContactAccess::querySettings() |
118 | { | 123 | { |
119 | return ( m_backEnd->querySettings() ); | 124 | return ( m_backEnd->querySettings() ); |
120 | } | 125 | } |
121 | 126 | ||
122 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const | 127 | bool OPimContactAccess::hasQuerySettings ( int querySettings ) const |
123 | { | 128 | { |
124 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 129 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
125 | } | 130 | } |
126 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const | 131 | OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const |
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 | } |
131 | 136 | ||
@@ -133,5 +138,5 @@ OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortO | |||
133 | bool OPimContactAccess::wasChangedExternally()const | 138 | bool OPimContactAccess::wasChangedExternally()const |
134 | { | 139 | { |
135 | return ( m_backEnd->wasChangedExternally() ); | 140 | return ( m_backEnd->wasChangedExternally() ); |
136 | } | 141 | } |
137 | 142 | ||
@@ -139,20 +144,20 @@ bool OPimContactAccess::wasChangedExternally()const | |||
139 | void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 144 | 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 | } |
153 | 158 | ||
154 | int OPimContactAccess::rtti() const | 159 | int OPimContactAccess::rtti() const |
155 | { | 160 | { |
156 | return OPimResolver::AddressBook; | 161 | return OPimResolver::AddressBook; |
157 | } | 162 | } |
158 | 163 | ||