author | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-11-16 19:14:18 (UTC) |
commit | ea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff) | |
tree | f2ea22cc50e9aa8aa73ee7dea148f41c563c9666 /libopie/pim/obackendfactory.h | |
parent | 1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff) | |
download | opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2 |
libopie1 goes into unsupported
Diffstat (limited to 'libopie/pim/obackendfactory.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/obackendfactory.h | 194 |
1 files changed, 0 insertions, 194 deletions
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h deleted file mode 100644 index 761ab9a..0000000 --- a/libopie/pim/obackendfactory.h +++ b/dev/null | |||
@@ -1,194 +0,0 @@ | |||
1 | /* | ||
2 | * Class to manage Backends. | ||
3 | * | ||
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | ||
5 | * | ||
6 | * ===================================================================== | ||
7 | *This program is free software; you can redistribute it and/or | ||
8 | *modify it under the terms of the GNU Library General Public | ||
9 | * License as published by the Free Software Foundation; | ||
10 | * either version 2 of the License, or (at your option) any later | ||
11 | * version. | ||
12 | * ===================================================================== | ||
13 | * ToDo: Use plugins | ||
14 | * ===================================================================== | ||
15 | * Version: $Id$ | ||
16 | * ===================================================================== | ||
17 | * History: | ||
18 | * $Log$ | ||
19 | * Revision 1.9 2003/12/22 10:19:26 eilers | ||
20 | * Finishing implementation of sql-backend for datebook. But I have to | ||
21 | * port the PIM datebook application to use it, before I could debug the | ||
22 | * whole stuff. | ||
23 | * Thus, PIM-Database backend is finished, but highly experimental. And some | ||
24 | * parts are still generic. For instance, the "queryByExample()" methods are | ||
25 | * not (or not fully) implemented. Todo: custom-entries not stored. | ||
26 | * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular | ||
27 | * expression search in the database, which is not supported by sqlite ! | ||
28 | * Therefore we need either an extended sqlite or a workaround which would | ||
29 | * be very slow and memory consuming.. | ||
30 | * | ||
31 | * Revision 1.8 2003/09/22 14:31:16 eilers | ||
32 | * Added first experimental incarnation of sql-backend for addressbook. | ||
33 | * Some modifications to be able to compile the todo sql-backend. | ||
34 | * A lot of changes fill follow... | ||
35 | * | ||
36 | * Revision 1.7 2003/08/01 12:30:16 eilers | ||
37 | * Merging changes from BRANCH_1_0 to HEAD | ||
38 | * | ||
39 | * Revision 1.6.4.1 2003/06/30 14:34:19 eilers | ||
40 | * Patches from Zecke: | ||
41 | * Fixing and cleaning up extraMap handling | ||
42 | * Adding d_ptr for binary compatibility in the future | ||
43 | * | ||
44 | * Revision 1.6 2003/04/13 18:07:10 zecke | ||
45 | * More API doc | ||
46 | * QString -> const QString& | ||
47 | * QString = 0l -> QString::null | ||
48 | * | ||
49 | * Revision 1.5 2003/02/21 23:31:52 zecke | ||
50 | * Add XML datebookresource | ||
51 | * -clean up todoaccessxml header | ||
52 | * -implement some more stuff in the oeven tester | ||
53 | * -extend DefaultFactory to not crash and to use datebook | ||
54 | * | ||
55 | * -reading of OEvents is working nicely.. saving will be added | ||
56 | * tomorrow | ||
57 | * -fix spelling in ODateBookAcces | ||
58 | * | ||
59 | * Revision 1.4 2002/10/14 15:55:18 eilers | ||
60 | * Redeactivate SQL.. ;) | ||
61 | * | ||
62 | * Revision 1.3 2002/10/10 17:08:58 zecke | ||
63 | * The Cache is finally in place | ||
64 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) | ||
65 | * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster.... | ||
66 | * I still have to fully implement read ahead | ||
67 | * This change is bic but sc | ||
68 | * | ||
69 | * Revision 1.2 2002/10/08 09:27:36 eilers | ||
70 | * Fixed libopie.pro to include the new pim-API. | ||
71 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to | ||
72 | * compile itself would need to install libsqlite, libopiesql... | ||
73 | * Therefore, the backend currently uses XML only.. | ||
74 | * | ||
75 | * Revision 1.1 2002/10/07 17:35:01 eilers | ||
76 | * added OBackendFactory for advanced backend access | ||
77 | * | ||
78 | * | ||
79 | * ===================================================================== | ||
80 | */ | ||
81 | #ifndef OPIE_BACKENDFACTORY_H_ | ||
82 | #define OPIE_BACKENDFACTORY_H_ | ||
83 | |||
84 | #include <qstring.h> | ||
85 | #include <qasciidict.h> | ||
86 | #include <qpe/config.h> | ||
87 | |||
88 | #include "otodoaccessxml.h" | ||
89 | #include "ocontactaccessbackend_xml.h" | ||
90 | #include "odatebookaccessbackend_xml.h" | ||
91 | |||
92 | #ifdef __USE_SQL | ||
93 | #include "otodoaccesssql.h" | ||
94 | #include "ocontactaccessbackend_sql.h" | ||
95 | #include "odatebookaccessbackend_sql.h" | ||
96 | #endif | ||
97 | |||
98 | class OBackendPrivate; | ||
99 | |||
100 | /** | ||
101 | * This class is our factory. It will give us the default implementations | ||
102 | * of at least Todolist, Contacts and Datebook. In the future this class will | ||
103 | * allow users to switch the backend with ( XML->SQLite ) without the need | ||
104 | * to recompile.# | ||
105 | * This class as the whole PIM Api is making use of templates | ||
106 | * | ||
107 | * <pre> | ||
108 | * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); | ||
109 | * backend->load(); | ||
110 | * </pre> | ||
111 | * | ||
112 | * @author Stefan Eilers | ||
113 | * @version 0.1 | ||
114 | */ | ||
115 | template<class T> | ||
116 | class OBackendFactory | ||
117 | { | ||
118 | public: | ||
119 | OBackendFactory() {}; | ||
120 | |||
121 | enum BACKENDS { | ||
122 | TODO, | ||
123 | CONTACT, | ||
124 | DATE | ||
125 | }; | ||
126 | |||
127 | /** | ||
128 | * Returns a backend implementation for backendName | ||
129 | * @param backendName the type of the backend | ||
130 | * @param appName will be passed on to the backend | ||
131 | */ | ||
132 | static T* Default( const QString backendName, const QString& appName ){ | ||
133 | |||
134 | // __asm__("int3"); | ||
135 | |||
136 | Config config( "pimaccess" ); | ||
137 | config.setGroup ( backendName ); | ||
138 | QString backend = config.readEntry( "usebackend" ); | ||
139 | |||
140 | qWarning("Selected backend for %s is: %s", backendName.latin1(), backend.latin1() ); | ||
141 | |||
142 | QAsciiDict<int> dict ( 3 ); | ||
143 | dict.setAutoDelete ( TRUE ); | ||
144 | |||
145 | dict.insert( "todo", new int (TODO) ); | ||
146 | dict.insert( "contact", new int (CONTACT) ); | ||
147 | dict.insert( "datebook", new int(DATE) ); | ||
148 | |||
149 | int *find = dict[ backendName ]; | ||
150 | if (!find ) return 0; | ||
151 | |||
152 | switch ( *find ){ | ||
153 | case TODO: | ||
154 | #ifdef __USE_SQL | ||
155 | if ( backend == "sql" ) | ||
156 | return (T*) new OTodoAccessBackendSQL(""); | ||
157 | #else | ||
158 | if ( backend == "sql" ) | ||
159 | qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); | ||
160 | #endif | ||
161 | |||
162 | return (T*) new OTodoAccessXML( appName ); | ||
163 | case CONTACT: | ||
164 | #ifdef __USE_SQL | ||
165 | if ( backend == "sql" ) | ||
166 | return (T*) new OContactAccessBackend_SQL(""); | ||
167 | #else | ||
168 | if ( backend == "sql" ) | ||
169 | qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); | ||
170 | #endif | ||
171 | |||
172 | return (T*) new OContactAccessBackend_XML( appName ); | ||
173 | case DATE: | ||
174 | #ifdef __USE_SQL | ||
175 | if ( backend == "sql" ) | ||
176 | return (T*) new ODateBookAccessBackend_SQL(""); | ||
177 | #else | ||
178 | if ( backend == "sql" ) | ||
179 | qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); | ||
180 | #endif | ||
181 | |||
182 | return (T*) new ODateBookAccessBackend_XML( appName ); | ||
183 | default: | ||
184 | return NULL; | ||
185 | } | ||
186 | |||
187 | |||
188 | } | ||
189 | private: | ||
190 | OBackendPrivate* d; | ||
191 | }; | ||
192 | |||
193 | |||
194 | #endif | ||