author | eilers <eilers> | 2002-10-08 09:27:36 (UTC) |
---|---|---|
committer | eilers <eilers> | 2002-10-08 09:27:36 (UTC) |
commit | 21766cbcf4b4ca84da82a83f1b87d1366e75dd86 (patch) (unidiff) | |
tree | 864f72273936128dd3db596e9e535165bf60a7fd /libopie/pim/obackendfactory.h | |
parent | f4559c166ae156b14a6cae518ede0496e83dad49 (diff) | |
download | opie-21766cbcf4b4ca84da82a83f1b87d1366e75dd86.zip opie-21766cbcf4b4ca84da82a83f1b87d1366e75dd86.tar.gz opie-21766cbcf4b4ca84da82a83f1b87d1366e75dd86.tar.bz2 |
Fixed libopie.pro to include the new pim-API.
The SQL-Stuff is currently deactivated. Otherwise everyone who wants to
compile itself would need to install libsqlite, libopiesql...
Therefore, the backend currently uses XML only..
Diffstat (limited to 'libopie/pim/obackendfactory.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie/pim/obackendfactory.h | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h index 599fbf2..f11f029 100644 --- a/libopie/pim/obackendfactory.h +++ b/libopie/pim/obackendfactory.h | |||
@@ -1,88 +1,101 @@ | |||
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.2 2002/10/08 09:27:36 eilers | ||
20 | * Fixed libopie.pro to include the new pim-API. | ||
21 | * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to | ||
22 | * compile itself would need to install libsqlite, libopiesql... | ||
23 | * Therefore, the backend currently uses XML only.. | ||
24 | * | ||
19 | * Revision 1.1 2002/10/07 17:35:01 eilers | 25 | * Revision 1.1 2002/10/07 17:35:01 eilers |
20 | * added OBackendFactory for advanced backend access | 26 | * added OBackendFactory for advanced backend access |
21 | * | 27 | * |
22 | * | 28 | * |
23 | * ===================================================================== | 29 | * ===================================================================== |
24 | */ | 30 | */ |
25 | #ifndef __OPIE_BACKENDFACTORY_H_ | 31 | #ifndef __OPIE_BACKENDFACTORY_H_ |
26 | #define __OPIE_BACKENDFACTORY_H_ | 32 | #define __OPIE_BACKENDFACTORY_H_ |
27 | 33 | ||
28 | #include <qstring.h> | 34 | #include <qstring.h> |
29 | #include <qasciidict.h> | 35 | #include <qasciidict.h> |
30 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
31 | 37 | ||
32 | #include "otodoaccessxml.h" | 38 | #include "otodoaccessxml.h" |
33 | #include "ocontactaccessbackend_xml.h" | 39 | #include "ocontactaccessbackend_xml.h" |
34 | #include "otodoaccesssql.h" | ||
35 | 40 | ||
41 | #ifdef __USE_SQL | ||
42 | #include "otodoaccesssql.h" | ||
43 | #endif | ||
36 | 44 | ||
37 | template<class T> | 45 | template<class T> |
38 | class OBackendFactory | 46 | class OBackendFactory |
39 | { | 47 | { |
40 | public: | 48 | public: |
41 | OBackendFactory() {}; | 49 | OBackendFactory() {}; |
42 | 50 | ||
43 | enum BACKENDS { | 51 | enum BACKENDS { |
44 | TODO, | 52 | TODO, |
45 | CONTACT, | 53 | CONTACT, |
46 | DATE | 54 | DATE |
47 | }; | 55 | }; |
48 | 56 | ||
49 | static T* Default( const QString backendName, const QString& appName ){ | 57 | static T* Default( const QString backendName, const QString& appName ){ |
50 | 58 | ||
51 | 59 | ||
52 | Config config( "pimaccess" ); | 60 | Config config( "pimaccess" ); |
53 | config.setGroup ( backendName ); | 61 | config.setGroup ( backendName ); |
54 | QString backend = config.readEntry( "usebackend" ); | 62 | QString backend = config.readEntry( "usebackend" ); |
55 | 63 | ||
56 | QAsciiDict<int> dict ( 3 ); | 64 | QAsciiDict<int> dict ( 3 ); |
57 | dict.setAutoDelete ( TRUE ); | 65 | dict.setAutoDelete ( TRUE ); |
58 | 66 | ||
59 | dict.insert( "todo", new int (TODO) ); | 67 | dict.insert( "todo", new int (TODO) ); |
60 | dict.insert( "contact", new int (CONTACT) ); | 68 | dict.insert( "contact", new int (CONTACT) ); |
61 | 69 | ||
62 | qWarning ("TODO is: %d", TODO); | 70 | qWarning ("TODO is: %d", TODO); |
63 | qWarning ("CONTACT is: %d", CONTACT); | 71 | qWarning ("CONTACT is: %d", CONTACT); |
64 | 72 | ||
65 | switch ( *dict.take( backendName ) ){ | 73 | switch ( *dict.take( backendName ) ){ |
66 | case TODO: | 74 | case TODO: |
75 | #ifdef __USE_SQL | ||
67 | if ( backend == "sql" ) | 76 | if ( backend == "sql" ) |
68 | return (T*) new OTodoAccessBackendSQL(""); | 77 | return (T*) new OTodoAccessBackendSQL(""); |
69 | 78 | #else | |
79 | if ( backend == "sql" ) | ||
80 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | ||
81 | #endif | ||
82 | |||
70 | return (T*) new OTodoAccessXML( appName ); | 83 | return (T*) new OTodoAccessXML( appName ); |
71 | case CONTACT: | 84 | case CONTACT: |
72 | if ( backend == "sql" ) | 85 | if ( backend == "sql" ) |
73 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); | 86 | qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!"); |
74 | 87 | ||
75 | return (T*) new OContactAccessBackend_XML( appName ); | 88 | return (T*) new OContactAccessBackend_XML( appName ); |
76 | case DATE: | 89 | case DATE: |
77 | qWarning ("OBackendFactory:: DATE-Backend not implemented!"); | 90 | qWarning ("OBackendFactory:: DATE-Backend not implemented!"); |
78 | return NULL; | 91 | return NULL; |
79 | default: | 92 | default: |
80 | return NULL; | 93 | return NULL; |
81 | } | 94 | } |
82 | 95 | ||
83 | 96 | ||
84 | } | 97 | } |
85 | }; | 98 | }; |
86 | 99 | ||
87 | 100 | ||
88 | #endif | 101 | #endif |