summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp1
-rw-r--r--libopie2/opiepim/core/ocontactaccess.cpp6
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h5
-rw-r--r--libopie2/opiepim/core/odatebookaccess.cpp5
-rw-r--r--libopie2/opiepim/core/odatebookaccess.h6
-rw-r--r--libopie2/opiepim/core/opimaccesstemplate.h28
-rw-r--r--libopie2/opiepim/core/opimtemplatebase.h16
-rw-r--r--libopie2/opiepim/core/otodoaccess.cpp7
-rw-r--r--libopie2/opiepim/core/otodoaccess.h6
9 files changed, 65 insertions, 15 deletions
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index 401a3c1..14207be 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -409,48 +409,49 @@ void OPimContactAccessBackend_SQL::clear ()
409 ClearQuery cle; 409 ClearQuery cle;
410 OSQLResult res = m_driver->query( &cle ); 410 OSQLResult res = m_driver->query( &cle );
411 411
412 reload(); 412 reload();
413} 413}
414 414
415bool OPimContactAccessBackend_SQL::wasChangedExternally() 415bool OPimContactAccessBackend_SQL::wasChangedExternally()
416{ 416{
417 return false; 417 return false;
418} 418}
419 419
420QArray<int> OPimContactAccessBackend_SQL::allRecords() const 420QArray<int> OPimContactAccessBackend_SQL::allRecords() const
421{ 421{
422 422
423 // FIXME: Think about cute handling of changed tables.. 423 // FIXME: Think about cute handling of changed tables..
424 // Thus, we don't have to call update here... 424 // Thus, we don't have to call update here...
425 if ( m_changed ) 425 if ( m_changed )
426 ((OPimContactAccessBackend_SQL*)this)->update(); 426 ((OPimContactAccessBackend_SQL*)this)->update();
427 427
428 return m_uids; 428 return m_uids;
429} 429}
430 430
431bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact ) 431bool OPimContactAccessBackend_SQL::add ( const OPimContact &newcontact )
432{ 432{
433 qDebug("add in contact SQL-Backend");
433 InsertQuery ins( newcontact ); 434 InsertQuery ins( newcontact );
434 OSQLResult res = m_driver->query( &ins ); 435 OSQLResult res = m_driver->query( &ins );
435 436
436 if ( res.state() == OSQLResult::Failure ) 437 if ( res.state() == OSQLResult::Failure )
437 return false; 438 return false;
438 439
439 int c = m_uids.count(); 440 int c = m_uids.count();
440 m_uids.resize( c+1 ); 441 m_uids.resize( c+1 );
441 m_uids[c] = newcontact.uid(); 442 m_uids[c] = newcontact.uid();
442 443
443 return true; 444 return true;
444} 445}
445 446
446 447
447bool OPimContactAccessBackend_SQL::remove ( int uid ) 448bool OPimContactAccessBackend_SQL::remove ( int uid )
448{ 449{
449 RemoveQuery rem( uid ); 450 RemoveQuery rem( uid );
450 OSQLResult res = m_driver->query(&rem ); 451 OSQLResult res = m_driver->query(&rem );
451 452
452 if ( res.state() == OSQLResult::Failure ) 453 if ( res.state() == OSQLResult::Failure )
453 return false; 454 return false;
454 455
455 m_changed = true; 456 m_changed = true;
456 457
diff --git a/libopie2/opiepim/core/ocontactaccess.cpp b/libopie2/opiepim/core/ocontactaccess.cpp
index 4f9b504..67f267f 100644
--- a/libopie2/opiepim/core/ocontactaccess.cpp
+++ b/libopie2/opiepim/core/ocontactaccess.cpp
@@ -31,48 +31,49 @@
31 * ToDo: XML-Backend: Automatic reload if something was changed... 31 * ToDo: XML-Backend: Automatic reload if something was changed...
32 * 32 *
33 * 33 *
34 */ 34 */
35 35
36#include "ocontactaccess.h" 36#include "ocontactaccess.h"
37#include "obackendfactory.h" 37#include "obackendfactory.h"
38 38
39#include <qasciidict.h> 39#include <qasciidict.h>
40#include <qdatetime.h> 40#include <qdatetime.h>
41#include <qfile.h> 41#include <qfile.h>
42#include <qregexp.h> 42#include <qregexp.h>
43#include <qlist.h> 43#include <qlist.h>
44#include <qcopchannel_qws.h> 44#include <qcopchannel_qws.h>
45 45
46//#include <qpe/qcopenvelope_qws.h> 46//#include <qpe/qcopenvelope_qws.h>
47#include <qpe/global.h> 47#include <qpe/global.h>
48 48
49#include <errno.h> 49#include <errno.h>
50#include <fcntl.h> 50#include <fcntl.h>
51#include <unistd.h> 51#include <unistd.h>
52#include <stdlib.h> 52#include <stdlib.h>
53 53
54#include <opie2/ocontactaccessbackend_xml.h> 54#include <opie2/ocontactaccessbackend_xml.h>
55#include <opie2/opimresolver.h>
55 56
56namespace Opie { 57namespace Opie {
57 58
58OPimContactAccess::OPimContactAccess ( const QString appname, const QString , 59OPimContactAccess::OPimContactAccess ( const QString appname, const QString ,
59 OPimContactAccessBackend* end, bool autosync ): 60 OPimContactAccessBackend* end, bool autosync ):
60 OPimAccessTemplate<OPimContact>( end ) 61 OPimAccessTemplate<OPimContact>( end )
61{ 62{
62 /* take care of the backend. If there is no one defined, we 63 /* take care of the backend. If there is no one defined, we
63 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 64 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
64 */ 65 */
65 if( end == 0 ) { 66 if( end == 0 ) {
66 qWarning ("Using BackendFactory !"); 67 qWarning ("Using BackendFactory !");
67 end = OBackendFactory<OPimContactAccessBackend>::Default( "contact", appname ); 68 end = OBackendFactory<OPimContactAccessBackend>::Default( "contact", appname );
68 } 69 }
69 // Set backend locally and in template 70 // Set backend locally and in template
70 m_backEnd = end; 71 m_backEnd = end;
71 OPimAccessTemplate<OPimContact>::setBackEnd (end); 72 OPimAccessTemplate<OPimContact>::setBackEnd (end);
72 73
73 74
74 /* Connect signal of external db change to function */ 75 /* Connect signal of external db change to function */
75 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 76 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
76 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), 77 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)),
77 this, SLOT(copMessage(const QCString&,const QByteArray&)) ); 78 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
78 if ( autosync ){ 79 if ( autosync ){
@@ -128,25 +129,30 @@ OPimRecordList<OPimContact> OPimContactAccess::sorted( bool ascending, int sortO
128} 129}
129 130
130 131
131bool OPimContactAccess::wasChangedExternally()const 132bool OPimContactAccess::wasChangedExternally()const
132{ 133{
133 return ( m_backEnd->wasChangedExternally() ); 134 return ( m_backEnd->wasChangedExternally() );
134} 135}
135 136
136 137
137void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & ) 138void OPimContactAccess::copMessage( const QCString &msg, const QByteArray & )
138{ 139{
139 if ( msg == "addressbookUpdated()" ){ 140 if ( msg == "addressbookUpdated()" ){
140 qWarning ("OPimContactAccess: Received addressbokUpdated()"); 141 qWarning ("OPimContactAccess: Received addressbokUpdated()");
141 emit signalChanged ( this ); 142 emit signalChanged ( this );
142 } else if ( msg == "flush()" ) { 143 } else if ( msg == "flush()" ) {
143 qWarning ("OPimContactAccess: Received flush()"); 144 qWarning ("OPimContactAccess: Received flush()");
144 save (); 145 save ();
145 } else if ( msg == "reload()" ) { 146 } else if ( msg == "reload()" ) {
146 qWarning ("OPimContactAccess: Received reload()"); 147 qWarning ("OPimContactAccess: Received reload()");
147 reload (); 148 reload ();
148 emit signalChanged ( this ); 149 emit signalChanged ( this );
149 } 150 }
150} 151}
151 152
153int OPimContactAccess::rtti() const
154{
155 return OPimResolver::AddressBook;
156}
157
152} 158}
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index cf5333a..4429b6f 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -106,48 +106,53 @@ class OPimContactAccess: public QObject, public OPimAccessTemplate<OPimContact>
106 106
107 /** Return all possible settings. 107 /** Return all possible settings.
108 * @return All settings provided by the current backend 108 * @return All settings provided by the current backend
109 * (i.e.: query_WildCards & query_IgnoreCase) 109 * (i.e.: query_WildCards & query_IgnoreCase)
110 */ 110 */
111 const uint querySettings(); 111 const uint querySettings();
112 112
113 /** Check whether settings are correct. 113 /** Check whether settings are correct.
114 * @return <i>true</i> if the given settings are correct and possible. 114 * @return <i>true</i> if the given settings are correct and possible.
115 */ 115 */
116 bool hasQuerySettings ( int querySettings ) const; 116 bool hasQuerySettings ( int querySettings ) const;
117 117
118 /** 118 /**
119 * if the resource was changed externally. 119 * if the resource was changed externally.
120 * You should use the signal instead of polling possible changes ! 120 * You should use the signal instead of polling possible changes !
121 */ 121 */
122 bool wasChangedExternally()const; 122 bool wasChangedExternally()const;
123 123
124 124
125 /** Save contacts database. 125 /** Save contacts database.
126 * Save is more a "commit". After calling this function, all changes are public available. 126 * Save is more a "commit". After calling this function, all changes are public available.
127 * @return true if successful 127 * @return true if successful
128 */ 128 */
129 bool save(); 129 bool save();
130
131 /**
132 * Return identification of used records
133 */
134 int rtti() const;
130 135
131 signals: 136 signals:
132 /* Signal is emitted if the database was changed. Therefore 137 /* Signal is emitted if the database was changed. Therefore
133 * we may need to reload to stay consistent. 138 * we may need to reload to stay consistent.
134 * @param which Pointer to the database who created this event. This pointer 139 * @param which Pointer to the database who created this event. This pointer
135 * is useful if an application has to handle multiple databases at the same time. 140 * is useful if an application has to handle multiple databases at the same time.
136 * @see reload() 141 * @see reload()
137 */ 142 */
138 void signalChanged ( const OPimContactAccess *which ); 143 void signalChanged ( const OPimContactAccess *which );
139 144
140 145
141 private: 146 private:
142 // class OPimContactAccessPrivate; 147 // class OPimContactAccessPrivate;
143 // OPimContactAccessPrivate* d; 148 // OPimContactAccessPrivate* d;
144 OPimContactAccessBackend *m_backEnd; 149 OPimContactAccessBackend *m_backEnd;
145 bool m_loading:1; 150 bool m_loading:1;
146 151
147 private slots: 152 private slots:
148 void copMessage( const QCString &msg, const QByteArray &data ); 153 void copMessage( const QCString &msg, const QByteArray &data );
149 154
150 private: 155 private:
151 class Private; 156 class Private;
152 Private *d; 157 Private *d;
153 158
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp
index ac310c1..29298ea 100644
--- a/libopie2/opiepim/core/odatebookaccess.cpp
+++ b/libopie2/opiepim/core/odatebookaccess.cpp
@@ -7,48 +7,49 @@
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <opie2/obackendfactory.h> 29#include <opie2/obackendfactory.h>
30#include <opie2/odatebookaccess.h> 30#include <opie2/odatebookaccess.h>
31#include <opie2/opimresolver.h>
31 32
32namespace Opie { 33namespace Opie {
33/** 34/**
34 * Simple constructor 35 * Simple constructor
35 * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation 36 * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation
36 * will be used! 37 * will be used!
37 * @param back The backend to be used or 0 for the default backend 38 * @param back The backend to be used or 0 for the default backend
38 * @param ac What kind of access is intended 39 * @param ac What kind of access is intended
39 */ 40 */
40ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac ) 41ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
41 : OPimAccessTemplate<OPimEvent>( back ) 42 : OPimAccessTemplate<OPimEvent>( back )
42{ 43{
43 if (!back ) 44 if (!back )
44 back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null ); 45 back = OBackendFactory<ODateBookAccessBackend>::Default("datebook", QString::null );
45 46
46 m_backEnd = back; 47 m_backEnd = back;
47 setBackEnd( m_backEnd ); 48 setBackEnd( m_backEnd );
48} 49}
49ODateBookAccess::~ODateBookAccess() { 50ODateBookAccess::~ODateBookAccess() {
50} 51}
51 52
52/** 53/**
53 * @return all events available 54 * @return all events available
54 */ 55 */
@@ -87,26 +88,30 @@ ODateBookAccess::List ODateBookAccess::nonRepeats()const {
87OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const { 88OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) const {
88 return m_backEnd->effectiveEvents( from, to ); 89 return m_backEnd->effectiveEvents( from, to );
89} 90}
90/** 91/**
91 * @return all events at a given datetime 92 * @return all events at a given datetime
92 */ 93 */
93OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const { 94OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) const {
94 return m_backEnd->effectiveEvents( start ); 95 return m_backEnd->effectiveEvents( start );
95} 96}
96 97
97/** 98/**
98 * @return non repeating dates in the time span between from and to 99 * @return non repeating dates in the time span between from and to
99 * @param from Include all events from... 100 * @param from Include all events from...
100 * @param to Include all events to... 101 * @param to Include all events to...
101 */ 102 */
102OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const { 103OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const {
103 return m_backEnd->effectiveNonRepeatingEvents( from, to ); 104 return m_backEnd->effectiveNonRepeatingEvents( from, to );
104} 105}
105/** 106/**
106 * @return all non repeating events at a given datetime 107 * @return all non repeating events at a given datetime
107 */ 108 */
108OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const { 109OEffectiveEvent::ValueList ODateBookAccess::effectiveNonRepeatingEvents( const QDateTime& start ) const {
109 return m_backEnd->effectiveNonRepeatingEvents( start ); 110 return m_backEnd->effectiveNonRepeatingEvents( start );
110} 111}
112int ODateBookAccess::rtti() const
113{
114 return OPimResolver::DateBook;
115}
111 116
112} 117}
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h
index 6c9290f..c6c3598 100644
--- a/libopie2/opiepim/core/odatebookaccess.h
+++ b/libopie2/opiepim/core/odatebookaccess.h
@@ -43,33 +43,39 @@ namespace Opie {
43 * destructing and creating the object 43 * destructing and creating the object
44 * 44 *
45 * @author Holger Freyther, Stefan Eilers 45 * @author Holger Freyther, Stefan Eilers
46 */ 46 */
47class ODateBookAccess : public OPimAccessTemplate<OPimEvent> { 47class ODateBookAccess : public OPimAccessTemplate<OPimEvent> {
48public: 48public:
49 ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random ); 49 ODateBookAccess( ODateBookAccessBackend* = 0l, enum Access acc = Random );
50 ~ODateBookAccess(); 50 ~ODateBookAccess();
51 51
52 /* return all events */ 52 /* return all events */
53 List rawEvents()const; 53 List rawEvents()const;
54 54
55 /* return repeating events */ 55 /* return repeating events */
56 List rawRepeats()const; 56 List rawRepeats()const;
57 57
58 /* return non repeating events */ 58 /* return non repeating events */
59 List nonRepeats()const; 59 List nonRepeats()const;
60 60
61 /* return non repeating events (from,to) */ 61 /* return non repeating events (from,to) */
62 OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const; 62 OEffectiveEvent::ValueList effectiveEvents( const QDate& from, const QDate& to ) const;
63 OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const; 63 OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start ) const;
64 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const; 64 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to ) const;
65 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const; 65 OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start ) const;
66 66
67 /**
68 * Return identification of used records
69 */
70 int rtti() const;
71
72
67private: 73private:
68 ODateBookAccessBackend* m_backEnd; 74 ODateBookAccessBackend* m_backEnd;
69 class Private; 75 class Private;
70 Private* d; 76 Private* d;
71}; 77};
72 78
73} 79}
74 80
75#endif 81#endif
diff --git a/libopie2/opiepim/core/opimaccesstemplate.h b/libopie2/opiepim/core/opimaccesstemplate.h
index f1bcc44..d4c5fbb 100644
--- a/libopie2/opiepim/core/opimaccesstemplate.h
+++ b/libopie2/opiepim/core/opimaccesstemplate.h
@@ -1,27 +1,28 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) Holger Freyther <zecke@handhelds.org>
4 Copyright (C) Stefan Eilers <eilers.stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 5 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 6 .=l.
6 .>+-= 7 .>+-=
7 _;:, .> :=|. This program is free software; you can 8 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 9.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 10:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 11.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 12 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 13 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 14 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 15 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 16 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 17 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 18 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 19 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 20..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 21++= -. .` .: details.
21 : = ...= . :.=- 22 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 23 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 24 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 25 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
@@ -116,48 +117,55 @@ public:
116 /** 117 /**
117 * find the OPimRecord uid 118 * find the OPimRecord uid
118 */ 119 */
119 virtual T find( int uid )const; 120 virtual T find( int uid )const;
120 121
121 /** 122 /**
122 * read ahead cache find method ;) 123 * read ahead cache find method ;)
123 */ 124 */
124 virtual T find( int uid, const QArray<int>&, 125 virtual T find( int uid, const QArray<int>&,
125 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const; 126 uint current, typename OTemplateBase<T>::CacheDirection dir = OTemplateBase<T>::Forward )const;
126 127
127 /* invalidate cache here */ 128 /* invalidate cache here */
128 /** 129 /**
129 * clears the backend and invalidates the backend 130 * clears the backend and invalidates the backend
130 */ 131 */
131 void clear() ; 132 void clear() ;
132 133
133 /** 134 /**
134 * add T to the backend 135 * add T to the backend
135 * @param t The item to add. 136 * @param t The item to add.
136 * @return <i>true</i> if added successfully. 137 * @return <i>true</i> if added successfully.
137 */ 138 */
138 virtual bool add( const T& t ) ; 139 virtual bool add( const T& t ) ;
139 bool add( const OPimRecord& ); 140 bool add( const OPimRecord& );
141 // Needed for real generic access (eilers)
142 // Info: Take this if you are working with OPimRecord, which is a generic base class, and
143 // you need to add it into any database, you cannot generate a reference to
144 // it and casting may be not approriate, too.
145 // But take care that the accessing database is compatible to the real type of OPimRecord !!
146 bool add( const OPimRecord* );
147
140 148
141 /* only the uid matters */ 149 /* only the uid matters */
142 /** 150 /**
143 * remove T from the backend 151 * remove T from the backend
144 * @param t The item to remove 152 * @param t The item to remove
145 * @return <i>true</i> if successful. 153 * @return <i>true</i> if successful.
146 */ 154 */
147 virtual bool remove( const T& t ); 155 virtual bool remove( const T& t );
148 156
149 /** 157 /**
150 * remove the OPimRecord with uid 158 * remove the OPimRecord with uid
151 * @param uid The ID of the item to remove 159 * @param uid The ID of the item to remove
152 * @return <i>true</i> if successful. 160 * @return <i>true</i> if successful.
153 */ 161 */
154 bool remove( int uid ); 162 bool remove( int uid );
155 bool remove( const OPimRecord& ); 163 bool remove( const OPimRecord& );
156 164
157 /** 165 /**
158 * replace T from backend 166 * replace T from backend
159 * @param t The item to replace 167 * @param t The item to replace
160 * @return <i>true</i> if successful. 168 * @return <i>true</i> if successful.
161 */ 169 */
162 virtual bool replace( const T& t) ; 170 virtual bool replace( const T& t) ;
163 171
@@ -250,57 +258,71 @@ T OPimAccessTemplate<T>::find( int uid, const QArray<int>& ar,
250 /* 258 /*
251 * better do T.isEmpty() 259 * better do T.isEmpty()
252 * after a find this way we would 260 * after a find this way we would
253 * avoid two finds in QCache... 261 * avoid two finds in QCache...
254 */ 262 */
255 // qWarning("find it now %d", uid ); 263 // qWarning("find it now %d", uid );
256 if (m_cache.contains( uid ) ) { 264 if (m_cache.contains( uid ) ) {
257 return m_cache.find( uid ); 265 return m_cache.find( uid );
258 } 266 }
259 267
260 T t = m_backEnd->find( uid, ar, current, dir ); 268 T t = m_backEnd->find( uid, ar, current, dir );
261 cache( t ); 269 cache( t );
262 return t; 270 return t;
263} 271}
264template <class T> 272template <class T>
265void OPimAccessTemplate<T>::clear() { 273void OPimAccessTemplate<T>::clear() {
266 invalidateCache(); 274 invalidateCache();
267 m_backEnd->clear(); 275 m_backEnd->clear();
268} 276}
269template <class T> 277template <class T>
270bool OPimAccessTemplate<T>::add( const T& t ) { 278bool OPimAccessTemplate<T>::add( const T& t ) {
271 cache( t ); 279 cache( t );
272 return m_backEnd->add( t ); 280 return m_backEnd->add( t );
273} 281}
282
274template <class T> 283template <class T>
275bool OPimAccessTemplate<T>::add( const OPimRecord& rec) { 284bool OPimAccessTemplate<T>::add( const OPimRecord& rec) {
276 /* same type */ 285 /* same type */
277 if ( rec.rtti() == T::rtti() ) { 286 T tempInstance;
278 const T &t = static_cast<const T&>(rec); 287 if ( rec.rtti() == tempInstance.rtti() ) {
288 const T& t = static_cast<const T&>(rec);
279 return add(t); 289 return add(t);
280 } 290 }
281 return false; 291 return false;
282} 292}
293
294template <class T>
295bool OPimAccessTemplate<T>::add( const OPimRecord* rec) {
296 /* same type, but pointer */
297 T tempInstance;
298 if ( rec -> rtti() == tempInstance.rtti() ) {
299 const T* t = static_cast<const T*>(rec);
300 return add( *t );
301 }
302 return false;
303}
304
283template <class T> 305template <class T>
284bool OPimAccessTemplate<T>::remove( const T& t ) { 306bool OPimAccessTemplate<T>::remove( const T& t ) {
285 return remove( t.uid() ); 307 return remove( t.uid() );
286} 308}
287template <class T> 309template <class T>
288bool OPimAccessTemplate<T>::remove( int uid ) { 310bool OPimAccessTemplate<T>::remove( int uid ) {
289 m_cache.remove( uid ); 311 m_cache.remove( uid );
290 return m_backEnd->remove( uid ); 312 return m_backEnd->remove( uid );
291} 313}
292template <class T> 314template <class T>
293bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) { 315bool OPimAccessTemplate<T>::remove( const OPimRecord& rec) {
294 return remove( rec.uid() ); 316 return remove( rec.uid() );
295} 317}
296template <class T> 318template <class T>
297bool OPimAccessTemplate<T>::replace( const T& t ) { 319bool OPimAccessTemplate<T>::replace( const T& t ) {
298 m_cache.replace( t ); 320 m_cache.replace( t );
299 return m_backEnd->replace( t ); 321 return m_backEnd->replace( t );
300} 322}
301template <class T> 323template <class T>
302void OPimAccessTemplate<T>::invalidateCache() { 324void OPimAccessTemplate<T>::invalidateCache() {
303 m_cache.invalidate(); 325 m_cache.invalidate();
304} 326}
305template <class T> 327template <class T>
306typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() { 328typename OPimAccessTemplate<T>::BackEnd* OPimAccessTemplate<T>::backEnd() {
diff --git a/libopie2/opiepim/core/opimtemplatebase.h b/libopie2/opiepim/core/opimtemplatebase.h
index 58cbfeb..b48dfed 100644
--- a/libopie2/opiepim/core/opimtemplatebase.h
+++ b/libopie2/opiepim/core/opimtemplatebase.h
@@ -1,130 +1,122 @@
1/* 1/*
2 This file is part of the Opie Project 2 This file is part of the Opie Project
3 Copyright (C) The Main Author <main-author@whereever.org> 3 Copyright (C) Holger Freyther <zecke@handhelds.org>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org> 4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l. 5 .=l.
6 .>+-= 6 .>+-=
7 _;:, .> :=|. This program is free software; you can 7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#ifndef OTEMPLATEBASE_H 29#ifndef OTEMPLATEBASE_H
30#define OTEMPLATEBASE_H 30#define OTEMPLATEBASE_H
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimrecord.h> 33#include <opie2/opimrecord.h>
34 34
35/* QT */ 35/* QT */
36#include <qarray.h> 36#include <qarray.h>
37 37
38namespace Opie { 38namespace Opie {
39/** 39/**
40 * Templates do not have a base class, This is why 40 * Templates do not have a base class, This is why
41 * we've this class 41 * we've this class
42 * this is here to give us the possibility 42 * this is here to give us the possibility
43 * to have a common base class 43 * to have a common base class
44 * You may not want to use that interface internaly 44 * You may not want to use that interface internaly
45 * POOR mans interface 45 * POOR mans interface
46 */ 46 */
47class OPimBasePrivate; 47class OPimBasePrivate;
48struct OPimBase { 48struct OPimBase {
49 /** 49 /**
50 * return the rtti 50 * return the rtti
51 */ 51 */
52 virtual int rtti()= 0; 52 virtual int rtti() const = 0;
53 virtual OPimRecord* record()const = 0; 53 virtual OPimRecord* record()const = 0;
54 virtual OPimRecord* record(int uid)const = 0; 54 virtual OPimRecord* record(int uid)const = 0;
55 virtual bool add( const OPimRecord& ) = 0; 55 virtual bool add( const OPimRecord& ) = 0;
56 virtual bool add( const OPimRecord* ) = 0;
56 virtual bool remove( int uid ) = 0; 57 virtual bool remove( int uid ) = 0;
57 virtual bool remove( const OPimRecord& ) = 0; 58 virtual bool remove( const OPimRecord& ) = 0;
58 virtual void clear() = 0; 59 virtual void clear() = 0;
59 virtual bool load() = 0; 60 virtual bool load() = 0;
60 virtual bool save() = 0; 61 virtual bool save() = 0;
61 virtual QArray<int> records()const = 0; 62 virtual QArray<int> records()const = 0;
62 /* 63 /*
63 * ADD editing here? 64 * ADD editing here?
64 * -zecke 65 * -zecke
65 */ 66 */
66private: 67private:
67 OPimBasePrivate* d; 68 OPimBasePrivate* d;
68 69
69}; 70};
70/** 71/**
71 * internal template base 72 * internal template base
72 * T needs to implement the copy c'tor!!! 73 * T needs to implement the copy c'tor!!!
73 */ 74 */
74class OTemplateBasePrivate; 75class OTemplateBasePrivate;
75template <class T = OPimRecord> 76template <class T = OPimRecord>
76class OTemplateBase : public OPimBase { 77class OTemplateBase : public OPimBase {
77public: 78public:
78 enum CacheDirection { Forward=0, Reverse }; 79 enum CacheDirection { Forward=0, Reverse };
79 OTemplateBase() { 80 OTemplateBase() {
80 }; 81 };
81 virtual ~OTemplateBase() { 82 virtual ~OTemplateBase() {
82 } 83 }
83 virtual T find( int uid )const = 0; 84 virtual T find( int uid )const = 0;
84 85
85 /** 86 /**
86 * read ahead find 87 * read ahead find
87 */ 88 */
88 virtual T find( int uid, const QArray<int>& items, 89 virtual T find( int uid, const QArray<int>& items,
89 uint current, CacheDirection dir = Forward )const = 0; 90 uint current, CacheDirection dir = Forward )const = 0;
90 virtual void cache( const T& )const = 0; 91 virtual void cache( const T& )const = 0;
91 virtual void setSaneCacheSize( int ) = 0; 92 virtual void setSaneCacheSize( int ) = 0;
92 93
93 /* reimplement of OPimBase */
94 int rtti();
95 OPimRecord* record()const; 94 OPimRecord* record()const;
96 OPimRecord* record(int uid )const; 95 OPimRecord* record(int uid )const;
97 static T* rec(); 96 static T* rec();
98 97
99private: 98private:
100 OTemplateBasePrivate *d; 99 OTemplateBasePrivate *d;
101}; 100};
102 101
103/* 102
104 * implementation
105 */
106template <class T>
107int
108OTemplateBase<T>::rtti() {
109 return T::rtti();
110}
111template <class T> 103template <class T>
112OPimRecord* OTemplateBase<T>::record()const { 104OPimRecord* OTemplateBase<T>::record()const {
113 T* t = new T; 105 T* t = new T;
114 return t; 106 return t;
115} 107}
116template <class T> 108template <class T>
117OPimRecord* OTemplateBase<T>::record(int uid )const { 109OPimRecord* OTemplateBase<T>::record(int uid )const {
118 T t2 = find(uid ); 110 T t2 = find(uid );
119 T* t1 = new T(t2); 111 T* t1 = new T(t2);
120 112
121 return t1; 113 return t1;
122}; 114};
123template <class T> 115template <class T>
124T* OTemplateBase<T>::rec() { 116T* OTemplateBase<T>::rec() {
125 return new T; 117 return new T;
126} 118}
127 119
128} 120}
129 121
130#endif 122#endif
diff --git a/libopie2/opiepim/core/otodoaccess.cpp b/libopie2/opiepim/core/otodoaccess.cpp
index 83750d5..6fa0089 100644
--- a/libopie2/opiepim/core/otodoaccess.cpp
+++ b/libopie2/opiepim/core/otodoaccess.cpp
@@ -12,48 +12,49 @@
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29#include <qdatetime.h> 29#include <qdatetime.h>
30 30
31#include <qpe/alarmserver.h> 31#include <qpe/alarmserver.h>
32 32
33// #include "otodoaccesssql.h" 33// #include "otodoaccesssql.h"
34#include <opie2/otodoaccess.h> 34#include <opie2/otodoaccess.h>
35#include <opie2/obackendfactory.h> 35#include <opie2/obackendfactory.h>
36#include <opie2/opimresolver.h>
36 37
37namespace Opie { 38namespace Opie {
38OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access ) 39OPimTodoAccess::OPimTodoAccess( OPimTodoAccessBackend* end, enum Access )
39 : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end ) 40 : QObject(), OPimAccessTemplate<OPimTodo>( end ), m_todoBackEnd( end )
40{ 41{
41// if (end == 0l ) 42// if (end == 0l )
42// m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null); 43// m_todoBackEnd = new OPimTodoAccessBackendSQL( QString::null);
43 44
44 // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben ! 45 // Zecke: Du musst hier noch fr das XML-Backend einen Appnamen bergeben !
45 if (end == 0l ) 46 if (end == 0l )
46 m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::Default ("todo", QString::null); 47 m_todoBackEnd = OBackendFactory<OPimTodoAccessBackend>::Default ("todo", QString::null);
47 48
48 setBackEnd( m_todoBackEnd ); 49 setBackEnd( m_todoBackEnd );
49} 50}
50OPimTodoAccess::~OPimTodoAccess() { 51OPimTodoAccess::~OPimTodoAccess() {
51// qWarning("~OPimTodoAccess"); 52// qWarning("~OPimTodoAccess");
52} 53}
53void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) { 54void OPimTodoAccess::mergeWith( const QValueList<OPimTodo>& list ) {
54 QValueList<OPimTodo>::ConstIterator it; 55 QValueList<OPimTodo>::ConstIterator it;
55 for ( it = list.begin(); it != list.end(); ++it ) { 56 for ( it = list.begin(); it != list.end(); ++it ) {
56 replace( (*it) ); 57 replace( (*it) );
57 } 58 }
58} 59}
59OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start, 60OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
@@ -69,25 +70,31 @@ OPimTodoAccess::List OPimTodoAccess::effectiveToDos( const QDate& start,
69 return effectiveToDos( start, QDate::currentDate(), 70 return effectiveToDos( start, QDate::currentDate(),
70 includeNoDates ); 71 includeNoDates );
71} 72}
72OPimTodoAccess::List OPimTodoAccess::overDue() { 73OPimTodoAccess::List OPimTodoAccess::overDue() {
73 List lis( m_todoBackEnd->overDue(), this ); 74 List lis( m_todoBackEnd->overDue(), this );
74 return lis; 75 return lis;
75} 76}
76/* sort order */ 77/* sort order */
77OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) { 78OPimTodoAccess::List OPimTodoAccess::sorted( bool ascending, int sort,int filter, int cat ) {
78 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort, 79 QArray<int> ints = m_todoBackEnd->sorted( ascending, sort,
79 filter, cat ); 80 filter, cat );
80 OPimTodoAccess::List list( ints, this ); 81 OPimTodoAccess::List list( ints, this );
81 return list; 82 return list;
82} 83}
83void OPimTodoAccess::removeAllCompleted() { 84void OPimTodoAccess::removeAllCompleted() {
84 m_todoBackEnd->removeAllCompleted(); 85 m_todoBackEnd->removeAllCompleted();
85} 86}
86QBitArray OPimTodoAccess::backendSupport( const QString& ) const{ 87QBitArray OPimTodoAccess::backendSupport( const QString& ) const{
87 return m_todoBackEnd->supports(); 88 return m_todoBackEnd->supports();
88} 89}
89bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{ 90bool OPimTodoAccess::backendSupports( int attr, const QString& ar) const{
90 return backendSupport(ar).testBit( attr ); 91 return backendSupport(ar).testBit( attr );
91} 92}
92 93
94
95int OPimTodoAccess::rtti() const
96{
97 return OPimResolver::TodoList;
98}
99
93} 100}
diff --git a/libopie2/opiepim/core/otodoaccess.h b/libopie2/opiepim/core/otodoaccess.h
index 51f3793..3f5af30 100644
--- a/libopie2/opiepim/core/otodoaccess.h
+++ b/libopie2/opiepim/core/otodoaccess.h
@@ -95,42 +95,48 @@ public:
95 * the resource 95 * the resource
96 */ 96 */
97 void mergeWith( const QValueList<OPimTodo>& ); 97 void mergeWith( const QValueList<OPimTodo>& );
98 98
99 /** 99 /**
100 * delete all already completed items 100 * delete all already completed items
101 */ 101 */
102 void removeAllCompleted(); 102 void removeAllCompleted();
103 103
104 /** 104 /**
105 * request information about what a backend supports. 105 * request information about what a backend supports.
106 * Supports in the sense of beeing able to store. 106 * Supports in the sense of beeing able to store.
107 * This is related to the enum in OPimTodo 107 * This is related to the enum in OPimTodo
108 * 108 *
109 * @param backend Will be used in the future when we support multiple backend 109 * @param backend Will be used in the future when we support multiple backend
110 */ 110 */
111 QBitArray backendSupport( const QString& backend = QString::null )const; 111 QBitArray backendSupport( const QString& backend = QString::null )const;
112 112
113 /** 113 /**
114 * see above but for a specefic attribute. This method was added for convience 114 * see above but for a specefic attribute. This method was added for convience
115 * @param attr The attribute to be queried for 115 * @param attr The attribute to be queried for
116 * @param backend Will be used in the future when we support multiple backends 116 * @param backend Will be used in the future when we support multiple backends
117 */ 117 */
118 bool backendSupports( int attr, const QString& backend = QString::null )const; 118 bool backendSupports( int attr, const QString& backend = QString::null )const;
119
120
121 /**
122 * Return identification of used records
123 */
124 int rtti() const;
119signals: 125signals:
120 /** 126 /**
121 * if the OPimTodoAccess was changed 127 * if the OPimTodoAccess was changed
122 */ 128 */
123 void changed( const OPimTodoAccess* ); 129 void changed( const OPimTodoAccess* );
124 void changed( const OPimTodoAccess*, int uid ); 130 void changed( const OPimTodoAccess*, int uid );
125 void added( const OPimTodoAccess*, int uid ); 131 void added( const OPimTodoAccess*, int uid );
126 void removed( const OPimTodoAccess*, int uid ); 132 void removed( const OPimTodoAccess*, int uid );
127private: 133private:
128 int m_cat; 134 int m_cat;
129 OPimTodoAccessBackend* m_todoBackEnd; 135 OPimTodoAccessBackend* m_todoBackEnd;
130 class OPimTodoAccessPrivate; 136 class OPimTodoAccessPrivate;
131 OPimTodoAccessPrivate* d; 137 OPimTodoAccessPrivate* d;
132}; 138};
133 139
134} 140}
135 141
136#endif 142#endif