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., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19*/
20
21#ifndef KABC_STDADDRESSBOOK_H
22#define KABC_STDADDRESSBOOK_H
23
24#include "addressbook.h"
25
26namespace KABC {
27
28/**
29 Standard KDE address book
30
31 This class provides access to the standard KDE address book shared by all
32 applications.
33
34 It's implemented as a singleton. Use self() to get the address book
35 object. On the first self() call the address book also gets loaded.
36
37 Example:
38
39 \code
40 KABC::AddressBook *ab = KABC::StdAddressBook::self();
41
42 AddressBook::Ticket *ticket = ab->requestSaveTicket();
43
44 if ( ticket ) {
45 KABC::AddressBook::Iterator it;
46 for ( it = ab->begin(); it != ab->end(); ++it ) {
47 kDebug( 5700 ) << "UID=" << ( *it ).uid();
48
49 // do some other stuff
50 }
51
52 KABC::StdAddressBook::save( ticket );
53 }
54 \endcode
55
56 @deprecated Port to libakonadi-kontact. For instance using Akonadi::ContactSearchJob.
57 See http://techbase.kde.org/Development/AkonadiPorting/AddressBook for details.
58*/
59class KABC_DEPRECATED_EXPORT StdAddressBook : public AddressBook
60{
61 public:
62
63 /**
64 Destructor.
65 */
66 ~StdAddressBook();
67
68 /**
69 Returns the standard addressbook object. It also loads all resources of
70 the users standard address book synchronously.
71 */
72 static StdAddressBook *self();
73
74 /**
75 This is the same as above, but with specified behaviour of resource loading.
76
77 @param asynchronous When true, the resources are loaded asynchronous, that
78 means you have the data foremost the addressBookChanged()
79 signal has been emitted. So connect to this signal when
80 using this method!
81 */
82 static StdAddressBook *self( bool asynchronous );
83
84 /**
85 Saves the standard address book to disk.
86
87 @deprecated Use AddressBook::save( Ticket* ) instead
88 */
89 static KABC_DEPRECATED bool save();
90
91 /**
92 Returns the default file name for vcard-based addressbook
93 */
94 static QString fileName();
95
96 /**
97 Returns the default directory name for vcard-based addressbook
98 */
99 static QString directoryName();
100
101 /**
102 Sets the automatic save property of the address book.
103
104 @param state If true, the address book is saved automatically
105 at destruction time, otherwise you have to call
106 AddressBook::save( Ticket* ).
107 */
108 static void setAutomaticSave( bool state );
109
110 /**
111 Closes the address book. Depending on automaticSave() it will
112 save the address book first.
113 */
114 static void close();
115
116 /**
117 Returns whether the address book is saved at destruction time.
118 See also setAutomaticSave().
119 */
120 static bool automaticSave();
121
122 /**
123 Returns the contact, that is associated with the owner of the
124 address book. This contact should be used by other programs
125 to access user specific data.
126 */
127 Addressee whoAmI() const;
128
129 /**
130 Sets the users contact. See whoAmI() for more information.
131
132 @param addr The users contact.
133 */
134 void setWhoAmI( const Addressee &addr );
135
136 protected:
137 StdAddressBook();
138 StdAddressBook( bool asynchronous );
139
140 private:
141 // needed another constructor for delaying Private::init() to right
142 // after the instance creation. Cannot change the other two since they
143 // are protected and might be called by subclasses
144 StdAddressBook( bool asynchronous, bool doInit );
145
146 class Private;
147 Private *const d;
148};
149
150}
151
152#endif
153
154