summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/backend
authoralwin <alwin>2004-02-20 02:06:52 (UTC)
committer alwin <alwin>2004-02-20 02:06:52 (UTC)
commit55f4d502486e01927356908223622e435c975f7e (patch) (side-by-side diff)
tree824b5c1e8992564677c4f39473bc108a32a2cf2a /libopie2/opiepim/backend
parent060b4fc7a3fd5c1b5f745167fe084f7486719b7e (diff)
downloadopie-55f4d502486e01927356908223622e435c975f7e.zip
opie-55f4d502486e01927356908223622e435c975f7e.tar.gz
opie-55f4d502486e01927356908223622e435c975f7e.tar.bz2
moved the opie pim stuff to libopie2 - pim. Tried to resort them, may be someone should take a look for a better file order. but now all applications can start using libopiepim2 instead of libopie1-pim-stuff.
Diffstat (limited to 'libopie2/opiepim/backend') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/backend/backends.pro31
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h118
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h82
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp77
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_sql.h62
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp125
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.h77
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp135
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h118
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.cpp38
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h35
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp67
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_sql.h33
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp41
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h33
-rw-r--r--libopie2/opiepim/backend/opimaccessbackend.h36
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.cpp33
-rw-r--r--libopie2/opiepim/backend/otodoaccessbackend.h35
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.cpp41
-rw-r--r--libopie2/opiepim/backend/otodoaccesssql.h34
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.cpp35
-rw-r--r--libopie2/opiepim/backend/otodoaccessvcal.h34
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.cpp45
-rw-r--r--libopie2/opiepim/backend/otodoaccessxml.h33
24 files changed, 815 insertions, 583 deletions
diff --git a/libopie2/opiepim/backend/backends.pro b/libopie2/opiepim/backend/backends.pro
new file mode 100644
index 0000000..4231a00
--- a/dev/null
+++ b/libopie2/opiepim/backend/backends.pro
@@ -0,0 +1,31 @@
+SOURCES += core/backends/ocontactaccessbackend_sql.cpp \
+ core/backends/ocontactaccessbackend_vcard.cpp \
+ core/backends/ocontactaccessbackend_xml.cpp \
+ core/backends/ocontactaccess.cpp \
+ core/backends/odatebookaccessbackend.cpp \
+ core/backends/odatebookaccessbackend_xml.cpp \
+ core/backends/otodoaccessbackend.cpp \
+ core/backends/otodoaccess.cpp \
+ core/backends/otodoaccesssql.cpp \
+ core/backends/otodoaccessvcal.cpp \
+ core/backends/otodoaccessxml.cpp \
+ core/backends/odatebookaccess.cpp \
+ core/backends/odatebookaccessbackend_sql.cpp
+
+HEADERS += core/backends/obackendfactory.h \
+ core/backends/ocontactaccessbackend.h \
+ core/backends/ocontactaccessbackend_sql.h \
+ core/backends/ocontactaccessbackend_vcard.h \
+ core/backends/ocontactaccessbackend_xml.h \
+ core/backends/ocontactaccess.h \
+ core/backends/odatebookaccessbackend.h \
+ core/backends/odatebookaccessbackend_sql.h \
+ core/backends/odatebookaccessbackend_xml.h \
+ core/backends/opimaccessbackend.h \
+ core/backends/opimaccesstemplate.h \
+ core/backends/otodoaccessbackend.h \
+ core/backends/otodoaccess.h \
+ core/backends/otodoaccesssql.h \
+ core/backends/otodoaccessvcal.h \
+ core/backends/otodoaccessxml.h \
+ core/backends/odatebookaccess.h
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index 761ab9a..346e2f5 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -1,121 +1,76 @@
/*
- * Class to manage Backends.
- *
- * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
- *
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation;
- * either version 2 of the License, or (at your option) any later
- * version.
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
* =====================================================================
* ToDo: Use plugins
* =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.9 2003/12/22 10:19:26 eilers
- * Finishing implementation of sql-backend for datebook. But I have to
- * port the PIM datebook application to use it, before I could debug the
- * whole stuff.
- * Thus, PIM-Database backend is finished, but highly experimental. And some
- * parts are still generic. For instance, the "queryByExample()" methods are
- * not (or not fully) implemented. Todo: custom-entries not stored.
- * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
- * expression search in the database, which is not supported by sqlite !
- * Therefore we need either an extended sqlite or a workaround which would
- * be very slow and memory consuming..
- *
- * Revision 1.8 2003/09/22 14:31:16 eilers
- * Added first experimental incarnation of sql-backend for addressbook.
- * Some modifications to be able to compile the todo sql-backend.
- * A lot of changes fill follow...
- *
- * Revision 1.7 2003/08/01 12:30:16 eilers
- * Merging changes from BRANCH_1_0 to HEAD
- *
- * Revision 1.6.4.1 2003/06/30 14:34:19 eilers
- * Patches from Zecke:
- * Fixing and cleaning up extraMap handling
- * Adding d_ptr for binary compatibility in the future
- *
- * Revision 1.6 2003/04/13 18:07:10 zecke
- * More API doc
- * QString -> const QString&
- * QString = 0l -> QString::null
- *
- * Revision 1.5 2003/02/21 23:31:52 zecke
- * Add XML datebookresource
- * -clean up todoaccessxml header
- * -implement some more stuff in the oeven tester
- * -extend DefaultFactory to not crash and to use datebook
- *
- * -reading of OEvents is working nicely.. saving will be added
- * tomorrow
- * -fix spelling in ODateBookAcces
- *
- * Revision 1.4 2002/10/14 15:55:18 eilers
- * Redeactivate SQL.. ;)
- *
- * Revision 1.3 2002/10/10 17:08:58 zecke
- * The Cache is finally in place
- * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;)
- * The read ahead functionality does not make sense for XMLs backends because most of the stuff is already in memory. While using readahead on SQL makes things a lot faster....
- * I still have to fully implement read ahead
- * This change is bic but sc
- *
- * Revision 1.2 2002/10/08 09:27:36 eilers
- * Fixed libopie.pro to include the new pim-API.
- * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to
- * compile itself would need to install libsqlite, libopiesql...
- * Therefore, the backend currently uses XML only..
- *
- * Revision 1.1 2002/10/07 17:35:01 eilers
- * added OBackendFactory for advanced backend access
- *
- *
- * =====================================================================
*/
#ifndef OPIE_BACKENDFACTORY_H_
#define OPIE_BACKENDFACTORY_H_
#include <qstring.h>
#include <qasciidict.h>
#include <qpe/config.h>
-#include "otodoaccessxml.h"
-#include "ocontactaccessbackend_xml.h"
-#include "odatebookaccessbackend_xml.h"
+#include <opie2/otodoaccessxml.h>
+#include <opie2/ocontactaccessbackend_xml.h>
+#include <opie2/odatebookaccessbackend_xml.h>
#ifdef __USE_SQL
-#include "otodoaccesssql.h"
-#include "ocontactaccessbackend_sql.h"
-#include "odatebookaccessbackend_sql.h"
+#include <opie2/otodoaccesssql.h>
+#include <opie2/ocontactaccessbackend_sql.h>
+#include <opie2/odatebookaccessbackend_sql.h>
#endif
+namespace Opie {
+
class OBackendPrivate;
/**
* This class is our factory. It will give us the default implementations
* of at least Todolist, Contacts and Datebook. In the future this class will
* allow users to switch the backend with ( XML->SQLite ) without the need
* to recompile.#
* This class as the whole PIM Api is making use of templates
*
* <pre>
* OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null );
* backend->load();
* </pre>
*
* @author Stefan Eilers
* @version 0.1
*/
template<class T>
class OBackendFactory
{
public:
OBackendFactory() {};
enum BACKENDS {
@@ -169,26 +124,27 @@ class OBackendFactory
qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!");
#endif
return (T*) new OContactAccessBackend_XML( appName );
case DATE:
#ifdef __USE_SQL
if ( backend == "sql" )
return (T*) new ODateBookAccessBackend_SQL("");
#else
if ( backend == "sql" )
qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!");
#endif
return (T*) new ODateBookAccessBackend_XML( appName );
default:
return NULL;
}
}
private:
OBackendPrivate* d;
};
+}
#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index 0eac6dc..6113cea 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -1,88 +1,71 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
/**
* The class responsible for managing a backend.
* The implementation of this abstract class contains
* the complete database handling.
*
* Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
* Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
*
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation;
- * either version 2 of the License, or (at your option) any later
- * version.
- * =====================================================================
- * ToDo: Define enum for query settings
- * =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.7 2004/02/19 02:05:37 zecke
- * Add notes for API fixes and BC stuff
- *
- * Revision 1.6 2003/08/01 12:30:16 eilers
- * Merging changes from BRANCH_1_0 to HEAD
- *
- * Revision 1.5.4.1 2003/06/30 14:34:19 eilers
- * Patches from Zecke:
- * Fixing and cleaning up extraMap handling
- * Adding d_ptr for binary compatibility in the future
- *
- * Revision 1.5 2003/04/13 18:07:10 zecke
- * More API doc
- * QString -> const QString&
- * QString = 0l -> QString::null
- *
- * Revision 1.4 2002/11/13 14:14:51 eilers
- * Added sorted for Contacts..
- *
- * Revision 1.3 2002/11/01 15:10:42 eilers
- * Added regExp-search in database for all fields in a contact.
- *
- * Revision 1.2 2002/10/07 17:34:24 eilers
- * added OBackendFactory for advanced backend access
- *
- * Revision 1.1 2002/09/27 17:11:44 eilers
- * Added API for accessing the Contact-Database ! It is compiling, but
- * please do not expect that anything is working !
- * I will debug that stuff in the next time ..
- * Please read README_COMPILE for compiling !
- *
- * =====================================================================
- *
*/
#ifndef _OCONTACTACCESSBACKEND_H_
#define _OCONTACTACCESSBACKEND_H_
-#include "ocontact.h"
-#include "opimaccessbackend.h"
+#include <opie2/ocontact.h>
+#include <opie2/opimaccessbackend.h>
#include <qregexp.h>
+namespace Opie {
/**
* This class represents the interface of all Contact Backends.
* Derivates of this class will be used to access the contacts.
* As implementation currently XML and vCard exist. This class needs to be implemented
* if you want to provide your own storage.
* In all queries a list of uids is passed on instead of loading the actual record!
*
* @see OContactAccessBackend_VCard
* @see OContactAccessBackend_XML
*/
class OContactAccessBackend: public OPimAccessBackend<OContact> {
public:
/**
* @todo make non line in regard to BC guide of KDE
*/
OContactAccessBackend() {}
/**
* @todo make non inline in regard to the BC guide of KDE
*/
virtual ~OContactAccessBackend() {}
/**
* Return if database was changed externally.
@@ -104,25 +87,28 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
/**
* Return all possible settings.
* @return All settings provided by the current backend
* (i.e.: query_WildCards & query_IgnoreCase)
*/
virtual const uint querySettings() = 0;
/**
* Check whether settings are correct.
* @return <i>true</i> if the given settings are correct and possible.
*/
virtual bool hasQuerySettings (uint querySettings) const = 0;
/**
* FIXME!!!
* Returns a sorted list of records either ascendinf or descending for a giving criteria and category
*/
virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0;
private:
class Private;
Private *d;
};
+
+}
+
#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
index a5be4c8..d0c8052 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.cpp
@@ -1,108 +1,97 @@
/*
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
* SQL Backend for the OPIE-Contact Database.
- *
- * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
- *
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * =====================================================================
- * =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.4 2003/12/22 10:19:26 eilers
- * Finishing implementation of sql-backend for datebook. But I have to
- * port the PIM datebook application to use it, before I could debug the
- * whole stuff.
- * Thus, PIM-Database backend is finished, but highly experimental. And some
- * parts are still generic. For instance, the "queryByExample()" methods are
- * not (or not fully) implemented. Todo: custom-entries not stored.
- * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
- * expression search in the database, which is not supported by sqlite !
- * Therefore we need either an extended sqlite or a workaround which would
- * be very slow and memory consuming..
- *
- * Revision 1.3 2003/12/08 15:18:10 eilers
- * Committing unfinished sql implementation before merging to libopie2 starts..
- *
- * Revision 1.2 2003/09/29 07:44:26 eilers
- * Improvement of PIM-SQL Databases, but search queries are still limited.
- * Addressbook: Changed table layout. Now, we just need 1/3 of disk-space.
- * Todo: Started to add new attributes. Some type conversions missing.
- *
- * Revision 1.1 2003/09/22 14:31:16 eilers
- * Added first experimental incarnation of sql-backend for addressbook.
- * Some modifications to be able to compile the todo sql-backend.
- * A lot of changes fill follow...
- *
*/
#include "ocontactaccessbackend_sql.h"
#include <qarray.h>
#include <qdatetime.h>
#include <qstringlist.h>
#include <qpe/global.h>
#include <qpe/recordfields.h>
-#include <opie/ocontactfields.h>
-#include <opie/oconversion.h>
+#include <opie2/ocontactfields.h>
+#include <opie2/oconversion.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlresult.h>
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead
// vertical like "uid, type, value".
// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !!
#define __STORE_HORIZONTAL_
// Distinct loading is not very fast. If I expect that every person has just
// one (and always one) 'Last Name', I can request all uid's for existing lastnames,
// which is faster..
// But this may not be true for all entries, like company contacts..
// The current AddressBook application handles this problem, but other may not.. (eilers)
#define __USE_SUPERFAST_LOADQUERY
/*
* Implementation of used query types
* CREATE query
* LOAD query
* INSERT
* REMOVE
* CLEAR
*/
-namespace {
+namespace Opie {
/**
* CreateQuery for the Todolist Table
*/
class CreateQuery : public OSQLQuery {
public:
CreateQuery();
~CreateQuery();
QString query()const;
};
/**
* Clears (delete) a Table
*/
class ClearQuery : public OSQLQuery {
public:
ClearQuery();
~ClearQuery();
QString query()const;
};
/**
* LoadQuery
@@ -447,48 +436,50 @@ namespace {
FindCustomQuery::FindCustomQuery(int uid)
: OSQLQuery(), m_uid( uid ) {
}
FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
: OSQLQuery(), m_uids( ints ){
}
FindCustomQuery::~FindCustomQuery() {
}
QString FindCustomQuery::query()const{
// if ( m_uids.count() == 0 )
return single();
}
QString FindCustomQuery::single()const{
QString qu = "select uid, type, value from custom_data where uid = ";
qu += QString::number(m_uid);
return qu;
}
};
/* --------------------------------------------------------------------------- */
+namespace Opie {
+
OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname */,
const QString& filename ):
OContactAccessBackend(), m_changed(false), m_driver( NULL )
{
qWarning("C'tor OContactAccessBackend_SQL starts");
QTime t;
t.start();
/* Expecting to access the default filename if nothing else is set */
if ( filename.isEmpty() ){
m_fileName = Global::applicationFileName( "addressbook","addressbook.db" );
} else
m_fileName = filename;
// Get the standart sql-driver from the OSQLManager..
OSQLManager man;
m_driver = man.standard();
m_driver->setUrl( m_fileName );
load();
qWarning("C'tor OContactAccessBackend_SQL ends: %d ms", t.elapsed() );
}
@@ -919,24 +910,26 @@ QMap<QString, QString> OContactAccessBackend_SQL::requestCustom( int uid ) cons
{
QTime t;
t.start();
QMap<QString, QString> customMap;
FindCustomQuery query( uid );
OSQLResult res_custom = m_driver->query( &query );
if ( res_custom.state() == OSQLResult::Failure ) {
qWarning("OSQLResult::Failure in find query !!");
QMap<QString, QString> empty;
return empty;
}
OSQLResultItem::ValueList list = res_custom.results();
OSQLResultItem::ValueList::Iterator it = list.begin();
for ( ; it != list.end(); ++it ) {
customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
}
qWarning("RequestCustom needed: %d ms", t.elapsed() );
return customMap;
}
+
+}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
index b8f1d8d..55b95fd 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_sql.h
@@ -1,66 +1,72 @@
/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
* SQL Backend for the OPIE-Contact Database.
- *
- * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
- *
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * =====================================================================
- *
- *
- * =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.2 2003/12/08 15:18:11 eilers
- * Committing unfinished sql implementation before merging to libopie2 starts..
- *
- * Revision 1.1 2003/09/22 14:31:16 eilers
- * Added first experimental incarnation of sql-backend for addressbook.
- * Some modifications to be able to compile the todo sql-backend.
- * A lot of changes fill follow...
- *
- *
*/
#ifndef _OContactAccessBackend_SQL_
#define _OContactAccessBackend_SQL_
-#include "ocontactaccessbackend.h"
-#include "ocontactaccess.h"
+#include <opie2/ocontactaccessbackend.h>
+#include <opie2/ocontactaccess.h>
#include <qlist.h>
#include <qdict.h>
+/* aren't in namespace Opie yet - alwin */
class OSQLDriver;
class OSQLResult;
class OSQLResultItem;
+namespace Opie {
+
/* the default xml implementation */
/**
* This class is the SQL implementation of a Contact backend
* it does implement everything available for OContact.
* @see OPimAccessBackend for more information of available methods
*/
class OContactAccessBackend_SQL : public OContactAccessBackend {
public:
OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
~OContactAccessBackend_SQL ();
bool save();
bool load ();
void clear ();
bool wasChangedExternally();
QArray<int> allRecords() const;
OContact find ( int uid ) const;
// FIXME: Add lookahead-cache support !
@@ -77,25 +83,27 @@ class OContactAccessBackend_SQL : public OContactAccessBackend {
// Currently only asc implemented..
QArray<int> sorted( bool asc, int , int , int );
bool add ( const OContact &newcontact );
bool replace ( const OContact &contact );
bool remove ( int uid );
bool reload();
private:
QArray<int> extractUids( OSQLResult& res ) const;
QMap<int, QString> requestNonCustom( int uid ) const;
QMap<QString, QString> requestCustom( int uid ) const;
void update();
protected:
bool m_changed;
QString m_fileName;
QArray<int> m_uids;
OSQLDriver* m_driver;
};
+}
+
#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index b60c5be..f85cf38 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -1,122 +1,65 @@
/*
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
* VCard Backend for the OPIE-Contact Database.
- *
- * Copyright (C) 2000 Trolltech AS. All rights reserved.
- * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
- *
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * =====================================================================
- * ToDo:
- *
- * =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.11 2003/08/01 12:30:16 eilers
- * Merging changes from BRANCH_1_0 to HEAD
- *
- * Revision 1.10.4.3 2003/07/23 08:54:37 eilers
- * Default email was added to the list of all emails, which already contains
- * the default email..
- * This closes bug #1045
- *
- * Revision 1.10.4.2 2003/07/23 08:44:45 eilers
- * Importing of Notes in vcard files wasn't implemented.
- * Closes bug #1044
- *
- * Revision 1.10.4.1 2003/06/02 13:37:49 eilers
- * Fixing memory leak
- *
- * Revision 1.10 2003/04/13 18:07:10 zecke
- * More API doc
- * QString -> const QString&
- * QString = 0l -> QString::null
- *
- * Revision 1.9 2003/03/21 10:33:09 eilers
- * Merged speed optimized xml backend for contacts to main.
- * Added QDateTime to querybyexample. For instance, it is now possible to get
- * all Birthdays/Anniversaries between two dates. This should be used
- * to show all birthdays in the datebook..
- * This change is sourcecode backward compatible but you have to upgrade
- * the binaries for today-addressbook.
- *
- * Revision 1.8 2003/02/21 16:52:49 zecke
- * -Remove old Todo classes they're deprecated and today I already using the
- * new API
- * -Guard against self assignment in OTodo
- * -Add test apps for OPIM
- * -Opiefied Event classes
- * -Added TimeZone handling and pinning of TimeZones to OEvent
- * -Adjust ORecur and the widget to better timezone behaviour
- *
- * Revision 1.7 2003/02/16 22:25:46 zecke
- * 0000276 Fix for that bug.. or better temp workaround
- * A Preferred Number is HOME|VOICE
- * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test
- * triggers both
- * and the cell phone number overrides the other entries..
- *
- * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the
- * number
- *
- * The right and final fix would be to reorder the if statement to make it
- * if else based and the less common thing put to the bottom
- *
- * OTodoAccessVcal fix the date for beaming
- *
- * Revision 1.6 2003/01/13 15:49:31 eilers
- * Fixing crash when businesscard.vcf is missing..
- *
- * Revision 1.5 2002/12/07 13:26:22 eilers
- * Fixing bug in storing anniversary..
- *
- * Revision 1.4 2002/11/13 14:14:51 eilers
- * Added sorted for Contacts..
- *
- * Revision 1.3 2002/11/11 16:41:09 kergoth
- * no default arguments in implementation
- *
- * Revision 1.2 2002/11/10 15:41:53 eilers
- * Bugfixes..
- *
- * Revision 1.1 2002/11/09 14:34:52 eilers
- * Added VCard Backend.
- *
*/
-#include "ocontactaccessbackend_vcard.h"
-#include "../../library/backend/vobject_p.h"
-#include "../../library/backend/qfiledirect_p.h"
+#include <opie2/ocontactaccessbackend_vcard.h>
+#include "../../../../library/backend/vobject_p.h"
+#include "../../../../library/backend/qfiledirect_p.h"
#include <qpe/timeconversion.h>
#include <qfile.h>
+namespace Opie {
+
OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ):
m_dirty( false ),
m_file( filename )
{
load();
}
bool OContactAccessBackend_VCard::load ()
{
m_map.clear();
m_dirty = false;
VObject* obj = 0l;
if ( QFile::exists(m_file) ){
obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
if ( !obj )
return false;
}else{
qWarning("File \"%s\" not found !", m_file.latin1() );
return false;
}
@@ -623,24 +566,26 @@ QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
}
int y = datestr.left( monthPos ).toInt();
int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
int d = datestr.mid( dayPos + sep_ignore ).toInt();
qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
QDate date ( y,m,d );
return date;
}
VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value )
{
VObject *ret = 0;
if ( o && !value.isEmpty() )
ret = addPropValue( o, prop, value.latin1() );
return ret;
}
VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop)
{
VObject *ret = 0;
if ( o )
ret = addProp( o, prop );
return ret;
}
+
+}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
index 712d769..11be027 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
@@ -1,96 +1,85 @@
/*
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
* VCard Backend for the OPIE-Contact Database.
- *
- * Copyright (C) 2000 Trolltech AS. All rights reserved.
- * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
- *
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * =====================================================================
- * ToDo:
- *
- * =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.6 2003/04/13 18:07:10 zecke
- * More API doc
- * QString -> const QString&
- * QString = 0l -> QString::null
- *
- * Revision 1.5 2003/03/21 10:33:09 eilers
- * Merged speed optimized xml backend for contacts to main.
- * Added QDateTime to querybyexample. For instance, it is now possible to get
- * all Birthdays/Anniversaries between two dates. This should be used
- * to show all birthdays in the datebook..
- * This change is sourcecode backward compatible but you have to upgrade
- * the binaries for today-addressbook.
- *
- * Revision 1.4 2002/12/07 13:26:22 eilers
- * Fixing bug in storing anniversary..
- *
- * Revision 1.3 2002/11/13 14:14:51 eilers
- * Added sorted for Contacts..
- *
- * Revision 1.2 2002/11/10 15:41:53 eilers
- * Bugfixes..
- *
- * Revision 1.1 2002/11/09 14:34:52 eilers
- * Added VCard Backend.
- *
*/
#ifndef __OCONTACTACCESSBACKEND_VCARD_H_
#define __OCONTACTACCESSBACKEND_VCARD_H_
-#include <opie/ocontact.h>
+#include <opie2/ocontact.h>
-#include "ocontactaccessbackend.h"
+#include <opie2/ocontactaccessbackend.h>
class VObject;
+namespace Opie {
/**
* This is the vCard 2.1 implementation of the Contact Storage
* @see OContactAccessBackend_XML
* @see OPimAccessBackend
*/
class OContactAccessBackend_VCard : public OContactAccessBackend {
public:
OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null );
bool load ();
bool reload();
bool save();
void clear ();
bool add ( const OContact& newcontact );
bool remove ( int uid );
bool replace ( const OContact& contact );
OContact find ( int uid ) const;
QArray<int> allRecords() const;
QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() );
QArray<int> matchRegexp( const QRegExp &r ) const;
const uint querySettings();
bool hasQuerySettings (uint querySettings) const;
QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat );
bool wasChangedExternally();
private:
OContact parseVObject( VObject* obj );
VObject* createVObject( const OContact& c );
QString convDateToVCardDate( const QDate& c ) const;
QDate convVCardDateToDate( const QString& datestr );
VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value );
VObject *safeAddProp( VObject* o, const char* prop);
bool m_dirty : 1;
QString m_file;
QMap<int, OContact> m_map;
};
+}
+
#endif
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index aae7fca..4c3da0c 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -1,150 +1,80 @@
/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
* XML Backend for the OPIE-Contact Database.
- *
- * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
- *
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * =====================================================================
- *
- * =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.9 2003/09/22 14:31:16 eilers
- * Added first experimental incarnation of sql-backend for addressbook.
- * Some modifications to be able to compile the todo sql-backend.
- * A lot of changes fill follow...
- *
- * Revision 1.8 2003/08/30 15:28:26 eilers
- * Removed some unimportant debug output which causes slow down..
- *
- * Revision 1.7 2003/08/01 12:30:16 eilers
- * Merging changes from BRANCH_1_0 to HEAD
- *
- * Revision 1.6 2003/07/07 16:19:47 eilers
- * Fixing serious bug in hasQuerySettings()
- *
- * Revision 1.5 2003/04/13 18:07:10 zecke
- * More API doc
- * QString -> const QString&
- * QString = 0l -> QString::null
- *
- * Revision 1.4 2003/03/21 14:32:54 mickeyl
- * g++ compliance fix: default arguments belong into the declaration, but not the definition
- *
- * Revision 1.3 2003/03/21 12:26:28 eilers
- * Fixing small bug: If we search a birthday from today to today, it returned
- * every contact ..
- *
- * Revision 1.2 2003/03/21 10:33:09 eilers
- * Merged speed optimized xml backend for contacts to main.
- * Added QDateTime to querybyexample. For instance, it is now possible to get
- * all Birthdays/Anniversaries between two dates. This should be used
- * to show all birthdays in the datebook..
- * This change is sourcecode backward compatible but you have to upgrade
- * the binaries for today-addressbook.
- *
- * Revision 1.1.2.2 2003/02/11 12:17:28 eilers
- * Speed optimization. Removed the sequential search loops.
- *
- * Revision 1.1.2.1 2003/02/10 15:31:38 eilers
- * Writing offsets to debug output..
- *
- * Revision 1.1 2003/02/09 15:05:01 eilers
- * Nothing happened.. Just some cleanup before I will start..
- *
- * Revision 1.12 2003/01/03 16:58:03 eilers
- * Reenable debug output
- *
- * Revision 1.11 2003/01/03 12:31:28 eilers
- * Bugfix for calculating data diffs..
- *
- * Revision 1.10 2003/01/02 14:27:12 eilers
- * Improved query by example: Search by date is possible.. First step
- * for a today plugin for birthdays..
- *
- * Revision 1.9 2002/12/08 12:48:57 eilers
- * Moved journal-enum from ocontact into i the xml-backend..
- *
- * Revision 1.8 2002/11/14 17:04:24 eilers
- * Sorting will now work if fullname is identical on some entries
- *
- * Revision 1.7 2002/11/13 15:02:46 eilers
- * Small Bug in sorted fixed
- *
- * Revision 1.6 2002/11/13 14:14:51 eilers
- * Added sorted for Contacts..
- *
- * Revision 1.5 2002/11/01 15:10:42 eilers
- * Added regExp-search in database for all fields in a contact.
- *
- * Revision 1.4 2002/10/16 10:52:40 eilers
- * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
- *
- * Revision 1.3 2002/10/14 16:21:54 eilers
- * Some minor interface updates
- *
- * Revision 1.2 2002/10/07 17:34:24 eilers
- * added OBackendFactory for advanced backend access
- *
- * Revision 1.1 2002/09/27 17:11:44 eilers
- * Added API for accessing the Contact-Database ! It is compiling, but
- * please do not expect that anything is working !
- * I will debug that stuff in the next time ..
- * Please read README_COMPILE for compiling !
- *
- *
*/
-#include "ocontactaccessbackend_xml.h"
+#include <opie2/ocontactaccessbackend_xml.h>
#include <qasciidict.h>
#include <qdatetime.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qregexp.h>
#include <qarray.h>
#include <qmap.h>
#include <qdatetime.h>
#include <qpe/global.h>
#include <opie/xmltree.h>
-#include "ocontactaccessbackend.h"
-#include "ocontactaccess.h"
+#include <opie2/ocontactaccessbackend.h>
+#include <opie2/ocontactaccess.h>
#include <stdlib.h>
#include <errno.h>
using namespace Opie;
+namespace Opie {
OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ):
m_changed( false )
{
// Just m_contactlist should call delete if an entry
// is removed.
m_contactList.setAutoDelete( true );
m_uidToContact.setAutoDelete( false );
m_appName = appname;
/* Set journalfile name ... */
m_journalName = getenv("HOME");
m_journalName +="/.abjournal" + appname;
/* Expecting to access the default filename if nothing else is set */
if ( filename.isEmpty() ){
m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
} else
m_fileName = filename;
/* Load Database now */
load ();
}
@@ -797,24 +727,25 @@ void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
// if the file was created, we have to set the Tag "<CONTACTS>" to
// get a XML-File which is readable by our parser.
// This is just a cheat, but better than rewrite the parser.
if ( created ){
buf = "<Contacts>";
QCString cstr = buf.utf8();
f.writeBlock( cstr.data(), cstr.length() );
}
buf = "<Contact ";
cnt.save( buf );
buf += " action=\"" + QString::number( (int)action ) + "\" ";
buf += "/>\n";
QCString cstr = buf.utf8();
f.writeBlock( cstr.data(), cstr.length() );
}
void OContactAccessBackend_XML::removeJournal()
{
QFile f ( m_journalName );
if ( f.exists() )
f.remove();
}
+}
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index a0cae4d..f439c4c 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
@@ -1,120 +1,66 @@
/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
* XML Backend for the OPIE-Contact Database.
- *
- * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
- *
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * =====================================================================
- * ToDo: XML-Backend: Automatic reload if something was changed...
- * File Locking to protect against concurrent access
- *
- *
- * =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.15 2003/09/22 14:31:16 eilers
- * Added first experimental incarnation of sql-backend for addressbook.
- * Some modifications to be able to compile the todo sql-backend.
- * A lot of changes fill follow...
- *
- * Revision 1.14 2003/04/13 18:07:10 zecke
- * More API doc
- * QString -> const QString&
- * QString = 0l -> QString::null
- *
- * Revision 1.13 2003/03/21 10:33:09 eilers
- * Merged speed optimized xml backend for contacts to main.
- * Added QDateTime to querybyexample. For instance, it is now possible to get
- * all Birthdays/Anniversaries between two dates. This should be used
- * to show all birthdays in the datebook..
- * This change is sourcecode backward compatible but you have to upgrade
- * the binaries for today-addressbook.
- *
- * Revision 1.12.2.2 2003/02/11 12:17:28 eilers
- * Speed optimization. Removed the sequential search loops.
- *
- * Revision 1.12.2.1 2003/02/09 15:05:01 eilers
- * Nothing happened.. Just some cleanup before I will start..
- *
- * Revision 1.12 2003/01/03 16:58:03 eilers
- * Reenable debug output
- *
- * Revision 1.11 2003/01/03 12:31:28 eilers
- * Bugfix for calculating data diffs..
- *
- * Revision 1.10 2003/01/02 14:27:12 eilers
- * Improved query by example: Search by date is possible.. First step
- * for a today plugin for birthdays..
- *
- * Revision 1.9 2002/12/08 12:48:57 eilers
- * Moved journal-enum from ocontact into i the xml-backend..
- *
- * Revision 1.8 2002/11/14 17:04:24 eilers
- * Sorting will now work if fullname is identical on some entries
- *
- * Revision 1.7 2002/11/13 15:02:46 eilers
- * Small Bug in sorted fixed
- *
- * Revision 1.6 2002/11/13 14:14:51 eilers
- * Added sorted for Contacts..
- *
- * Revision 1.5 2002/11/01 15:10:42 eilers
- * Added regExp-search in database for all fields in a contact.
- *
- * Revision 1.4 2002/10/16 10:52:40 eilers
- * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
- *
- * Revision 1.3 2002/10/14 16:21:54 eilers
- * Some minor interface updates
- *
- * Revision 1.2 2002/10/07 17:34:24 eilers
- * added OBackendFactory for advanced backend access
- *
- * Revision 1.1 2002/09/27 17:11:44 eilers
- * Added API for accessing the Contact-Database ! It is compiling, but
- * please do not expect that anything is working !
- * I will debug that stuff in the next time ..
- * Please read README_COMPILE for compiling !
- *
- *
*/
#ifndef _OContactAccessBackend_XML_
#define _OContactAccessBackend_XML_
-#include "ocontactaccessbackend.h"
-#include "ocontactaccess.h"
+#include <opie2/ocontactaccessbackend.h>
+#include <opie2/ocontactaccess.h>
#include <qlist.h>
#include <qdict.h>
+namespace Opie {
/* the default xml implementation */
/**
* This class is the XML implementation of a Contact backend
* it does implement everything available for OContact.
* @see OPimAccessBackend for more information of available methods
*/
class OContactAccessBackend_XML : public OContactAccessBackend {
public:
OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null );
bool save();
bool load ();
void clear ();
bool wasChangedExternally();
QArray<int> allRecords() const;
OContact find ( int uid ) const;
QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() );
@@ -136,25 +82,27 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
private:
enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
void addContact_p( const OContact &newcontact );
/* This function loads the xml-database and the journalfile */
bool load( const QString filename, bool isJournal );
void updateJournal( const OContact& cnt, journal_action action );
void removeJournal();
protected:
bool m_changed;
QString m_journalName;
QString m_fileName;
QString m_appName;
QList<OContact> m_contactList;
QDateTime m_readtime;
QDict<OContact> m_uidToContact;
};
+}
+
#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.cpp b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
index f0c5d65..9bf4bf0 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.cpp
@@ -1,29 +1,59 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#include <qtl.h>
-#include "orecur.h"
+#include <opie2/orecur.h>
-#include "odatebookaccessbackend.h"
+#include <opie2/odatebookaccessbackend.h>
+
+using namespace Opie;
namespace {
/* a small helper to get all NonRepeating events for a range of time */
void events( OEffectiveEvent::ValueList& tmpList, const OEvent::ValueList& events,
const QDate& from, const QDate& to ) {
QDateTime dtStart, dtEnd;
for ( OEvent::ValueList::ConstIterator it = events.begin(); it != events.end(); ++it ) {
dtStart = (*it).startDateTime();
dtEnd = (*it).endDateTime();
/*
* If in range
*/
if (dtStart.date() >= from && dtEnd.date() <= to ) {
OEffectiveEvent eff;
eff.setEvent( (*it) );
eff.setDate( dtStart.date() );
eff.setStartTime( dtStart.time() );
/* if not on the same day */
if ( dtStart.date() != dtEnd.date() )
eff.setEndTime( QTime(23, 59, 0 ) );
else
@@ -98,48 +128,50 @@ namespace {
OEffectiveEvent tmpEff = eff;
tmpEff.setEvent( (*it) );
if ( sub_it != startDate )
tmpEff.setStartTime( QTime(0, 0, 0 ) );
if ( sub_it != endDate )
tmpEff.setEndTime( QTime( 23, 59, 59 ) );
tmpEff.setDate( sub_it );
tmpEff.setEffectiveDates( startDate, endDate );
tmpList.append( tmpEff );
sub_it = sub_it.addDays( 1 );
}
itDate = endDate;
}else {
eff.setEvent( (*it) );
tmpList.append( eff );
itDate = repeat.addDays( 1 );
}
}
}
}
}
+namespace Opie {
+
ODateBookAccessBackend::ODateBookAccessBackend()
: OPimAccessBackend<OEvent>()
{
}
ODateBookAccessBackend::~ODateBookAccessBackend() {
}
OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDate& from,
const QDate& to ) {
OEffectiveEvent::ValueList tmpList;
OEvent::ValueList list = directNonRepeats();
events( tmpList, list, from, to );
repeat( tmpList, directRawRepeats(),from,to );
list = directRawRepeats(); // Useless, isn't it ? (eilers)
qHeapSort( tmpList );
return tmpList;
}
OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveEvents( const QDateTime& dt ) {
OEffectiveEvent::ValueList day = effectiveEvents( dt.date(), dt.date() );
OEffectiveEvent::ValueList::Iterator it;
@@ -159,24 +191,26 @@ OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents(
const QDate& to ) {
OEffectiveEvent::ValueList tmpList;
OEvent::ValueList list = directNonRepeats();
events( tmpList, list, from, to );
qHeapSort( tmpList );
return tmpList;
}
OEffectiveEvent::ValueList ODateBookAccessBackend::effectiveNonRepeatingEvents( const QDateTime& dt ) {
OEffectiveEvent::ValueList day = effectiveNonRepeatingEvents( dt.date(), dt.date() );
OEffectiveEvent::ValueList::Iterator it;
OEffectiveEvent::ValueList tmpList;
QDateTime dtTmp;
for ( it = day.begin(); it != day.end(); ++it ) {
dtTmp = QDateTime( (*it).date(), (*it).startTime() );
if ( QABS(dt.secsTo(dtTmp) ) < 60 )
tmpList.append( (*it) );
}
return tmpList;
}
+
+}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
index 3472ab3..6853670 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -1,32 +1,61 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_H
#define OPIE_DATE_BOOK_ACCESS_BACKEND_H
#include <qarray.h>
-#include "opimaccessbackend.h"
-#include "oevent.h"
+#include <opie2/opimaccessbackend.h>
+#include <opie2/oevent.h>
+namespace Opie {
/**
* This class is the interface to the storage of Events.
* @see OPimAccessBackend
*
*/
class ODateBookAccessBackend : public OPimAccessBackend<OEvent> {
public:
typedef int UID;
/**
* c'tor without parameter
*/
ODateBookAccessBackend();
~ODateBookAccessBackend();
/**
* This method should return a list of UIDs containing
* all events. No filter should be applied
* @return list of events
*/
virtual QArray<UID> rawEvents()const = 0;
/**
* This method should return a list of UIDs containing
@@ -66,25 +95,27 @@ public:
* this is an overloaded member function
* @see effectiveEvents( const QDate& from, const QDate& to )
*/
virtual OEffectiveEvent::ValueList effectiveEvents( const QDateTime& start );
/**
* Effective Events are special event occuring during a time frame. This method does calcualte
* EffectiveEvents bases on the directNonRepeats and directRawRepeats. You may implement this method
* yourself
*/
virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDate& from, const QDate& to );
/**
* this is an overloaded member function
* @see effectiveNonRepeatingEvents( const QDate& from, const QDate& to )
*/
virtual OEffectiveEvent::ValueList effectiveNonRepeatingEvents( const QDateTime& start );
private:
class Private;
Private *d;
};
+}
+
#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
index 756f405..e79696c 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.cpp
@@ -1,76 +1,73 @@
/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+/*
* SQL Backend for the OPIE-Calender Database.
*
- * Copyright (c) 2003 by Stefan Eilers (Eilers.Stefan@epost.de)
- *
- * =====================================================================
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * =====================================================================
- * =====================================================================
- * Version: $Id$
- * =====================================================================
- * History:
- * $Log$
- * Revision 1.3 2003/12/22 11:41:39 eilers
- * Fixing stupid bug, found by sourcode review..
- *
- * Revision 1.2 2003/12/22 10:19:26 eilers
- * Finishing implementation of sql-backend for datebook. But I have to
- * port the PIM datebook application to use it, before I could debug the
- * whole stuff.
- * Thus, PIM-Database backend is finished, but highly experimental. And some
- * parts are still generic. For instance, the "queryByExample()" methods are
- * not (or not fully) implemented. Todo: custom-entries not stored.
- * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
- * expression search in the database, which is not supported by sqlite !
- * Therefore we need either an extended sqlite or a workaround which would
- * be very slow and memory consuming..
- *
- * Revision 1.1 2003/12/08 15:18:12 eilers
- * Committing unfinished sql implementation before merging to libopie2 starts..
- *
- *
*/
#include <stdio.h>
#include <stdlib.h>
#include <qarray.h>
#include <qstringlist.h>
#include <qpe/global.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
-#include "orecur.h"
-#include "odatebookaccessbackend_sql.h"
+#include <opie2/orecur.h>
+#include <opie2/odatebookaccessbackend_sql.h>
+namespace Opie {
ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
const QString& fileName )
: ODateBookAccessBackend(), m_driver( NULL )
{
m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
// Get the standart sql-driver from the OSQLManager..
OSQLManager man;
m_driver = man.standard();
m_driver->setUrl( m_fileName );
initFields();
load();
}
ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() {
if( m_driver )
delete m_driver;
}
void ODateBookAccessBackend_SQL::initFields()
@@ -344,24 +341,26 @@ QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
}
/* ===== Private Functions ========================================== */
QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const
{
qWarning("extractUids");
QTime t;
t.start();
OSQLResultItem::ValueList list = res.results();
OSQLResultItem::ValueList::Iterator it;
QArray<int> ints(list.count() );
qWarning(" count = %d", list.count() );
int i = 0;
for (it = list.begin(); it != list.end(); ++it ) {
ints[i] = (*it).data("uid").toInt();
i++;
}
qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() );
return ints;
}
+
+}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
index f39e154..89939ef 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_sql.h
@@ -1,34 +1,63 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
#define OPIE_DATE_BOOK_ACCESS_BACKEND_SQL__H
#include <qmap.h>
#include <opie2/osqlresult.h>
-#include "odatebookaccessbackend.h"
+#include <opie2/odatebookaccessbackend.h>
class OSQLDriver;
+namespace Opie {
/**
* This is the default SQL implementation for DateBoook SQL storage
* It fully implements the interface
* @see ODateBookAccessBackend
* @see OPimAccessBackend
*/
class ODateBookAccessBackend_SQL : public ODateBookAccessBackend {
public:
ODateBookAccessBackend_SQL( const QString& appName,
const QString& fileName = QString::null);
~ODateBookAccessBackend_SQL();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
OEvent find( int uid )const;
void clear();
bool add( const OEvent& ev );
bool remove( int uid );
bool replace( const OEvent& ev );
@@ -38,25 +67,27 @@ public:
QArray<UID> nonRepeats()const;
OEvent::ValueList directNonRepeats();
OEvent::ValueList directRawRepeats();
private:
bool loadFile();
QString m_fileName;
QArray<int> m_uids;
QMap<int, QString> m_fieldMap;
QMap<QString, int> m_reverseFieldMap;
OSQLDriver* m_driver;
class Private;
Private *d;
void initFields();
void update();
QArray<int> extractUids( OSQLResult& res ) const;
};
+}
+
#endif
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
index 929d004..0ebda98 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.cpp
@@ -1,47 +1,77 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <unistd.h>
#include <qasciidict.h>
#include <qfile.h>
#include <qtopia/global.h>
#include <qtopia/stringutil.h>
#include <qtopia/timeconversion.h>
-#include "opimnotifymanager.h"
-#include "orecur.h"
-#include "otimezone.h"
-#include "odatebookaccessbackend_xml.h"
+#include <opie2/opimnotifymanager.h>
+#include <opie2/orecur.h>
+#include <opie2/otimezone.h>
+#include <opie2/odatebookaccessbackend_xml.h>
+
+using namespace Opie;
namespace {
// FROM TT again
char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
{
char needleChar;
char haystackChar;
if (!needle || !haystack || !hLen || !nLen)
return 0;
const char* hsearch = haystack;
if ((needleChar = *needle++) != 0) {
nLen--; //(to make up for needle++)
do {
do {
if ((haystackChar = *hsearch++) == 0)
return (0);
if (hsearch >= haystack + hLen)
return (0);
} while (haystackChar != needleChar);
} while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
hsearch--;
}
@@ -145,48 +175,49 @@ namespace {
}
// skip custom writing
}
inline bool forAll( const QMap<int, OEvent>& list, QFile& file ) {
QMap<int, OEvent>::ConstIterator it;
QString buf;
QCString str;
int total_written;
for ( it = list.begin(); it != list.end(); ++it ) {
buf = "<event";
save( it.data(), buf );
buf += " />\n";
str = buf.utf8();
total_written = file.writeBlock(str.data(), str.length() );
if ( total_written != int(str.length() ) )
return false;
}
return true;
}
}
+namespace Opie {
ODateBookAccessBackend_XML::ODateBookAccessBackend_XML( const QString& ,
const QString& fileName )
: ODateBookAccessBackend() {
m_name = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.xml" ) : fileName;
m_changed = false;
}
ODateBookAccessBackend_XML::~ODateBookAccessBackend_XML() {
}
bool ODateBookAccessBackend_XML::load() {
return loadFile();
}
bool ODateBookAccessBackend_XML::reload() {
clear();
return load();
}
bool ODateBookAccessBackend_XML::save() {
if (!m_changed) return true;
int total_written;
QString strFileNew = m_name + ".new";
QFile f( strFileNew );
if (!f.open( IO_WriteOnly | IO_Raw ) ) return false;
@@ -589,24 +620,26 @@ void ODateBookAccessBackend_XML::setField( OEvent& e, int id, const QString& val
e.setTimeZone( value );
break;
default:
break;
}
}
QArray<int> ODateBookAccessBackend_XML::matchRegexp( const QRegExp &r ) const
{
QArray<int> m_currentQuery( m_raw.count()+ m_rep.count() );
uint arraycounter = 0;
QMap<int, OEvent>::ConstIterator it;
for ( it = m_raw.begin(); it != m_raw.end(); ++it )
if ( it.data().match( r ) )
m_currentQuery[arraycounter++] = it.data().uid();
for ( it = m_rep.begin(); it != m_rep.end(); ++it )
if ( it.data().match( r ) )
m_currentQuery[arraycounter++] = it.data().uid();
// Shrink to fit..
m_currentQuery.resize(arraycounter);
return m_currentQuery;
}
+
+}
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index a5cc0fc..29f5f4f 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -1,55 +1,86 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#ifndef OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
#define OPIE_DATE_BOOK_ACCESS_BACKEND_XML__H
#include <qmap.h>
-#include "odatebookaccessbackend.h"
+#include <opie2/odatebookaccessbackend.h>
+namespace Opie {
/**
* This is the default XML implementation for DateBoook XML storage
* It fully implements the interface
* @see ODateBookAccessBackend
* @see OPimAccessBackend
*/
class ODateBookAccessBackend_XML : public ODateBookAccessBackend {
public:
ODateBookAccessBackend_XML( const QString& appName,
const QString& fileName = QString::null);
~ODateBookAccessBackend_XML();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OEvent&, int, const QDateTime& d = QDateTime() );
OEvent find( int uid )const;
void clear();
bool add( const OEvent& ev );
bool remove( int uid );
bool replace( const OEvent& ev );
QArray<UID> rawEvents()const;
QArray<UID> rawRepeats()const;
QArray<UID> nonRepeats()const;
OEvent::ValueList directNonRepeats();
OEvent::ValueList directRawRepeats();
private:
bool m_changed :1 ;
bool loadFile();
inline void finalizeRecord( OEvent& ev );
inline void setField( OEvent&, int field, const QString& val );
QString m_name;
QMap<int, OEvent> m_raw;
QMap<int, OEvent> m_rep;
struct Data;
Data* data;
class Private;
Private *d;
};
+}
+
#endif
diff --git a/libopie2/opiepim/backend/opimaccessbackend.h b/libopie2/opiepim/backend/opimaccessbackend.h
index fd264fc..505358e 100644
--- a/libopie2/opiepim/backend/opimaccessbackend.h
+++ b/libopie2/opiepim/backend/opimaccessbackend.h
@@ -1,34 +1,63 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#ifndef OPIE_PIM_ACCESS_BACKEND
#define OPIE_PIM_ACCESS_BACKEND
#include <qarray.h>
#include <qdatetime.h>
-#include <opie/otemplatebase.h>
-#include <opie/opimrecord.h>
+#include <opie2/otemplatebase.h>
+#include <opie2/opimrecord.h>
+namespace Opie {
class OPimAccessBackendPrivate;
/**
* OPimAccessBackend is the base class
* for all private backends
* it operates on OPimRecord as the base class
* and it's responsible for fast manipulating
* the resource the implementation takes care
* of
*/
template <class T = OPimRecord>
class OPimAccessBackend {
public:
typedef OTemplateBase<T> Frontend;
/** The access hint from the frontend */
OPimAccessBackend(int access = 0);
virtual ~OPimAccessBackend();
/**
* load the resource
*/
virtual bool load() = 0;
/**
@@ -136,25 +165,28 @@ void OPimAccessBackend<T>::cache( const T& t )const {
m_front->cache( t );
}
template <class T>
void OPimAccessBackend<T>::setSaneCacheSize( int size) {
if (m_front )
m_front->setSaneCacheSize( size );
}
template <class T>
T OPimAccessBackend<T>::find( int uid, const QArray<int>&,
uint, typename Frontend::CacheDirection )const {
return find( uid );
}
template <class T>
void OPimAccessBackend<T>::setReadAhead( uint count ) {
m_read = count;
}
template <class T>
uint OPimAccessBackend<T>::readAhead()const {
return m_read;
}
template <class T>
int OPimAccessBackend<T>::access()const {
return m_acc;
}
+
+}
+
#endif
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.cpp b/libopie2/opiepim/backend/otodoaccessbackend.cpp
index baaeecc..d27f5ef 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.cpp
+++ b/libopie2/opiepim/backend/otodoaccessbackend.cpp
@@ -1,10 +1,41 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
-#include "otodoaccessbackend.h"
+#include <opie2/otodoaccessbackend.h>
+namespace Opie {
OTodoAccessBackend::OTodoAccessBackend()
: OPimAccessBackend<OTodo>()
{
}
OTodoAccessBackend::~OTodoAccessBackend() {
}
+
+}
diff --git a/libopie2/opiepim/backend/otodoaccessbackend.h b/libopie2/opiepim/backend/otodoaccessbackend.h
index 6be95bc..54b52cc 100644
--- a/libopie2/opiepim/backend/otodoaccessbackend.h
+++ b/libopie2/opiepim/backend/otodoaccessbackend.h
@@ -1,28 +1,59 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) The Main Author <main-author@whereever.org>
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#ifndef OPIE_TODO_ACCESS_BACKEND_H
#define OPIE_TODO_ACCESS_BACKEND_H
#include <qbitarray.h>
-#include "otodo.h"
-#include "opimaccessbackend.h"
+#include <opie2/otodo.h>
+#include <opie2/opimaccessbackend.h>
+namespace Opie {
class OTodoAccessBackend : public OPimAccessBackend<OTodo> {
public:
OTodoAccessBackend();
~OTodoAccessBackend();
virtual QArray<int> effectiveToDos( const QDate& start,
const QDate& end,
bool includeNoDates ) = 0;
virtual QArray<int> overDue() = 0;
virtual QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
int cat ) = 0;
virtual void removeAllCompleted() = 0;
virtual QBitArray supports()const = 0;
private:
class Private;
Private *d;
};
+}
+
#endif
diff --git a/libopie2/opiepim/backend/otodoaccesssql.cpp b/libopie2/opiepim/backend/otodoaccesssql.cpp
index 3764c7e..944f82a 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.cpp
+++ b/libopie2/opiepim/backend/otodoaccesssql.cpp
@@ -1,39 +1,68 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#include <qdatetime.h>
#include <qpe/global.h>
#include <opie2/osqldriver.h>
#include <opie2/osqlresult.h>
#include <opie2/osqlmanager.h>
#include <opie2/osqlquery.h>
-#include "otodoaccesssql.h"
-#include "opimstate.h"
-#include "opimnotifymanager.h"
-#include "orecur.h"
+#include <opie2/otodoaccesssql.h>
+#include <opie2/opimstate.h>
+#include <opie2/opimnotifymanager.h>
+#include <opie2/orecur.h>
+using namespace Opie;
/*
* first some query
* CREATE query
* LOAD query
* INSERT
* REMOVE
* CLEAR
*/
namespace {
/**
* CreateQuery for the Todolist Table
*/
class CreateQuery : public OSQLQuery {
public:
CreateQuery();
~CreateQuery();
QString query()const;
};
/**
* LoadQuery
* this one queries for all uids
*/
class LoadQuery : public OSQLQuery {
@@ -277,48 +306,50 @@ namespace {
EffQuery::EffQuery( const QDate& start, const QDate& end, bool inc )
: OSQLQuery(), m_start( start ), m_end( end ),m_inc(inc) {}
EffQuery::~EffQuery() {}
QString EffQuery::query()const {
return m_inc ? with() : out();
}
QString EffQuery::with()const {
QString str;
str = QString("select uid from todolist where ( DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6' ) OR DueDate = '0-0-0' ")
.arg( m_start.year() ).arg( m_start.month() ).arg( m_start.day() )
.arg( m_end .year() ).arg( m_end .month() ).arg( m_end .day() );
return str;
}
QString EffQuery::out()const {
QString str;
str = QString("select uid from todolist where DueDate >= '%1-%2-%3' AND DueDate <= '%4-%5-%6'")
.arg(m_start.year() ).arg(m_start.month() ).arg( m_start.day() )
.arg(m_end. year() ).arg(m_end. month() ).arg(m_end.day() );
return str;
}
};
+
+namespace Opie {
OTodoAccessBackendSQL::OTodoAccessBackendSQL( const QString& file )
: OTodoAccessBackend(), m_dict(15), m_driver(NULL), m_dirty(true)
{
QString fi = file;
if ( fi.isEmpty() )
fi = Global::applicationFileName( "todolist", "todolist.db" );
OSQLManager man;
m_driver = man.standard();
m_driver->setUrl(fi);
// fillDict();
}
OTodoAccessBackendSQL::~OTodoAccessBackendSQL(){
if( m_driver )
delete m_driver;
}
bool OTodoAccessBackendSQL::load(){
if (!m_driver->open() )
return false;
CreateQuery creat;
OSQLResult res = m_driver->query(&creat );
@@ -670,24 +701,26 @@ QArray<int> OTodoAccessBackendSQL::matchRegexp( const QRegExp &r ) const
return empty;
}
QBitArray OTodoAccessBackendSQL::supports()const {
return sup();
}
QBitArray OTodoAccessBackendSQL::sup() const{
QBitArray ar( OTodo::CompletedDate + 1 );
ar.fill( true );
ar[OTodo::CrossReference] = false;
ar[OTodo::State ] = false;
ar[OTodo::Reminders] = false;
ar[OTodo::Notifiers] = false;
ar[OTodo::Maintainer] = false;
return ar;
}
void OTodoAccessBackendSQL::removeAllCompleted(){
#warning OTodoAccessBackendSQL::removeAllCompleted() not implemented !!
}
+
+}
diff --git a/libopie2/opiepim/backend/otodoaccesssql.h b/libopie2/opiepim/backend/otodoaccesssql.h
index 1c55567..1a6f614 100644
--- a/libopie2/opiepim/backend/otodoaccesssql.h
+++ b/libopie2/opiepim/backend/otodoaccesssql.h
@@ -1,56 +1,88 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#ifndef OPIE_PIM_ACCESS_SQL_H
#define OPIE_PIM_ACCESS_SQL_H
#include <qasciidict.h>
-#include "otodoaccessbackend.h"
+#include <opie2/otodoaccessbackend.h>
class OSQLDriver;
class OSQLResult;
class OSQLResultItem;
+
+namespace Opie {
+
class OTodoAccessBackendSQL : public OTodoAccessBackend {
public:
OTodoAccessBackendSQL( const QString& file );
~OTodoAccessBackendSQL();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> queryByExample( const OTodo& t, int settings, const QDateTime& d = QDateTime() );
OTodo find(int uid)const;
OTodo find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
void clear();
bool add( const OTodo& t );
bool remove( int uid );
bool replace( const OTodo& t );
QArray<int> overDue();
QArray<int> effectiveToDos( const QDate& start,
const QDate& end, bool includeNoDates );
QArray<int> sorted(bool asc, int sortOrder, int sortFilter, int cat );
QBitArray supports()const;
QArray<int> matchRegexp( const QRegExp &r ) const;
void removeAllCompleted();
private:
void update()const;
void fillDict();
inline bool date( QDate& date, const QString& )const;
inline OTodo todo( const OSQLResult& )const;
inline OTodo todo( OSQLResultItem& )const;
inline QArray<int> uids( const OSQLResult& )const;
OTodo todo( int uid )const;
QBitArray sup() const;
QAsciiDict<int> m_dict;
OSQLDriver* m_driver;
QArray<int> m_uids;
bool m_dirty : 1;
};
+}
#endif
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.cpp b/libopie2/opiepim/backend/otodoaccessvcal.cpp
index 6415952..e364ee2 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.cpp
+++ b/libopie2/opiepim/backend/otodoaccessvcal.cpp
@@ -1,31 +1,61 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#include <qfile.h>
#include <qtopia/private/vobject_p.h>
#include <qtopia/timeconversion.h>
#include <qtopia/private/qfiledirect_p.h>
-#include "otodoaccessvcal.h"
+#include <opie2/otodoaccessvcal.h>
+
+using namespace Opie;
namespace {
static OTodo eventByVObj( VObject *obj ){
OTodo event;
VObject *ob;
QCString name;
// no uid, attendees, ... and no fun
// description
if( ( ob = isAPropertyOf( obj, VCDescriptionProp )) != 0 ){
name = vObjectStringZValue( ob );
#if 0
event.setDescription( name );
#else
event.setSummary( name );
#endif
}
// summary
if ( ( ob = isAPropertyOf( obj, VCSummaryProp ) ) != 0 ) {
name = vObjectStringZValue( ob );
#if 0
event.setSummary( name );
#else
event.setDescription( name );
#endif
@@ -86,48 +116,49 @@ namespace {
// There seems a misrepresentation between summary in otodoevent
// and summary in vcard.
// The same with description..
// Description is summary and vice versa.. Argh.. (eilers)
addPropValue( task, VCDescriptionProp,
event.description().local8Bit() );
addPropValue( task, VCSummaryProp,
event.summary().local8Bit() );
#else
addPropValue( task, VCDescriptionProp,
event.summary().local8Bit() );
addPropValue( task, VCSummaryProp,
event.description().local8Bit() );
#endif
return task;
};
}
+namespace Opie {
OTodoAccessVCal::OTodoAccessVCal( const QString& path )
: m_dirty(false), m_file( path )
{
}
OTodoAccessVCal::~OTodoAccessVCal() {
}
bool OTodoAccessVCal::load() {
m_map.clear();
m_dirty = false;
VObject* vcal = 0l;
vcal = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
if (!vcal )
return false;
// Iterate over the list
VObjectIterator it;
VObject* vobj;
initPropIterator(&it, vcal);
while( moreIteration( &it ) ) {
vobj = ::nextVObject( &it );
QCString name = ::vObjectName( vobj );
@@ -226,24 +257,26 @@ QArray<int> OTodoAccessVCal::effectiveToDos( const QDate& ,
QArray<int> OTodoAccessVCal::overDue() {
QArray<int> ar(0);
return ar;
}
QBitArray OTodoAccessVCal::supports()const {
static QBitArray ar = sup();
return ar;
}
QBitArray OTodoAccessVCal::sup() {
QBitArray ar ( OTodo::CompletedDate +1 );
ar.fill( true );
ar[OTodo::CrossReference] = false;
ar[OTodo::State ] = false;
ar[OTodo::Reminders] = false;
ar[OTodo::Notifiers] = false;
ar[OTodo::Maintainer] = false;
ar[OTodo::Progress] = false;
ar[OTodo::Alarms ] = false;
ar[OTodo::Recurrence] = false;
return ar;
}
+
+}
diff --git a/libopie2/opiepim/backend/otodoaccessvcal.h b/libopie2/opiepim/backend/otodoaccessvcal.h
index 2b17147..f9323fb 100644
--- a/libopie2/opiepim/backend/otodoaccessvcal.h
+++ b/libopie2/opiepim/backend/otodoaccessvcal.h
@@ -1,40 +1,72 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#ifndef OPIE_OTODO_ACCESS_VCAL_H
#define OPIE_OTODO_ACCESS_VCAL_H
-#include "otodoaccessbackend.h"
+#include <opie2/otodoaccessbackend.h>
+
+namespace Opie {
class OTodoAccessVCal : public OTodoAccessBackend {
public:
OTodoAccessVCal(const QString& );
~OTodoAccessVCal();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OTodo& t, int sort, const QDateTime& d = QDateTime() );
QArray<int> effectiveToDos( const QDate& start,
const QDate& end,
bool includeNoDates );
QArray<int> overDue();
QArray<int> sorted( bool asc, int sortOrder, int sortFilter,
int cat );
OTodo find(int uid)const;
void clear();
bool add( const OTodo& );
bool remove( int uid );
bool replace( const OTodo& );
void removeAllCompleted();
virtual QBitArray supports()const;
private:
static QBitArray sup();
bool m_dirty : 1;
QString m_file;
QMap<int, OTodo> m_map;
};
+}
+
#endif
diff --git a/libopie2/opiepim/backend/otodoaccessxml.cpp b/libopie2/opiepim/backend/otodoaccessxml.cpp
index 4a5cb33..2d50ecd 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.cpp
+++ b/libopie2/opiepim/backend/otodoaccessxml.cpp
@@ -1,92 +1,123 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <qfile.h>
#include <qvector.h>
#include <qpe/global.h>
#include <qpe/stringutil.h>
#include <qpe/timeconversion.h>
-#include "oconversion.h"
-#include "opimstate.h"
-#include "otimezone.h"
-#include "opimnotifymanager.h"
-#include "orecur.h"
-#include "otodoaccessxml.h"
+#include <opie2/oconversion.h>
+#include <opie2/opimstate.h>
+#include <opie2/otimezone.h>
+#include <opie2/opimnotifymanager.h>
+#include <opie2/orecur.h>
+#include <opie2/otodoaccessxml.h>
+
+using namespace Opie;
namespace {
time_t rp_end;
ORecur* rec;
ORecur *recur() {
if (!rec ) rec = new ORecur;
return rec;
}
int snd;
enum MoreAttributes {
FRType = OTodo::CompletedDate + 2,
FRWeekdays,
FRPosition,
FRFreq,
FRHasEndDate,
FREndDate,
FRStart,
FREnd
};
// FROM TT again
char *strstrlen(const char *haystack, int hLen, const char* needle, int nLen)
{
char needleChar;
char haystackChar;
if (!needle || !haystack || !hLen || !nLen)
return 0;
const char* hsearch = haystack;
if ((needleChar = *needle++) != 0) {
nLen--; //(to make up for needle++)
do {
do {
if ((haystackChar = *hsearch++) == 0)
return (0);
if (hsearch >= haystack + hLen)
return (0);
} while (haystackChar != needleChar);
} while (strncmp(hsearch, needle, QMIN(hLen - (hsearch - haystack), nLen)) != 0);
hsearch--;
}
return ((char *)hsearch);
}
}
+namespace Opie {
OTodoAccessXML::OTodoAccessXML( const QString& appName,
const QString& fileName )
: OTodoAccessBackend(), m_app( appName ), m_opened( false ), m_changed( false )
{
if (!fileName.isEmpty() )
m_file = fileName;
else
m_file = Global::applicationFileName( "todolist", "todolist.xml" );
}
OTodoAccessXML::~OTodoAccessXML() {
}
bool OTodoAccessXML::load() {
rec = 0;
m_opened = true;
m_changed = false;
/* initialize dict */
/*
* UPDATE dict if you change anything!!!
*/
QAsciiDict<int> dict(26);
dict.setAutoDelete( TRUE );
dict.insert("Categories" , new int(OTodo::Category) );
@@ -853,24 +884,26 @@ QBitArray OTodoAccessXML::sup() {
ar[OTodo::CrossReference] = false;
ar[OTodo::State ] = false;
ar[OTodo::Reminders] = false;
ar[OTodo::Notifiers] = false;
ar[OTodo::Maintainer] = false;
return ar;
}
QArray<int> OTodoAccessXML::matchRegexp( const QRegExp &r ) const
{
QArray<int> m_currentQuery( m_events.count() );
uint arraycounter = 0;
QMap<int, OTodo>::ConstIterator it;
for (it = m_events.begin(); it != m_events.end(); ++it ) {
if ( it.data().match( r ) )
m_currentQuery[arraycounter++] = it.data().uid();
}
// Shrink to fit..
m_currentQuery.resize(arraycounter);
return m_currentQuery;
}
+
+}
diff --git a/libopie2/opiepim/backend/otodoaccessxml.h b/libopie2/opiepim/backend/otodoaccessxml.h
index e4850a1..d634398 100644
--- a/libopie2/opiepim/backend/otodoaccessxml.h
+++ b/libopie2/opiepim/backend/otodoaccessxml.h
@@ -1,60 +1,89 @@
+/*
+ This file is part of the Opie Project
+ Copyright (C) Stefan Eilers (Eilers.Stefan@epost.de)
+ =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ .=l.
+ .>+-=
+ _;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+ - . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+ : = ...= . :.=-
+ -. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
+ If not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
#ifndef OPIE_TODO_ACCESS_XML_H
#define OPIE_TODO_ACCESS_XML_H
#include <qasciidict.h>
#include <qmap.h>
-#include "otodoaccessbackend.h"
+#include <opie2/otodoaccessbackend.h>
namespace Opie {
class XMLElement;
-};
class OTodoAccessXML : public OTodoAccessBackend {
public:
/**
* fileName if Empty we will use the default path
*/
OTodoAccessXML( const QString& appName,
const QString& fileName = QString::null );
~OTodoAccessXML();
bool load();
bool reload();
bool save();
QArray<int> allRecords()const;
QArray<int> matchRegexp(const QRegExp &r) const;
QArray<int> queryByExample( const OTodo&, int querysettings, const QDateTime& d = QDateTime() );
OTodo find( int uid )const;
void clear();
bool add( const OTodo& );
bool remove( int uid );
void removeAllCompleted();
bool replace( const OTodo& );
/* our functions */
QArray<int> effectiveToDos( const QDate& start,
const QDate& end,
bool includeNoDates );
QArray<int> overDue();
QArray<int> sorted( bool asc, int sortOrder,
int sortFilter, int cat );
QBitArray supports()const;
private:
static QBitArray sup();
void todo( QAsciiDict<int>*, OTodo&,const QCString&,const QString& );
QString toString( const OTodo& )const;
QString toString( const QArray<int>& ints ) const;
QMap<int, OTodo> m_events;
QString m_file;
QString m_app;
bool m_opened : 1;
bool m_changed : 1;
class OTodoAccessXMLPrivate;
OTodoAccessXMLPrivate* d;
int m_year, m_month, m_day;
};
+};
+
#endif