-rw-r--r-- | kabc/stdaddressbook.h | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/kabc/stdaddressbook.h b/kabc/stdaddressbook.h new file mode 100644 index 0000000..9ec53b0 --- a/dev/null +++ b/kabc/stdaddressbook.h | |||
@@ -0,0 +1,151 @@ | |||
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 | /* | ||
22 | Enhanced Version of the file for platform independent KDE tools. | ||
23 | Copyright (c) 2004 Ulf Schenk | ||
24 | |||
25 | $Id$ | ||
26 | */ | ||
27 | |||
28 | #ifndef KABC_STDADDRESSBOOK_H | ||
29 | #define KABC_STDADDRESSBOOK_H | ||
30 | |||
31 | #include "addressbook.h" | ||
32 | |||
33 | namespace KABC { | ||
34 | |||
35 | /** | ||
36 | Standard KDE address book | ||
37 | |||
38 | This class provides access to the standard KDE address book shared by all | ||
39 | applications. | ||
40 | |||
41 | It's implemented as a singleton. Use @ref self() to get the address book | ||
42 | object. On the first self() call the address book also gets loaded. | ||
43 | |||
44 | Example: | ||
45 | |||
46 | <pre> | ||
47 | KABC::AddressBook *ab = KABC::StdAddressBook::self(); | ||
48 | |||
49 | KABC::AddressBook::Iterator it; | ||
50 | for ( it = ab->begin(); it != ab->end(); ++it ) { | ||
51 | kdDebug() << "UID=" << (*it).uid() << endl; | ||
52 | |||
53 | // do some other stuff | ||
54 | } | ||
55 | |||
56 | KABC::StdAddressBook::save(); | ||
57 | </pre> | ||
58 | */ | ||
59 | class StdAddressBook : public AddressBook | ||
60 | { | ||
61 | public: | ||
62 | |||
63 | /** | ||
64 | Destructor. | ||
65 | */ | ||
66 | ~StdAddressBook(); | ||
67 | |||
68 | /** | ||
69 | Return the standard addressbook object. It also loads slow resources. | ||
70 | It is the same as self(false); . | ||
71 | */ | ||
72 | static StdAddressBook *self(); | ||
73 | |||
74 | /** | ||
75 | This is the same as above, but with specified | ||
76 | behaviour of resource loading. | ||
77 | |||
78 | @param onlyFastResource Only resources marked as 'fast' should be loaded | ||
79 | */ | ||
80 | // FIXME for KDE4 return StdAddressBook and merge with the metod above -zecke | ||
81 | static StdAddressBook *self( bool onlyFastResources ); | ||
82 | |||
83 | /** | ||
84 | Save the standard address book to disk. | ||
85 | */ | ||
86 | static bool save(); | ||
87 | |||
88 | /** | ||
89 | Call this method in your crash handler to allow the library clean up | ||
90 | possible locks. | ||
91 | */ | ||
92 | static void handleCrash(); | ||
93 | |||
94 | /** | ||
95 | Returns the default file name for vcard-based addressbook | ||
96 | */ | ||
97 | static QString fileName(); | ||
98 | |||
99 | /** | ||
100 | Returns the default directory name for vcard-based addressbook | ||
101 | */ | ||
102 | static QString directoryName(); | ||
103 | |||
104 | /** | ||
105 | Set the automatic save property of the address book. | ||
106 | If @p enable is TRUE (default) the address book is saved at | ||
107 | destruction time otherwise you have to call @ref save() to | ||
108 | explicitely save it. | ||
109 | */ | ||
110 | static void setAutomaticSave( bool enable ); | ||
111 | |||
112 | /** | ||
113 | Closes the address book. Depending on @ref automaticSave() it will | ||
114 | save the address book first. | ||
115 | */ | ||
116 | static void close(); | ||
117 | |||
118 | /** | ||
119 | Returns whether the address book is saved at destruction time. | ||
120 | See also @ref setAutomaticSave(). | ||
121 | */ | ||
122 | static bool automaticSave(); | ||
123 | |||
124 | /** | ||
125 | Returns the contact, that is associated with the owner of the | ||
126 | address book. This contact should be used by other programs | ||
127 | to access user specific data. | ||
128 | */ | ||
129 | Addressee whoAmI(); | ||
130 | |||
131 | /** | ||
132 | Sets the users contact. See @ref whoAmI() for more information. | ||
133 | |||
134 | @param uid The uid of the users contact. | ||
135 | */ | ||
136 | void setWhoAmI( const Addressee &addr ); | ||
137 | |||
138 | protected: | ||
139 | StdAddressBook(); | ||
140 | StdAddressBook( bool onlyFastResources ); | ||
141 | |||
142 | void init( bool onlyFastResources ); | ||
143 | |||
144 | private: | ||
145 | static QString setTempAppDir(); | ||
146 | static StdAddressBook *mSelf; | ||
147 | static bool mAutomaticSave; | ||
148 | }; | ||
149 | |||
150 | } | ||
151 | #endif | ||