Mercurial > pidgin.yaz
annotate src/savedstatuses.h @ 13194:7099a443131d
[gaim-migrate @ 15557]
The other half of sf patch #1414103, from Sadrul Habib Chowdhury
"Make the initial selection in the substatus-
edit dialog correct (currently it always opens with the
last status in the list selected)."
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 09 Feb 2006 00:00:08 +0000 |
parents | e2a94ab60a7e |
children | c97c76d9d347 |
rev | line source |
---|---|
10418 | 1 /** |
2 * @file savedstatuses.h Saved Status API | |
3 * @ingroup core | |
4 * | |
5 * gaim | |
6 * | |
7 * Gaim is the legal property of its developers, whose names are too numerous | |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
10 * | |
11 * This program is free software; you can redistribute it and/or modify | |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
25 #ifndef _GAIM_SAVEDSTATUSES_H_ | |
26 #define _GAIM_SAVEDSTATUSES_H_ | |
27 | |
28 /** | |
29 * Saved statuses don't really interact much with the rest of Gaim. It | |
30 * could really be a plugin. It's just a list of away states. When | |
31 * a user chooses one of the saved states, their Gaim accounts are set | |
32 * to the settings of that state. | |
12125 | 33 * |
34 * In the savedstatus API, there is the concept of a 'transient' | |
35 * saved status. A transient saved status is one that is not | |
36 * permanent. Gaim will removed it automatically if it isn't | |
37 * used for a period of time. Transient saved statuses don't | |
38 * have titles and they don't show up in the list of saved | |
39 * statuses. In fact, if a saved status does not have a title | |
40 * then it is transient. If it does have a title, then it is not | |
41 * transient. | |
42 * | |
43 * What good is a transient status, you ask? They can be used to | |
44 * keep track of the user's 5 most recently used statuses, for | |
45 * example. Basically if they just set a message on the fly, | |
46 * we'll cache it for them in case they want to use it again. If | |
47 * they don't use it again, we'll just delete it. | |
10418 | 48 */ |
49 | |
11651 | 50 /* |
51 * TODO: Hmm. We should probably just be saving GaimPresences. That's | |
52 * something we should look into once the status box gets fleshed | |
53 * out more. | |
54 */ | |
55 | |
10419 | 56 typedef struct _GaimSavedStatus GaimSavedStatus; |
57 typedef struct _GaimSavedStatusSub GaimSavedStatusSub; | |
10418 | 58 |
10447 | 59 #include "status.h" |
60 | |
10418 | 61 /**************************************************************************/ |
62 /** @name Saved status subsystem */ | |
63 /**************************************************************************/ | |
64 /*@{*/ | |
65 | |
66 /** | |
67 * Create a new saved status. This will add the saved status to the | |
68 * list of saved statuses and writes the revised list to status.xml. | |
69 * | |
11651 | 70 * @param title The title of the saved status. This must be |
12125 | 71 * unique. Or, if you want to create a transient |
72 * saved status, then pass in NULL. | |
11651 | 73 * @param type The type of saved status. |
10418 | 74 * |
10420 | 75 * @return The newly created saved status, or NULL if the title you |
76 * used was already taken. | |
10418 | 77 */ |
10419 | 78 GaimSavedStatus *gaim_savedstatus_new(const char *title, |
79 GaimStatusPrimitive type); | |
10418 | 80 |
81 /** | |
12056 | 82 * Set the title for the given saved status. |
83 * | |
84 * @param status The saved status. | |
85 * @param title The title of the saved status. | |
86 */ | |
87 void gaim_savedstatus_set_title(GaimSavedStatus *status, | |
88 const char *title); | |
89 | |
90 /** | |
11651 | 91 * Set the type for the given saved status. |
92 * | |
93 * @param status The saved status. | |
94 * @param type The type of saved status. | |
95 */ | |
96 void gaim_savedstatus_set_type(GaimSavedStatus *status, | |
97 GaimStatusPrimitive type); | |
98 | |
99 /** | |
10420 | 100 * Set the message for the given saved status. |
101 * | |
102 * @param status The saved status. | |
103 * @param message The message, or NULL if you want to unset the | |
104 * message for this status. | |
105 */ | |
106 void gaim_savedstatus_set_message(GaimSavedStatus *status, | |
107 const char *message); | |
108 | |
109 /** | |
12056 | 110 * Set a substatus for an account in a saved status. |
111 * | |
112 * @param status The saved status. | |
113 * @param account The account. | |
114 * @param type The status type for the account in the staved | |
115 * status. | |
116 * @param message The message for the account in the substatus. | |
117 */ | |
12080 | 118 void gaim_savedstatus_set_substatus(GaimSavedStatus *status, |
119 const GaimAccount *account, | |
120 const GaimStatusType *type, | |
121 const char *message); | |
12056 | 122 |
123 /** | |
124 * Unset a substatus for an account in a saved status. This clears | |
125 * the previosly set substatus for the GaimSavedStatus. If this | |
126 * saved status is activated then this account will use the default | |
127 * status type and message. | |
128 * | |
12245 | 129 * @param saved_status The saved status. |
130 * @param account The account. | |
12056 | 131 */ |
12080 | 132 void gaim_savedstatus_unset_substatus(GaimSavedStatus *saved_status, |
12056 | 133 const GaimAccount *account); |
134 | |
135 /** | |
10418 | 136 * Delete a saved status. This removes the saved status from the list |
137 * of saved statuses, and writes the revised list to status.xml. | |
138 * | |
139 * @param title The title of the saved status. | |
140 * | |
141 * @return TRUE if the status was successfully deleted. FALSE if the | |
142 * status could not be deleted because no saved status exists | |
143 * with the given title. | |
144 */ | |
10419 | 145 gboolean gaim_savedstatus_delete(const char *title); |
10418 | 146 |
147 /** | |
148 * Returns all saved statuses. | |
149 * | |
150 * @return A list of saved statuses. | |
151 */ | |
152 const GList *gaim_savedstatuses_get_all(void); | |
153 | |
154 /** | |
12688 | 155 * Returns the n most popular saved statuses. "Popularity" is |
156 * determined by when the last time a saved_status was used and | |
157 * how many times it has been used. | |
158 * | |
159 * @param how_many The maximum number of saved statuses | |
160 * to return, or '0' to get all saved | |
161 * statuses sorted by popularity. | |
162 * @return A linked list containing at most how_many | |
163 * GaimSavedStatuses. This list should be | |
164 * g_list_free'd by the caller (but the | |
165 * GaimSavedStatuses must not be free'd). | |
166 */ | |
167 GList *gaim_savedstatuses_get_popular(unsigned int how_many); | |
168 | |
169 /** | |
12125 | 170 * Returns the currently selected saved status. |
171 * | |
172 * @return A pointer to the in-use GaimSavedStatus. | |
173 */ | |
12323
fc464a0abccc
[gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents:
12245
diff
changeset
|
174 GaimSavedStatus *gaim_savedstatus_get_current(void); |
12125 | 175 |
176 /** | |
12857
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12690
diff
changeset
|
177 * Returns the status to be used when gaim is starting up |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12690
diff
changeset
|
178 * |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12690
diff
changeset
|
179 * @return A pointer to the startup GaimSavedStatus. |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12690
diff
changeset
|
180 */ |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12690
diff
changeset
|
181 GaimSavedStatus *gaim_savedstatus_get_startup(void); |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12690
diff
changeset
|
182 |
e5f780a6137b
[gaim-migrate @ 15208]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12690
diff
changeset
|
183 /** |
12125 | 184 * Returns the saved status that gets used when your |
185 * accounts become idle-away. | |
186 * | |
187 * @return A pointer to the idle-away GaimSavedStatus. | |
188 */ | |
12323
fc464a0abccc
[gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents:
12245
diff
changeset
|
189 GaimSavedStatus *gaim_savedstatus_get_idleaway(void); |
12125 | 190 |
191 /** | |
10418 | 192 * Finds a saved status with the specified title. |
193 * | |
194 * @param title The name of the saved status. | |
195 * | |
196 * @return The saved status if found, or NULL. | |
197 */ | |
10419 | 198 GaimSavedStatus *gaim_savedstatus_find(const char *title); |
10418 | 199 |
200 /** | |
12690 | 201 * Finds a saved status with the specified creation time. |
202 * | |
203 * @param creation_time The timestamp when the saved | |
204 * status was created. | |
205 * | |
206 * @return The saved status if found, or NULL. | |
207 */ | |
208 GaimSavedStatus *gaim_savedstatus_find_by_creation_time(time_t creation_time); | |
209 | |
210 /** | |
13012 | 211 * Finds a saved status with the specified primitive and message. |
212 * | |
213 * @param type The GaimStatusPrimitive for the status you're trying | |
214 * to find. | |
215 * @param message The message for the status you're trying | |
216 * to find. | |
217 * | |
218 * @return The saved status if found, or NULL. | |
219 */ | |
220 GaimSavedStatus *gaim_savedstatus_find_by_type_and_message(GaimStatusPrimitive type, const char *message); | |
221 | |
222 /** | |
11651 | 223 * Determines if a given saved status is "transient." |
224 * A transient saved status is one that was not | |
225 * explicitly added by the user. Transient statuses | |
226 * are automatically removed if they are not used | |
227 * for a period of time. | |
228 * | |
229 * A transient saved statuses is automatically | |
230 * created by the status box when the user sets himself | |
231 * to one of the generic primitive statuses. The reason | |
232 * we need to save this status information is so we can | |
233 * restore it when Gaim restarts. | |
234 * | |
235 * @param saved_status The saved status. | |
236 * | |
237 * @return TRUE if the saved status is transient. | |
238 */ | |
239 gboolean gaim_savedstatus_is_transient(const GaimSavedStatus *saved_status); | |
240 | |
241 /** | |
10418 | 242 * Return the name of a given saved status. |
243 * | |
244 * @param saved_status The saved status. | |
245 * | |
12690 | 246 * @return The title. This value may be a static buffer which may |
247 * be overwritten on subsequent calls to this function. If | |
248 * you need a reference to the title for prolonged use then | |
249 * you should make a copy of it. | |
10418 | 250 */ |
10419 | 251 const char *gaim_savedstatus_get_title(const GaimSavedStatus *saved_status); |
10418 | 252 |
253 /** | |
12056 | 254 * Return the type of a given saved status. |
10418 | 255 * |
256 * @param saved_status The saved status. | |
257 * | |
258 * @return The name. | |
259 */ | |
10419 | 260 GaimStatusPrimitive gaim_savedstatus_get_type(const GaimSavedStatus *saved_status); |
10418 | 261 |
262 /** | |
12056 | 263 * Return the default message of a given saved status. |
10418 | 264 * |
265 * @param saved_status The saved status. | |
266 * | |
13121 | 267 * @return The message. This will return NULL if the saved |
268 * status does not have a message. This will | |
269 * contain the normal markup that is created by | |
270 * Gaim's IMHTML (basically HTML markup). | |
10418 | 271 */ |
10419 | 272 const char *gaim_savedstatus_get_message(const GaimSavedStatus *saved_status); |
10418 | 273 |
274 /** | |
12125 | 275 * Return the time in seconds-since-the-epoch when this |
276 * saved status was created. Note: For any status created | |
277 * by Gaim 1.5.0 or older this value will be invalid and | |
278 * very small (close to 0). This is because Gaim 1.5.0 | |
279 * and older did not record the timestamp when the status | |
280 * was created. | |
281 * | |
282 * However, this value is guaranteed to be a unique | |
283 * identifier for the given saved status. | |
284 * | |
285 * @param saved_status The saved status. | |
286 * | |
287 * @return The timestamp when this saved status was created. | |
288 */ | |
289 time_t gaim_savedstatus_get_creation_time(const GaimSavedStatus *saved_status); | |
290 | |
291 /** | |
11651 | 292 * Determine if a given saved status has "substatuses," |
293 * or if it is a simple status (the same for all | |
294 * accounts). | |
295 * | |
296 * @param saved_status The saved status. | |
297 * | |
298 * @return TRUE if the saved_status has substatuses. | |
299 * FALSE otherwise. | |
300 */ | |
301 gboolean gaim_savedstatus_has_substatuses(const GaimSavedStatus *saved_status); | |
302 | |
303 /** | |
12056 | 304 * Get the substatus for an account in a saved status. |
305 * | |
12245 | 306 * @param saved_status The saved status. |
307 * @param account The account. | |
12056 | 308 * |
309 * @return The GaimSavedStatusSub for the account, or NULL if | |
310 * the given account does not have a substatus that | |
311 * differs from the default status of this GaimSavedStatus. | |
312 */ | |
12080 | 313 GaimSavedStatusSub *gaim_savedstatus_get_substatus( |
12056 | 314 const GaimSavedStatus *saved_status, |
315 const GaimAccount *account); | |
316 | |
317 /** | |
318 * Get the status type of a given substatus. | |
319 * | |
320 * @param substatus The substatus. | |
321 * | |
322 * @return The status type. | |
323 */ | |
324 const GaimStatusType *gaim_savedstatus_substatus_get_type(const GaimSavedStatusSub *substatus); | |
325 | |
326 /** | |
327 * Get the message of a given substatus. | |
328 * | |
329 * @param substatus The substatus. | |
330 * | |
331 * @return The message of the substatus, or NULL if this substatus does | |
332 * not have a message. | |
333 */ | |
334 const char *gaim_savedstatus_substatus_get_message(const GaimSavedStatusSub *substatus); | |
335 | |
336 /** | |
11724 | 337 * Sets the statuses for all your accounts to those specified |
338 * by the given saved_status. This function calls | |
339 * gaim_savedstatus_activate_for_account() for all your accounts. | |
340 * | |
341 * @param saved_status The status you want to set your accounts to. | |
342 */ | |
12125 | 343 void gaim_savedstatus_activate(GaimSavedStatus *saved_status); |
11724 | 344 |
345 /** | |
346 * Sets the statuses for a given account to those specified | |
347 * by the given saved_status. | |
348 * | |
349 * @param saved_status The status you want to set your accounts to. | |
350 * @param account The account whose statuses you want to change. | |
351 */ | |
352 void gaim_savedstatus_activate_for_account(const GaimSavedStatus *saved_status, GaimAccount *account); | |
353 | |
354 /** | |
10418 | 355 * Get the handle for the status subsystem. |
356 * | |
357 * @return the handle to the status subsystem | |
358 */ | |
12323
fc464a0abccc
[gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents:
12245
diff
changeset
|
359 void *gaim_savedstatuses_get_handle(void); |
10418 | 360 |
361 /** | |
362 * Initializes the status subsystem. | |
363 */ | |
364 void gaim_savedstatuses_init(void); | |
365 | |
366 /** | |
367 * Uninitializes the status subsystem. | |
368 */ | |
369 void gaim_savedstatuses_uninit(void); | |
370 | |
371 /*@}*/ | |
372 | |
373 #endif /* _GAIM_SAVEDSTATUSES_H_ */ |