Diffstat (limited to 'libopie2/opiepim/core/ocontactaccess.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 57 |
1 files changed, 11 insertions, 46 deletions
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp index e8c0a45..2ca0283 100644 --- a/libopie2/opiepim/core/ocontactaccess.cpp +++ b/libopie2/opiepim/core/ocontactaccess.cpp | |||
@@ -18,12 +18,15 @@ | |||
18 | * | 18 | * |
19 | * ===================================================================== | 19 | * ===================================================================== |
20 | * Version: $Id$ | 20 | * Version: $Id$ |
21 | * ===================================================================== | 21 | * ===================================================================== |
22 | * History: | 22 | * History: |
23 | * $Log$ | 23 | * $Log$ |
24 | * Revision 1.5 2002/10/16 10:52:40 eilers | ||
25 | * Added some docu to the interface and now using the cache infrastucture by zecke.. :) | ||
26 | * | ||
24 | * Revision 1.4 2002/10/14 16:21:54 eilers | 27 | * Revision 1.4 2002/10/14 16:21:54 eilers |
25 | * Some minor interface updates | 28 | * Some minor interface updates |
26 | * | 29 | * |
27 | * Revision 1.3 2002/10/07 17:34:24 eilers | 30 | * Revision 1.3 2002/10/07 17:34:24 eilers |
28 | * added OBackendFactory for advanced backend access | 31 | * added OBackendFactory for advanced backend access |
29 | * | 32 | * |
@@ -59,14 +62,13 @@ | |||
59 | 62 | ||
60 | #include "ocontactaccessbackend_xml.h" | 63 | #include "ocontactaccessbackend_xml.h" |
61 | 64 | ||
62 | 65 | ||
63 | OContactAccess::OContactAccess ( const QString appname, const QString , | 66 | OContactAccess::OContactAccess ( const QString appname, const QString , |
64 | OContactAccessBackend* end, bool autosync ): | 67 | OContactAccessBackend* end, bool autosync ): |
65 | OPimAccessTemplate<OContact>( end ), | 68 | OPimAccessTemplate<OContact>( end ) |
66 | m_changed ( false ) | ||
67 | { | 69 | { |
68 | /* take care of the backend. If there is no one defined, we | 70 | /* take care of the backend. If there is no one defined, we |
69 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). | 71 | * will use the XML-Backend as default (until we have a cute SQL-Backend..). |
70 | */ | 72 | */ |
71 | if( end == 0 ) { | 73 | if( end == 0 ) { |
72 | qWarning ("Using BackendFactory !"); | 74 | qWarning ("Using BackendFactory !"); |
@@ -91,41 +93,32 @@ OContactAccess::OContactAccess ( const QString appname, const QString , | |||
91 | } | 93 | } |
92 | OContactAccess::~OContactAccess () | 94 | OContactAccess::~OContactAccess () |
93 | { | 95 | { |
94 | /* The user may forget to save the changed database, therefore try to | 96 | /* The user may forget to save the changed database, therefore try to |
95 | * do it for him.. | 97 | * do it for him.. |
96 | */ | 98 | */ |
97 | if ( m_changed ) | 99 | save(); |
98 | save(); | ||
99 | // delete m_backEnd; is done by template.. | 100 | // delete m_backEnd; is done by template.. |
100 | } | 101 | } |
101 | 102 | ||
102 | bool OContactAccess::load() | ||
103 | { | ||
104 | return ( m_backEnd->load() ); | ||
105 | } | ||
106 | 103 | ||
107 | bool OContactAccess::save () | 104 | bool OContactAccess::save () |
108 | { | 105 | { |
109 | /* If the database was changed externally, we could not save the | 106 | /* If the database was changed externally, we could not save the |
110 | * Data. This will remove added items which is unacceptable ! | 107 | * Data. This will remove added items which is unacceptable ! |
111 | * Therefore: Reload database and merge the data... | 108 | * Therefore: Reload database and merge the data... |
112 | */ | 109 | */ |
113 | if ( m_backEnd->wasChangedExternally() ) | 110 | if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) |
114 | reload(); | 111 | reload(); |
115 | 112 | ||
116 | if ( m_changed ){ | 113 | bool status = OPimAccessTemplate<OContact>::save(); |
117 | bool status = m_backEnd->save(); | 114 | if ( !status ) return false; |
118 | if ( !status ) return false; | ||
119 | 115 | ||
120 | m_changed = false; | 116 | /* Now tell everyone that new data is available. |
121 | /* Now tell everyone that new data is available. | 117 | */ |
122 | */ | 118 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); |
123 | QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); | ||
124 | |||
125 | } | ||
126 | 119 | ||
127 | return true; | 120 | return true; |
128 | } | 121 | } |
129 | 122 | ||
130 | const uint OContactAccess::querySettings() | 123 | const uint OContactAccess::querySettings() |
131 | { | 124 | { |
@@ -134,47 +127,19 @@ const uint OContactAccess::querySettings() | |||
134 | 127 | ||
135 | bool OContactAccess::hasQuerySettings ( int querySettings ) const | 128 | bool OContactAccess::hasQuerySettings ( int querySettings ) const |
136 | { | 129 | { |
137 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); | 130 | return ( m_backEnd->hasQuerySettings ( querySettings ) ); |
138 | } | 131 | } |
139 | 132 | ||
140 | bool OContactAccess::add ( const OContact& newcontact ) | ||
141 | { | ||
142 | m_changed = true; | ||
143 | return ( m_backEnd->add ( newcontact ) ); | ||
144 | } | ||
145 | |||
146 | bool OContactAccess::replace ( const OContact& contact ) | ||
147 | { | ||
148 | m_changed = true; | ||
149 | return ( m_backEnd->replace ( contact ) ); | ||
150 | } | ||
151 | |||
152 | bool OContactAccess::remove ( const OContact& t ) | ||
153 | { | ||
154 | m_changed = true; | ||
155 | return ( m_backEnd->remove ( t.uid() ) ); | ||
156 | } | ||
157 | |||
158 | bool OContactAccess::remove ( int uid ) | ||
159 | { | ||
160 | m_changed = true; | ||
161 | return ( m_backEnd->remove ( uid ) ); | ||
162 | } | ||
163 | 133 | ||
164 | bool OContactAccess::wasChangedExternally()const | 134 | bool OContactAccess::wasChangedExternally()const |
165 | { | 135 | { |
166 | return ( m_backEnd->wasChangedExternally() ); | 136 | return ( m_backEnd->wasChangedExternally() ); |
167 | } | 137 | } |
168 | 138 | ||
169 | 139 | ||
170 | bool OContactAccess::reload() | ||
171 | { | ||
172 | return ( m_backEnd->reload() ); | ||
173 | } | ||
174 | |||
175 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) | 140 | void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) |
176 | { | 141 | { |
177 | if ( msg == "addressbookUpdated()" ){ | 142 | if ( msg == "addressbookUpdated()" ){ |
178 | qWarning ("OContactAccess: Received addressbokUpdated()"); | 143 | qWarning ("OContactAccess: Received addressbokUpdated()"); |
179 | emit signalChanged ( this ); | 144 | emit signalChanged ( this ); |
180 | } else if ( msg == "flush()" ) { | 145 | } else if ( msg == "flush()" ) { |