author | zecke <zecke> | 2004-11-18 21:49:23 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-11-18 21:49:23 (UTC) |
commit | 1e7f8f22fc10e3ed85b6563332ddc348c95792d0 (patch) (unidiff) | |
tree | 59498ba1d4a7dbff05228c09bebcf0c849e916be /libopie2/opiepim/backend/obackendfactory.h | |
parent | 41fa1c196965f17f9748f835d90c307b7e594883 (diff) | |
download | opie-1e7f8f22fc10e3ed85b6563332ddc348c95792d0.zip opie-1e7f8f22fc10e3ed85b6563332ddc348c95792d0.tar.gz opie-1e7f8f22fc10e3ed85b6563332ddc348c95792d0.tar.bz2 |
Backend Changes:
Each Backend can:
-Sort and Filter a set of Records/AllRecords (which can be filtered again)
-QueryByExample by every Backend
-Occurrences for a period of time and a QDateTime
-More common implementation
-OPimBackendOccurrence with common splitting to OPimOccurrence
Diffstat (limited to 'libopie2/opiepim/backend/obackendfactory.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/backend/obackendfactory.h | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h index 9f3a823..25e247b 100644 --- a/libopie2/opiepim/backend/obackendfactory.h +++ b/libopie2/opiepim/backend/obackendfactory.h | |||
@@ -59,15 +59,15 @@ | |||
59 | 59 | ||
60 | 60 | ||
61 | using namespace Opie; | 61 | using namespace Opie; |
62 | using namespace Opie::Pim; | 62 | using namespace Opie::Pim; |
63 | 63 | ||
64 | namespace Opie { | 64 | namespace Opie { |
65 | 65 | ||
66 | class OBackendPrivate; | 66 | class OBackendPrivate; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * This class is our factory. It will give us the default implementations | 69 | * This class is our factory. It will give us the default implementations |
70 | * of at least Todolist, Contacts and Datebook. In the future this class will | 70 | * of at least Todolist, Contacts and Datebook. In the future this class will |
71 | * allow users to switch the backend with ( XML->SQLite ) without the need | 71 | * allow users to switch the backend with ( XML->SQLite ) without the need |
72 | * to recompile.# | 72 | * to recompile.# |
73 | * This class - as the whole PIM Api - is making use of templates | 73 | * This class - as the whole PIM Api - is making use of templates |
@@ -81,34 +81,36 @@ class OBackendPrivate; | |||
81 | * @version 0.1 | 81 | * @version 0.1 |
82 | */ | 82 | */ |
83 | template<class T> | 83 | template<class T> |
84 | class OBackendFactory | 84 | class OBackendFactory |
85 | { | 85 | { |
86 | public: | 86 | public: |
87 | OBackendFactory() {}; | 87 | OBackendFactory() {}; |
88 | 88 | ||
89 | /** | 89 | /** |
90 | * Returns a selected backend implementation | 90 | * Returns a selected backend implementation |
91 | * @param type the type of the backend | 91 | * @param type the type of the backend |
92 | * @param database the type of the used database | 92 | * @param database the type of the used database |
93 | * @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. |
94 | * @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 |
95 | * @see OPimGlobal() | 95 | * @see OPimGlobal() |
96 | */ | 96 | */ |
97 | static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, | 97 | static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, |
98 | const QString& appName, const QString& filename = QString::null ){ | 98 | const QString& appName, const QString& filename = QString::null ){ |
99 | owarn << "Selected backend for " << type << " is: " << database << oendl; | 99 | owarn << "Selected backend for " << type << " is: " << |
100 | // If we should use the dafult database style, we have to request it | 100 | database << oendl; |
101 | |||
102 | // If we should use the dafult database style, we have to request it | ||
101 | OPimGlobal::DatabaseStyle use_database = database; | 103 | OPimGlobal::DatabaseStyle use_database = database; |
102 | if ( use_database == OPimGlobal::DEFAULT ){ | 104 | if ( use_database == OPimGlobal::DEFAULT ){ |
103 | use_database = defaultDB( type ); | 105 | use_database = defaultDB( type ); |
104 | } | 106 | } |
105 | 107 | ||
106 | switch ( type ){ | 108 | switch ( type ){ |
107 | case OPimGlobal::TODOLIST: | 109 | case OPimGlobal::TODOLIST: |
108 | 110 | ||
109 | switch ( use_database ){ | 111 | switch ( use_database ){ |
110 | default: // Use SQL if something weird is given. | 112 | default: // Use SQL if something weird is given. |
111 | // Fall through !! | 113 | // Fall through !! |
112 | case OPimGlobal::SQL: | 114 | case OPimGlobal::SQL: |
113 | #ifdef __USE_SQL | 115 | #ifdef __USE_SQL |
114 | return (T*) new OPimTodoAccessBackendSQL( filename ); | 116 | return (T*) new OPimTodoAccessBackendSQL( filename ); |
@@ -163,15 +165,15 @@ class OBackendPrivate; | |||
163 | return (T*) NULL; | 165 | return (T*) NULL; |
164 | break; | 166 | break; |
165 | } | 167 | } |
166 | default: | 168 | default: |
167 | return (T*) NULL; | 169 | return (T*) NULL; |
168 | } | 170 | } |
169 | 171 | ||
170 | } | 172 | } |
171 | 173 | ||
172 | /** | 174 | /** |
173 | * Returns the style of the default database which is used to contact PIM data. | 175 | * Returns the style of the default database which is used to contact PIM data. |
174 | * @param type the type of the backend | 176 | * @param type the type of the backend |
175 | * @see OPimGlobal() | 177 | * @see OPimGlobal() |
176 | */ | 178 | */ |
177 | static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ | 179 | static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ |
@@ -186,45 +188,45 @@ class OBackendPrivate; | |||
186 | case OPimGlobal::DATEBOOK: | 188 | case OPimGlobal::DATEBOOK: |
187 | group_name = "datebook"; | 189 | group_name = "datebook"; |
188 | break; | 190 | break; |
189 | default: | 191 | default: |
190 | group_name = "unknown"; | 192 | group_name = "unknown"; |
191 | } | 193 | } |
192 | 194 | ||
193 | Config config( "pimaccess" ); | 195 | Config config( "pimaccess" ); |
194 | config.setGroup ( group_name ); | 196 | config.setGroup ( group_name ); |
195 | QString db_String = config.readEntry( "usebackend", "xml" ); | 197 | QString db_String = config.readEntry( "usebackend", "xml" ); |
196 | 198 | ||
197 | QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle ); | 199 | QAsciiDict<int> dictDbTypes( OPimGlobal::_END_DatabaseStyle ); |
198 | dictDbTypes.setAutoDelete( TRUE ); | 200 | dictDbTypes.setAutoDelete( TRUE ); |
199 | 201 | ||
200 | dictDbTypes.insert( "xml", new int (OPimGlobal::XML) ); | 202 | dictDbTypes.insert( "xml", new int (OPimGlobal::XML) ); |
201 | dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) ); | 203 | dictDbTypes.insert( "sql", new int (OPimGlobal::SQL) ); |
202 | dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) ); | 204 | dictDbTypes.insert( "vcard", new int (OPimGlobal::VCARD) ); |
203 | 205 | ||
204 | int* db_find = dictDbTypes[ db_String ]; | 206 | int* db_find = dictDbTypes[ db_String ]; |
205 | 207 | ||
206 | if ( !db_find ) | 208 | if ( !db_find ) |
207 | return OPimGlobal::UNKNOWN; | 209 | return OPimGlobal::UNKNOWN; |
208 | 210 | ||
209 | return (OPimGlobal::DatabaseStyle) *db_find; | 211 | return (OPimGlobal::DatabaseStyle) *db_find; |
210 | } | 212 | } |
211 | 213 | ||
212 | 214 | ||
213 | /** | 215 | /** |
214 | * Returns the default backend implementation for backendName. Which one is used, is defined | 216 | * Returns the default backend implementation for backendName. Which one is used, is defined |
215 | * by the configfile "pimaccess.conf". | 217 | * by the configfile "pimaccess.conf". |
216 | * @param type The type of the backend (@see OPimGlobal()) | 218 | * @param type The type of the backend (@see OPimGlobal()) |
217 | * @param appName The name of your application. It will be passed on to the backend | 219 | * @param appName The name of your application. It will be passed on to the backend |
218 | * @see OPimGlobal() | 220 | * @see OPimGlobal() |
219 | */ | 221 | */ |
220 | static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){ | 222 | static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){ |
221 | return create( type, OPimGlobal::DEFAULT, appName ); | 223 | return create( type, OPimGlobal::DEFAULT, appName ); |
222 | } | 224 | } |
223 | private: | 225 | private: |
224 | OBackendPrivate* d; | 226 | OBackendPrivate* d; |
225 | 227 | ||
226 | }; | 228 | }; |
227 | 229 | ||
228 | } | 230 | } |
229 | 231 | ||
230 | #endif | 232 | #endif |