-rw-r--r-- | libopie2/opiepim/backend/obackendfactory.h | 242 | ||||
-rw-r--r-- | libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | 36 | ||||
-rw-r--r-- | libopie2/opiepim/core/ocontactaccess.cpp | 117 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimaccesstemplate.h | 17 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimcontact.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimnotifymanager.cpp | 4 | ||||
-rw-r--r-- | libopie2/opiepim/core/opimrecordlist.h | 5 |
7 files changed, 218 insertions, 207 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index 6f46652..3680ded 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h | |||
@@ -34,10 +34,7 @@ | |||
34 | #ifndef OPIE_BACKENDFACTORY_H_ | 34 | #ifndef OPIE_BACKENDFACTORY_H_ |
35 | #define OPIE_BACKENDFACTORY_H_ | 35 | #define OPIE_BACKENDFACTORY_H_ |
36 | 36 | ||
37 | #include <qstring.h> | 37 | /* OPIE */ |
38 | #include <qasciidict.h> | ||
39 | #include <qpe/config.h> | ||
40 | |||
41 | #include <opie2/opimaccessbackend.h> | 38 | #include <opie2/opimaccessbackend.h> |
42 | #include <opie2/opimglobal.h> | 39 | #include <opie2/opimglobal.h> |
43 | #include <opie2/otodoaccessxml.h> | 40 | #include <opie2/otodoaccessxml.h> |
@@ -45,6 +42,7 @@ | |||
45 | #include <opie2/ocontactaccessbackend_xml.h> | 42 | #include <opie2/ocontactaccessbackend_xml.h> |
46 | #include <opie2/ocontactaccessbackend_vcard.h> | 43 | #include <opie2/ocontactaccessbackend_vcard.h> |
47 | #include <opie2/odatebookaccessbackend_xml.h> | 44 | #include <opie2/odatebookaccessbackend_xml.h> |
45 | #include <opie2/odebug.h> | ||
48 | 46 | ||
49 | #ifdef __USE_SQL | 47 | #ifdef __USE_SQL |
50 | #include <opie2/otodoaccesssql.h> | 48 | #include <opie2/otodoaccesssql.h> |
@@ -52,6 +50,14 @@ | |||
52 | #include <opie2/odatebookaccessbackend_sql.h> | 50 | #include <opie2/odatebookaccessbackend_sql.h> |
53 | #endif | 51 | #endif |
54 | 52 | ||
53 | #include <qpe/config.h> | ||
54 | |||
55 | /* QT */ | ||
56 | #include <qstring.h> | ||
57 | #include <qasciidict.h> | ||
58 | |||
59 | |||
60 | |||
55 | using namespace Opie; | 61 | using namespace Opie; |
56 | using namespace Opie::Pim; | 62 | using namespace Opie::Pim; |
57 | 63 | ||
@@ -78,144 +84,144 @@ template<class T> | |||
78 | class OBackendFactory | 84 | class OBackendFactory |
79 | { | 85 | { |
80 | public: | 86 | public: |
81 | OBackendFactory() {}; | 87 | OBackendFactory() {}; |
82 | 88 | ||
83 | /** | 89 | /** |
84 | * Returns a selected backend implementation | 90 | * Returns a selected backend implementation |
85 | * @param type the type of the backend | 91 | * @param type the type of the backend |
86 | * @param database the type of the used database | 92 | * @param database the type of the used database |
87 | * @param appName The name of your application. It will be passed on to the backend. | 93 | * @param appName The name of your application. It will be passed on to the backend. |
88 | * @param filename Filename of the database file if you don't want to access the default | 94 | * @param filename Filename of the database file if you don't want to access the default |
89 | * @see OPimGlobal() | 95 | * @see OPimGlobal() |
90 | */ | 96 | */ |
91 | static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, | 97 | static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, |
92 | const QString& appName, const QString& filename = QString::null ){ | 98 | const QString& appName, const QString& filename = QString::null ){ |
93 | qWarning("Selected backend for %d is: %d", type, database ); | 99 | owarn << "Selected backend for " << type << " is: " << database << oendl; |
94 | // If we should use the dafult database style, we have to request it | 100 | // If we should use the dafult database style, we have to request it |
95 | OPimGlobal::DatabaseStyle use_database = database; | 101 | OPimGlobal::DatabaseStyle use_database = database; |
96 | if ( use_database == OPimGlobal::DEFAULT ){ | 102 | if ( use_database == OPimGlobal::DEFAULT ){ |
97 | use_database = defaultDB( type ); | 103 | use_database = defaultDB( type ); |
98 | } | 104 | } |
99 | 105 | ||
100 | switch ( type ){ | 106 | switch ( type ){ |
101 | case OPimGlobal::TODOLIST: | 107 | case OPimGlobal::TODOLIST: |
102 | 108 | ||
103 | switch ( use_database ){ | 109 | switch ( use_database ){ |
104 | default: // Use SQL if something weird is given. | 110 | default: // Use SQL if something weird is given. |
105 | // Fall through !! | 111 | // Fall through !! |
106 | case OPimGlobal::SQL: | 112 | case OPimGlobal::SQL: |
107 | #ifdef __USE_SQL | 113 | #ifdef __USE_SQL |
108 | return (T*) new OPimTodoAccessBackendSQL( filename ); | 114 | return (T*) new OPimTodoAccessBackendSQL( filename ); |
109 | break; | 115 | break; |
110 | #else | 116 | #else |
111 | qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); | 117 | owarn << "OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!" << oendl; |
112 | // Fall through !! | 118 | // Fall through !! |
113 | #endif | 119 | #endif |
114 | case OPimGlobal::XML: | 120 | case OPimGlobal::XML: |
115 | return (T*) new OPimTodoAccessXML( appName, filename ); | 121 | return (T*) new OPimTodoAccessXML( appName, filename ); |
116 | break; | 122 | break; |
117 | case OPimGlobal::VCARD: | 123 | case OPimGlobal::VCARD: |
118 | return (T*) new OPimTodoAccessVCal( filename ); | 124 | return (T*) new OPimTodoAccessVCal( filename ); |
119 | break; | 125 | break; |
120 | } | 126 | } |
121 | case OPimGlobal::CONTACTLIST: | 127 | case OPimGlobal::CONTACTLIST: |
122 | switch ( use_database ){ | 128 | switch ( use_database ){ |
123 | default: // Use SQL if something weird is given. | 129 | default: // Use SQL if something weird is given. |
124 | // Fall through !! | 130 | // Fall through !! |
125 | case OPimGlobal::SQL: | 131 | case OPimGlobal::SQL: |
126 | #ifdef __USE_SQL | 132 | #ifdef __USE_SQL |
127 | return (T*) new OPimContactAccessBackend_SQL( appName, filename ); | 133 | return (T*) new OPimContactAccessBackend_SQL( appName, filename ); |
128 | break; | 134 | break; |
129 | #else | 135 | #else |
130 | qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); | 136 | owarn << "OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!" << oendl; |
131 | // Fall through !! | 137 | // Fall through !! |
132 | #endif | 138 | #endif |
133 | case OPimGlobal::XML: | 139 | case OPimGlobal::XML: |
134 | return (T*) new OPimContactAccessBackend_XML( appName, filename ); | 140 | return (T*) new OPimContactAccessBackend_XML( appName, filename ); |
135 | break; | 141 | break; |
136 | case OPimGlobal::VCARD: | 142 | case OPimGlobal::VCARD: |
137 | return (T*) new OPimContactAccessBackend_VCard( appName, filename ); | 143 | return (T*) new OPimContactAccessBackend_VCard( appName, filename ); |
138 | break; | 144 | break; |
139 | } | 145 | } |
140 | case OPimGlobal::DATEBOOK: | 146 | case OPimGlobal::DATEBOOK: |
141 | switch ( use_database ){ | 147 | switch ( use_database ){ |
142 | default: // Use SQL if something weird is given. | 148 | default: // Use SQL if something weird is given. |
143 | // Fall through !! | 149 | // Fall through !! |
144 | case OPimGlobal::SQL: | 150 | case OPimGlobal::SQL: |
145 | #ifdef __USE_SQL | 151 | #ifdef __USE_SQL |
146 | return (T*) new ODateBookAccessBackend_SQL( appName, filename ); | 152 | return (T*) new ODateBookAccessBackend_SQL( appName, filename ); |
147 | break; | 153 | break; |
148 | #else | 154 | #else |
149 | qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); | 155 | owarn << "OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!" << oendl; |
150 | // Fall through !! | 156 | // Fall through !! |
151 | #endif | 157 | #endif |
152 | case OPimGlobal::XML: | 158 | case OPimGlobal::XML: |
153 | return (T*) new ODateBookAccessBackend_XML( appName, filename ); | 159 | return (T*) new ODateBookAccessBackend_XML( appName, filename ); |
154 | break; | 160 | break; |
155 | case OPimGlobal::VCARD: | 161 | case OPimGlobal::VCARD: |
156 | qWarning("OBackendFactory:: VCal Backend for DATEBOOK not implemented!"); | 162 | owarn << "OBackendFactory:: VCal Backend for DATEBOOK not implemented!" << oendl; |
157 | return (T*) NULL; | 163 | return (T*) NULL; |
158 | break; | 164 | break; |
159 | } | 165 | } |
160 | default: | 166 | default: |
161 | return (T*) NULL; | 167 | return (T*) NULL; |
162 | } | 168 | } |
163 | 169 | ||
164 | } | 170 | } |
165 | 171 | ||
166 | /** | 172 | /** |
167 | * Returns the style of the default database which is used to contact PIM data. | 173 | * Returns the style of the default database which is used to contact PIM data. |
168 | * @param type the type of the backend | 174 | * @param type the type of the backend |
169 | * @see OPimGlobal() | 175 | * @see OPimGlobal() |
170 | */ | 176 | */ |
171 | static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ | 177 | static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ |
172 | QString group_name; | 178 | QString group_name; |
173 | switch ( type ){ | 179 | switch ( type ){ |
174 | case OPimGlobal::TODOLIST: | 180 | case OPimGlobal::TODOLIST: |
175 | group_name = "todo"; | 181 | group_name = "todo"; |
176 | break; | 182 | break; |
177 | case OPimGlobal::CONTACTLIST: | 183 | case OPimGlobal::CONTACTLIST: |
178 | group_name = "contact"; | 184 | group_name = "contact"; |
179 | break; | 185 | break; |
180 | case OPimGlobal::DATEBOOK: | 186 | case OPimGlobal::DATEBOOK: |
181 | group_name = "datebook"; | 187 | group_name = "datebook"; |
182 | break; | 188 | break; |
183 | default: | 189 | default: |
184 | group_name = "unknown"; | 190 | group_name = "unknown"; |
185 | } | 191 | } |
186 | 192 | ||
187 | Config config( "pimaccess" ); | 193 | Config config( "pimaccess" ); |
188 | config.setGroup ( group_name ); | 194 | config.setGroup ( group_name ); |
189 | QString db_String = config.readEntry( "usebackend", "xml" ); | 195 | QString db_String = config.readEntry( "usebackend", "xml" ); |
190 | 196 | ||
191 | QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle ); | 197 | QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle ); |
192 | dictDbTypes.setAutoDelete( TRUE ); | 198 | dictDbTypes.setAutoDelete( TRUE ); |
193 | 199 | ||
194 | dictDbTypes.insert( "xml", new int (OPimGlobal::XML) ); | 200 | dictDbTypes.insert( "xml", new int (OPimGlobal::XML) ); |
195 | dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) ); | 201 | dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) ); |
196 | dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) ); | 202 | dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) ); |
197 | 203 | ||
198 | int* db_find = dictDbTypes[ db_String ]; | 204 | int* db_find = dictDbTypes[ db_String ]; |
199 | 205 | ||
200 | if ( !db_find ) | 206 | if ( !db_find ) |
201 | return OPimGlobal::UNKNOWN; | 207 | return OPimGlobal::UNKNOWN; |
202 | 208 | ||
203 | return (OPimGlobal::DatabaseStyle) *db_find; | 209 | return (OPimGlobal::DatabaseStyle) *db_find; |
204 | } | 210 | } |
205 | 211 | ||
206 | 212 | ||
207 | /** | 213 | /** |
208 | * Returns the default backend implementation for backendName. Which one is used, is defined | 214 | * Returns the default backend implementation for backendName. Which one is used, is defined |
209 | * by the configfile "pimaccess.conf". | 215 | * by the configfile "pimaccess.conf". |
210 | * @param type The type of the backend (@see OPimGlobal()) | 216 | * @param type The type of the backend (@see OPimGlobal()) |
211 | * @param appName The name of your application. It will be passed on to the backend | 217 | * @param appName The name of your application. It will be passed on to the backend |
212 | * @see OPimGlobal() | 218 | * @see OPimGlobal() |
213 | */ | 219 | */ |
214 | static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){ | 220 | static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){ |
215 | return create( type, OPimGlobal::DEFAULT, appName ); | 221 | return create( type, OPimGlobal::DEFAULT, appName ); |
216 | } | 222 | } |
217 | private: | 223 | private: |
218 | OBackendPrivate* d; | 224 | OBackendPrivate* d; |
219 | 225 | ||
220 | }; | 226 | }; |
221 | 227 | ||
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp index 5ffcb11..00d62ee 100644 --- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp +++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp | |||
@@ -137,8 +137,8 @@ bool OPimContactAccessBackend_XML::save() | |||
137 | // move the file over, I'm just going to use the system call | 137 | // move the file over, I'm just going to use the system call |
138 | // because, I don't feel like using QDir. | 138 | // because, I don't feel like using QDir. |
139 | if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { | 139 | if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { |
140 | qWarning( "problem renaming file %s to %s, errno: %d", | 140 | owarn << "problem renaming file " << strNewFile << " to " << m_journalName |
141 | strNewFile.latin1(), m_journalName.latin1(), errno ); | 141 | << ", errno: " << errno << oendl; |
142 | // remove the tmp file... | 142 | // remove the tmp file... |
143 | QFile::remove( strNewFile ); | 143 | QFile::remove( strNewFile ); |
144 | } | 144 | } |
@@ -278,15 +278,13 @@ QArray<int> OPimContactAccessBackend_XML::queryByExample ( const OPimContact &qu | |||
278 | // Check whether the birthday/anniversary date is between | 278 | // Check whether the birthday/anniversary date is between |
279 | // the current/given date and the maximum date | 279 | // the current/given date and the maximum date |
280 | // ( maximum time range ) ! | 280 | // ( maximum time range ) ! |
281 | qWarning("Checking if %s is between %s and %s ! ", | 281 | owarn << "Checking if " << checkDate->toString() << " is between " << current.toString() |
282 | checkDate->toString().latin1(), | 282 | << " and " << queryDate->toString() << " ! " << oendl; |
283 | current.toString().latin1(), | ||
284 | queryDate->toString().latin1() ); | ||
285 | if ( current.daysTo( *queryDate ) >= 0 ){ | 283 | if ( current.daysTo( *queryDate ) >= 0 ){ |
286 | if ( !( ( *checkDate >= current ) && | 284 | if ( !( ( *checkDate >= current ) && |
287 | ( *checkDate <= *queryDate ) ) ){ | 285 | ( *checkDate <= *queryDate ) ) ){ |
288 | allcorrect = false; | 286 | allcorrect = false; |
289 | qWarning (" Nope!.."); | 287 | owarn << " Nope!.." << oendl; |
290 | } | 288 | } |
291 | } | 289 | } |
292 | } | 290 | } |
@@ -607,8 +605,8 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal | |||
607 | /* Search Tag "Contacts" which is the parent of all Contacts */ | 605 | /* Search Tag "Contacts" which is the parent of all Contacts */ |
608 | while( element && !isJournal ){ | 606 | while( element && !isJournal ){ |
609 | if( element->tagName() != QString::fromLatin1("Contacts") ){ | 607 | if( element->tagName() != QString::fromLatin1("Contacts") ){ |
610 | //qWarning ("OPimContactDefBack::Searching for Tag \"Contacts\"! Found: %s", | 608 | //owarn << "OPimContactDefBack::Searching for Tag \"Contacts\"! Found: " |
611 | // element->tagName().latin1()); | 609 | // << element->tagName() << oendl; |
612 | element = element->nextChild(); | 610 | element = element->nextChild(); |
613 | } else { | 611 | } else { |
614 | element = element->firstChild(); | 612 | element = element->firstChild(); |
@@ -618,16 +616,16 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal | |||
618 | /* Parse all Contacts and ignore unknown tags */ | 616 | /* Parse all Contacts and ignore unknown tags */ |
619 | while( element ){ | 617 | while( element ){ |
620 | if( element->tagName() != QString::fromLatin1("Contact") ){ | 618 | if( element->tagName() != QString::fromLatin1("Contact") ){ |
621 | //qWarning ("OPimContactDefBack::Searching for Tag \"Contact\"! Found: %s", | 619 | //owarn << "OPimContactDefBack::Searching for Tag \"Contact\"! Found: " |
622 | // element->tagName().latin1()); | 620 | // << element->tagName() << oendl; |
623 | element = element->nextChild(); | 621 | element = element->nextChild(); |
624 | continue; | 622 | continue; |
625 | } | 623 | } |
626 | /* Found alement with tagname "contact", now parse and store all | 624 | /* Found alement with tagname "contact", now parse and store all |
627 | * attributes contained | 625 | * attributes contained |
628 | */ | 626 | */ |
629 | //qWarning("OPimContactDefBack::load element tagName() : %s", | 627 | //owarn << "OPimContactDefBack::load element tagName() : " |
630 | // element->tagName().latin1() ); | 628 | // << element->tagName() << oendl; |
631 | QString dummy; | 629 | QString dummy; |
632 | foundAction = false; | 630 | foundAction = false; |
633 | 631 | ||
@@ -636,7 +634,7 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal | |||
636 | contactMap.clear(); | 634 | contactMap.clear(); |
637 | customMap.clear(); | 635 | customMap.clear(); |
638 | for( it = aMap.begin(); it != aMap.end(); ++it ){ | 636 | for( it = aMap.begin(); it != aMap.end(); ++it ){ |
639 | // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); | 637 | // owarn << "Read Attribute: " << it.key() << "=" << it.data() << oendl; |
640 | 638 | ||
641 | int *find = dict[ it.key() ]; | 639 | int *find = dict[ it.key() ]; |
642 | /* Unknown attributes will be stored as "Custom" elements */ | 640 | /* Unknown attributes will be stored as "Custom" elements */ |
@@ -662,7 +660,7 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal | |||
662 | case JOURNALACTION: | 660 | case JOURNALACTION: |
663 | action = journal_action(it.data().toInt()); | 661 | action = journal_action(it.data().toInt()); |
664 | foundAction = true; | 662 | foundAction = true; |
665 | qWarning ("ODefBack(journal)::ACTION found: %d", action); | 663 | owarn << "ODefBack(journal)::ACTION found: " << action << oendl; |
666 | break; | 664 | break; |
667 | case JOURNALROW: | 665 | case JOURNALROW: |
668 | journalKey = it.data().toInt(); | 666 | journalKey = it.data().toInt(); |
@@ -687,16 +685,14 @@ bool OPimContactAccessBackend_XML::load( const QString filename, bool isJournal | |||
687 | break; | 685 | break; |
688 | case ACTION_REMOVE: | 686 | case ACTION_REMOVE: |
689 | if ( !remove (contact.uid()) ) | 687 | if ( !remove (contact.uid()) ) |
690 | qWarning ("ODefBack(journal)::Unable to remove uid: %d", | 688 | owarn << "ODefBack(journal)::Unable to remove uid: " << contact.uid() << oendl; |
691 | contact.uid() ); | ||
692 | break; | 689 | break; |
693 | case ACTION_REPLACE: | 690 | case ACTION_REPLACE: |
694 | if ( !replace ( contact ) ) | 691 | if ( !replace ( contact ) ) |
695 | qWarning ("ODefBack(journal)::Unable to replace uid: %d", | 692 | owarn << "ODefBack(journal)::Unable to replace uid: " << contact.uid() << oendl; |
696 | contact.uid() ); | ||
697 | break; | 693 | break; |
698 | default: | 694 | default: |
699 | qWarning ("Unknown action: ignored !"); | 695 | owarn << "Unknown action: ignored !" << oendl; |
700 | break; | 696 | break; |
701 | } | 697 | } |
702 | }else{ | 698 | }else{ |
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 | |||
@@ -36,6 +36,16 @@ | |||
36 | #include "ocontactaccess.h" | 36 | #include "ocontactaccess.h" |
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> |
41 | #include <qfile.h> | 51 | #include <qfile.h> |
@@ -43,117 +53,112 @@ | |||
43 | #include <qlist.h> | 53 | #include <qlist.h> |
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> |
51 | #include <unistd.h> | 59 | #include <unistd.h> |
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 | ||
87 | } | 92 | } |
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 | ||
97 | 102 | ||
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 | ||
132 | 137 | ||
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 | ||
138 | 143 | ||
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 | ||
159 | } | 164 | } |
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h index e438980..55d600a 100644 --- a/libopie2/opiepim/core/opimaccesstemplate.h +++ b/libopie2/opiepim/core/opimaccesstemplate.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) Holger Freyther <zecke@handhelds.org> | 3 | Copyright (C) Holger Freyther <zecke@handhelds.org> |
4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> | 4 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 5 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
@@ -30,14 +30,17 @@ | |||
30 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H | 30 | #ifndef OPIE_PIM_ACCESS_TEMPLATE_H |
31 | #define OPIE_PIM_ACCESS_TEMPLATE_H | 31 | #define OPIE_PIM_ACCESS_TEMPLATE_H |
32 | 32 | ||
33 | #include <qarray.h> | 33 | /* OPIE */ |
34 | |||
35 | #include <opie2/opimrecord.h> | 34 | #include <opie2/opimrecord.h> |
36 | #include <opie2/opimaccessbackend.h> | 35 | #include <opie2/opimaccessbackend.h> |
37 | #include <opie2/opimrecordlist.h> | 36 | #include <opie2/opimrecordlist.h> |
38 | 37 | ||
39 | #include <opie2/opimcache.h> | 38 | #include <opie2/opimcache.h> |
40 | #include <opie2/opimtemplatebase.h> | 39 | #include <opie2/opimtemplatebase.h> |
40 | #include <opie2/odebug.h> | ||
41 | |||
42 | /* QT */ | ||
43 | #include <qarray.h> | ||
41 | 44 | ||
42 | namespace Opie { | 45 | namespace Opie { |
43 | 46 | ||
@@ -205,7 +208,7 @@ OPimAccessTemplate<T>::OPimAccessTemplate( BackEnd* end ) | |||
205 | } | 208 | } |
206 | template <class T> | 209 | template <class T> |
207 | OPimAccessTemplate<T>::~OPimAccessTemplate() { | 210 | OPimAccessTemplate<T>::~OPimAccessTemplate() { |
208 | qWarning("~OPimAccessTemplate<T>"); | 211 | owarn << "~OPimAccessTemplate<T>" << oendl; |
209 | delete m_backEnd; | 212 | delete m_backEnd; |
210 | } | 213 | } |
211 | template <class T> | 214 | template <class T> |
@@ -215,8 +218,8 @@ bool OPimAccessTemplate<T>::load() { | |||
215 | } | 218 | } |
216 | template <class T> | 219 | template <class T> |
217 | bool OPimAccessTemplate<T>::reload() { | 220 | bool OPimAccessTemplate<T>::reload() { |
218 | invalidateCache(); // zecke: I think this should be added (se) | 221 | invalidateCache(); // zecke: I think this should be added (se) |
219 | return m_backEnd->reload(); | 222 | return m_backEnd->reload(); |
220 | } | 223 | } |
221 | template <class T> | 224 | template <class T> |
222 | bool OPimAccessTemplate<T>::save() { | 225 | bool OPimAccessTemplate<T>::save() { |
@@ -260,7 +263,7 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar, | |||
260 | * after a find this way we would | 263 | * after a find this way we would |
261 | * avoid two finds in QCache... | 264 | * avoid two finds in QCache... |
262 | */ | 265 | */ |
263 | // qWarning("find it now %d", uid ); | 266 | // owarn << "find it now " << uid << oendl; |
264 | if (m_cache.contains( uid ) ) { | 267 | if (m_cache.contains( uid ) ) { |
265 | return m_cache.find( uid ); | 268 | return m_cache.find( uid ); |
266 | } | 269 | } |
diff --git a/libopie2/opiepim/core/opimcontact.cpp b/libopie2/opiepim/core/opimcontact.cpp index 48a74d0..36e9a93 100644 --- a/libopie2/opiepim/core/opimcontact.cpp +++ b/libopie2/opiepim/core/opimcontact.cpp | |||
@@ -1173,7 +1173,7 @@ void OPimContact::setAnniversary( const QDate &v ) | |||
1173 | QDate OPimContact::birthday() const | 1173 | QDate OPimContact::birthday() const |
1174 | { | 1174 | { |
1175 | QString str = find( Qtopia::Birthday ); | 1175 | QString str = find( Qtopia::Birthday ); |
1176 | // qWarning ("Birthday %s", str.latin1() ); | 1176 | // owarn << "Birthday " << str << oendl; |
1177 | if ( !str.isEmpty() ) | 1177 | if ( !str.isEmpty() ) |
1178 | return OPimDateConversion::dateFromString ( str ); | 1178 | return OPimDateConversion::dateFromString ( str ); |
1179 | else | 1179 | else |
@@ -1188,7 +1188,7 @@ QDate OPimContact::anniversary() const | |||
1188 | { | 1188 | { |
1189 | QDate empty; | 1189 | QDate empty; |
1190 | QString str = find( Qtopia::Anniversary ); | 1190 | QString str = find( Qtopia::Anniversary ); |
1191 | // qWarning ("Anniversary %s", str.latin1() ); | 1191 | // owarn << "Anniversary " << str << oendl; |
1192 | if ( !str.isEmpty() ) | 1192 | if ( !str.isEmpty() ) |
1193 | return OPimDateConversion::dateFromString ( str ); | 1193 | return OPimDateConversion::dateFromString ( str ); |
1194 | else | 1194 | else |
diff --git a/libopie2/opiepim/core/opimnotifymanager.cpp b/libopie2/opiepim/core/opimnotifymanager.cpp index 0f863aa..516dc79 100644 --- a/libopie2/opiepim/core/opimnotifymanager.cpp +++ b/libopie2/opiepim/core/opimnotifymanager.cpp | |||
@@ -227,8 +227,8 @@ void OPimNotifyManager::alarmsFromString( const QString& str ) | |||
227 | { | 227 | { |
228 | QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty | 228 | QStringList alarm = QStringList::split( ":", ( *it ), TRUE ); // allow empty |
229 | owarn << "alarm: " << alarm.join( "___" ) << "" << oendl; | 229 | owarn << "alarm: " << alarm.join( "___" ) << "" << oendl; |
230 | qWarning( "alarm[0]: %s %s", alarm[ 0 ].latin1(), | 230 | owarn << "alarm[0]: " << alarm[ 0 ] << " " |
231 | OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString().latin1() ); | 231 | << OPimDateConversion::dateTimeFromString( alarm[ 0 ] ).toString() << oendl; |
232 | OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ), | 232 | OPimAlarm al( alarm[ 2 ].toInt(), OPimDateConversion::dateTimeFromString( alarm[ 0 ] ), |
233 | alarm[ 1 ].toInt() ); | 233 | alarm[ 1 ].toInt() ); |
234 | add( al ); | 234 | add( al ); |
diff --git a/libopie2/opiepim/core/opimrecordlist.h b/libopie2/opiepim/core/opimrecordlist.h index b23138d..1d5027f 100644 --- a/libopie2/opiepim/core/opimrecordlist.h +++ b/libopie2/opiepim/core/opimrecordlist.h | |||
@@ -33,6 +33,7 @@ | |||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/opimtemplatebase.h> | 34 | #include <opie2/opimtemplatebase.h> |
35 | #include <opie2/opimrecord.h> | 35 | #include <opie2/opimrecord.h> |
36 | //#include <opie2/odebug.h> | ||
36 | 37 | ||
37 | /* QT */ | 38 | /* QT */ |
38 | #include <qarray.h> | 39 | #include <qarray.h> |
@@ -189,7 +190,7 @@ OPimRecordListIterator<T>::~OPimRecordListIterator() | |||
189 | template <class T> | 190 | template <class T> |
190 | OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator<T>& it ) | 191 | OPimRecordListIterator<T>::OPimRecordListIterator( const OPimRecordListIterator<T>& it ) |
191 | { | 192 | { |
192 | // qWarning("OPimRecordListIterator copy c'tor"); | 193 | //owarn << "OPimRecordListIterator copy c'tor" << oendl; |
193 | m_uids = it.m_uids; | 194 | m_uids = it.m_uids; |
194 | m_current = it.m_current; | 195 | m_current = it.m_current; |
195 | m_temp = it.m_temp; | 196 | m_temp = it.m_temp; |
@@ -215,7 +216,7 @@ OPimRecordListIterator<T> &OPimRecordListIterator<T>::operator=( const OPimRecor | |||
215 | template <class T> | 216 | template <class T> |
216 | T OPimRecordListIterator<T>::operator*() | 217 | T OPimRecordListIterator<T>::operator*() |
217 | { | 218 | { |
218 | //qWarning("operator* %d %d", m_current, m_uids[m_current] ); | 219 | //owarn << "operator* " << m_current << " " << m_uids[m_current] << oendl; |
219 | if ( !m_end ) | 220 | if ( !m_end ) |
220 | m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current, | 221 | m_record = m_temp->find( m_uids[ m_current ], m_uids, m_current, |
221 | m_direction ? Base::Forward : | 222 | m_direction ? Base::Forward : |