summaryrefslogtreecommitdiff
path: root/libopie2/opiepim
Unidiff
Diffstat (limited to 'libopie2/opiepim') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h2
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp2
-rw-r--r--libopie2/opiepim/core/odatebookaccess.cpp2
-rw-r--r--libopie2/opiepim/core/opimaccessfactory.h2
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp2
5 files changed, 5 insertions, 5 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index 993ecb4..4daf861 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -85,124 +85,124 @@ class OBackendFactory
85 */ 85 */
86 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, 86 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database,
87 const QString& appName ){ 87 const QString& appName ){
88 qWarning("Selected backend for %d is: %d", type, database ); 88 qWarning("Selected backend for %d is: %d", type, database );
89 // If we should use the dafult database style, we have to request it 89 // If we should use the dafult database style, we have to request it
90 OPimGlobal::DatabaseStyle used_database = database; 90 OPimGlobal::DatabaseStyle used_database = database;
91 if ( database == OPimGlobal::DEFAULT ){ 91 if ( database == OPimGlobal::DEFAULT ){
92 used_database = defaultDB( type ); 92 used_database = defaultDB( type );
93 } 93 }
94 94
95 95
96 switch ( type ){ 96 switch ( type ){
97 case OPimGlobal::TODOLIST: 97 case OPimGlobal::TODOLIST:
98#ifdef __USE_SQL 98#ifdef __USE_SQL
99 if ( used_database == OPimGlobal::SQL ) 99 if ( used_database == OPimGlobal::SQL )
100 return (T*) new OPimTodoAccessBackendSQL(""); 100 return (T*) new OPimTodoAccessBackendSQL("");
101#else 101#else
102 if ( used_database == OPimGlobal::SQL ) 102 if ( used_database == OPimGlobal::SQL )
103 qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); 103 qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!");
104#endif 104#endif
105 105
106 return (T*) new OPimTodoAccessXML( appName ); 106 return (T*) new OPimTodoAccessXML( appName );
107 case OPimGlobal::CONTACTLIST: 107 case OPimGlobal::CONTACTLIST:
108#ifdef __USE_SQL 108#ifdef __USE_SQL
109 if ( used_database == OPimGlobal::SQL ) 109 if ( used_database == OPimGlobal::SQL )
110 return (T*) new OPimContactAccessBackend_SQL(""); 110 return (T*) new OPimContactAccessBackend_SQL("");
111#else 111#else
112 if ( used_database == OPimGlobal::SQL ) 112 if ( used_database == OPimGlobal::SQL )
113 qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); 113 qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!");
114#endif 114#endif
115 115
116 return (T*) new OPimContactAccessBackend_XML( appName ); 116 return (T*) new OPimContactAccessBackend_XML( appName );
117 case OPimGlobal::DATEBOOK: 117 case OPimGlobal::DATEBOOK:
118#ifdef __USE_SQL 118#ifdef __USE_SQL
119 if ( used_database == OPimGlobal::SQL ) 119 if ( used_database == OPimGlobal::SQL )
120 return (T*) new ODateBookAccessBackend_SQL(""); 120 return (T*) new ODateBookAccessBackend_SQL("");
121#else 121#else
122 if ( used_database == OPimGlobal::SQL ) 122 if ( used_database == OPimGlobal::SQL )
123 qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); 123 qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!");
124#endif 124#endif
125 125
126 return (T*) new ODateBookAccessBackend_XML( appName ); 126 return (T*) new ODateBookAccessBackend_XML( appName );
127 default: 127 default:
128 return (T*) NULL; 128 return (T*) NULL;
129 } 129 }
130 130
131 131
132 } 132 }
133 133
134 /** 134 /**
135 * Returns the style of the default database which is used to contact PIM data. 135 * Returns the style of the default database which is used to contact PIM data.
136 * @param type the type of the backend 136 * @param type the type of the backend
137 * @see OPimGlobal 137 * @see OPimGlobal
138 */ 138 */
139 static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ 139 static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){
140 QString group_name; 140 QString group_name;
141 switch ( type ){ 141 switch ( type ){
142 case OPimGlobal::TODOLIST: 142 case OPimGlobal::TODOLIST:
143 group_name = "todo"; 143 group_name = "todo";
144 break; 144 break;
145 case OPimGlobal::CONTACTLIST: 145 case OPimGlobal::CONTACTLIST:
146 group_name = "contact"; 146 group_name = "contact";
147 break; 147 break;
148 case OPimGlobal::DATEBOOK: 148 case OPimGlobal::DATEBOOK:
149 group_name = "datebook"; 149 group_name = "datebook";
150 break; 150 break;
151 default: 151 default:
152 group_name = "unknown"; 152 group_name = "unknown";
153 } 153 }
154 154
155 Config config( "pimaccess" ); 155 Config config( "pimaccess" );
156 config.setGroup ( group_name ); 156 config.setGroup ( group_name );
157 QString db_String = config.readEntry( "usebackend" ); 157 QString db_String = config.readEntry( "usebackend" );
158 158
159 QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle ); 159 QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle );
160 dictDbTypes.setAutoDelete( TRUE ); 160 dictDbTypes.setAutoDelete( TRUE );
161 161
162 dictDbTypes.insert( "xml", new int (OPimGlobal::XML) ); 162 dictDbTypes.insert( "xml", new int (OPimGlobal::XML) );
163 dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) ); 163 dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) );
164 dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) ); 164 dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) );
165 165
166 int* db_find = dictDbTypes[ db_String ]; 166 int* db_find = dictDbTypes[ db_String ];
167 167
168 if ( !db_find ) 168 if ( !db_find )
169 return OPimGlobal::UNKNOWN; 169 return OPimGlobal::UNKNOWN;
170 170
171 return (OPimGlobal::DatabaseStyle) *db_find; 171 return (OPimGlobal::DatabaseStyle) *db_find;
172 } 172 }
173 173
174 174
175 /** 175 /**
176 * Returns the default backend implementation for backendName. Which one is used, is defined 176 * Returns the default backend implementation for backendName. Which one is used, is defined
177 * by the configfile "pimaccess.conf". 177 * by the configfile "pimaccess.conf".
178 * @param backendName the type of the backend (use "todo", "contact" or "datebook" ) 178 * @param backendName the type of the backend (use "todo", "contact" or "datebook" )
179 * @param appName The name of your application. It will be passed on to the backend 179 * @param appName The name of your application. It will be passed on to the backend
180 */ 180 */
181 static T* Default( const QString backendName, const QString& appName ){ 181 static T* defaultBackend( const QString backendName, const QString& appName ){
182 182
183 QAsciiDict<int> dictBackends( OPimGlobal::_END_PimType ); 183 QAsciiDict<int> dictBackends( OPimGlobal::_END_PimType );
184 dictBackends.setAutoDelete ( TRUE ); 184 dictBackends.setAutoDelete ( TRUE );
185 185
186 dictBackends.insert( "todo", new int (OPimGlobal::TODOLIST) ); 186 dictBackends.insert( "todo", new int (OPimGlobal::TODOLIST) );
187 dictBackends.insert( "contact", new int (OPimGlobal::CONTACTLIST) ); 187 dictBackends.insert( "contact", new int (OPimGlobal::CONTACTLIST) );
188 dictBackends.insert( "datebook", new int(OPimGlobal::DATEBOOK) ); 188 dictBackends.insert( "datebook", new int(OPimGlobal::DATEBOOK) );
189 189
190 int* backend_find = dictBackends[ backendName ]; 190 int* backend_find = dictBackends[ backendName ];
191 if ( !backend_find ) return NULL; 191 if ( !backend_find ) return NULL;
192 192
193 OPimGlobal::DatabaseStyle style = defaultDB( static_cast<OPimGlobal::PimType>( *backend_find ) ); 193 OPimGlobal::DatabaseStyle style = defaultDB( static_cast<OPimGlobal::PimType>( *backend_find ) );
194 194
195 qDebug( "OBackendFactory::Default -> Backend is %s, Database is %d", backendName.latin1(), 195 qDebug( "OBackendFactory::Default -> Backend is %s, Database is %d", backendName.latin1(),
196 style ); 196 style );
197 197
198 return create( (OPimGlobal::PimType) *backend_find, style, appName ); 198 return create( (OPimGlobal::PimType) *backend_find, style, appName );
199 199
200 } 200 }
201 private: 201 private:
202 OBackendPrivate* d; 202 OBackendPrivate* d;
203 203
204}; 204};
205 205
206} 206}
207 207
208#endif 208#endif
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index 67f267f..417a954 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -1,158 +1,158 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29/* 29/*
30 * ===================================================================== 30 * =====================================================================
31 * ToDo: XML-Backend: Automatic reload if something was changed... 31 * ToDo: XML-Backend: Automatic reload if something was changed...
32 * 32 *
33 * 33 *
34 */ 34 */
35 35
36#include "ocontactaccess.h" 36#include "ocontactaccess.h"
37#include "obackendfactory.h" 37#include "obackendfactory.h"
38 38
39#include <qasciidict.h> 39#include <qasciidict.h>
40#include <qdatetime.h> 40#include <qdatetime.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qlist.h> 43#include <qlist.h>
44#include <qcopchannel_qws.h> 44#include <qcopchannel_qws.h>
45 45
46//#include <qpe/qcopenvelope_qws.h> 46//#include <qpe/qcopenvelope_qws.h>
47#include <qpe/global.h> 47#include <qpe/global.h>
48 48
49#include <errno.h> 49#include <errno.h>
50#include <fcntl.h> 50#include <fcntl.h>
51#include <unistd.h> 51#include <unistd.h>
52#include <stdlib.h> 52#include <stdlib.h>
53 53
54#include <opie2/ocontactaccessbackend_xml.h> 54#include <opie2/ocontactaccessbackend_xml.h>
55#include <opie2/opimresolver.h> 55#include <opie2/opimresolver.h>
56 56
57namespace Opie { 57namespace Opie {
58 58
59OPimContactAccess::OPimContactAccess ( const QString appname, const QString , 59OPimContactAccess::OPimContactAccess ( const QString appname, const QString ,
60 OPimContactAccessBackend* end, bool autosync ): 60 OPimContactAccessBackend* end, bool autosync ):
61 OPimAccessTemplate<OPimContact>( end ) 61 OPimAccessTemplate<OPimContact>( end )
62{ 62{
63 /* take care of the backend. If there is no one defined, we 63 /* take care of the backend. If there is no one defined, we
64 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 64 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
65 */ 65 */
66 if( end == 0 ) { 66 if( end == 0 ) {
67 qWarning ("Using BackendFactory !"); 67 qWarning ("Using BackendFactory !");
68 end = OBackendFactory<OPimContactAccessBackend>::Default( "contact", appname ); 68 end = OBackendFactory<OPimContactAccessBackend>::defaultBackend( "contact", appname );
69 } 69 }
70 // Set backend locally and in template 70 // Set backend locally and in template
71 m_backEnd = end; 71 m_backEnd = end;
72 OPimAccessTemplate<OPimContact>::setBackEnd (end); 72 OPimAccessTemplate<OPimContact>::setBackEnd (end);
73 73
74 74
75 /* Connect signal of external db change to function */ 75 /* Connect signal of external db change to function */
76 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 76 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
77 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), 77 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)),
78 this, SLOT(copMessage(const QCString&,const QByteArray&)) ); 78 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
79 if ( autosync ){ 79 if ( autosync ){
80 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 80 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
81 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), 81 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)),
82 this, SLOT(copMessage(const QCString&,const QByteArray&)) ); 82 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
83 } 83 }
84 84
85 85
86} 86}
87OPimContactAccess::~OPimContactAccess () 87OPimContactAccess::~OPimContactAccess ()
88{ 88{
89 /* The user may forget to save the changed database, therefore try to 89 /* The user may forget to save the changed database, therefore try to
90 * do it for him.. 90 * do it for him..
91 */ 91 */
92 save(); 92 save();
93 // delete m_backEnd; is done by template.. 93 // delete m_backEnd; is done by template..
94} 94}
95 95
96 96
97bool OPimContactAccess::save () 97bool OPimContactAccess::save ()
98{ 98{
99 /* If the database was changed externally, we could not save the 99 /* If the database was changed externally, we could not save the
100 * Data. This will remove added items which is unacceptable ! 100 * Data. This will remove added items which is unacceptable !
101 * Therefore: Reload database and merge the data... 101 * Therefore: Reload database and merge the data...
102 */ 102 */
103 if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() ) 103 if ( OPimAccessTemplate<OPimContact>::wasChangedExternally() )
104 reload(); 104 reload();
105 105
106 bool status = OPimAccessTemplate<OPimContact>::save(); 106 bool status = OPimAccessTemplate<OPimContact>::save();
107 if ( !status ) return false; 107 if ( !status ) return false;
108 108
109 /* Now tell everyone that new data is available. 109 /* Now tell everyone that new data is available.
110 */ 110 */
111 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 111 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
112 112
113 return true; 113 return true;
114} 114}
115 115
116const uint OPimContactAccess::querySettings() 116const uint OPimContactAccess::querySettings()
117{ 117{
118 return ( m_backEnd->querySettings() ); 118 return ( m_backEnd->querySettings() );
119} 119}
120 120
121bool OPimContactAccess::hasQuerySettings ( int querySettings ) const 121bool OPimContactAccess::hasQuerySettings ( int querySettings ) const
122{ 122{
123 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 123 return ( m_backEnd->hasQuerySettings ( querySettings ) );
124} 124}
125OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 125OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
126{ 126{
127 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 127 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
128 return ( OPimRecordList<OPimContact>(matchingContacts, this) ); 128 return ( OPimRecordList<OPimContact>(matchingContacts, this) );
129} 129}
130 130
131 131
132bool OPimContactAccess::wasChangedExternally()const 132bool OPimContactAccess::wasChangedExternally()const
133{ 133{
134 return ( m_backEnd->wasChangedExternally() ); 134 return ( m_backEnd->wasChangedExternally() );
135} 135}
136 136
137 137
138void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) 138void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & )
139{ 139{
140 if ( msg == "addressbookUpdated()" ){ 140 if ( msg == "addressbookUpdated()" ){
141 qWarning ("OPimContactAccess: Received addressbokUpdated()"); 141 qWarning ("OPimContactAccess: Received addressbokUpdated()");
142 emit signalChanged ( this ); 142 emit signalChanged ( this );
143 } else if ( msg == "flush()" ) { 143 } else if ( msg == "flush()" ) {
144 qWarning ("OPimContactAccess: Received flush()"); 144 qWarning ("OPimContactAccess: Received flush()");
145 save (); 145 save ();
146 } else if ( msg == "reload()" ) { 146 } else if ( msg == "reload()" ) {
147 qWarning ("OPimContactAccess: Received reload()"); 147 qWarning ("OPimContactAccess: Received reload()");
148 reload (); 148 reload ();
149 emit signalChanged ( this ); 149 emit signalChanged ( this );
150 } 150 }
151} 151}
152 152
153int OPimContactAccess::rtti() const 153int OPimContactAccess::rtti() const
154{ 154{
155 return OPimResolver::AddressBook; 155 return OPimResolver::AddressBook;
156} 156}
157 157
158} 158}
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp
index 29298ea..5f471cf 100644
--- a/libopie2/opiepim/core/odatebookaccess.cpp
+++ b/libopie2/opiepim/core/odatebookaccess.cpp
@@ -1,117 +1,117 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de) 3 Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <opie2/obackendfactory.h> 29#include <opie2/obackendfactory.h>
30#include <opie2/odatebookaccess.h> 30#include <opie2/odatebookaccess.h>
31#include <opie2/opimresolver.h> 31#include <opie2/opimresolver.h>
32 32
33namespace Opie { 33namespace Opie {
34/** 34/**
35 * Simple constructor 35 * Simple constructor
36 * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation 36 * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation
37 * will be used! 37 * will be used!
38 * @param back The backend to be used or 0 for the default backend 38 * @param back The backend to be used or 0 for the default backend
39 * @param ac What kind of access is intended 39 * @param ac What kind of access is intended
40 */ 40 */
41ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) 41ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
42 : OPimAccessTemplate<OPimEvent>( back ) 42 : OPimAccessTemplate<OPimEvent>( back )
43{ 43{
44 if (!back ) 44 if (!back )
45 back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null ); 45 back = OBackendFactory<ODateBookAccessBackend>::defaultBackend("datebook", QString::null );
46 46
47 m_backEnd = back; 47 m_backEnd = back;
48 setBackEnd( m_backEnd ); 48 setBackEnd( m_backEnd );
49} 49}
50ODateBookAccess::~ODateBookAccess() { 50ODateBookAccess::~ODateBookAccess() {
51} 51}
52 52
53/** 53/**
54 * @return all events available 54 * @return all events available
55 */ 55 */
56ODateBookAccess::List ODateBookAccess::rawEvents()const { 56ODateBookAccess::List ODateBookAccess::rawEvents()const {
57 QArray<int> ints = m_backEnd->rawEvents(); 57 QArray<int> ints = m_backEnd->rawEvents();
58 58
59 List lis( ints, this ); 59 List lis( ints, this );
60 return lis; 60 return lis;
61} 61}
62 62
63/** 63/**
64 * @return all repeating events 64 * @return all repeating events
65 */ 65 */
66ODateBookAccess::List ODateBookAccess::rawRepeats()const { 66ODateBookAccess::List ODateBookAccess::rawRepeats()const {
67 QArray<int> ints = m_backEnd->rawRepeats(); 67 QArray<int> ints = m_backEnd->rawRepeats();
68 68
69 List lis( ints, this ); 69 List lis( ints, this );
70 return lis; 70 return lis;
71} 71}
72 72
73/** 73/**
74 * @return all non repeating events 74 * @return all non repeating events
75 */ 75 */
76ODateBookAccess::List ODateBookAccess::nonRepeats()const { 76ODateBookAccess::List ODateBookAccess::nonRepeats()const {
77 QArray<int> ints = m_backEnd->nonRepeats(); 77 QArray<int> ints = m_backEnd->nonRepeats();
78 78
79 List lis( ints, this ); 79 List lis( ints, this );
80 return lis; 80 return lis;
81} 81}
82 82
83/** 83/**
84 * @return dates in the time span between from and to 84 * @return dates in the time span between from and to
85 * @param from Include all events from... 85 * @param from Include all events from...
86 * @param to Include all events to... 86 * @param to Include all events to...
87 */ 87 */
88OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const { 88OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const {
89 return m_backEnd->effectiveEvents( from, to ); 89 return m_backEnd->effectiveEvents( from, to );
90} 90}
91/** 91/**
92 * @return all events at a given datetime 92 * @return all events at a given datetime
93 */ 93 */
94OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const { 94OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const {
95 return m_backEnd->effectiveEvents( start ); 95 return m_backEnd->effectiveEvents( start );
96} 96}
97 97
98/** 98/**
99 * @return non repeating dates in the time span between from and to 99 * @return non repeating dates in the time span between from and to
100 * @param from Include all events from... 100 * @param from Include all events from...
101 * @param to Include all events to... 101 * @param to Include all events to...
102 */ 102 */
103OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { 103OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const {
104 return m_backEnd->effectiveNonRepeatingEvents( from, to ); 104 return m_backEnd->effectiveNonRepeatingEvents( from, to );
105} 105}
106/** 106/**
107 * @return all non repeating events at a given datetime 107 * @return all non repeating events at a given datetime
108 */ 108 */
109OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { 109OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const {
110 return m_backEnd->effectiveNonRepeatingEvents( start ); 110 return m_backEnd->effectiveNonRepeatingEvents( start );
111} 111}
112int ODateBookAccess::rtti() const 112int ODateBookAccess::rtti() const
113{ 113{
114 return OPimResolver::DateBook; 114 return OPimResolver::DateBook;
115} 115}
116 116
117} 117}
diff --git a/libopie2/opiepim/core/opimaccessfactory.h b/libopie2/opiepim/core/opimaccessfactory.h
index 7d32958..6aaa5e4 100644
--- a/libopie2/opiepim/core/opimaccessfactory.h
+++ b/libopie2/opiepim/core/opimaccessfactory.h
@@ -11,107 +11,107 @@
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#ifndef __OPIE_OPIMACCESSFACTORY_H_ 30#ifndef __OPIE_OPIMACCESSFACTORY_H_
31#define __OPIE_OPIMACCESSFACTORY_H_ 31#define __OPIE_OPIMACCESSFACTORY_H_
32 32
33#include <opie2/opimglobal.h> 33#include <opie2/opimglobal.h>
34#include <opie2/obackendfactory.h> 34#include <opie2/obackendfactory.h>
35#include <opie2/ocontactaccess.h> 35#include <opie2/ocontactaccess.h>
36#include <opie2/otodoaccess.h> 36#include <opie2/otodoaccess.h>
37#include <opie2/odatebookaccess.h> 37#include <opie2/odatebookaccess.h>
38 38
39using namespace Opie::Pim; 39using namespace Opie::Pim;
40 40
41namespace Opie { 41namespace Opie {
42 42
43 43
44/** 44/**
45 * This class is our factory for creating PIM access objects. You should use these objects to load, store and search 45 * This class is our factory for creating PIM access objects. You should use these objects to load, store and search
46 * information in our PIM databases. Currently we support objects for accessing the datebook, the contact- and the 46 * information in our PIM databases. Currently we support objects for accessing the datebook, the contact- and the
47 * todolist. 47 * todolist.
48 * @see OPimGlobal for more information of used values. 48 * @see OPimGlobal for more information of used values.
49 * 49 *
50 * This class - as the whole PIM Api - is making use of templates 50 * This class - as the whole PIM Api - is making use of templates
51 * 51 *
52 * Example for getting an access object for the XML database of todolist: 52 * Example for getting an access object for the XML database of todolist:
53 * <pre> 53 * <pre>
54 * OPimTodoAccess* access = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "example" ); 54 * OPimTodoAccess* access = OPimAccessFactory<OPimTodoAccess>::create( OPimGlobal::TODOLIST, OPimGlobal::XML, "example" );
55 * </pre> 55 * </pre>
56 * 56 *
57 * @author Stefan Eilers 57 * @author Stefan Eilers
58 * @version 0.1 58 * @version 0.1
59 */ 59 */
60 60
61template<class T> 61template<class T>
62class OPimAccessFactory 62class OPimAccessFactory
63{ 63{
64 public: 64 public:
65 65
66 // Maybe we should introduce a global class for storing such global enums 66 // Maybe we should introduce a global class for storing such global enums
67 // (something like opimglobal.h) ? (eilers) 67 // (something like opimglobal.h) ? (eilers)
68 68
69 OPimAccessFactory() {}; 69 OPimAccessFactory() {};
70 70
71 /** 71 /**
72 * Returns the selected PIM access-object. 72 * Returns the selected PIM access-object.
73 * @param type Type of the selected database (addressbook, todolist or datebook) 73 * @param type Type of the selected database (addressbook, todolist or datebook)
74 * @param dbStyle Which database style should be used (xml, sql, vcard) 74 * @param dbStyle Which database style should be used (xml, sql, vcard)
75 * @param appName "Name" of your application. This should be any constant string which is used 75 * @param appName "Name" of your application. This should be any constant string which is used
76 * by some backends for creating special files (i.e.journal files). Please keep the 76 * by some backends for creating special files (i.e.journal files). Please keep the
77 * string unique for your application ! 77 * string unique for your application !
78 * @see OPimGlobal 78 * @see OPimGlobal
79 */ 79 */
80 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle dbStyle, const QString& appName ){ 80 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle dbStyle, const QString& appName ){
81 81
82 switch ( type ){ 82 switch ( type ){
83 case OPimGlobal::TODOLIST: 83 case OPimGlobal::TODOLIST:
84 return dynamic_cast<T*>( new OPimTodoAccess( OBackendFactory<OPimTodoAccessBackend>::create( type, dbStyle, appName ) ) ); 84 return dynamic_cast<T*>( new OPimTodoAccess( OBackendFactory<OPimTodoAccessBackend>::create( type, dbStyle, appName ) ) );
85 case OPimGlobal::CONTACTLIST: 85 case OPimGlobal::CONTACTLIST:
86 return dynamic_cast<T*>( new OPimContactAccess( QString::null, QString::null, OBackendFactory<OPimContactAccessBackend>::create( type, dbStyle, appName ) ) ); 86 return dynamic_cast<T*>( new OPimContactAccess( QString::null, QString::null, OBackendFactory<OPimContactAccessBackend>::create( type, dbStyle, appName ) ) );
87 case OPimGlobal::DATEBOOK: 87 case OPimGlobal::DATEBOOK:
88 return dynamic_cast<T*>( new ODateBookAccess( OBackendFactory<ODateBookAccessBackend>::create( type, dbStyle, appName ) ) ); 88 return dynamic_cast<T*>( new ODateBookAccess( OBackendFactory<ODateBookAccessBackend>::create( type, dbStyle, appName ) ) );
89 default: 89 default:
90 return 0l; 90 return 0l;
91 91
92 } 92 }
93 } 93 }
94 94
95 95
96 /** 96 /**
97 * Returns the selected PIM access-object, using the default database style 97 * Returns the selected PIM access-object, using the default database style
98 * Which style is selected is defined in the configfile "pimaccess.conf" in 98 * Which style is selected is defined in the configfile "pimaccess.conf" in
99 * the directory "Settings" 99 * the directory "Settings"
100 * @param type Type of the selected database (addressbook, todolist or datebook) 100 * @param type Type of the selected database (addressbook, todolist or datebook)
101 * @param appName "Name" of your application. This should be any constant string which is used 101 * @param appName "Name" of your application. This should be any constant string which is used
102 * by some backends for creating special files (i.e.journal files). Please keep the 102 * by some backends for creating special files (i.e.journal files). Please keep the
103 * string unique for your application ! 103 * string unique for your application !
104 * @see OPimGlobal 104 * @see OPimGlobal
105 * 105 *
106 */ 106 */
107 static T* Default( typename OPimGlobal::PimType type, const QString& appName ){ 107 static T* defaultAccess( typename OPimGlobal::PimType type, const QString& appName ){
108 108
109 return create( type, OPimGlobal::DEFAULT, appName ); 109 return create( type, OPimGlobal::DEFAULT, appName );
110 110
111 } 111 }
112}; 112};
113 113
114} 114}
115 115
116 116
117#endif 117#endif
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp
index 6fa0089..87a211f 100644
--- a/libopie2/opiepim/core/otodoaccess.cpp
+++ b/libopie2/opiepim/core/otodoaccess.cpp
@@ -1,100 +1,100 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) The Main Author <main-author@whereever.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qdatetime.h> 29#include <qdatetime.h>
30 30
31#include <qpe/alarmserver.h> 31#include <qpe/alarmserver.h>
32 32
33// #include "otodoaccesssql.h" 33// #include "otodoaccesssql.h"
34#include <opie2/otodoaccess.h> 34#include <opie2/otodoaccess.h>
35#include <opie2/obackendfactory.h> 35#include <opie2/obackendfactory.h>
36#include <opie2/opimresolver.h> 36#include <opie2/opimresolver.h>
37 37
38namespace Opie { 38namespace Opie {
39OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) 39OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access )
40 : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) 40 : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end )
41{ 41{
42// if (end == 0l ) 42// if (end == 0l )
43// m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); 43// m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null);
44 44
45 // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! 45 // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben !
46 if (end == 0l ) 46 if (end == 0l )
47 m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::Default ("todo", QString::null); 47 m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::defaultBackend ("todo", QString::null);
48 48
49 setBackEnd( m_todoBackEnd ); 49 setBackEnd( m_todoBackEnd );
50} 50}
51OPimTodoAccess::~OPimTodoAccess() { 51OPimTodoAccess::~OPimTodoAccess() {
52// qWarning("~OPimTodoAccess"); 52// qWarning("~OPimTodoAccess");
53} 53}
54void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) { 54void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) {
55 QValueList<OPimTodo>::ConstIterator it; 55 QValueList<OPimTodo>::ConstIterator it;
56 for ( it = list.begin(); it != list.end(); ++it ) { 56 for ( it = list.begin(); it != list.end(); ++it ) {
57 replace( (*it) ); 57 replace( (*it) );
58 } 58 }
59} 59}
60OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, 60OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
61 const QDate& end, 61 const QDate& end,
62 bool includeNoDates ) { 62 bool includeNoDates ) {
63 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates ); 63 QArray<int> ints = m_todoBackEnd->effectiveToDos( start, end, includeNoDates );
64 64
65 List lis( ints, this ); 65 List lis( ints, this );
66 return lis; 66 return lis;
67} 67}
68OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, 68OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
69 bool includeNoDates ) { 69 bool includeNoDates ) {
70 return effectiveToDos( start, QDate::currentDate(), 70 return effectiveToDos( start, QDate::currentDate(),
71 includeNoDates ); 71 includeNoDates );
72} 72}
73OPimTodoAccess::List OPimTodoAccess::overDue() { 73OPimTodoAccess::List OPimTodoAccess::overDue() {
74 List lis( m_todoBackEnd->overDue(), this ); 74 List lis( m_todoBackEnd->overDue(), this );
75 return lis; 75 return lis;
76} 76}
77/* sort order */ 77/* sort order */
78OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { 78OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
79 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, 79 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
80 filter, cat ); 80 filter, cat );
81 OPimTodoAccess::List list( ints, this ); 81 OPimTodoAccess::List list( ints, this );
82 return list; 82 return list;
83} 83}
84void OPimTodoAccess::removeAllCompleted() { 84void OPimTodoAccess::removeAllCompleted() {
85 m_todoBackEnd->removeAllCompleted(); 85 m_todoBackEnd->removeAllCompleted();
86} 86}
87QBitArray OPimTodoAccess::backendSupport( const QString& ) const{ 87QBitArray OPimTodoAccess::backendSupport( const QString& ) const{
88 return m_todoBackEnd->supports(); 88 return m_todoBackEnd->supports();
89} 89}
90bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{ 90bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{
91 return backendSupport(ar).testBit( attr ); 91 return backendSupport(ar).testBit( attr );
92} 92}
93 93
94 94
95int OPimTodoAccess::rtti() const 95int OPimTodoAccess::rtti() const
96{ 96{
97 return OPimResolver::TodoList; 97 return OPimResolver::TodoList;
98} 98}
99 99
100} 100}