summaryrefslogtreecommitdiff
authoreilers <eilers>2004-05-23 17:35:42 (UTC)
committer eilers <eilers>2004-05-23 17:35:42 (UTC)
commiteb5e071463cc2a6b2fa27a486e291da9e8ae01a6 (patch) (unidiff)
tree9d50c3b88921f33dec6d186f6491733480e21f63
parent3025eab185d9e4237c37b4a193fbb20a4dbe504e (diff)
downloadopie-eb5e071463cc2a6b2fa27a486e291da9e8ae01a6.zip
opie-eb5e071463cc2a6b2fa27a486e291da9e8ae01a6.tar.gz
opie-eb5e071463cc2a6b2fa27a486e291da9e8ae01a6.tar.bz2
Make it possible to define the filename of a database via factories..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h6
-rw-r--r--libopie2/opiepim/core/opimaccessfactory.h22
2 files changed, 16 insertions, 12 deletions
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index c8a4627..6f46652 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -67,7 +67,7 @@ class OBackendPrivate;
67 * This class - as the whole PIM Api - is making use of templates 67 * This class - as the whole PIM Api - is making use of templates
68 * 68 *
69 * <pre> 69 * <pre>
70 * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default("todo", QString::null ); 70 * OPimTodoAccessBackend* backend = OBackEndFactory<OPimTodoAccessBackend>::Default( OPimGlobal::TODOLIST, QString::null );
71 * backend->load(); 71 * backend->load();
72 * </pre> 72 * </pre>
73 * 73 *
@@ -86,6 +86,7 @@ class OBackendFactory
86 * @param database the type of the used database 86 * @param database the type of the used database
87 * @param appName The name of your application. It will be passed on to the backend. 87 * @param appName The name of your application. It will be passed on to the backend.
88 * @param filename Filename of the database file if you don't want to access the default 88 * @param filename Filename of the database file if you don't want to access the default
89 * @see OPimGlobal()
89 */ 90 */
90 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database, 91 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle database,
91 const QString& appName, const QString& filename = QString::null ){ 92 const QString& appName, const QString& filename = QString::null ){
@@ -165,7 +166,7 @@ class OBackendFactory
165 /** 166 /**
166 * Returns the style of the default database which is used to contact PIM data. 167 * Returns the style of the default database which is used to contact PIM data.
167 * @param type the type of the backend 168 * @param type the type of the backend
168 * @see OPimGlobal 169 * @see OPimGlobal()
169 */ 170 */
170 static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){ 171 static OPimGlobal::DatabaseStyle defaultDB( OPimGlobal::PimType type ){
171 QString group_name; 172 QString group_name;
@@ -208,6 +209,7 @@ class OBackendFactory
208 * by the configfile "pimaccess.conf". 209 * by the configfile "pimaccess.conf".
209 * @param type The type of the backend (@see OPimGlobal()) 210 * @param type The type of the backend (@see OPimGlobal())
210 * @param appName The name of your application. It will be passed on to the backend 211 * @param appName The name of your application. It will be passed on to the backend
212 * @see OPimGlobal()
211 */ 213 */
212 static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){ 214 static T* defaultBackend( OPimGlobal::PimType type, const QString& appName ){
213 return create( type, OPimGlobal::DEFAULT, appName ); 215 return create( type, OPimGlobal::DEFAULT, appName );
diff --git a/libopie2/opiepim/core/opimaccessfactory.h b/libopie2/opiepim/core/opimaccessfactory.h
index ee55ba5..3cd448e 100644
--- a/libopie2/opiepim/core/opimaccessfactory.h
+++ b/libopie2/opiepim/core/opimaccessfactory.h
@@ -62,10 +62,6 @@ template<class T>
62class OPimAccessFactory 62class OPimAccessFactory
63{ 63{
64 public: 64 public:
65
66 // Maybe we should introduce a global class for storing such global enums
67 // (something like opimglobal.h) ? (eilers)
68
69 OPimAccessFactory() {}; 65 OPimAccessFactory() {};
70 66
71 /** 67 /**
@@ -75,19 +71,25 @@ class OPimAccessFactory
75 * @param appName "Name" of your application. This should be any constant string which is used 71 * @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 72 * by some backends for creating special files (i.e.journal files). Please keep the
77 * string unique for your application ! 73 * string unique for your application !
78 * @see OPimGlobal 74 * @param fileName Filename of database if something different as the default should be used.
75 * @see OPimGlobal()
79 */ 76 */
80 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle dbStyle, const QString& appName ){ 77 static T* create( OPimGlobal::PimType type, OPimGlobal::DatabaseStyle dbStyle, const QString& appName,
78 const QString& fileName = QString::null ){
81 OPimBase *base; 79 OPimBase *base;
82 switch ( type ){ 80 switch ( type ){
83 case OPimGlobal::TODOLIST: 81 case OPimGlobal::TODOLIST:
84 base = new OPimTodoAccess( OBackendFactory<OPimTodoAccessBackend>::create( type, dbStyle, appName ) ); 82 base = new OPimTodoAccess( OBackendFactory<OPimTodoAccessBackend>::create( type, dbStyle,
83 appName, fileName ) );
85 break; 84 break;
86 case OPimGlobal::CONTACTLIST: 85 case OPimGlobal::CONTACTLIST:
87 base = new OPimContactAccess( QString::null, QString::null, OBackendFactory<OPimContactAccessBackend>::create( type, dbStyle, appName ) ); 86 base = new OPimContactAccess( QString::null, QString::null,
87 OBackendFactory<OPimContactAccessBackend>::create( type, dbStyle,
88 appName, fileName ) );
88 break; 89 break;
89 case OPimGlobal::DATEBOOK: 90 case OPimGlobal::DATEBOOK:
90 base = new ODateBookAccess( OBackendFactory<ODateBookAccessBackend>::create( type, dbStyle, appName ) ); 91 base = new ODateBookAccess( OBackendFactory<ODateBookAccessBackend>::create( type, dbStyle,
92 appName, fileName ) );
91 break; 93 break;
92 default: 94 default:
93 return 0l; 95 return 0l;
@@ -104,7 +106,7 @@ class OPimAccessFactory
104 * @param appName "Name" of your application. This should be any constant string which is used 106 * @param appName "Name" of your application. This should be any constant string which is used
105 * by some backends for creating special files (i.e.journal files). Please keep the 107 * by some backends for creating special files (i.e.journal files). Please keep the
106 * string unique for your application ! 108 * string unique for your application !
107 * @see OPimGlobal 109 * @see OPimGlobal()
108 * 110 *
109 */ 111 */
110 static T* defaultAccess( typename OPimGlobal::PimType type, const QString& appName ){ 112 static T* defaultAccess( typename OPimGlobal::PimType type, const QString& appName ){