summaryrefslogtreecommitdiff
authoreilers <eilers>2002-10-07 17:34:24 (UTC)
committer eilers <eilers>2002-10-07 17:34:24 (UTC)
commit0981af024243b314b45ddaf3ebee08bc184f06e2 (patch) (unidiff)
tree578c3057b922911010bfbddc373476e3ae3b32f6
parentab5b7ba61580bfd3aa20297e67bd9fa6b6c90d41 (diff)
downloadopie-0981af024243b314b45ddaf3ebee08bc184f06e2.zip
opie-0981af024243b314b45ddaf3ebee08bc184f06e2.tar.gz
opie-0981af024243b314b45ddaf3ebee08bc184f06e2.tar.bz2
added OBackendFactory for advanced backend access
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/obackendfactory.h88
-rw-r--r--libopie/pim/ocontactaccess.cpp10
-rw-r--r--libopie/pim/ocontactaccessbackend.h4
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.h10
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h88
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h4
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h10
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp10
8 files changed, 220 insertions, 4 deletions
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h
new file mode 100644
index 0000000..599fbf2
--- a/dev/null
+++ b/libopie/pim/obackendfactory.h
@@ -0,0 +1,88 @@
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.1 2002/10/07 17:35:01 eilers
20 * added OBackendFactory for advanced backend access
21 *
22 *
23 * =====================================================================
24 */
25#ifndef __OPIE_BACKENDFACTORY_H_
26#define __OPIE_BACKENDFACTORY_H_
27
28#include <qstring.h>
29#include <qasciidict.h>
30#include <qpe/config.h>
31
32#include "otodoaccessxml.h"
33#include "ocontactaccessbackend_xml.h"
34#include "otodoaccesssql.h"
35
36
37template<class T>
38class OBackendFactory
39{
40 public:
41 OBackendFactory() {};
42
43 enum BACKENDS {
44 TODO,
45 CONTACT,
46 DATE
47 };
48
49 static T* Default( const QString backendName, const QString& appName ){
50
51
52 Config config( "pimaccess" );
53 config.setGroup ( backendName );
54 QString backend = config.readEntry( "usebackend" );
55
56 QAsciiDict<int> dict ( 3 );
57 dict.setAutoDelete ( TRUE );
58
59 dict.insert( "todo", new int (TODO) );
60 dict.insert( "contact", new int (CONTACT) );
61
62 qWarning ("TODO is: %d", TODO);
63 qWarning ("CONTACT is: %d", CONTACT);
64
65 switch ( *dict.take( backendName ) ){
66 case TODO:
67 if ( backend == "sql" )
68 return (T*) new OTodoAccessBackendSQL("");
69
70 return (T*) new OTodoAccessXML( appName );
71 case CONTACT:
72 if ( backend == "sql" )
73 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!");
74
75 return (T*) new OContactAccessBackend_XML( appName );
76 case DATE:
77 qWarning ("OBackendFactory:: DATE-Backend not implemented!");
78 return NULL;
79 default:
80 return NULL;
81 }
82
83
84 }
85};
86
87
88#endif
diff --git a/libopie/pim/ocontactaccess.cpp b/libopie/pim/ocontactaccess.cpp
index 8a8ff08..b5f358b 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/libopie/pim/ocontactaccess.cpp
@@ -1,129 +1,135 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
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; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.3 2002/10/07 17:34:24 eilers
25 * added OBackendFactory for advanced backend access
26 *
24 * Revision 1.2 2002/10/02 16:18:11 eilers 27 * Revision 1.2 2002/10/02 16:18:11 eilers
25 * debugged and seems to work almost perfectly .. 28 * debugged and seems to work almost perfectly ..
26 * 29 *
27 * Revision 1.1 2002/09/27 17:11:44 eilers 30 * Revision 1.1 2002/09/27 17:11:44 eilers
28 * Added API for accessing the Contact-Database ! It is compiling, but 31 * Added API for accessing the Contact-Database ! It is compiling, but
29 * please do not expect that anything is working ! 32 * please do not expect that anything is working !
30 * I will debug that stuff in the next time .. 33 * I will debug that stuff in the next time ..
31 * Please read README_COMPILE for compiling ! 34 * Please read README_COMPILE for compiling !
32 * 35 *
33 * 36 *
34 */ 37 */
35 38
36#include "ocontactaccess.h" 39#include "ocontactaccess.h"
40#include "obackendfactory.h"
37 41
38#include <qasciidict.h> 42#include <qasciidict.h>
39#include <qdatetime.h> 43#include <qdatetime.h>
40#include <qfile.h> 44#include <qfile.h>
41#include <qregexp.h> 45#include <qregexp.h>
42#include <qlist.h> 46#include <qlist.h>
43#include <qcopchannel_qws.h> 47#include <qcopchannel_qws.h>
44 48
45//#include <qpe/qcopenvelope_qws.h> 49//#include <qpe/qcopenvelope_qws.h>
46#include <qpe/global.h> 50#include <qpe/global.h>
47 51
48#include <errno.h> 52#include <errno.h>
49#include <fcntl.h> 53#include <fcntl.h>
50#include <unistd.h> 54#include <unistd.h>
51#include <stdlib.h> 55#include <stdlib.h>
52 56
53#include "ocontactaccessbackend_xml.h" 57#include "ocontactaccessbackend_xml.h"
54 58
55 59
56OContactAccess::OContactAccess ( const QString appname, const QString filename, 60OContactAccess::OContactAccess ( const QString appname, const QString ,
57 OContactAccessBackend* end, bool autosync ): 61 OContactAccessBackend* end, bool autosync ):
58 OPimAccessTemplate<OContact>( end ), 62 OPimAccessTemplate<OContact>( end ),
59 m_changed ( false ) 63 m_changed ( false )
60{ 64{
61 /* take care of the backend. If there is no one defined, we 65 /* take care of the backend. If there is no one defined, we
62 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 66 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
63 */ 67 */
64 if( end == 0 ) { 68 if( end == 0 ) {
65 end = new OContactAccessBackend_XML( appname, filename ); 69 // __asm__("int3");
70 qWarning ("Using BackendFactory !");
71 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
66 } 72 }
67 // Set backend locally and in template 73 // Set backend locally and in template
68 m_backEnd = end; 74 m_backEnd = end;
69 OPimAccessTemplate<OContact>::setBackEnd (end); 75 OPimAccessTemplate<OContact>::setBackEnd (end);
70 76
71 77
72 /* Connect signal of external db change to function */ 78 /* Connect signal of external db change to function */
73 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 79 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
74 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 80 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
75 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 81 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
76 if ( autosync ){ 82 if ( autosync ){
77 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 83 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
78 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 84 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)),
79 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 85 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
80 } 86 }
81 87
82 88
83} 89}
84OContactAccess::~OContactAccess () 90OContactAccess::~OContactAccess ()
85{ 91{
86 /* The user may forget to save the changed database, therefore try to 92 /* The user may forget to save the changed database, therefore try to
87 * do it for him.. 93 * do it for him..
88 */ 94 */
89 if ( m_changed ) 95 if ( m_changed )
90 save(); 96 save();
91 // delete m_backEnd; is done by template.. 97 // delete m_backEnd; is done by template..
92} 98}
93 99
94bool OContactAccess::load() 100bool OContactAccess::load()
95{ 101{
96 return ( m_backEnd->load() ); 102 return ( m_backEnd->load() );
97} 103}
98 104
99bool OContactAccess::save () 105bool OContactAccess::save ()
100{ 106{
101 /* If the database was changed externally, we could not save the 107 /* If the database was changed externally, we could not save the
102 * Data. This will remove added items which is unacceptable ! 108 * Data. This will remove added items which is unacceptable !
103 * Therefore: Reload database and merge the data... 109 * Therefore: Reload database and merge the data...
104 */ 110 */
105 if ( m_backEnd->wasChangedExternally() ) 111 if ( m_backEnd->wasChangedExternally() )
106 reload(); 112 reload();
107 113
108 if ( m_changed ){ 114 if ( m_changed ){
109 bool status = m_backEnd->save(); 115 bool status = m_backEnd->save();
110 if ( !status ) return false; 116 if ( !status ) return false;
111 117
112 m_changed = false; 118 m_changed = false;
113 /* Now tell everyone that new data is available. 119 /* Now tell everyone that new data is available.
114 */ 120 */
115 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 121 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
116 122
117 } 123 }
118 124
119 return true; 125 return true;
120} 126}
121 127
122const uint OContactAccess::querySettings() 128const uint OContactAccess::querySettings()
123{ 129{
124 return ( m_backEnd->querySettings() ); 130 return ( m_backEnd->querySettings() );
125} 131}
126 132
127bool OContactAccess::hasQuerySettings ( int querySettings ) const 133bool OContactAccess::hasQuerySettings ( int querySettings ) const
128{ 134{
129 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 135 return ( m_backEnd->hasQuerySettings ( querySettings ) );
diff --git a/libopie/pim/ocontactaccessbackend.h b/libopie/pim/ocontactaccessbackend.h
index 9469bbc..a651477 100644
--- a/libopie/pim/ocontactaccessbackend.h
+++ b/libopie/pim/ocontactaccessbackend.h
@@ -1,70 +1,74 @@
1/** 1/**
2 * The class responsible for managing a backend. 2 * The class responsible for managing a backend.
3 * The implementation of this abstract class contains 3 * The implementation of this abstract class contains
4 * the complete database handling. 4 * the complete database handling.
5 * 5 *
6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
8 * 8 *
9 * ===================================================================== 9 * =====================================================================
10 *This program is free software; you can redistribute it and/or 10 *This program is free software; you can redistribute it and/or
11 *modify it under the terms of the GNU Library General Public 11 *modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; 12 * License as published by the Free Software Foundation;
13 * either version 2 of the License, or (at your option) any later 13 * either version 2 of the License, or (at your option) any later
14 * version. 14 * version.
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: Define enum for query settings 16 * ToDo: Define enum for query settings
17 * ===================================================================== 17 * =====================================================================
18 * Version: $Id$ 18 * Version: $Id$
19 * ===================================================================== 19 * =====================================================================
20 * History: 20 * History:
21 * $Log$ 21 * $Log$
22 * Revision 1.2 2002/10/07 17:34:24 eilers
23 * added OBackendFactory for advanced backend access
24 *
22 * Revision 1.1 2002/09/27 17:11:44 eilers 25 * Revision 1.1 2002/09/27 17:11:44 eilers
23 * Added API for accessing the Contact-Database ! It is compiling, but 26 * Added API for accessing the Contact-Database ! It is compiling, but
24 * please do not expect that anything is working ! 27 * please do not expect that anything is working !
25 * I will debug that stuff in the next time .. 28 * I will debug that stuff in the next time ..
26 * Please read README_COMPILE for compiling ! 29 * Please read README_COMPILE for compiling !
27 * 30 *
28 * ===================================================================== 31 * =====================================================================
29 * 32 *
30 */ 33 */
31 34
32#ifndef _OCONTACTACCESSBACKEND_H_ 35#ifndef _OCONTACTACCESSBACKEND_H_
33#define _OCONTACTACCESSBACKEND_H_ 36#define _OCONTACTACCESSBACKEND_H_
34 37
38#include "ocontact.h"
35#include "opimaccessbackend.h" 39#include "opimaccessbackend.h"
36 40
37class OContactAccessBackend: public OPimAccessBackend<OContact> { 41class OContactAccessBackend: public OPimAccessBackend<OContact> {
38 public: 42 public:
39 OContactAccessBackend() {} 43 OContactAccessBackend() {}
40 virtual ~OContactAccessBackend() {} 44 virtual ~OContactAccessBackend() {}
41 45
42 46
43 /** Return if database was changed externally. 47 /** Return if database was changed externally.
44 * This may just make sense on file based databases like a XML-File. 48 * This may just make sense on file based databases like a XML-File.
45 * It is used to prevent to overwrite the current database content 49 * It is used to prevent to overwrite the current database content
46 * if the file was already changed by something else ! 50 * if the file was already changed by something else !
47 * If this happens, we have to reload before save our data. 51 * If this happens, we have to reload before save our data.
48 * If we use real databases, this should be handled by the database 52 * If we use real databases, this should be handled by the database
49 * management system themselve, therefore this function should always return false in 53 * management system themselve, therefore this function should always return false in
50 * this case. It is not our problem to handle this conflict ... 54 * this case. It is not our problem to handle this conflict ...
51 * @return <i>true</i> if the database was changed and if save without reload will 55 * @return <i>true</i> if the database was changed and if save without reload will
52 * be dangerous. <i>false</i> if the database was not changed or it is save to write 56 * be dangerous. <i>false</i> if the database was not changed or it is save to write
53 * in this situation. 57 * in this situation.
54 */ 58 */
55 virtual bool wasChangedExternally() = 0; 59 virtual bool wasChangedExternally() = 0;
56 60
57 /** Return all possible settings. 61 /** Return all possible settings.
58 * @return All settings provided by the current backend 62 * @return All settings provided by the current backend
59 * (i.e.: query_WildCards & query_IgnoreCase) 63 * (i.e.: query_WildCards & query_IgnoreCase)
60 */ 64 */
61 virtual const uint querySettings() = 0; 65 virtual const uint querySettings() = 0;
62 66
63 /** Check whether settings are correct. 67 /** Check whether settings are correct.
64 * @return <i>true</i> if the given settings are correct and possible. 68 * @return <i>true</i> if the given settings are correct and possible.
65 */ 69 */
66 virtual bool hasQuerySettings (uint querySettings) const = 0; 70 virtual bool hasQuerySettings (uint querySettings) const = 0;
67 71
68 72
69}; 73};
70#endif 74#endif
diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h
index 2cdb45b..97ef40f 100644
--- a/libopie/pim/ocontactaccessbackend_xml.h
+++ b/libopie/pim/ocontactaccessbackend_xml.h
@@ -1,103 +1,113 @@
1/* 1/*
2 * XML Backend for the OPIE-Contact Database. 2 * XML Backend for the OPIE-Contact Database.
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; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ToDo: XML-Backend: Automatic reload if something was changed... 12 * ToDo: XML-Backend: Automatic reload if something was changed...
13 * 13 *
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.2 2002/10/07 17:34:24 eilers
21 * added OBackendFactory for advanced backend access
22 *
20 * Revision 1.1 2002/09/27 17:11:44 eilers 23 * Revision 1.1 2002/09/27 17:11:44 eilers
21 * Added API for accessing the Contact-Database ! It is compiling, but 24 * Added API for accessing the Contact-Database ! It is compiling, but
22 * please do not expect that anything is working ! 25 * please do not expect that anything is working !
23 * I will debug that stuff in the next time .. 26 * I will debug that stuff in the next time ..
24 * Please read README_COMPILE for compiling ! 27 * Please read README_COMPILE for compiling !
25 * 28 *
26 * 29 *
27 */ 30 */
28 31
29#ifndef _OContactAccessBackend_XML_ 32#ifndef _OContactAccessBackend_XML_
30#define _OContactAccessBackend_XML_ 33#define _OContactAccessBackend_XML_
31 34
32#include <qasciidict.h> 35#include <qasciidict.h>
33#include <qdatetime.h> 36#include <qdatetime.h>
34#include <qfile.h> 37#include <qfile.h>
38#include <qfileinfo.h>
35#include <qregexp.h> 39#include <qregexp.h>
36#include <qarray.h> 40#include <qarray.h>
37 41
42#include <qpe/global.h>
43
38#include <opie/xmltree.h> 44#include <opie/xmltree.h>
39#include "ocontactaccessbackend.h" 45#include "ocontactaccessbackend.h"
46#include "ocontactaccess.h"
47
48#include <stdlib.h>
49#include <errno.h>
40 50
41using namespace Opie; 51using namespace Opie;
42 52
43/* the default xml implementation */ 53/* the default xml implementation */
44class OContactAccessBackend_XML : public OContactAccessBackend { 54class OContactAccessBackend_XML : public OContactAccessBackend {
45 public: 55 public:
46 OContactAccessBackend_XML ( QString appname, QString filename = 0l ) 56 OContactAccessBackend_XML ( QString appname, QString filename = 0l )
47 { 57 {
48 m_appName = appname; 58 m_appName = appname;
49 59
50 /* Set journalfile name ... */ 60 /* Set journalfile name ... */
51 m_journalName = getenv("HOME"); 61 m_journalName = getenv("HOME");
52 m_journalName +="/.abjournal" + appname; 62 m_journalName +="/.abjournal" + appname;
53 63
54 /* Expecting to access the default filename if nothing else is set */ 64 /* Expecting to access the default filename if nothing else is set */
55 if ( filename.isEmpty() ){ 65 if ( filename.isEmpty() ){
56 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); 66 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
57 } else 67 } else
58 m_fileName = filename; 68 m_fileName = filename;
59 69
60 /* Load Database now */ 70 /* Load Database now */
61 load (); 71 load ();
62 } 72 }
63 73
64 bool save() { 74 bool save() {
65 QString strNewFile = m_fileName + ".new"; 75 QString strNewFile = m_fileName + ".new";
66 QFile f( strNewFile ); 76 QFile f( strNewFile );
67 if ( !f.open( IO_WriteOnly|IO_Raw ) ) 77 if ( !f.open( IO_WriteOnly|IO_Raw ) )
68 return false; 78 return false;
69 79
70 int total_written; 80 int total_written;
71 QString out; 81 QString out;
72 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" 82 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
73 " <Groups>\n" 83 " <Groups>\n"
74 " </Groups>\n" 84 " </Groups>\n"
75 " <Contacts>\n"; 85 " <Contacts>\n";
76 //QValueList<Contact>::iterator it; 86 //QValueList<Contact>::iterator it;
77 QValueListConstIterator<OContact> it; 87 QValueListConstIterator<OContact> it;
78 for ( it = m_contactList.begin(); it != m_contactList.end(); ++it ) { 88 for ( it = m_contactList.begin(); it != m_contactList.end(); ++it ) {
79 out += "<Contact "; 89 out += "<Contact ";
80 (*it).save( out ); 90 (*it).save( out );
81 out += "/>\n"; 91 out += "/>\n";
82 QCString cstr = out.utf8(); 92 QCString cstr = out.utf8();
83 total_written = f.writeBlock( cstr.data(), cstr.length() ); 93 total_written = f.writeBlock( cstr.data(), cstr.length() );
84 if ( total_written != int(cstr.length()) ) { 94 if ( total_written != int(cstr.length()) ) {
85 f.close(); 95 f.close();
86 QFile::remove( strNewFile ); 96 QFile::remove( strNewFile );
87 return false; 97 return false;
88 } 98 }
89 out = ""; 99 out = "";
90 } 100 }
91 out += " </Contacts>\n</AddressBook>\n"; 101 out += " </Contacts>\n</AddressBook>\n";
92 102
93 QCString cstr = out.utf8(); 103 QCString cstr = out.utf8();
94 total_written = f.writeBlock( cstr.data(), cstr.length() ); 104 total_written = f.writeBlock( cstr.data(), cstr.length() );
95 if ( total_written != int( cstr.length() ) ) { 105 if ( total_written != int( cstr.length() ) ) {
96 f.close(); 106 f.close();
97 QFile::remove( strNewFile ); 107 QFile::remove( strNewFile );
98 return false; 108 return false;
99 } 109 }
100 f.close(); 110 f.close();
101 111
102 // move the file over, I'm just going to use the system call 112 // move the file over, I'm just going to use the system call
103 // because, I don't feel like using QDir. 113 // because, I don't feel like using QDir.
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
new file mode 100644
index 0000000..599fbf2
--- a/dev/null
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -0,0 +1,88 @@
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.1 2002/10/07 17:35:01 eilers
20 * added OBackendFactory for advanced backend access
21 *
22 *
23 * =====================================================================
24 */
25#ifndef __OPIE_BACKENDFACTORY_H_
26#define __OPIE_BACKENDFACTORY_H_
27
28#include <qstring.h>
29#include <qasciidict.h>
30#include <qpe/config.h>
31
32#include "otodoaccessxml.h"
33#include "ocontactaccessbackend_xml.h"
34#include "otodoaccesssql.h"
35
36
37template<class T>
38class OBackendFactory
39{
40 public:
41 OBackendFactory() {};
42
43 enum BACKENDS {
44 TODO,
45 CONTACT,
46 DATE
47 };
48
49 static T* Default( const QString backendName, const QString& appName ){
50
51
52 Config config( "pimaccess" );
53 config.setGroup ( backendName );
54 QString backend = config.readEntry( "usebackend" );
55
56 QAsciiDict<int> dict ( 3 );
57 dict.setAutoDelete ( TRUE );
58
59 dict.insert( "todo", new int (TODO) );
60 dict.insert( "contact", new int (CONTACT) );
61
62 qWarning ("TODO is: %d", TODO);
63 qWarning ("CONTACT is: %d", CONTACT);
64
65 switch ( *dict.take( backendName ) ){
66 case TODO:
67 if ( backend == "sql" )
68 return (T*) new OTodoAccessBackendSQL("");
69
70 return (T*) new OTodoAccessXML( appName );
71 case CONTACT:
72 if ( backend == "sql" )
73 qWarning ("OBackendFactory:: sql Backend not implemented! Using XML instead!");
74
75 return (T*) new OContactAccessBackend_XML( appName );
76 case DATE:
77 qWarning ("OBackendFactory:: DATE-Backend not implemented!");
78 return NULL;
79 default:
80 return NULL;
81 }
82
83
84 }
85};
86
87
88#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index 9469bbc..a651477 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -1,70 +1,74 @@
1/** 1/**
2 * The class responsible for managing a backend. 2 * The class responsible for managing a backend.
3 * The implementation of this abstract class contains 3 * The implementation of this abstract class contains
4 * the complete database handling. 4 * the complete database handling.
5 * 5 *
6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
8 * 8 *
9 * ===================================================================== 9 * =====================================================================
10 *This program is free software; you can redistribute it and/or 10 *This program is free software; you can redistribute it and/or
11 *modify it under the terms of the GNU Library General Public 11 *modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; 12 * License as published by the Free Software Foundation;
13 * either version 2 of the License, or (at your option) any later 13 * either version 2 of the License, or (at your option) any later
14 * version. 14 * version.
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: Define enum for query settings 16 * ToDo: Define enum for query settings
17 * ===================================================================== 17 * =====================================================================
18 * Version: $Id$ 18 * Version: $Id$
19 * ===================================================================== 19 * =====================================================================
20 * History: 20 * History:
21 * $Log$ 21 * $Log$
22 * Revision 1.2 2002/10/07 17:34:24 eilers
23 * added OBackendFactory for advanced backend access
24 *
22 * Revision 1.1 2002/09/27 17:11:44 eilers 25 * Revision 1.1 2002/09/27 17:11:44 eilers
23 * Added API for accessing the Contact-Database ! It is compiling, but 26 * Added API for accessing the Contact-Database ! It is compiling, but
24 * please do not expect that anything is working ! 27 * please do not expect that anything is working !
25 * I will debug that stuff in the next time .. 28 * I will debug that stuff in the next time ..
26 * Please read README_COMPILE for compiling ! 29 * Please read README_COMPILE for compiling !
27 * 30 *
28 * ===================================================================== 31 * =====================================================================
29 * 32 *
30 */ 33 */
31 34
32#ifndef _OCONTACTACCESSBACKEND_H_ 35#ifndef _OCONTACTACCESSBACKEND_H_
33#define _OCONTACTACCESSBACKEND_H_ 36#define _OCONTACTACCESSBACKEND_H_
34 37
38#include "ocontact.h"
35#include "opimaccessbackend.h" 39#include "opimaccessbackend.h"
36 40
37class OContactAccessBackend: public OPimAccessBackend<OContact> { 41class OContactAccessBackend: public OPimAccessBackend<OContact> {
38 public: 42 public:
39 OContactAccessBackend() {} 43 OContactAccessBackend() {}
40 virtual ~OContactAccessBackend() {} 44 virtual ~OContactAccessBackend() {}
41 45
42 46
43 /** Return if database was changed externally. 47 /** Return if database was changed externally.
44 * This may just make sense on file based databases like a XML-File. 48 * This may just make sense on file based databases like a XML-File.
45 * It is used to prevent to overwrite the current database content 49 * It is used to prevent to overwrite the current database content
46 * if the file was already changed by something else ! 50 * if the file was already changed by something else !
47 * If this happens, we have to reload before save our data. 51 * If this happens, we have to reload before save our data.
48 * If we use real databases, this should be handled by the database 52 * If we use real databases, this should be handled by the database
49 * management system themselve, therefore this function should always return false in 53 * management system themselve, therefore this function should always return false in
50 * this case. It is not our problem to handle this conflict ... 54 * this case. It is not our problem to handle this conflict ...
51 * @return <i>true</i> if the database was changed and if save without reload will 55 * @return <i>true</i> if the database was changed and if save without reload will
52 * be dangerous. <i>false</i> if the database was not changed or it is save to write 56 * be dangerous. <i>false</i> if the database was not changed or it is save to write
53 * in this situation. 57 * in this situation.
54 */ 58 */
55 virtual bool wasChangedExternally() = 0; 59 virtual bool wasChangedExternally() = 0;
56 60
57 /** Return all possible settings. 61 /** Return all possible settings.
58 * @return All settings provided by the current backend 62 * @return All settings provided by the current backend
59 * (i.e.: query_WildCards & query_IgnoreCase) 63 * (i.e.: query_WildCards & query_IgnoreCase)
60 */ 64 */
61 virtual const uint querySettings() = 0; 65 virtual const uint querySettings() = 0;
62 66
63 /** Check whether settings are correct. 67 /** Check whether settings are correct.
64 * @return <i>true</i> if the given settings are correct and possible. 68 * @return <i>true</i> if the given settings are correct and possible.
65 */ 69 */
66 virtual bool hasQuerySettings (uint querySettings) const = 0; 70 virtual bool hasQuerySettings (uint querySettings) const = 0;
67 71
68 72
69}; 73};
70#endif 74#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index 2cdb45b..97ef40f 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
@@ -1,103 +1,113 @@
1/* 1/*
2 * XML Backend for the OPIE-Contact Database. 2 * XML Backend for the OPIE-Contact Database.
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; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ToDo: XML-Backend: Automatic reload if something was changed... 12 * ToDo: XML-Backend: Automatic reload if something was changed...
13 * 13 *
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.2 2002/10/07 17:34:24 eilers
21 * added OBackendFactory for advanced backend access
22 *
20 * Revision 1.1 2002/09/27 17:11:44 eilers 23 * Revision 1.1 2002/09/27 17:11:44 eilers
21 * Added API for accessing the Contact-Database ! It is compiling, but 24 * Added API for accessing the Contact-Database ! It is compiling, but
22 * please do not expect that anything is working ! 25 * please do not expect that anything is working !
23 * I will debug that stuff in the next time .. 26 * I will debug that stuff in the next time ..
24 * Please read README_COMPILE for compiling ! 27 * Please read README_COMPILE for compiling !
25 * 28 *
26 * 29 *
27 */ 30 */
28 31
29#ifndef _OContactAccessBackend_XML_ 32#ifndef _OContactAccessBackend_XML_
30#define _OContactAccessBackend_XML_ 33#define _OContactAccessBackend_XML_
31 34
32#include <qasciidict.h> 35#include <qasciidict.h>
33#include <qdatetime.h> 36#include <qdatetime.h>
34#include <qfile.h> 37#include <qfile.h>
38#include <qfileinfo.h>
35#include <qregexp.h> 39#include <qregexp.h>
36#include <qarray.h> 40#include <qarray.h>
37 41
42#include <qpe/global.h>
43
38#include <opie/xmltree.h> 44#include <opie/xmltree.h>
39#include "ocontactaccessbackend.h" 45#include "ocontactaccessbackend.h"
46#include "ocontactaccess.h"
47
48#include <stdlib.h>
49#include <errno.h>
40 50
41using namespace Opie; 51using namespace Opie;
42 52
43/* the default xml implementation */ 53/* the default xml implementation */
44class OContactAccessBackend_XML : public OContactAccessBackend { 54class OContactAccessBackend_XML : public OContactAccessBackend {
45 public: 55 public:
46 OContactAccessBackend_XML ( QString appname, QString filename = 0l ) 56 OContactAccessBackend_XML ( QString appname, QString filename = 0l )
47 { 57 {
48 m_appName = appname; 58 m_appName = appname;
49 59
50 /* Set journalfile name ... */ 60 /* Set journalfile name ... */
51 m_journalName = getenv("HOME"); 61 m_journalName = getenv("HOME");
52 m_journalName +="/.abjournal" + appname; 62 m_journalName +="/.abjournal" + appname;
53 63
54 /* Expecting to access the default filename if nothing else is set */ 64 /* Expecting to access the default filename if nothing else is set */
55 if ( filename.isEmpty() ){ 65 if ( filename.isEmpty() ){
56 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); 66 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
57 } else 67 } else
58 m_fileName = filename; 68 m_fileName = filename;
59 69
60 /* Load Database now */ 70 /* Load Database now */
61 load (); 71 load ();
62 } 72 }
63 73
64 bool save() { 74 bool save() {
65 QString strNewFile = m_fileName + ".new"; 75 QString strNewFile = m_fileName + ".new";
66 QFile f( strNewFile ); 76 QFile f( strNewFile );
67 if ( !f.open( IO_WriteOnly|IO_Raw ) ) 77 if ( !f.open( IO_WriteOnly|IO_Raw ) )
68 return false; 78 return false;
69 79
70 int total_written; 80 int total_written;
71 QString out; 81 QString out;
72 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" 82 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
73 " <Groups>\n" 83 " <Groups>\n"
74 " </Groups>\n" 84 " </Groups>\n"
75 " <Contacts>\n"; 85 " <Contacts>\n";
76 //QValueList<Contact>::iterator it; 86 //QValueList<Contact>::iterator it;
77 QValueListConstIterator<OContact> it; 87 QValueListConstIterator<OContact> it;
78 for ( it = m_contactList.begin(); it != m_contactList.end(); ++it ) { 88 for ( it = m_contactList.begin(); it != m_contactList.end(); ++it ) {
79 out += "<Contact "; 89 out += "<Contact ";
80 (*it).save( out ); 90 (*it).save( out );
81 out += "/>\n"; 91 out += "/>\n";
82 QCString cstr = out.utf8(); 92 QCString cstr = out.utf8();
83 total_written = f.writeBlock( cstr.data(), cstr.length() ); 93 total_written = f.writeBlock( cstr.data(), cstr.length() );
84 if ( total_written != int(cstr.length()) ) { 94 if ( total_written != int(cstr.length()) ) {
85 f.close(); 95 f.close();
86 QFile::remove( strNewFile ); 96 QFile::remove( strNewFile );
87 return false; 97 return false;
88 } 98 }
89 out = ""; 99 out = "";
90 } 100 }
91 out += " </Contacts>\n</AddressBook>\n"; 101 out += " </Contacts>\n</AddressBook>\n";
92 102
93 QCString cstr = out.utf8(); 103 QCString cstr = out.utf8();
94 total_written = f.writeBlock( cstr.data(), cstr.length() ); 104 total_written = f.writeBlock( cstr.data(), cstr.length() );
95 if ( total_written != int( cstr.length() ) ) { 105 if ( total_written != int( cstr.length() ) ) {
96 f.close(); 106 f.close();
97 QFile::remove( strNewFile ); 107 QFile::remove( strNewFile );
98 return false; 108 return false;
99 } 109 }
100 f.close(); 110 f.close();
101 111
102 // move the file over, I'm just going to use the system call 112 // move the file over, I'm just going to use the system call
103 // because, I don't feel like using QDir. 113 // because, I don't feel like using QDir.
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index 8a8ff08..b5f358b 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -1,129 +1,135 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
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; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.3 2002/10/07 17:34:24 eilers
25 * added OBackendFactory for advanced backend access
26 *
24 * Revision 1.2 2002/10/02 16:18:11 eilers 27 * Revision 1.2 2002/10/02 16:18:11 eilers
25 * debugged and seems to work almost perfectly .. 28 * debugged and seems to work almost perfectly ..
26 * 29 *
27 * Revision 1.1 2002/09/27 17:11:44 eilers 30 * Revision 1.1 2002/09/27 17:11:44 eilers
28 * Added API for accessing the Contact-Database ! It is compiling, but 31 * Added API for accessing the Contact-Database ! It is compiling, but
29 * please do not expect that anything is working ! 32 * please do not expect that anything is working !
30 * I will debug that stuff in the next time .. 33 * I will debug that stuff in the next time ..
31 * Please read README_COMPILE for compiling ! 34 * Please read README_COMPILE for compiling !
32 * 35 *
33 * 36 *
34 */ 37 */
35 38
36#include "ocontactaccess.h" 39#include "ocontactaccess.h"
40#include "obackendfactory.h"
37 41
38#include <qasciidict.h> 42#include <qasciidict.h>
39#include <qdatetime.h> 43#include <qdatetime.h>
40#include <qfile.h> 44#include <qfile.h>
41#include <qregexp.h> 45#include <qregexp.h>
42#include <qlist.h> 46#include <qlist.h>
43#include <qcopchannel_qws.h> 47#include <qcopchannel_qws.h>
44 48
45//#include <qpe/qcopenvelope_qws.h> 49//#include <qpe/qcopenvelope_qws.h>
46#include <qpe/global.h> 50#include <qpe/global.h>
47 51
48#include <errno.h> 52#include <errno.h>
49#include <fcntl.h> 53#include <fcntl.h>
50#include <unistd.h> 54#include <unistd.h>
51#include <stdlib.h> 55#include <stdlib.h>
52 56
53#include "ocontactaccessbackend_xml.h" 57#include "ocontactaccessbackend_xml.h"
54 58
55 59
56OContactAccess::OContactAccess ( const QString appname, const QString filename, 60OContactAccess::OContactAccess ( const QString appname, const QString ,
57 OContactAccessBackend* end, bool autosync ): 61 OContactAccessBackend* end, bool autosync ):
58 OPimAccessTemplate<OContact>( end ), 62 OPimAccessTemplate<OContact>( end ),
59 m_changed ( false ) 63 m_changed ( false )
60{ 64{
61 /* take care of the backend. If there is no one defined, we 65 /* take care of the backend. If there is no one defined, we
62 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 66 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
63 */ 67 */
64 if( end == 0 ) { 68 if( end == 0 ) {
65 end = new OContactAccessBackend_XML( appname, filename ); 69 // __asm__("int3");
70 qWarning ("Using BackendFactory !");
71 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
66 } 72 }
67 // Set backend locally and in template 73 // Set backend locally and in template
68 m_backEnd = end; 74 m_backEnd = end;
69 OPimAccessTemplate<OContact>::setBackEnd (end); 75 OPimAccessTemplate<OContact>::setBackEnd (end);
70 76
71 77
72 /* Connect signal of external db change to function */ 78 /* Connect signal of external db change to function */
73 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 79 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
74 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)), 80 connect( dbchannel, SIGNAL(received(const QCString &, const QByteArray &)),
75 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 81 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
76 if ( autosync ){ 82 if ( autosync ){
77 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 83 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
78 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)), 84 connect( syncchannel, SIGNAL(received(const QCString &, const QByteArray &)),
79 this, SLOT(copMessage( const QCString &, const QByteArray &)) ); 85 this, SLOT(copMessage( const QCString &, const QByteArray &)) );
80 } 86 }
81 87
82 88
83} 89}
84OContactAccess::~OContactAccess () 90OContactAccess::~OContactAccess ()
85{ 91{
86 /* The user may forget to save the changed database, therefore try to 92 /* The user may forget to save the changed database, therefore try to
87 * do it for him.. 93 * do it for him..
88 */ 94 */
89 if ( m_changed ) 95 if ( m_changed )
90 save(); 96 save();
91 // delete m_backEnd; is done by template.. 97 // delete m_backEnd; is done by template..
92} 98}
93 99
94bool OContactAccess::load() 100bool OContactAccess::load()
95{ 101{
96 return ( m_backEnd->load() ); 102 return ( m_backEnd->load() );
97} 103}
98 104
99bool OContactAccess::save () 105bool OContactAccess::save ()
100{ 106{
101 /* If the database was changed externally, we could not save the 107 /* If the database was changed externally, we could not save the
102 * Data. This will remove added items which is unacceptable ! 108 * Data. This will remove added items which is unacceptable !
103 * Therefore: Reload database and merge the data... 109 * Therefore: Reload database and merge the data...
104 */ 110 */
105 if ( m_backEnd->wasChangedExternally() ) 111 if ( m_backEnd->wasChangedExternally() )
106 reload(); 112 reload();
107 113
108 if ( m_changed ){ 114 if ( m_changed ){
109 bool status = m_backEnd->save(); 115 bool status = m_backEnd->save();
110 if ( !status ) return false; 116 if ( !status ) return false;
111 117
112 m_changed = false; 118 m_changed = false;
113 /* Now tell everyone that new data is available. 119 /* Now tell everyone that new data is available.
114 */ 120 */
115 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 121 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
116 122
117 } 123 }
118 124
119 return true; 125 return true;
120} 126}
121 127
122const uint OContactAccess::querySettings() 128const uint OContactAccess::querySettings()
123{ 129{
124 return ( m_backEnd->querySettings() ); 130 return ( m_backEnd->querySettings() );
125} 131}
126 132
127bool OContactAccess::hasQuerySettings ( int querySettings ) const 133bool OContactAccess::hasQuerySettings ( int querySettings ) const
128{ 134{
129 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 135 return ( m_backEnd->hasQuerySettings ( querySettings ) );