Diffstat (limited to 'libopie/pim/obackendfactory.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/obackendfactory.h | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h index b796fb8..3a73210 100644 --- a/libopie/pim/obackendfactory.h +++ b/libopie/pim/obackendfactory.h | |||
@@ -1,30 +1,40 @@ | |||
1 | /* | 1 | /* |
2 | * Class to manage Backends. | 2 | * Class to manage Backends. |
3 | * | 3 | * |
4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) | 4 | * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) |
5 | * | 5 | * |
6 | * ===================================================================== | 6 | * ===================================================================== |
7 | *This program is free software; you can redistribute it and/or | 7 | *This program is free software; you can redistribute it and/or |
8 | *modify it under the terms of the GNU Library General Public | 8 | *modify it under the terms of the GNU Library General Public |
9 | * License as published by the Free Software Foundation; | 9 | * License as published by the Free Software Foundation; |
10 | * either version 2 of the License, or (at your option) any later | 10 | * either version 2 of the License, or (at your option) any later |
11 | * version. | 11 | * version. |
12 | * ===================================================================== | 12 | * ===================================================================== |
13 | * ToDo: Use plugins | 13 | * ToDo: Use plugins |
14 | * ===================================================================== | 14 | * ===================================================================== |
15 | * Version: $Id$ | 15 | * Version: $Id$ |
16 | * ===================================================================== | 16 | * ===================================================================== |
17 | * History: | 17 | * History: |
18 | * $Log$ | 18 | * $Log$ |
19 | * Revision 1.5 2003/02/21 23:31:52 zecke | ||
20 | * Add XML datebookresource | ||
21 | * -clean up todoaccessxml header | ||
22 | * -implement some more stuff in the oeven tester | ||
23 | * -extend DefaultFactory to not crash and to use datebook | ||
24 | * | ||
25 | * -reading of OEvents is working nicely.. saving will be added | ||
26 | * tomorrow | ||
27 | * -fix spelling in ODateBookAcces | ||
28 | * | ||
19 | * Revision 1.4 2002/10/14 15:55:18 eilers | 29 | * Revision 1.4 2002/10/14 15:55:18 eilers |
20 | * Redeactivate SQL.. ;) | 30 | * Redeactivate SQL.. ;) |
21 | * | 31 | * |
22 | * Revision 1.3 2002/10/10 17:08:58 zecke | 32 | * Revision 1.3 2002/10/10 17:08:58 zecke |
23 | * The Cache is finally in place | 33 | * The Cache is finally in place |
24 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) | 34 | * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) |
25 | * 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.... | 35 | * 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.... |
26 | * I still have to fully implement read ahead | 36 | * I still have to fully implement read ahead |
27 | * This change is bic but sc | 37 | * This change is bic but sc |
28 | * | 38 | * |
29 | * Revision 1.2 2002/10/08 09:27:36 eilers | 39 | * Revision 1.2 2002/10/08 09:27:36 eilers |
30 | * Fixed libopie.pro to include the new pim-API. | 40 | * Fixed libopie.pro to include the new pim-API. |
@@ -38,76 +48,83 @@ | |||
38 | * | 48 | * |
39 | * ===================================================================== | 49 | * ===================================================================== |
40 | */ | 50 | */ |
41 | #ifndef OPIE_BACKENDFACTORY_H_ | 51 | #ifndef OPIE_BACKENDFACTORY_H_ |
42 | #define OPIE_BACKENDFACTORY_H_ | 52 | #define OPIE_BACKENDFACTORY_H_ |
43 | 53 | ||
44 | #include <qstring.h> | 54 | #include <qstring.h> |
45 | #include <qasciidict.h> | 55 | #include <qasciidict.h> |
46 | #include <qpe/config.h> | 56 | #include <qpe/config.h> |
47 | 57 | ||
48 | #include "otodoaccessxml.h" | 58 | #include "otodoaccessxml.h" |
49 | #include "ocontactaccessbackend_xml.h" | 59 | #include "ocontactaccessbackend_xml.h" |
60 | #include "odatebookaccessbackend_xml.h" | ||
50 | 61 | ||
51 | #ifdef __USE_SQL | 62 | #ifdef __USE_SQL |
52 | #include "otodoaccesssql.h" | 63 | #include "otodoaccesssql.h" |
53 | #endif | 64 | #endif |
54 | 65 | ||
55 | 66 | ||
56 | template<class T> | 67 | template<class T> |
57 | class OBackendFactory | 68 | class OBackendFactory |
58 | { | 69 | { |
59 | public: | 70 | public: |
60 | OBackendFactory() {}; | 71 | OBackendFactory() {}; |
61 | 72 | ||
62 | enum BACKENDS { | 73 | enum BACKENDS { |
63 | TODO, | 74 | TODO, |
64 | CONTACT, | 75 | CONTACT, |
65 | DATE | 76 | DATE |
66 | }; | 77 | }; |
67 | 78 | ||
68 | static T* Default( const QString backendName, const QString& appName ){ | 79 | static T* Default( const QString backendName, const QString& appName ){ |
69 | 80 | ||
70 | // __asm__("int3"); | 81 | // __asm__("int3"); |
71 | 82 | ||
72 | Config config( "pimaccess" ); | 83 | Config config( "pimaccess" ); |
73 | config.setGroup ( backendName ); | 84 | config.setGroup ( backendName ); |
74 | QString backend = config.readEntry( "usebackend" ); | 85 | QString backend = config.readEntry( "usebackend" ); |
75 | 86 | ||
76 | QAsciiDict<int> dict ( 3 ); | 87 | QAsciiDict<int> dict ( 3 ); |
77 | dict.setAutoDelete ( TRUE ); | 88 | dict.setAutoDelete ( TRUE ); |
78 | 89 | ||
79 | dict.insert( "todo", new int (TODO) ); | 90 | dict.insert( "todo", new int (TODO) ); |
80 | dict.insert( "contact", new int (CONTACT) ); | 91 | dict.insert( "contact", new int (CONTACT) ); |
92 | dict.insert( "datebook", new int(DATE) ); | ||
81 | 93 | ||
82 | qWarning ("TODO is: %d", TODO); | 94 | qWarning ("TODO is: %d", TODO); |
83 | qWarning ("CONTACT is: %d", CONTACT); | 95 | qWarning ("CONTACT is: %d", CONTACT); |
84 | 96 | ||
85 | switch ( *dict.take( backendName ) ){ | 97 | int *find = dict[ backendName ]; |
98 | if (!find ) return 0; | ||
99 | |||
100 | switch ( *find ){ | ||
86 | case TODO: | 101 | case TODO: |
87 | #ifdef __USE_SQL | 102 | #ifdef __USE_SQL |
88 | if ( backend == "sql" ) | 103 | if ( backend == "sql" ) |
89 | return (T*) new OTodoAccessBackendSQL(""); | 104 | return (T*) new OTodoAccessBackendSQL(""); |
90 | #else | 105 | #else |
91 | if ( backend == "sql" ) | 106 | if ( backend == "sql" ) |
92 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 107 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
93 | #endif | 108 | #endif |
94 | 109 | ||
95 | return (T*) new OTodoAccessXML( appName ); | 110 | return (T*) new OTodoAccessXML( appName ); |
96 | case CONTACT: | 111 | case CONTACT: |
97 | if ( backend == "sql" ) | 112 | if ( backend == "sql" ) |
98 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 113 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
99 | 114 | ||
100 | return (T*) new OContactAccessBackend_XML( appName ); | 115 | return (T*) new OContactAccessBackend_XML( appName ); |
101 | case DATE: | 116 | case DATE: |
102 | qWarning ("OBackendFactory:: DATE-Backend not implemented!"); | 117 | if ( backend == "sql" ) |
103 | return NULL; | 118 | qWarning("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
119 | |||
120 | return (T*) new ODateBookAccessBackend_XML( appName ); | ||
104 | default: | 121 | default: |
105 | return NULL; | 122 | return NULL; |
106 | } | 123 | } |
107 | 124 | ||
108 | 125 | ||
109 | } | 126 | } |
110 | }; | 127 | }; |
111 | 128 | ||
112 | 129 | ||
113 | #endif | 130 | #endif |