summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/pim/obackendfactory.h26
-rw-r--r--libopie/pim/ocontact.h11
-rw-r--r--libopie/pim/ocontactaccess.h16
-rw-r--r--libopie/pim/ocontactaccessbackend.h32
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.cpp7
-rw-r--r--libopie/pim/ocontactaccessbackend_vcard.h18
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.cpp171
-rw-r--r--libopie/pim/ocontactaccessbackend_xml.h46
-rw-r--r--libopie/pim/odatebookaccess.cpp28
-rw-r--r--libopie/pim/odatebookaccess.h15
-rw-r--r--libopie/pim/odatebookaccessbackend.h45
-rw-r--r--libopie/pim/odatebookaccessbackend_xml.h6
-rw-r--r--libopie/pim/oevent.h17
-rw-r--r--libopie2/opiepim/backend/obackendfactory.h26
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend.h32
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp7
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_vcard.h18
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp171
-rw-r--r--libopie2/opiepim/backend/ocontactaccessbackend_xml.h46
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend.h45
-rw-r--r--libopie2/opiepim/backend/odatebookaccessbackend_xml.h6
-rw-r--r--libopie2/opiepim/core/ocontactaccess.h16
-rw-r--r--libopie2/opiepim/core/odatebookaccess.cpp28
-rw-r--r--libopie2/opiepim/core/odatebookaccess.h15
-rw-r--r--libopie2/opiepim/ocontact.h11
-rw-r--r--libopie2/opiepim/oevent.h17
26 files changed, 630 insertions, 246 deletions
diff --git a/libopie/pim/obackendfactory.h b/libopie/pim/obackendfactory.h
index 3a73210..ad6cf5a 100644
--- a/libopie/pim/obackendfactory.h
+++ b/libopie/pim/obackendfactory.h
@@ -17,4 +17,9 @@
* 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/02/21 23:31:52 zecke
* Add XML datebookresource
@@ -64,5 +69,19 @@
#endif
-
+/**
+ * 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
@@ -77,4 +96,9 @@ class OBackendFactory
};
+ /**
+ * Returns a backend implementation for backendName
+ * @param backendName the type of the backend
+ * @param appName will be passed on to the backend
+ */
static T* Default( const QString backendName, const QString& appName ){
diff --git a/libopie/pim/ocontact.h b/libopie/pim/ocontact.h
index 1fd1c75..25fa0e7 100644
--- a/libopie/pim/ocontact.h
+++ b/libopie/pim/ocontact.h
@@ -35,6 +35,13 @@ QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
#endif
-class ContactPrivate;
-
+class ContactPrivate;
+
+/**
+ * OContact class represents a specialised PIM Record for contacts.
+ * It does store all kind of persopn related information.
+ *
+ * @short Contact Container
+ * @author TT, Stefan Eiler, Holger Freyther
+ */
class QPC_EXPORT OContact : public OPimRecord
{
diff --git a/libopie/pim/ocontactaccess.h b/libopie/pim/ocontactaccess.h
index 32b2dcb..d7ceaf2 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/libopie/pim/ocontactaccess.h
@@ -18,4 +18,9 @@
* History:
* $Log$
+ * Revision 1.7 2003/04/13 18:07:10 zecke
+ * More API doc
+ * QString -> const QString&
+ * QString = 0l -> QString::null
+ *
* Revision 1.6 2003/01/02 14:27:12 eilers
* Improved query by example: Search by date is possible.. First step
@@ -56,7 +61,11 @@
#include "opimaccesstemplate.h"
-/** Class to access the contacts database.
+/**
+ * Class to access the contacts database.
* This is just a frontend for the real database handling which is
* done by the backend.
+ * This class is used to access the Contacts on a system. This class as any OPIE PIM
+ * class is backend independent.
+
* @see OPimAccessTemplate
*/
@@ -66,5 +75,6 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
public:
- /** Create Database with contacts (addressbook).
+ /**
+ * Create Database with contacts (addressbook).
* @param appname Name of application which wants access to the database
* (i.e. "todolist")
@@ -100,5 +110,5 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
};
-
+
ORecordList<OContact> matchRegexp( const QRegExp &r )const;
diff --git a/libopie/pim/ocontactaccessbackend.h b/libopie/pim/ocontactaccessbackend.h
index 821f5bf..ebeb42d 100644
--- a/libopie/pim/ocontactaccessbackend.h
+++ b/libopie/pim/ocontactaccessbackend.h
@@ -20,4 +20,9 @@
* History:
* $Log$
+ * 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..
@@ -45,6 +50,16 @@
#include "opimaccessbackend.h"
-#include "qregexp.h"
+#include <qregexp.h>
+/**
+ * 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:
@@ -53,5 +68,6 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
- /** Return if database was changed externally.
+ /**
+ * Return if database was changed externally.
* This may just make sense on file based databases like a XML-File.
* It is used to prevent to overwrite the current database content
@@ -69,5 +85,6 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0;
- /** Return all possible settings.
+ /**
+ * Return all possible settings.
* @return All settings provided by the current backend
* (i.e.: query_WildCards & query_IgnoreCase)
@@ -75,10 +92,15 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
virtual const uint querySettings() = 0;
- /** Check whether settings are correct.
+ /**
+ * Check whether settings are correct.
* @return <i>true</i> if the given settings are correct and possible.
*/
virtual bool hasQuerySettings (uint querySettings) const = 0;
- virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 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;
};
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/libopie/pim/ocontactaccessbackend_vcard.cpp
index f24523f..270bef3 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -18,4 +18,9 @@
* History:
* $Log$
+ * 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.
@@ -77,5 +82,5 @@
#include <qfile.h>
-OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ):
+OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ):
m_dirty( false ),
m_file( filename )
diff --git a/libopie/pim/ocontactaccessbackend_vcard.h b/libopie/pim/ocontactaccessbackend_vcard.h
index 93e2da3..712d769 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.h
+++ b/libopie/pim/ocontactaccessbackend_vcard.h
@@ -18,4 +18,9 @@
* 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.
@@ -48,7 +53,12 @@
class VObject;
+/**
+ * This is the vCard 2.1 implementation of the Contact Storage
+ * @see OContactAccessBackend_XML
+ * @see OPimAccessBackend
+ */
class OContactAccessBackend_VCard : public OContactAccessBackend {
public:
- OContactAccessBackend_VCard ( QString appname, QString filename = 0l );
+ OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null );
bool load ();
@@ -60,5 +70,5 @@ class OContactAccessBackend_VCard : public OContactAccessBackend {
bool remove ( int uid );
bool replace ( const OContact& contact );
-
+
OContact find ( int uid ) const;
QArray<int> allRecords() const;
@@ -70,5 +80,5 @@ class OContactAccessBackend_VCard : public OContactAccessBackend {
QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat );
bool wasChangedExternally();
-
+
private:
OContact parseVObject( VObject* obj );
@@ -78,5 +88,5 @@ private:
VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value );
VObject *safeAddProp( VObject* o, const char* prop);
-
+
bool m_dirty : 1;
QString m_file;
diff --git a/libopie/pim/ocontactaccessbackend_xml.cpp b/libopie/pim/ocontactaccessbackend_xml.cpp
index c5a7820..661cd51 100644
--- a/libopie/pim/ocontactaccessbackend_xml.cpp
+++ b/libopie/pim/ocontactaccessbackend_xml.cpp
@@ -18,4 +18,9 @@
* History:
* $Log$
+ * 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
@@ -94,5 +99,5 @@
#include <qarray.h>
#include <qmap.h>
-#include <qdatetime.h>
+#include <qdatetime.h>
#include <qpe/global.h>
@@ -108,5 +113,5 @@ using namespace Opie;
-OContactAccessBackend_XML::OContactAccessBackend_XML ( QString appname, QString filename ):
+OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ):
m_changed( false )
{
@@ -117,9 +122,9 @@ OContactAccessBackend_XML::OContactAccessBackend_XML ( QString appname, QString
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() ){
@@ -127,20 +132,20 @@ OContactAccessBackend_XML::OContactAccessBackend_XML ( QString appname, QString
} else
m_fileName = filename;
-
+
/* Load Database now */
load ();
}
-bool OContactAccessBackend_XML::save()
+bool OContactAccessBackend_XML::save()
{
-
+
if ( !m_changed )
return true;
-
+
QString strNewFile = m_fileName + ".new";
QFile f( strNewFile );
if ( !f.open( IO_WriteOnly|IO_Raw ) )
return false;
-
+
int total_written;
int idx_offset = 0;
@@ -175,5 +180,5 @@ bool OContactAccessBackend_XML::save()
}
out += " </Contacts>\n</AddressBook>\n";
-
+
// Write Footer
cstr = out.utf8();
@@ -185,5 +190,5 @@ bool OContactAccessBackend_XML::save()
}
f.close();
-
+
// move the file over, I'm just going to use the system call
// because, I don't feel like using QDir.
@@ -194,17 +199,17 @@ bool OContactAccessBackend_XML::save()
QFile::remove( strNewFile );
}
-
+
/* The journalfile should be removed now... */
removeJournal();
-
+
m_changed = false;
return true;
}
-bool OContactAccessBackend_XML::load ()
+bool OContactAccessBackend_XML::load ()
{
m_contactList.clear();
m_uidToContact.clear();
-
+
/* Load XML-File and journal if it exists */
if ( !load ( m_fileName, false ) )
@@ -217,9 +222,9 @@ bool OContactAccessBackend_XML::load ()
*/
load (m_journalName, true);
-
+
return true;
}
-void OContactAccessBackend_XML::clear ()
+void OContactAccessBackend_XML::clear ()
{
m_contactList.clear();
@@ -232,20 +237,20 @@ bool OContactAccessBackend_XML::wasChangedExternally()
{
QFileInfo fi( m_fileName );
-
+
QDateTime lastmod = fi.lastModified ();
-
+
return (lastmod != m_readtime);
}
-QArray<int> OContactAccessBackend_XML::allRecords() const
+QArray<int> OContactAccessBackend_XML::allRecords() const
{
QArray<int> uid_list( m_contactList.count() );
-
- uint counter = 0;
+
+ uint counter = 0;
QListIterator<OContact> it( m_contactList );
for( ; it.current(); ++it ){
uid_list[counter++] = (*it)->uid();
}
-
+
return ( uid_list );
}
@@ -254,5 +259,5 @@ OContact OContactAccessBackend_XML::find ( int uid ) const
{
OContact foundContact; //Create empty contact
-
+
OContact* found = m_uidToContact.find( QString().setNum( uid ) );
@@ -260,16 +265,16 @@ OContact OContactAccessBackend_XML::find ( int uid ) const
foundContact = *found;
}
-
+
return ( foundContact );
}
-QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings,
+QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings,
const QDateTime& d )
{
-
+
QArray<int> m_currentQuery( m_contactList.count() );
QListIterator<OContact> it( m_contactList );
uint arraycounter = 0;
-
+
for( ; it.current(); ++it ){
/* Search all fields and compare them with query object. Store them into list
@@ -291,5 +296,5 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
checkDate = new QDate( (*it)->anniversary() );
}
-
+
if ( queryDate->isValid() ){
if( checkDate->isValid() ){
@@ -297,18 +302,18 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
if ( queryDate->year() != checkDate->year() )
allcorrect = false;
- }
+ }
if ( settings & OContactAccess::DateMonth ){
if ( queryDate->month() != checkDate->month() )
allcorrect = false;
- }
+ }
if ( settings & OContactAccess::DateDay ){
if ( queryDate->day() != checkDate->day() )
allcorrect = false;
- }
+ }
if ( settings & OContactAccess::DateDiff ) {
QDate current;
// If we get an additional date, we
// will take this date instead of
- // the current one..
+ // the current one..
if ( !d.date().isValid() )
current = QDate::currentDate();
@@ -318,10 +323,10 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
// We have to equalize the year, otherwise
// the search will fail..
- checkDate->setYMD( current.year(),
- checkDate->month(),
+ checkDate->setYMD( current.year(),
+ checkDate->month(),
checkDate->day() );
if ( *checkDate < current )
- checkDate->setYMD( current.year()+1,
- checkDate->month(),
+ checkDate->setYMD( current.year()+1,
+ checkDate->month(),
checkDate->day() );
@@ -329,10 +334,10 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
// the current/given date and the maximum date
// ( maximum time range ) !
- qWarning("Checking if %s is between %s and %s ! ",
+ qWarning("Checking if %s is between %s and %s ! ",
checkDate->toString().latin1(),
- current.toString().latin1(),
+ current.toString().latin1(),
queryDate->toString().latin1() );
if ( current.daysTo( *queryDate ) >= 0 ){
- if ( !( ( *checkDate >= current ) &&
+ if ( !( ( *checkDate >= current ) &&
( *checkDate <= *queryDate ) ) ){
allcorrect = false;
@@ -346,5 +351,5 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
}
}
-
+
delete queryDate;
queryDate = 0l;
@@ -360,7 +365,7 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
| OContactAccess::DateMonth
| OContactAccess::DateDay
- | OContactAccess::MatchOne
+ | OContactAccess::MatchOne
) ){
-
+
case OContactAccess::RegExp:{
QRegExp expr ( query.field(i),
@@ -398,8 +403,8 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
}
}
-
+
// Shrink to fit..
m_currentQuery.resize(arraycounter);
-
+
return m_currentQuery;
}
@@ -410,14 +415,14 @@ QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const
QListIterator<OContact> it( m_contactList );
uint arraycounter = 0;
-
+
for( ; it.current(); ++it ){
if ( (*it)->match( r ) ){
m_currentQuery[arraycounter++] = (*it)->uid();
}
-
+
}
// Shrink to fit..
m_currentQuery.resize(arraycounter);
-
+
return m_currentQuery;
}
@@ -428,5 +433,5 @@ const uint OContactAccessBackend_XML::querySettings()
| OContactAccess::IgnoreCase
| OContactAccess::RegExp
- | OContactAccess::ExactMatch
+ | OContactAccess::ExactMatch
| OContactAccess::DateDiff
| OContactAccess::DateYear
@@ -438,12 +443,12 @@ const uint OContactAccessBackend_XML::querySettings()
bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
{
- /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
+ /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
* may be added with any of the other settings. IgnoreCase should never used alone.
* Wildcards, RegExp, ExactMatch should never used at the same time...
*/
-
- if ( querySettings == OContactAccess::IgnoreCase )
+
+ if ( querySettings == OContactAccess::IgnoreCase )
return false;
-
+
switch ( querySettings & ~( OContactAccess::IgnoreCase
| OContactAccess::DateDiff
@@ -451,5 +456,5 @@ bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
| OContactAccess::DateMonth
| OContactAccess::DateDay
- )
+ )
){
case OContactAccess::RegExp:
@@ -464,12 +469,12 @@ bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
}
-// Currently only asc implemented..
-QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
+// Currently only asc implemented..
+QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
{
QMap<QString, int> nameToUid;
QStringList names;
QArray<int> m_currentQuery( m_contactList.count() );
-
- // First fill map and StringList with all Names
+
+ // First fill map and StringList with all Names
// Afterwards sort namelist and use map to fill array to return..
QListIterator<OContact> it( m_contactList );
@@ -479,5 +484,5 @@ QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
}
names.sort();
-
+
int i = 0;
if ( asc ){
@@ -488,7 +493,7 @@ QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
m_currentQuery[i++] = nameToUid[ (*it) ];
}
-
+
return m_currentQuery;
-
+
}
@@ -498,7 +503,7 @@ bool OContactAccessBackend_XML::add ( const OContact &newcontact )
updateJournal (newcontact, ACTION_ADD);
addContact_p( newcontact );
-
+
m_changed = true;
-
+
return true;
}
@@ -507,5 +512,5 @@ bool OContactAccessBackend_XML::replace ( const OContact &contact )
{
m_changed = true;
-
+
OContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) );
@@ -529,5 +534,5 @@ bool OContactAccessBackend_XML::remove ( int uid )
{
m_changed = true;
-
+
OContact* found = m_uidToContact.find ( QString().setNum( uid ) );
@@ -556,7 +561,7 @@ void OContactAccessBackend_XML::addContact_p( const OContact &newcontact )
/* This function loads the xml-database and the journalfile */
-bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
+bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
{
-
+
/* We use the time of the last read to check if the file was
* changed externally.
@@ -566,8 +571,8 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
m_readtime = fi.lastModified ();
}
-
+
const int JOURNALACTION = Qtopia::Notes + 1;
const int JOURNALROW = JOURNALACTION + 1;
-
+
bool foundAction = false;
journal_action action = ACTION_ADD;
@@ -577,5 +582,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
QMap<QString, QString>::Iterator customIt;
QAsciiDict<int> dict( 47 );
-
+
dict.setAutoDelete( TRUE );
dict.insert( "Uid", new int(Qtopia::AddressUid) );
@@ -624,7 +629,7 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
dict.insert( "action", new int(JOURNALACTION) );
dict.insert( "actionrow", new int(JOURNALROW) );
-
+
//qWarning( "OContactDefaultBackEnd::loading %s", filename.latin1() );
-
+
XMLElement *root = XMLElement::load( filename );
if(root != 0l ){ // start parsing
@@ -635,5 +640,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
//qWarning("OContactAccess::load tagName(): %s", root->tagName().latin1() );
element = element->firstChild();
-
+
/* Search Tag "Contacts" which is the parent of all Contacts */
while( element && !isJournal ){
@@ -662,5 +667,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
QString dummy;
foundAction = false;
-
+
XMLElement::AttributeMap aMap = element->attributes();
XMLElement::AttributeMap::Iterator it;
@@ -669,5 +674,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
for( it = aMap.begin(); it != aMap.end(); ++it ){
// qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
-
+
int *find = dict[ it.key() ];
/* Unknown attributes will be stored as "Custom" elements */
@@ -678,5 +683,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
continue;
}
-
+
/* Check if special conversion is needed and add attribute
* into Contact class
@@ -706,9 +711,9 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
/* now generate the Contact contact */
OContact contact( contactMap );
-
+
for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) {
contact.setCustomField( customIt.key(), customIt.data() );
}
-
+
if (foundAction){
foundAction = false;
@@ -735,5 +740,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
addContact_p (contact);
}
-
+
/* Move to next element */
element = element->nextChild();
@@ -749,5 +754,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
- journal_action action )
+ journal_action action )
{
QFile f( m_journalName );
@@ -755,8 +760,8 @@ void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
if ( !f.open(IO_WriteOnly|IO_Append) )
return;
-
+
QString buf;
QCString str;
-
+
// if the file was created, we have to set the Tag "<CONTACTS>" to
// get a XML-File which is readable by our parser.
@@ -767,5 +772,5 @@ void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
f.writeBlock( cstr.data(), cstr.length() );
}
-
+
buf = "<Contact ";
cnt.save( buf );
diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/libopie/pim/ocontactaccessbackend_xml.h
index 4d6a7ef..7b5365b 100644
--- a/libopie/pim/ocontactaccessbackend_xml.h
+++ b/libopie/pim/ocontactaccessbackend_xml.h
@@ -18,4 +18,9 @@
* History:
* $Log$
+ * 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.
@@ -85,37 +90,42 @@
/* 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 ( QString appname, QString filename = 0l );
-
+ 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() );
QArray<int> matchRegexp( const QRegExp &r ) const;
-
+
const uint querySettings();
-
+
bool hasQuerySettings (uint querySettings) const;
-
- // Currently only asc implemented..
+
+ // 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:
@@ -123,12 +133,12 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
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;
diff --git a/libopie/pim/odatebookaccess.cpp b/libopie/pim/odatebookaccess.cpp
index 08e61ff..a3661a3 100644
--- a/libopie/pim/odatebookaccess.cpp
+++ b/libopie/pim/odatebookaccess.cpp
@@ -2,4 +2,11 @@
#include "odatebookaccess.h"
+/**
+ * Simple constructor
+ * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation
+ * will be used!
+ * @param back The backend to be used or 0 for the default backend
+ * @param ac What kind of access is intended
+ */
ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
: OPimAccessTemplate<OEvent>( back )
@@ -13,4 +20,8 @@ ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
ODateBookAccess::~ODateBookAccess() {
}
+
+/**
+ * @return all events available
+ */
ODateBookAccess::List ODateBookAccess::rawEvents()const {
QArray<int> ints = m_backEnd->rawEvents();
@@ -19,4 +30,8 @@ ODateBookAccess::List ODateBookAccess::rawEvents()const {
return lis;
}
+
+/**
+ * @return all repeating events
+ */
ODateBookAccess::List ODateBookAccess::rawRepeats()const {
QArray<int> ints = m_backEnd->rawRepeats();
@@ -25,4 +40,8 @@ ODateBookAccess::List ODateBookAccess::rawRepeats()const {
return lis;
}
+
+/**
+ * @return all non repeating events
+ */
ODateBookAccess::List ODateBookAccess::nonRepeats()const {
QArray<int> ints = m_backEnd->nonRepeats();
@@ -31,7 +50,16 @@ ODateBookAccess::List ODateBookAccess::nonRepeats()const {
return lis;
}
+
+/**
+ * @return dates in the time span between from and to
+ * @param from Include all events from...
+ * @param to Include all events to...
+ */
OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) {
return m_backEnd->effecticeEvents( from, to );
}
+/**
+ * @return all events at a given datetime
+ */
OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) {
return m_backEnd->effecticeEvents( start );
diff --git a/libopie/pim/odatebookaccess.h b/libopie/pim/odatebookaccess.h
index 7047039..7c7a63f 100644
--- a/libopie/pim/odatebookaccess.h
+++ b/libopie/pim/odatebookaccess.h
@@ -7,4 +7,13 @@
#include "oevent.h"
+/**
+ * This is the object orientated datebook database. It'll use OBackendFactory
+ * to query for a backend.
+ * All access to the datebook should be done via this class.
+ * Make sure to load and save the datebook this is not part of
+ * destructing and creating the object
+ *
+ * @author Holger Freyther
+ */
class ODateBookAccess : public OPimAccessTemplate<OEvent> {
public:
@@ -12,11 +21,11 @@ public:
~ODateBookAccess();
- /** return all events */
+ /* return all events */
List rawEvents()const;
- /** return repeating events */
+ /* return repeating events */
List rawRepeats()const;
- /** return non repeating events */
+ /* return non repeating events */
List nonRepeats()const;
diff --git a/libopie/pim/odatebookaccessbackend.h b/libopie/pim/odatebookaccessbackend.h
index eb6e8fb..86ff298 100644
--- a/libopie/pim/odatebookaccessbackend.h
+++ b/libopie/pim/odatebookaccessbackend.h
@@ -7,23 +7,64 @@
#include "oevent.h"
+/**
+ * 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
+ * all repeating events. No filter should be applied
+ * @return list of repeating events
+ */
virtual QArray<UID> rawRepeats()const = 0;
+
+ /**
+ * This mthod should return a list of UIDs containing all non
+ * repeating events. No filter should be applied
+ * @return list of nonrepeating events
+ */
virtual QArray<UID> nonRepeats() const = 0;
/**
- * these two methods are used if you do not implement
- * effectiveEvents...
+ * If you do not want to implement the effectiveEvents methods below
+ * you need to supply it with directNonRepeats.
+ * This method can return empty lists if effectiveEvents is implememted
*/
virtual OEvent::ValueList directNonRepeats() = 0;
+
+ /**
+ * Same as above but return raw repeats!
+ */
virtual OEvent::ValueList directRawRepeats() = 0;
/* is implemented by default but you can reimplement it*/
+ /**
+ * 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 effecticeEvents( const QDate& from, const QDate& to );
+
+ /**
+ * this is an overloaded member function
+ * @see effecticeEvents
+ */
virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
diff --git a/libopie/pim/odatebookaccessbackend_xml.h b/libopie/pim/odatebookaccessbackend_xml.h
index 563c31f..7848f7c 100644
--- a/libopie/pim/odatebookaccessbackend_xml.h
+++ b/libopie/pim/odatebookaccessbackend_xml.h
@@ -6,4 +6,10 @@
#include "odatebookaccessbackend.h"
+/**
+ * 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:
diff --git a/libopie/pim/oevent.h b/libopie/pim/oevent.h
index 585515c..57d32d0 100644
--- a/libopie/pim/oevent.h
+++ b/libopie/pim/oevent.h
@@ -31,7 +31,16 @@ struct OCalendarHelper {
class OPimNotifyManager;
class ORecur;
+
+/**
+ * This is the container for all Events. It encapsules all
+ * available information for a single Event
+ * @short container for events.
+ */
class OEvent : public OPimRecord {
public:
typedef QValueList<OEvent> ValueList;
+ /**
+ * RecordFields contain possible attributes
+ */
enum RecordFields {
Uid = Qtopia::UID_ID,
@@ -50,5 +59,12 @@ public:
};
+ /**
+ * Start with an Empty OEvent. UID == 0 means that it is empty
+ */
OEvent(int uid = 0);
+
+ /**
+ * copy c'tor
+ */
OEvent( const OEvent& );
~OEvent();
@@ -145,5 +161,4 @@ private:
* AN Event can span through multiple days. We split up a multiday eve
*/
-
class OEffectiveEvent {
public:
diff --git a/libopie2/opiepim/backend/obackendfactory.h b/libopie2/opiepim/backend/obackendfactory.h
index 3a73210..ad6cf5a 100644
--- a/libopie2/opiepim/backend/obackendfactory.h
+++ b/libopie2/opiepim/backend/obackendfactory.h
@@ -17,4 +17,9 @@
* 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/02/21 23:31:52 zecke
* Add XML datebookresource
@@ -64,5 +69,19 @@
#endif
-
+/**
+ * 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
@@ -77,4 +96,9 @@ class OBackendFactory
};
+ /**
+ * Returns a backend implementation for backendName
+ * @param backendName the type of the backend
+ * @param appName will be passed on to the backend
+ */
static T* Default( const QString backendName, const QString& appName ){
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend.h b/libopie2/opiepim/backend/ocontactaccessbackend.h
index 821f5bf..ebeb42d 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend.h
@@ -20,4 +20,9 @@
* History:
* $Log$
+ * 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..
@@ -45,6 +50,16 @@
#include "opimaccessbackend.h"
-#include "qregexp.h"
+#include <qregexp.h>
+/**
+ * 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:
@@ -53,5 +68,6 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
- /** Return if database was changed externally.
+ /**
+ * Return if database was changed externally.
* This may just make sense on file based databases like a XML-File.
* It is used to prevent to overwrite the current database content
@@ -69,5 +85,6 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0;
- /** Return all possible settings.
+ /**
+ * Return all possible settings.
* @return All settings provided by the current backend
* (i.e.: query_WildCards & query_IgnoreCase)
@@ -75,10 +92,15 @@ class OContactAccessBackend: public OPimAccessBackend<OContact> {
virtual const uint querySettings() = 0;
- /** Check whether settings are correct.
+ /**
+ * Check whether settings are correct.
* @return <i>true</i> if the given settings are correct and possible.
*/
virtual bool hasQuerySettings (uint querySettings) const = 0;
- virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 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;
};
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
index f24523f..270bef3 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.cpp
@@ -18,4 +18,9 @@
* History:
* $Log$
+ * 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.
@@ -77,5 +82,5 @@
#include <qfile.h>
-OContactAccessBackend_VCard::OContactAccessBackend_VCard ( QString , QString filename ):
+OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ):
m_dirty( false ),
m_file( filename )
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
index 93e2da3..712d769 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_vcard.h
@@ -18,4 +18,9 @@
* 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.
@@ -48,7 +53,12 @@
class VObject;
+/**
+ * This is the vCard 2.1 implementation of the Contact Storage
+ * @see OContactAccessBackend_XML
+ * @see OPimAccessBackend
+ */
class OContactAccessBackend_VCard : public OContactAccessBackend {
public:
- OContactAccessBackend_VCard ( QString appname, QString filename = 0l );
+ OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null );
bool load ();
@@ -60,5 +70,5 @@ class OContactAccessBackend_VCard : public OContactAccessBackend {
bool remove ( int uid );
bool replace ( const OContact& contact );
-
+
OContact find ( int uid ) const;
QArray<int> allRecords() const;
@@ -70,5 +80,5 @@ class OContactAccessBackend_VCard : public OContactAccessBackend {
QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat );
bool wasChangedExternally();
-
+
private:
OContact parseVObject( VObject* obj );
@@ -78,5 +88,5 @@ private:
VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value );
VObject *safeAddProp( VObject* o, const char* prop);
-
+
bool m_dirty : 1;
QString m_file;
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
index c5a7820..661cd51 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.cpp
@@ -18,4 +18,9 @@
* History:
* $Log$
+ * 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
@@ -94,5 +99,5 @@
#include <qarray.h>
#include <qmap.h>
-#include <qdatetime.h>
+#include <qdatetime.h>
#include <qpe/global.h>
@@ -108,5 +113,5 @@ using namespace Opie;
-OContactAccessBackend_XML::OContactAccessBackend_XML ( QString appname, QString filename ):
+OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ):
m_changed( false )
{
@@ -117,9 +122,9 @@ OContactAccessBackend_XML::OContactAccessBackend_XML ( QString appname, QString
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() ){
@@ -127,20 +132,20 @@ OContactAccessBackend_XML::OContactAccessBackend_XML ( QString appname, QString
} else
m_fileName = filename;
-
+
/* Load Database now */
load ();
}
-bool OContactAccessBackend_XML::save()
+bool OContactAccessBackend_XML::save()
{
-
+
if ( !m_changed )
return true;
-
+
QString strNewFile = m_fileName + ".new";
QFile f( strNewFile );
if ( !f.open( IO_WriteOnly|IO_Raw ) )
return false;
-
+
int total_written;
int idx_offset = 0;
@@ -175,5 +180,5 @@ bool OContactAccessBackend_XML::save()
}
out += " </Contacts>\n</AddressBook>\n";
-
+
// Write Footer
cstr = out.utf8();
@@ -185,5 +190,5 @@ bool OContactAccessBackend_XML::save()
}
f.close();
-
+
// move the file over, I'm just going to use the system call
// because, I don't feel like using QDir.
@@ -194,17 +199,17 @@ bool OContactAccessBackend_XML::save()
QFile::remove( strNewFile );
}
-
+
/* The journalfile should be removed now... */
removeJournal();
-
+
m_changed = false;
return true;
}
-bool OContactAccessBackend_XML::load ()
+bool OContactAccessBackend_XML::load ()
{
m_contactList.clear();
m_uidToContact.clear();
-
+
/* Load XML-File and journal if it exists */
if ( !load ( m_fileName, false ) )
@@ -217,9 +222,9 @@ bool OContactAccessBackend_XML::load ()
*/
load (m_journalName, true);
-
+
return true;
}
-void OContactAccessBackend_XML::clear ()
+void OContactAccessBackend_XML::clear ()
{
m_contactList.clear();
@@ -232,20 +237,20 @@ bool OContactAccessBackend_XML::wasChangedExternally()
{
QFileInfo fi( m_fileName );
-
+
QDateTime lastmod = fi.lastModified ();
-
+
return (lastmod != m_readtime);
}
-QArray<int> OContactAccessBackend_XML::allRecords() const
+QArray<int> OContactAccessBackend_XML::allRecords() const
{
QArray<int> uid_list( m_contactList.count() );
-
- uint counter = 0;
+
+ uint counter = 0;
QListIterator<OContact> it( m_contactList );
for( ; it.current(); ++it ){
uid_list[counter++] = (*it)->uid();
}
-
+
return ( uid_list );
}
@@ -254,5 +259,5 @@ OContact OContactAccessBackend_XML::find ( int uid ) const
{
OContact foundContact; //Create empty contact
-
+
OContact* found = m_uidToContact.find( QString().setNum( uid ) );
@@ -260,16 +265,16 @@ OContact OContactAccessBackend_XML::find ( int uid ) const
foundContact = *found;
}
-
+
return ( foundContact );
}
-QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings,
+QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings,
const QDateTime& d )
{
-
+
QArray<int> m_currentQuery( m_contactList.count() );
QListIterator<OContact> it( m_contactList );
uint arraycounter = 0;
-
+
for( ; it.current(); ++it ){
/* Search all fields and compare them with query object. Store them into list
@@ -291,5 +296,5 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
checkDate = new QDate( (*it)->anniversary() );
}
-
+
if ( queryDate->isValid() ){
if( checkDate->isValid() ){
@@ -297,18 +302,18 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
if ( queryDate->year() != checkDate->year() )
allcorrect = false;
- }
+ }
if ( settings & OContactAccess::DateMonth ){
if ( queryDate->month() != checkDate->month() )
allcorrect = false;
- }
+ }
if ( settings & OContactAccess::DateDay ){
if ( queryDate->day() != checkDate->day() )
allcorrect = false;
- }
+ }
if ( settings & OContactAccess::DateDiff ) {
QDate current;
// If we get an additional date, we
// will take this date instead of
- // the current one..
+ // the current one..
if ( !d.date().isValid() )
current = QDate::currentDate();
@@ -318,10 +323,10 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
// We have to equalize the year, otherwise
// the search will fail..
- checkDate->setYMD( current.year(),
- checkDate->month(),
+ checkDate->setYMD( current.year(),
+ checkDate->month(),
checkDate->day() );
if ( *checkDate < current )
- checkDate->setYMD( current.year()+1,
- checkDate->month(),
+ checkDate->setYMD( current.year()+1,
+ checkDate->month(),
checkDate->day() );
@@ -329,10 +334,10 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
// the current/given date and the maximum date
// ( maximum time range ) !
- qWarning("Checking if %s is between %s and %s ! ",
+ qWarning("Checking if %s is between %s and %s ! ",
checkDate->toString().latin1(),
- current.toString().latin1(),
+ current.toString().latin1(),
queryDate->toString().latin1() );
if ( current.daysTo( *queryDate ) >= 0 ){
- if ( !( ( *checkDate >= current ) &&
+ if ( !( ( *checkDate >= current ) &&
( *checkDate <= *queryDate ) ) ){
allcorrect = false;
@@ -346,5 +351,5 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
}
}
-
+
delete queryDate;
queryDate = 0l;
@@ -360,7 +365,7 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
| OContactAccess::DateMonth
| OContactAccess::DateDay
- | OContactAccess::MatchOne
+ | OContactAccess::MatchOne
) ){
-
+
case OContactAccess::RegExp:{
QRegExp expr ( query.field(i),
@@ -398,8 +403,8 @@ QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, i
}
}
-
+
// Shrink to fit..
m_currentQuery.resize(arraycounter);
-
+
return m_currentQuery;
}
@@ -410,14 +415,14 @@ QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const
QListIterator<OContact> it( m_contactList );
uint arraycounter = 0;
-
+
for( ; it.current(); ++it ){
if ( (*it)->match( r ) ){
m_currentQuery[arraycounter++] = (*it)->uid();
}
-
+
}
// Shrink to fit..
m_currentQuery.resize(arraycounter);
-
+
return m_currentQuery;
}
@@ -428,5 +433,5 @@ const uint OContactAccessBackend_XML::querySettings()
| OContactAccess::IgnoreCase
| OContactAccess::RegExp
- | OContactAccess::ExactMatch
+ | OContactAccess::ExactMatch
| OContactAccess::DateDiff
| OContactAccess::DateYear
@@ -438,12 +443,12 @@ const uint OContactAccessBackend_XML::querySettings()
bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
{
- /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
+ /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
* may be added with any of the other settings. IgnoreCase should never used alone.
* Wildcards, RegExp, ExactMatch should never used at the same time...
*/
-
- if ( querySettings == OContactAccess::IgnoreCase )
+
+ if ( querySettings == OContactAccess::IgnoreCase )
return false;
-
+
switch ( querySettings & ~( OContactAccess::IgnoreCase
| OContactAccess::DateDiff
@@ -451,5 +456,5 @@ bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
| OContactAccess::DateMonth
| OContactAccess::DateDay
- )
+ )
){
case OContactAccess::RegExp:
@@ -464,12 +469,12 @@ bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
}
-// Currently only asc implemented..
-QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
+// Currently only asc implemented..
+QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
{
QMap<QString, int> nameToUid;
QStringList names;
QArray<int> m_currentQuery( m_contactList.count() );
-
- // First fill map and StringList with all Names
+
+ // First fill map and StringList with all Names
// Afterwards sort namelist and use map to fill array to return..
QListIterator<OContact> it( m_contactList );
@@ -479,5 +484,5 @@ QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
}
names.sort();
-
+
int i = 0;
if ( asc ){
@@ -488,7 +493,7 @@ QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
m_currentQuery[i++] = nameToUid[ (*it) ];
}
-
+
return m_currentQuery;
-
+
}
@@ -498,7 +503,7 @@ bool OContactAccessBackend_XML::add ( const OContact &newcontact )
updateJournal (newcontact, ACTION_ADD);
addContact_p( newcontact );
-
+
m_changed = true;
-
+
return true;
}
@@ -507,5 +512,5 @@ bool OContactAccessBackend_XML::replace ( const OContact &contact )
{
m_changed = true;
-
+
OContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) );
@@ -529,5 +534,5 @@ bool OContactAccessBackend_XML::remove ( int uid )
{
m_changed = true;
-
+
OContact* found = m_uidToContact.find ( QString().setNum( uid ) );
@@ -556,7 +561,7 @@ void OContactAccessBackend_XML::addContact_p( const OContact &newcontact )
/* This function loads the xml-database and the journalfile */
-bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
+bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
{
-
+
/* We use the time of the last read to check if the file was
* changed externally.
@@ -566,8 +571,8 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
m_readtime = fi.lastModified ();
}
-
+
const int JOURNALACTION = Qtopia::Notes + 1;
const int JOURNALROW = JOURNALACTION + 1;
-
+
bool foundAction = false;
journal_action action = ACTION_ADD;
@@ -577,5 +582,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
QMap<QString, QString>::Iterator customIt;
QAsciiDict<int> dict( 47 );
-
+
dict.setAutoDelete( TRUE );
dict.insert( "Uid", new int(Qtopia::AddressUid) );
@@ -624,7 +629,7 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
dict.insert( "action", new int(JOURNALACTION) );
dict.insert( "actionrow", new int(JOURNALROW) );
-
+
//qWarning( "OContactDefaultBackEnd::loading %s", filename.latin1() );
-
+
XMLElement *root = XMLElement::load( filename );
if(root != 0l ){ // start parsing
@@ -635,5 +640,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
//qWarning("OContactAccess::load tagName(): %s", root->tagName().latin1() );
element = element->firstChild();
-
+
/* Search Tag "Contacts" which is the parent of all Contacts */
while( element && !isJournal ){
@@ -662,5 +667,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
QString dummy;
foundAction = false;
-
+
XMLElement::AttributeMap aMap = element->attributes();
XMLElement::AttributeMap::Iterator it;
@@ -669,5 +674,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
for( it = aMap.begin(); it != aMap.end(); ++it ){
// qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
-
+
int *find = dict[ it.key() ];
/* Unknown attributes will be stored as "Custom" elements */
@@ -678,5 +683,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
continue;
}
-
+
/* Check if special conversion is needed and add attribute
* into Contact class
@@ -706,9 +711,9 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
/* now generate the Contact contact */
OContact contact( contactMap );
-
+
for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) {
contact.setCustomField( customIt.key(), customIt.data() );
}
-
+
if (foundAction){
foundAction = false;
@@ -735,5 +740,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
addContact_p (contact);
}
-
+
/* Move to next element */
element = element->nextChild();
@@ -749,5 +754,5 @@ bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
- journal_action action )
+ journal_action action )
{
QFile f( m_journalName );
@@ -755,8 +760,8 @@ void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
if ( !f.open(IO_WriteOnly|IO_Append) )
return;
-
+
QString buf;
QCString str;
-
+
// if the file was created, we have to set the Tag "<CONTACTS>" to
// get a XML-File which is readable by our parser.
@@ -767,5 +772,5 @@ void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
f.writeBlock( cstr.data(), cstr.length() );
}
-
+
buf = "<Contact ";
cnt.save( buf );
diff --git a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
index 4d6a7ef..7b5365b 100644
--- a/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/ocontactaccessbackend_xml.h
@@ -18,4 +18,9 @@
* History:
* $Log$
+ * 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.
@@ -85,37 +90,42 @@
/* 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 ( QString appname, QString filename = 0l );
-
+ 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() );
QArray<int> matchRegexp( const QRegExp &r ) const;
-
+
const uint querySettings();
-
+
bool hasQuerySettings (uint querySettings) const;
-
- // Currently only asc implemented..
+
+ // 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:
@@ -123,12 +133,12 @@ class OContactAccessBackend_XML : public OContactAccessBackend {
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;
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend.h b/libopie2/opiepim/backend/odatebookaccessbackend.h
index eb6e8fb..86ff298 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend.h
@@ -7,23 +7,64 @@
#include "oevent.h"
+/**
+ * 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
+ * all repeating events. No filter should be applied
+ * @return list of repeating events
+ */
virtual QArray<UID> rawRepeats()const = 0;
+
+ /**
+ * This mthod should return a list of UIDs containing all non
+ * repeating events. No filter should be applied
+ * @return list of nonrepeating events
+ */
virtual QArray<UID> nonRepeats() const = 0;
/**
- * these two methods are used if you do not implement
- * effectiveEvents...
+ * If you do not want to implement the effectiveEvents methods below
+ * you need to supply it with directNonRepeats.
+ * This method can return empty lists if effectiveEvents is implememted
*/
virtual OEvent::ValueList directNonRepeats() = 0;
+
+ /**
+ * Same as above but return raw repeats!
+ */
virtual OEvent::ValueList directRawRepeats() = 0;
/* is implemented by default but you can reimplement it*/
+ /**
+ * 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 effecticeEvents( const QDate& from, const QDate& to );
+
+ /**
+ * this is an overloaded member function
+ * @see effecticeEvents
+ */
virtual OEffectiveEvent::ValueList effecticeEvents( const QDateTime& start );
diff --git a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
index 563c31f..7848f7c 100644
--- a/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
+++ b/libopie2/opiepim/backend/odatebookaccessbackend_xml.h
@@ -6,4 +6,10 @@
#include "odatebookaccessbackend.h"
+/**
+ * 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:
diff --git a/libopie2/opiepim/core/ocontactaccess.h b/libopie2/opiepim/core/ocontactaccess.h
index 32b2dcb..d7ceaf2 100644
--- a/libopie2/opiepim/core/ocontactaccess.h
+++ b/libopie2/opiepim/core/ocontactaccess.h
@@ -18,4 +18,9 @@
* History:
* $Log$
+ * Revision 1.7 2003/04/13 18:07:10 zecke
+ * More API doc
+ * QString -> const QString&
+ * QString = 0l -> QString::null
+ *
* Revision 1.6 2003/01/02 14:27:12 eilers
* Improved query by example: Search by date is possible.. First step
@@ -56,7 +61,11 @@
#include "opimaccesstemplate.h"
-/** Class to access the contacts database.
+/**
+ * Class to access the contacts database.
* This is just a frontend for the real database handling which is
* done by the backend.
+ * This class is used to access the Contacts on a system. This class as any OPIE PIM
+ * class is backend independent.
+
* @see OPimAccessTemplate
*/
@@ -66,5 +75,6 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
public:
- /** Create Database with contacts (addressbook).
+ /**
+ * Create Database with contacts (addressbook).
* @param appname Name of application which wants access to the database
* (i.e. "todolist")
@@ -100,5 +110,5 @@ class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
};
-
+
ORecordList<OContact> matchRegexp( const QRegExp &r )const;
diff --git a/libopie2/opiepim/core/odatebookaccess.cpp b/libopie2/opiepim/core/odatebookaccess.cpp
index 08e61ff..a3661a3 100644
--- a/libopie2/opiepim/core/odatebookaccess.cpp
+++ b/libopie2/opiepim/core/odatebookaccess.cpp
@@ -2,4 +2,11 @@
#include "odatebookaccess.h"
+/**
+ * Simple constructor
+ * It takes a ODateBookAccessBackend as parent. If it is 0 the default implementation
+ * will be used!
+ * @param back The backend to be used or 0 for the default backend
+ * @param ac What kind of access is intended
+ */
ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
: OPimAccessTemplate<OEvent>( back )
@@ -13,4 +20,8 @@ ODateBookAccess::ODateBookAccess( ODateBookAccessBackend* back, enum Access ac )
ODateBookAccess::~ODateBookAccess() {
}
+
+/**
+ * @return all events available
+ */
ODateBookAccess::List ODateBookAccess::rawEvents()const {
QArray<int> ints = m_backEnd->rawEvents();
@@ -19,4 +30,8 @@ ODateBookAccess::List ODateBookAccess::rawEvents()const {
return lis;
}
+
+/**
+ * @return all repeating events
+ */
ODateBookAccess::List ODateBookAccess::rawRepeats()const {
QArray<int> ints = m_backEnd->rawRepeats();
@@ -25,4 +40,8 @@ ODateBookAccess::List ODateBookAccess::rawRepeats()const {
return lis;
}
+
+/**
+ * @return all non repeating events
+ */
ODateBookAccess::List ODateBookAccess::nonRepeats()const {
QArray<int> ints = m_backEnd->nonRepeats();
@@ -31,7 +50,16 @@ ODateBookAccess::List ODateBookAccess::nonRepeats()const {
return lis;
}
+
+/**
+ * @return dates in the time span between from and to
+ * @param from Include all events from...
+ * @param to Include all events to...
+ */
OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDate& from, const QDate& to ) {
return m_backEnd->effecticeEvents( from, to );
}
+/**
+ * @return all events at a given datetime
+ */
OEffectiveEvent::ValueList ODateBookAccess::effectiveEvents( const QDateTime& start ) {
return m_backEnd->effecticeEvents( start );
diff --git a/libopie2/opiepim/core/odatebookaccess.h b/libopie2/opiepim/core/odatebookaccess.h
index 7047039..7c7a63f 100644
--- a/libopie2/opiepim/core/odatebookaccess.h
+++ b/libopie2/opiepim/core/odatebookaccess.h
@@ -7,4 +7,13 @@
#include "oevent.h"
+/**
+ * This is the object orientated datebook database. It'll use OBackendFactory
+ * to query for a backend.
+ * All access to the datebook should be done via this class.
+ * Make sure to load and save the datebook this is not part of
+ * destructing and creating the object
+ *
+ * @author Holger Freyther
+ */
class ODateBookAccess : public OPimAccessTemplate<OEvent> {
public:
@@ -12,11 +21,11 @@ public:
~ODateBookAccess();
- /** return all events */
+ /* return all events */
List rawEvents()const;
- /** return repeating events */
+ /* return repeating events */
List rawRepeats()const;
- /** return non repeating events */
+ /* return non repeating events */
List nonRepeats()const;
diff --git a/libopie2/opiepim/ocontact.h b/libopie2/opiepim/ocontact.h
index 1fd1c75..25fa0e7 100644
--- a/libopie2/opiepim/ocontact.h
+++ b/libopie2/opiepim/ocontact.h
@@ -35,6 +35,13 @@ QPC_TEMPLATEEXTERN template class QPC_EXPORT QMap<int, QString>;
#endif
-class ContactPrivate;
-
+class ContactPrivate;
+
+/**
+ * OContact class represents a specialised PIM Record for contacts.
+ * It does store all kind of persopn related information.
+ *
+ * @short Contact Container
+ * @author TT, Stefan Eiler, Holger Freyther
+ */
class QPC_EXPORT OContact : public OPimRecord
{
diff --git a/libopie2/opiepim/oevent.h b/libopie2/opiepim/oevent.h
index 585515c..57d32d0 100644
--- a/libopie2/opiepim/oevent.h
+++ b/libopie2/opiepim/oevent.h
@@ -31,7 +31,16 @@ struct OCalendarHelper {
class OPimNotifyManager;
class ORecur;
+
+/**
+ * This is the container for all Events. It encapsules all
+ * available information for a single Event
+ * @short container for events.
+ */
class OEvent : public OPimRecord {
public:
typedef QValueList<OEvent> ValueList;
+ /**
+ * RecordFields contain possible attributes
+ */
enum RecordFields {
Uid = Qtopia::UID_ID,
@@ -50,5 +59,12 @@ public:
};
+ /**
+ * Start with an Empty OEvent. UID == 0 means that it is empty
+ */
OEvent(int uid = 0);
+
+ /**
+ * copy c'tor
+ */
OEvent( const OEvent& );
~OEvent();
@@ -145,5 +161,4 @@ private:
* AN Event can span through multiple days. We split up a multiday eve
*/
-
class OEffectiveEvent {
public: