summaryrefslogtreecommitdiffabout
path: root/kabc/resource.h
authorzautrix <zautrix>2004-06-26 19:01:18 (UTC)
committer zautrix <zautrix>2004-06-26 19:01:18 (UTC)
commitb9aad1f15dc600e4dbe4c62d3fcced6363188ba3 (patch) (unidiff)
tree2c3d4004fb21c72cba65793859f9bcd8ffd3a49c /kabc/resource.h
downloadkdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.zip
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.gz
kdepimpi-b9aad1f15dc600e4dbe4c62d3fcced6363188ba3.tar.bz2
Initial revision
Diffstat (limited to 'kabc/resource.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/resource.h134
1 files changed, 134 insertions, 0 deletions
diff --git a/kabc/resource.h b/kabc/resource.h
new file mode 100644
index 0000000..c363125
--- a/dev/null
+++ b/kabc/resource.h
@@ -0,0 +1,134 @@
1/*
2 This file is part of libkabc.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/*
22Enhanced Version of the file for platform independent KDE tools.
23Copyright (c) 2004 Ulf Schenk
24
25$Id$
26*/
27
28#ifndef KABC_RESOURCE_H
29#define KABC_RESOURCE_H
30
31#include <kresources/resource.h>
32
33#include "addressbook.h"
34
35namespace KABC {
36
37/**
38 * @short Helper class for handling coordinated save of address books.
39 *
40 * This class is used as helper class for saving address book.
41 * @see requestSaveTicket(), save().
42 */
43class Ticket
44{
45 friend class Resource;
46 public:
47 Resource *resource() { return mResource; }
48
49 private:
50 Ticket( Resource *resource ) : mResource( resource ) {}
51
52 Resource *mResource;
53};
54
55/**
56 * @internal
57 */
58class Resource : public KRES::Resource
59{
60public:
61 /**
62 * Constructor
63 */
64 Resource( const KConfig *config );
65
66 /**
67 * Destructor.
68 */
69 virtual ~Resource();
70
71 /**
72 * Sets the address book of the resource.
73 */
74 void setAddressBook( AddressBook* );
75
76 /**
77 * Returns a pointer to the addressbook.
78 */
79 AddressBook *addressBook();
80
81 /**
82 * Writes the resource specific config to file.
83 */
84 virtual void writeConfig( KConfig *config );
85
86 /**
87 * Open the resource and returns if it was successfully
88 */
89 virtual bool doOpen();
90
91 /**
92 * Close the resource and returns if it was successfully
93 */
94 virtual void doClose();
95
96 /**
97 * Request a ticket, you have to pass through @ref save() to
98 * allow locking.
99 */
100 virtual Ticket *requestSaveTicket();
101
102 /**
103 * Load all addressees to the addressbook
104 */
105 virtual bool load();
106
107 /**
108 * Save all addressees to the addressbook.
109 *
110 * @param ticket The ticket you get by @ref requestSaveTicket()
111 */
112 virtual bool save( Ticket *ticket );
113
114 /**
115 * Removes a addressee from resource. This method is mainly
116 * used by record-based resources like LDAP or SQL.
117 */
118 virtual void removeAddressee( const Addressee& addr );
119
120 /**
121 * This method is called by an error handler if the application
122 * crashed
123 */
124 virtual void cleanUp();
125
126protected:
127 Ticket *createTicket( Resource * );
128
129private:
130 AddressBook *mAddressBook;
131};
132
133}
134#endif