summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-11-16 19:14:18 (UTC)
committer mickeyl <mickeyl>2004-11-16 19:14:18 (UTC)
commitea3945a9bd8f9830f70b1efa133f9df13b19362f (patch) (unidiff)
treef2ea22cc50e9aa8aa73ee7dea148f41c563c9666
parent1c6f490e8541626f68422e0a3a7c7281d7f5b7d3 (diff)
downloadopie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.zip
opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.gz
opie-ea3945a9bd8f9830f70b1efa133f9df13b19362f.tar.bz2
libopie1 goes into unsupported
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/TODO16
-rw-r--r--libopie/ofileselector/.cvsignore1
-rw-r--r--libopie/pim/ABSTRACT18
-rw-r--r--libopie/pim/DESIGN56
-rw-r--r--libopie/pim/TODO34
-rw-r--r--libopie/pim/test/converter.cpp107
-rwxr-xr-xlibopie/pim/test/converter.h18
-rw-r--r--libopie/pim/test/converter.pro12
-rw-r--r--libopie/pim/test/converter_base.ui238
-rw-r--r--libopie/pim/test/oevent_test.cpp35
-rw-r--r--libopie/pim/test/oevent_test.pro11
-rw-r--r--libopie/pim/test/test_todo.cpp36
-rw-r--r--libopie/pim/test/todo_test.pro11
-rw-r--r--noncore/unsupported/libopie/.cvsignore (renamed from libopie/.cvsignore)0
-rw-r--r--noncore/unsupported/libopie/colordialog.cpp (renamed from libopie/colordialog.cpp)0
-rw-r--r--noncore/unsupported/libopie/colordialog.h (renamed from libopie/colordialog.h)0
-rw-r--r--noncore/unsupported/libopie/colorpopupmenu.cpp (renamed from libopie/colorpopupmenu.cpp)0
-rw-r--r--noncore/unsupported/libopie/colorpopupmenu.h (renamed from libopie/colorpopupmenu.h)0
-rw-r--r--noncore/unsupported/libopie/config.in (renamed from libopie/config.in)0
-rw-r--r--noncore/unsupported/libopie/libopie.pro (renamed from libopie/libopie.pro)0
-rw-r--r--noncore/unsupported/libopie/libopie1.control (renamed from libopie/libopie1.control)0
-rwxr-xr-xnoncore/unsupported/libopie/libopie1.postinst (renamed from libopie/libopie1.postinst)0
-rw-r--r--noncore/unsupported/libopie/oapplicationfactory.h (renamed from libopie/oapplicationfactory.h)0
-rw-r--r--noncore/unsupported/libopie/ocheckitem.cpp (renamed from libopie/ocheckitem.cpp)0
-rw-r--r--noncore/unsupported/libopie/ocheckitem.h (renamed from libopie/ocheckitem.h)0
-rw-r--r--noncore/unsupported/libopie/oclickablelabel.cpp (renamed from libopie/oclickablelabel.cpp)0
-rw-r--r--noncore/unsupported/libopie/oclickablelabel.h (renamed from libopie/oclickablelabel.h)0
-rw-r--r--noncore/unsupported/libopie/ocolorbutton.cpp (renamed from libopie/ocolorbutton.cpp)0
-rw-r--r--noncore/unsupported/libopie/ocolorbutton.h (renamed from libopie/ocolorbutton.h)0
-rw-r--r--noncore/unsupported/libopie/odevice.cpp (renamed from libopie/odevice.cpp)0
-rw-r--r--noncore/unsupported/libopie/odevice.h (renamed from libopie/odevice.h)0
-rw-r--r--noncore/unsupported/libopie/odevicebutton.cpp (renamed from libopie/odevicebutton.cpp)0
-rw-r--r--noncore/unsupported/libopie/odevicebutton.h (renamed from libopie/odevicebutton.h)0
-rw-r--r--noncore/unsupported/libopie/ofiledialog.cc (renamed from libopie/ofiledialog.cc)0
-rw-r--r--noncore/unsupported/libopie/ofiledialog.h (renamed from libopie/ofiledialog.h)0
-rw-r--r--noncore/unsupported/libopie/ofileselector.cpp (renamed from libopie/ofileselector.cpp)0
-rw-r--r--noncore/unsupported/libopie/ofileselector.h (renamed from libopie/ofileselector.h)0
-rw-r--r--noncore/unsupported/libopie/ofileselector_p.h (renamed from libopie/ofileselector_p.h)0
-rw-r--r--noncore/unsupported/libopie/ofileview.h (renamed from libopie/ofileview.h)0
-rw-r--r--noncore/unsupported/libopie/ofontmenu.cc (renamed from libopie/ofontmenu.cc)0
-rw-r--r--noncore/unsupported/libopie/ofontmenu.h (renamed from libopie/ofontmenu.h)0
-rw-r--r--noncore/unsupported/libopie/ofontselector.cpp (renamed from libopie/ofontselector.cpp)0
-rw-r--r--noncore/unsupported/libopie/ofontselector.h (renamed from libopie/ofontselector.h)0
-rw-r--r--noncore/unsupported/libopie/oprocctrl.cpp (renamed from libopie/oprocctrl.cpp)0
-rw-r--r--noncore/unsupported/libopie/oprocctrl.h (renamed from libopie/oprocctrl.h)0
-rw-r--r--noncore/unsupported/libopie/oprocess.cpp (renamed from libopie/oprocess.cpp)0
-rw-r--r--noncore/unsupported/libopie/oprocess.h (renamed from libopie/oprocess.h)0
-rw-r--r--noncore/unsupported/libopie/orecurrancebase.ui (renamed from libopie/orecurrancebase.ui)0
-rw-r--r--noncore/unsupported/libopie/orecurrancewidget.cpp (renamed from libopie/orecurrancewidget.cpp)0
-rw-r--r--noncore/unsupported/libopie/orecurrancewidget.h (renamed from libopie/orecurrancewidget.h)0
-rw-r--r--noncore/unsupported/libopie/otabbar.cpp (renamed from libopie/otabbar.cpp)0
-rw-r--r--noncore/unsupported/libopie/otabbar.h (renamed from libopie/otabbar.h)0
-rw-r--r--noncore/unsupported/libopie/otabinfo.h (renamed from libopie/otabinfo.h)0
-rw-r--r--noncore/unsupported/libopie/otabwidget.cpp (renamed from libopie/otabwidget.cpp)0
-rw-r--r--noncore/unsupported/libopie/otabwidget.h (renamed from libopie/otabwidget.h)0
-rw-r--r--noncore/unsupported/libopie/oticker.cpp (renamed from libopie/oticker.cpp)0
-rw-r--r--noncore/unsupported/libopie/oticker.h (renamed from libopie/oticker.h)0
-rw-r--r--noncore/unsupported/libopie/otimepicker.cpp (renamed from libopie/otimepicker.cpp)0
-rw-r--r--noncore/unsupported/libopie/otimepicker.h (renamed from libopie/otimepicker.h)0
-rw-r--r--noncore/unsupported/libopie/otimepickerbase.ui (renamed from libopie/otimepickerbase.ui)0
-rw-r--r--noncore/unsupported/libopie/owait.cpp (renamed from libopie/owait.cpp)0
-rw-r--r--noncore/unsupported/libopie/owait.h (renamed from libopie/owait.h)0
-rw-r--r--noncore/unsupported/libopie/pim/.cvsignore (renamed from libopie/pim/.cvsignore)0
-rw-r--r--noncore/unsupported/libopie/pim/config.in2
-rw-r--r--noncore/unsupported/libopie/pim/libopie.pro (renamed from libopie/pim/libopie.pro)0
-rw-r--r--noncore/unsupported/libopie/pim/obackendfactory.h (renamed from libopie/pim/obackendfactory.h)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontact.cpp (renamed from libopie/pim/ocontact.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/ocontact.h (renamed from libopie/pim/ocontact.h)0
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccess.cpp (renamed from libopie/pim/ocontactaccess.cpp)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccess.h (renamed from libopie/pim/ocontactaccess.h)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend.h (renamed from libopie/pim/ocontactaccessbackend.h)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.cpp (renamed from libopie/pim/ocontactaccessbackend_sql.cpp)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h (renamed from libopie/pim/ocontactaccessbackend_sql.h)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend_vcard.cpp (renamed from libopie/pim/ocontactaccessbackend_vcard.cpp)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend_vcard.h (renamed from libopie/pim/ocontactaccessbackend_vcard.h)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.cpp (renamed from libopie/pim/ocontactaccessbackend_xml.cpp)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h (renamed from libopie/pim/ocontactaccessbackend_xml.h)3
-rw-r--r--noncore/unsupported/libopie/pim/ocontactfields.cpp (renamed from libopie/pim/ocontactfields.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/ocontactfields.h (renamed from libopie/pim/ocontactfields.h)0
-rw-r--r--noncore/unsupported/libopie/pim/oconversion.cpp (renamed from libopie/pim/oconversion.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/oconversion.h (renamed from libopie/pim/oconversion.h)0
-rw-r--r--noncore/unsupported/libopie/pim/odatebookaccess.cpp (renamed from libopie/pim/odatebookaccess.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/odatebookaccess.h (renamed from libopie/pim/odatebookaccess.h)0
-rw-r--r--noncore/unsupported/libopie/pim/odatebookaccessbackend.cpp (renamed from libopie/pim/odatebookaccessbackend.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/odatebookaccessbackend.h (renamed from libopie/pim/odatebookaccessbackend.h)0
-rw-r--r--noncore/unsupported/libopie/pim/odatebookaccessbackend_sql.cpp (renamed from libopie/pim/odatebookaccessbackend_sql.cpp)3
-rw-r--r--noncore/unsupported/libopie/pim/odatebookaccessbackend_sql.h (renamed from libopie/pim/odatebookaccessbackend_sql.h)0
-rw-r--r--noncore/unsupported/libopie/pim/odatebookaccessbackend_xml.cpp (renamed from libopie/pim/odatebookaccessbackend_xml.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/odatebookaccessbackend_xml.h (renamed from libopie/pim/odatebookaccessbackend_xml.h)0
-rw-r--r--noncore/unsupported/libopie/pim/oevent.cpp (renamed from libopie/pim/oevent.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/oevent.h (renamed from libopie/pim/oevent.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimaccessbackend.h (renamed from libopie/pim/opimaccessbackend.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimaccesstemplate.h (renamed from libopie/pim/opimaccesstemplate.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimcache.h (renamed from libopie/pim/opimcache.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimmaintainer.cpp (renamed from libopie/pim/opimmaintainer.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimmaintainer.h (renamed from libopie/pim/opimmaintainer.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimmainwindow.cpp (renamed from libopie/pim/opimmainwindow.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimmainwindow.h (renamed from libopie/pim/opimmainwindow.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimnotify.cpp (renamed from libopie/pim/opimnotify.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimnotify.h (renamed from libopie/pim/opimnotify.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimnotifymanager.cpp (renamed from libopie/pim/opimnotifymanager.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimnotifymanager.h (renamed from libopie/pim/opimnotifymanager.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimrecord.cpp (renamed from libopie/pim/opimrecord.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimrecord.h (renamed from libopie/pim/opimrecord.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimresolver.cpp (renamed from libopie/pim/opimresolver.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimresolver.h (renamed from libopie/pim/opimresolver.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimstate.cpp (renamed from libopie/pim/opimstate.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimstate.h (renamed from libopie/pim/opimstate.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimxref.cpp (renamed from libopie/pim/opimxref.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimxref.h (renamed from libopie/pim/opimxref.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimxrefmanager.cpp (renamed from libopie/pim/opimxrefmanager.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimxrefmanager.h (renamed from libopie/pim/opimxrefmanager.h)0
-rw-r--r--noncore/unsupported/libopie/pim/opimxrefpartner.cpp (renamed from libopie/pim/opimxrefpartner.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/opimxrefpartner.h (renamed from libopie/pim/opimxrefpartner.h)0
-rw-r--r--noncore/unsupported/libopie/pim/orecordlist.h (renamed from libopie/pim/orecordlist.h)0
-rw-r--r--noncore/unsupported/libopie/pim/orecur.cpp (renamed from libopie/pim/orecur.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/orecur.h (renamed from libopie/pim/orecur.h)0
-rw-r--r--noncore/unsupported/libopie/pim/otemplatebase.h (renamed from libopie/pim/otemplatebase.h)0
-rw-r--r--noncore/unsupported/libopie/pim/otimezone.cpp (renamed from libopie/pim/otimezone.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/otimezone.h (renamed from libopie/pim/otimezone.h)0
-rw-r--r--noncore/unsupported/libopie/pim/otodo.cpp (renamed from libopie/pim/otodo.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/otodo.h (renamed from libopie/pim/otodo.h)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccess.cpp (renamed from libopie/pim/otodoaccess.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccess.h (renamed from libopie/pim/otodoaccess.h)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccessbackend.cpp (renamed from libopie/pim/otodoaccessbackend.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccessbackend.h (renamed from libopie/pim/otodoaccessbackend.h)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccesssql.cpp (renamed from libopie/pim/otodoaccesssql.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccesssql.h (renamed from libopie/pim/otodoaccesssql.h)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccessvcal.cpp (renamed from libopie/pim/otodoaccessvcal.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccessvcal.h (renamed from libopie/pim/otodoaccessvcal.h)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccessxml.cpp (renamed from libopie/pim/otodoaccessxml.cpp)0
-rw-r--r--noncore/unsupported/libopie/pim/otodoaccessxml.h (renamed from libopie/pim/otodoaccessxml.h)0
-rw-r--r--noncore/unsupported/libopie/sharp_compat.cpp (renamed from libopie/sharp_compat.cpp)0
-rw-r--r--noncore/unsupported/libopie/todayconfigwidget.h (renamed from libopie/todayconfigwidget.h)0
-rw-r--r--noncore/unsupported/libopie/todayplugininterface.h (renamed from libopie/todayplugininterface.h)0
-rw-r--r--noncore/unsupported/libopie/xmltree.cc (renamed from libopie/xmltree.cc)0
-rw-r--r--noncore/unsupported/libopie/xmltree.h (renamed from libopie/xmltree.h)0
137 files changed, 35 insertions, 593 deletions
diff --git a/libopie/TODO b/libopie/TODO
deleted file mode 100644
index 9607fde..0000000
--- a/libopie/TODO
+++ b/dev/null
@@ -1,16 +0,0 @@
1- xmltree done
2
3- tododb
4 - set Alarms
5
6- OFileSelector
7 - m_mimeCheck always shows the first icon
8 - mimetype selection broken
9 - when changing dirs the mimetype selections get messed up
10 - DocLnk when not in Document Mode ( and vice versa )
11 - MultipleDocuments
12 - Move OFileSelectorItem to it's own files
13 - new Dirs created inside the listview
14
15- Clickable labels?
16 committed \ No newline at end of file
diff --git a/libopie/ofileselector/.cvsignore b/libopie/ofileselector/.cvsignore
deleted file mode 100644
index 6d678c6..0000000
--- a/libopie/ofileselector/.cvsignore
+++ b/dev/null
@@ -1 +0,0 @@
1config.in
diff --git a/libopie/pim/ABSTRACT b/libopie/pim/ABSTRACT
deleted file mode 100644
index 5538d19..0000000
--- a/libopie/pim/ABSTRACT
+++ b/dev/null
@@ -1,18 +0,0 @@
1What is Opie PIM? Why is it special?
2Why do we need Opie PIM?
3
4The goal of OpiePIM is to be first of all
5extendable, light weight, scalable and fast.
6For the programmer we try to add a nice but
7powerful API to all classes.
8
9Memory is a costy resource on small and embedded
10devices. So we try to keep the memory usage as
11low as possible. Never the less we won't use structs
12and Pointers in the public API.
13The whole pim framework is value based. Internally we try
14to use implicit sharing as found in other Qt classes as well.
15This makes it possible to give 3rd party devels a nice
16API while keeping the memory usage as low as possible.
17
18We use C++ Templates
diff --git a/libopie/pim/DESIGN b/libopie/pim/DESIGN
deleted file mode 100644
index bd92b1b..0000000
--- a/libopie/pim/DESIGN
+++ b/dev/null
@@ -1,56 +0,0 @@
1Hija to the DESIGN of our OPIE PIM stuff
2
3This design was firstly discussed in the train
4from Frankfurt to Hannover between me (zecke ) and eilers.
5
6We had a look at our pim implementation and the one from
7trolltech and we looked what was missing.
8
9GOALS:
10 - clean implementation
11 - share code
12 - ObjectOriented Design
13 - Scalable
14 - Integration into common solutions like STL and Qt
15 - Addition
16 - Ease of Use
17
18GENERAL:
19 - use templates
20 - have a common base class for all Records OPimRecord
21 - use references instead of pointers
22 - make use of QShared internally memory consumption
23
24We've a 'public' and 'private' part in our lib
25OPimAccessTemplate is the public part. This will be used
26by 3rd party developers to access the PIMs.
27OPimAccessBackend is the backend. You could also call it
28resource.
29
30Both things need to be implemented for different kind of records.
31By using templates we can make sure we share code and the reason
32not to use simple inheretance is that we can specialise quite easy.
33
34For example we have OTodoAccess : public OPimAccessTemplate<OTodo>;
35the we would do
36OTodoAccess::List list = otodoAccess.all();
37OTodoAccess::List::Iterator it;
38for( it = list.begin(); it != list.end(); ++it );
39
40
41as you can see from here it just behaves like you expect from Qt or STL.
42
43The kewlest thing is that List and List::Iterator is free to use if you
44want to implement your own OPimAccessTemplate.
45You just have to sub class it and voila you're done
46
47
48Hope you enjoy using OPIE PIM
49
50regards Holger 'zecke' Freyther
51
52
53
54
55
56
diff --git a/libopie/pim/TODO b/libopie/pim/TODO
deleted file mode 100644
index 9bd2789..0000000
--- a/libopie/pim/TODO
+++ b/dev/null
@@ -1,34 +0,0 @@
1-Add XML Index ( dropped )
2-Add ReadOnly Resources ( to be discussed )
3-Add Sorted/Random Access mode for faster access to the base ( to be discussed )
4
5Yeah Stefan you're right I need to stop the fragmentation but these are just ideas
6we not to talk about.
7
8New Ideas Widgets:
9 OCategoryPopup:
10 Like the function Menu in Xemacs. If there are too many
11 Categories sort them into sub popups. A-B,B-G,H-K....
12 Integrate SUbcategories
13
14
15New Ideas on Infrastructure:
16 -finally switch to sqlite
17 -rework Category Sub Categories
18 -X-Ref!!!!!
19 -signalling ( Peer to Peer/ Backend to Backend communication of changes on a file basis )
20 -Signal the User about updates. Use QSignal and make it generic push from backend
21 to the access.
22 -flocking, mmapping
23 -Generic Tablewidget, getting QString for a record and attribute ( generic ) like QProperty
24 -chooser widgets
25 -hierachies
26 -multiple backends
27 -public private sort public and private on backends. default backend for each if multiple
28 backends loaded. Move from backend to backend.. ( backend mover app? )
29 -importer/exporter
30 -check if cache also drops
31 -port to BigSize Api
32
33 ORedoManager ORedoItem both are templates to allow undoing and redoing to a level...
34 \ No newline at end of file
diff --git a/libopie/pim/test/converter.cpp b/libopie/pim/test/converter.cpp
deleted file mode 100644
index bfdb605..0000000
--- a/libopie/pim/test/converter.cpp
+++ b/dev/null
@@ -1,107 +0,0 @@
1#include "converter.h"
2
3#include <qdatetime.h>
4#include <qprogressbar.h>
5
6#include <qpe/qpeapplication.h>
7
8#include <opie/ocontactaccess.h>
9#include <opie/ocontactaccessbackend_xml.h>
10#include <opie/ocontactaccessbackend_sql.h>
11
12#include <opie/odatebookaccess.h>
13#include <opie/odatebookaccessbackend_xml.h>
14#include <opie/odatebookaccessbackend_sql.h>
15
16// #define _ADDRESSBOOK_ACCESS
17
18Converter::Converter(){
19}
20
21void Converter::start_conversion(){
22 qWarning("Converting Contacts from XML to SQL..");
23
24 // Creating backends to the requested databases..
25
26#ifdef _ADDRESSBOOK_ACCESS
27 OContactAccessBackend* xmlBackend = new OContactAccessBackend_XML( "Converter",
28 QString::null );
29
30 OContactAccessBackend* sqlBackend = new OContactAccessBackend_SQL( QString::null,
31 QString::null );
32 // Put the created backends into frontends to access them
33 OContactAccess* xmlAccess = new OContactAccess ( "addressbook_xml",
34 QString::null , xmlBackend, true );
35
36 OContactAccess* sqlAccess = new OContactAccess ( "addressbook_sql",
37 QString::null );
38
39#else
40 ODateBookAccessBackend* xmlBackend = new ODateBookAccessBackend_XML( "Converter",
41 QString::null );
42
43 ODateBookAccessBackend* sqlBackend = new ODateBookAccessBackend_SQL( QString::null,
44 QString::null );
45 // Put the created backends into frontends to access them
46 ODateBookAccess* xmlAccess = new ODateBookAccess ( xmlBackend );
47
48 ODateBookAccess* sqlAccess = new ODateBookAccess ( sqlBackend );
49
50 xmlAccess->load();
51
52#endif
53
54 QTime t;
55 t.start();
56
57// Clean the sql-database..
58 sqlAccess->clear();
59
60#ifdef _ADDRESSBOOK_ACCESS
61 // Now trasmit every contact from the xml database to the sql-database
62 OContactAccess::List contactList = xmlAccess->allRecords();
63 m_progressBar->setTotalSteps( contactList.count() );
64 int count = 0;
65 if ( sqlAccess && xmlAccess ){
66 OContactAccess::List::Iterator it;
67 for ( it = contactList.begin(); it != contactList.end(); ++it ){
68 sqlAccess->add( *it );
69 m_progressBar->setProgress( ++count );
70 }
71 }
72#else
73 // Now transmit every contact from the xml database to the sql-database
74 ODateBookAccess::List dateList = xmlAccess->allRecords();
75 m_progressBar->setTotalSteps( dateList.count() );
76 qWarning( "Number of elements to copy: %d", dateList.count() );
77
78 int count = 0;
79 if ( sqlAccess && xmlAccess ){
80 ODateBookAccess::List::Iterator it;
81 for ( it = dateList.begin(); it != dateList.end(); ++it ){
82 sqlAccess->add( *it );
83 m_progressBar->setProgress( ++count );
84 }
85 }
86
87 #endif
88 // Delete the frontends. Backends will be deleted automatically, too !
89 delete sqlAccess;
90
91 qWarning("Conversion is finished and needed %d ms !", t.elapsed());
92
93 delete xmlAccess;
94}
95
96int main( int argc, char** argv ) {
97
98 QPEApplication a( argc, argv );
99
100 Converter dlg;
101
102 a.showMainWidget( &dlg );
103 // dlg. showMaximized ( );
104
105 return a.exec();
106
107}
diff --git a/libopie/pim/test/converter.h b/libopie/pim/test/converter.h
deleted file mode 100755
index 1cc2a7c..0000000
--- a/libopie/pim/test/converter.h
+++ b/dev/null
@@ -1,18 +0,0 @@
1#ifndef _CONVERTER_H_
2#define _CONVERTER_H_
3
4
5#include "converter_base.h"
6
7
8class Converter: public converter_base {
9public:
10 Converter();
11
12 void start_conversion();
13private:
14
15};
16
17
18#endif
diff --git a/libopie/pim/test/converter.pro b/libopie/pim/test/converter.pro
deleted file mode 100644
index bd9c7a3..0000000
--- a/libopie/pim/test/converter.pro
+++ b/dev/null
@@ -1,12 +0,0 @@
1 # TEMPLATE= app
2 CONFIG = qt warn_on debug
3 # CONFIG = qt warn_on release
4 #HEADERS =
5 SOURCES = converter.cpp
6INTERFACES = converter_base.ui
7 INCLUDEPATH+= $(OPIEDIR)/include
8 DEPENDPATH+= $(OPIEDIR)/include
9LIBS += -lqpe -lopie
10 TARGET = converter
11
12include ( $(OPIEDIR)/include.pro )
diff --git a/libopie/pim/test/converter_base.ui b/libopie/pim/test/converter_base.ui
deleted file mode 100644
index e9bf636..0000000
--- a/libopie/pim/test/converter_base.ui
+++ b/dev/null
@@ -1,238 +0,0 @@
1<!DOCTYPE UI><UI>
2<class>converter_base</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>converter_base</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>273</width>
15 <height>324</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>PIM-Database Converter</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <grid>
26 <property stdset="1">
27 <name>margin</name>
28 <number>4</number>
29 </property>
30 <property stdset="1">
31 <name>spacing</name>
32 <number>6</number>
33 </property>
34 <widget row="0" column="0" >
35 <class>QGroupBox</class>
36 <property stdset="1">
37 <name>name</name>
38 <cstring>GroupBox6</cstring>
39 </property>
40 <property stdset="1">
41 <name>title</name>
42 <string>Converter</string>
43 </property>
44 <property>
45 <name>layoutMargin</name>
46 </property>
47 <property>
48 <name>layoutSpacing</name>
49 </property>
50 <vbox>
51 <property stdset="1">
52 <name>margin</name>
53 <number>4</number>
54 </property>
55 <property stdset="1">
56 <name>spacing</name>
57 <number>4</number>
58 </property>
59 <widget>
60 <class>QGroupBox</class>
61 <property stdset="1">
62 <name>name</name>
63 <cstring>GroupBox1</cstring>
64 </property>
65 <property stdset="1">
66 <name>title</name>
67 <string>Select Database:</string>
68 </property>
69 <grid>
70 <property stdset="1">
71 <name>margin</name>
72 <number>11</number>
73 </property>
74 <property stdset="1">
75 <name>spacing</name>
76 <number>6</number>
77 </property>
78 <widget row="0" column="1" >
79 <class>QComboBox</class>
80 <item>
81 <property>
82 <name>text</name>
83 <string>Addressbook</string>
84 </property>
85 </item>
86 <item>
87 <property>
88 <name>text</name>
89 <string>TodoList</string>
90 </property>
91 </item>
92 <property stdset="1">
93 <name>name</name>
94 <cstring>ComboBox1</cstring>
95 </property>
96 </widget>
97 </grid>
98 </widget>
99 <widget>
100 <class>QGroupBox</class>
101 <property stdset="1">
102 <name>name</name>
103 <cstring>GroupBox2</cstring>
104 </property>
105 <property stdset="1">
106 <name>title</name>
107 <string>Source/Destination:</string>
108 </property>
109 <grid>
110 <property stdset="1">
111 <name>margin</name>
112 <number>11</number>
113 </property>
114 <property stdset="1">
115 <name>spacing</name>
116 <number>6</number>
117 </property>
118 <widget row="1" column="0" >
119 <class>QLabel</class>
120 <property stdset="1">
121 <name>name</name>
122 <cstring>TextLabel3_2</cstring>
123 </property>
124 <property stdset="1">
125 <name>text</name>
126 <string>to</string>
127 </property>
128 </widget>
129 <widget row="1" column="1" >
130 <class>QComboBox</class>
131 <item>
132 <property>
133 <name>text</name>
134 <string>Select</string>
135 </property>
136 </item>
137 <item>
138 <property>
139 <name>text</name>
140 <string>XML</string>
141 </property>
142 </item>
143 <item>
144 <property>
145 <name>text</name>
146 <string>SQL (SQLite)</string>
147 </property>
148 </item>
149 <property stdset="1">
150 <name>name</name>
151 <cstring>ComboBox2_3</cstring>
152 </property>
153 </widget>
154 <widget row="0" column="0" >
155 <class>QLabel</class>
156 <property stdset="1">
157 <name>name</name>
158 <cstring>TextLabel2_2</cstring>
159 </property>
160 <property stdset="1">
161 <name>text</name>
162 <string>Convert from</string>
163 </property>
164 </widget>
165 <widget row="0" column="1" >
166 <class>QComboBox</class>
167 <item>
168 <property>
169 <name>text</name>
170 <string>XML</string>
171 </property>
172 </item>
173 <item>
174 <property>
175 <name>text</name>
176 <string>SQL (SQLite)</string>
177 </property>
178 </item>
179 <property stdset="1">
180 <name>name</name>
181 <cstring>ComboBox2_2_2</cstring>
182 </property>
183 </widget>
184 </grid>
185 </widget>
186 <widget>
187 <class>QGroupBox</class>
188 <property stdset="1">
189 <name>name</name>
190 <cstring>GroupBox4</cstring>
191 </property>
192 <property stdset="1">
193 <name>title</name>
194 <string>Progress:</string>
195 </property>
196 <grid>
197 <property stdset="1">
198 <name>margin</name>
199 <number>11</number>
200 </property>
201 <property stdset="1">
202 <name>spacing</name>
203 <number>6</number>
204 </property>
205 <widget row="0" column="0" >
206 <class>QProgressBar</class>
207 <property stdset="1">
208 <name>name</name>
209 <cstring>m_progressBar</cstring>
210 </property>
211 </widget>
212 </grid>
213 </widget>
214 <widget>
215 <class>QPushButton</class>
216 <property stdset="1">
217 <name>name</name>
218 <cstring>PushButton1</cstring>
219 </property>
220 <property stdset="1">
221 <name>text</name>
222 <string>Go!</string>
223 </property>
224 </widget>
225 </vbox>
226 </widget>
227 </grid>
228</widget>
229<connections>
230 <connection>
231 <sender>PushButton1</sender>
232 <signal>clicked()</signal>
233 <receiver>converter_base</receiver>
234 <slot>start_conversion()</slot>
235 </connection>
236 <slot access="public">start_conversion()</slot>
237</connections>
238</UI>
diff --git a/libopie/pim/test/oevent_test.cpp b/libopie/pim/test/oevent_test.cpp
deleted file mode 100644
index 9f16911..0000000
--- a/libopie/pim/test/oevent_test.cpp
+++ b/dev/null
@@ -1,35 +0,0 @@
1#include <qdatetime.h>
2
3#include "../oevent.h"
4#include "../odatebookaccess.h"
5
6int main(int argc, char* argv ) {
7 ODateBookAccess acc;
8 if(!acc.load() ) qWarning("could not load");
9
10 ODateBookAccess::List::Iterator it;
11 ODateBookAccess::List list = acc.allRecords();
12
13 for( it = list.begin(); it != list.end(); ++it ){
14 OEvent ev = (*it);
15 qWarning("Summary: %s",ev.description().latin1() );
16 qWarning("Start: %s End: %s",ev.startDateTime().toString().latin1(), ev.endDateTime().toString().latin1() );
17 qWarning("All Day: %d Recurrence: %d",ev.isAllDay(), ev.hasRecurrence() );
18 qWarning("UID %d", ev.uid() );
19
20 }
21 QDate date1(2003,02,01 );
22 QDate date2(2003,03,01 );
23
24 OEffectiveEvent::ValueList effList = acc.effectiveEvents( date1,date2 );
25 OEffectiveEvent::ValueList::Iterator effIt;
26
27 for( effIt = effList.begin(); effIt != effList.end(); ++effIt ){
28 OEffectiveEvent ef = (*effIt);
29 qWarning("Summary: %s", ef.description().latin1() );
30 qWarning("Date: %s", ef.date().toString().latin1() );
31 }
32 acc.save();
33
34 return 0;
35}
diff --git a/libopie/pim/test/oevent_test.pro b/libopie/pim/test/oevent_test.pro
deleted file mode 100644
index 3365def..0000000
--- a/libopie/pim/test/oevent_test.pro
+++ b/dev/null
@@ -1,11 +0,0 @@
1 TEMPLATE= app
2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release
4 #HEADERS =
5 SOURCES = oevent_test.cpp
6 INCLUDEPATH+= $(OPIEDIR)/include
7 DEPENDPATH+= $(OPIEDIR)/include
8LIBS += -lqpe -lopie
9 TARGET = oevent_test
10
11include ( $(OPIEDIR)/include.pro ) \ No newline at end of file
diff --git a/libopie/pim/test/test_todo.cpp b/libopie/pim/test/test_todo.cpp
deleted file mode 100644
index 7440503..0000000
--- a/libopie/pim/test/test_todo.cpp
+++ b/dev/null
@@ -1,36 +0,0 @@
1#include <qdatetime.h>
2#include <qmap.h>
3
4#include <opie/otodo.h>
5#include <opie/otodoaccess.h>
6#include <opie/otodoaccessxml.h>
7
8int main(int argc, char* argv[] ) {
9
10 OTodoAccessXML* xml = new OTodoAccessXML("demo");
11 OTodoAccess ac(xml);
12 int elc;
13 QTime timer;
14 qWarning("start loading");
15 timer.start();
16 ac.load();
17 elc = timer.elapsed();
18 qWarning("Elapsed loading %d %d", elc, elc/1000);
19
20 timer.start();
21 OTodoAccess::List lis = ac.allRecords();
22 elc = timer.elapsed();
23 qWarning("Elapsed allRecords %d %d", elc, elc/1000 );
24 OTodoAccess::List::Iterator it;
25 timer.start();
26ac.save();
27/*
28 for( it = lis.begin(); it != lis.end(); ++it ) {
29 qWarning("Desc: " + (*it).summary() );
30 qWarning("UID %d", (*it).uid() );
31 }
32 */
33elc = timer.elapsed();
34
35 qWarning("elapsed iterating %d %d", elc, elc/1000 );
36};
diff --git a/libopie/pim/test/todo_test.pro b/libopie/pim/test/todo_test.pro
deleted file mode 100644
index 3d14dda..0000000
--- a/libopie/pim/test/todo_test.pro
+++ b/dev/null
@@ -1,11 +0,0 @@
1 TEMPLATE= app
2 #CONFIG = qt warn_on debug
3 CONFIG = qt warn_on release
4 #HEADERS =
5 SOURCES = test_todo.cpp
6 INCLUDEPATH+= $(OPIEDIR)/include
7 DEPENDPATH+= $(OPIEDIR)/include
8LIBS += -lqpe -lopie -lopiesql
9 TARGET = todo_test
10
11include ( $(OPIEDIR)/ ) \ No newline at end of file
diff --git a/libopie/.cvsignore b/noncore/unsupported/libopie/.cvsignore
index f76e42e..f76e42e 100644
--- a/libopie/.cvsignore
+++ b/noncore/unsupported/libopie/.cvsignore
diff --git a/libopie/colordialog.cpp b/noncore/unsupported/libopie/colordialog.cpp
index b2854a6..b2854a6 100644
--- a/libopie/colordialog.cpp
+++ b/noncore/unsupported/libopie/colordialog.cpp
diff --git a/libopie/colordialog.h b/noncore/unsupported/libopie/colordialog.h
index c825a83..c825a83 100644
--- a/libopie/colordialog.h
+++ b/noncore/unsupported/libopie/colordialog.h
diff --git a/libopie/colorpopupmenu.cpp b/noncore/unsupported/libopie/colorpopupmenu.cpp
index 03ad233..03ad233 100644
--- a/libopie/colorpopupmenu.cpp
+++ b/noncore/unsupported/libopie/colorpopupmenu.cpp
diff --git a/libopie/colorpopupmenu.h b/noncore/unsupported/libopie/colorpopupmenu.h
index 98d67cc..98d67cc 100644
--- a/libopie/colorpopupmenu.h
+++ b/noncore/unsupported/libopie/colorpopupmenu.h
diff --git a/libopie/config.in b/noncore/unsupported/libopie/config.in
index e8bc2e2..e8bc2e2 100644
--- a/libopie/config.in
+++ b/noncore/unsupported/libopie/config.in
diff --git a/libopie/libopie.pro b/noncore/unsupported/libopie/libopie.pro
index 783c11d..783c11d 100644
--- a/libopie/libopie.pro
+++ b/noncore/unsupported/libopie/libopie.pro
diff --git a/libopie/libopie1.control b/noncore/unsupported/libopie/libopie1.control
index 5b6825e..5b6825e 100644
--- a/libopie/libopie1.control
+++ b/noncore/unsupported/libopie/libopie1.control
diff --git a/libopie/libopie1.postinst b/noncore/unsupported/libopie/libopie1.postinst
index 0c37b3d..0c37b3d 100755
--- a/libopie/libopie1.postinst
+++ b/noncore/unsupported/libopie/libopie1.postinst
diff --git a/libopie/oapplicationfactory.h b/noncore/unsupported/libopie/oapplicationfactory.h
index ab88d80..ab88d80 100644
--- a/libopie/oapplicationfactory.h
+++ b/noncore/unsupported/libopie/oapplicationfactory.h
diff --git a/libopie/ocheckitem.cpp b/noncore/unsupported/libopie/ocheckitem.cpp
index cd763c1..cd763c1 100644
--- a/libopie/ocheckitem.cpp
+++ b/noncore/unsupported/libopie/ocheckitem.cpp
diff --git a/libopie/ocheckitem.h b/noncore/unsupported/libopie/ocheckitem.h
index 82ee3d0..82ee3d0 100644
--- a/libopie/ocheckitem.h
+++ b/noncore/unsupported/libopie/ocheckitem.h
diff --git a/libopie/oclickablelabel.cpp b/noncore/unsupported/libopie/oclickablelabel.cpp
index bc7037b..bc7037b 100644
--- a/libopie/oclickablelabel.cpp
+++ b/noncore/unsupported/libopie/oclickablelabel.cpp
diff --git a/libopie/oclickablelabel.h b/noncore/unsupported/libopie/oclickablelabel.h
index f93ade0..f93ade0 100644
--- a/libopie/oclickablelabel.h
+++ b/noncore/unsupported/libopie/oclickablelabel.h
diff --git a/libopie/ocolorbutton.cpp b/noncore/unsupported/libopie/ocolorbutton.cpp
index 298dba2..298dba2 100644
--- a/libopie/ocolorbutton.cpp
+++ b/noncore/unsupported/libopie/ocolorbutton.cpp
diff --git a/libopie/ocolorbutton.h b/noncore/unsupported/libopie/ocolorbutton.h
index 6196c83..6196c83 100644
--- a/libopie/ocolorbutton.h
+++ b/noncore/unsupported/libopie/ocolorbutton.h
diff --git a/libopie/odevice.cpp b/noncore/unsupported/libopie/odevice.cpp
index 9d0bbbf..9d0bbbf 100644
--- a/libopie/odevice.cpp
+++ b/noncore/unsupported/libopie/odevice.cpp
diff --git a/libopie/odevice.h b/noncore/unsupported/libopie/odevice.h
index fc41079..fc41079 100644
--- a/libopie/odevice.h
+++ b/noncore/unsupported/libopie/odevice.h
diff --git a/libopie/odevicebutton.cpp b/noncore/unsupported/libopie/odevicebutton.cpp
index 647ac4b..647ac4b 100644
--- a/libopie/odevicebutton.cpp
+++ b/noncore/unsupported/libopie/odevicebutton.cpp
diff --git a/libopie/odevicebutton.h b/noncore/unsupported/libopie/odevicebutton.h
index 1621526..1621526 100644
--- a/libopie/odevicebutton.h
+++ b/noncore/unsupported/libopie/odevicebutton.h
diff --git a/libopie/ofiledialog.cc b/noncore/unsupported/libopie/ofiledialog.cc
index 47306b6..47306b6 100644
--- a/libopie/ofiledialog.cc
+++ b/noncore/unsupported/libopie/ofiledialog.cc
diff --git a/libopie/ofiledialog.h b/noncore/unsupported/libopie/ofiledialog.h
index 3b905c0..3b905c0 100644
--- a/libopie/ofiledialog.h
+++ b/noncore/unsupported/libopie/ofiledialog.h
diff --git a/libopie/ofileselector.cpp b/noncore/unsupported/libopie/ofileselector.cpp
index 2a6aed0..2a6aed0 100644
--- a/libopie/ofileselector.cpp
+++ b/noncore/unsupported/libopie/ofileselector.cpp
diff --git a/libopie/ofileselector.h b/noncore/unsupported/libopie/ofileselector.h
index 767455c..767455c 100644
--- a/libopie/ofileselector.h
+++ b/noncore/unsupported/libopie/ofileselector.h
diff --git a/libopie/ofileselector_p.h b/noncore/unsupported/libopie/ofileselector_p.h
index 7fd0c50..7fd0c50 100644
--- a/libopie/ofileselector_p.h
+++ b/noncore/unsupported/libopie/ofileselector_p.h
diff --git a/libopie/ofileview.h b/noncore/unsupported/libopie/ofileview.h
index e072477..e072477 100644
--- a/libopie/ofileview.h
+++ b/noncore/unsupported/libopie/ofileview.h
diff --git a/libopie/ofontmenu.cc b/noncore/unsupported/libopie/ofontmenu.cc
index d16c5e5..d16c5e5 100644
--- a/libopie/ofontmenu.cc
+++ b/noncore/unsupported/libopie/ofontmenu.cc
diff --git a/libopie/ofontmenu.h b/noncore/unsupported/libopie/ofontmenu.h
index 6e143ca..6e143ca 100644
--- a/libopie/ofontmenu.h
+++ b/noncore/unsupported/libopie/ofontmenu.h
diff --git a/libopie/ofontselector.cpp b/noncore/unsupported/libopie/ofontselector.cpp
index 87b7869..87b7869 100644
--- a/libopie/ofontselector.cpp
+++ b/noncore/unsupported/libopie/ofontselector.cpp
diff --git a/libopie/ofontselector.h b/noncore/unsupported/libopie/ofontselector.h
index b819c45..b819c45 100644
--- a/libopie/ofontselector.h
+++ b/noncore/unsupported/libopie/ofontselector.h
diff --git a/libopie/oprocctrl.cpp b/noncore/unsupported/libopie/oprocctrl.cpp
index df8da1e..df8da1e 100644
--- a/libopie/oprocctrl.cpp
+++ b/noncore/unsupported/libopie/oprocctrl.cpp
diff --git a/libopie/oprocctrl.h b/noncore/unsupported/libopie/oprocctrl.h
index 5b39490..5b39490 100644
--- a/libopie/oprocctrl.h
+++ b/noncore/unsupported/libopie/oprocctrl.h
diff --git a/libopie/oprocess.cpp b/noncore/unsupported/libopie/oprocess.cpp
index c19881a..c19881a 100644
--- a/libopie/oprocess.cpp
+++ b/noncore/unsupported/libopie/oprocess.cpp
diff --git a/libopie/oprocess.h b/noncore/unsupported/libopie/oprocess.h
index af7cddb..af7cddb 100644
--- a/libopie/oprocess.h
+++ b/noncore/unsupported/libopie/oprocess.h
diff --git a/libopie/orecurrancebase.ui b/noncore/unsupported/libopie/orecurrancebase.ui
index baf79d3..baf79d3 100644
--- a/libopie/orecurrancebase.ui
+++ b/noncore/unsupported/libopie/orecurrancebase.ui
diff --git a/libopie/orecurrancewidget.cpp b/noncore/unsupported/libopie/orecurrancewidget.cpp
index 33be269..33be269 100644
--- a/libopie/orecurrancewidget.cpp
+++ b/noncore/unsupported/libopie/orecurrancewidget.cpp
diff --git a/libopie/orecurrancewidget.h b/noncore/unsupported/libopie/orecurrancewidget.h
index 37a57f0..37a57f0 100644
--- a/libopie/orecurrancewidget.h
+++ b/noncore/unsupported/libopie/orecurrancewidget.h
diff --git a/libopie/otabbar.cpp b/noncore/unsupported/libopie/otabbar.cpp
index 52621ca..52621ca 100644
--- a/libopie/otabbar.cpp
+++ b/noncore/unsupported/libopie/otabbar.cpp
diff --git a/libopie/otabbar.h b/noncore/unsupported/libopie/otabbar.h
index 668187b..668187b 100644
--- a/libopie/otabbar.h
+++ b/noncore/unsupported/libopie/otabbar.h
diff --git a/libopie/otabinfo.h b/noncore/unsupported/libopie/otabinfo.h
index 00bb06d..00bb06d 100644
--- a/libopie/otabinfo.h
+++ b/noncore/unsupported/libopie/otabinfo.h
diff --git a/libopie/otabwidget.cpp b/noncore/unsupported/libopie/otabwidget.cpp
index 52190b2..52190b2 100644
--- a/libopie/otabwidget.cpp
+++ b/noncore/unsupported/libopie/otabwidget.cpp
diff --git a/libopie/otabwidget.h b/noncore/unsupported/libopie/otabwidget.h
index 047eaa1..047eaa1 100644
--- a/libopie/otabwidget.h
+++ b/noncore/unsupported/libopie/otabwidget.h
diff --git a/libopie/oticker.cpp b/noncore/unsupported/libopie/oticker.cpp
index b41cab6..b41cab6 100644
--- a/libopie/oticker.cpp
+++ b/noncore/unsupported/libopie/oticker.cpp
diff --git a/libopie/oticker.h b/noncore/unsupported/libopie/oticker.h
index 45bf7ce..45bf7ce 100644
--- a/libopie/oticker.h
+++ b/noncore/unsupported/libopie/oticker.h
diff --git a/libopie/otimepicker.cpp b/noncore/unsupported/libopie/otimepicker.cpp
index 11b80ed..11b80ed 100644
--- a/libopie/otimepicker.cpp
+++ b/noncore/unsupported/libopie/otimepicker.cpp
diff --git a/libopie/otimepicker.h b/noncore/unsupported/libopie/otimepicker.h
index 8df7d10..8df7d10 100644
--- a/libopie/otimepicker.h
+++ b/noncore/unsupported/libopie/otimepicker.h
diff --git a/libopie/otimepickerbase.ui b/noncore/unsupported/libopie/otimepickerbase.ui
index 3e7f2fb..3e7f2fb 100644
--- a/libopie/otimepickerbase.ui
+++ b/noncore/unsupported/libopie/otimepickerbase.ui
diff --git a/libopie/owait.cpp b/noncore/unsupported/libopie/owait.cpp
index a0f3834..a0f3834 100644
--- a/libopie/owait.cpp
+++ b/noncore/unsupported/libopie/owait.cpp
diff --git a/libopie/owait.h b/noncore/unsupported/libopie/owait.h
index cbfc8d6..cbfc8d6 100644
--- a/libopie/owait.h
+++ b/noncore/unsupported/libopie/owait.h
diff --git a/libopie/pim/.cvsignore b/noncore/unsupported/libopie/pim/.cvsignore
index aef62c4..aef62c4 100644
--- a/libopie/pim/.cvsignore
+++ b/noncore/unsupported/libopie/pim/.cvsignore
diff --git a/noncore/unsupported/libopie/pim/config.in b/noncore/unsupported/libopie/pim/config.in
new file mode 100644
index 0000000..95d3737
--- a/dev/null
+++ b/noncore/unsupported/libopie/pim/config.in
@@ -0,0 +1,2 @@
1menu "Pim"
2endmenu
diff --git a/libopie/pim/libopie.pro b/noncore/unsupported/libopie/pim/libopie.pro
index 62f235d..62f235d 100644
--- a/libopie/pim/libopie.pro
+++ b/noncore/unsupported/libopie/pim/libopie.pro
diff --git a/libopie/pim/obackendfactory.h b/noncore/unsupported/libopie/pim/obackendfactory.h
index 761ab9a..4cdef8b 100644
--- a/libopie/pim/obackendfactory.h
+++ b/noncore/unsupported/libopie/pim/obackendfactory.h
@@ -1,194 +1,197 @@
1/* 1/*
2 * Class to manage Backends. 2 * Class to manage Backends.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; 9 * License as published by the Free Software Foundation;
10 * either version 2 of the License, or (at your option) any later 10 * either version 2 of the License, or (at your option) any later
11 * version. 11 * version.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: Use plugins 13 * ToDo: Use plugins
14 * ===================================================================== 14 * =====================================================================
15 * Version: $Id$ 15 * Version: $Id$
16 * ===================================================================== 16 * =====================================================================
17 * History: 17 * History:
18 * $Log$ 18 * $Log$
19 * Revision 1.1 2004/11/16 21:46:07 mickeyl
20 * libopie1 goes into unsupported
21 *
19 * Revision 1.9 2003/12/22 10:19:26 eilers 22 * Revision 1.9 2003/12/22 10:19:26 eilers
20 * Finishing implementation of sql-backend for datebook. But I have to 23 * Finishing implementation of sql-backend for datebook. But I have to
21 * port the PIM datebook application to use it, before I could debug the 24 * port the PIM datebook application to use it, before I could debug the
22 * whole stuff. 25 * whole stuff.
23 * Thus, PIM-Database backend is finished, but highly experimental. And some 26 * Thus, PIM-Database backend is finished, but highly experimental. And some
24 * parts are still generic. For instance, the "queryByExample()" methods are 27 * parts are still generic. For instance, the "queryByExample()" methods are
25 * not (or not fully) implemented. Todo: custom-entries not stored. 28 * not (or not fully) implemented. Todo: custom-entries not stored.
26 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular 29 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
27 * expression search in the database, which is not supported by sqlite ! 30 * expression search in the database, which is not supported by sqlite !
28 * Therefore we need either an extended sqlite or a workaround which would 31 * Therefore we need either an extended sqlite or a workaround which would
29 * be very slow and memory consuming.. 32 * be very slow and memory consuming..
30 * 33 *
31 * Revision 1.8 2003/09/22 14:31:16 eilers 34 * Revision 1.8 2003/09/22 14:31:16 eilers
32 * Added first experimental incarnation of sql-backend for addressbook. 35 * Added first experimental incarnation of sql-backend for addressbook.
33 * Some modifications to be able to compile the todo sql-backend. 36 * Some modifications to be able to compile the todo sql-backend.
34 * A lot of changes fill follow... 37 * A lot of changes fill follow...
35 * 38 *
36 * Revision 1.7 2003/08/01 12:30:16 eilers 39 * Revision 1.7 2003/08/01 12:30:16 eilers
37 * Merging changes from BRANCH_1_0 to HEAD 40 * Merging changes from BRANCH_1_0 to HEAD
38 * 41 *
39 * Revision 1.6.4.1 2003/06/30 14:34:19 eilers 42 * Revision 1.6.4.1 2003/06/30 14:34:19 eilers
40 * Patches from Zecke: 43 * Patches from Zecke:
41 * Fixing and cleaning up extraMap handling 44 * Fixing and cleaning up extraMap handling
42 * Adding d_ptr for binary compatibility in the future 45 * Adding d_ptr for binary compatibility in the future
43 * 46 *
44 * Revision 1.6 2003/04/13 18:07:10 zecke 47 * Revision 1.6 2003/04/13 18:07:10 zecke
45 * More API doc 48 * More API doc
46 * QString -> const QString& 49 * QString -> const QString&
47 * QString = 0l -> QString::null 50 * QString = 0l -> QString::null
48 * 51 *
49 * Revision 1.5 2003/02/21 23:31:52 zecke 52 * Revision 1.5 2003/02/21 23:31:52 zecke
50 * Add XML datebookresource 53 * Add XML datebookresource
51 * -clean up todoaccessxml header 54 * -clean up todoaccessxml header
52 * -implement some more stuff in the oeven tester 55 * -implement some more stuff in the oeven tester
53 * -extend DefaultFactory to not crash and to use datebook 56 * -extend DefaultFactory to not crash and to use datebook
54 * 57 *
55 * -reading of OEvents is working nicely.. saving will be added 58 * -reading of OEvents is working nicely.. saving will be added
56 * tomorrow 59 * tomorrow
57 * -fix spelling in ODateBookAcces 60 * -fix spelling in ODateBookAcces
58 * 61 *
59 * Revision 1.4 2002/10/14 15:55:18 eilers 62 * Revision 1.4 2002/10/14 15:55:18 eilers
60 * Redeactivate SQL.. ;) 63 * Redeactivate SQL.. ;)
61 * 64 *
62 * Revision 1.3 2002/10/10 17:08:58 zecke 65 * Revision 1.3 2002/10/10 17:08:58 zecke
63 * The Cache is finally in place 66 * The Cache is finally in place
64 * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;) 67 * I tested it with my todolist and it 'works' for 10.000 todos the hits are awesome ;)
65 * 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.... 68 * 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....
66 * I still have to fully implement read ahead 69 * I still have to fully implement read ahead
67 * This change is bic but sc 70 * This change is bic but sc
68 * 71 *
69 * Revision 1.2 2002/10/08 09:27:36 eilers 72 * Revision 1.2 2002/10/08 09:27:36 eilers
70 * Fixed libopie.pro to include the new pim-API. 73 * Fixed libopie.pro to include the new pim-API.
71 * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to 74 * The SQL-Stuff is currently deactivated. Otherwise everyone who wants to
72 * compile itself would need to install libsqlite, libopiesql... 75 * compile itself would need to install libsqlite, libopiesql...
73 * Therefore, the backend currently uses XML only.. 76 * Therefore, the backend currently uses XML only..
74 * 77 *
75 * Revision 1.1 2002/10/07 17:35:01 eilers 78 * Revision 1.1 2002/10/07 17:35:01 eilers
76 * added OBackendFactory for advanced backend access 79 * added OBackendFactory for advanced backend access
77 * 80 *
78 * 81 *
79 * ===================================================================== 82 * =====================================================================
80 */ 83 */
81#ifndef OPIE_BACKENDFACTORY_H_ 84#ifndef OPIE_BACKENDFACTORY_H_
82#define OPIE_BACKENDFACTORY_H_ 85#define OPIE_BACKENDFACTORY_H_
83 86
84#include <qstring.h> 87#include <qstring.h>
85#include <qasciidict.h> 88#include <qasciidict.h>
86#include <qpe/config.h> 89#include <qpe/config.h>
87 90
88#include "otodoaccessxml.h" 91#include "otodoaccessxml.h"
89#include "ocontactaccessbackend_xml.h" 92#include "ocontactaccessbackend_xml.h"
90#include "odatebookaccessbackend_xml.h" 93#include "odatebookaccessbackend_xml.h"
91 94
92#ifdef __USE_SQL 95#ifdef __USE_SQL
93#include "otodoaccesssql.h" 96#include "otodoaccesssql.h"
94#include "ocontactaccessbackend_sql.h" 97#include "ocontactaccessbackend_sql.h"
95#include "odatebookaccessbackend_sql.h" 98#include "odatebookaccessbackend_sql.h"
96#endif 99#endif
97 100
98class OBackendPrivate; 101class OBackendPrivate;
99 102
100/** 103/**
101 * This class is our factory. It will give us the default implementations 104 * This class is our factory. It will give us the default implementations
102 * of at least Todolist, Contacts and Datebook. In the future this class will 105 * of at least Todolist, Contacts and Datebook. In the future this class will
103 * allow users to switch the backend with ( XML->SQLite ) without the need 106 * allow users to switch the backend with ( XML->SQLite ) without the need
104 * to recompile.# 107 * to recompile.#
105 * This class as the whole PIM Api is making use of templates 108 * This class as the whole PIM Api is making use of templates
106 * 109 *
107 * <pre> 110 * <pre>
108 * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null ); 111 * OTodoAccessBackend* backend = OBackEndFactory<OTodoAccessBackend>::Default("todo", QString::null );
109 * backend->load(); 112 * backend->load();
110 * </pre> 113 * </pre>
111 * 114 *
112 * @author Stefan Eilers 115 * @author Stefan Eilers
113 * @version 0.1 116 * @version 0.1
114 */ 117 */
115template<class T> 118template<class T>
116class OBackendFactory 119class OBackendFactory
117{ 120{
118 public: 121 public:
119 OBackendFactory() {}; 122 OBackendFactory() {};
120 123
121 enum BACKENDS { 124 enum BACKENDS {
122 TODO, 125 TODO,
123 CONTACT, 126 CONTACT,
124 DATE 127 DATE
125 }; 128 };
126 129
127 /** 130 /**
128 * Returns a backend implementation for backendName 131 * Returns a backend implementation for backendName
129 * @param backendName the type of the backend 132 * @param backendName the type of the backend
130 * @param appName will be passed on to the backend 133 * @param appName will be passed on to the backend
131 */ 134 */
132 static T* Default( const QString backendName, const QString& appName ){ 135 static T* Default( const QString backendName, const QString& appName ){
133 136
134 // __asm__("int3"); 137 // __asm__("int3");
135 138
136 Config config( "pimaccess" ); 139 Config config( "pimaccess" );
137 config.setGroup ( backendName ); 140 config.setGroup ( backendName );
138 QString backend = config.readEntry( "usebackend" ); 141 QString backend = config.readEntry( "usebackend" );
139 142
140 qWarning("Selected backend for %s is: %s", backendName.latin1(), backend.latin1() ); 143 qWarning("Selected backend for %s is: %s", backendName.latin1(), backend.latin1() );
141 144
142 QAsciiDict<int> dict ( 3 ); 145 QAsciiDict<int> dict ( 3 );
143 dict.setAutoDelete ( TRUE ); 146 dict.setAutoDelete ( TRUE );
144 147
145 dict.insert( "todo", new int (TODO) ); 148 dict.insert( "todo", new int (TODO) );
146 dict.insert( "contact", new int (CONTACT) ); 149 dict.insert( "contact", new int (CONTACT) );
147 dict.insert( "datebook", new int(DATE) ); 150 dict.insert( "datebook", new int(DATE) );
148 151
149 int *find = dict[ backendName ]; 152 int *find = dict[ backendName ];
150 if (!find ) return 0; 153 if (!find ) return 0;
151 154
152 switch ( *find ){ 155 switch ( *find ){
153 case TODO: 156 case TODO:
154#ifdef __USE_SQL 157#ifdef __USE_SQL
155 if ( backend == "sql" ) 158 if ( backend == "sql" )
156 return (T*) new OTodoAccessBackendSQL(""); 159 return (T*) new OTodoAccessBackendSQL("");
157#else 160#else
158 if ( backend == "sql" ) 161 if ( backend == "sql" )
159 qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!"); 162 qWarning ("OBackendFactory:: sql Backend for TODO not implemented! Using XML instead!");
160#endif 163#endif
161 164
162 return (T*) new OTodoAccessXML( appName ); 165 return (T*) new OTodoAccessXML( appName );
163 case CONTACT: 166 case CONTACT:
164#ifdef __USE_SQL 167#ifdef __USE_SQL
165 if ( backend == "sql" ) 168 if ( backend == "sql" )
166 return (T*) new OContactAccessBackend_SQL(""); 169 return (T*) new OContactAccessBackend_SQL("");
167#else 170#else
168 if ( backend == "sql" ) 171 if ( backend == "sql" )
169 qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!"); 172 qWarning ("OBackendFactory:: sql Backend for CONTACT not implemented! Using XML instead!");
170#endif 173#endif
171 174
172 return (T*) new OContactAccessBackend_XML( appName ); 175 return (T*) new OContactAccessBackend_XML( appName );
173 case DATE: 176 case DATE:
174#ifdef __USE_SQL 177#ifdef __USE_SQL
175 if ( backend == "sql" ) 178 if ( backend == "sql" )
176 return (T*) new ODateBookAccessBackend_SQL(""); 179 return (T*) new ODateBookAccessBackend_SQL("");
177#else 180#else
178 if ( backend == "sql" ) 181 if ( backend == "sql" )
179 qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!"); 182 qWarning("OBackendFactory:: sql Backend for DATEBOOK not implemented! Using XML instead!");
180#endif 183#endif
181 184
182 return (T*) new ODateBookAccessBackend_XML( appName ); 185 return (T*) new ODateBookAccessBackend_XML( appName );
183 default: 186 default:
184 return NULL; 187 return NULL;
185 } 188 }
186 189
187 190
188 } 191 }
189 private: 192 private:
190 OBackendPrivate* d; 193 OBackendPrivate* d;
191}; 194};
192 195
193 196
194#endif 197#endif
diff --git a/libopie/pim/ocontact.cpp b/noncore/unsupported/libopie/pim/ocontact.cpp
index fcf3b26..fcf3b26 100644
--- a/libopie/pim/ocontact.cpp
+++ b/noncore/unsupported/libopie/pim/ocontact.cpp
diff --git a/libopie/pim/ocontact.h b/noncore/unsupported/libopie/pim/ocontact.h
index 1d46b81..1d46b81 100644
--- a/libopie/pim/ocontact.h
+++ b/noncore/unsupported/libopie/pim/ocontact.h
diff --git a/libopie/pim/ocontactaccess.cpp b/noncore/unsupported/libopie/pim/ocontactaccess.cpp
index bc359f7..63b93ee 100644
--- a/libopie/pim/ocontactaccess.cpp
+++ b/noncore/unsupported/libopie/pim/ocontactaccess.cpp
@@ -1,173 +1,176 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * Info: This class could just work with a change in the header-file 12 * Info: This class could just work with a change in the header-file
13 * of the Contact class ! Therefore our libopie only compiles 13 * of the Contact class ! Therefore our libopie only compiles
14 * with our version of libqpe 14 * with our version of libqpe
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: XML-Backend: Automatic reload if something was changed... 16 * ToDo: XML-Backend: Automatic reload if something was changed...
17 * 17 *
18 * 18 *
19 * ===================================================================== 19 * =====================================================================
20 * Version: $Id$ 20 * Version: $Id$
21 * ===================================================================== 21 * =====================================================================
22 * History: 22 * History:
23 * $Log$ 23 * $Log$
24 * Revision 1.1 2004/11/16 21:46:07 mickeyl
25 * libopie1 goes into unsupported
26 *
24 * Revision 1.9 2004/03/02 12:14:22 alwin 27 * Revision 1.9 2004/03/02 12:14:22 alwin
25 * run the optimize_connect script 28 * run the optimize_connect script
26 * the whole cvs is tagged with "before_optimize_connect" if there are problems you 29 * the whole cvs is tagged with "before_optimize_connect" if there are problems you
27 * can check the diff (but it had compiled and run here) 30 * can check the diff (but it had compiled and run here)
28 * 31 *
29 * Revision 1.8 2003/05/08 13:55:09 tille 32 * Revision 1.8 2003/05/08 13:55:09 tille
30 * search stuff 33 * search stuff
31 * and match, toRichText & toShortText in oevent 34 * and match, toRichText & toShortText in oevent
32 * 35 *
33 * Revision 1.7 2002/11/13 14:14:51 eilers 36 * Revision 1.7 2002/11/13 14:14:51 eilers
34 * Added sorted for Contacts.. 37 * Added sorted for Contacts..
35 * 38 *
36 * Revision 1.6 2002/11/01 15:10:42 eilers 39 * Revision 1.6 2002/11/01 15:10:42 eilers
37 * Added regExp-search in database for all fields in a contact. 40 * Added regExp-search in database for all fields in a contact.
38 * 41 *
39 * Revision 1.5 2002/10/16 10:52:40 eilers 42 * Revision 1.5 2002/10/16 10:52:40 eilers
40 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 43 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
41 * 44 *
42 * Revision 1.4 2002/10/14 16:21:54 eilers 45 * Revision 1.4 2002/10/14 16:21:54 eilers
43 * Some minor interface updates 46 * Some minor interface updates
44 * 47 *
45 * Revision 1.3 2002/10/07 17:34:24 eilers 48 * Revision 1.3 2002/10/07 17:34:24 eilers
46 * added OBackendFactory for advanced backend access 49 * added OBackendFactory for advanced backend access
47 * 50 *
48 * Revision 1.2 2002/10/02 16:18:11 eilers 51 * Revision 1.2 2002/10/02 16:18:11 eilers
49 * debugged and seems to work almost perfectly .. 52 * debugged and seems to work almost perfectly ..
50 * 53 *
51 * Revision 1.1 2002/09/27 17:11:44 eilers 54 * Revision 1.1 2002/09/27 17:11:44 eilers
52 * Added API for accessing the Contact-Database ! It is compiling, but 55 * Added API for accessing the Contact-Database ! It is compiling, but
53 * please do not expect that anything is working ! 56 * please do not expect that anything is working !
54 * I will debug that stuff in the next time .. 57 * I will debug that stuff in the next time ..
55 * Please read README_COMPILE for compiling ! 58 * Please read README_COMPILE for compiling !
56 * 59 *
57 * 60 *
58 */ 61 */
59 62
60#include "ocontactaccess.h" 63#include "ocontactaccess.h"
61#include "obackendfactory.h" 64#include "obackendfactory.h"
62 65
63#include <qasciidict.h> 66#include <qasciidict.h>
64#include <qdatetime.h> 67#include <qdatetime.h>
65#include <qfile.h> 68#include <qfile.h>
66#include <qregexp.h> 69#include <qregexp.h>
67#include <qlist.h> 70#include <qlist.h>
68#include <qcopchannel_qws.h> 71#include <qcopchannel_qws.h>
69 72
70//#include <qpe/qcopenvelope_qws.h> 73//#include <qpe/qcopenvelope_qws.h>
71#include <qpe/global.h> 74#include <qpe/global.h>
72 75
73#include <errno.h> 76#include <errno.h>
74#include <fcntl.h> 77#include <fcntl.h>
75#include <unistd.h> 78#include <unistd.h>
76#include <stdlib.h> 79#include <stdlib.h>
77 80
78#include "ocontactaccessbackend_xml.h" 81#include "ocontactaccessbackend_xml.h"
79 82
80 83
81OContactAccess::OContactAccess ( const QString appname, const QString , 84OContactAccess::OContactAccess ( const QString appname, const QString ,
82 OContactAccessBackend* end, bool autosync ): 85 OContactAccessBackend* end, bool autosync ):
83 OPimAccessTemplate<OContact>( end ) 86 OPimAccessTemplate<OContact>( end )
84{ 87{
85 /* take care of the backend. If there is no one defined, we 88 /* take care of the backend. If there is no one defined, we
86 * will use the XML-Backend as default (until we have a cute SQL-Backend..). 89 * will use the XML-Backend as default (until we have a cute SQL-Backend..).
87 */ 90 */
88 if( end == 0 ) { 91 if( end == 0 ) {
89 qWarning ("Using BackendFactory !"); 92 qWarning ("Using BackendFactory !");
90 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname ); 93 end = OBackendFactory<OContactAccessBackend>::Default( "contact", appname );
91 } 94 }
92 // Set backend locally and in template 95 // Set backend locally and in template
93 m_backEnd = end; 96 m_backEnd = end;
94 OPimAccessTemplate<OContact>::setBackEnd (end); 97 OPimAccessTemplate<OContact>::setBackEnd (end);
95 98
96 99
97 /* Connect signal of external db change to function */ 100 /* Connect signal of external db change to function */
98 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this ); 101 QCopChannel *dbchannel = new QCopChannel( "QPE/PIM", this );
99 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)), 102 connect( dbchannel, SIGNAL(received(const QCString&,const QByteArray&)),
100 this, SLOT(copMessage(const QCString&,const QByteArray&)) ); 103 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
101 if ( autosync ){ 104 if ( autosync ){
102 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this ); 105 QCopChannel *syncchannel = new QCopChannel( "QPE/Sync", this );
103 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)), 106 connect( syncchannel, SIGNAL(received(const QCString&,const QByteArray&)),
104 this, SLOT(copMessage(const QCString&,const QByteArray&)) ); 107 this, SLOT(copMessage(const QCString&,const QByteArray&)) );
105 } 108 }
106 109
107 110
108} 111}
109OContactAccess::~OContactAccess () 112OContactAccess::~OContactAccess ()
110{ 113{
111 /* The user may forget to save the changed database, therefore try to 114 /* The user may forget to save the changed database, therefore try to
112 * do it for him.. 115 * do it for him..
113 */ 116 */
114 save(); 117 save();
115 // delete m_backEnd; is done by template.. 118 // delete m_backEnd; is done by template..
116} 119}
117 120
118 121
119bool OContactAccess::save () 122bool OContactAccess::save ()
120{ 123{
121 /* If the database was changed externally, we could not save the 124 /* If the database was changed externally, we could not save the
122 * Data. This will remove added items which is unacceptable ! 125 * Data. This will remove added items which is unacceptable !
123 * Therefore: Reload database and merge the data... 126 * Therefore: Reload database and merge the data...
124 */ 127 */
125 if ( OPimAccessTemplate<OContact>::wasChangedExternally() ) 128 if ( OPimAccessTemplate<OContact>::wasChangedExternally() )
126 reload(); 129 reload();
127 130
128 bool status = OPimAccessTemplate<OContact>::save(); 131 bool status = OPimAccessTemplate<OContact>::save();
129 if ( !status ) return false; 132 if ( !status ) return false;
130 133
131 /* Now tell everyone that new data is available. 134 /* Now tell everyone that new data is available.
132 */ 135 */
133 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" ); 136 QCopEnvelope e( "QPE/PIM", "addressbookUpdated()" );
134 137
135 return true; 138 return true;
136} 139}
137 140
138const uint OContactAccess::querySettings() 141const uint OContactAccess::querySettings()
139{ 142{
140 return ( m_backEnd->querySettings() ); 143 return ( m_backEnd->querySettings() );
141} 144}
142 145
143bool OContactAccess::hasQuerySettings ( int querySettings ) const 146bool OContactAccess::hasQuerySettings ( int querySettings ) const
144{ 147{
145 return ( m_backEnd->hasQuerySettings ( querySettings ) ); 148 return ( m_backEnd->hasQuerySettings ( querySettings ) );
146} 149}
147ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const 150ORecordList<OContact> OContactAccess::sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const
148{ 151{
149 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat ); 152 QArray<int> matchingContacts = m_backEnd -> sorted( ascending, sortOrder, sortFilter, cat );
150 return ( ORecordList<OContact>(matchingContacts, this) ); 153 return ( ORecordList<OContact>(matchingContacts, this) );
151} 154}
152 155
153 156
154bool OContactAccess::wasChangedExternally()const 157bool OContactAccess::wasChangedExternally()const
155{ 158{
156 return ( m_backEnd->wasChangedExternally() ); 159 return ( m_backEnd->wasChangedExternally() );
157} 160}
158 161
159 162
160void OContactAccess::copMessage( const QCString &msg, const QByteArray & ) 163void OContactAccess::copMessage( const QCString &msg, const QByteArray & )
161{ 164{
162 if ( msg == "addressbookUpdated()" ){ 165 if ( msg == "addressbookUpdated()" ){
163 qWarning ("OContactAccess: Received addressbokUpdated()"); 166 qWarning ("OContactAccess: Received addressbokUpdated()");
164 emit signalChanged ( this ); 167 emit signalChanged ( this );
165 } else if ( msg == "flush()" ) { 168 } else if ( msg == "flush()" ) {
166 qWarning ("OContactAccess: Received flush()"); 169 qWarning ("OContactAccess: Received flush()");
167 save (); 170 save ();
168 } else if ( msg == "reload()" ) { 171 } else if ( msg == "reload()" ) {
169 qWarning ("OContactAccess: Received reload()"); 172 qWarning ("OContactAccess: Received reload()");
170 reload (); 173 reload ();
171 emit signalChanged ( this ); 174 emit signalChanged ( this );
172 } 175 }
173} 176}
diff --git a/libopie/pim/ocontactaccess.h b/noncore/unsupported/libopie/pim/ocontactaccess.h
index bd6da40..a7a099f 100644
--- a/libopie/pim/ocontactaccess.h
+++ b/noncore/unsupported/libopie/pim/ocontactaccess.h
@@ -1,193 +1,196 @@
1/* 1/*
2 * Class to manage the Contacts. 2 * Class to manage the Contacts.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 5 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; 10 * License as published by the Free Software Foundation;
11 * either version 2 of the License, or (at your option) any later 11 * either version 2 of the License, or (at your option) any later
12 * version. 12 * version.
13 * ===================================================================== 13 * =====================================================================
14 * ToDo: Define enum for query settings 14 * ToDo: Define enum for query settings
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.1 2004/11/16 21:46:07 mickeyl
21 * libopie1 goes into unsupported
22 *
20 * Revision 1.10 2003/12/22 10:19:26 eilers 23 * Revision 1.10 2003/12/22 10:19:26 eilers
21 * Finishing implementation of sql-backend for datebook. But I have to 24 * Finishing implementation of sql-backend for datebook. But I have to
22 * port the PIM datebook application to use it, before I could debug the 25 * port the PIM datebook application to use it, before I could debug the
23 * whole stuff. 26 * whole stuff.
24 * Thus, PIM-Database backend is finished, but highly experimental. And some 27 * Thus, PIM-Database backend is finished, but highly experimental. And some
25 * parts are still generic. For instance, the "queryByExample()" methods are 28 * parts are still generic. For instance, the "queryByExample()" methods are
26 * not (or not fully) implemented. Todo: custom-entries not stored. 29 * not (or not fully) implemented. Todo: custom-entries not stored.
27 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular 30 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
28 * expression search in the database, which is not supported by sqlite ! 31 * expression search in the database, which is not supported by sqlite !
29 * Therefore we need either an extended sqlite or a workaround which would 32 * Therefore we need either an extended sqlite or a workaround which would
30 * be very slow and memory consuming.. 33 * be very slow and memory consuming..
31 * 34 *
32 * Revision 1.9 2003/08/01 12:30:16 eilers 35 * Revision 1.9 2003/08/01 12:30:16 eilers
33 * Merging changes from BRANCH_1_0 to HEAD 36 * Merging changes from BRANCH_1_0 to HEAD
34 * 37 *
35 * Revision 1.8.2.1 2003/06/30 14:34:19 eilers 38 * Revision 1.8.2.1 2003/06/30 14:34:19 eilers
36 * Patches from Zecke: 39 * Patches from Zecke:
37 * Fixing and cleaning up extraMap handling 40 * Fixing and cleaning up extraMap handling
38 * Adding d_ptr for binary compatibility in the future 41 * Adding d_ptr for binary compatibility in the future
39 * 42 *
40 * Revision 1.8 2003/05/08 13:55:09 tille 43 * Revision 1.8 2003/05/08 13:55:09 tille
41 * search stuff 44 * search stuff
42 * and match, toRichText & toShortText in oevent 45 * and match, toRichText & toShortText in oevent
43 * 46 *
44 * Revision 1.7 2003/04/13 18:07:10 zecke 47 * Revision 1.7 2003/04/13 18:07:10 zecke
45 * More API doc 48 * More API doc
46 * QString -> const QString& 49 * QString -> const QString&
47 * QString = 0l -> QString::null 50 * QString = 0l -> QString::null
48 * 51 *
49 * Revision 1.6 2003/01/02 14:27:12 eilers 52 * Revision 1.6 2003/01/02 14:27:12 eilers
50 * Improved query by example: Search by date is possible.. First step 53 * Improved query by example: Search by date is possible.. First step
51 * for a today plugin for birthdays.. 54 * for a today plugin for birthdays..
52 * 55 *
53 * Revision 1.5 2002/11/13 14:14:51 eilers 56 * Revision 1.5 2002/11/13 14:14:51 eilers
54 * Added sorted for Contacts.. 57 * Added sorted for Contacts..
55 * 58 *
56 * Revision 1.4 2002/11/01 15:10:42 eilers 59 * Revision 1.4 2002/11/01 15:10:42 eilers
57 * Added regExp-search in database for all fields in a contact. 60 * Added regExp-search in database for all fields in a contact.
58 * 61 *
59 * Revision 1.3 2002/10/16 10:52:40 eilers 62 * Revision 1.3 2002/10/16 10:52:40 eilers
60 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 63 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
61 * 64 *
62 * Revision 1.2 2002/10/14 16:21:54 eilers 65 * Revision 1.2 2002/10/14 16:21:54 eilers
63 * Some minor interface updates 66 * Some minor interface updates
64 * 67 *
65 * Revision 1.1 2002/09/27 17:11:44 eilers 68 * Revision 1.1 2002/09/27 17:11:44 eilers
66 * Added API for accessing the Contact-Database ! It is compiling, but 69 * Added API for accessing the Contact-Database ! It is compiling, but
67 * please do not expect that anything is working ! 70 * please do not expect that anything is working !
68 * I will debug that stuff in the next time .. 71 * I will debug that stuff in the next time ..
69 * Please read README_COMPILE for compiling ! 72 * Please read README_COMPILE for compiling !
70 * 73 *
71 * ===================================================================== 74 * =====================================================================
72 */ 75 */
73#ifndef _OCONTACTACCESS_H 76#ifndef _OCONTACTACCESS_H
74#define _OCONTACTACCESS_H 77#define _OCONTACTACCESS_H
75 78
76#include <qobject.h> 79#include <qobject.h>
77 80
78#include <qpe/qcopenvelope_qws.h> 81#include <qpe/qcopenvelope_qws.h>
79 82
80#include <qvaluelist.h> 83#include <qvaluelist.h>
81#include <qfileinfo.h> 84#include <qfileinfo.h>
82 85
83#include "ocontact.h" 86#include "ocontact.h"
84#include "ocontactaccessbackend.h" 87#include "ocontactaccessbackend.h"
85#include "opimaccesstemplate.h" 88#include "opimaccesstemplate.h"
86 89
87/** 90/**
88 * Class to access the contacts database. 91 * Class to access the contacts database.
89 * This is just a frontend for the real database handling which is 92 * This is just a frontend for the real database handling which is
90 * done by the backend. 93 * done by the backend.
91 * This class is used to access the Contacts on a system. This class as any OPIE PIM 94 * This class is used to access the Contacts on a system. This class as any OPIE PIM
92 * class is backend independent. 95 * class is backend independent.
93 * @author Stefan Eilers, Holger Freyther 96 * @author Stefan Eilers, Holger Freyther
94 * @see OPimAccessTemplate 97 * @see OPimAccessTemplate
95 */ 98 */
96class OContactAccess: public QObject, public OPimAccessTemplate<OContact> 99class OContactAccess: public QObject, public OPimAccessTemplate<OContact>
97{ 100{
98 Q_OBJECT 101 Q_OBJECT
99 102
100 public: 103 public:
101 /** 104 /**
102 * Create Database with contacts (addressbook). 105 * Create Database with contacts (addressbook).
103 * @param appname Name of application which wants access to the database 106 * @param appname Name of application which wants access to the database
104 * (i.e. "todolist") 107 * (i.e. "todolist")
105 * @param filename The name of the database file. If not set, the default one 108 * @param filename The name of the database file. If not set, the default one
106 * is used. 109 * is used.
107 * @param backend Pointer to an alternative Backend. If not set, we will use 110 * @param backend Pointer to an alternative Backend. If not set, we will use
108 * the default backend. 111 * the default backend.
109 * @param handlesync If <b>true</b> the database stores the current state 112 * @param handlesync If <b>true</b> the database stores the current state
110 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i> 113 * automatically if it receives the signals <i>flush()</i> and <i>reload()</i>
111 * which are used before and after synchronisation. If the application wants 114 * which are used before and after synchronisation. If the application wants
112 * to react itself, it should be disabled by setting it to <b>false</b> 115 * to react itself, it should be disabled by setting it to <b>false</b>
113 * @see OContactAccessBackend 116 * @see OContactAccessBackend
114 */ 117 */
115 OContactAccess (const QString appname, const QString filename = 0l, 118 OContactAccess (const QString appname, const QString filename = 0l,
116 OContactAccessBackend* backend = 0l, bool handlesync = true); 119 OContactAccessBackend* backend = 0l, bool handlesync = true);
117 ~OContactAccess (); 120 ~OContactAccess ();
118 121
119 /** Constants for query. 122 /** Constants for query.
120 * Use this constants to set the query parameters. 123 * Use this constants to set the query parameters.
121 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes ! 124 * Note: <i>query_IgnoreCase</i> just make sense with one of the other attributes !
122 * @see queryByExample() 125 * @see queryByExample()
123 */ 126 */
124 enum QuerySettings { 127 enum QuerySettings {
125 WildCards = 0x0001, 128 WildCards = 0x0001,
126 IgnoreCase = 0x0002, 129 IgnoreCase = 0x0002,
127 RegExp = 0x0004, 130 RegExp = 0x0004,
128 ExactMatch = 0x0008, 131 ExactMatch = 0x0008,
129 MatchOne = 0x0010, // Only one Entry must match 132 MatchOne = 0x0010, // Only one Entry must match
130 DateDiff = 0x0020, // Find all entries from today until given date 133 DateDiff = 0x0020, // Find all entries from today until given date
131 DateYear = 0x0040, // The year matches 134 DateYear = 0x0040, // The year matches
132 DateMonth = 0x0080, // The month matches 135 DateMonth = 0x0080, // The month matches
133 DateDay = 0x0100, // The day matches 136 DateDay = 0x0100, // The day matches
134 }; 137 };
135 138
136 139
137 /** Return all Contacts in a sorted manner. 140 /** Return all Contacts in a sorted manner.
138 * @param ascending true: Sorted in acending order. 141 * @param ascending true: Sorted in acending order.
139 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess 142 * @param sortOrder Currently not implemented. Just defined to stay compatible to otodoaccess
140 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess 143 * @param sortFilter Currently not implemented. Just defined to stay compatible to otodoaccess
141 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess 144 * @param cat Currently not implemented. Just defined to stay compatible to otodoaccess
142 */ 145 */
143 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const; 146 List sorted( bool ascending, int sortOrder, int sortFilter, int cat ) const;
144 147
145 /** Return all possible settings. 148 /** Return all possible settings.
146 * @return All settings provided by the current backend 149 * @return All settings provided by the current backend
147 * (i.e.: query_WildCards & query_IgnoreCase) 150 * (i.e.: query_WildCards & query_IgnoreCase)
148 */ 151 */
149 const uint querySettings(); 152 const uint querySettings();
150 153
151 /** Check whether settings are correct. 154 /** Check whether settings are correct.
152 * @return <i>true</i> if the given settings are correct and possible. 155 * @return <i>true</i> if the given settings are correct and possible.
153 */ 156 */
154 bool hasQuerySettings ( int querySettings ) const; 157 bool hasQuerySettings ( int querySettings ) const;
155 158
156 /** 159 /**
157 * if the resource was changed externally. 160 * if the resource was changed externally.
158 * You should use the signal instead of polling possible changes ! 161 * You should use the signal instead of polling possible changes !
159 */ 162 */
160 bool wasChangedExternally()const; 163 bool wasChangedExternally()const;
161 164
162 165
163 /** Save contacts database. 166 /** Save contacts database.
164 * Save is more a "commit". After calling this function, all changes are public available. 167 * Save is more a "commit". After calling this function, all changes are public available.
165 * @return true if successful 168 * @return true if successful
166 */ 169 */
167 bool save(); 170 bool save();
168 171
169 signals: 172 signals:
170 /* Signal is emitted if the database was changed. Therefore 173 /* Signal is emitted if the database was changed. Therefore
171 * we may need to reload to stay consistent. 174 * we may need to reload to stay consistent.
172 * @param which Pointer to the database who created this event. This pointer 175 * @param which Pointer to the database who created this event. This pointer
173 * is useful if an application has to handle multiple databases at the same time. 176 * is useful if an application has to handle multiple databases at the same time.
174 * @see reload() 177 * @see reload()
175 */ 178 */
176 void signalChanged ( const OContactAccess *which ); 179 void signalChanged ( const OContactAccess *which );
177 180
178 181
179 private: 182 private:
180 // class OContactAccessPrivate; 183 // class OContactAccessPrivate;
181 // OContactAccessPrivate* d; 184 // OContactAccessPrivate* d;
182 OContactAccessBackend *m_backEnd; 185 OContactAccessBackend *m_backEnd;
183 bool m_loading:1; 186 bool m_loading:1;
184 187
185 private slots: 188 private slots:
186 void copMessage( const QCString &msg, const QByteArray &data ); 189 void copMessage( const QCString &msg, const QByteArray &data );
187 190
188 private: 191 private:
189 class Private; 192 class Private;
190 Private *d; 193 Private *d;
191 194
192}; 195};
193#endif 196#endif
diff --git a/libopie/pim/ocontactaccessbackend.h b/noncore/unsupported/libopie/pim/ocontactaccessbackend.h
index 0eac6dc..cfeeff2 100644
--- a/libopie/pim/ocontactaccessbackend.h
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend.h
@@ -1,128 +1,131 @@
1/** 1/**
2 * The class responsible for managing a backend. 2 * The class responsible for managing a backend.
3 * The implementation of this abstract class contains 3 * The implementation of this abstract class contains
4 * the complete database handling. 4 * the complete database handling.
5 * 5 *
6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 6 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org) 7 * Copyright (c) 2002 by Holger Freyther (zecke@handhelds.org)
8 * 8 *
9 * ===================================================================== 9 * =====================================================================
10 *This program is free software; you can redistribute it and/or 10 *This program is free software; you can redistribute it and/or
11 *modify it under the terms of the GNU Library General Public 11 *modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; 12 * License as published by the Free Software Foundation;
13 * either version 2 of the License, or (at your option) any later 13 * either version 2 of the License, or (at your option) any later
14 * version. 14 * version.
15 * ===================================================================== 15 * =====================================================================
16 * ToDo: Define enum for query settings 16 * ToDo: Define enum for query settings
17 * ===================================================================== 17 * =====================================================================
18 * Version: $Id$ 18 * Version: $Id$
19 * ===================================================================== 19 * =====================================================================
20 * History: 20 * History:
21 * $Log$ 21 * $Log$
22 * Revision 1.1 2004/11/16 21:46:07 mickeyl
23 * libopie1 goes into unsupported
24 *
22 * Revision 1.7 2004/02/19 02:05:37 zecke 25 * Revision 1.7 2004/02/19 02:05:37 zecke
23 * Add notes for API fixes and BC stuff 26 * Add notes for API fixes and BC stuff
24 * 27 *
25 * Revision 1.6 2003/08/01 12:30:16 eilers 28 * Revision 1.6 2003/08/01 12:30:16 eilers
26 * Merging changes from BRANCH_1_0 to HEAD 29 * Merging changes from BRANCH_1_0 to HEAD
27 * 30 *
28 * Revision 1.5.4.1 2003/06/30 14:34:19 eilers 31 * Revision 1.5.4.1 2003/06/30 14:34:19 eilers
29 * Patches from Zecke: 32 * Patches from Zecke:
30 * Fixing and cleaning up extraMap handling 33 * Fixing and cleaning up extraMap handling
31 * Adding d_ptr for binary compatibility in the future 34 * Adding d_ptr for binary compatibility in the future
32 * 35 *
33 * Revision 1.5 2003/04/13 18:07:10 zecke 36 * Revision 1.5 2003/04/13 18:07:10 zecke
34 * More API doc 37 * More API doc
35 * QString -> const QString& 38 * QString -> const QString&
36 * QString = 0l -> QString::null 39 * QString = 0l -> QString::null
37 * 40 *
38 * Revision 1.4 2002/11/13 14:14:51 eilers 41 * Revision 1.4 2002/11/13 14:14:51 eilers
39 * Added sorted for Contacts.. 42 * Added sorted for Contacts..
40 * 43 *
41 * Revision 1.3 2002/11/01 15:10:42 eilers 44 * Revision 1.3 2002/11/01 15:10:42 eilers
42 * Added regExp-search in database for all fields in a contact. 45 * Added regExp-search in database for all fields in a contact.
43 * 46 *
44 * Revision 1.2 2002/10/07 17:34:24 eilers 47 * Revision 1.2 2002/10/07 17:34:24 eilers
45 * added OBackendFactory for advanced backend access 48 * added OBackendFactory for advanced backend access
46 * 49 *
47 * Revision 1.1 2002/09/27 17:11:44 eilers 50 * Revision 1.1 2002/09/27 17:11:44 eilers
48 * Added API for accessing the Contact-Database ! It is compiling, but 51 * Added API for accessing the Contact-Database ! It is compiling, but
49 * please do not expect that anything is working ! 52 * please do not expect that anything is working !
50 * I will debug that stuff in the next time .. 53 * I will debug that stuff in the next time ..
51 * Please read README_COMPILE for compiling ! 54 * Please read README_COMPILE for compiling !
52 * 55 *
53 * ===================================================================== 56 * =====================================================================
54 * 57 *
55 */ 58 */
56 59
57#ifndef _OCONTACTACCESSBACKEND_H_ 60#ifndef _OCONTACTACCESSBACKEND_H_
58#define _OCONTACTACCESSBACKEND_H_ 61#define _OCONTACTACCESSBACKEND_H_
59 62
60#include "ocontact.h" 63#include "ocontact.h"
61#include "opimaccessbackend.h" 64#include "opimaccessbackend.h"
62 65
63#include <qregexp.h> 66#include <qregexp.h>
64 67
65/** 68/**
66 * This class represents the interface of all Contact Backends. 69 * This class represents the interface of all Contact Backends.
67 * Derivates of this class will be used to access the contacts. 70 * Derivates of this class will be used to access the contacts.
68 * As implementation currently XML and vCard exist. This class needs to be implemented 71 * As implementation currently XML and vCard exist. This class needs to be implemented
69 * if you want to provide your own storage. 72 * if you want to provide your own storage.
70 * In all queries a list of uids is passed on instead of loading the actual record! 73 * In all queries a list of uids is passed on instead of loading the actual record!
71 * 74 *
72 * @see OContactAccessBackend_VCard 75 * @see OContactAccessBackend_VCard
73 * @see OContactAccessBackend_XML 76 * @see OContactAccessBackend_XML
74 */ 77 */
75class OContactAccessBackend: public OPimAccessBackend<OContact> { 78class OContactAccessBackend: public OPimAccessBackend<OContact> {
76 public: 79 public:
77 /** 80 /**
78 * @todo make non line in regard to BC guide of KDE 81 * @todo make non line in regard to BC guide of KDE
79 */ 82 */
80 OContactAccessBackend() {} 83 OContactAccessBackend() {}
81 /** 84 /**
82 * @todo make non inline in regard to the BC guide of KDE 85 * @todo make non inline in regard to the BC guide of KDE
83 */ 86 */
84 virtual ~OContactAccessBackend() {} 87 virtual ~OContactAccessBackend() {}
85 88
86 89
87 /** 90 /**
88 * Return if database was changed externally. 91 * Return if database was changed externally.
89 * This may just make sense on file based databases like a XML-File. 92 * This may just make sense on file based databases like a XML-File.
90 * It is used to prevent to overwrite the current database content 93 * It is used to prevent to overwrite the current database content
91 * if the file was already changed by something else ! 94 * if the file was already changed by something else !
92 * If this happens, we have to reload before save our data. 95 * If this happens, we have to reload before save our data.
93 * If we use real databases, this should be handled by the database 96 * If we use real databases, this should be handled by the database
94 * management system themselve, therefore this function should always return false in 97 * management system themselve, therefore this function should always return false in
95 * this case. It is not our problem to handle this conflict ... 98 * this case. It is not our problem to handle this conflict ...
96 * @return <i>true</i> if the database was changed and if save without reload will 99 * @return <i>true</i> if the database was changed and if save without reload will
97 * be dangerous. <i>false</i> if the database was not changed or it is save to write 100 * be dangerous. <i>false</i> if the database was not changed or it is save to write
98 * in this situation. 101 * in this situation.
99 */ 102 */
100 virtual bool wasChangedExternally() = 0; 103 virtual bool wasChangedExternally() = 0;
101 104
102 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0; 105 virtual QArray<int> matchRegexp( const QRegExp &r ) const = 0;
103 106
104 /** 107 /**
105 * Return all possible settings. 108 * Return all possible settings.
106 * @return All settings provided by the current backend 109 * @return All settings provided by the current backend
107 * (i.e.: query_WildCards & query_IgnoreCase) 110 * (i.e.: query_WildCards & query_IgnoreCase)
108 */ 111 */
109 virtual const uint querySettings() = 0; 112 virtual const uint querySettings() = 0;
110 113
111 /** 114 /**
112 * Check whether settings are correct. 115 * Check whether settings are correct.
113 * @return <i>true</i> if the given settings are correct and possible. 116 * @return <i>true</i> if the given settings are correct and possible.
114 */ 117 */
115 virtual bool hasQuerySettings (uint querySettings) const = 0; 118 virtual bool hasQuerySettings (uint querySettings) const = 0;
116 119
117 /** 120 /**
118 * FIXME!!! 121 * FIXME!!!
119 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category 122 * Returns a sorted list of records either ascendinf or descending for a giving criteria and category
120 */ 123 */
121 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0; 124 virtual QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ) = 0;
122 125
123 126
124private: 127private:
125 class Private; 128 class Private;
126 Private *d; 129 Private *d;
127}; 130};
128#endif 131#endif
diff --git a/libopie/pim/ocontactaccessbackend_sql.cpp b/noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.cpp
index d20df56..669483d 100644
--- a/libopie/pim/ocontactaccessbackend_sql.cpp
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.cpp
@@ -1,945 +1,948 @@
1/* 1/*
2 * SQL Backend for the OPIE-Contact Database. 2 * SQL Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ===================================================================== 12 * =====================================================================
13 * Version: $Id$ 13 * Version: $Id$
14 * ===================================================================== 14 * =====================================================================
15 * History: 15 * History:
16 * $Log$ 16 * $Log$
17 * Revision 1.1 2004/11/16 21:46:07 mickeyl
18 * libopie1 goes into unsupported
19 *
17 * Revision 1.5 2004/03/14 13:50:35 alwin 20 * Revision 1.5 2004/03/14 13:50:35 alwin
18 * namespace correction 21 * namespace correction
19 * 22 *
20 * Revision 1.4 2003/12/22 10:19:26 eilers 23 * Revision 1.4 2003/12/22 10:19:26 eilers
21 * Finishing implementation of sql-backend for datebook. But I have to 24 * Finishing implementation of sql-backend for datebook. But I have to
22 * port the PIM datebook application to use it, before I could debug the 25 * port the PIM datebook application to use it, before I could debug the
23 * whole stuff. 26 * whole stuff.
24 * Thus, PIM-Database backend is finished, but highly experimental. And some 27 * Thus, PIM-Database backend is finished, but highly experimental. And some
25 * parts are still generic. For instance, the "queryByExample()" methods are 28 * parts are still generic. For instance, the "queryByExample()" methods are
26 * not (or not fully) implemented. Todo: custom-entries not stored. 29 * not (or not fully) implemented. Todo: custom-entries not stored.
27 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular 30 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
28 * expression search in the database, which is not supported by sqlite ! 31 * expression search in the database, which is not supported by sqlite !
29 * Therefore we need either an extended sqlite or a workaround which would 32 * Therefore we need either an extended sqlite or a workaround which would
30 * be very slow and memory consuming.. 33 * be very slow and memory consuming..
31 * 34 *
32 * Revision 1.3 2003/12/08 15:18:10 eilers 35 * Revision 1.3 2003/12/08 15:18:10 eilers
33 * Committing unfinished sql implementation before merging to libopie2 starts.. 36 * Committing unfinished sql implementation before merging to libopie2 starts..
34 * 37 *
35 * Revision 1.2 2003/09/29 07:44:26 eilers 38 * Revision 1.2 2003/09/29 07:44:26 eilers
36 * Improvement of PIM-SQL Databases, but search queries are still limited. 39 * Improvement of PIM-SQL Databases, but search queries are still limited.
37 * Addressbook: Changed table layout. Now, we just need 1/3 of disk-space. 40 * Addressbook: Changed table layout. Now, we just need 1/3 of disk-space.
38 * Todo: Started to add new attributes. Some type conversions missing. 41 * Todo: Started to add new attributes. Some type conversions missing.
39 * 42 *
40 * Revision 1.1 2003/09/22 14:31:16 eilers 43 * Revision 1.1 2003/09/22 14:31:16 eilers
41 * Added first experimental incarnation of sql-backend for addressbook. 44 * Added first experimental incarnation of sql-backend for addressbook.
42 * Some modifications to be able to compile the todo sql-backend. 45 * Some modifications to be able to compile the todo sql-backend.
43 * A lot of changes fill follow... 46 * A lot of changes fill follow...
44 * 47 *
45 */ 48 */
46 49
47#include "ocontactaccessbackend_sql.h" 50#include "ocontactaccessbackend_sql.h"
48 51
49#include <qarray.h> 52#include <qarray.h>
50#include <qdatetime.h> 53#include <qdatetime.h>
51#include <qstringlist.h> 54#include <qstringlist.h>
52 55
53#include <qpe/global.h> 56#include <qpe/global.h>
54#include <qpe/recordfields.h> 57#include <qpe/recordfields.h>
55 58
56#include <opie/ocontactfields.h> 59#include <opie/ocontactfields.h>
57#include <opie/oconversion.h> 60#include <opie/oconversion.h>
58#include <opie2/osqldriver.h> 61#include <opie2/osqldriver.h>
59#include <opie2/osqlresult.h> 62#include <opie2/osqlresult.h>
60#include <opie2/osqlmanager.h> 63#include <opie2/osqlmanager.h>
61#include <opie2/osqlquery.h> 64#include <opie2/osqlquery.h>
62 65
63using namespace Opie::DB; 66using namespace Opie::DB;
64 67
65 68
66// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead 69// If defined, we use a horizontal table ( uid, attr1, attr2, attr3, ..., attrn ) instead
67// vertical like "uid, type, value". 70// vertical like "uid, type, value".
68// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !! 71// DON'T DEACTIVATE THIS DEFINE IN PRODUCTIVE ENVIRONMENTS !!
69#define __STORE_HORIZONTAL_ 72#define __STORE_HORIZONTAL_
70 73
71// Distinct loading is not very fast. If I expect that every person has just 74// Distinct loading is not very fast. If I expect that every person has just
72// one (and always one) 'Last Name', I can request all uid's for existing lastnames, 75// one (and always one) 'Last Name', I can request all uid's for existing lastnames,
73// which is faster.. 76// which is faster..
74// But this may not be true for all entries, like company contacts.. 77// But this may not be true for all entries, like company contacts..
75// The current AddressBook application handles this problem, but other may not.. (eilers) 78// The current AddressBook application handles this problem, but other may not.. (eilers)
76#define __USE_SUPERFAST_LOADQUERY 79#define __USE_SUPERFAST_LOADQUERY
77 80
78 81
79/* 82/*
80 * Implementation of used query types 83 * Implementation of used query types
81 * CREATE query 84 * CREATE query
82 * LOAD query 85 * LOAD query
83 * INSERT 86 * INSERT
84 * REMOVE 87 * REMOVE
85 * CLEAR 88 * CLEAR
86 */ 89 */
87namespace { 90namespace {
88 /** 91 /**
89 * CreateQuery for the Todolist Table 92 * CreateQuery for the Todolist Table
90 */ 93 */
91 class CreateQuery : public OSQLQuery { 94 class CreateQuery : public OSQLQuery {
92 public: 95 public:
93 CreateQuery(); 96 CreateQuery();
94 ~CreateQuery(); 97 ~CreateQuery();
95 QString query()const; 98 QString query()const;
96 }; 99 };
97 100
98 /** 101 /**
99 * Clears (delete) a Table 102 * Clears (delete) a Table
100 */ 103 */
101 class ClearQuery : public OSQLQuery { 104 class ClearQuery : public OSQLQuery {
102 public: 105 public:
103 ClearQuery(); 106 ClearQuery();
104 ~ClearQuery(); 107 ~ClearQuery();
105 QString query()const; 108 QString query()const;
106 109
107 }; 110 };
108 111
109 112
110 /** 113 /**
111 * LoadQuery 114 * LoadQuery
112 * this one queries for all uids 115 * this one queries for all uids
113 */ 116 */
114 class LoadQuery : public OSQLQuery { 117 class LoadQuery : public OSQLQuery {
115 public: 118 public:
116 LoadQuery(); 119 LoadQuery();
117 ~LoadQuery(); 120 ~LoadQuery();
118 QString query()const; 121 QString query()const;
119 }; 122 };
120 123
121 /** 124 /**
122 * inserts/adds a OContact to the table 125 * inserts/adds a OContact to the table
123 */ 126 */
124 class InsertQuery : public OSQLQuery { 127 class InsertQuery : public OSQLQuery {
125 public: 128 public:
126 InsertQuery(const OContact& ); 129 InsertQuery(const OContact& );
127 ~InsertQuery(); 130 ~InsertQuery();
128 QString query()const; 131 QString query()const;
129 private: 132 private:
130 OContact m_contact; 133 OContact m_contact;
131 }; 134 };
132 135
133 136
134 /** 137 /**
135 * removes one from the table 138 * removes one from the table
136 */ 139 */
137 class RemoveQuery : public OSQLQuery { 140 class RemoveQuery : public OSQLQuery {
138 public: 141 public:
139 RemoveQuery(int uid ); 142 RemoveQuery(int uid );
140 ~RemoveQuery(); 143 ~RemoveQuery();
141 QString query()const; 144 QString query()const;
142 private: 145 private:
143 int m_uid; 146 int m_uid;
144 }; 147 };
145 148
146 /** 149 /**
147 * a find query for noncustom elements 150 * a find query for noncustom elements
148 */ 151 */
149 class FindQuery : public OSQLQuery { 152 class FindQuery : public OSQLQuery {
150 public: 153 public:
151 FindQuery(int uid); 154 FindQuery(int uid);
152 FindQuery(const QArray<int>& ); 155 FindQuery(const QArray<int>& );
153 ~FindQuery(); 156 ~FindQuery();
154 QString query()const; 157 QString query()const;
155 private: 158 private:
156 QString single()const; 159 QString single()const;
157 QString multi()const; 160 QString multi()const;
158 QArray<int> m_uids; 161 QArray<int> m_uids;
159 int m_uid; 162 int m_uid;
160 }; 163 };
161 164
162 /** 165 /**
163 * a find query for custom elements 166 * a find query for custom elements
164 */ 167 */
165 class FindCustomQuery : public OSQLQuery { 168 class FindCustomQuery : public OSQLQuery {
166 public: 169 public:
167 FindCustomQuery(int uid); 170 FindCustomQuery(int uid);
168 FindCustomQuery(const QArray<int>& ); 171 FindCustomQuery(const QArray<int>& );
169 ~FindCustomQuery(); 172 ~FindCustomQuery();
170 QString query()const; 173 QString query()const;
171 private: 174 private:
172 QString single()const; 175 QString single()const;
173 QString multi()const; 176 QString multi()const;
174 QArray<int> m_uids; 177 QArray<int> m_uids;
175 int m_uid; 178 int m_uid;
176 }; 179 };
177 180
178 181
179 182
180 // We using three tables to store the information: 183 // We using three tables to store the information:
181 // 1. addressbook : It contains General information about the contact (non custom) 184 // 1. addressbook : It contains General information about the contact (non custom)
182 // 2. custom_data : Not official supported entries 185 // 2. custom_data : Not official supported entries
183 // All tables are connected by the uid of the contact. 186 // All tables are connected by the uid of the contact.
184 // Maybe I should add a table for meta-information ? 187 // Maybe I should add a table for meta-information ?
185 CreateQuery::CreateQuery() : OSQLQuery() {} 188 CreateQuery::CreateQuery() : OSQLQuery() {}
186 CreateQuery::~CreateQuery() {} 189 CreateQuery::~CreateQuery() {}
187 QString CreateQuery::query()const { 190 QString CreateQuery::query()const {
188 QString qu; 191 QString qu;
189#ifdef __STORE_HORIZONTAL_ 192#ifdef __STORE_HORIZONTAL_
190 193
191 qu += "create table addressbook( uid PRIMARY KEY "; 194 qu += "create table addressbook( uid PRIMARY KEY ";
192 195
193 QStringList fieldList = OContactFields::untrfields( false ); 196 QStringList fieldList = OContactFields::untrfields( false );
194 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 197 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
195 qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it ); 198 qu += QString( ",\"%1\" VARCHAR(10)" ).arg( *it );
196 } 199 }
197 qu += " );"; 200 qu += " );";
198 201
199 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; 202 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );";
200 203
201#else 204#else
202 205
203 qu += "create table addressbook( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id));"; 206 qu += "create table addressbook( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id));";
204 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; 207 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );";
205 // qu += "create table dates( uid PRIMARY KEY, type, day, month, year, hour, minute, second );"; 208 // qu += "create table dates( uid PRIMARY KEY, type, day, month, year, hour, minute, second );";
206 209
207#endif // __STORE_HORIZONTAL_ 210#endif // __STORE_HORIZONTAL_
208 return qu; 211 return qu;
209 } 212 }
210 213
211 ClearQuery::ClearQuery() 214 ClearQuery::ClearQuery()
212 : OSQLQuery() {} 215 : OSQLQuery() {}
213 ClearQuery::~ClearQuery() {} 216 ClearQuery::~ClearQuery() {}
214 QString ClearQuery::query()const { 217 QString ClearQuery::query()const {
215 QString qu = "drop table addressbook;"; 218 QString qu = "drop table addressbook;";
216 qu += "drop table custom_data;"; 219 qu += "drop table custom_data;";
217 // qu += "drop table dates;"; 220 // qu += "drop table dates;";
218 return qu; 221 return qu;
219 } 222 }
220 223
221 224
222 LoadQuery::LoadQuery() : OSQLQuery() {} 225 LoadQuery::LoadQuery() : OSQLQuery() {}
223 LoadQuery::~LoadQuery() {} 226 LoadQuery::~LoadQuery() {}
224 QString LoadQuery::query()const { 227 QString LoadQuery::query()const {
225 QString qu; 228 QString qu;
226#ifdef __STORE_HORIZONTAL_ 229#ifdef __STORE_HORIZONTAL_
227 qu += "select uid from addressbook"; 230 qu += "select uid from addressbook";
228#else 231#else
229# ifndef __USE_SUPERFAST_LOADQUERY 232# ifndef __USE_SUPERFAST_LOADQUERY
230 qu += "select distinct uid from addressbook"; 233 qu += "select distinct uid from addressbook";
231# else 234# else
232 qu += "select uid from addressbook where type = 'Last Name'"; 235 qu += "select uid from addressbook where type = 'Last Name'";
233# endif // __USE_SUPERFAST_LOADQUERY 236# endif // __USE_SUPERFAST_LOADQUERY
234#endif // __STORE_HORIZONTAL_ 237#endif // __STORE_HORIZONTAL_
235 238
236 return qu; 239 return qu;
237 } 240 }
238 241
239 242
240 InsertQuery::InsertQuery( const OContact& contact ) 243 InsertQuery::InsertQuery( const OContact& contact )
241 : OSQLQuery(), m_contact( contact ) { 244 : OSQLQuery(), m_contact( contact ) {
242 } 245 }
243 246
244 InsertQuery::~InsertQuery() { 247 InsertQuery::~InsertQuery() {
245 } 248 }
246 249
247 /* 250 /*
248 * converts from a OContact to a query 251 * converts from a OContact to a query
249 */ 252 */
250 QString InsertQuery::query()const{ 253 QString InsertQuery::query()const{
251 254
252#ifdef __STORE_HORIZONTAL_ 255#ifdef __STORE_HORIZONTAL_
253 QString qu; 256 QString qu;
254 qu += "insert into addressbook VALUES( " + 257 qu += "insert into addressbook VALUES( " +
255 QString::number( m_contact.uid() ); 258 QString::number( m_contact.uid() );
256 259
257 // Get all information out of the contact-class 260 // Get all information out of the contact-class
258 // Remember: The category is stored in contactMap, too ! 261 // Remember: The category is stored in contactMap, too !
259 QMap<int, QString> contactMap = m_contact.toMap(); 262 QMap<int, QString> contactMap = m_contact.toMap();
260 263
261 QStringList fieldList = OContactFields::untrfields( false ); 264 QStringList fieldList = OContactFields::untrfields( false );
262 QMap<QString, int> translate = OContactFields::untrFieldsToId(); 265 QMap<QString, int> translate = OContactFields::untrFieldsToId();
263 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 266 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
264 // Convert Column-String to Id and get value for this id.. 267 // Convert Column-String to Id and get value for this id..
265 // Hmmm.. Maybe not very cute solution.. 268 // Hmmm.. Maybe not very cute solution..
266 int id = translate[*it]; 269 int id = translate[*it];
267 switch ( id ){ 270 switch ( id ){
268 case Qtopia::Birthday:{ 271 case Qtopia::Birthday:{
269 // These entries should stored in a special format 272 // These entries should stored in a special format
270 // year-month-day 273 // year-month-day
271 QDate day = m_contact.birthday(); 274 QDate day = m_contact.birthday();
272 if ( day.isValid() ){ 275 if ( day.isValid() ){
273 qu += QString(",\"%1-%2-%3\"") 276 qu += QString(",\"%1-%2-%3\"")
274 .arg( day.year() ) 277 .arg( day.year() )
275 .arg( day.month() ) 278 .arg( day.month() )
276 .arg( day.day() ); 279 .arg( day.day() );
277 } else { 280 } else {
278 qu += ",\"\""; 281 qu += ",\"\"";
279 } 282 }
280 } 283 }
281 break; 284 break;
282 case Qtopia::Anniversary:{ 285 case Qtopia::Anniversary:{
283 // These entries should stored in a special format 286 // These entries should stored in a special format
284 // year-month-day 287 // year-month-day
285 QDate day = m_contact.anniversary(); 288 QDate day = m_contact.anniversary();
286 if ( day.isValid() ){ 289 if ( day.isValid() ){
287 qu += QString(",\"%1-%2-%3\"") 290 qu += QString(",\"%1-%2-%3\"")
288 .arg( day.year() ) 291 .arg( day.year() )
289 .arg( day.month() ) 292 .arg( day.month() )
290 .arg( day.day() ); 293 .arg( day.day() );
291 } else { 294 } else {
292 qu += ",\"\""; 295 qu += ",\"\"";
293 } 296 }
294 } 297 }
295 break; 298 break;
296 299
297 default: 300 default:
298 qu += QString( ",\"%1\"" ).arg( contactMap[id] ); 301 qu += QString( ",\"%1\"" ).arg( contactMap[id] );
299 } 302 }
300 } 303 }
301 qu += " );"; 304 qu += " );";
302 305
303 306
304#else 307#else
305 // Get all information out of the contact-class 308 // Get all information out of the contact-class
306 // Remember: The category is stored in contactMap, too ! 309 // Remember: The category is stored in contactMap, too !
307 QMap<int, QString> contactMap = m_contact.toMap(); 310 QMap<int, QString> contactMap = m_contact.toMap();
308 311
309 QMap<QString, QString> addressbook_db; 312 QMap<QString, QString> addressbook_db;
310 313
311 // Get the translation from the ID to the String 314 // Get the translation from the ID to the String
312 QMap<int, QString> transMap = OContactFields::idToUntrFields(); 315 QMap<int, QString> transMap = OContactFields::idToUntrFields();
313 316
314 for( QMap<int, QString>::Iterator it = contactMap.begin(); 317 for( QMap<int, QString>::Iterator it = contactMap.begin();
315 it != contactMap.end(); ++it ){ 318 it != contactMap.end(); ++it ){
316 switch ( it.key() ){ 319 switch ( it.key() ){
317 case Qtopia::Birthday:{ 320 case Qtopia::Birthday:{
318 // These entries should stored in a special format 321 // These entries should stored in a special format
319 // year-month-day 322 // year-month-day
320 QDate day = m_contact.birthday(); 323 QDate day = m_contact.birthday();
321 addressbook_db.insert( transMap[it.key()], 324 addressbook_db.insert( transMap[it.key()],
322 QString("%1-%2-%3") 325 QString("%1-%2-%3")
323 .arg( day.year() ) 326 .arg( day.year() )
324 .arg( day.month() ) 327 .arg( day.month() )
325 .arg( day.day() ) ); 328 .arg( day.day() ) );
326 } 329 }
327 break; 330 break;
328 case Qtopia::Anniversary:{ 331 case Qtopia::Anniversary:{
329 // These entries should stored in a special format 332 // These entries should stored in a special format
330 // year-month-day 333 // year-month-day
331 QDate day = m_contact.anniversary(); 334 QDate day = m_contact.anniversary();
332 addressbook_db.insert( transMap[it.key()], 335 addressbook_db.insert( transMap[it.key()],
333 QString("%1-%2-%3") 336 QString("%1-%2-%3")
334 .arg( day.year() ) 337 .arg( day.year() )
335 .arg( day.month() ) 338 .arg( day.month() )
336 .arg( day.day() ) ); 339 .arg( day.day() ) );
337 } 340 }
338 break; 341 break;
339 case Qtopia::AddressUid: // Ignore UID 342 case Qtopia::AddressUid: // Ignore UID
340 break; 343 break;
341 default: // Translate id to String 344 default: // Translate id to String
342 addressbook_db.insert( transMap[it.key()], it.data() ); 345 addressbook_db.insert( transMap[it.key()], it.data() );
343 break; 346 break;
344 } 347 }
345 348
346 } 349 }
347 350
348 // Now convert this whole stuff into a SQL String, beginning with 351 // Now convert this whole stuff into a SQL String, beginning with
349 // the addressbook table.. 352 // the addressbook table..
350 QString qu; 353 QString qu;
351 // qu += "begin transaction;"; 354 // qu += "begin transaction;";
352 int id = 0; 355 int id = 0;
353 for( QMap<QString, QString>::Iterator it = addressbook_db.begin(); 356 for( QMap<QString, QString>::Iterator it = addressbook_db.begin();
354 it != addressbook_db.end(); ++it ){ 357 it != addressbook_db.end(); ++it ){
355 qu += "insert into addressbook VALUES(" 358 qu += "insert into addressbook VALUES("
356 + QString::number( m_contact.uid() ) 359 + QString::number( m_contact.uid() )
357 + "," 360 + ","
358 + QString::number( id++ ) 361 + QString::number( id++ )
359 + ",'" 362 + ",'"
360 + it.key() //.latin1() 363 + it.key() //.latin1()
361 + "'," 364 + "',"
362 + "0" // Priority for future enhancements 365 + "0" // Priority for future enhancements
363 + ",'" 366 + ",'"
364 + it.data() //.latin1() 367 + it.data() //.latin1()
365 + "');"; 368 + "');";
366 } 369 }
367 370
368 #endif //__STORE_HORIZONTAL_ 371 #endif //__STORE_HORIZONTAL_
369 // Now add custom data.. 372 // Now add custom data..
370#ifdef __STORE_HORIZONTAL_ 373#ifdef __STORE_HORIZONTAL_
371 int id = 0; 374 int id = 0;
372#endif 375#endif
373 id = 0; 376 id = 0;
374 QMap<QString, QString> customMap = m_contact.toExtraMap(); 377 QMap<QString, QString> customMap = m_contact.toExtraMap();
375 for( QMap<QString, QString>::Iterator it = customMap.begin(); 378 for( QMap<QString, QString>::Iterator it = customMap.begin();
376 it != customMap.end(); ++it ){ 379 it != customMap.end(); ++it ){
377 qu += "insert into custom_data VALUES(" 380 qu += "insert into custom_data VALUES("
378 + QString::number( m_contact.uid() ) 381 + QString::number( m_contact.uid() )
379 + "," 382 + ","
380 + QString::number( id++ ) 383 + QString::number( id++ )
381 + ",'" 384 + ",'"
382 + it.key() //.latin1() 385 + it.key() //.latin1()
383 + "'," 386 + "',"
384 + "0" // Priority for future enhancements 387 + "0" // Priority for future enhancements
385 + ",'" 388 + ",'"
386 + it.data() //.latin1() 389 + it.data() //.latin1()
387 + "');"; 390 + "');";
388 } 391 }
389 // qu += "commit;"; 392 // qu += "commit;";
390 qWarning("add %s", qu.latin1() ); 393 qWarning("add %s", qu.latin1() );
391 return qu; 394 return qu;
392 } 395 }
393 396
394 397
395 RemoveQuery::RemoveQuery(int uid ) 398 RemoveQuery::RemoveQuery(int uid )
396 : OSQLQuery(), m_uid( uid ) {} 399 : OSQLQuery(), m_uid( uid ) {}
397 RemoveQuery::~RemoveQuery() {} 400 RemoveQuery::~RemoveQuery() {}
398 QString RemoveQuery::query()const { 401 QString RemoveQuery::query()const {
399 QString qu = "DELETE from addressbook where uid = " 402 QString qu = "DELETE from addressbook where uid = "
400 + QString::number(m_uid) + ";"; 403 + QString::number(m_uid) + ";";
401 qu += "DELETE from custom_data where uid = " 404 qu += "DELETE from custom_data where uid = "
402 + QString::number(m_uid) + ";"; 405 + QString::number(m_uid) + ";";
403 return qu; 406 return qu;
404 } 407 }
405 408
406 409
407 410
408 411
409 FindQuery::FindQuery(int uid) 412 FindQuery::FindQuery(int uid)
410 : OSQLQuery(), m_uid( uid ) { 413 : OSQLQuery(), m_uid( uid ) {
411 } 414 }
412 FindQuery::FindQuery(const QArray<int>& ints) 415 FindQuery::FindQuery(const QArray<int>& ints)
413 : OSQLQuery(), m_uids( ints ){ 416 : OSQLQuery(), m_uids( ints ){
414 } 417 }
415 FindQuery::~FindQuery() { 418 FindQuery::~FindQuery() {
416 } 419 }
417 QString FindQuery::query()const{ 420 QString FindQuery::query()const{
418 // if ( m_uids.count() == 0 ) 421 // if ( m_uids.count() == 0 )
419 return single(); 422 return single();
420 } 423 }
421 /* 424 /*
422 else 425 else
423 return multi(); 426 return multi();
424 } 427 }
425 QString FindQuery::multi()const { 428 QString FindQuery::multi()const {
426 QString qu = "select uid, type, value from addressbook where"; 429 QString qu = "select uid, type, value from addressbook where";
427 for (uint i = 0; i < m_uids.count(); i++ ) { 430 for (uint i = 0; i < m_uids.count(); i++ ) {
428 qu += " UID = " + QString::number( m_uids[i] ) + " OR"; 431 qu += " UID = " + QString::number( m_uids[i] ) + " OR";
429 } 432 }
430 qu.remove( qu.length()-2, 2 ); // Hmmmm.. 433 qu.remove( qu.length()-2, 2 ); // Hmmmm..
431 return qu; 434 return qu;
432 } 435 }
433 */ 436 */
434#ifdef __STORE_HORIZONTAL_ 437#ifdef __STORE_HORIZONTAL_
435 QString FindQuery::single()const{ 438 QString FindQuery::single()const{
436 QString qu = "select *"; 439 QString qu = "select *";
437 qu += " from addressbook where uid = " + QString::number(m_uid); 440 qu += " from addressbook where uid = " + QString::number(m_uid);
438 441
439 // qWarning("find query: %s", qu.latin1() ); 442 // qWarning("find query: %s", qu.latin1() );
440 return qu; 443 return qu;
441 } 444 }
442#else 445#else
443 QString FindQuery::single()const{ 446 QString FindQuery::single()const{
444 QString qu = "select uid, type, value from addressbook where uid = "; 447 QString qu = "select uid, type, value from addressbook where uid = ";
445 qu += QString::number(m_uid); 448 qu += QString::number(m_uid);
446 return qu; 449 return qu;
447 } 450 }
448#endif 451#endif
449 452
450 453
451 FindCustomQuery::FindCustomQuery(int uid) 454 FindCustomQuery::FindCustomQuery(int uid)
452 : OSQLQuery(), m_uid( uid ) { 455 : OSQLQuery(), m_uid( uid ) {
453 } 456 }
454 FindCustomQuery::FindCustomQuery(const QArray<int>& ints) 457 FindCustomQuery::FindCustomQuery(const QArray<int>& ints)
455 : OSQLQuery(), m_uids( ints ){ 458 : OSQLQuery(), m_uids( ints ){
456 } 459 }
457 FindCustomQuery::~FindCustomQuery() { 460 FindCustomQuery::~FindCustomQuery() {
458 } 461 }
459 QString FindCustomQuery::query()const{ 462 QString FindCustomQuery::query()const{
460 // if ( m_uids.count() == 0 ) 463 // if ( m_uids.count() == 0 )
461 return single(); 464 return single();
462 } 465 }
463 QString FindCustomQuery::single()const{ 466 QString FindCustomQuery::single()const{
464 QString qu = "select uid, type, value from custom_data where uid = "; 467 QString qu = "select uid, type, value from custom_data where uid = ";
465 qu += QString::number(m_uid); 468 qu += QString::number(m_uid);
466 return qu; 469 return qu;
467 } 470 }
468 471
469}; 472};
470 473
471 474
472/* --------------------------------------------------------------------------- */ 475/* --------------------------------------------------------------------------- */
473 476
474OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname */, 477OContactAccessBackend_SQL::OContactAccessBackend_SQL ( const QString& /* appname */,
475 const QString& filename ): 478 const QString& filename ):
476 OContactAccessBackend(), m_changed(false), m_driver( NULL ) 479 OContactAccessBackend(), m_changed(false), m_driver( NULL )
477{ 480{
478 qWarning("C'tor OContactAccessBackend_SQL starts"); 481 qWarning("C'tor OContactAccessBackend_SQL starts");
479 QTime t; 482 QTime t;
480 t.start(); 483 t.start();
481 484
482 /* Expecting to access the default filename if nothing else is set */ 485 /* Expecting to access the default filename if nothing else is set */
483 if ( filename.isEmpty() ){ 486 if ( filename.isEmpty() ){
484 m_fileName = Global::applicationFileName( "addressbook","addressbook.db" ); 487 m_fileName = Global::applicationFileName( "addressbook","addressbook.db" );
485 } else 488 } else
486 m_fileName = filename; 489 m_fileName = filename;
487 490
488 // Get the standart sql-driver from the OSQLManager.. 491 // Get the standart sql-driver from the OSQLManager..
489 OSQLManager man; 492 OSQLManager man;
490 m_driver = man.standard(); 493 m_driver = man.standard();
491 m_driver->setUrl( m_fileName ); 494 m_driver->setUrl( m_fileName );
492 495
493 load(); 496 load();
494 497
495 qWarning("C'tor OContactAccessBackend_SQL ends: %d ms", t.elapsed() ); 498 qWarning("C'tor OContactAccessBackend_SQL ends: %d ms", t.elapsed() );
496} 499}
497 500
498OContactAccessBackend_SQL::~OContactAccessBackend_SQL () 501OContactAccessBackend_SQL::~OContactAccessBackend_SQL ()
499{ 502{
500 if( m_driver ) 503 if( m_driver )
501 delete m_driver; 504 delete m_driver;
502} 505}
503 506
504bool OContactAccessBackend_SQL::load () 507bool OContactAccessBackend_SQL::load ()
505{ 508{
506 if (!m_driver->open() ) 509 if (!m_driver->open() )
507 return false; 510 return false;
508 511
509 // Don't expect that the database exists. 512 // Don't expect that the database exists.
510 // It is save here to create the table, even if it 513 // It is save here to create the table, even if it
511 // do exist. ( Is that correct for all databases ?? ) 514 // do exist. ( Is that correct for all databases ?? )
512 CreateQuery creat; 515 CreateQuery creat;
513 OSQLResult res = m_driver->query( &creat ); 516 OSQLResult res = m_driver->query( &creat );
514 517
515 update(); 518 update();
516 519
517 return true; 520 return true;
518 521
519} 522}
520 523
521bool OContactAccessBackend_SQL::reload() 524bool OContactAccessBackend_SQL::reload()
522{ 525{
523 return load(); 526 return load();
524} 527}
525 528
526bool OContactAccessBackend_SQL::save() 529bool OContactAccessBackend_SQL::save()
527{ 530{
528 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) 531 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
529} 532}
530 533
531 534
532void OContactAccessBackend_SQL::clear () 535void OContactAccessBackend_SQL::clear ()
533{ 536{
534 ClearQuery cle; 537 ClearQuery cle;
535 OSQLResult res = m_driver->query( &cle ); 538 OSQLResult res = m_driver->query( &cle );
536 539
537 reload(); 540 reload();
538} 541}
539 542
540bool OContactAccessBackend_SQL::wasChangedExternally() 543bool OContactAccessBackend_SQL::wasChangedExternally()
541{ 544{
542 return false; 545 return false;
543} 546}
544 547
545QArray<int> OContactAccessBackend_SQL::allRecords() const 548QArray<int> OContactAccessBackend_SQL::allRecords() const
546{ 549{
547 550
548 // FIXME: Think about cute handling of changed tables.. 551 // FIXME: Think about cute handling of changed tables..
549 // Thus, we don't have to call update here... 552 // Thus, we don't have to call update here...
550 if ( m_changed ) 553 if ( m_changed )
551 ((OContactAccessBackend_SQL*)this)->update(); 554 ((OContactAccessBackend_SQL*)this)->update();
552 555
553 return m_uids; 556 return m_uids;
554} 557}
555 558
556bool OContactAccessBackend_SQL::add ( const OContact &newcontact ) 559bool OContactAccessBackend_SQL::add ( const OContact &newcontact )
557{ 560{
558 InsertQuery ins( newcontact ); 561 InsertQuery ins( newcontact );
559 OSQLResult res = m_driver->query( &ins ); 562 OSQLResult res = m_driver->query( &ins );
560 563
561 if ( res.state() == OSQLResult::Failure ) 564 if ( res.state() == OSQLResult::Failure )
562 return false; 565 return false;
563 566
564 int c = m_uids.count(); 567 int c = m_uids.count();
565 m_uids.resize( c+1 ); 568 m_uids.resize( c+1 );
566 m_uids[c] = newcontact.uid(); 569 m_uids[c] = newcontact.uid();
567 570
568 return true; 571 return true;
569} 572}
570 573
571 574
572bool OContactAccessBackend_SQL::remove ( int uid ) 575bool OContactAccessBackend_SQL::remove ( int uid )
573{ 576{
574 RemoveQuery rem( uid ); 577 RemoveQuery rem( uid );
575 OSQLResult res = m_driver->query(&rem ); 578 OSQLResult res = m_driver->query(&rem );
576 579
577 if ( res.state() == OSQLResult::Failure ) 580 if ( res.state() == OSQLResult::Failure )
578 return false; 581 return false;
579 582
580 m_changed = true; 583 m_changed = true;
581 584
582 return true; 585 return true;
583} 586}
584 587
585bool OContactAccessBackend_SQL::replace ( const OContact &contact ) 588bool OContactAccessBackend_SQL::replace ( const OContact &contact )
586{ 589{
587 if ( !remove( contact.uid() ) ) 590 if ( !remove( contact.uid() ) )
588 return false; 591 return false;
589 592
590 return add( contact ); 593 return add( contact );
591} 594}
592 595
593 596
594OContact OContactAccessBackend_SQL::find ( int uid ) const 597OContact OContactAccessBackend_SQL::find ( int uid ) const
595{ 598{
596 qWarning("OContactAccessBackend_SQL::find()"); 599 qWarning("OContactAccessBackend_SQL::find()");
597 QTime t; 600 QTime t;
598 t.start(); 601 t.start();
599 602
600 OContact retContact( requestNonCustom( uid ) ); 603 OContact retContact( requestNonCustom( uid ) );
601 retContact.setExtraMap( requestCustom( uid ) ); 604 retContact.setExtraMap( requestCustom( uid ) );
602 605
603 qWarning("OContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() ); 606 qWarning("OContactAccessBackend_SQL::find() needed: %d ms", t.elapsed() );
604 return retContact; 607 return retContact;
605} 608}
606 609
607 610
608 611
609QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ) 612QArray<int> OContactAccessBackend_SQL::queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() )
610{ 613{
611 QString qu = "SELECT uid FROM addressbook WHERE"; 614 QString qu = "SELECT uid FROM addressbook WHERE";
612 615
613 QMap<int, QString> queryFields = query.toMap(); 616 QMap<int, QString> queryFields = query.toMap();
614 QStringList fieldList = OContactFields::untrfields( false ); 617 QStringList fieldList = OContactFields::untrfields( false );
615 QMap<QString, int> translate = OContactFields::untrFieldsToId(); 618 QMap<QString, int> translate = OContactFields::untrFieldsToId();
616 619
617 // Convert every filled field to a SQL-Query 620 // Convert every filled field to a SQL-Query
618 bool isAnyFieldSelected = false; 621 bool isAnyFieldSelected = false;
619 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 622 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
620 int id = translate[*it]; 623 int id = translate[*it];
621 QString queryStr = queryFields[id]; 624 QString queryStr = queryFields[id];
622 if ( !queryStr.isEmpty() ){ 625 if ( !queryStr.isEmpty() ){
623 isAnyFieldSelected = true; 626 isAnyFieldSelected = true;
624 switch( id ){ 627 switch( id ){
625 default: 628 default:
626 // Switching between case sensitive and insensitive... 629 // Switching between case sensitive and insensitive...
627 // LIKE is not case sensitive, GLOB is case sensitive 630 // LIKE is not case sensitive, GLOB is case sensitive
628 // Do exist a better solution to switch this ? 631 // Do exist a better solution to switch this ?
629 if ( settings & OContactAccess::IgnoreCase ) 632 if ( settings & OContactAccess::IgnoreCase )
630 qu += "(\"" + *it + "\"" + " LIKE " + "'" 633 qu += "(\"" + *it + "\"" + " LIKE " + "'"
631 + queryStr.replace(QRegExp("\\*"),"%") + "'" + ") AND "; 634 + queryStr.replace(QRegExp("\\*"),"%") + "'" + ") AND ";
632 else 635 else
633 qu += "(\"" + *it + "\"" + " GLOB " + "'" 636 qu += "(\"" + *it + "\"" + " GLOB " + "'"
634 + queryStr + "'" + ") AND "; 637 + queryStr + "'" + ") AND ";
635 638
636 } 639 }
637 } 640 }
638 } 641 }
639 // Skip trailing "AND" 642 // Skip trailing "AND"
640 if ( isAnyFieldSelected ) 643 if ( isAnyFieldSelected )
641 qu = qu.left( qu.length() - 4 ); 644 qu = qu.left( qu.length() - 4 );
642 645
643 qWarning( "queryByExample query: %s", qu.latin1() ); 646 qWarning( "queryByExample query: %s", qu.latin1() );
644 647
645 // Execute query and return the received uid's 648 // Execute query and return the received uid's
646 OSQLRawQuery raw( qu ); 649 OSQLRawQuery raw( qu );
647 OSQLResult res = m_driver->query( &raw ); 650 OSQLResult res = m_driver->query( &raw );
648 if ( res.state() != OSQLResult::Success ){ 651 if ( res.state() != OSQLResult::Success ){
649 QArray<int> empty; 652 QArray<int> empty;
650 return empty; 653 return empty;
651 } 654 }
652 655
653 QArray<int> list = extractUids( res ); 656 QArray<int> list = extractUids( res );
654 657
655 return list; 658 return list;
656} 659}
657 660
658QArray<int> OContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const 661QArray<int> OContactAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
659{ 662{
660 QArray<int> nix(0); 663 QArray<int> nix(0);
661 return nix; 664 return nix;
662} 665}
663 666
664const uint OContactAccessBackend_SQL::querySettings() 667const uint OContactAccessBackend_SQL::querySettings()
665{ 668{
666 return OContactAccess::IgnoreCase 669 return OContactAccess::IgnoreCase
667 || OContactAccess::WildCards; 670 || OContactAccess::WildCards;
668} 671}
669 672
670bool OContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const 673bool OContactAccessBackend_SQL::hasQuerySettings (uint querySettings) const
671{ 674{
672 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay 675 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
673 * may be added with any of the other settings. IgnoreCase should never used alone. 676 * may be added with any of the other settings. IgnoreCase should never used alone.
674 * Wildcards, RegExp, ExactMatch should never used at the same time... 677 * Wildcards, RegExp, ExactMatch should never used at the same time...
675 */ 678 */
676 679
677 // Step 1: Check whether the given settings are supported by this backend 680 // Step 1: Check whether the given settings are supported by this backend
678 if ( ( querySettings & ( 681 if ( ( querySettings & (
679 OContactAccess::IgnoreCase 682 OContactAccess::IgnoreCase
680 | OContactAccess::WildCards 683 | OContactAccess::WildCards
681 // | OContactAccess::DateDiff 684 // | OContactAccess::DateDiff
682 // | OContactAccess::DateYear 685 // | OContactAccess::DateYear
683 // | OContactAccess::DateMonth 686 // | OContactAccess::DateMonth
684 // | OContactAccess::DateDay 687 // | OContactAccess::DateDay
685 // | OContactAccess::RegExp 688 // | OContactAccess::RegExp
686 // | OContactAccess::ExactMatch 689 // | OContactAccess::ExactMatch
687 ) ) != querySettings ) 690 ) ) != querySettings )
688 return false; 691 return false;
689 692
690 // Step 2: Check whether the given combinations are ok.. 693 // Step 2: Check whether the given combinations are ok..
691 694
692 // IngoreCase alone is invalid 695 // IngoreCase alone is invalid
693 if ( querySettings == OContactAccess::IgnoreCase ) 696 if ( querySettings == OContactAccess::IgnoreCase )
694 return false; 697 return false;
695 698
696 // WildCards, RegExp and ExactMatch should never used at the same time 699 // WildCards, RegExp and ExactMatch should never used at the same time
697 switch ( querySettings & ~( OContactAccess::IgnoreCase 700 switch ( querySettings & ~( OContactAccess::IgnoreCase
698 | OContactAccess::DateDiff 701 | OContactAccess::DateDiff
699 | OContactAccess::DateYear 702 | OContactAccess::DateYear
700 | OContactAccess::DateMonth 703 | OContactAccess::DateMonth
701 | OContactAccess::DateDay 704 | OContactAccess::DateDay
702 ) 705 )
703 ){ 706 ){
704 case OContactAccess::RegExp: 707 case OContactAccess::RegExp:
705 return ( true ); 708 return ( true );
706 case OContactAccess::WildCards: 709 case OContactAccess::WildCards:
707 return ( true ); 710 return ( true );
708 case OContactAccess::ExactMatch: 711 case OContactAccess::ExactMatch:
709 return ( true ); 712 return ( true );
710 case 0: // one of the upper removed bits were set.. 713 case 0: // one of the upper removed bits were set..
711 return ( true ); 714 return ( true );
712 default: 715 default:
713 return ( false ); 716 return ( false );
714 } 717 }
715 718
716} 719}
717 720
718QArray<int> OContactAccessBackend_SQL::sorted( bool asc, int , int , int ) 721QArray<int> OContactAccessBackend_SQL::sorted( bool asc, int , int , int )
719{ 722{
720 QTime t; 723 QTime t;
721 t.start(); 724 t.start();
722 725
723#ifdef __STORE_HORIZONTAL_ 726#ifdef __STORE_HORIZONTAL_
724 QString query = "SELECT uid FROM addressbook "; 727 QString query = "SELECT uid FROM addressbook ";
725 query += "ORDER BY \"Last Name\" "; 728 query += "ORDER BY \"Last Name\" ";
726#else 729#else
727 QString query = "SELECT uid FROM addressbook WHERE type = 'Last Name' "; 730 QString query = "SELECT uid FROM addressbook WHERE type = 'Last Name' ";
728 query += "ORDER BY upper( value )"; 731 query += "ORDER BY upper( value )";
729#endif 732#endif
730 733
731 if ( !asc ) 734 if ( !asc )
732 query += "DESC"; 735 query += "DESC";
733 736
734 // qWarning("sorted query is: %s", query.latin1() ); 737 // qWarning("sorted query is: %s", query.latin1() );
735 738
736 OSQLRawQuery raw( query ); 739 OSQLRawQuery raw( query );
737 OSQLResult res = m_driver->query( &raw ); 740 OSQLResult res = m_driver->query( &raw );
738 if ( res.state() != OSQLResult::Success ){ 741 if ( res.state() != OSQLResult::Success ){
739 QArray<int> empty; 742 QArray<int> empty;
740 return empty; 743 return empty;
741 } 744 }
742 745
743 QArray<int> list = extractUids( res ); 746 QArray<int> list = extractUids( res );
744 747
745 qWarning("sorted needed %d ms!", t.elapsed() ); 748 qWarning("sorted needed %d ms!", t.elapsed() );
746 return list; 749 return list;
747} 750}
748 751
749 752
750void OContactAccessBackend_SQL::update() 753void OContactAccessBackend_SQL::update()
751{ 754{
752 qWarning("Update starts"); 755 qWarning("Update starts");
753 QTime t; 756 QTime t;
754 t.start(); 757 t.start();
755 758
756 // Now load the database set and extract the uid's 759 // Now load the database set and extract the uid's
757 // which will be held locally 760 // which will be held locally
758 761
759 LoadQuery lo; 762 LoadQuery lo;
760 OSQLResult res = m_driver->query(&lo); 763 OSQLResult res = m_driver->query(&lo);
761 if ( res.state() != OSQLResult::Success ) 764 if ( res.state() != OSQLResult::Success )
762 return; 765 return;
763 766
764 m_uids = extractUids( res ); 767 m_uids = extractUids( res );
765 768
766 m_changed = false; 769 m_changed = false;
767 770
768 qWarning("Update ends %d ms", t.elapsed() ); 771 qWarning("Update ends %d ms", t.elapsed() );
769} 772}
770 773
771QArray<int> OContactAccessBackend_SQL::extractUids( OSQLResult& res ) const 774QArray<int> OContactAccessBackend_SQL::extractUids( OSQLResult& res ) const
772{ 775{
773 qWarning("extractUids"); 776 qWarning("extractUids");
774 QTime t; 777 QTime t;
775 t.start(); 778 t.start();
776 OSQLResultItem::ValueList list = res.results(); 779 OSQLResultItem::ValueList list = res.results();
777 OSQLResultItem::ValueList::Iterator it; 780 OSQLResultItem::ValueList::Iterator it;
778 QArray<int> ints(list.count() ); 781 QArray<int> ints(list.count() );
779 qWarning(" count = %d", list.count() ); 782 qWarning(" count = %d", list.count() );
780 783
781 int i = 0; 784 int i = 0;
782 for (it = list.begin(); it != list.end(); ++it ) { 785 for (it = list.begin(); it != list.end(); ++it ) {
783 ints[i] = (*it).data("uid").toInt(); 786 ints[i] = (*it).data("uid").toInt();
784 i++; 787 i++;
785 } 788 }
786 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); 789 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() );
787 790
788 return ints; 791 return ints;
789 792
790} 793}
791 794
792#ifdef __STORE_HORIZONTAL_ 795#ifdef __STORE_HORIZONTAL_
793QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const 796QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
794{ 797{
795 QTime t; 798 QTime t;
796 t.start(); 799 t.start();
797 800
798 QMap<int, QString> nonCustomMap; 801 QMap<int, QString> nonCustomMap;
799 802
800 int t2needed = 0; 803 int t2needed = 0;
801 int t3needed = 0; 804 int t3needed = 0;
802 QTime t2; 805 QTime t2;
803 t2.start(); 806 t2.start();
804 FindQuery query( uid ); 807 FindQuery query( uid );
805 OSQLResult res_noncustom = m_driver->query( &query ); 808 OSQLResult res_noncustom = m_driver->query( &query );
806 t2needed = t2.elapsed(); 809 t2needed = t2.elapsed();
807 810
808 OSQLResultItem resItem = res_noncustom.first(); 811 OSQLResultItem resItem = res_noncustom.first();
809 812
810 QTime t3; 813 QTime t3;
811 t3.start(); 814 t3.start();
812 // Now loop through all columns 815 // Now loop through all columns
813 QStringList fieldList = OContactFields::untrfields( false ); 816 QStringList fieldList = OContactFields::untrfields( false );
814 QMap<QString, int> translate = OContactFields::untrFieldsToId(); 817 QMap<QString, int> translate = OContactFields::untrFieldsToId();
815 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){ 818 for ( QStringList::Iterator it = ++fieldList.begin(); it != fieldList.end(); ++it ){
816 // Get data for the selected column and store it with the 819 // Get data for the selected column and store it with the
817 // corresponding id into the map.. 820 // corresponding id into the map..
818 821
819 int id = translate[*it]; 822 int id = translate[*it];
820 QString value = resItem.data( (*it) ); 823 QString value = resItem.data( (*it) );
821 824
822 // qWarning("Reading %s... found: %s", (*it).latin1(), value.latin1() ); 825 // qWarning("Reading %s... found: %s", (*it).latin1(), value.latin1() );
823 826
824 switch( id ){ 827 switch( id ){
825 case Qtopia::Birthday: 828 case Qtopia::Birthday:
826 case Qtopia::Anniversary:{ 829 case Qtopia::Anniversary:{
827 // Birthday and Anniversary are encoded special ( yyyy-mm-dd ) 830 // Birthday and Anniversary are encoded special ( yyyy-mm-dd )
828 QStringList list = QStringList::split( '-', value ); 831 QStringList list = QStringList::split( '-', value );
829 QStringList::Iterator lit = list.begin(); 832 QStringList::Iterator lit = list.begin();
830 int year = (*lit).toInt(); 833 int year = (*lit).toInt();
831 int month = (*(++lit)).toInt(); 834 int month = (*(++lit)).toInt();
832 int day = (*(++lit)).toInt(); 835 int day = (*(++lit)).toInt();
833 if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){ 836 if ( ( day != 0 ) && ( month != 0 ) && ( year != 0 ) ){
834 QDate date( year, month, day ); 837 QDate date( year, month, day );
835 nonCustomMap.insert( id, OConversion::dateToString( date ) ); 838 nonCustomMap.insert( id, OConversion::dateToString( date ) );
836 } 839 }
837 } 840 }
838 break; 841 break;
839 case Qtopia::AddressCategory: 842 case Qtopia::AddressCategory:
840 qWarning("Category is: %s", value.latin1() ); 843 qWarning("Category is: %s", value.latin1() );
841 default: 844 default:
842 nonCustomMap.insert( id, value ); 845 nonCustomMap.insert( id, value );
843 } 846 }
844 } 847 }
845 848
846 // First insert uid 849 // First insert uid
847 nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) ); 850 nonCustomMap.insert( Qtopia::AddressUid, resItem.data( "uid" ) );
848 t3needed = t3.elapsed(); 851 t3needed = t3.elapsed();
849 852
850 // qWarning("Adding UID: %s", resItem.data( "uid" ).latin1() ); 853 // qWarning("Adding UID: %s", resItem.data( "uid" ).latin1() );
851 qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", 854 qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms",
852 t.elapsed(), t2needed, t3needed ); 855 t.elapsed(), t2needed, t3needed );
853 856
854 return nonCustomMap; 857 return nonCustomMap;
855} 858}
856#else 859#else
857 860
858QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const 861QMap<int, QString> OContactAccessBackend_SQL::requestNonCustom( int uid ) const
859{ 862{
860 QTime t; 863 QTime t;
861 t.start(); 864 t.start();
862 865
863 QMap<int, QString> nonCustomMap; 866 QMap<int, QString> nonCustomMap;
864 867
865 int t2needed = 0; 868 int t2needed = 0;
866 QTime t2; 869 QTime t2;
867 t2.start(); 870 t2.start();
868 FindQuery query( uid ); 871 FindQuery query( uid );
869 OSQLResult res_noncustom = m_driver->query( &query ); 872 OSQLResult res_noncustom = m_driver->query( &query );
870 t2needed = t2.elapsed(); 873 t2needed = t2.elapsed();
871 874
872 if ( res_noncustom.state() == OSQLResult::Failure ) { 875 if ( res_noncustom.state() == OSQLResult::Failure ) {
873 qWarning("OSQLResult::Failure in find query !!"); 876 qWarning("OSQLResult::Failure in find query !!");
874 QMap<int, QString> empty; 877 QMap<int, QString> empty;
875 return empty; 878 return empty;
876 } 879 }
877 880
878 int t3needed = 0; 881 int t3needed = 0;
879 QTime t3; 882 QTime t3;
880 t3.start(); 883 t3.start();
881 QMap<QString, int> translateMap = OContactFields::untrFieldsToId(); 884 QMap<QString, int> translateMap = OContactFields::untrFieldsToId();
882 885
883 OSQLResultItem::ValueList list = res_noncustom.results(); 886 OSQLResultItem::ValueList list = res_noncustom.results();
884 OSQLResultItem::ValueList::Iterator it = list.begin(); 887 OSQLResultItem::ValueList::Iterator it = list.begin();
885 for ( ; it != list.end(); ++it ) { 888 for ( ; it != list.end(); ++it ) {
886 if ( (*it).data("type") != "" ){ 889 if ( (*it).data("type") != "" ){
887 int typeId = translateMap[(*it).data( "type" )]; 890 int typeId = translateMap[(*it).data( "type" )];
888 switch( typeId ){ 891 switch( typeId ){
889 case Qtopia::Birthday: 892 case Qtopia::Birthday:
890 case Qtopia::Anniversary:{ 893 case Qtopia::Anniversary:{
891 // Birthday and Anniversary are encoded special ( yyyy-mm-dd ) 894 // Birthday and Anniversary are encoded special ( yyyy-mm-dd )
892 QStringList list = QStringList::split( '-', (*it).data( "value" ) ); 895 QStringList list = QStringList::split( '-', (*it).data( "value" ) );
893 QStringList::Iterator lit = list.begin(); 896 QStringList::Iterator lit = list.begin();
894 int year = (*lit).toInt(); 897 int year = (*lit).toInt();
895 qWarning("1. %s", (*lit).latin1()); 898 qWarning("1. %s", (*lit).latin1());
896 int month = (*(++lit)).toInt(); 899 int month = (*(++lit)).toInt();
897 qWarning("2. %s", (*lit).latin1()); 900 qWarning("2. %s", (*lit).latin1());
898 int day = (*(++lit)).toInt(); 901 int day = (*(++lit)).toInt();
899 qWarning("3. %s", (*lit).latin1()); 902 qWarning("3. %s", (*lit).latin1());
900 qWarning( "RequestNonCustom->Converting:%s to Year: %d, Month: %d, Day: %d ", (*it).data( "value" ).latin1(), year, month, day ); 903 qWarning( "RequestNonCustom->Converting:%s to Year: %d, Month: %d, Day: %d ", (*it).data( "value" ).latin1(), year, month, day );
901 QDate date( year, month, day ); 904 QDate date( year, month, day );
902 nonCustomMap.insert( typeId, OConversion::dateToString( date ) ); 905 nonCustomMap.insert( typeId, OConversion::dateToString( date ) );
903 } 906 }
904 break; 907 break;
905 default: 908 default:
906 nonCustomMap.insert( typeId, 909 nonCustomMap.insert( typeId,
907 (*it).data( "value" ) ); 910 (*it).data( "value" ) );
908 } 911 }
909 } 912 }
910 } 913 }
911 // Add UID to Map.. 914 // Add UID to Map..
912 nonCustomMap.insert( Qtopia::AddressUid, QString::number( uid ) ); 915 nonCustomMap.insert( Qtopia::AddressUid, QString::number( uid ) );
913 t3needed = t3.elapsed(); 916 t3needed = t3.elapsed();
914 917
915 qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", t.elapsed(), t2needed, t3needed ); 918 qWarning("RequestNonCustom needed: insg.:%d ms, query: %d ms, mapping: %d ms", t.elapsed(), t2needed, t3needed );
916 return nonCustomMap; 919 return nonCustomMap;
917} 920}
918 921
919#endif // __STORE_HORIZONTAL_ 922#endif // __STORE_HORIZONTAL_
920 923
921QMap<QString, QString> OContactAccessBackend_SQL::requestCustom( int uid ) const 924QMap<QString, QString> OContactAccessBackend_SQL::requestCustom( int uid ) const
922{ 925{
923 QTime t; 926 QTime t;
924 t.start(); 927 t.start();
925 928
926 QMap<QString, QString> customMap; 929 QMap<QString, QString> customMap;
927 930
928 FindCustomQuery query( uid ); 931 FindCustomQuery query( uid );
929 OSQLResult res_custom = m_driver->query( &query ); 932 OSQLResult res_custom = m_driver->query( &query );
930 933
931 if ( res_custom.state() == OSQLResult::Failure ) { 934 if ( res_custom.state() == OSQLResult::Failure ) {
932 qWarning("OSQLResult::Failure in find query !!"); 935 qWarning("OSQLResult::Failure in find query !!");
933 QMap<QString, QString> empty; 936 QMap<QString, QString> empty;
934 return empty; 937 return empty;
935 } 938 }
936 939
937 OSQLResultItem::ValueList list = res_custom.results(); 940 OSQLResultItem::ValueList list = res_custom.results();
938 OSQLResultItem::ValueList::Iterator it = list.begin(); 941 OSQLResultItem::ValueList::Iterator it = list.begin();
939 for ( ; it != list.end(); ++it ) { 942 for ( ; it != list.end(); ++it ) {
940 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) ); 943 customMap.insert( (*it).data( "type" ), (*it).data( "value" ) );
941 } 944 }
942 945
943 qWarning("RequestCustom needed: %d ms", t.elapsed() ); 946 qWarning("RequestCustom needed: %d ms", t.elapsed() );
944 return customMap; 947 return customMap;
945} 948}
diff --git a/libopie/pim/ocontactaccessbackend_sql.h b/noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h
index f553760..8cd92e8 100644
--- a/libopie/pim/ocontactaccessbackend_sql.h
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h
@@ -1,107 +1,110 @@
1/* 1/*
2 * SQL Backend for the OPIE-Contact Database. 2 * SQL Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * 12 *
13 * 13 *
14 * ===================================================================== 14 * =====================================================================
15 * Version: $Id$ 15 * Version: $Id$
16 * ===================================================================== 16 * =====================================================================
17 * History: 17 * History:
18 * $Log$ 18 * $Log$
19 * Revision 1.1 2004/11/16 21:46:07 mickeyl
20 * libopie1 goes into unsupported
21 *
19 * Revision 1.3 2004/03/14 13:50:35 alwin 22 * Revision 1.3 2004/03/14 13:50:35 alwin
20 * namespace correction 23 * namespace correction
21 * 24 *
22 * Revision 1.2 2003/12/08 15:18:11 eilers 25 * Revision 1.2 2003/12/08 15:18:11 eilers
23 * Committing unfinished sql implementation before merging to libopie2 starts.. 26 * Committing unfinished sql implementation before merging to libopie2 starts..
24 * 27 *
25 * Revision 1.1 2003/09/22 14:31:16 eilers 28 * Revision 1.1 2003/09/22 14:31:16 eilers
26 * Added first experimental incarnation of sql-backend for addressbook. 29 * Added first experimental incarnation of sql-backend for addressbook.
27 * Some modifications to be able to compile the todo sql-backend. 30 * Some modifications to be able to compile the todo sql-backend.
28 * A lot of changes fill follow... 31 * A lot of changes fill follow...
29 * 32 *
30 * 33 *
31 */ 34 */
32 35
33#ifndef _OContactAccessBackend_SQL_ 36#ifndef _OContactAccessBackend_SQL_
34#define _OContactAccessBackend_SQL_ 37#define _OContactAccessBackend_SQL_
35 38
36#include "ocontactaccessbackend.h" 39#include "ocontactaccessbackend.h"
37#include "ocontactaccess.h" 40#include "ocontactaccess.h"
38 41
39#include <qlist.h> 42#include <qlist.h>
40#include <qdict.h> 43#include <qdict.h>
41 44
42namespace Opie { namespace DB { 45namespace Opie { namespace DB {
43class OSQLDriver; 46class OSQLDriver;
44class OSQLResult; 47class OSQLResult;
45class OSQLResultItem; 48class OSQLResultItem;
46 49
47}} 50}}
48 51
49/* the default xml implementation */ 52/* the default xml implementation */
50/** 53/**
51 * This class is the SQL implementation of a Contact backend 54 * This class is the SQL implementation of a Contact backend
52 * it does implement everything available for OContact. 55 * it does implement everything available for OContact.
53 * @see OPimAccessBackend for more information of available methods 56 * @see OPimAccessBackend for more information of available methods
54 */ 57 */
55class OContactAccessBackend_SQL : public OContactAccessBackend { 58class OContactAccessBackend_SQL : public OContactAccessBackend {
56 public: 59 public:
57 OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null ); 60 OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
58 61
59 ~OContactAccessBackend_SQL (); 62 ~OContactAccessBackend_SQL ();
60 63
61 bool save(); 64 bool save();
62 65
63 bool load (); 66 bool load ();
64 67
65 void clear (); 68 void clear ();
66 69
67 bool wasChangedExternally(); 70 bool wasChangedExternally();
68 71
69 QArray<int> allRecords() const; 72 QArray<int> allRecords() const;
70 73
71 OContact find ( int uid ) const; 74 OContact find ( int uid ) const;
72 // FIXME: Add lookahead-cache support ! 75 // FIXME: Add lookahead-cache support !
73 //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const; 76 //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
74 77
75 QArray<int> queryByExample ( const OContact &query, int settings, 78 QArray<int> queryByExample ( const OContact &query, int settings,
76 const QDateTime& d ); 79 const QDateTime& d );
77 80
78 QArray<int> matchRegexp( const QRegExp &r ) const; 81 QArray<int> matchRegexp( const QRegExp &r ) const;
79 82
80 const uint querySettings(); 83 const uint querySettings();
81 84
82 bool hasQuerySettings (uint querySettings) const; 85 bool hasQuerySettings (uint querySettings) const;
83 86
84 // Currently only asc implemented.. 87 // Currently only asc implemented..
85 QArray<int> sorted( bool asc, int , int , int ); 88 QArray<int> sorted( bool asc, int , int , int );
86 bool add ( const OContact &newcontact ); 89 bool add ( const OContact &newcontact );
87 90
88 bool replace ( const OContact &contact ); 91 bool replace ( const OContact &contact );
89 92
90 bool remove ( int uid ); 93 bool remove ( int uid );
91 bool reload(); 94 bool reload();
92 95
93 private: 96 private:
94 QArray<int> extractUids( Opie::DB::OSQLResult& res ) const; 97 QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
95 QMap<int, QString> requestNonCustom( int uid ) const; 98 QMap<int, QString> requestNonCustom( int uid ) const;
96 QMap<QString, QString> requestCustom( int uid ) const; 99 QMap<QString, QString> requestCustom( int uid ) const;
97 void update(); 100 void update();
98 101
99 protected: 102 protected:
100 bool m_changed; 103 bool m_changed;
101 QString m_fileName; 104 QString m_fileName;
102 QArray<int> m_uids; 105 QArray<int> m_uids;
103 106
104 Opie::DB::OSQLDriver* m_driver; 107 Opie::DB::OSQLDriver* m_driver;
105}; 108};
106 109
107#endif 110#endif
diff --git a/libopie/pim/ocontactaccessbackend_vcard.cpp b/noncore/unsupported/libopie/pim/ocontactaccessbackend_vcard.cpp
index b60c5be..a795b56 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.cpp
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend_vcard.cpp
@@ -1,646 +1,649 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved. 4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.1 2004/11/16 21:46:07 mickeyl
21 * libopie1 goes into unsupported
22 *
20 * Revision 1.11 2003/08/01 12:30:16 eilers 23 * Revision 1.11 2003/08/01 12:30:16 eilers
21 * Merging changes from BRANCH_1_0 to HEAD 24 * Merging changes from BRANCH_1_0 to HEAD
22 * 25 *
23 * Revision 1.10.4.3 2003/07/23 08:54:37 eilers 26 * Revision 1.10.4.3 2003/07/23 08:54:37 eilers
24 * Default email was added to the list of all emails, which already contains 27 * Default email was added to the list of all emails, which already contains
25 * the default email.. 28 * the default email..
26 * This closes bug #1045 29 * This closes bug #1045
27 * 30 *
28 * Revision 1.10.4.2 2003/07/23 08:44:45 eilers 31 * Revision 1.10.4.2 2003/07/23 08:44:45 eilers
29 * Importing of Notes in vcard files wasn't implemented. 32 * Importing of Notes in vcard files wasn't implemented.
30 * Closes bug #1044 33 * Closes bug #1044
31 * 34 *
32 * Revision 1.10.4.1 2003/06/02 13:37:49 eilers 35 * Revision 1.10.4.1 2003/06/02 13:37:49 eilers
33 * Fixing memory leak 36 * Fixing memory leak
34 * 37 *
35 * Revision 1.10 2003/04/13 18:07:10 zecke 38 * Revision 1.10 2003/04/13 18:07:10 zecke
36 * More API doc 39 * More API doc
37 * QString -> const QString& 40 * QString -> const QString&
38 * QString = 0l -> QString::null 41 * QString = 0l -> QString::null
39 * 42 *
40 * Revision 1.9 2003/03/21 10:33:09 eilers 43 * Revision 1.9 2003/03/21 10:33:09 eilers
41 * Merged speed optimized xml backend for contacts to main. 44 * Merged speed optimized xml backend for contacts to main.
42 * Added QDateTime to querybyexample. For instance, it is now possible to get 45 * Added QDateTime to querybyexample. For instance, it is now possible to get
43 * all Birthdays/Anniversaries between two dates. This should be used 46 * all Birthdays/Anniversaries between two dates. This should be used
44 * to show all birthdays in the datebook.. 47 * to show all birthdays in the datebook..
45 * This change is sourcecode backward compatible but you have to upgrade 48 * This change is sourcecode backward compatible but you have to upgrade
46 * the binaries for today-addressbook. 49 * the binaries for today-addressbook.
47 * 50 *
48 * Revision 1.8 2003/02/21 16:52:49 zecke 51 * Revision 1.8 2003/02/21 16:52:49 zecke
49 * -Remove old Todo classes they're deprecated and today I already using the 52 * -Remove old Todo classes they're deprecated and today I already using the
50 * new API 53 * new API
51 * -Guard against self assignment in OTodo 54 * -Guard against self assignment in OTodo
52 * -Add test apps for OPIM 55 * -Add test apps for OPIM
53 * -Opiefied Event classes 56 * -Opiefied Event classes
54 * -Added TimeZone handling and pinning of TimeZones to OEvent 57 * -Added TimeZone handling and pinning of TimeZones to OEvent
55 * -Adjust ORecur and the widget to better timezone behaviour 58 * -Adjust ORecur and the widget to better timezone behaviour
56 * 59 *
57 * Revision 1.7 2003/02/16 22:25:46 zecke 60 * Revision 1.7 2003/02/16 22:25:46 zecke
58 * 0000276 Fix for that bug.. or better temp workaround 61 * 0000276 Fix for that bug.. or better temp workaround
59 * A Preferred Number is HOME|VOICE 62 * A Preferred Number is HOME|VOICE
60 * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test 63 * A CellPhone is HOME|VOICE|CELL the type & HOME|VOICE test
61 * triggers both 64 * triggers both
62 * and the cell phone number overrides the other entries.. 65 * and the cell phone number overrides the other entries..
63 * 66 *
64 * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the 67 * as a temp I check that it's not equal to HOME|VOICE|CELL before setting the
65 * number 68 * number
66 * 69 *
67 * The right and final fix would be to reorder the if statement to make it 70 * The right and final fix would be to reorder the if statement to make it
68 * if else based and the less common thing put to the bottom 71 * if else based and the less common thing put to the bottom
69 * 72 *
70 * OTodoAccessVcal fix the date for beaming 73 * OTodoAccessVcal fix the date for beaming
71 * 74 *
72 * Revision 1.6 2003/01/13 15:49:31 eilers 75 * Revision 1.6 2003/01/13 15:49:31 eilers
73 * Fixing crash when businesscard.vcf is missing.. 76 * Fixing crash when businesscard.vcf is missing..
74 * 77 *
75 * Revision 1.5 2002/12/07 13:26:22 eilers 78 * Revision 1.5 2002/12/07 13:26:22 eilers
76 * Fixing bug in storing anniversary.. 79 * Fixing bug in storing anniversary..
77 * 80 *
78 * Revision 1.4 2002/11/13 14:14:51 eilers 81 * Revision 1.4 2002/11/13 14:14:51 eilers
79 * Added sorted for Contacts.. 82 * Added sorted for Contacts..
80 * 83 *
81 * Revision 1.3 2002/11/11 16:41:09 kergoth 84 * Revision 1.3 2002/11/11 16:41:09 kergoth
82 * no default arguments in implementation 85 * no default arguments in implementation
83 * 86 *
84 * Revision 1.2 2002/11/10 15:41:53 eilers 87 * Revision 1.2 2002/11/10 15:41:53 eilers
85 * Bugfixes.. 88 * Bugfixes..
86 * 89 *
87 * Revision 1.1 2002/11/09 14:34:52 eilers 90 * Revision 1.1 2002/11/09 14:34:52 eilers
88 * Added VCard Backend. 91 * Added VCard Backend.
89 * 92 *
90 */ 93 */
91#include "ocontactaccessbackend_vcard.h" 94#include "ocontactaccessbackend_vcard.h"
92#include "../../library/backend/vobject_p.h" 95#include "../../library/backend/vobject_p.h"
93#include "../../library/backend/qfiledirect_p.h" 96#include "../../library/backend/qfiledirect_p.h"
94 97
95#include <qpe/timeconversion.h> 98#include <qpe/timeconversion.h>
96 99
97#include <qfile.h> 100#include <qfile.h>
98 101
99OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ): 102OContactAccessBackend_VCard::OContactAccessBackend_VCard ( const QString& , const QString& filename ):
100 m_dirty( false ), 103 m_dirty( false ),
101 m_file( filename ) 104 m_file( filename )
102{ 105{
103 load(); 106 load();
104} 107}
105 108
106 109
107bool OContactAccessBackend_VCard::load () 110bool OContactAccessBackend_VCard::load ()
108{ 111{
109 m_map.clear(); 112 m_map.clear();
110 m_dirty = false; 113 m_dirty = false;
111 114
112 VObject* obj = 0l; 115 VObject* obj = 0l;
113 116
114 if ( QFile::exists(m_file) ){ 117 if ( QFile::exists(m_file) ){
115 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() ); 118 obj = Parse_MIME_FromFileName( QFile::encodeName(m_file).data() );
116 if ( !obj ) 119 if ( !obj )
117 return false; 120 return false;
118 }else{ 121 }else{
119 qWarning("File \"%s\" not found !", m_file.latin1() ); 122 qWarning("File \"%s\" not found !", m_file.latin1() );
120 return false; 123 return false;
121 } 124 }
122 125
123 while ( obj ) { 126 while ( obj ) {
124 OContact con = parseVObject( obj ); 127 OContact con = parseVObject( obj );
125 /* 128 /*
126 * if uid is 0 assign a new one 129 * if uid is 0 assign a new one
127 * this at least happens on 130 * this at least happens on
128 * Nokia6210 131 * Nokia6210
129 */ 132 */
130 if ( con.uid() == 0 ){ 133 if ( con.uid() == 0 ){
131 con.setUid( 1 ); 134 con.setUid( 1 );
132 qWarning("assigned new uid %d",con.uid() ); 135 qWarning("assigned new uid %d",con.uid() );
133 } 136 }
134 137
135 m_map.insert( con.uid(), con ); 138 m_map.insert( con.uid(), con );
136 139
137 VObject *t = obj; 140 VObject *t = obj;
138 obj = nextVObjectInList(obj); 141 obj = nextVObjectInList(obj);
139 cleanVObject( t ); 142 cleanVObject( t );
140 } 143 }
141 144
142 return true; 145 return true;
143 146
144} 147}
145bool OContactAccessBackend_VCard::reload() 148bool OContactAccessBackend_VCard::reload()
146{ 149{
147 return load(); 150 return load();
148} 151}
149bool OContactAccessBackend_VCard::save() 152bool OContactAccessBackend_VCard::save()
150{ 153{
151 if (!m_dirty ) 154 if (!m_dirty )
152 return true; 155 return true;
153 156
154 QFileDirect file( m_file ); 157 QFileDirect file( m_file );
155 if (!file.open(IO_WriteOnly ) ) 158 if (!file.open(IO_WriteOnly ) )
156 return false; 159 return false;
157 160
158 VObject *obj; 161 VObject *obj;
159 obj = newVObject( VCCalProp ); 162 obj = newVObject( VCCalProp );
160 addPropValue( obj, VCVersionProp, "1.0" ); 163 addPropValue( obj, VCVersionProp, "1.0" );
161 164
162 VObject *vo; 165 VObject *vo;
163 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){ 166 for(QMap<int, OContact>::ConstIterator it=m_map.begin(); it !=m_map.end(); ++it ){
164 vo = createVObject( *it ); 167 vo = createVObject( *it );
165 writeVObject( file.directHandle() , vo ); 168 writeVObject( file.directHandle() , vo );
166 cleanVObject( vo ); 169 cleanVObject( vo );
167 } 170 }
168 cleanStrTbl(); 171 cleanStrTbl();
169 deleteVObject( obj ); 172 deleteVObject( obj );
170 173
171 m_dirty = false; 174 m_dirty = false;
172 return true; 175 return true;
173 176
174 177
175} 178}
176void OContactAccessBackend_VCard::clear () 179void OContactAccessBackend_VCard::clear ()
177{ 180{
178 m_map.clear(); 181 m_map.clear();
179 m_dirty = true; // ??? sure ? (se) 182 m_dirty = true; // ??? sure ? (se)
180} 183}
181 184
182bool OContactAccessBackend_VCard::add ( const OContact& newcontact ) 185bool OContactAccessBackend_VCard::add ( const OContact& newcontact )
183{ 186{
184 m_map.insert( newcontact.uid(), newcontact ); 187 m_map.insert( newcontact.uid(), newcontact );
185 m_dirty = true; 188 m_dirty = true;
186 return true; 189 return true;
187} 190}
188 191
189bool OContactAccessBackend_VCard::remove ( int uid ) 192bool OContactAccessBackend_VCard::remove ( int uid )
190{ 193{
191 m_map.remove( uid ); 194 m_map.remove( uid );
192 m_dirty = true; 195 m_dirty = true;
193 return true; 196 return true;
194} 197}
195 198
196bool OContactAccessBackend_VCard::replace ( const OContact &contact ) 199bool OContactAccessBackend_VCard::replace ( const OContact &contact )
197{ 200{
198 m_map.replace( contact.uid(), contact ); 201 m_map.replace( contact.uid(), contact );
199 m_dirty = true; 202 m_dirty = true;
200 return true; 203 return true;
201} 204}
202 205
203OContact OContactAccessBackend_VCard::find ( int uid ) const 206OContact OContactAccessBackend_VCard::find ( int uid ) const
204{ 207{
205 return m_map[uid]; 208 return m_map[uid];
206} 209}
207 210
208QArray<int> OContactAccessBackend_VCard::allRecords() const 211QArray<int> OContactAccessBackend_VCard::allRecords() const
209{ 212{
210 QArray<int> ar( m_map.count() ); 213 QArray<int> ar( m_map.count() );
211 QMap<int, OContact>::ConstIterator it; 214 QMap<int, OContact>::ConstIterator it;
212 int i = 0; 215 int i = 0;
213 for ( it = m_map.begin(); it != m_map.end(); ++it ) { 216 for ( it = m_map.begin(); it != m_map.end(); ++it ) {
214 ar[i] = it.key(); 217 ar[i] = it.key();
215 i++; 218 i++;
216 } 219 }
217 return ar; 220 return ar;
218} 221}
219 222
220// Not implemented 223// Not implemented
221QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int, const QDateTime& ) 224QArray<int> OContactAccessBackend_VCard::queryByExample ( const OContact&, int, const QDateTime& )
222{ 225{
223 QArray<int> ar(0); 226 QArray<int> ar(0);
224 return ar; 227 return ar;
225} 228}
226 229
227// Not implemented 230// Not implemented
228QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const 231QArray<int> OContactAccessBackend_VCard::matchRegexp( const QRegExp& ) const
229{ 232{
230 QArray<int> ar(0); 233 QArray<int> ar(0);
231 return ar; 234 return ar;
232} 235}
233 236
234const uint OContactAccessBackend_VCard::querySettings() 237const uint OContactAccessBackend_VCard::querySettings()
235{ 238{
236 return 0; // No search possible 239 return 0; // No search possible
237} 240}
238 241
239bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const 242bool OContactAccessBackend_VCard::hasQuerySettings (uint ) const
240{ 243{
241 return false; // No search possible, therefore all settings invalid ;) 244 return false; // No search possible, therefore all settings invalid ;)
242} 245}
243 246
244bool OContactAccessBackend_VCard::wasChangedExternally() 247bool OContactAccessBackend_VCard::wasChangedExternally()
245{ 248{
246 return false; // Don't expect concurrent access 249 return false; // Don't expect concurrent access
247} 250}
248 251
249// Not implemented 252// Not implemented
250QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int ) 253QArray<int> OContactAccessBackend_VCard::sorted( bool , int, int, int )
251{ 254{
252 QArray<int> ar(0); 255 QArray<int> ar(0);
253 return ar; 256 return ar;
254} 257}
255 258
256// *** Private stuff *** 259// *** Private stuff ***
257 260
258 261
259OContact OContactAccessBackend_VCard::parseVObject( VObject *obj ) 262OContact OContactAccessBackend_VCard::parseVObject( VObject *obj )
260{ 263{
261 OContact c; 264 OContact c;
262 265
263 VObjectIterator it; 266 VObjectIterator it;
264 initPropIterator( &it, obj ); 267 initPropIterator( &it, obj );
265 while( moreIteration( &it ) ) { 268 while( moreIteration( &it ) ) {
266 VObject *o = nextVObject( &it ); 269 VObject *o = nextVObject( &it );
267 QCString name = vObjectName( o ); 270 QCString name = vObjectName( o );
268 QCString value = vObjectStringZValue( o ); 271 QCString value = vObjectStringZValue( o );
269 if ( name == VCNameProp ) { 272 if ( name == VCNameProp ) {
270 VObjectIterator nit; 273 VObjectIterator nit;
271 initPropIterator( &nit, o ); 274 initPropIterator( &nit, o );
272 while( moreIteration( &nit ) ) { 275 while( moreIteration( &nit ) ) {
273 VObject *o = nextVObject( &nit ); 276 VObject *o = nextVObject( &nit );
274 QCString name = vObjectTypeInfo( o ); 277 QCString name = vObjectTypeInfo( o );
275 QString value = vObjectStringZValue( o ); 278 QString value = vObjectStringZValue( o );
276 if ( name == VCNamePrefixesProp ) 279 if ( name == VCNamePrefixesProp )
277 c.setTitle( value ); 280 c.setTitle( value );
278 else if ( name == VCNameSuffixesProp ) 281 else if ( name == VCNameSuffixesProp )
279 c.setSuffix( value ); 282 c.setSuffix( value );
280 else if ( name == VCFamilyNameProp ) 283 else if ( name == VCFamilyNameProp )
281 c.setLastName( value ); 284 c.setLastName( value );
282 else if ( name == VCGivenNameProp ) 285 else if ( name == VCGivenNameProp )
283 c.setFirstName( value ); 286 c.setFirstName( value );
284 else if ( name == VCAdditionalNamesProp ) 287 else if ( name == VCAdditionalNamesProp )
285 c.setMiddleName( value ); 288 c.setMiddleName( value );
286 } 289 }
287 } 290 }
288 else if ( name == VCAdrProp ) { 291 else if ( name == VCAdrProp ) {
289 bool work = TRUE; // default address is work address 292 bool work = TRUE; // default address is work address
290 QString street; 293 QString street;
291 QString city; 294 QString city;
292 QString region; 295 QString region;
293 QString postal; 296 QString postal;
294 QString country; 297 QString country;
295 298
296 VObjectIterator nit; 299 VObjectIterator nit;
297 initPropIterator( &nit, o ); 300 initPropIterator( &nit, o );
298 while( moreIteration( &nit ) ) { 301 while( moreIteration( &nit ) ) {
299 VObject *o = nextVObject( &nit ); 302 VObject *o = nextVObject( &nit );
300 QCString name = vObjectName( o ); 303 QCString name = vObjectName( o );
301 QString value = vObjectStringZValue( o ); 304 QString value = vObjectStringZValue( o );
302 if ( name == VCHomeProp ) 305 if ( name == VCHomeProp )
303 work = FALSE; 306 work = FALSE;
304 else if ( name == VCWorkProp ) 307 else if ( name == VCWorkProp )
305 work = TRUE; 308 work = TRUE;
306 else if ( name == VCStreetAddressProp ) 309 else if ( name == VCStreetAddressProp )
307 street = value; 310 street = value;
308 else if ( name == VCCityProp ) 311 else if ( name == VCCityProp )
309 city = value; 312 city = value;
310 else if ( name == VCRegionProp ) 313 else if ( name == VCRegionProp )
311 region = value; 314 region = value;
312 else if ( name == VCPostalCodeProp ) 315 else if ( name == VCPostalCodeProp )
313 postal = value; 316 postal = value;
314 else if ( name == VCCountryNameProp ) 317 else if ( name == VCCountryNameProp )
315 country = value; 318 country = value;
316 } 319 }
317 if ( work ) { 320 if ( work ) {
318 c.setBusinessStreet( street ); 321 c.setBusinessStreet( street );
319 c.setBusinessCity( city ); 322 c.setBusinessCity( city );
320 c.setBusinessCountry( country ); 323 c.setBusinessCountry( country );
321 c.setBusinessZip( postal ); 324 c.setBusinessZip( postal );
322 c.setBusinessState( region ); 325 c.setBusinessState( region );
323 } else { 326 } else {
324 c.setHomeStreet( street ); 327 c.setHomeStreet( street );
325 c.setHomeCity( city ); 328 c.setHomeCity( city );
326 c.setHomeCountry( country ); 329 c.setHomeCountry( country );
327 c.setHomeZip( postal ); 330 c.setHomeZip( postal );
328 c.setHomeState( region ); 331 c.setHomeState( region );
329 } 332 }
330 } 333 }
331 else if ( name == VCTelephoneProp ) { 334 else if ( name == VCTelephoneProp ) {
332 enum { 335 enum {
333 HOME = 0x01, 336 HOME = 0x01,
334 WORK = 0x02, 337 WORK = 0x02,
335 VOICE = 0x04, 338 VOICE = 0x04,
336 CELL = 0x08, 339 CELL = 0x08,
337 FAX = 0x10, 340 FAX = 0x10,
338 PAGER = 0x20, 341 PAGER = 0x20,
339 UNKNOWN = 0x80 342 UNKNOWN = 0x80
340 }; 343 };
341 int type = 0; 344 int type = 0;
342 345
343 VObjectIterator nit; 346 VObjectIterator nit;
344 initPropIterator( &nit, o ); 347 initPropIterator( &nit, o );
345 while( moreIteration( &nit ) ) { 348 while( moreIteration( &nit ) ) {
346 VObject *o = nextVObject( &nit ); 349 VObject *o = nextVObject( &nit );
347 QCString name = vObjectTypeInfo( o ); 350 QCString name = vObjectTypeInfo( o );
348 if ( name == VCHomeProp ) 351 if ( name == VCHomeProp )
349 type |= HOME; 352 type |= HOME;
350 else if ( name == VCWorkProp ) 353 else if ( name == VCWorkProp )
351 type |= WORK; 354 type |= WORK;
352 else if ( name == VCVoiceProp ) 355 else if ( name == VCVoiceProp )
353 type |= VOICE; 356 type |= VOICE;
354 else if ( name == VCCellularProp ) 357 else if ( name == VCCellularProp )
355 type |= CELL; 358 type |= CELL;
356 else if ( name == VCFaxProp ) 359 else if ( name == VCFaxProp )
357 type |= FAX; 360 type |= FAX;
358 else if ( name == VCPagerProp ) 361 else if ( name == VCPagerProp )
359 type |= PAGER; 362 type |= PAGER;
360 else if ( name == VCPreferredProp ) 363 else if ( name == VCPreferredProp )
361 ; 364 ;
362 else 365 else
363 type |= UNKNOWN; 366 type |= UNKNOWN;
364 } 367 }
365 if ( (type & UNKNOWN) != UNKNOWN ) { 368 if ( (type & UNKNOWN) != UNKNOWN ) {
366 if ( ( type & (HOME|WORK) ) == 0 ) // default 369 if ( ( type & (HOME|WORK) ) == 0 ) // default
367 type |= HOME; 370 type |= HOME;
368 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default 371 if ( ( type & (VOICE|CELL|FAX|PAGER) ) == 0 ) // default
369 type |= VOICE; 372 type |= VOICE;
370 373
371 qWarning("value %s %d", value.data(), type ); 374 qWarning("value %s %d", value.data(), type );
372 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) ) 375 if ( (type & (VOICE|HOME) ) == (VOICE|HOME) && (type & (CELL|HOME) ) != (CELL|HOME) )
373 c.setHomePhone( value ); 376 c.setHomePhone( value );
374 if ( ( type & (FAX|HOME) ) == (FAX|HOME) ) 377 if ( ( type & (FAX|HOME) ) == (FAX|HOME) )
375 c.setHomeFax( value ); 378 c.setHomeFax( value );
376 if ( ( type & (CELL|HOME) ) == (CELL|HOME) ) 379 if ( ( type & (CELL|HOME) ) == (CELL|HOME) )
377 c.setHomeMobile( value ); 380 c.setHomeMobile( value );
378 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) ) 381 if ( ( type & (VOICE|WORK) ) == (VOICE|WORK) && (type & (CELL|WORK) ) != (CELL|WORK) )
379 c.setBusinessPhone( value ); 382 c.setBusinessPhone( value );
380 if ( ( type & (FAX|WORK) ) == (FAX|WORK) ) 383 if ( ( type & (FAX|WORK) ) == (FAX|WORK) )
381 c.setBusinessFax( value ); 384 c.setBusinessFax( value );
382 if ( ( type & (CELL|WORK) ) == (CELL|WORK) ) 385 if ( ( type & (CELL|WORK) ) == (CELL|WORK) )
383 c.setBusinessMobile( value ); 386 c.setBusinessMobile( value );
384 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) ) 387 if ( ( type & (PAGER|WORK) ) == (PAGER|WORK) )
385 c.setBusinessPager( value ); 388 c.setBusinessPager( value );
386 } 389 }
387 } 390 }
388 else if ( name == VCEmailAddressProp ) { 391 else if ( name == VCEmailAddressProp ) {
389 QString email = vObjectStringZValue( o ); 392 QString email = vObjectStringZValue( o );
390 bool valid = TRUE; 393 bool valid = TRUE;
391 VObjectIterator nit; 394 VObjectIterator nit;
392 initPropIterator( &nit, o ); 395 initPropIterator( &nit, o );
393 while( moreIteration( &nit ) ) { 396 while( moreIteration( &nit ) ) {
394 VObject *o = nextVObject( &nit ); 397 VObject *o = nextVObject( &nit );
395 QCString name = vObjectTypeInfo( o ); 398 QCString name = vObjectTypeInfo( o );
396 if ( name != VCInternetProp && name != VCHomeProp && 399 if ( name != VCInternetProp && name != VCHomeProp &&
397 name != VCWorkProp && 400 name != VCWorkProp &&
398 name != VCPreferredProp ) 401 name != VCPreferredProp )
399 // ### preffered should map to default email 402 // ### preffered should map to default email
400 valid = FALSE; 403 valid = FALSE;
401 } 404 }
402 if ( valid ) { 405 if ( valid ) {
403 c.insertEmail( email ); 406 c.insertEmail( email );
404 } 407 }
405 } 408 }
406 else if ( name == VCURLProp ) { 409 else if ( name == VCURLProp ) {
407 VObjectIterator nit; 410 VObjectIterator nit;
408 initPropIterator( &nit, o ); 411 initPropIterator( &nit, o );
409 while( moreIteration( &nit ) ) { 412 while( moreIteration( &nit ) ) {
410 VObject *o = nextVObject( &nit ); 413 VObject *o = nextVObject( &nit );
411 QCString name = vObjectTypeInfo( o ); 414 QCString name = vObjectTypeInfo( o );
412 if ( name == VCHomeProp ) 415 if ( name == VCHomeProp )
413 c.setHomeWebpage( value ); 416 c.setHomeWebpage( value );
414 else if ( name == VCWorkProp ) 417 else if ( name == VCWorkProp )
415 c.setBusinessWebpage( value ); 418 c.setBusinessWebpage( value );
416 } 419 }
417 } 420 }
418 else if ( name == VCOrgProp ) { 421 else if ( name == VCOrgProp ) {
419 VObjectIterator nit; 422 VObjectIterator nit;
420 initPropIterator( &nit, o ); 423 initPropIterator( &nit, o );
421 while( moreIteration( &nit ) ) { 424 while( moreIteration( &nit ) ) {
422 VObject *o = nextVObject( &nit ); 425 VObject *o = nextVObject( &nit );
423 QCString name = vObjectName( o ); 426 QCString name = vObjectName( o );
424 QString value = vObjectStringZValue( o ); 427 QString value = vObjectStringZValue( o );
425 if ( name == VCOrgNameProp ) 428 if ( name == VCOrgNameProp )
426 c.setCompany( value ); 429 c.setCompany( value );
427 else if ( name == VCOrgUnitProp ) 430 else if ( name == VCOrgUnitProp )
428 c.setDepartment( value ); 431 c.setDepartment( value );
429 else if ( name == VCOrgUnit2Prop ) 432 else if ( name == VCOrgUnit2Prop )
430 c.setOffice( value ); 433 c.setOffice( value );
431 } 434 }
432 } 435 }
433 else if ( name == VCTitleProp ) { 436 else if ( name == VCTitleProp ) {
434 c.setJobTitle( value ); 437 c.setJobTitle( value );
435 } 438 }
436 else if ( name == "X-Qtopia-Profession" ) { 439 else if ( name == "X-Qtopia-Profession" ) {
437 c.setProfession( value ); 440 c.setProfession( value );
438 } 441 }
439 else if ( name == "X-Qtopia-Manager" ) { 442 else if ( name == "X-Qtopia-Manager" ) {
440 c.setManager( value ); 443 c.setManager( value );
441 } 444 }
442 else if ( name == "X-Qtopia-Assistant" ) { 445 else if ( name == "X-Qtopia-Assistant" ) {
443 c.setAssistant( value ); 446 c.setAssistant( value );
444 } 447 }
445 else if ( name == "X-Qtopia-Spouse" ) { 448 else if ( name == "X-Qtopia-Spouse" ) {
446 c.setSpouse( value ); 449 c.setSpouse( value );
447 } 450 }
448 else if ( name == "X-Qtopia-Gender" ) { 451 else if ( name == "X-Qtopia-Gender" ) {
449 c.setGender( value ); 452 c.setGender( value );
450 } 453 }
451 else if ( name == "X-Qtopia-Anniversary" ) { 454 else if ( name == "X-Qtopia-Anniversary" ) {
452 c.setAnniversary( convVCardDateToDate( value ) ); 455 c.setAnniversary( convVCardDateToDate( value ) );
453 } 456 }
454 else if ( name == "X-Qtopia-Nickname" ) { 457 else if ( name == "X-Qtopia-Nickname" ) {
455 c.setNickname( value ); 458 c.setNickname( value );
456 } 459 }
457 else if ( name == "X-Qtopia-Children" ) { 460 else if ( name == "X-Qtopia-Children" ) {
458 c.setChildren( value ); 461 c.setChildren( value );
459 } 462 }
460 else if ( name == VCBirthDateProp ) { 463 else if ( name == VCBirthDateProp ) {
461 // Reading Birthdate regarding RFC 2425 (5.8.4) 464 // Reading Birthdate regarding RFC 2425 (5.8.4)
462 c.setBirthday( convVCardDateToDate( value ) ); 465 c.setBirthday( convVCardDateToDate( value ) );
463 466
464 } 467 }
465 else if ( name == VCCommentProp ) { 468 else if ( name == VCCommentProp ) {
466 c.setNotes( value ); 469 c.setNotes( value );
467 } 470 }
468#if 0 471#if 0
469 else { 472 else {
470 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) ); 473 printf("Name: %s, value=%s\n", name.data(), vObjectStringZValue( o ) );
471 VObjectIterator nit; 474 VObjectIterator nit;
472 initPropIterator( &nit, o ); 475 initPropIterator( &nit, o );
473 while( moreIteration( &nit ) ) { 476 while( moreIteration( &nit ) ) {
474 VObject *o = nextVObject( &nit ); 477 VObject *o = nextVObject( &nit );
475 QCString name = vObjectName( o ); 478 QCString name = vObjectName( o );
476 QString value = vObjectStringZValue( o ); 479 QString value = vObjectStringZValue( o );
477 printf(" subprop: %s = %s\n", name.data(), value.latin1() ); 480 printf(" subprop: %s = %s\n", name.data(), value.latin1() );
478 } 481 }
479 } 482 }
480#endif 483#endif
481 } 484 }
482 c.setFileAs(); 485 c.setFileAs();
483 return c; 486 return c;
484} 487}
485 488
486 489
487VObject* OContactAccessBackend_VCard::createVObject( const OContact &c ) 490VObject* OContactAccessBackend_VCard::createVObject( const OContact &c )
488{ 491{
489 VObject *vcard = newVObject( VCCardProp ); 492 VObject *vcard = newVObject( VCCardProp );
490 safeAddPropValue( vcard, VCVersionProp, "2.1" ); 493 safeAddPropValue( vcard, VCVersionProp, "2.1" );
491 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) ); 494 safeAddPropValue( vcard, VCLastRevisedProp, TimeConversion::toISO8601( QDateTime::currentDateTime() ) );
492 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) ); 495 safeAddPropValue( vcard, VCUniqueStringProp, QString::number(c.uid()) );
493 496
494 // full name 497 // full name
495 safeAddPropValue( vcard, VCFullNameProp, c.fullName() ); 498 safeAddPropValue( vcard, VCFullNameProp, c.fullName() );
496 499
497 // name properties 500 // name properties
498 VObject *name = safeAddProp( vcard, VCNameProp ); 501 VObject *name = safeAddProp( vcard, VCNameProp );
499 safeAddPropValue( name, VCFamilyNameProp, c.lastName() ); 502 safeAddPropValue( name, VCFamilyNameProp, c.lastName() );
500 safeAddPropValue( name, VCGivenNameProp, c.firstName() ); 503 safeAddPropValue( name, VCGivenNameProp, c.firstName() );
501 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() ); 504 safeAddPropValue( name, VCAdditionalNamesProp, c.middleName() );
502 safeAddPropValue( name, VCNamePrefixesProp, c.title() ); 505 safeAddPropValue( name, VCNamePrefixesProp, c.title() );
503 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() ); 506 safeAddPropValue( name, VCNameSuffixesProp, c.suffix() );
504 507
505 // home properties 508 // home properties
506 VObject *home_adr= safeAddProp( vcard, VCAdrProp ); 509 VObject *home_adr= safeAddProp( vcard, VCAdrProp );
507 safeAddProp( home_adr, VCHomeProp ); 510 safeAddProp( home_adr, VCHomeProp );
508 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() ); 511 safeAddPropValue( home_adr, VCStreetAddressProp, c.homeStreet() );
509 safeAddPropValue( home_adr, VCCityProp, c.homeCity() ); 512 safeAddPropValue( home_adr, VCCityProp, c.homeCity() );
510 safeAddPropValue( home_adr, VCRegionProp, c.homeState() ); 513 safeAddPropValue( home_adr, VCRegionProp, c.homeState() );
511 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() ); 514 safeAddPropValue( home_adr, VCPostalCodeProp, c.homeZip() );
512 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() ); 515 safeAddPropValue( home_adr, VCCountryNameProp, c.homeCountry() );
513 516
514 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() ); 517 VObject *home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homePhone() );
515 safeAddProp( home_phone, VCHomeProp ); 518 safeAddProp( home_phone, VCHomeProp );
516 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() ); 519 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeMobile() );
517 safeAddProp( home_phone, VCHomeProp ); 520 safeAddProp( home_phone, VCHomeProp );
518 safeAddProp( home_phone, VCCellularProp ); 521 safeAddProp( home_phone, VCCellularProp );
519 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() ); 522 home_phone = safeAddPropValue( vcard, VCTelephoneProp, c.homeFax() );
520 safeAddProp( home_phone, VCHomeProp ); 523 safeAddProp( home_phone, VCHomeProp );
521 safeAddProp( home_phone, VCFaxProp ); 524 safeAddProp( home_phone, VCFaxProp );
522 525
523 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() ); 526 VObject *url = safeAddPropValue( vcard, VCURLProp, c.homeWebpage() );
524 safeAddProp( url, VCHomeProp ); 527 safeAddProp( url, VCHomeProp );
525 528
526 // work properties 529 // work properties
527 VObject *work_adr= safeAddProp( vcard, VCAdrProp ); 530 VObject *work_adr= safeAddProp( vcard, VCAdrProp );
528 safeAddProp( work_adr, VCWorkProp ); 531 safeAddProp( work_adr, VCWorkProp );
529 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() ); 532 safeAddPropValue( work_adr, VCStreetAddressProp, c.businessStreet() );
530 safeAddPropValue( work_adr, VCCityProp, c.businessCity() ); 533 safeAddPropValue( work_adr, VCCityProp, c.businessCity() );
531 safeAddPropValue( work_adr, VCRegionProp, c.businessState() ); 534 safeAddPropValue( work_adr, VCRegionProp, c.businessState() );
532 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() ); 535 safeAddPropValue( work_adr, VCPostalCodeProp, c.businessZip() );
533 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() ); 536 safeAddPropValue( work_adr, VCCountryNameProp, c.businessCountry() );
534 537
535 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() ); 538 VObject *work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPhone() );
536 safeAddProp( work_phone, VCWorkProp ); 539 safeAddProp( work_phone, VCWorkProp );
537 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() ); 540 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessMobile() );
538 safeAddProp( work_phone, VCWorkProp ); 541 safeAddProp( work_phone, VCWorkProp );
539 safeAddProp( work_phone, VCCellularProp ); 542 safeAddProp( work_phone, VCCellularProp );
540 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() ); 543 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessFax() );
541 safeAddProp( work_phone, VCWorkProp ); 544 safeAddProp( work_phone, VCWorkProp );
542 safeAddProp( work_phone, VCFaxProp ); 545 safeAddProp( work_phone, VCFaxProp );
543 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() ); 546 work_phone = safeAddPropValue( vcard, VCTelephoneProp, c.businessPager() );
544 safeAddProp( work_phone, VCWorkProp ); 547 safeAddProp( work_phone, VCWorkProp );
545 safeAddProp( work_phone, VCPagerProp ); 548 safeAddProp( work_phone, VCPagerProp );
546 549
547 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() ); 550 url = safeAddPropValue( vcard, VCURLProp, c.businessWebpage() );
548 safeAddProp( url, VCWorkProp ); 551 safeAddProp( url, VCWorkProp );
549 552
550 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() ); 553 VObject *title = safeAddPropValue( vcard, VCTitleProp, c.jobTitle() );
551 safeAddProp( title, VCWorkProp ); 554 safeAddProp( title, VCWorkProp );
552 555
553 556
554 QStringList emails = c.emailList(); 557 QStringList emails = c.emailList();
555 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045 558 // emails.prepend( c.defaultEmail() ); Fix for bugreport #1045
556 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { 559 for( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) {
557 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it ); 560 VObject *email = safeAddPropValue( vcard, VCEmailAddressProp, *it );
558 safeAddProp( email, VCInternetProp ); 561 safeAddProp( email, VCInternetProp );
559 } 562 }
560 563
561 safeAddPropValue( vcard, VCNoteProp, c.notes() ); 564 safeAddPropValue( vcard, VCNoteProp, c.notes() );
562 565
563 // Exporting Birthday regarding RFC 2425 (5.8.4) 566 // Exporting Birthday regarding RFC 2425 (5.8.4)
564 if ( c.birthday().isValid() ){ 567 if ( c.birthday().isValid() ){
565 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() ); 568 qWarning("Exporting birthday as: %s", convDateToVCardDate( c.birthday() ).latin1() );
566 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) ); 569 safeAddPropValue( vcard, VCBirthDateProp, convDateToVCardDate( c.birthday() ) );
567 } 570 }
568 571
569 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) { 572 if ( !c.company().isEmpty() || !c.department().isEmpty() || !c.office().isEmpty() ) {
570 VObject *org = safeAddProp( vcard, VCOrgProp ); 573 VObject *org = safeAddProp( vcard, VCOrgProp );
571 safeAddPropValue( org, VCOrgNameProp, c.company() ); 574 safeAddPropValue( org, VCOrgNameProp, c.company() );
572 safeAddPropValue( org, VCOrgUnitProp, c.department() ); 575 safeAddPropValue( org, VCOrgUnitProp, c.department() );
573 safeAddPropValue( org, VCOrgUnit2Prop, c.office() ); 576 safeAddPropValue( org, VCOrgUnit2Prop, c.office() );
574 } 577 }
575 578
576 // some values we have to export as custom fields 579 // some values we have to export as custom fields
577 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() ); 580 safeAddPropValue( vcard, "X-Qtopia-Profession", c.profession() );
578 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() ); 581 safeAddPropValue( vcard, "X-Qtopia-Manager", c.manager() );
579 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() ); 582 safeAddPropValue( vcard, "X-Qtopia-Assistant", c.assistant() );
580 583
581 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() ); 584 safeAddPropValue( vcard, "X-Qtopia-Spouse", c.spouse() );
582 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() ); 585 safeAddPropValue( vcard, "X-Qtopia-Gender", c.gender() );
583 if ( c.anniversary().isValid() ){ 586 if ( c.anniversary().isValid() ){
584 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() ); 587 qWarning("Exporting anniversary as: %s", convDateToVCardDate( c.anniversary() ).latin1() );
585 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) ); 588 safeAddPropValue( vcard, "X-Qtopia-Anniversary", convDateToVCardDate( c.anniversary() ) );
586 } 589 }
587 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() ); 590 safeAddPropValue( vcard, "X-Qtopia-Nickname", c.nickname() );
588 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() ); 591 safeAddPropValue( vcard, "X-Qtopia-Children", c.children() );
589 592
590 return vcard; 593 return vcard;
591} 594}
592 595
593QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const 596QString OContactAccessBackend_VCard::convDateToVCardDate( const QDate& d ) const
594{ 597{
595 QString str_rfc2425 = QString("%1-%2-%3") 598 QString str_rfc2425 = QString("%1-%2-%3")
596 .arg( d.year() ) 599 .arg( d.year() )
597 .arg( d.month(), 2 ) 600 .arg( d.month(), 2 )
598 .arg( d.day(), 2 ); 601 .arg( d.day(), 2 );
599 // Now replace spaces with "0"... 602 // Now replace spaces with "0"...
600 int pos = 0; 603 int pos = 0;
601 while ( ( pos = str_rfc2425.find (' ') ) > 0 ) 604 while ( ( pos = str_rfc2425.find (' ') ) > 0 )
602 str_rfc2425.replace( pos, 1, "0" ); 605 str_rfc2425.replace( pos, 1, "0" );
603 606
604 return str_rfc2425; 607 return str_rfc2425;
605} 608}
606 609
607QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr ) 610QDate OContactAccessBackend_VCard::convVCardDateToDate( const QString& datestr )
608{ 611{
609 int monthPos = datestr.find('-'); 612 int monthPos = datestr.find('-');
610 int dayPos = datestr.find('-', monthPos+1 ); 613 int dayPos = datestr.find('-', monthPos+1 );
611 int sep_ignore = 1; 614 int sep_ignore = 1;
612 if ( monthPos == -1 || dayPos == -1 ) { 615 if ( monthPos == -1 || dayPos == -1 ) {
613 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 616 qDebug("fromString didn't find - in str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
614 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD ) 617 // Ok.. No "-" found, therefore we will try to read other format ( YYYYMMDD )
615 if ( datestr.length() == 8 ){ 618 if ( datestr.length() == 8 ){
616 monthPos = 4; 619 monthPos = 4;
617 dayPos = 6; 620 dayPos = 6;
618 sep_ignore = 0; 621 sep_ignore = 0;
619 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos ); 622 qDebug("Try with follwing positions str = %s; mpos = %d ypos = %d", datestr.latin1(), monthPos, dayPos );
620 } else { 623 } else {
621 return QDate(); 624 return QDate();
622 } 625 }
623 } 626 }
624 int y = datestr.left( monthPos ).toInt(); 627 int y = datestr.left( monthPos ).toInt();
625 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt(); 628 int m = datestr.mid( monthPos + sep_ignore, dayPos - monthPos - sep_ignore ).toInt();
626 int d = datestr.mid( dayPos + sep_ignore ).toInt(); 629 int d = datestr.mid( dayPos + sep_ignore ).toInt();
627 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos); 630 qDebug("TimeConversion::fromString ymd = %s => %d %d %d; mpos = %d ypos = %d", datestr.latin1(), y, m, d, monthPos, dayPos);
628 QDate date ( y,m,d ); 631 QDate date ( y,m,d );
629 return date; 632 return date;
630} 633}
631 634
632VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value ) 635VObject* OContactAccessBackend_VCard::safeAddPropValue( VObject *o, const char *prop, const QString &value )
633{ 636{
634 VObject *ret = 0; 637 VObject *ret = 0;
635 if ( o && !value.isEmpty() ) 638 if ( o && !value.isEmpty() )
636 ret = addPropValue( o, prop, value.latin1() ); 639 ret = addPropValue( o, prop, value.latin1() );
637 return ret; 640 return ret;
638} 641}
639 642
640VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop) 643VObject* OContactAccessBackend_VCard::safeAddProp( VObject *o, const char *prop)
641{ 644{
642 VObject *ret = 0; 645 VObject *ret = 0;
643 if ( o ) 646 if ( o )
644 ret = addProp( o, prop ); 647 ret = addProp( o, prop );
645 return ret; 648 return ret;
646} 649}
diff --git a/libopie/pim/ocontactaccessbackend_vcard.h b/noncore/unsupported/libopie/pim/ocontactaccessbackend_vcard.h
index 712d769..6dbc718 100644
--- a/libopie/pim/ocontactaccessbackend_vcard.h
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend_vcard.h
@@ -1,96 +1,99 @@
1/* 1/*
2 * VCard Backend for the OPIE-Contact Database. 2 * VCard Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (C) 2000 Trolltech AS. All rights reserved. 4 * Copyright (C) 2000 Trolltech AS. All rights reserved.
5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 5 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
6 * 6 *
7 * ===================================================================== 7 * =====================================================================
8 *This program is free software; you can redistribute it and/or 8 *This program is free software; you can redistribute it and/or
9 *modify it under the terms of the GNU Library General Public 9 *modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version. 11 * version 2 of the License, or (at your option) any later version.
12 * ===================================================================== 12 * =====================================================================
13 * ToDo: 13 * ToDo:
14 * 14 *
15 * ===================================================================== 15 * =====================================================================
16 * Version: $Id$ 16 * Version: $Id$
17 * ===================================================================== 17 * =====================================================================
18 * History: 18 * History:
19 * $Log$ 19 * $Log$
20 * Revision 1.1 2004/11/16 21:46:07 mickeyl
21 * libopie1 goes into unsupported
22 *
20 * Revision 1.6 2003/04/13 18:07:10 zecke 23 * Revision 1.6 2003/04/13 18:07:10 zecke
21 * More API doc 24 * More API doc
22 * QString -> const QString& 25 * QString -> const QString&
23 * QString = 0l -> QString::null 26 * QString = 0l -> QString::null
24 * 27 *
25 * Revision 1.5 2003/03/21 10:33:09 eilers 28 * Revision 1.5 2003/03/21 10:33:09 eilers
26 * Merged speed optimized xml backend for contacts to main. 29 * Merged speed optimized xml backend for contacts to main.
27 * Added QDateTime to querybyexample. For instance, it is now possible to get 30 * Added QDateTime to querybyexample. For instance, it is now possible to get
28 * all Birthdays/Anniversaries between two dates. This should be used 31 * all Birthdays/Anniversaries between two dates. This should be used
29 * to show all birthdays in the datebook.. 32 * to show all birthdays in the datebook..
30 * This change is sourcecode backward compatible but you have to upgrade 33 * This change is sourcecode backward compatible but you have to upgrade
31 * the binaries for today-addressbook. 34 * the binaries for today-addressbook.
32 * 35 *
33 * Revision 1.4 2002/12/07 13:26:22 eilers 36 * Revision 1.4 2002/12/07 13:26:22 eilers
34 * Fixing bug in storing anniversary.. 37 * Fixing bug in storing anniversary..
35 * 38 *
36 * Revision 1.3 2002/11/13 14:14:51 eilers 39 * Revision 1.3 2002/11/13 14:14:51 eilers
37 * Added sorted for Contacts.. 40 * Added sorted for Contacts..
38 * 41 *
39 * Revision 1.2 2002/11/10 15:41:53 eilers 42 * Revision 1.2 2002/11/10 15:41:53 eilers
40 * Bugfixes.. 43 * Bugfixes..
41 * 44 *
42 * Revision 1.1 2002/11/09 14:34:52 eilers 45 * Revision 1.1 2002/11/09 14:34:52 eilers
43 * Added VCard Backend. 46 * Added VCard Backend.
44 * 47 *
45 */ 48 */
46#ifndef __OCONTACTACCESSBACKEND_VCARD_H_ 49#ifndef __OCONTACTACCESSBACKEND_VCARD_H_
47#define __OCONTACTACCESSBACKEND_VCARD_H_ 50#define __OCONTACTACCESSBACKEND_VCARD_H_
48 51
49#include <opie/ocontact.h> 52#include <opie/ocontact.h>
50 53
51#include "ocontactaccessbackend.h" 54#include "ocontactaccessbackend.h"
52 55
53class VObject; 56class VObject;
54 57
55/** 58/**
56 * This is the vCard 2.1 implementation of the Contact Storage 59 * This is the vCard 2.1 implementation of the Contact Storage
57 * @see OContactAccessBackend_XML 60 * @see OContactAccessBackend_XML
58 * @see OPimAccessBackend 61 * @see OPimAccessBackend
59 */ 62 */
60class OContactAccessBackend_VCard : public OContactAccessBackend { 63class OContactAccessBackend_VCard : public OContactAccessBackend {
61 public: 64 public:
62 OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null ); 65 OContactAccessBackend_VCard ( const QString& appname, const QString& filename = QString::null );
63 66
64 bool load (); 67 bool load ();
65 bool reload(); 68 bool reload();
66 bool save(); 69 bool save();
67 void clear (); 70 void clear ();
68 71
69 bool add ( const OContact& newcontact ); 72 bool add ( const OContact& newcontact );
70 bool remove ( int uid ); 73 bool remove ( int uid );
71 bool replace ( const OContact& contact ); 74 bool replace ( const OContact& contact );
72 75
73 OContact find ( int uid ) const; 76 OContact find ( int uid ) const;
74 QArray<int> allRecords() const; 77 QArray<int> allRecords() const;
75 QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); 78 QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() );
76 QArray<int> matchRegexp( const QRegExp &r ) const; 79 QArray<int> matchRegexp( const QRegExp &r ) const;
77 80
78 const uint querySettings(); 81 const uint querySettings();
79 bool hasQuerySettings (uint querySettings) const; 82 bool hasQuerySettings (uint querySettings) const;
80 QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat ); 83 QArray<int> sorted( bool ascending, int sortOrder, int sortFilter, int cat );
81 bool wasChangedExternally(); 84 bool wasChangedExternally();
82 85
83private: 86private:
84 OContact parseVObject( VObject* obj ); 87 OContact parseVObject( VObject* obj );
85 VObject* createVObject( const OContact& c ); 88 VObject* createVObject( const OContact& c );
86 QString convDateToVCardDate( const QDate& c ) const; 89 QString convDateToVCardDate( const QDate& c ) const;
87 QDate convVCardDateToDate( const QString& datestr ); 90 QDate convVCardDateToDate( const QString& datestr );
88 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value ); 91 VObject *safeAddPropValue( VObject *o, const char* prop, const QString& value );
89 VObject *safeAddProp( VObject* o, const char* prop); 92 VObject *safeAddProp( VObject* o, const char* prop);
90 93
91 bool m_dirty : 1; 94 bool m_dirty : 1;
92 QString m_file; 95 QString m_file;
93 QMap<int, OContact> m_map; 96 QMap<int, OContact> m_map;
94}; 97};
95 98
96#endif 99#endif
diff --git a/libopie/pim/ocontactaccessbackend_xml.cpp b/noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.cpp
index 2373ad6..7ceaf5b 100644
--- a/libopie/pim/ocontactaccessbackend_xml.cpp
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.cpp
@@ -1,821 +1,824 @@
1/* 1/*
2 * XML Backend for the OPIE-Contact Database. 2 * XML Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * 12 *
13 * ===================================================================== 13 * =====================================================================
14 * Version: $Id$ 14 * Version: $Id$
15 * ===================================================================== 15 * =====================================================================
16 * History: 16 * History:
17 * $Log$ 17 * $Log$
18 * Revision 1.1 2004/11/16 21:46:07 mickeyl
19 * libopie1 goes into unsupported
20 *
18 * Revision 1.10 2004/03/01 15:44:36 chicken 21 * Revision 1.10 2004/03/01 15:44:36 chicken
19 * fix includes 22 * fix includes
20 * 23 *
21 * Revision 1.9 2003/09/22 14:31:16 eilers 24 * Revision 1.9 2003/09/22 14:31:16 eilers
22 * Added first experimental incarnation of sql-backend for addressbook. 25 * Added first experimental incarnation of sql-backend for addressbook.
23 * Some modifications to be able to compile the todo sql-backend. 26 * Some modifications to be able to compile the todo sql-backend.
24 * A lot of changes fill follow... 27 * A lot of changes fill follow...
25 * 28 *
26 * Revision 1.8 2003/08/30 15:28:26 eilers 29 * Revision 1.8 2003/08/30 15:28:26 eilers
27 * Removed some unimportant debug output which causes slow down.. 30 * Removed some unimportant debug output which causes slow down..
28 * 31 *
29 * Revision 1.7 2003/08/01 12:30:16 eilers 32 * Revision 1.7 2003/08/01 12:30:16 eilers
30 * Merging changes from BRANCH_1_0 to HEAD 33 * Merging changes from BRANCH_1_0 to HEAD
31 * 34 *
32 * Revision 1.6 2003/07/07 16:19:47 eilers 35 * Revision 1.6 2003/07/07 16:19:47 eilers
33 * Fixing serious bug in hasQuerySettings() 36 * Fixing serious bug in hasQuerySettings()
34 * 37 *
35 * Revision 1.5 2003/04/13 18:07:10 zecke 38 * Revision 1.5 2003/04/13 18:07:10 zecke
36 * More API doc 39 * More API doc
37 * QString -> const QString& 40 * QString -> const QString&
38 * QString = 0l -> QString::null 41 * QString = 0l -> QString::null
39 * 42 *
40 * Revision 1.4 2003/03/21 14:32:54 mickeyl 43 * Revision 1.4 2003/03/21 14:32:54 mickeyl
41 * g++ compliance fix: default arguments belong into the declaration, but not the definition 44 * g++ compliance fix: default arguments belong into the declaration, but not the definition
42 * 45 *
43 * Revision 1.3 2003/03/21 12:26:28 eilers 46 * Revision 1.3 2003/03/21 12:26:28 eilers
44 * Fixing small bug: If we search a birthday from today to today, it returned 47 * Fixing small bug: If we search a birthday from today to today, it returned
45 * every contact .. 48 * every contact ..
46 * 49 *
47 * Revision 1.2 2003/03/21 10:33:09 eilers 50 * Revision 1.2 2003/03/21 10:33:09 eilers
48 * Merged speed optimized xml backend for contacts to main. 51 * Merged speed optimized xml backend for contacts to main.
49 * Added QDateTime to querybyexample. For instance, it is now possible to get 52 * Added QDateTime to querybyexample. For instance, it is now possible to get
50 * all Birthdays/Anniversaries between two dates. This should be used 53 * all Birthdays/Anniversaries between two dates. This should be used
51 * to show all birthdays in the datebook.. 54 * to show all birthdays in the datebook..
52 * This change is sourcecode backward compatible but you have to upgrade 55 * This change is sourcecode backward compatible but you have to upgrade
53 * the binaries for today-addressbook. 56 * the binaries for today-addressbook.
54 * 57 *
55 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers 58 * Revision 1.1.2.2 2003/02/11 12:17:28 eilers
56 * Speed optimization. Removed the sequential search loops. 59 * Speed optimization. Removed the sequential search loops.
57 * 60 *
58 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers 61 * Revision 1.1.2.1 2003/02/10 15:31:38 eilers
59 * Writing offsets to debug output.. 62 * Writing offsets to debug output..
60 * 63 *
61 * Revision 1.1 2003/02/09 15:05:01 eilers 64 * Revision 1.1 2003/02/09 15:05:01 eilers
62 * Nothing happened.. Just some cleanup before I will start.. 65 * Nothing happened.. Just some cleanup before I will start..
63 * 66 *
64 * Revision 1.12 2003/01/03 16:58:03 eilers 67 * Revision 1.12 2003/01/03 16:58:03 eilers
65 * Reenable debug output 68 * Reenable debug output
66 * 69 *
67 * Revision 1.11 2003/01/03 12:31:28 eilers 70 * Revision 1.11 2003/01/03 12:31:28 eilers
68 * Bugfix for calculating data diffs.. 71 * Bugfix for calculating data diffs..
69 * 72 *
70 * Revision 1.10 2003/01/02 14:27:12 eilers 73 * Revision 1.10 2003/01/02 14:27:12 eilers
71 * Improved query by example: Search by date is possible.. First step 74 * Improved query by example: Search by date is possible.. First step
72 * for a today plugin for birthdays.. 75 * for a today plugin for birthdays..
73 * 76 *
74 * Revision 1.9 2002/12/08 12:48:57 eilers 77 * Revision 1.9 2002/12/08 12:48:57 eilers
75 * Moved journal-enum from ocontact into i the xml-backend.. 78 * Moved journal-enum from ocontact into i the xml-backend..
76 * 79 *
77 * Revision 1.8 2002/11/14 17:04:24 eilers 80 * Revision 1.8 2002/11/14 17:04:24 eilers
78 * Sorting will now work if fullname is identical on some entries 81 * Sorting will now work if fullname is identical on some entries
79 * 82 *
80 * Revision 1.7 2002/11/13 15:02:46 eilers 83 * Revision 1.7 2002/11/13 15:02:46 eilers
81 * Small Bug in sorted fixed 84 * Small Bug in sorted fixed
82 * 85 *
83 * Revision 1.6 2002/11/13 14:14:51 eilers 86 * Revision 1.6 2002/11/13 14:14:51 eilers
84 * Added sorted for Contacts.. 87 * Added sorted for Contacts..
85 * 88 *
86 * Revision 1.5 2002/11/01 15:10:42 eilers 89 * Revision 1.5 2002/11/01 15:10:42 eilers
87 * Added regExp-search in database for all fields in a contact. 90 * Added regExp-search in database for all fields in a contact.
88 * 91 *
89 * Revision 1.4 2002/10/16 10:52:40 eilers 92 * Revision 1.4 2002/10/16 10:52:40 eilers
90 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 93 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
91 * 94 *
92 * Revision 1.3 2002/10/14 16:21:54 eilers 95 * Revision 1.3 2002/10/14 16:21:54 eilers
93 * Some minor interface updates 96 * Some minor interface updates
94 * 97 *
95 * Revision 1.2 2002/10/07 17:34:24 eilers 98 * Revision 1.2 2002/10/07 17:34:24 eilers
96 * added OBackendFactory for advanced backend access 99 * added OBackendFactory for advanced backend access
97 * 100 *
98 * Revision 1.1 2002/09/27 17:11:44 eilers 101 * Revision 1.1 2002/09/27 17:11:44 eilers
99 * Added API for accessing the Contact-Database ! It is compiling, but 102 * Added API for accessing the Contact-Database ! It is compiling, but
100 * please do not expect that anything is working ! 103 * please do not expect that anything is working !
101 * I will debug that stuff in the next time .. 104 * I will debug that stuff in the next time ..
102 * Please read README_COMPILE for compiling ! 105 * Please read README_COMPILE for compiling !
103 * 106 *
104 * 107 *
105 */ 108 */
106 109
107#include "ocontactaccessbackend_xml.h" 110#include "ocontactaccessbackend_xml.h"
108 111
109#include <qasciidict.h> 112#include <qasciidict.h>
110#include <qfile.h> 113#include <qfile.h>
111#include <qfileinfo.h> 114#include <qfileinfo.h>
112#include <qregexp.h> 115#include <qregexp.h>
113#include <qarray.h> 116#include <qarray.h>
114#include <qmap.h> 117#include <qmap.h>
115 118
116#include <qpe/global.h> 119#include <qpe/global.h>
117 120
118#include <opie/xmltree.h> 121#include <opie/xmltree.h>
119#include "ocontactaccessbackend.h" 122#include "ocontactaccessbackend.h"
120#include "ocontactaccess.h" 123#include "ocontactaccess.h"
121 124
122#include <stdlib.h> 125#include <stdlib.h>
123#include <errno.h> 126#include <errno.h>
124 127
125using namespace Opie; 128using namespace Opie;
126 129
127 130
128OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ): 131OContactAccessBackend_XML::OContactAccessBackend_XML ( const QString& appname, const QString& filename ):
129 m_changed( false ) 132 m_changed( false )
130{ 133{
131 // Just m_contactlist should call delete if an entry 134 // Just m_contactlist should call delete if an entry
132 // is removed. 135 // is removed.
133 m_contactList.setAutoDelete( true ); 136 m_contactList.setAutoDelete( true );
134 m_uidToContact.setAutoDelete( false ); 137 m_uidToContact.setAutoDelete( false );
135 138
136 m_appName = appname; 139 m_appName = appname;
137 140
138 /* Set journalfile name ... */ 141 /* Set journalfile name ... */
139 m_journalName = getenv("HOME"); 142 m_journalName = getenv("HOME");
140 m_journalName +="/.abjournal" + appname; 143 m_journalName +="/.abjournal" + appname;
141 144
142 /* Expecting to access the default filename if nothing else is set */ 145 /* Expecting to access the default filename if nothing else is set */
143 if ( filename.isEmpty() ){ 146 if ( filename.isEmpty() ){
144 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" ); 147 m_fileName = Global::applicationFileName( "addressbook","addressbook.xml" );
145 } else 148 } else
146 m_fileName = filename; 149 m_fileName = filename;
147 150
148 /* Load Database now */ 151 /* Load Database now */
149 load (); 152 load ();
150} 153}
151 154
152bool OContactAccessBackend_XML::save() 155bool OContactAccessBackend_XML::save()
153{ 156{
154 157
155 if ( !m_changed ) 158 if ( !m_changed )
156 return true; 159 return true;
157 160
158 QString strNewFile = m_fileName + ".new"; 161 QString strNewFile = m_fileName + ".new";
159 QFile f( strNewFile ); 162 QFile f( strNewFile );
160 if ( !f.open( IO_WriteOnly|IO_Raw ) ) 163 if ( !f.open( IO_WriteOnly|IO_Raw ) )
161 return false; 164 return false;
162 165
163 int total_written; 166 int total_written;
164 int idx_offset = 0; 167 int idx_offset = 0;
165 QString out; 168 QString out;
166 169
167 // Write Header 170 // Write Header
168 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n" 171 out = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><!DOCTYPE Addressbook ><AddressBook>\n"
169 " <Groups>\n" 172 " <Groups>\n"
170 " </Groups>\n" 173 " </Groups>\n"
171 " <Contacts>\n"; 174 " <Contacts>\n";
172 QCString cstr = out.utf8(); 175 QCString cstr = out.utf8();
173 f.writeBlock( cstr.data(), cstr.length() ); 176 f.writeBlock( cstr.data(), cstr.length() );
174 idx_offset += cstr.length(); 177 idx_offset += cstr.length();
175 out = ""; 178 out = "";
176 179
177 // Write all contacts 180 // Write all contacts
178 QListIterator<OContact> it( m_contactList ); 181 QListIterator<OContact> it( m_contactList );
179 for ( ; it.current(); ++it ) { 182 for ( ; it.current(); ++it ) {
180 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset ); 183 // qWarning(" Uid %d at Offset: %x", (*it)->uid(), idx_offset );
181 out += "<Contact "; 184 out += "<Contact ";
182 (*it)->save( out ); 185 (*it)->save( out );
183 out += "/>\n"; 186 out += "/>\n";
184 cstr = out.utf8(); 187 cstr = out.utf8();
185 total_written = f.writeBlock( cstr.data(), cstr.length() ); 188 total_written = f.writeBlock( cstr.data(), cstr.length() );
186 idx_offset += cstr.length(); 189 idx_offset += cstr.length();
187 if ( total_written != int(cstr.length()) ) { 190 if ( total_written != int(cstr.length()) ) {
188 f.close(); 191 f.close();
189 QFile::remove( strNewFile ); 192 QFile::remove( strNewFile );
190 return false; 193 return false;
191 } 194 }
192 out = ""; 195 out = "";
193 } 196 }
194 out += " </Contacts>\n</AddressBook>\n"; 197 out += " </Contacts>\n</AddressBook>\n";
195 198
196 // Write Footer 199 // Write Footer
197 cstr = out.utf8(); 200 cstr = out.utf8();
198 total_written = f.writeBlock( cstr.data(), cstr.length() ); 201 total_written = f.writeBlock( cstr.data(), cstr.length() );
199 if ( total_written != int( cstr.length() ) ) { 202 if ( total_written != int( cstr.length() ) ) {
200 f.close(); 203 f.close();
201 QFile::remove( strNewFile ); 204 QFile::remove( strNewFile );
202 return false; 205 return false;
203 } 206 }
204 f.close(); 207 f.close();
205 208
206 // move the file over, I'm just going to use the system call 209 // move the file over, I'm just going to use the system call
207 // because, I don't feel like using QDir. 210 // because, I don't feel like using QDir.
208 if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) { 211 if ( ::rename( strNewFile.latin1(), m_fileName.latin1() ) < 0 ) {
209 qWarning( "problem renaming file %s to %s, errno: %d", 212 qWarning( "problem renaming file %s to %s, errno: %d",
210 strNewFile.latin1(), m_journalName.latin1(), errno ); 213 strNewFile.latin1(), m_journalName.latin1(), errno );
211 // remove the tmp file... 214 // remove the tmp file...
212 QFile::remove( strNewFile ); 215 QFile::remove( strNewFile );
213 } 216 }
214 217
215 /* The journalfile should be removed now... */ 218 /* The journalfile should be removed now... */
216 removeJournal(); 219 removeJournal();
217 220
218 m_changed = false; 221 m_changed = false;
219 return true; 222 return true;
220} 223}
221 224
222bool OContactAccessBackend_XML::load () 225bool OContactAccessBackend_XML::load ()
223{ 226{
224 m_contactList.clear(); 227 m_contactList.clear();
225 m_uidToContact.clear(); 228 m_uidToContact.clear();
226 229
227 /* Load XML-File and journal if it exists */ 230 /* Load XML-File and journal if it exists */
228 if ( !load ( m_fileName, false ) ) 231 if ( !load ( m_fileName, false ) )
229 return false; 232 return false;
230 /* The returncode of the journalfile is ignored due to the 233 /* The returncode of the journalfile is ignored due to the
231 * fact that it does not exist when this class is instantiated ! 234 * fact that it does not exist when this class is instantiated !
232 * But there may such a file exist, if the application crashed. 235 * But there may such a file exist, if the application crashed.
233 * Therefore we try to load it to get the changes before the # 236 * Therefore we try to load it to get the changes before the #
234 * crash happened... 237 * crash happened...
235 */ 238 */
236 load (m_journalName, true); 239 load (m_journalName, true);
237 240
238 return true; 241 return true;
239} 242}
240 243
241void OContactAccessBackend_XML::clear () 244void OContactAccessBackend_XML::clear ()
242{ 245{
243 m_contactList.clear(); 246 m_contactList.clear();
244 m_uidToContact.clear(); 247 m_uidToContact.clear();
245 248
246 m_changed = false; 249 m_changed = false;
247} 250}
248 251
249bool OContactAccessBackend_XML::wasChangedExternally() 252bool OContactAccessBackend_XML::wasChangedExternally()
250{ 253{
251 QFileInfo fi( m_fileName ); 254 QFileInfo fi( m_fileName );
252 255
253 QDateTime lastmod = fi.lastModified (); 256 QDateTime lastmod = fi.lastModified ();
254 257
255 return (lastmod != m_readtime); 258 return (lastmod != m_readtime);
256} 259}
257 260
258QArray<int> OContactAccessBackend_XML::allRecords() const 261QArray<int> OContactAccessBackend_XML::allRecords() const
259{ 262{
260 QArray<int> uid_list( m_contactList.count() ); 263 QArray<int> uid_list( m_contactList.count() );
261 264
262 uint counter = 0; 265 uint counter = 0;
263 QListIterator<OContact> it( m_contactList ); 266 QListIterator<OContact> it( m_contactList );
264 for( ; it.current(); ++it ){ 267 for( ; it.current(); ++it ){
265 uid_list[counter++] = (*it)->uid(); 268 uid_list[counter++] = (*it)->uid();
266 } 269 }
267 270
268 return ( uid_list ); 271 return ( uid_list );
269} 272}
270 273
271OContact OContactAccessBackend_XML::find ( int uid ) const 274OContact OContactAccessBackend_XML::find ( int uid ) const
272{ 275{
273 OContact foundContact; //Create empty contact 276 OContact foundContact; //Create empty contact
274 277
275 OContact* found = m_uidToContact.find( QString().setNum( uid ) ); 278 OContact* found = m_uidToContact.find( QString().setNum( uid ) );
276 279
277 if ( found ){ 280 if ( found ){
278 foundContact = *found; 281 foundContact = *found;
279 } 282 }
280 283
281 return ( foundContact ); 284 return ( foundContact );
282} 285}
283 286
284QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings, 287QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings,
285 const QDateTime& d ) 288 const QDateTime& d )
286{ 289{
287 290
288 QArray<int> m_currentQuery( m_contactList.count() ); 291 QArray<int> m_currentQuery( m_contactList.count() );
289 QListIterator<OContact> it( m_contactList ); 292 QListIterator<OContact> it( m_contactList );
290 uint arraycounter = 0; 293 uint arraycounter = 0;
291 294
292 for( ; it.current(); ++it ){ 295 for( ; it.current(); ++it ){
293 /* Search all fields and compare them with query object. Store them into list 296 /* Search all fields and compare them with query object. Store them into list
294 * if all fields matches. 297 * if all fields matches.
295 */ 298 */
296 QDate* queryDate = 0l; 299 QDate* queryDate = 0l;
297 QDate* checkDate = 0l; 300 QDate* checkDate = 0l;
298 bool allcorrect = true; 301 bool allcorrect = true;
299 for ( int i = 0; i < Qtopia::Groups; i++ ) { 302 for ( int i = 0; i < Qtopia::Groups; i++ ) {
300 // Birthday and anniversary are special nonstring fields and should 303 // Birthday and anniversary are special nonstring fields and should
301 // be handled specially 304 // be handled specially
302 switch ( i ){ 305 switch ( i ){
303 case Qtopia::Birthday: 306 case Qtopia::Birthday:
304 queryDate = new QDate( query.birthday() ); 307 queryDate = new QDate( query.birthday() );
305 checkDate = new QDate( (*it)->birthday() ); 308 checkDate = new QDate( (*it)->birthday() );
306 case Qtopia::Anniversary: 309 case Qtopia::Anniversary:
307 if ( queryDate == 0l ){ 310 if ( queryDate == 0l ){
308 queryDate = new QDate( query.anniversary() ); 311 queryDate = new QDate( query.anniversary() );
309 checkDate = new QDate( (*it)->anniversary() ); 312 checkDate = new QDate( (*it)->anniversary() );
310 } 313 }
311 314
312 if ( queryDate->isValid() ){ 315 if ( queryDate->isValid() ){
313 if( checkDate->isValid() ){ 316 if( checkDate->isValid() ){
314 if ( settings & OContactAccess::DateYear ){ 317 if ( settings & OContactAccess::DateYear ){
315 if ( queryDate->year() != checkDate->year() ) 318 if ( queryDate->year() != checkDate->year() )
316 allcorrect = false; 319 allcorrect = false;
317 } 320 }
318 if ( settings & OContactAccess::DateMonth ){ 321 if ( settings & OContactAccess::DateMonth ){
319 if ( queryDate->month() != checkDate->month() ) 322 if ( queryDate->month() != checkDate->month() )
320 allcorrect = false; 323 allcorrect = false;
321 } 324 }
322 if ( settings & OContactAccess::DateDay ){ 325 if ( settings & OContactAccess::DateDay ){
323 if ( queryDate->day() != checkDate->day() ) 326 if ( queryDate->day() != checkDate->day() )
324 allcorrect = false; 327 allcorrect = false;
325 } 328 }
326 if ( settings & OContactAccess::DateDiff ) { 329 if ( settings & OContactAccess::DateDiff ) {
327 QDate current; 330 QDate current;
328 // If we get an additional date, we 331 // If we get an additional date, we
329 // will take this date instead of 332 // will take this date instead of
330 // the current one.. 333 // the current one..
331 if ( !d.date().isValid() ) 334 if ( !d.date().isValid() )
332 current = QDate::currentDate(); 335 current = QDate::currentDate();
333 else 336 else
334 current = d.date(); 337 current = d.date();
335 338
336 // We have to equalize the year, otherwise 339 // We have to equalize the year, otherwise
337 // the search will fail.. 340 // the search will fail..
338 checkDate->setYMD( current.year(), 341 checkDate->setYMD( current.year(),
339 checkDate->month(), 342 checkDate->month(),
340 checkDate->day() ); 343 checkDate->day() );
341 if ( *checkDate < current ) 344 if ( *checkDate < current )
342 checkDate->setYMD( current.year()+1, 345 checkDate->setYMD( current.year()+1,
343 checkDate->month(), 346 checkDate->month(),
344 checkDate->day() ); 347 checkDate->day() );
345 348
346 // Check whether the birthday/anniversary date is between 349 // Check whether the birthday/anniversary date is between
347 // the current/given date and the maximum date 350 // the current/given date and the maximum date
348 // ( maximum time range ) ! 351 // ( maximum time range ) !
349 qWarning("Checking if %s is between %s and %s ! ", 352 qWarning("Checking if %s is between %s and %s ! ",
350 checkDate->toString().latin1(), 353 checkDate->toString().latin1(),
351 current.toString().latin1(), 354 current.toString().latin1(),
352 queryDate->toString().latin1() ); 355 queryDate->toString().latin1() );
353 if ( current.daysTo( *queryDate ) >= 0 ){ 356 if ( current.daysTo( *queryDate ) >= 0 ){
354 if ( !( ( *checkDate >= current ) && 357 if ( !( ( *checkDate >= current ) &&
355 ( *checkDate <= *queryDate ) ) ){ 358 ( *checkDate <= *queryDate ) ) ){
356 allcorrect = false; 359 allcorrect = false;
357 qWarning (" Nope!.."); 360 qWarning (" Nope!..");
358 } 361 }
359 } 362 }
360 } 363 }
361 } else{ 364 } else{
362 // checkDate is invalid. Therefore this entry is always rejected 365 // checkDate is invalid. Therefore this entry is always rejected
363 allcorrect = false; 366 allcorrect = false;
364 } 367 }
365 } 368 }
366 369
367 delete queryDate; 370 delete queryDate;
368 queryDate = 0l; 371 queryDate = 0l;
369 delete checkDate; 372 delete checkDate;
370 checkDate = 0l; 373 checkDate = 0l;
371 break; 374 break;
372 default: 375 default:
373 /* Just compare fields which are not empty in the query object */ 376 /* Just compare fields which are not empty in the query object */
374 if ( !query.field(i).isEmpty() ){ 377 if ( !query.field(i).isEmpty() ){
375 switch ( settings & ~( OContactAccess::IgnoreCase 378 switch ( settings & ~( OContactAccess::IgnoreCase
376 | OContactAccess::DateDiff 379 | OContactAccess::DateDiff
377 | OContactAccess::DateYear 380 | OContactAccess::DateYear
378 | OContactAccess::DateMonth 381 | OContactAccess::DateMonth
379 | OContactAccess::DateDay 382 | OContactAccess::DateDay
380 | OContactAccess::MatchOne 383 | OContactAccess::MatchOne
381 ) ){ 384 ) ){
382 385
383 case OContactAccess::RegExp:{ 386 case OContactAccess::RegExp:{
384 QRegExp expr ( query.field(i), 387 QRegExp expr ( query.field(i),
385 !(settings & OContactAccess::IgnoreCase), 388 !(settings & OContactAccess::IgnoreCase),
386 false ); 389 false );
387 if ( expr.find ( (*it)->field(i), 0 ) == -1 ) 390 if ( expr.find ( (*it)->field(i), 0 ) == -1 )
388 allcorrect = false; 391 allcorrect = false;
389 } 392 }
390 break; 393 break;
391 case OContactAccess::WildCards:{ 394 case OContactAccess::WildCards:{
392 QRegExp expr ( query.field(i), 395 QRegExp expr ( query.field(i),
393 !(settings & OContactAccess::IgnoreCase), 396 !(settings & OContactAccess::IgnoreCase),
394 true ); 397 true );
395 if ( expr.find ( (*it)->field(i), 0 ) == -1 ) 398 if ( expr.find ( (*it)->field(i), 0 ) == -1 )
396 allcorrect = false; 399 allcorrect = false;
397 } 400 }
398 break; 401 break;
399 case OContactAccess::ExactMatch:{ 402 case OContactAccess::ExactMatch:{
400 if (settings & OContactAccess::IgnoreCase){ 403 if (settings & OContactAccess::IgnoreCase){
401 if ( query.field(i).upper() != 404 if ( query.field(i).upper() !=
402 (*it)->field(i).upper() ) 405 (*it)->field(i).upper() )
403 allcorrect = false; 406 allcorrect = false;
404 }else{ 407 }else{
405 if ( query.field(i) != (*it)->field(i) ) 408 if ( query.field(i) != (*it)->field(i) )
406 allcorrect = false; 409 allcorrect = false;
407 } 410 }
408 } 411 }
409 break; 412 break;
410 } 413 }
411 } 414 }
412 } 415 }
413 } 416 }
414 if ( allcorrect ){ 417 if ( allcorrect ){
415 m_currentQuery[arraycounter++] = (*it)->uid(); 418 m_currentQuery[arraycounter++] = (*it)->uid();
416 } 419 }
417 } 420 }
418 421
419 // Shrink to fit.. 422 // Shrink to fit..
420 m_currentQuery.resize(arraycounter); 423 m_currentQuery.resize(arraycounter);
421 424
422 return m_currentQuery; 425 return m_currentQuery;
423} 426}
424 427
425QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const 428QArray<int> OContactAccessBackend_XML::matchRegexp( const QRegExp &r ) const
426{ 429{
427 QArray<int> m_currentQuery( m_contactList.count() ); 430 QArray<int> m_currentQuery( m_contactList.count() );
428 QListIterator<OContact> it( m_contactList ); 431 QListIterator<OContact> it( m_contactList );
429 uint arraycounter = 0; 432 uint arraycounter = 0;
430 433
431 for( ; it.current(); ++it ){ 434 for( ; it.current(); ++it ){
432 if ( (*it)->match( r ) ){ 435 if ( (*it)->match( r ) ){
433 m_currentQuery[arraycounter++] = (*it)->uid(); 436 m_currentQuery[arraycounter++] = (*it)->uid();
434 } 437 }
435 438
436 } 439 }
437 // Shrink to fit.. 440 // Shrink to fit..
438 m_currentQuery.resize(arraycounter); 441 m_currentQuery.resize(arraycounter);
439 442
440 return m_currentQuery; 443 return m_currentQuery;
441} 444}
442 445
443const uint OContactAccessBackend_XML::querySettings() 446const uint OContactAccessBackend_XML::querySettings()
444{ 447{
445 return ( OContactAccess::WildCards 448 return ( OContactAccess::WildCards
446 | OContactAccess::IgnoreCase 449 | OContactAccess::IgnoreCase
447 | OContactAccess::RegExp 450 | OContactAccess::RegExp
448 | OContactAccess::ExactMatch 451 | OContactAccess::ExactMatch
449 | OContactAccess::DateDiff 452 | OContactAccess::DateDiff
450 | OContactAccess::DateYear 453 | OContactAccess::DateYear
451 | OContactAccess::DateMonth 454 | OContactAccess::DateMonth
452 | OContactAccess::DateDay 455 | OContactAccess::DateDay
453 ); 456 );
454} 457}
455 458
456bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const 459bool OContactAccessBackend_XML::hasQuerySettings (uint querySettings) const
457{ 460{
458 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay 461 /* OContactAccess::IgnoreCase, DateDiff, DateYear, DateMonth, DateDay
459 * may be added with any of the other settings. IgnoreCase should never used alone. 462 * may be added with any of the other settings. IgnoreCase should never used alone.
460 * Wildcards, RegExp, ExactMatch should never used at the same time... 463 * Wildcards, RegExp, ExactMatch should never used at the same time...
461 */ 464 */
462 465
463 // Step 1: Check whether the given settings are supported by this backend 466 // Step 1: Check whether the given settings are supported by this backend
464 if ( ( querySettings & ( 467 if ( ( querySettings & (
465 OContactAccess::IgnoreCase 468 OContactAccess::IgnoreCase
466 | OContactAccess::WildCards 469 | OContactAccess::WildCards
467 | OContactAccess::DateDiff 470 | OContactAccess::DateDiff
468 | OContactAccess::DateYear 471 | OContactAccess::DateYear
469 | OContactAccess::DateMonth 472 | OContactAccess::DateMonth
470 | OContactAccess::DateDay 473 | OContactAccess::DateDay
471 | OContactAccess::RegExp 474 | OContactAccess::RegExp
472 | OContactAccess::ExactMatch 475 | OContactAccess::ExactMatch
473 ) ) != querySettings ) 476 ) ) != querySettings )
474 return false; 477 return false;
475 478
476 // Step 2: Check whether the given combinations are ok.. 479 // Step 2: Check whether the given combinations are ok..
477 480
478 // IngoreCase alone is invalid 481 // IngoreCase alone is invalid
479 if ( querySettings == OContactAccess::IgnoreCase ) 482 if ( querySettings == OContactAccess::IgnoreCase )
480 return false; 483 return false;
481 484
482 // WildCards, RegExp and ExactMatch should never used at the same time 485 // WildCards, RegExp and ExactMatch should never used at the same time
483 switch ( querySettings & ~( OContactAccess::IgnoreCase 486 switch ( querySettings & ~( OContactAccess::IgnoreCase
484 | OContactAccess::DateDiff 487 | OContactAccess::DateDiff
485 | OContactAccess::DateYear 488 | OContactAccess::DateYear
486 | OContactAccess::DateMonth 489 | OContactAccess::DateMonth
487 | OContactAccess::DateDay 490 | OContactAccess::DateDay
488 ) 491 )
489 ){ 492 ){
490 case OContactAccess::RegExp: 493 case OContactAccess::RegExp:
491 return ( true ); 494 return ( true );
492 case OContactAccess::WildCards: 495 case OContactAccess::WildCards:
493 return ( true ); 496 return ( true );
494 case OContactAccess::ExactMatch: 497 case OContactAccess::ExactMatch:
495 return ( true ); 498 return ( true );
496 case 0: // one of the upper removed bits were set.. 499 case 0: // one of the upper removed bits were set..
497 return ( true ); 500 return ( true );
498 default: 501 default:
499 return ( false ); 502 return ( false );
500 } 503 }
501} 504}
502 505
503// Currently only asc implemented.. 506// Currently only asc implemented..
504QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int ) 507QArray<int> OContactAccessBackend_XML::sorted( bool asc, int , int , int )
505{ 508{
506 QMap<QString, int> nameToUid; 509 QMap<QString, int> nameToUid;
507 QStringList names; 510 QStringList names;
508 QArray<int> m_currentQuery( m_contactList.count() ); 511 QArray<int> m_currentQuery( m_contactList.count() );
509 512
510 // First fill map and StringList with all Names 513 // First fill map and StringList with all Names
511 // Afterwards sort namelist and use map to fill array to return.. 514 // Afterwards sort namelist and use map to fill array to return..
512 QListIterator<OContact> it( m_contactList ); 515 QListIterator<OContact> it( m_contactList );
513 for( ; it.current(); ++it ){ 516 for( ; it.current(); ++it ){
514 names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) ); 517 names.append( (*it)->fileAs() + QString::number( (*it)->uid() ) );
515 nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() ); 518 nameToUid.insert( (*it)->fileAs() + QString::number( (*it)->uid() ), (*it)->uid() );
516 } 519 }
517 names.sort(); 520 names.sort();
518 521
519 int i = 0; 522 int i = 0;
520 if ( asc ){ 523 if ( asc ){
521 for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it ) 524 for ( QStringList::Iterator it = names.begin(); it != names.end(); ++it )
522 m_currentQuery[i++] = nameToUid[ (*it) ]; 525 m_currentQuery[i++] = nameToUid[ (*it) ];
523 }else{ 526 }else{
524 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it ) 527 for ( QStringList::Iterator it = names.end(); it != names.begin(); --it )
525 m_currentQuery[i++] = nameToUid[ (*it) ]; 528 m_currentQuery[i++] = nameToUid[ (*it) ];
526 } 529 }
527 530
528 return m_currentQuery; 531 return m_currentQuery;
529 532
530} 533}
531 534
532bool OContactAccessBackend_XML::add ( const OContact &newcontact ) 535bool OContactAccessBackend_XML::add ( const OContact &newcontact )
533{ 536{
534 //qWarning("odefaultbackend: ACTION::ADD"); 537 //qWarning("odefaultbackend: ACTION::ADD");
535 updateJournal (newcontact, ACTION_ADD); 538 updateJournal (newcontact, ACTION_ADD);
536 addContact_p( newcontact ); 539 addContact_p( newcontact );
537 540
538 m_changed = true; 541 m_changed = true;
539 542
540 return true; 543 return true;
541} 544}
542 545
543bool OContactAccessBackend_XML::replace ( const OContact &contact ) 546bool OContactAccessBackend_XML::replace ( const OContact &contact )
544{ 547{
545 m_changed = true; 548 m_changed = true;
546 549
547 OContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) ); 550 OContact* found = m_uidToContact.find ( QString().setNum( contact.uid() ) );
548 551
549 if ( found ) { 552 if ( found ) {
550 OContact* newCont = new OContact( contact ); 553 OContact* newCont = new OContact( contact );
551 554
552 updateJournal ( *newCont, ACTION_REPLACE); 555 updateJournal ( *newCont, ACTION_REPLACE);
553 m_contactList.removeRef ( found ); 556 m_contactList.removeRef ( found );
554 m_contactList.append ( newCont ); 557 m_contactList.append ( newCont );
555 m_uidToContact.remove( QString().setNum( contact.uid() ) ); 558 m_uidToContact.remove( QString().setNum( contact.uid() ) );
556 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont ); 559 m_uidToContact.insert( QString().setNum( newCont->uid() ), newCont );
557 560
558 qWarning("Nur zur Sicherheit: %d == %d ?",contact.uid(), newCont->uid()); 561 qWarning("Nur zur Sicherheit: %d == %d ?",contact.uid(), newCont->uid());
559 562
560 return true; 563 return true;
561 } else 564 } else
562 return false; 565 return false;
563} 566}
564 567
565bool OContactAccessBackend_XML::remove ( int uid ) 568bool OContactAccessBackend_XML::remove ( int uid )
566{ 569{
567 m_changed = true; 570 m_changed = true;
568 571
569 OContact* found = m_uidToContact.find ( QString().setNum( uid ) ); 572 OContact* found = m_uidToContact.find ( QString().setNum( uid ) );
570 573
571 if ( found ) { 574 if ( found ) {
572 updateJournal ( *found, ACTION_REMOVE); 575 updateJournal ( *found, ACTION_REMOVE);
573 m_contactList.removeRef ( found ); 576 m_contactList.removeRef ( found );
574 m_uidToContact.remove( QString().setNum( uid ) ); 577 m_uidToContact.remove( QString().setNum( uid ) );
575 578
576 return true; 579 return true;
577 } else 580 } else
578 return false; 581 return false;
579} 582}
580 583
581bool OContactAccessBackend_XML::reload(){ 584bool OContactAccessBackend_XML::reload(){
582 /* Reload is the same as load in this implementation */ 585 /* Reload is the same as load in this implementation */
583 return ( load() ); 586 return ( load() );
584} 587}
585 588
586void OContactAccessBackend_XML::addContact_p( const OContact &newcontact ) 589void OContactAccessBackend_XML::addContact_p( const OContact &newcontact )
587{ 590{
588 OContact* contRef = new OContact( newcontact ); 591 OContact* contRef = new OContact( newcontact );
589 592
590 m_contactList.append ( contRef ); 593 m_contactList.append ( contRef );
591 m_uidToContact.insert( QString().setNum( newcontact.uid() ), contRef ); 594 m_uidToContact.insert( QString().setNum( newcontact.uid() ), contRef );
592} 595}
593 596
594/* This function loads the xml-database and the journalfile */ 597/* This function loads the xml-database and the journalfile */
595bool OContactAccessBackend_XML::load( const QString filename, bool isJournal ) 598bool OContactAccessBackend_XML::load( const QString filename, bool isJournal )
596{ 599{
597 600
598 /* We use the time of the last read to check if the file was 601 /* We use the time of the last read to check if the file was
599 * changed externally. 602 * changed externally.
600 */ 603 */
601 if ( !isJournal ){ 604 if ( !isJournal ){
602 QFileInfo fi( filename ); 605 QFileInfo fi( filename );
603 m_readtime = fi.lastModified (); 606 m_readtime = fi.lastModified ();
604 } 607 }
605 608
606 const int JOURNALACTION = Qtopia::Notes + 1; 609 const int JOURNALACTION = Qtopia::Notes + 1;
607 const int JOURNALROW = JOURNALACTION + 1; 610 const int JOURNALROW = JOURNALACTION + 1;
608 611
609 bool foundAction = false; 612 bool foundAction = false;
610 journal_action action = ACTION_ADD; 613 journal_action action = ACTION_ADD;
611 int journalKey = 0; 614 int journalKey = 0;
612 QMap<int, QString> contactMap; 615 QMap<int, QString> contactMap;
613 QMap<QString, QString> customMap; 616 QMap<QString, QString> customMap;
614 QMap<QString, QString>::Iterator customIt; 617 QMap<QString, QString>::Iterator customIt;
615 QAsciiDict<int> dict( 47 ); 618 QAsciiDict<int> dict( 47 );
616 619
617 dict.setAutoDelete( TRUE ); 620 dict.setAutoDelete( TRUE );
618 dict.insert( "Uid", new int(Qtopia::AddressUid) ); 621 dict.insert( "Uid", new int(Qtopia::AddressUid) );
619 dict.insert( "Title", new int(Qtopia::Title) ); 622 dict.insert( "Title", new int(Qtopia::Title) );
620 dict.insert( "FirstName", new int(Qtopia::FirstName) ); 623 dict.insert( "FirstName", new int(Qtopia::FirstName) );
621 dict.insert( "MiddleName", new int(Qtopia::MiddleName) ); 624 dict.insert( "MiddleName", new int(Qtopia::MiddleName) );
622 dict.insert( "LastName", new int(Qtopia::LastName) ); 625 dict.insert( "LastName", new int(Qtopia::LastName) );
623 dict.insert( "Suffix", new int(Qtopia::Suffix) ); 626 dict.insert( "Suffix", new int(Qtopia::Suffix) );
624 dict.insert( "FileAs", new int(Qtopia::FileAs) ); 627 dict.insert( "FileAs", new int(Qtopia::FileAs) );
625 dict.insert( "Categories", new int(Qtopia::AddressCategory) ); 628 dict.insert( "Categories", new int(Qtopia::AddressCategory) );
626 dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) ); 629 dict.insert( "DefaultEmail", new int(Qtopia::DefaultEmail) );
627 dict.insert( "Emails", new int(Qtopia::Emails) ); 630 dict.insert( "Emails", new int(Qtopia::Emails) );
628 dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) ); 631 dict.insert( "HomeStreet", new int(Qtopia::HomeStreet) );
629 dict.insert( "HomeCity", new int(Qtopia::HomeCity) ); 632 dict.insert( "HomeCity", new int(Qtopia::HomeCity) );
630 dict.insert( "HomeState", new int(Qtopia::HomeState) ); 633 dict.insert( "HomeState", new int(Qtopia::HomeState) );
631 dict.insert( "HomeZip", new int(Qtopia::HomeZip) ); 634 dict.insert( "HomeZip", new int(Qtopia::HomeZip) );
632 dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) ); 635 dict.insert( "HomeCountry", new int(Qtopia::HomeCountry) );
633 dict.insert( "HomePhone", new int(Qtopia::HomePhone) ); 636 dict.insert( "HomePhone", new int(Qtopia::HomePhone) );
634 dict.insert( "HomeFax", new int(Qtopia::HomeFax) ); 637 dict.insert( "HomeFax", new int(Qtopia::HomeFax) );
635 dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) ); 638 dict.insert( "HomeMobile", new int(Qtopia::HomeMobile) );
636 dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) ); 639 dict.insert( "HomeWebPage", new int(Qtopia::HomeWebPage) );
637 dict.insert( "Company", new int(Qtopia::Company) ); 640 dict.insert( "Company", new int(Qtopia::Company) );
638 dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) ); 641 dict.insert( "BusinessStreet", new int(Qtopia::BusinessStreet) );
639 dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) ); 642 dict.insert( "BusinessCity", new int(Qtopia::BusinessCity) );
640 dict.insert( "BusinessState", new int(Qtopia::BusinessState) ); 643 dict.insert( "BusinessState", new int(Qtopia::BusinessState) );
641 dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) ); 644 dict.insert( "BusinessZip", new int(Qtopia::BusinessZip) );
642 dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) ); 645 dict.insert( "BusinessCountry", new int(Qtopia::BusinessCountry) );
643 dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) ); 646 dict.insert( "BusinessWebPage", new int(Qtopia::BusinessWebPage) );
644 dict.insert( "JobTitle", new int(Qtopia::JobTitle) ); 647 dict.insert( "JobTitle", new int(Qtopia::JobTitle) );
645 dict.insert( "Department", new int(Qtopia::Department) ); 648 dict.insert( "Department", new int(Qtopia::Department) );
646 dict.insert( "Office", new int(Qtopia::Office) ); 649 dict.insert( "Office", new int(Qtopia::Office) );
647 dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) ); 650 dict.insert( "BusinessPhone", new int(Qtopia::BusinessPhone) );
648 dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) ); 651 dict.insert( "BusinessFax", new int(Qtopia::BusinessFax) );
649 dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) ); 652 dict.insert( "BusinessMobile", new int(Qtopia::BusinessMobile) );
650 dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) ); 653 dict.insert( "BusinessPager", new int(Qtopia::BusinessPager) );
651 dict.insert( "Profession", new int(Qtopia::Profession) ); 654 dict.insert( "Profession", new int(Qtopia::Profession) );
652 dict.insert( "Assistant", new int(Qtopia::Assistant) ); 655 dict.insert( "Assistant", new int(Qtopia::Assistant) );
653 dict.insert( "Manager", new int(Qtopia::Manager) ); 656 dict.insert( "Manager", new int(Qtopia::Manager) );
654 dict.insert( "Spouse", new int(Qtopia::Spouse) ); 657 dict.insert( "Spouse", new int(Qtopia::Spouse) );
655 dict.insert( "Children", new int(Qtopia::Children) ); 658 dict.insert( "Children", new int(Qtopia::Children) );
656 dict.insert( "Gender", new int(Qtopia::Gender) ); 659 dict.insert( "Gender", new int(Qtopia::Gender) );
657 dict.insert( "Birthday", new int(Qtopia::Birthday) ); 660 dict.insert( "Birthday", new int(Qtopia::Birthday) );
658 dict.insert( "Anniversary", new int(Qtopia::Anniversary) ); 661 dict.insert( "Anniversary", new int(Qtopia::Anniversary) );
659 dict.insert( "Nickname", new int(Qtopia::Nickname) ); 662 dict.insert( "Nickname", new int(Qtopia::Nickname) );
660 dict.insert( "Notes", new int(Qtopia::Notes) ); 663 dict.insert( "Notes", new int(Qtopia::Notes) );
661 dict.insert( "action", new int(JOURNALACTION) ); 664 dict.insert( "action", new int(JOURNALACTION) );
662 dict.insert( "actionrow", new int(JOURNALROW) ); 665 dict.insert( "actionrow", new int(JOURNALROW) );
663 666
664 //qWarning( "OContactDefaultBackEnd::loading %s", filename.latin1() ); 667 //qWarning( "OContactDefaultBackEnd::loading %s", filename.latin1() );
665 668
666 XMLElement *root = XMLElement::load( filename ); 669 XMLElement *root = XMLElement::load( filename );
667 if(root != 0l ){ // start parsing 670 if(root != 0l ){ // start parsing
668 /* Parse all XML-Elements and put the data into the 671 /* Parse all XML-Elements and put the data into the
669 * Contact-Class 672 * Contact-Class
670 */ 673 */
671 XMLElement *element = root->firstChild(); 674 XMLElement *element = root->firstChild();
672 //qWarning("OContactAccess::load tagName(): %s", root->tagName().latin1() ); 675 //qWarning("OContactAccess::load tagName(): %s", root->tagName().latin1() );
673 element = element->firstChild(); 676 element = element->firstChild();
674 677
675 /* Search Tag "Contacts" which is the parent of all Contacts */ 678 /* Search Tag "Contacts" which is the parent of all Contacts */
676 while( element && !isJournal ){ 679 while( element && !isJournal ){
677 if( element->tagName() != QString::fromLatin1("Contacts") ){ 680 if( element->tagName() != QString::fromLatin1("Contacts") ){
678 //qWarning ("OContactDefBack::Searching for Tag \"Contacts\"! Found: %s", 681 //qWarning ("OContactDefBack::Searching for Tag \"Contacts\"! Found: %s",
679 // element->tagName().latin1()); 682 // element->tagName().latin1());
680 element = element->nextChild(); 683 element = element->nextChild();
681 } else { 684 } else {
682 element = element->firstChild(); 685 element = element->firstChild();
683 break; 686 break;
684 } 687 }
685 } 688 }
686 /* Parse all Contacts and ignore unknown tags */ 689 /* Parse all Contacts and ignore unknown tags */
687 while( element ){ 690 while( element ){
688 if( element->tagName() != QString::fromLatin1("Contact") ){ 691 if( element->tagName() != QString::fromLatin1("Contact") ){
689 //qWarning ("OContactDefBack::Searching for Tag \"Contact\"! Found: %s", 692 //qWarning ("OContactDefBack::Searching for Tag \"Contact\"! Found: %s",
690 // element->tagName().latin1()); 693 // element->tagName().latin1());
691 element = element->nextChild(); 694 element = element->nextChild();
692 continue; 695 continue;
693 } 696 }
694 /* Found alement with tagname "contact", now parse and store all 697 /* Found alement with tagname "contact", now parse and store all
695 * attributes contained 698 * attributes contained
696 */ 699 */
697 //qWarning("OContactDefBack::load element tagName() : %s", 700 //qWarning("OContactDefBack::load element tagName() : %s",
698 // element->tagName().latin1() ); 701 // element->tagName().latin1() );
699 QString dummy; 702 QString dummy;
700 foundAction = false; 703 foundAction = false;
701 704
702 XMLElement::AttributeMap aMap = element->attributes(); 705 XMLElement::AttributeMap aMap = element->attributes();
703 XMLElement::AttributeMap::Iterator it; 706 XMLElement::AttributeMap::Iterator it;
704 contactMap.clear(); 707 contactMap.clear();
705 customMap.clear(); 708 customMap.clear();
706 for( it = aMap.begin(); it != aMap.end(); ++it ){ 709 for( it = aMap.begin(); it != aMap.end(); ++it ){
707 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1()); 710 // qWarning ("Read Attribute: %s=%s", it.key().latin1(),it.data().latin1());
708 711
709 int *find = dict[ it.key() ]; 712 int *find = dict[ it.key() ];
710 /* Unknown attributes will be stored as "Custom" elements */ 713 /* Unknown attributes will be stored as "Custom" elements */
711 if ( !find ) { 714 if ( !find ) {
712 // qWarning("Attribute %s not known.", it.key().latin1()); 715 // qWarning("Attribute %s not known.", it.key().latin1());
713 //contact.setCustomField(it.key(), it.data()); 716 //contact.setCustomField(it.key(), it.data());
714 customMap.insert( it.key(), it.data() ); 717 customMap.insert( it.key(), it.data() );
715 continue; 718 continue;
716 } 719 }
717 720
718 /* Check if special conversion is needed and add attribute 721 /* Check if special conversion is needed and add attribute
719 * into Contact class 722 * into Contact class
720 */ 723 */
721 switch( *find ) { 724 switch( *find ) {
722 /* 725 /*
723 case Qtopia::AddressUid: 726 case Qtopia::AddressUid:
724 contact.setUid( it.data().toInt() ); 727 contact.setUid( it.data().toInt() );
725 break; 728 break;
726 case Qtopia::AddressCategory: 729 case Qtopia::AddressCategory:
727 contact.setCategories( Qtopia::Record::idsFromString( it.data( ))); 730 contact.setCategories( Qtopia::Record::idsFromString( it.data( )));
728 break; 731 break;
729 */ 732 */
730 case JOURNALACTION: 733 case JOURNALACTION:
731 action = journal_action(it.data().toInt()); 734 action = journal_action(it.data().toInt());
732 foundAction = true; 735 foundAction = true;
733 qWarning ("ODefBack(journal)::ACTION found: %d", action); 736 qWarning ("ODefBack(journal)::ACTION found: %d", action);
734 break; 737 break;
735 case JOURNALROW: 738 case JOURNALROW:
736 journalKey = it.data().toInt(); 739 journalKey = it.data().toInt();
737 break; 740 break;
738 default: // no conversion needed add them to the map 741 default: // no conversion needed add them to the map
739 contactMap.insert( *find, it.data() ); 742 contactMap.insert( *find, it.data() );
740 break; 743 break;
741 } 744 }
742 } 745 }
743 /* now generate the Contact contact */ 746 /* now generate the Contact contact */
744 OContact contact( contactMap ); 747 OContact contact( contactMap );
745 748
746 for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) { 749 for (customIt = customMap.begin(); customIt != customMap.end(); ++customIt ) {
747 contact.setCustomField( customIt.key(), customIt.data() ); 750 contact.setCustomField( customIt.key(), customIt.data() );
748 } 751 }
749 752
750 if (foundAction){ 753 if (foundAction){
751 foundAction = false; 754 foundAction = false;
752 switch ( action ) { 755 switch ( action ) {
753 case ACTION_ADD: 756 case ACTION_ADD:
754 addContact_p (contact); 757 addContact_p (contact);
755 break; 758 break;
756 case ACTION_REMOVE: 759 case ACTION_REMOVE:
757 if ( !remove (contact.uid()) ) 760 if ( !remove (contact.uid()) )
758 qWarning ("ODefBack(journal)::Unable to remove uid: %d", 761 qWarning ("ODefBack(journal)::Unable to remove uid: %d",
759 contact.uid() ); 762 contact.uid() );
760 break; 763 break;
761 case ACTION_REPLACE: 764 case ACTION_REPLACE:
762 if ( !replace ( contact ) ) 765 if ( !replace ( contact ) )
763 qWarning ("ODefBack(journal)::Unable to replace uid: %d", 766 qWarning ("ODefBack(journal)::Unable to replace uid: %d",
764 contact.uid() ); 767 contact.uid() );
765 break; 768 break;
766 default: 769 default:
767 qWarning ("Unknown action: ignored !"); 770 qWarning ("Unknown action: ignored !");
768 break; 771 break;
769 } 772 }
770 }else{ 773 }else{
771 /* Add contact to list */ 774 /* Add contact to list */
772 addContact_p (contact); 775 addContact_p (contact);
773 } 776 }
774 777
775 /* Move to next element */ 778 /* Move to next element */
776 element = element->nextChild(); 779 element = element->nextChild();
777 } 780 }
778 }else { 781 }else {
779 qWarning("ODefBack::could not load"); 782 qWarning("ODefBack::could not load");
780 } 783 }
781 delete root; 784 delete root;
782 qWarning("returning from loading" ); 785 qWarning("returning from loading" );
783 return true; 786 return true;
784} 787}
785 788
786 789
787void OContactAccessBackend_XML::updateJournal( const OContact& cnt, 790void OContactAccessBackend_XML::updateJournal( const OContact& cnt,
788 journal_action action ) 791 journal_action action )
789{ 792{
790 QFile f( m_journalName ); 793 QFile f( m_journalName );
791 bool created = !f.exists(); 794 bool created = !f.exists();
792 if ( !f.open(IO_WriteOnly|IO_Append) ) 795 if ( !f.open(IO_WriteOnly|IO_Append) )
793 return; 796 return;
794 797
795 QString buf; 798 QString buf;
796 QCString str; 799 QCString str;
797 800
798 // if the file was created, we have to set the Tag "<CONTACTS>" to 801 // if the file was created, we have to set the Tag "<CONTACTS>" to
799 // get a XML-File which is readable by our parser. 802 // get a XML-File which is readable by our parser.
800 // This is just a cheat, but better than rewrite the parser. 803 // This is just a cheat, but better than rewrite the parser.
801 if ( created ){ 804 if ( created ){
802 buf = "<Contacts>"; 805 buf = "<Contacts>";
803 QCString cstr = buf.utf8(); 806 QCString cstr = buf.utf8();
804 f.writeBlock( cstr.data(), cstr.length() ); 807 f.writeBlock( cstr.data(), cstr.length() );
805 } 808 }
806 809
807 buf = "<Contact "; 810 buf = "<Contact ";
808 cnt.save( buf ); 811 cnt.save( buf );
809 buf += " action=\"" + QString::number( (int)action ) + "\" "; 812 buf += " action=\"" + QString::number( (int)action ) + "\" ";
810 buf += "/>\n"; 813 buf += "/>\n";
811 QCString cstr = buf.utf8(); 814 QCString cstr = buf.utf8();
812 f.writeBlock( cstr.data(), cstr.length() ); 815 f.writeBlock( cstr.data(), cstr.length() );
813} 816}
814 817
815void OContactAccessBackend_XML::removeJournal() 818void OContactAccessBackend_XML::removeJournal()
816{ 819{
817 QFile f ( m_journalName ); 820 QFile f ( m_journalName );
818 if ( f.exists() ) 821 if ( f.exists() )
819 f.remove(); 822 f.remove();
820} 823}
821 824
diff --git a/libopie/pim/ocontactaccessbackend_xml.h b/noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h
index a0cae4d..6857844 100644
--- a/libopie/pim/ocontactaccessbackend_xml.h
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend_xml.h
@@ -1,160 +1,163 @@
1/* 1/*
2 * XML Backend for the OPIE-Contact Database. 2 * XML Backend for the OPIE-Contact Database.
3 * 3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ToDo: XML-Backend: Automatic reload if something was changed... 12 * ToDo: XML-Backend: Automatic reload if something was changed...
13 * File Locking to protect against concurrent access 13 * File Locking to protect against concurrent access
14 * 14 *
15 * 15 *
16 * ===================================================================== 16 * =====================================================================
17 * Version: $Id$ 17 * Version: $Id$
18 * ===================================================================== 18 * =====================================================================
19 * History: 19 * History:
20 * $Log$ 20 * $Log$
21 * Revision 1.1 2004/11/16 21:46:07 mickeyl
22 * libopie1 goes into unsupported
23 *
21 * Revision 1.15 2003/09/22 14:31:16 eilers 24 * Revision 1.15 2003/09/22 14:31:16 eilers
22 * Added first experimental incarnation of sql-backend for addressbook. 25 * Added first experimental incarnation of sql-backend for addressbook.
23 * Some modifications to be able to compile the todo sql-backend. 26 * Some modifications to be able to compile the todo sql-backend.
24 * A lot of changes fill follow... 27 * A lot of changes fill follow...
25 * 28 *
26 * Revision 1.14 2003/04/13 18:07:10 zecke 29 * Revision 1.14 2003/04/13 18:07:10 zecke
27 * More API doc 30 * More API doc
28 * QString -> const QString& 31 * QString -> const QString&
29 * QString = 0l -> QString::null 32 * QString = 0l -> QString::null
30 * 33 *
31 * Revision 1.13 2003/03/21 10:33:09 eilers 34 * Revision 1.13 2003/03/21 10:33:09 eilers
32 * Merged speed optimized xml backend for contacts to main. 35 * Merged speed optimized xml backend for contacts to main.
33 * Added QDateTime to querybyexample. For instance, it is now possible to get 36 * Added QDateTime to querybyexample. For instance, it is now possible to get
34 * all Birthdays/Anniversaries between two dates. This should be used 37 * all Birthdays/Anniversaries between two dates. This should be used
35 * to show all birthdays in the datebook.. 38 * to show all birthdays in the datebook..
36 * This change is sourcecode backward compatible but you have to upgrade 39 * This change is sourcecode backward compatible but you have to upgrade
37 * the binaries for today-addressbook. 40 * the binaries for today-addressbook.
38 * 41 *
39 * Revision 1.12.2.2 2003/02/11 12:17:28 eilers 42 * Revision 1.12.2.2 2003/02/11 12:17:28 eilers
40 * Speed optimization. Removed the sequential search loops. 43 * Speed optimization. Removed the sequential search loops.
41 * 44 *
42 * Revision 1.12.2.1 2003/02/09 15:05:01 eilers 45 * Revision 1.12.2.1 2003/02/09 15:05:01 eilers
43 * Nothing happened.. Just some cleanup before I will start.. 46 * Nothing happened.. Just some cleanup before I will start..
44 * 47 *
45 * Revision 1.12 2003/01/03 16:58:03 eilers 48 * Revision 1.12 2003/01/03 16:58:03 eilers
46 * Reenable debug output 49 * Reenable debug output
47 * 50 *
48 * Revision 1.11 2003/01/03 12:31:28 eilers 51 * Revision 1.11 2003/01/03 12:31:28 eilers
49 * Bugfix for calculating data diffs.. 52 * Bugfix for calculating data diffs..
50 * 53 *
51 * Revision 1.10 2003/01/02 14:27:12 eilers 54 * Revision 1.10 2003/01/02 14:27:12 eilers
52 * Improved query by example: Search by date is possible.. First step 55 * Improved query by example: Search by date is possible.. First step
53 * for a today plugin for birthdays.. 56 * for a today plugin for birthdays..
54 * 57 *
55 * Revision 1.9 2002/12/08 12:48:57 eilers 58 * Revision 1.9 2002/12/08 12:48:57 eilers
56 * Moved journal-enum from ocontact into i the xml-backend.. 59 * Moved journal-enum from ocontact into i the xml-backend..
57 * 60 *
58 * Revision 1.8 2002/11/14 17:04:24 eilers 61 * Revision 1.8 2002/11/14 17:04:24 eilers
59 * Sorting will now work if fullname is identical on some entries 62 * Sorting will now work if fullname is identical on some entries
60 * 63 *
61 * Revision 1.7 2002/11/13 15:02:46 eilers 64 * Revision 1.7 2002/11/13 15:02:46 eilers
62 * Small Bug in sorted fixed 65 * Small Bug in sorted fixed
63 * 66 *
64 * Revision 1.6 2002/11/13 14:14:51 eilers 67 * Revision 1.6 2002/11/13 14:14:51 eilers
65 * Added sorted for Contacts.. 68 * Added sorted for Contacts..
66 * 69 *
67 * Revision 1.5 2002/11/01 15:10:42 eilers 70 * Revision 1.5 2002/11/01 15:10:42 eilers
68 * Added regExp-search in database for all fields in a contact. 71 * Added regExp-search in database for all fields in a contact.
69 * 72 *
70 * Revision 1.4 2002/10/16 10:52:40 eilers 73 * Revision 1.4 2002/10/16 10:52:40 eilers
71 * Added some docu to the interface and now using the cache infrastucture by zecke.. :) 74 * Added some docu to the interface and now using the cache infrastucture by zecke.. :)
72 * 75 *
73 * Revision 1.3 2002/10/14 16:21:54 eilers 76 * Revision 1.3 2002/10/14 16:21:54 eilers
74 * Some minor interface updates 77 * Some minor interface updates
75 * 78 *
76 * Revision 1.2 2002/10/07 17:34:24 eilers 79 * Revision 1.2 2002/10/07 17:34:24 eilers
77 * added OBackendFactory for advanced backend access 80 * added OBackendFactory for advanced backend access
78 * 81 *
79 * Revision 1.1 2002/09/27 17:11:44 eilers 82 * Revision 1.1 2002/09/27 17:11:44 eilers
80 * Added API for accessing the Contact-Database ! It is compiling, but 83 * Added API for accessing the Contact-Database ! It is compiling, but
81 * please do not expect that anything is working ! 84 * please do not expect that anything is working !
82 * I will debug that stuff in the next time .. 85 * I will debug that stuff in the next time ..
83 * Please read README_COMPILE for compiling ! 86 * Please read README_COMPILE for compiling !
84 * 87 *
85 * 88 *
86 */ 89 */
87 90
88#ifndef _OContactAccessBackend_XML_ 91#ifndef _OContactAccessBackend_XML_
89#define _OContactAccessBackend_XML_ 92#define _OContactAccessBackend_XML_
90 93
91#include "ocontactaccessbackend.h" 94#include "ocontactaccessbackend.h"
92#include "ocontactaccess.h" 95#include "ocontactaccess.h"
93 96
94#include <qlist.h> 97#include <qlist.h>
95#include <qdict.h> 98#include <qdict.h>
96 99
97/* the default xml implementation */ 100/* the default xml implementation */
98/** 101/**
99 * This class is the XML implementation of a Contact backend 102 * This class is the XML implementation of a Contact backend
100 * it does implement everything available for OContact. 103 * it does implement everything available for OContact.
101 * @see OPimAccessBackend for more information of available methods 104 * @see OPimAccessBackend for more information of available methods
102 */ 105 */
103class OContactAccessBackend_XML : public OContactAccessBackend { 106class OContactAccessBackend_XML : public OContactAccessBackend {
104 public: 107 public:
105 OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null ); 108 OContactAccessBackend_XML ( const QString& appname, const QString& filename = QString::null );
106 109
107 bool save(); 110 bool save();
108 111
109 bool load (); 112 bool load ();
110 113
111 void clear (); 114 void clear ();
112 115
113 bool wasChangedExternally(); 116 bool wasChangedExternally();
114 117
115 QArray<int> allRecords() const; 118 QArray<int> allRecords() const;
116 119
117 OContact find ( int uid ) const; 120 OContact find ( int uid ) const;
118 121
119 QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() ); 122 QArray<int> queryByExample ( const OContact &query, int settings, const QDateTime& d = QDateTime() );
120 123
121 QArray<int> matchRegexp( const QRegExp &r ) const; 124 QArray<int> matchRegexp( const QRegExp &r ) const;
122 125
123 const uint querySettings(); 126 const uint querySettings();
124 127
125 bool hasQuerySettings (uint querySettings) const; 128 bool hasQuerySettings (uint querySettings) const;
126 129
127 // Currently only asc implemented.. 130 // Currently only asc implemented..
128 QArray<int> sorted( bool asc, int , int , int ); 131 QArray<int> sorted( bool asc, int , int , int );
129 bool add ( const OContact &newcontact ); 132 bool add ( const OContact &newcontact );
130 133
131 bool replace ( const OContact &contact ); 134 bool replace ( const OContact &contact );
132 135
133 bool remove ( int uid ); 136 bool remove ( int uid );
134 bool reload(); 137 bool reload();
135 138
136 private: 139 private:
137 140
138 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE }; 141 enum journal_action { ACTION_ADD, ACTION_REMOVE, ACTION_REPLACE };
139 142
140 void addContact_p( const OContact &newcontact ); 143 void addContact_p( const OContact &newcontact );
141 144
142 /* This function loads the xml-database and the journalfile */ 145 /* This function loads the xml-database and the journalfile */
143 bool load( const QString filename, bool isJournal ); 146 bool load( const QString filename, bool isJournal );
144 147
145 148
146 void updateJournal( const OContact& cnt, journal_action action ); 149 void updateJournal( const OContact& cnt, journal_action action );
147 void removeJournal(); 150 void removeJournal();
148 151
149 protected: 152 protected:
150 bool m_changed; 153 bool m_changed;
151 QString m_journalName; 154 QString m_journalName;
152 QString m_fileName; 155 QString m_fileName;
153 QString m_appName; 156 QString m_appName;
154 QList<OContact> m_contactList; 157 QList<OContact> m_contactList;
155 QDateTime m_readtime; 158 QDateTime m_readtime;
156 159
157 QDict<OContact> m_uidToContact; 160 QDict<OContact> m_uidToContact;
158}; 161};
159 162
160#endif 163#endif
diff --git a/libopie/pim/ocontactfields.cpp b/noncore/unsupported/libopie/pim/ocontactfields.cpp
index 0f08a5a..0f08a5a 100644
--- a/libopie/pim/ocontactfields.cpp
+++ b/noncore/unsupported/libopie/pim/ocontactfields.cpp
diff --git a/libopie/pim/ocontactfields.h b/noncore/unsupported/libopie/pim/ocontactfields.h
index f105de7..f105de7 100644
--- a/libopie/pim/ocontactfields.h
+++ b/noncore/unsupported/libopie/pim/ocontactfields.h
diff --git a/libopie/pim/oconversion.cpp b/noncore/unsupported/libopie/pim/oconversion.cpp
index 0d15414..0d15414 100644
--- a/libopie/pim/oconversion.cpp
+++ b/noncore/unsupported/libopie/pim/oconversion.cpp
diff --git a/libopie/pim/oconversion.h b/noncore/unsupported/libopie/pim/oconversion.h
index 4c0a497..4c0a497 100644
--- a/libopie/pim/oconversion.h
+++ b/noncore/unsupported/libopie/pim/oconversion.h
diff --git a/libopie/pim/odatebookaccess.cpp b/noncore/unsupported/libopie/pim/odatebookaccess.cpp
index d95fed6..d95fed6 100644
--- a/libopie/pim/odatebookaccess.cpp
+++ b/noncore/unsupported/libopie/pim/odatebookaccess.cpp
diff --git a/libopie/pim/odatebookaccess.h b/noncore/unsupported/libopie/pim/odatebookaccess.h
index 62196da..62196da 100644
--- a/libopie/pim/odatebookaccess.h
+++ b/noncore/unsupported/libopie/pim/odatebookaccess.h
diff --git a/libopie/pim/odatebookaccessbackend.cpp b/noncore/unsupported/libopie/pim/odatebookaccessbackend.cpp
index f0c5d65..f0c5d65 100644
--- a/libopie/pim/odatebookaccessbackend.cpp
+++ b/noncore/unsupported/libopie/pim/odatebookaccessbackend.cpp
diff --git a/libopie/pim/odatebookaccessbackend.h b/noncore/unsupported/libopie/pim/odatebookaccessbackend.h
index 3472ab3..3472ab3 100644
--- a/libopie/pim/odatebookaccessbackend.h
+++ b/noncore/unsupported/libopie/pim/odatebookaccessbackend.h
diff --git a/libopie/pim/odatebookaccessbackend_sql.cpp b/noncore/unsupported/libopie/pim/odatebookaccessbackend_sql.cpp
index 44dd2bc..5f87afe 100644
--- a/libopie/pim/odatebookaccessbackend_sql.cpp
+++ b/noncore/unsupported/libopie/pim/odatebookaccessbackend_sql.cpp
@@ -1,371 +1,374 @@
1/* 1/*
2 * SQL Backend for the OPIE-Calender Database. 2 * SQL Backend for the OPIE-Calender Database.
3 * 3 *
4 * Copyright (c) 2003 by Stefan Eilers (Eilers.Stefan@epost.de) 4 * Copyright (c) 2003 by Stefan Eilers (Eilers.Stefan@epost.de)
5 * 5 *
6 * ===================================================================== 6 * =====================================================================
7 *This program is free software; you can redistribute it and/or 7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public 8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
11 * ===================================================================== 11 * =====================================================================
12 * ===================================================================== 12 * =====================================================================
13 * Version: $Id$ 13 * Version: $Id$
14 * ===================================================================== 14 * =====================================================================
15 * History: 15 * History:
16 * $Log$ 16 * $Log$
17 * Revision 1.1 2004/11/16 21:46:08 mickeyl
18 * libopie1 goes into unsupported
19 *
17 * Revision 1.4 2004/03/14 13:50:35 alwin 20 * Revision 1.4 2004/03/14 13:50:35 alwin
18 * namespace correction 21 * namespace correction
19 * 22 *
20 * Revision 1.3 2003/12/22 11:41:39 eilers 23 * Revision 1.3 2003/12/22 11:41:39 eilers
21 * Fixing stupid bug, found by sourcode review.. 24 * Fixing stupid bug, found by sourcode review..
22 * 25 *
23 * Revision 1.2 2003/12/22 10:19:26 eilers 26 * Revision 1.2 2003/12/22 10:19:26 eilers
24 * Finishing implementation of sql-backend for datebook. But I have to 27 * Finishing implementation of sql-backend for datebook. But I have to
25 * port the PIM datebook application to use it, before I could debug the 28 * port the PIM datebook application to use it, before I could debug the
26 * whole stuff. 29 * whole stuff.
27 * Thus, PIM-Database backend is finished, but highly experimental. And some 30 * Thus, PIM-Database backend is finished, but highly experimental. And some
28 * parts are still generic. For instance, the "queryByExample()" methods are 31 * parts are still generic. For instance, the "queryByExample()" methods are
29 * not (or not fully) implemented. Todo: custom-entries not stored. 32 * not (or not fully) implemented. Todo: custom-entries not stored.
30 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular 33 * The big show stopper: matchRegExp() (needed by OpieSearch) needs regular
31 * expression search in the database, which is not supported by sqlite ! 34 * expression search in the database, which is not supported by sqlite !
32 * Therefore we need either an extended sqlite or a workaround which would 35 * Therefore we need either an extended sqlite or a workaround which would
33 * be very slow and memory consuming.. 36 * be very slow and memory consuming..
34 * 37 *
35 * Revision 1.1 2003/12/08 15:18:12 eilers 38 * Revision 1.1 2003/12/08 15:18:12 eilers
36 * Committing unfinished sql implementation before merging to libopie2 starts.. 39 * Committing unfinished sql implementation before merging to libopie2 starts..
37 * 40 *
38 * 41 *
39 */ 42 */
40 43
41#include <stdio.h> 44#include <stdio.h>
42#include <stdlib.h> 45#include <stdlib.h>
43 46
44#include <qarray.h> 47#include <qarray.h>
45#include <qstringlist.h> 48#include <qstringlist.h>
46 49
47#include <qpe/global.h> 50#include <qpe/global.h>
48 51
49#include <opie2/osqldriver.h> 52#include <opie2/osqldriver.h>
50#include <opie2/osqlmanager.h> 53#include <opie2/osqlmanager.h>
51#include <opie2/osqlquery.h> 54#include <opie2/osqlquery.h>
52 55
53#include "orecur.h" 56#include "orecur.h"
54#include "odatebookaccessbackend_sql.h" 57#include "odatebookaccessbackend_sql.h"
55 58
56using namespace Opie::DB; 59using namespace Opie::DB;
57 60
58 61
59ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& , 62ODateBookAccessBackend_SQL::ODateBookAccessBackend_SQL( const QString& ,
60 const QString& fileName ) 63 const QString& fileName )
61 : ODateBookAccessBackend(), m_driver( NULL ) 64 : ODateBookAccessBackend(), m_driver( NULL )
62{ 65{
63 m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName; 66 m_fileName = fileName.isEmpty() ? Global::applicationFileName( "datebook", "datebook.db" ) : fileName;
64 67
65 // Get the standart sql-driver from the OSQLManager.. 68 // Get the standart sql-driver from the OSQLManager..
66 OSQLManager man; 69 OSQLManager man;
67 m_driver = man.standard(); 70 m_driver = man.standard();
68 m_driver->setUrl( m_fileName ); 71 m_driver->setUrl( m_fileName );
69 72
70 initFields(); 73 initFields();
71 74
72 load(); 75 load();
73} 76}
74 77
75ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() { 78ODateBookAccessBackend_SQL::~ODateBookAccessBackend_SQL() {
76 if( m_driver ) 79 if( m_driver )
77 delete m_driver; 80 delete m_driver;
78} 81}
79 82
80void ODateBookAccessBackend_SQL::initFields() 83void ODateBookAccessBackend_SQL::initFields()
81{ 84{
82 85
83 // This map contains the translation of the fieldtype id's to 86 // This map contains the translation of the fieldtype id's to
84 // the names of the table columns 87 // the names of the table columns
85 m_fieldMap.insert( OEvent::FUid, "uid" ); 88 m_fieldMap.insert( OEvent::FUid, "uid" );
86 m_fieldMap.insert( OEvent::FCategories, "Categories" ); 89 m_fieldMap.insert( OEvent::FCategories, "Categories" );
87 m_fieldMap.insert( OEvent::FDescription, "Description" ); 90 m_fieldMap.insert( OEvent::FDescription, "Description" );
88 m_fieldMap.insert( OEvent::FLocation, "Location" ); 91 m_fieldMap.insert( OEvent::FLocation, "Location" );
89 m_fieldMap.insert( OEvent::FType, "Type" ); 92 m_fieldMap.insert( OEvent::FType, "Type" );
90 m_fieldMap.insert( OEvent::FAlarm, "Alarm" ); 93 m_fieldMap.insert( OEvent::FAlarm, "Alarm" );
91 m_fieldMap.insert( OEvent::FSound, "Sound" ); 94 m_fieldMap.insert( OEvent::FSound, "Sound" );
92 m_fieldMap.insert( OEvent::FRType, "RType" ); 95 m_fieldMap.insert( OEvent::FRType, "RType" );
93 m_fieldMap.insert( OEvent::FRWeekdays, "RWeekdays" ); 96 m_fieldMap.insert( OEvent::FRWeekdays, "RWeekdays" );
94 m_fieldMap.insert( OEvent::FRPosition, "RPosition" ); 97 m_fieldMap.insert( OEvent::FRPosition, "RPosition" );
95 m_fieldMap.insert( OEvent::FRFreq, "RFreq" ); 98 m_fieldMap.insert( OEvent::FRFreq, "RFreq" );
96 m_fieldMap.insert( OEvent::FRHasEndDate, "RHasEndDate" ); 99 m_fieldMap.insert( OEvent::FRHasEndDate, "RHasEndDate" );
97 m_fieldMap.insert( OEvent::FREndDate, "REndDate" ); 100 m_fieldMap.insert( OEvent::FREndDate, "REndDate" );
98 m_fieldMap.insert( OEvent::FRCreated, "RCreated" ); 101 m_fieldMap.insert( OEvent::FRCreated, "RCreated" );
99 m_fieldMap.insert( OEvent::FRExceptions, "RExceptions" ); 102 m_fieldMap.insert( OEvent::FRExceptions, "RExceptions" );
100 m_fieldMap.insert( OEvent::FStart, "Start" ); 103 m_fieldMap.insert( OEvent::FStart, "Start" );
101 m_fieldMap.insert( OEvent::FEnd, "End" ); 104 m_fieldMap.insert( OEvent::FEnd, "End" );
102 m_fieldMap.insert( OEvent::FNote, "Note" ); 105 m_fieldMap.insert( OEvent::FNote, "Note" );
103 m_fieldMap.insert( OEvent::FTimeZone, "TimeZone" ); 106 m_fieldMap.insert( OEvent::FTimeZone, "TimeZone" );
104 m_fieldMap.insert( OEvent::FRecParent, "RecParent" ); 107 m_fieldMap.insert( OEvent::FRecParent, "RecParent" );
105 m_fieldMap.insert( OEvent::FRecChildren, "Recchildren" ); 108 m_fieldMap.insert( OEvent::FRecChildren, "Recchildren" );
106 109
107 // Create a map that maps the column name to the id 110 // Create a map that maps the column name to the id
108 QMapConstIterator<int, QString> it; 111 QMapConstIterator<int, QString> it;
109 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 112 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
110 m_reverseFieldMap.insert( it.data(), it.key() ); 113 m_reverseFieldMap.insert( it.data(), it.key() );
111 } 114 }
112 115
113} 116}
114 117
115bool ODateBookAccessBackend_SQL::load() 118bool ODateBookAccessBackend_SQL::load()
116{ 119{
117 if (!m_driver->open() ) 120 if (!m_driver->open() )
118 return false; 121 return false;
119 122
120 // Don't expect that the database exists. 123 // Don't expect that the database exists.
121 // It is save here to create the table, even if it 124 // It is save here to create the table, even if it
122 // do exist. ( Is that correct for all databases ?? ) 125 // do exist. ( Is that correct for all databases ?? )
123 QStringqu = "create table datebook( uid INTEGER PRIMARY KEY "; 126 QStringqu = "create table datebook( uid INTEGER PRIMARY KEY ";
124 127
125 QMap<int, QString>::Iterator it; 128 QMap<int, QString>::Iterator it;
126 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 129 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
127 qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() ); 130 qu += QString( ",%1 VARCHAR(10)" ).arg( it.data() );
128 } 131 }
129 qu += " );"; 132 qu += " );";
130 133
131 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );"; 134 qu += "create table custom_data( uid INTEGER, id INTEGER, type VARCHAR, priority INTEGER, value VARCHAR, PRIMARY KEY /* identifier */ (uid, id) );";
132 135
133 qWarning( "command: %s", qu.latin1() ); 136 qWarning( "command: %s", qu.latin1() );
134 137
135 OSQLRawQuery raw( qu ); 138 OSQLRawQuery raw( qu );
136 OSQLResult res = m_driver->query( &raw ); 139 OSQLResult res = m_driver->query( &raw );
137 if ( res.state() != OSQLResult::Success ) 140 if ( res.state() != OSQLResult::Success )
138 return false; 141 return false;
139 142
140 update(); 143 update();
141 144
142 return true; 145 return true;
143} 146}
144 147
145void ODateBookAccessBackend_SQL::update() 148void ODateBookAccessBackend_SQL::update()
146{ 149{
147 150
148 QString qu = "select uid from datebook"; 151 QString qu = "select uid from datebook";
149 OSQLRawQuery raw( qu ); 152 OSQLRawQuery raw( qu );
150 OSQLResult res = m_driver->query( &raw ); 153 OSQLResult res = m_driver->query( &raw );
151 if ( res.state() != OSQLResult::Success ){ 154 if ( res.state() != OSQLResult::Success ){
152 // m_uids.clear(); 155 // m_uids.clear();
153 return; 156 return;
154 } 157 }
155 158
156 m_uids = extractUids( res ); 159 m_uids = extractUids( res );
157 160
158} 161}
159 162
160bool ODateBookAccessBackend_SQL::reload() 163bool ODateBookAccessBackend_SQL::reload()
161{ 164{
162 return load(); 165 return load();
163} 166}
164 167
165bool ODateBookAccessBackend_SQL::save() 168bool ODateBookAccessBackend_SQL::save()
166{ 169{
167 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers) 170 return m_driver->close(); // Shouldn't m_driver->sync be better than close ? (eilers)
168} 171}
169 172
170QArray<int> ODateBookAccessBackend_SQL::allRecords()const 173QArray<int> ODateBookAccessBackend_SQL::allRecords()const
171{ 174{
172 return m_uids; 175 return m_uids;
173} 176}
174 177
175QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OEvent&, int, const QDateTime& ) { 178QArray<int> ODateBookAccessBackend_SQL::queryByExample(const OEvent&, int, const QDateTime& ) {
176 return QArray<int>(); 179 return QArray<int>();
177} 180}
178 181
179void ODateBookAccessBackend_SQL::clear() 182void ODateBookAccessBackend_SQL::clear()
180{ 183{
181 QString qu = "drop table datebook;"; 184 QString qu = "drop table datebook;";
182 qu += "drop table custom_data;"; 185 qu += "drop table custom_data;";
183 186
184 OSQLRawQuery raw( qu ); 187 OSQLRawQuery raw( qu );
185 OSQLResult res = m_driver->query( &raw ); 188 OSQLResult res = m_driver->query( &raw );
186 189
187 reload(); 190 reload();
188} 191}
189 192
190 193
191OEvent ODateBookAccessBackend_SQL::find( int uid ) const{ 194OEvent ODateBookAccessBackend_SQL::find( int uid ) const{
192 QString qu = "select *"; 195 QString qu = "select *";
193 qu += "from datebook where uid = " + QString::number(uid); 196 qu += "from datebook where uid = " + QString::number(uid);
194 197
195 OSQLRawQuery raw( qu ); 198 OSQLRawQuery raw( qu );
196 OSQLResult res = m_driver->query( &raw ); 199 OSQLResult res = m_driver->query( &raw );
197 200
198 OSQLResultItem resItem = res.first(); 201 OSQLResultItem resItem = res.first();
199 202
200 // Create Map for date event and insert UID 203 // Create Map for date event and insert UID
201 QMap<int,QString> dateEventMap; 204 QMap<int,QString> dateEventMap;
202 dateEventMap.insert( OEvent::FUid, QString::number( uid ) ); 205 dateEventMap.insert( OEvent::FUid, QString::number( uid ) );
203 206
204 // Now insert the data out of the columns into the map. 207 // Now insert the data out of the columns into the map.
205 QMapConstIterator<int, QString> it; 208 QMapConstIterator<int, QString> it;
206 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 209 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
207 dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) ); 210 dateEventMap.insert( m_reverseFieldMap[*it], resItem.data( *it ) );
208 } 211 }
209 212
210 // Last step: Put map into date event and return it 213 // Last step: Put map into date event and return it
211 OEvent retDate( dateEventMap ); 214 OEvent retDate( dateEventMap );
212 215
213 return retDate; 216 return retDate;
214} 217}
215 218
216// FIXME: Speed up update of uid's.. 219// FIXME: Speed up update of uid's..
217bool ODateBookAccessBackend_SQL::add( const OEvent& ev ) 220bool ODateBookAccessBackend_SQL::add( const OEvent& ev )
218{ 221{
219 QMap<int,QString> eventMap = ev.toMap(); 222 QMap<int,QString> eventMap = ev.toMap();
220 223
221 QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() ); 224 QString qu = "insert into datebook VALUES( " + QString::number( ev.uid() );
222 QMap<int, QString>::Iterator it; 225 QMap<int, QString>::Iterator it;
223 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){ 226 for ( it = ++m_fieldMap.begin(); it != m_fieldMap.end(); ++it ){
224 if ( !eventMap[it.key()].isEmpty() ) 227 if ( !eventMap[it.key()].isEmpty() )
225 qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] ); 228 qu += QString( ",\"%1\"" ).arg( eventMap[it.key()] );
226 else 229 else
227 qu += QString( ",\"\"" ); 230 qu += QString( ",\"\"" );
228 } 231 }
229 qu += " );"; 232 qu += " );";
230 233
231 // Add custom entries 234 // Add custom entries
232 int id = 0; 235 int id = 0;
233 QMap<QString, QString> customMap = ev.toExtraMap(); 236 QMap<QString, QString> customMap = ev.toExtraMap();
234 for( QMap<QString, QString>::Iterator it = customMap.begin(); 237 for( QMap<QString, QString>::Iterator it = customMap.begin();
235 it != customMap.end(); ++it ){ 238 it != customMap.end(); ++it ){
236 qu += "insert into custom_data VALUES(" 239 qu += "insert into custom_data VALUES("
237 + QString::number( ev.uid() ) 240 + QString::number( ev.uid() )
238 + "," 241 + ","
239 + QString::number( id++ ) 242 + QString::number( id++ )
240 + ",'" 243 + ",'"
241 + it.key() //.latin1() 244 + it.key() //.latin1()
242 + "'," 245 + "',"
243 + "0" // Priority for future enhancements 246 + "0" // Priority for future enhancements
244 + ",'" 247 + ",'"
245 + it.data() //.latin1() 248 + it.data() //.latin1()
246 + "');"; 249 + "');";
247 } 250 }
248 qWarning("add %s", qu.latin1() ); 251 qWarning("add %s", qu.latin1() );
249 252
250 OSQLRawQuery raw( qu ); 253 OSQLRawQuery raw( qu );
251 OSQLResult res = m_driver->query( &raw ); 254 OSQLResult res = m_driver->query( &raw );
252 if ( res.state() != OSQLResult::Success ){ 255 if ( res.state() != OSQLResult::Success ){
253 return false; 256 return false;
254 } 257 }
255 258
256 // Update list of uid's 259 // Update list of uid's
257 update(); 260 update();
258 261
259 return true; 262 return true;
260} 263}
261 264
262// FIXME: Speed up update of uid's.. 265// FIXME: Speed up update of uid's..
263bool ODateBookAccessBackend_SQL::remove( int uid ) 266bool ODateBookAccessBackend_SQL::remove( int uid )
264{ 267{
265 QString qu = "DELETE from datebook where uid = " 268 QString qu = "DELETE from datebook where uid = "
266 + QString::number( uid ) + ";"; 269 + QString::number( uid ) + ";";
267 qu += "DELETE from custom_data where uid = " 270 qu += "DELETE from custom_data where uid = "
268 + QString::number( uid ) + ";"; 271 + QString::number( uid ) + ";";
269 272
270 OSQLRawQuery raw( qu ); 273 OSQLRawQuery raw( qu );
271 OSQLResult res = m_driver->query( &raw ); 274 OSQLResult res = m_driver->query( &raw );
272 if ( res.state() != OSQLResult::Success ){ 275 if ( res.state() != OSQLResult::Success ){
273 return false; 276 return false;
274 } 277 }
275 278
276 // Update list of uid's 279 // Update list of uid's
277 update(); 280 update();
278 281
279 return true; 282 return true;
280} 283}
281 284
282bool ODateBookAccessBackend_SQL::replace( const OEvent& ev ) 285bool ODateBookAccessBackend_SQL::replace( const OEvent& ev )
283{ 286{
284 remove( ev.uid() ); 287 remove( ev.uid() );
285 return add( ev ); 288 return add( ev );
286} 289}
287 290
288QArray<int> ODateBookAccessBackend_SQL::rawEvents()const 291QArray<int> ODateBookAccessBackend_SQL::rawEvents()const
289{ 292{
290 return allRecords(); 293 return allRecords();
291} 294}
292 295
293QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const 296QArray<int> ODateBookAccessBackend_SQL::rawRepeats()const
294{ 297{
295 QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\""; 298 QString qu = "select uid from datebook where RType!=\"\" AND RType!=\"NoRepeat\"";
296 OSQLRawQuery raw( qu ); 299 OSQLRawQuery raw( qu );
297 OSQLResult res = m_driver->query( &raw ); 300 OSQLResult res = m_driver->query( &raw );
298 if ( res.state() != OSQLResult::Success ){ 301 if ( res.state() != OSQLResult::Success ){
299 QArray<int> nix; 302 QArray<int> nix;
300 return nix; 303 return nix;
301 } 304 }
302 305
303 return extractUids( res ); 306 return extractUids( res );
304} 307}
305 308
306QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const 309QArray<int> ODateBookAccessBackend_SQL::nonRepeats()const
307{ 310{
308 QString qu = "select uid from datebook where RType=\"\" or RType=\"NoRepeat\""; 311 QString qu = "select uid from datebook where RType=\"\" or RType=\"NoRepeat\"";
309 OSQLRawQuery raw( qu ); 312 OSQLRawQuery raw( qu );
310 OSQLResult res = m_driver->query( &raw ); 313 OSQLResult res = m_driver->query( &raw );
311 if ( res.state() != OSQLResult::Success ){ 314 if ( res.state() != OSQLResult::Success ){
312 QArray<int> nix; 315 QArray<int> nix;
313 return nix; 316 return nix;
314 } 317 }
315 318
316 return extractUids( res ); 319 return extractUids( res );
317} 320}
318 321
319OEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats() 322OEvent::ValueList ODateBookAccessBackend_SQL::directNonRepeats()
320{ 323{
321 QArray<int> nonRepUids = nonRepeats(); 324 QArray<int> nonRepUids = nonRepeats();
322 OEvent::ValueList list; 325 OEvent::ValueList list;
323 326
324 for (uint i = 0; i < nonRepUids.count(); ++i ){ 327 for (uint i = 0; i < nonRepUids.count(); ++i ){
325 list.append( find( nonRepUids[i] ) ); 328 list.append( find( nonRepUids[i] ) );
326 } 329 }
327 330
328 return list; 331 return list;
329 332
330} 333}
331OEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats() 334OEvent::ValueList ODateBookAccessBackend_SQL::directRawRepeats()
332{ 335{
333 QArray<int> rawRepUids = rawRepeats(); 336 QArray<int> rawRepUids = rawRepeats();
334 OEvent::ValueList list; 337 OEvent::ValueList list;
335 338
336 for (uint i = 0; i < rawRepUids.count(); ++i ){ 339 for (uint i = 0; i < rawRepUids.count(); ++i ){
337 list.append( find( rawRepUids[i] ) ); 340 list.append( find( rawRepUids[i] ) );
338 } 341 }
339 342
340 return list; 343 return list;
341} 344}
342 345
343 346
344QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const 347QArray<int> ODateBookAccessBackend_SQL::matchRegexp( const QRegExp &r ) const
345{ 348{
346 QArray<int> null; 349 QArray<int> null;
347 return null; 350 return null;
348} 351}
349 352
350/* ===== Private Functions ========================================== */ 353/* ===== Private Functions ========================================== */
351 354
352QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const 355QArray<int> ODateBookAccessBackend_SQL::extractUids( OSQLResult& res ) const
353{ 356{
354 qWarning("extractUids"); 357 qWarning("extractUids");
355 QTime t; 358 QTime t;
356 t.start(); 359 t.start();
357 OSQLResultItem::ValueList list = res.results(); 360 OSQLResultItem::ValueList list = res.results();
358 OSQLResultItem::ValueList::Iterator it; 361 OSQLResultItem::ValueList::Iterator it;
359 QArray<int> ints(list.count() ); 362 QArray<int> ints(list.count() );
360 qWarning(" count = %d", list.count() ); 363 qWarning(" count = %d", list.count() );
361 364
362 int i = 0; 365 int i = 0;
363 for (it = list.begin(); it != list.end(); ++it ) { 366 for (it = list.begin(); it != list.end(); ++it ) {
364 ints[i] = (*it).data("uid").toInt(); 367 ints[i] = (*it).data("uid").toInt();
365 i++; 368 i++;
366 } 369 }
367 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() ); 370 qWarning("extractUids ready: count2 = %d needs %d ms", i, t.elapsed() );
368 371
369 return ints; 372 return ints;
370 373
371} 374}
diff --git a/libopie/pim/odatebookaccessbackend_sql.h b/noncore/unsupported/libopie/pim/odatebookaccessbackend_sql.h
index ba514bc..ba514bc 100644
--- a/libopie/pim/odatebookaccessbackend_sql.h
+++ b/noncore/unsupported/libopie/pim/odatebookaccessbackend_sql.h
diff --git a/libopie/pim/odatebookaccessbackend_xml.cpp b/noncore/unsupported/libopie/pim/odatebookaccessbackend_xml.cpp
index 929d004..929d004 100644
--- a/libopie/pim/odatebookaccessbackend_xml.cpp
+++ b/noncore/unsupported/libopie/pim/odatebookaccessbackend_xml.cpp
diff --git a/libopie/pim/odatebookaccessbackend_xml.h b/noncore/unsupported/libopie/pim/odatebookaccessbackend_xml.h
index a5cc0fc..a5cc0fc 100644
--- a/libopie/pim/odatebookaccessbackend_xml.h
+++ b/noncore/unsupported/libopie/pim/odatebookaccessbackend_xml.h
diff --git a/libopie/pim/oevent.cpp b/noncore/unsupported/libopie/pim/oevent.cpp
index 9b31957..9b31957 100644
--- a/libopie/pim/oevent.cpp
+++ b/noncore/unsupported/libopie/pim/oevent.cpp
diff --git a/libopie/pim/oevent.h b/noncore/unsupported/libopie/pim/oevent.h
index 9eb948f..9eb948f 100644
--- a/libopie/pim/oevent.h
+++ b/noncore/unsupported/libopie/pim/oevent.h
diff --git a/libopie/pim/opimaccessbackend.h b/noncore/unsupported/libopie/pim/opimaccessbackend.h
index fd264fc..fd264fc 100644
--- a/libopie/pim/opimaccessbackend.h
+++ b/noncore/unsupported/libopie/pim/opimaccessbackend.h
diff --git a/libopie/pim/opimaccesstemplate.h b/noncore/unsupported/libopie/pim/opimaccesstemplate.h
index ecbeb68..ecbeb68 100644
--- a/libopie/pim/opimaccesstemplate.h
+++ b/noncore/unsupported/libopie/pim/opimaccesstemplate.h
diff --git a/libopie/pim/opimcache.h b/noncore/unsupported/libopie/pim/opimcache.h
index 7f7cff5..7f7cff5 100644
--- a/libopie/pim/opimcache.h
+++ b/noncore/unsupported/libopie/pim/opimcache.h
diff --git a/libopie/pim/opimmaintainer.cpp b/noncore/unsupported/libopie/pim/opimmaintainer.cpp
index 92cb25a..92cb25a 100644
--- a/libopie/pim/opimmaintainer.cpp
+++ b/noncore/unsupported/libopie/pim/opimmaintainer.cpp
diff --git a/libopie/pim/opimmaintainer.h b/noncore/unsupported/libopie/pim/opimmaintainer.h
index 793d066..793d066 100644
--- a/libopie/pim/opimmaintainer.h
+++ b/noncore/unsupported/libopie/pim/opimmaintainer.h
diff --git a/libopie/pim/opimmainwindow.cpp b/noncore/unsupported/libopie/pim/opimmainwindow.cpp
index 99a0333..99a0333 100644
--- a/libopie/pim/opimmainwindow.cpp
+++ b/noncore/unsupported/libopie/pim/opimmainwindow.cpp
diff --git a/libopie/pim/opimmainwindow.h b/noncore/unsupported/libopie/pim/opimmainwindow.h
index 855d364..855d364 100644
--- a/libopie/pim/opimmainwindow.h
+++ b/noncore/unsupported/libopie/pim/opimmainwindow.h
diff --git a/libopie/pim/opimnotify.cpp b/noncore/unsupported/libopie/pim/opimnotify.cpp
index af5514b..af5514b 100644
--- a/libopie/pim/opimnotify.cpp
+++ b/noncore/unsupported/libopie/pim/opimnotify.cpp
diff --git a/libopie/pim/opimnotify.h b/noncore/unsupported/libopie/pim/opimnotify.h
index 58417db..58417db 100644
--- a/libopie/pim/opimnotify.h
+++ b/noncore/unsupported/libopie/pim/opimnotify.h
diff --git a/libopie/pim/opimnotifymanager.cpp b/noncore/unsupported/libopie/pim/opimnotifymanager.cpp
index d6f0ead..d6f0ead 100644
--- a/libopie/pim/opimnotifymanager.cpp
+++ b/noncore/unsupported/libopie/pim/opimnotifymanager.cpp
diff --git a/libopie/pim/opimnotifymanager.h b/noncore/unsupported/libopie/pim/opimnotifymanager.h
index f3c22f9..f3c22f9 100644
--- a/libopie/pim/opimnotifymanager.h
+++ b/noncore/unsupported/libopie/pim/opimnotifymanager.h
diff --git a/libopie/pim/opimrecord.cpp b/noncore/unsupported/libopie/pim/opimrecord.cpp
index 2365748..2365748 100644
--- a/libopie/pim/opimrecord.cpp
+++ b/noncore/unsupported/libopie/pim/opimrecord.cpp
diff --git a/libopie/pim/opimrecord.h b/noncore/unsupported/libopie/pim/opimrecord.h
index 3d774e2..3d774e2 100644
--- a/libopie/pim/opimrecord.h
+++ b/noncore/unsupported/libopie/pim/opimrecord.h
diff --git a/libopie/pim/opimresolver.cpp b/noncore/unsupported/libopie/pim/opimresolver.cpp
index 4ebbd6e..4ebbd6e 100644
--- a/libopie/pim/opimresolver.cpp
+++ b/noncore/unsupported/libopie/pim/opimresolver.cpp
diff --git a/libopie/pim/opimresolver.h b/noncore/unsupported/libopie/pim/opimresolver.h
index 1ce1619..1ce1619 100644
--- a/libopie/pim/opimresolver.h
+++ b/noncore/unsupported/libopie/pim/opimresolver.h
diff --git a/libopie/pim/opimstate.cpp b/noncore/unsupported/libopie/pim/opimstate.cpp
index 6fb2feb..6fb2feb 100644
--- a/libopie/pim/opimstate.cpp
+++ b/noncore/unsupported/libopie/pim/opimstate.cpp
diff --git a/libopie/pim/opimstate.h b/noncore/unsupported/libopie/pim/opimstate.h
index cf6af46..cf6af46 100644
--- a/libopie/pim/opimstate.h
+++ b/noncore/unsupported/libopie/pim/opimstate.h
diff --git a/libopie/pim/opimxref.cpp b/noncore/unsupported/libopie/pim/opimxref.cpp
index 8eefbd8..8eefbd8 100644
--- a/libopie/pim/opimxref.cpp
+++ b/noncore/unsupported/libopie/pim/opimxref.cpp
diff --git a/libopie/pim/opimxref.h b/noncore/unsupported/libopie/pim/opimxref.h
index 6852651..6852651 100644
--- a/libopie/pim/opimxref.h
+++ b/noncore/unsupported/libopie/pim/opimxref.h
diff --git a/libopie/pim/opimxrefmanager.cpp b/noncore/unsupported/libopie/pim/opimxrefmanager.cpp
index 58bfd24..58bfd24 100644
--- a/libopie/pim/opimxrefmanager.cpp
+++ b/noncore/unsupported/libopie/pim/opimxrefmanager.cpp
diff --git a/libopie/pim/opimxrefmanager.h b/noncore/unsupported/libopie/pim/opimxrefmanager.h
index c485e98..c485e98 100644
--- a/libopie/pim/opimxrefmanager.h
+++ b/noncore/unsupported/libopie/pim/opimxrefmanager.h
diff --git a/libopie/pim/opimxrefpartner.cpp b/noncore/unsupported/libopie/pim/opimxrefpartner.cpp
index 6ef3efb..6ef3efb 100644
--- a/libopie/pim/opimxrefpartner.cpp
+++ b/noncore/unsupported/libopie/pim/opimxrefpartner.cpp
diff --git a/libopie/pim/opimxrefpartner.h b/noncore/unsupported/libopie/pim/opimxrefpartner.h
index d76e384..d76e384 100644
--- a/libopie/pim/opimxrefpartner.h
+++ b/noncore/unsupported/libopie/pim/opimxrefpartner.h
diff --git a/libopie/pim/orecordlist.h b/noncore/unsupported/libopie/pim/orecordlist.h
index 5211f57..5211f57 100644
--- a/libopie/pim/orecordlist.h
+++ b/noncore/unsupported/libopie/pim/orecordlist.h
diff --git a/libopie/pim/orecur.cpp b/noncore/unsupported/libopie/pim/orecur.cpp
index f46f22e..f46f22e 100644
--- a/libopie/pim/orecur.cpp
+++ b/noncore/unsupported/libopie/pim/orecur.cpp
diff --git a/libopie/pim/orecur.h b/noncore/unsupported/libopie/pim/orecur.h
index d7ecd90..d7ecd90 100644
--- a/libopie/pim/orecur.h
+++ b/noncore/unsupported/libopie/pim/orecur.h
diff --git a/libopie/pim/otemplatebase.h b/noncore/unsupported/libopie/pim/otemplatebase.h
index cadac74..cadac74 100644
--- a/libopie/pim/otemplatebase.h
+++ b/noncore/unsupported/libopie/pim/otemplatebase.h
diff --git a/libopie/pim/otimezone.cpp b/noncore/unsupported/libopie/pim/otimezone.cpp
index 34659c3..34659c3 100644
--- a/libopie/pim/otimezone.cpp
+++ b/noncore/unsupported/libopie/pim/otimezone.cpp
diff --git a/libopie/pim/otimezone.h b/noncore/unsupported/libopie/pim/otimezone.h
index bb08349..bb08349 100644
--- a/libopie/pim/otimezone.h
+++ b/noncore/unsupported/libopie/pim/otimezone.h
diff --git a/libopie/pim/otodo.cpp b/noncore/unsupported/libopie/pim/otodo.cpp
index b2c76f8..b2c76f8 100644
--- a/libopie/pim/otodo.cpp
+++ b/noncore/unsupported/libopie/pim/otodo.cpp
diff --git a/libopie/pim/otodo.h b/noncore/unsupported/libopie/pim/otodo.h
index 6df98b9..6df98b9 100644
--- a/libopie/pim/otodo.h
+++ b/noncore/unsupported/libopie/pim/otodo.h
diff --git a/libopie/pim/otodoaccess.cpp b/noncore/unsupported/libopie/pim/otodoaccess.cpp
index 37f6fbc..37f6fbc 100644
--- a/libopie/pim/otodoaccess.cpp
+++ b/noncore/unsupported/libopie/pim/otodoaccess.cpp
diff --git a/libopie/pim/otodoaccess.h b/noncore/unsupported/libopie/pim/otodoaccess.h
index 916923f..916923f 100644
--- a/libopie/pim/otodoaccess.h
+++ b/noncore/unsupported/libopie/pim/otodoaccess.h
diff --git a/libopie/pim/otodoaccessbackend.cpp b/noncore/unsupported/libopie/pim/otodoaccessbackend.cpp
index baaeecc..baaeecc 100644
--- a/libopie/pim/otodoaccessbackend.cpp
+++ b/noncore/unsupported/libopie/pim/otodoaccessbackend.cpp
diff --git a/libopie/pim/otodoaccessbackend.h b/noncore/unsupported/libopie/pim/otodoaccessbackend.h
index 6be95bc..6be95bc 100644
--- a/libopie/pim/otodoaccessbackend.h
+++ b/noncore/unsupported/libopie/pim/otodoaccessbackend.h
diff --git a/libopie/pim/otodoaccesssql.cpp b/noncore/unsupported/libopie/pim/otodoaccesssql.cpp
index fd01a42..fd01a42 100644
--- a/libopie/pim/otodoaccesssql.cpp
+++ b/noncore/unsupported/libopie/pim/otodoaccesssql.cpp
diff --git a/libopie/pim/otodoaccesssql.h b/noncore/unsupported/libopie/pim/otodoaccesssql.h
index 72214de..72214de 100644
--- a/libopie/pim/otodoaccesssql.h
+++ b/noncore/unsupported/libopie/pim/otodoaccesssql.h
diff --git a/libopie/pim/otodoaccessvcal.cpp b/noncore/unsupported/libopie/pim/otodoaccessvcal.cpp
index 6415952..6415952 100644
--- a/libopie/pim/otodoaccessvcal.cpp
+++ b/noncore/unsupported/libopie/pim/otodoaccessvcal.cpp
diff --git a/libopie/pim/otodoaccessvcal.h b/noncore/unsupported/libopie/pim/otodoaccessvcal.h
index 2b17147..2b17147 100644
--- a/libopie/pim/otodoaccessvcal.h
+++ b/noncore/unsupported/libopie/pim/otodoaccessvcal.h
diff --git a/libopie/pim/otodoaccessxml.cpp b/noncore/unsupported/libopie/pim/otodoaccessxml.cpp
index 4a5cb33..4a5cb33 100644
--- a/libopie/pim/otodoaccessxml.cpp
+++ b/noncore/unsupported/libopie/pim/otodoaccessxml.cpp
diff --git a/libopie/pim/otodoaccessxml.h b/noncore/unsupported/libopie/pim/otodoaccessxml.h
index e4850a1..e4850a1 100644
--- a/libopie/pim/otodoaccessxml.h
+++ b/noncore/unsupported/libopie/pim/otodoaccessxml.h
diff --git a/libopie/sharp_compat.cpp b/noncore/unsupported/libopie/sharp_compat.cpp
index 1d16a09..1d16a09 100644
--- a/libopie/sharp_compat.cpp
+++ b/noncore/unsupported/libopie/sharp_compat.cpp
diff --git a/libopie/todayconfigwidget.h b/noncore/unsupported/libopie/todayconfigwidget.h
index f3501a1..f3501a1 100644
--- a/libopie/todayconfigwidget.h
+++ b/noncore/unsupported/libopie/todayconfigwidget.h
diff --git a/libopie/todayplugininterface.h b/noncore/unsupported/libopie/todayplugininterface.h
index 5dfeaa8..5dfeaa8 100644
--- a/libopie/todayplugininterface.h
+++ b/noncore/unsupported/libopie/todayplugininterface.h
diff --git a/libopie/xmltree.cc b/noncore/unsupported/libopie/xmltree.cc
index 27db5b3..27db5b3 100644
--- a/libopie/xmltree.cc
+++ b/noncore/unsupported/libopie/xmltree.cc
diff --git a/libopie/xmltree.h b/noncore/unsupported/libopie/xmltree.h
index 4b6bdfa..4b6bdfa 100644
--- a/libopie/xmltree.h
+++ b/noncore/unsupported/libopie/xmltree.h