1 | /* |
2 | kopeteglobal.h - Kopete Globals |
3 | |
4 | Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk> |
5 | |
6 | Kopete (c) 2004 by the Kopete developers <kopete-devel@kde.org> |
7 | |
8 | ************************************************************************* |
9 | * * |
10 | * This library is free software; you can redistribute it and/or * |
11 | * modify it under the terms of the GNU Lesser General Public * |
12 | * License as published by the Free Software Foundation; either * |
13 | * version 2 of the License, or (at your option) any later version. * |
14 | * * |
15 | ************************************************************************* |
16 | */ |
17 | |
18 | #ifndef KOPETEGLOBAL_H |
19 | #define KOPETEGLOBAL_H |
20 | |
21 | #include "kopeteproperty.h" |
22 | |
23 | #include "kopete_export.h" |
24 | |
25 | /** |
26 | * This namespace contains all of Kopete's core classes and functions. |
27 | */ |
28 | namespace Kopete |
29 | { |
30 | |
31 | /** |
32 | * This namespace contains Kopete's global settings and functions |
33 | */ |
34 | namespace Global |
35 | { |
36 | class PropertiesPrivate; |
37 | |
38 | /** |
39 | * \brief Global facility to query/store templates that are needed by KopeteProperty |
40 | * |
41 | * Basically all a plugin author needs to worry about is creating PropertyTmpl |
42 | * objects for all the properties he wants to set for a Kopete::Contact, |
43 | * everything else is handled behind the scenes. |
44 | **/ |
45 | class KOPETE_EXPORT Properties |
46 | { |
47 | friend class Kopete::PropertyTmpl; |
48 | public: |
49 | /** |
50 | * \brief Singleton accessor for this class. |
51 | * |
52 | * Use it to access the global list of property-templates or to get |
53 | * a reference to one of the common PropertyTmpl objects |
54 | */ |
55 | static Properties *self(); |
56 | |
57 | /** |
58 | * Return a template with defined by @p key, if no such template has |
59 | * been registered PropertyTmpl::null will be returned |
60 | */ |
61 | const PropertyTmpl &tmpl(const QString &key) const; |
62 | |
63 | /** |
64 | * @return a ready-to-use template for a contact's full name. |
65 | * |
66 | * This is actually no real property, it makes use of |
67 | * firstName() and lastName() to assemble an name that consists of |
68 | * both name parts |
69 | */ |
70 | const PropertyTmpl &fullName() const; |
71 | |
72 | /** |
73 | * Return default template for a contact's idle-time |
74 | */ |
75 | const PropertyTmpl &idleTime() const; |
76 | /** |
77 | * Return default template for a contact's online-since time |
78 | * (i.e. time since he went from offline to online) |
79 | */ |
80 | const PropertyTmpl &onlineSince() const; |
81 | /** |
82 | * @return default template for a contact's last-seen time |
83 | */ |
84 | const PropertyTmpl &lastSeen() const; |
85 | /** |
86 | * @return default template for a contact's status title |
87 | */ |
88 | const PropertyTmpl &statusTitle() const; |
89 | /** |
90 | * @return default template for a contact's status message |
91 | */ |
92 | const PropertyTmpl &statusMessage() const; |
93 | /** |
94 | * @return default template for a contact's first name |
95 | */ |
96 | const PropertyTmpl &firstName() const; |
97 | /** |
98 | * @return default template for a contact's last name |
99 | */ |
100 | const PropertyTmpl &lastName() const; |
101 | /** |
102 | * @return default template for a contact's email-address |
103 | */ |
104 | const PropertyTmpl &emailAddress() const; |
105 | /** |
106 | * @return default template for a contact's private phone number |
107 | */ |
108 | const PropertyTmpl &privatePhone() const; |
109 | /** |
110 | * @return default template for a contact's private mobile number |
111 | */ |
112 | const PropertyTmpl &privateMobilePhone() const; |
113 | /** |
114 | * @return default template for a contact's work phone number |
115 | */ |
116 | const PropertyTmpl &workPhone() const; |
117 | /** |
118 | * @return default template for a contact's work mobile number |
119 | */ |
120 | const PropertyTmpl &workMobilePhone() const; |
121 | /** |
122 | * @return default template for a contact's nickname (set by the contact) |
123 | * This property comes from contact and cannot be changed by user custom name |
124 | */ |
125 | const PropertyTmpl &nickName() const; |
126 | /** |
127 | * @return default template for a contact's nickname (set by the contact) |
128 | * This property is set by user and stored on server contact list |
129 | */ |
130 | const PropertyTmpl &customName() const; |
131 | /** |
132 | * @return default template for a contact's visibility even if offline |
133 | */ |
134 | const PropertyTmpl &isAlwaysVisible() const; |
135 | /** |
136 | * default template for a contact's photo. |
137 | * |
138 | * It could be either a QString or a QImage. |
139 | * If it's a QString, it should points to the path the image is stored. |
140 | */ |
141 | const PropertyTmpl &photo() const; |
142 | |
143 | /** |
144 | * @return a map of all registered PropertyTmpl object |
145 | */ |
146 | const PropertyTmpl::Map &templateMap() const; |
147 | |
148 | /** |
149 | * return true if a template with key @p key is already registered, |
150 | * false otherwise |
151 | */ |
152 | bool isRegistered(const QString &key); |
153 | |
154 | private: |
155 | Properties(); |
156 | ~Properties(); |
157 | |
158 | bool registerTemplate(const QString &key, |
159 | const PropertyTmpl &tmpl); |
160 | void unregisterTemplate(const QString &key); |
161 | |
162 | const PropertyTmpl &createProp(const QString &key, |
163 | const QString &label, const QString &icon=QString(), |
164 | bool persistent = false) const; |
165 | |
166 | private: |
167 | static Properties *mSelf; |
168 | PropertiesPrivate *d; |
169 | }; // end class Properties |
170 | |
171 | } // Global |
172 | |
173 | } // Kopete |
174 | |
175 | #endif |
176 | // vim: set noet ts=4 sts=4 sw=4: |
177 | |