summaryrefslogtreecommitdiff
path: root/noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h
Unidiff
Diffstat (limited to 'noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h110
1 files changed, 110 insertions, 0 deletions
diff --git a/noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h b/noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h
new file mode 100644
index 0000000..8cd92e8
--- a/dev/null
+++ b/noncore/unsupported/libopie/pim/ocontactaccessbackend_sql.h
@@ -0,0 +1,110 @@
1/*
2 * SQL Backend for the OPIE-Contact Database.
3 *
4 * Copyright (c) 2002 by Stefan Eilers (Eilers.Stefan@epost.de)
5 *
6 * =====================================================================
7 *This program is free software; you can redistribute it and/or
8 *modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 * =====================================================================
12 *
13 *
14 * =====================================================================
15 * Version: $Id$
16 * =====================================================================
17 * History:
18 * $Log$
19 * Revision 1.1 2004/11/16 21:46:07 mickeyl
20 * libopie1 goes into unsupported
21 *
22 * Revision 1.3 2004/03/14 13:50:35 alwin
23 * namespace correction
24 *
25 * Revision 1.2 2003/12/08 15:18:11 eilers
26 * Committing unfinished sql implementation before merging to libopie2 starts..
27 *
28 * Revision 1.1 2003/09/22 14:31:16 eilers
29 * Added first experimental incarnation of sql-backend for addressbook.
30 * Some modifications to be able to compile the todo sql-backend.
31 * A lot of changes fill follow...
32 *
33 *
34 */
35
36#ifndef _OContactAccessBackend_SQL_
37#define _OContactAccessBackend_SQL_
38
39#include "ocontactaccessbackend.h"
40#include "ocontactaccess.h"
41
42#include <qlist.h>
43#include <qdict.h>
44
45namespace Opie { namespace DB {
46class OSQLDriver;
47class OSQLResult;
48class OSQLResultItem;
49
50}}
51
52/* the default xml implementation */
53/**
54 * This class is the SQL implementation of a Contact backend
55 * it does implement everything available for OContact.
56 * @see OPimAccessBackend for more information of available methods
57 */
58class OContactAccessBackend_SQL : public OContactAccessBackend {
59 public:
60 OContactAccessBackend_SQL ( const QString& appname, const QString& filename = QString::null );
61
62 ~OContactAccessBackend_SQL ();
63
64 bool save();
65
66 bool load ();
67
68 void clear ();
69
70 bool wasChangedExternally();
71
72 QArray<int> allRecords() const;
73
74 OContact find ( int uid ) const;
75 // FIXME: Add lookahead-cache support !
76 //OContact find(int uid, const QArray<int>&, uint cur, Frontend::CacheDirection )const;
77
78 QArray<int> queryByExample ( const OContact &query, int settings,
79 const QDateTime& d );
80
81 QArray<int> matchRegexp( const QRegExp &r ) const;
82
83 const uint querySettings();
84
85 bool hasQuerySettings (uint querySettings) const;
86
87 // Currently only asc implemented..
88 QArray<int> sorted( bool asc, int , int , int );
89 bool add ( const OContact &newcontact );
90
91 bool replace ( const OContact &contact );
92
93 bool remove ( int uid );
94 bool reload();
95
96 private:
97 QArray<int> extractUids( Opie::DB::OSQLResult& res ) const;
98 QMap<int, QString> requestNonCustom( int uid ) const;
99 QMap<QString, QString> requestCustom( int uid ) const;
100 void update();
101
102 protected:
103 bool m_changed;
104 QString m_fileName;
105 QArray<int> m_uids;
106
107 Opie::DB::OSQLDriver* m_driver;
108};
109
110#endif