4359
|
1 /**
|
|
2 * @file conversation.h Conversation API
|
|
3 *
|
|
4 * gaim
|
|
5 *
|
|
6 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org>
|
|
7 *
|
|
8 * This program is free software; you can redistribute it and/or modify
|
|
9 * it under the terms of the GNU General Public License as published by
|
|
10 * the Free Software Foundation; either version 2 of the License, or
|
|
11 * (at your option) any later version.
|
|
12 *
|
|
13 * This program is distributed in the hope that it will be useful,
|
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 * GNU General Public License for more details.
|
|
17 *
|
|
18 * You should have received a copy of the GNU General Public License
|
|
19 * along with this program; if not, write to the Free Software
|
|
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 *
|
|
22 */
|
|
23
|
|
24 #ifndef _CONVERSATION_H_
|
|
25 #define _CONVERSATION_H_
|
|
26
|
|
27 /**************************************************************************/
|
|
28 /** Data Structures */
|
|
29 /**************************************************************************/
|
|
30
|
|
31 typedef enum _GaimConversationType GaimConversationType;
|
|
32 typedef enum _GaimUnseenState GaimUnseenState;
|
|
33 typedef enum _GaimConvUpdateType GaimConvUpdateType;
|
|
34 struct gaim_window_ops;
|
|
35 struct gaim_window;
|
|
36 struct gaim_conversation;
|
|
37 struct gaim_im;
|
|
38 struct gaim_chat;
|
|
39
|
|
40 /**
|
|
41 * A type of conversation.
|
|
42 */
|
|
43 enum _GaimConversationType
|
|
44 {
|
|
45 GAIM_CONV_UNKNOWN = 0, /**< Unknown conversation type. */
|
|
46 GAIM_CONV_IM, /**< Instant Message. */
|
|
47 GAIM_CONV_CHAT /**< Chat room. */
|
|
48 };
|
|
49
|
|
50 /**
|
|
51 * Unseen text states.
|
|
52 */
|
|
53 enum _GaimUnseenState
|
|
54 {
|
|
55 GAIM_UNSEEN_NONE = 0, /**< No unseen text in the conversation. */
|
|
56 GAIM_UNSEEN_TEXT, /**< Unseen text in the conversation. */
|
|
57 GAIM_UNSEEN_NICK, /**< Unseen text and the nick was said. */
|
|
58 };
|
|
59
|
|
60 /**
|
|
61 * Conversation update type.
|
|
62 */
|
|
63 enum _GaimConvUpdateType
|
|
64 {
|
|
65 GAIM_CONV_UPDATE_ADD = 0, /**< The buddy associated with the conversation
|
|
66 was added. */
|
|
67 GAIM_CONV_UPDATE_REMOVE, /**< The buddy associated with the conversation
|
|
68 was removed. */
|
|
69 GAIM_CONV_UPDATE_USER, /**< The aim_user was changed. */
|
|
70 GAIM_CONV_UPDATE_TYPING, /**< The typing state was updated. */
|
|
71 GAIM_CONV_UPDATE_UNSEEN, /**< The unseen state was updated. */
|
|
72 GAIM_CONV_UPDATE_LOGGING, /**< Logging for this conversation was
|
|
73 enabled or disabled. */
|
|
74 GAIM_CONV_UPDATE_TOPIC, /**< The topic for a chat was updated. */
|
|
75
|
|
76 /*
|
|
77 * XXX These need to go when we implement a more generic core/UI event
|
|
78 * system.
|
|
79 */
|
|
80 GAIM_CONV_ACCOUNT_ONLINE, /**< One of the user's accounts went online. */
|
|
81 GAIM_CONV_ACCOUNT_OFFLINE /**< One of the user's accounts went offline. */
|
|
82 };
|
|
83
|
|
84 /* Yeah, this has to be included here. Ugh. */
|
|
85 #include "gaim.h"
|
|
86
|
|
87 /**
|
|
88 * Conversation window operations.
|
|
89 *
|
|
90 * Any UI representing a window must assign a filled-out gaim_window_ops
|
|
91 * structure to the gaim_window.
|
|
92 */
|
|
93 struct gaim_window_ops
|
|
94 {
|
|
95 struct gaim_conversation_ops *(*get_conversation_ops)(void);
|
|
96
|
|
97 void (*new_window)(struct gaim_window *win);
|
|
98 void (*destroy_window)(struct gaim_window *win);
|
|
99
|
|
100 void (*show)(struct gaim_window *win);
|
|
101 void (*hide)(struct gaim_window *win);
|
|
102 void (*raise)(struct gaim_window *win);
|
|
103 void (*flash)(struct gaim_window *win);
|
|
104
|
|
105 void (*switch_conversation)(struct gaim_window *win, unsigned int index);
|
|
106 void (*add_conversation)(struct gaim_window *win,
|
|
107 struct gaim_conversation *conv);
|
|
108 void (*remove_conversation)(struct gaim_window *win,
|
|
109 struct gaim_conversation *conv);
|
|
110 void (*move_conversation)(struct gaim_window *win,
|
|
111 struct gaim_conversation *conv,
|
|
112 unsigned int newIndex);
|
|
113 int (*get_active_index)(const struct gaim_window *win);
|
|
114 };
|
|
115
|
|
116 /**
|
|
117 * Conversation operations and events.
|
|
118 *
|
|
119 * Any UI representing a conversation must assign a filled-out
|
|
120 * gaim_conversation_ops structure to the gaim_conversation.
|
|
121 */
|
|
122 struct gaim_conversation_ops
|
|
123 {
|
|
124 void (*destroy_conversation)(struct gaim_conversation *conv);
|
|
125 void (*write_chat)(struct gaim_conversation *conv, const char *who,
|
|
126 const char *message, int flags, time_t mtime);
|
|
127 void (*write_im)(struct gaim_conversation *conv, const char *who,
|
|
128 const char *message, size_t len, int flags, time_t mtime);
|
|
129 void (*write_conv)(struct gaim_conversation *conv, const char *who,
|
|
130 const char *message, size_t length, int flags,
|
|
131 time_t mtime);
|
|
132
|
|
133 void (*chat_add_user)(struct gaim_conversation *conv, const char *user);
|
|
134 void (*chat_rename_user)(struct gaim_conversation *conv,
|
|
135 const char *old_name, const char *new_name);
|
|
136 void (*chat_remove_user)(struct gaim_conversation *conv, const char *user);
|
|
137
|
|
138 void (*set_title)(struct gaim_conversation *conv,
|
|
139 const char *title);
|
|
140 void (*update_progress)(struct gaim_conversation *conv, float percent);
|
|
141
|
|
142 /* Events */
|
|
143 void (*updated)(struct gaim_conversation *conv, GaimConvUpdateType type);
|
|
144 };
|
|
145
|
|
146 /**
|
|
147 * A core representation of a graphical window containing one or more
|
|
148 * conversations.
|
|
149 */
|
|
150 struct gaim_window
|
|
151 {
|
|
152 GList *conversations; /**< The conversations in the window. */
|
|
153 size_t conversation_count; /**< The number of conversations. */
|
|
154
|
|
155 struct gaim_window_ops *ops; /**< UI-specific window operations. */
|
|
156
|
|
157 void *ui_data; /**< UI-specific data. */
|
|
158 };
|
|
159
|
|
160 /**
|
|
161 * Data specific to Instant Messages.
|
|
162 */
|
|
163 struct gaim_im
|
|
164 {
|
|
165 struct gaim_conversation *conv;
|
|
166
|
|
167 int typing_state;
|
|
168 guint typing_timeout;
|
|
169 time_t type_again;
|
|
170 guint type_again_timeout;
|
|
171
|
|
172 GSList *images;
|
|
173 };
|
|
174
|
|
175 /**
|
|
176 * Data specific to Chats.
|
|
177 */
|
|
178 struct gaim_chat
|
|
179 {
|
|
180 struct gaim_conversation *conv;
|
|
181
|
|
182 GList *in_room;
|
|
183 GList *ignored;
|
|
184 char *who;
|
|
185 char *topic;
|
|
186 int id;
|
|
187 };
|
|
188
|
|
189 /**
|
|
190 * A core representation of a conversation between two or more people.
|
|
191 *
|
|
192 * The conversation can be an IM or a chat. Each conversation is kept
|
|
193 * in a gaim_window and has a UI representation.
|
|
194 */
|
|
195 struct gaim_conversation
|
|
196 {
|
|
197 GaimConversationType type; /**< The type of conversation. */
|
|
198
|
|
199 struct aim_user *user; /**< The user using this conversation. */
|
|
200 struct gaim_window *window; /**< The parent window. */
|
|
201
|
|
202 /** UI-specific conversation operations.*/
|
|
203 struct gaim_conversation_ops *ops;
|
|
204
|
|
205 int conversation_pos; /**< The position in the window's list. */
|
|
206
|
|
207 char *name; /**< The name of the conversation. */
|
|
208 char *title; /**< The window title. */
|
|
209
|
|
210 gboolean logging; /**< The status of logging. */
|
|
211
|
|
212 GList *send_history; /**< The send history. */
|
|
213 GString *history; /**< The conversation history. */
|
|
214
|
|
215 GaimUnseenState unseen; /**< The unseen tab state. */
|
|
216
|
|
217 void *ui_data; /**< UI-specific data. */
|
|
218
|
|
219 union
|
|
220 {
|
|
221 struct gaim_im *im; /**< IM-specific data. */
|
|
222 struct gaim_chat *chat; /**< Chat-specific data. */
|
|
223
|
|
224 } u;
|
|
225 };
|
|
226
|
|
227
|
|
228 /**************************************************************************/
|
|
229 /** @name Conversation Window API */
|
|
230 /**************************************************************************/
|
|
231 /*@{*/
|
|
232
|
|
233 /**
|
|
234 * Creates a new conversation window.
|
|
235 *
|
|
236 * This window is added to the list of windows, but is not shown until
|
|
237 * gaim_window_show() is called.
|
|
238 *
|
|
239 * @return The new conversation window.
|
|
240 */
|
|
241 struct gaim_window *gaim_window_new(void);
|
|
242
|
|
243 /**
|
|
244 * Destroys the specified conversation window and all conversations in it.
|
|
245 *
|
|
246 * @param win The window to destroy.
|
|
247 */
|
|
248 void gaim_window_destroy(struct gaim_window *win);
|
|
249
|
|
250 /**
|
|
251 * Shows the specified conversation window.
|
|
252 *
|
|
253 * @param win The window.
|
|
254 */
|
|
255 void gaim_window_show(struct gaim_window *win);
|
|
256
|
|
257 /**
|
|
258 * Hides the specified conversation window.
|
|
259 *
|
|
260 * @param win The window.
|
|
261 */
|
|
262 void gaim_window_hide(struct gaim_window *win);
|
|
263
|
|
264 /**
|
|
265 * Raises the specified conversation window.
|
|
266 *
|
|
267 * @param win The window.
|
|
268 */
|
|
269 void gaim_window_raise(struct gaim_window *win);
|
|
270
|
|
271 /**
|
|
272 * Causes the window to flash for IM notification, if the UI supports this.
|
|
273 *
|
|
274 * @param win The window.
|
|
275 */
|
|
276 void gaim_window_flash(struct gaim_window *win);
|
|
277
|
|
278 /**
|
|
279 * Sets the specified window's UI window operations structure.
|
|
280 *
|
|
281 * @param win The window.
|
|
282 * @param ops The UI window operations structure.
|
|
283 */
|
|
284 void gaim_window_set_ops(struct gaim_window *win,
|
|
285 struct gaim_window_ops *ops);
|
|
286
|
|
287 /**
|
|
288 * Returns the specified window's UI window operations structure.
|
|
289 *
|
|
290 * @param win The window.
|
|
291 *
|
|
292 * @return The UI window operations structure.
|
|
293 */
|
|
294 struct gaim_window_ops *gaim_window_get_ops(const struct gaim_window *win);
|
|
295
|
|
296 /**
|
|
297 * Adds a conversation to this window.
|
|
298 *
|
|
299 * If the conversation already has a parent window, this will do nothing.
|
|
300 *
|
|
301 * @param win The window.
|
|
302 * @param conv The conversation.
|
|
303 *
|
|
304 * @return The new index of the conversation in the window.
|
|
305 */
|
|
306 int gaim_window_add_conversation(struct gaim_window *win,
|
|
307 struct gaim_conversation *conv);
|
|
308
|
|
309 /**
|
|
310 * Removes the conversation at the specified index from the window.
|
|
311 *
|
|
312 * If there is no conversation at this index, this will do nothing.
|
|
313 *
|
|
314 * @param win The window.
|
|
315 * @param index The index of the conversation.
|
|
316 *
|
|
317 * @return The conversation removed.
|
|
318 */
|
|
319 struct gaim_conversation *gaim_window_remove_conversation(
|
|
320 struct gaim_window *win, unsigned int index);
|
|
321
|
|
322 /**
|
|
323 * Moves the conversation at the specified index in a window to a new index.
|
|
324 *
|
|
325 * @param win The window.
|
|
326 * @param index The index of the conversation to move.
|
|
327 * @param new_index The new index.
|
|
328 */
|
|
329 void gaim_window_move_conversation(struct gaim_window *win,
|
|
330 unsigned int index, unsigned int new_index);
|
|
331
|
|
332 /**
|
|
333 * Returns the conversation in the window at the specified index.
|
|
334 *
|
|
335 * If the index is out of range, this returns @c NULL.
|
|
336 *
|
|
337 * @param win The window.
|
|
338 * @param index The index containing a conversation.
|
|
339 *
|
|
340 * @return The conversation at the specified index.
|
|
341 */
|
|
342 struct gaim_conversation *gaim_window_get_conversation_at(
|
|
343 const struct gaim_window *win, unsigned int index);
|
|
344
|
|
345 /**
|
|
346 * Returns the number of conversations in the window.
|
|
347 *
|
|
348 * @param win The window.
|
|
349 *
|
|
350 * @return The number of conversations.
|
|
351 */
|
|
352 size_t gaim_window_get_conversation_count(const struct gaim_window *win);
|
|
353
|
|
354 /**
|
|
355 * Switches the active conversation to the one at the specified index.
|
|
356 *
|
|
357 * If @a index is out of range, this does nothing.
|
|
358 *
|
|
359 * @param win The window.
|
|
360 * @param index The new index.
|
|
361 */
|
|
362 void gaim_window_switch_conversation(struct gaim_window *win,
|
|
363 unsigned int index);
|
|
364
|
|
365 /**
|
|
366 * Returns the active conversation in the window.
|
|
367 *
|
|
368 * @param win The window.
|
|
369 *
|
|
370 * @return The active conversation.
|
|
371 */
|
|
372 struct gaim_conversation *gaim_window_get_active_conversation(
|
|
373 const struct gaim_window *win);
|
|
374
|
|
375 /**
|
|
376 * Returns the list of conversations in the specified window.
|
|
377 *
|
|
378 * @param win The window.
|
|
379 *
|
|
380 * @return The list of conversations.
|
|
381 */
|
|
382 GList *gaim_window_get_conversations(const struct gaim_window *win);
|
|
383
|
|
384 /**
|
|
385 * Returns a list of all windows.
|
|
386 *
|
|
387 * @return A list of windows.
|
|
388 */
|
|
389 GList *gaim_get_windows(void);
|
|
390
|
|
391 /*@}*/
|
|
392
|
|
393 /**************************************************************************/
|
|
394 /** @name Conversation API */
|
|
395 /**************************************************************************/
|
|
396 /*@{*/
|
|
397
|
|
398 /**
|
|
399 * Creates a new conversation of the specified type.
|
|
400 *
|
|
401 * @param type The type of conversation.
|
|
402 * @param name The name of the conversation.
|
|
403 *
|
|
404 * @return The new conversation.
|
|
405 */
|
|
406 struct gaim_conversation *gaim_conversation_new(GaimConversationType type,
|
|
407 const char *name);
|
|
408
|
|
409 /**
|
|
410 * Destroys the specified conversation and removes it from the parent
|
|
411 * window.
|
|
412 *
|
|
413 * If this conversation is the only one contained in the parent window,
|
|
414 * that window is also destroyed.
|
|
415 *
|
|
416 * @param conv The conversation to destroy.
|
|
417 */
|
|
418 void gaim_conversation_destroy(struct gaim_conversation *conv);
|
|
419
|
|
420 /**
|
|
421 * Returns the specified conversation's type.
|
|
422 *
|
|
423 * @param conv The conversation.
|
|
424 *
|
|
425 * @return The conversation's type.
|
|
426 */
|
|
427 GaimConversationType gaim_conversation_get_type(
|
|
428 const struct gaim_conversation *conv);
|
|
429
|
|
430 /**
|
|
431 * Sets the specified conversation's UI operations structure.
|
|
432 *
|
|
433 * @param conv The conversation.
|
|
434 * @param ops The UI conversation operations structure.
|
|
435 */
|
|
436 void gaim_conversation_set_ops(struct gaim_conversation *conv,
|
|
437 struct gaim_conversation_ops *ops);
|
|
438
|
|
439 /**
|
|
440 * Returns the specified conversation's UI operations structure.
|
|
441 *
|
|
442 * @param conv The conversation.
|
|
443 *
|
|
444 * @return The operations structure.
|
|
445 */
|
|
446 struct gaim_conversation_ops *gaim_conversation_get_ops(
|
|
447 struct gaim_conversation *conv);
|
|
448
|
|
449 /**
|
|
450 * Sets the specified conversation's aim_user.
|
|
451 *
|
|
452 * This aim_user represents the user using gaim, not the person the user
|
|
453 * is having a conversation/chat/flame with.
|
|
454 *
|
|
455 * @param conv The conversation.
|
|
456 * @param user The aim_user.
|
|
457 */
|
|
458 void gaim_conversation_set_user(struct gaim_conversation *conv,
|
|
459 struct aim_user *user);
|
|
460
|
|
461 /**
|
|
462 * Returns the specified conversation's aim_user.
|
|
463 *
|
|
464 * This aim_user represents the user using gaim, not the person the user
|
|
465 * is having a conversation/chat/flame with.
|
|
466 *
|
|
467 * @param conv The conversation.
|
|
468 *
|
|
469 * @return The conversation's aim_user.
|
|
470 */
|
|
471 struct aim_user *gaim_conversation_get_user(
|
|
472 const struct gaim_conversation *conv);
|
|
473
|
|
474 #if 0
|
|
475 /**
|
|
476 * Sets the specified conversation's gaim_connection.
|
|
477 *
|
|
478 * @param conv The conversation.
|
|
479 * @param gc The gaim_connection.
|
|
480 */
|
|
481 void gaim_conversation_set_gc(struct gaim_conversation *conv,
|
|
482 struct gaim_connection *gc);
|
|
483 #endif
|
|
484
|
|
485 /**
|
|
486 * Returns the specified conversation's gaim_connection.
|
|
487 *
|
|
488 * This is the same as gaim_conversation_get_user(conv)->gc.
|
|
489 *
|
|
490 * @param conv The conversation.
|
|
491 *
|
|
492 * @return The conversation's gaim_connection.
|
|
493 */
|
|
494 struct gaim_connection *gaim_conversation_get_gc(
|
|
495 const struct gaim_conversation *conv);
|
|
496
|
|
497 /**
|
|
498 * Sets the specified conversation's title.
|
|
499 *
|
|
500 * @param conv The conversation.
|
|
501 * @param title The title.
|
|
502 */
|
|
503 void gaim_conversation_set_title(struct gaim_conversation *conv,
|
|
504 const char *title);
|
|
505
|
|
506 /**
|
|
507 * Returns the specified conversation's title.
|
|
508 *
|
|
509 * @param win The conversation.
|
|
510 *
|
|
511 * @return The title.
|
|
512 */
|
|
513 const char *gaim_conversation_get_title(const struct gaim_conversation *conv);
|
|
514
|
|
515 /**
|
|
516 * Automatically sets the specified conversation's title.
|
|
517 *
|
|
518 * This function takes OPT_IM_ALIAS_TAB into account, as well as the
|
|
519 * user's alias.
|
|
520 *
|
|
521 * @param conv The conversation.
|
|
522 */
|
|
523 void gaim_conversation_autoset_title(struct gaim_conversation *conv);
|
|
524
|
|
525 /**
|
|
526 * Returns the specified conversation's index in the parent window.
|
|
527 *
|
|
528 * @param conv The conversation.
|
|
529 *
|
|
530 * @return The current index in the parent window.
|
|
531 */
|
|
532 int gaim_conversation_get_index(const struct gaim_conversation *conv);
|
|
533
|
|
534 /**
|
|
535 * Sets the conversation's unseen state.
|
|
536 *
|
|
537 * @param conv The conversation.
|
|
538 * @param state The new unseen state.
|
|
539 */
|
|
540 void gaim_conversation_set_unseen(struct gaim_conversation *conv,
|
|
541 GaimUnseenState state);
|
|
542
|
|
543 /**
|
|
544 * Returns the conversation's unseen state.
|
|
545 *
|
|
546 * @param conv The conversation.
|
|
547 *
|
|
548 * @param The conversation's unseen state.
|
|
549 */
|
|
550 GaimUnseenState gaim_conversation_get_unseen(
|
|
551 const struct gaim_conversation *conv);
|
|
552
|
|
553 /**
|
|
554 * Returns the specified conversation's name.
|
|
555 *
|
|
556 * @param conv The conversation.
|
|
557 *
|
|
558 * @return The conversation's name.
|
|
559 */
|
|
560 const char *gaim_conversation_get_name(const struct gaim_conversation *conv);
|
|
561
|
|
562 /**
|
|
563 * Enables or disables logging for this conversation.
|
|
564 *
|
|
565 * @param log @c TRUE if logging should be enabled, or @c FALSE otherwise.
|
|
566 */
|
|
567 void gaim_conversation_set_logging(struct gaim_conversation *conv,
|
|
568 gboolean log);
|
|
569
|
|
570 /**
|
|
571 * Returns whether or not logging is enabled for this conversation.
|
|
572 *
|
|
573 * @return @c TRUE if logging is enabled, or @c FALSE otherwise.
|
|
574 */
|
|
575 gboolean gaim_conversation_is_logging(const struct gaim_conversation *conv);
|
|
576
|
|
577 /**
|
|
578 * Returns the specified conversation's send history.
|
|
579 *
|
|
580 * @param conv The conversation.
|
|
581 *
|
|
582 * @return The conversation's send history.
|
|
583 */
|
|
584 GList *gaim_conversation_get_send_history(
|
|
585 const struct gaim_conversation *conv);
|
|
586
|
|
587 /**
|
|
588 * Sets the specified conversation's history.
|
|
589 *
|
|
590 * @param conv The conversation.
|
|
591 * @param history The history.
|
|
592 */
|
|
593 void gaim_conversation_set_history(struct gaim_conversation *conv,
|
|
594 GString *history);
|
|
595
|
|
596 /**
|
|
597 * Returns the specified conversation's history.
|
|
598 *
|
|
599 * @param conv The conversation.
|
|
600 *
|
|
601 * @return The conversation's history.
|
|
602 */
|
|
603 GString *gaim_conversation_get_history(const struct gaim_conversation *conv);
|
|
604
|
|
605 /**
|
|
606 * Returns the specified conversation's parent window.
|
|
607 *
|
|
608 * @param conv The conversation.
|
|
609 *
|
|
610 * @return The conversation's parent window.
|
|
611 */
|
|
612 struct gaim_window *gaim_conversation_get_window(
|
|
613 const struct gaim_conversation *conv);
|
|
614
|
|
615 /**
|
|
616 * Returns the specified conversation's IM-specific data.
|
|
617 *
|
|
618 * If the conversation type is not GAIM_CONV_IM, this will return @c NULL.
|
|
619 *
|
|
620 * @param conv The conversation.
|
|
621 *
|
|
622 * @return The IM-specific data.
|
|
623 */
|
|
624 struct gaim_im *gaim_conversation_get_im_data(
|
|
625 const struct gaim_conversation *conv);
|
|
626
|
|
627 #define GAIM_IM(c) (gaim_conversation_get_im_data(c))
|
|
628
|
|
629 /**
|
|
630 * Returns the specified conversation's chat-specific data.
|
|
631 *
|
|
632 * If the conversation type is not GAIM_CONV_CHAT, this will return @c NULL.
|
|
633 *
|
|
634 * @param conv The conversation.
|
|
635 *
|
|
636 * @return The chat-specific data.
|
|
637 */
|
|
638 struct gaim_chat *gaim_conversation_get_chat_data(
|
|
639 const struct gaim_conversation *conv);
|
|
640
|
|
641 #define GAIM_CHAT(c) (gaim_conversation_get_chat_data(c))
|
|
642
|
|
643 /**
|
|
644 * Returns a list of all conversations.
|
|
645 *
|
|
646 * This list includes both IMs and chats.
|
|
647 *
|
|
648 * @return A GList of all conversations.
|
|
649 */
|
|
650 GList *gaim_get_conversations(void);
|
|
651
|
|
652 /**
|
|
653 * Returns a list of all IMs.
|
|
654 *
|
|
655 * @return A GList of all IMs.
|
|
656 */
|
|
657 GList *gaim_get_ims(void);
|
|
658
|
|
659 /**
|
|
660 * Returns a list of all chats.
|
|
661 *
|
|
662 * @return A GList of all chats.
|
|
663 */
|
|
664 GList *gaim_get_chats(void);
|
|
665
|
|
666 /**
|
|
667 * Finds the conversation with the specified name.
|
|
668 *
|
|
669 * @param name The name of the conversation.
|
|
670 *
|
|
671 * @return The conversation if found, or @c NULL otherwise.
|
|
672 */
|
|
673 struct gaim_conversation *gaim_find_conversation(const char *name);
|
|
674
|
|
675 /**
|
|
676 * Finds a conversation with the specified name and user.
|
|
677 *
|
|
678 * @param name The name of the conversation.
|
|
679 * @param user The aim_user associated with the conversation.
|
|
680 *
|
|
681 * @return The conversation if found, or @c NULL otherwise.
|
|
682 */
|
|
683 struct gaim_conversation *gaim_find_conversation_with_user(
|
|
684 const char *name, const struct aim_user *user);
|
|
685
|
|
686 /**
|
|
687 * Writes to a conversation window.
|
|
688 *
|
|
689 * This function should not be used to write IM or chat messages. Use
|
|
690 * gaim_im_write() and gaim_chat_write() instead. Those functions will
|
|
691 * most likely call this anyway, but they may do their own formatting,
|
|
692 * sound playback, etc.
|
|
693 *
|
|
694 * This can be used to write generic messages, such as "so and so closed
|
|
695 * the conversation window."
|
|
696 *
|
|
697 * @param conv The conversation.
|
|
698 * @param who The user who sent the message.
|
|
699 * @param message The message.
|
|
700 * @param length The length of the message.
|
|
701 * @param flags The flags.
|
|
702 * @param mtime The time the message was sent.
|
|
703 *
|
|
704 * @see gaim_im_write()
|
|
705 * @see gaim_chat_write()
|
|
706 */
|
|
707 void gaim_conversation_write(struct gaim_conversation *conv, const char *who,
|
|
708 const char *message, size_t length, int flags,
|
|
709 time_t mtime);
|
|
710
|
|
711 /**
|
|
712 * Updates the progress bar on a conversation window
|
|
713 * (if one exists in the UI).
|
|
714 *
|
|
715 * This is used for loading images typically.
|
|
716 *
|
|
717 * @param conv The conversation.
|
|
718 * @param percent The percentage.
|
|
719 */
|
|
720 void gaim_conversation_update_progress(struct gaim_conversation *conv,
|
|
721 float percent);
|
|
722
|
|
723 /**
|
|
724 * Updates the visual status and UI of a conversation.
|
|
725 *
|
|
726 * @param conv The conversation.
|
|
727 * @param type The update type.
|
|
728 */
|
|
729 void gaim_conversation_update(struct gaim_conversation *conv,
|
|
730 GaimConvUpdateType type);
|
|
731
|
|
732 /**
|
|
733 * Calls a function on each conversation.
|
|
734 *
|
|
735 * @param func The function.
|
|
736 */
|
|
737 void gaim_conversation_foreach(void (*func)(struct gaim_conversation *conv));
|
|
738
|
|
739 /*@}*/
|
|
740
|
|
741
|
|
742 /**************************************************************************/
|
|
743 /** @name IM Conversation API */
|
|
744 /**************************************************************************/
|
|
745 /*@{*/
|
|
746
|
|
747 /**
|
|
748 * Gets an IM's parent conversation.
|
|
749 *
|
|
750 * @param im The IM.
|
|
751 *
|
|
752 * @return The parent conversation.
|
|
753 */
|
|
754 struct gaim_conversation *gaim_im_get_conversation(struct gaim_im *im);
|
|
755
|
|
756 /**
|
|
757 * Sets the IM's typing state.
|
|
758 *
|
|
759 * @param im The IM.
|
|
760 * @param state The typing state.
|
|
761 */
|
|
762 void gaim_im_set_typing_state(struct gaim_im *im, int state);
|
|
763
|
|
764 /**
|
|
765 * Returns the IM's typing state.
|
|
766 *
|
|
767 * @param im The IM.
|
|
768 *
|
|
769 * @return The IM's typing state.
|
|
770 */
|
|
771 int gaim_im_get_typing_state(const struct gaim_im *im);
|
|
772
|
|
773 /**
|
|
774 * Starts the IM's typing timeout.
|
|
775 *
|
|
776 * @param im The IM.
|
|
777 * @param timeout The timeout.
|
|
778 */
|
|
779 void gaim_im_start_typing_timeout(struct gaim_im *im, int timeout);
|
|
780
|
|
781 /**
|
|
782 * Stops the IM's typing timeout.
|
|
783 *
|
|
784 * @param im The IM.
|
|
785 */
|
|
786 void gaim_im_stop_typing_timeout(struct gaim_im *im);
|
|
787
|
|
788 /**
|
|
789 * Returns the IM's typing timeout.
|
|
790 *
|
|
791 * @param im The IM.
|
|
792 *
|
|
793 * @return The timeout.
|
|
794 */
|
|
795 guint gaim_im_get_typing_timeout(const struct gaim_im *im);
|
|
796
|
|
797 /**
|
|
798 * Sets the IM's time until it should send another typing notification.
|
|
799 *
|
|
800 * @param im The IM.
|
|
801 * @param val The time.
|
|
802 */
|
|
803 void gaim_im_set_type_again(struct gaim_im *im, time_t val);
|
|
804
|
|
805 /**
|
|
806 * Returns the IM's time until it should send another typing notification.
|
|
807 *
|
|
808 * @param im The IM.
|
|
809 *
|
|
810 * @return The time.
|
|
811 */
|
|
812 time_t gaim_im_get_type_again(const struct gaim_im *im);
|
|
813
|
|
814 /**
|
|
815 * Starts the IM's type again timeout.
|
|
816 *
|
|
817 * @param im The IM.
|
|
818 */
|
|
819 void gaim_im_start_type_again_timeout(struct gaim_im *im);
|
|
820
|
|
821 /**
|
|
822 * Stops the IM's type again timeout.
|
|
823 *
|
|
824 * @param im The IM.
|
|
825 */
|
|
826 void gaim_im_stop_type_again_timeout(struct gaim_im *im);
|
|
827
|
|
828 /**
|
|
829 * Returns the IM's type again timeout interval.
|
|
830 *
|
|
831 * @param im The IM.
|
|
832 *
|
|
833 * @return The type again timeout interval.
|
|
834 */
|
|
835 guint gaim_im_get_type_again_timeout(const struct gaim_im *im);
|
|
836
|
|
837 /**
|
|
838 * Updates the visual typing notification for an IM conversation.
|
|
839 *
|
|
840 * @param im The IM.
|
|
841 */
|
|
842 void gaim_im_update_typing(struct gaim_im *im);
|
|
843
|
|
844 /**
|
|
845 * Writes to an IM.
|
|
846 *
|
|
847 * The @a len parameter is used for writing binary data, such as an
|
|
848 * image. If @c message is text, specify -1 for @a len.
|
|
849 *
|
|
850 * @param im The IM.
|
|
851 * @param who The user who sent the message.
|
|
852 * @param message The message to write.
|
|
853 * @param len The length of the message, or -1 to specify the length
|
|
854 * of @a message.
|
|
855 * @param flag The flags.
|
|
856 * @param mtime The time the message was sent.
|
|
857 */
|
|
858 void gaim_im_write(struct gaim_im *im, const char *who,
|
|
859 const char *message, size_t len, int flag, time_t mtime);
|
|
860
|
|
861 /**
|
|
862 * Sends a message to this IM conversation.
|
|
863 *
|
|
864 * @param im The IM.
|
|
865 * @param message The message to send.
|
|
866 */
|
|
867 void gaim_im_send(struct gaim_im *im, const char *message);
|
|
868
|
|
869 /*@}*/
|
|
870
|
|
871
|
|
872 /**************************************************************************/
|
|
873 /** @name Chat Conversation API */
|
|
874 /**************************************************************************/
|
|
875 /*@{*/
|
|
876
|
|
877 /**
|
|
878 * Gets a chat's parent conversation.
|
|
879 *
|
|
880 * @param chat The chat.
|
|
881 *
|
|
882 * @return The parent conversation.
|
|
883 */
|
|
884 struct gaim_conversation *gaim_chat_get_conversation(struct gaim_chat *chat);
|
|
885
|
|
886 /**
|
|
887 * Sets the list of users in the chat room.
|
|
888 *
|
|
889 * @param chat The chat.
|
|
890 * @param users The list of users.
|
|
891 *
|
|
892 * @return The list passed.
|
|
893 */
|
|
894 GList *gaim_chat_set_users(struct gaim_chat *chat, GList *users);
|
|
895
|
|
896 /**
|
|
897 * Returns a list of users in the chat room.
|
|
898 *
|
|
899 * @param chat The chat.
|
|
900 *
|
|
901 * @return The list of users.
|
|
902 */
|
|
903 GList *gaim_chat_get_users(const struct gaim_chat *chat);
|
|
904
|
|
905 /**
|
|
906 * Ignores a user in a chat room.
|
|
907 *
|
|
908 * @param chat The chat.
|
|
909 * @param name The name of the user.
|
|
910 */
|
|
911 void gaim_chat_ignore(struct gaim_chat *chat, const char *name);
|
|
912
|
|
913 /**
|
|
914 * Unignores a user in a chat room.
|
|
915 *
|
|
916 * @param chat The chat.
|
|
917 * @param name The name of the user.
|
|
918 */
|
|
919 void gaim_chat_unignore(struct gaim_chat *chat, const char *name);
|
|
920
|
|
921 /**
|
|
922 * Sets the list of ignored users in the chat room.
|
|
923 *
|
|
924 * @param chat The chat.
|
|
925 * @param ignored The list of ignored users.
|
|
926 *
|
|
927 * @return The list passed.
|
|
928 */
|
|
929 GList *gaim_chat_set_ignored(struct gaim_chat *chat, GList *ignored);
|
|
930
|
|
931 /**
|
|
932 * Returns the list of ignored users in the chat room.
|
|
933 *
|
|
934 * @param chat The chat.
|
|
935 *
|
|
936 * @return The list of ignored users.
|
|
937 */
|
|
938 GList *gaim_chat_get_ignored(const struct gaim_chat *chat);
|
|
939
|
|
940 /**
|
|
941 * Returns the actual name of the specified ignored user, if it exists in
|
|
942 * the ignore list.
|
|
943 *
|
|
944 * If the user found contains a prefix, such as '+' or '\@', this is also
|
|
945 * returned. The username passed to the function does not have to have this
|
|
946 * formatting.
|
|
947 *
|
|
948 * @param chat The chat.
|
|
949 * @param user The user to check in the ignore list.
|
|
950 *
|
|
951 * @return The ignored user if found, complete with prefixes, or @c NULL
|
|
952 * if not found.
|
|
953 */
|
|
954 const char *gaim_chat_get_ignored_user(const struct gaim_chat *chat,
|
|
955 const char *user);
|
|
956
|
|
957 /**
|
|
958 * Returns @c TRUE if the specified user is ignored.
|
|
959 *
|
|
960 * @param chat The chat.
|
|
961 * @param user The user.
|
|
962 *
|
|
963 * @return @c TRUE if the user is in the ignore list; @c FALSE otherwise.
|
|
964 */
|
|
965 gboolean gaim_chat_is_user_ignored(const struct gaim_chat *chat,
|
|
966 const char *user);
|
|
967
|
|
968 /**
|
|
969 * Sets the chat room's topic.
|
|
970 *
|
|
971 * @param chat The chat.
|
|
972 * @param who The user that set the topic.
|
|
973 * @param topic The topic.
|
|
974 */
|
|
975 void gaim_chat_set_topic(struct gaim_chat *chat, const char *who,
|
|
976 const char *topic);
|
|
977
|
|
978 /**
|
|
979 * Returns the chat room's topic.
|
|
980 *
|
|
981 * @param chat The chat.
|
|
982 *
|
|
983 * @return The chat's topic.
|
|
984 */
|
|
985 const char *gaim_chat_get_topic(const struct gaim_chat *chat);
|
|
986
|
|
987 /**
|
|
988 * Sets the chat room's ID.
|
|
989 *
|
|
990 * @param chat The chat.
|
|
991 * @param id The ID.
|
|
992 */
|
|
993 void gaim_chat_set_id(struct gaim_chat *chat, int id);
|
|
994
|
|
995 /**
|
|
996 * Returns the chat room's ID.
|
|
997 *
|
|
998 * @param chat The chat.
|
|
999 *
|
|
1000 * @return The ID.
|
|
1001 */
|
|
1002 int gaim_chat_get_id(const struct gaim_chat *chat);
|
|
1003
|
|
1004 /**
|
|
1005 * Writes to a chat.
|
|
1006 *
|
|
1007 * @param chat The chat.
|
|
1008 * @param who The user who sent the message.
|
|
1009 * @param message The message to write.
|
|
1010 * @param flag The flags.
|
|
1011 * @param mtime The time the message was sent.
|
|
1012 */
|
|
1013 void gaim_chat_write(struct gaim_chat *chat, const char *who,
|
|
1014 const char *message, int flag, time_t mtime);
|
|
1015
|
|
1016 /**
|
|
1017 * Sends a message to this chat conversation.
|
|
1018 *
|
|
1019 * @param chat The chat.
|
|
1020 * @param message The message to send.
|
|
1021 */
|
|
1022 void gaim_chat_send(struct gaim_chat *chat, const char *message);
|
|
1023
|
|
1024 /**
|
|
1025 * Adds a user to a chat.
|
|
1026 *
|
|
1027 * @param chat The chat.
|
|
1028 * @param user The user to add.
|
|
1029 * @param extra_msg An extra message to display with the join message.
|
|
1030 */
|
|
1031 void gaim_chat_add_user(struct gaim_chat *chat, const char *user,
|
|
1032 const char *extra_msg);
|
|
1033
|
|
1034 /**
|
|
1035 * Renames a user in a chat.
|
|
1036 *
|
|
1037 * @param chat The chat.
|
|
1038 * @param old_user The old username.
|
|
1039 * @param new_user The new username.
|
|
1040 */
|
|
1041 void gaim_chat_rename_user(struct gaim_chat *chat, const char *old_user,
|
|
1042 const char *new_user);
|
|
1043
|
|
1044 /**
|
|
1045 * Removes a user from a chat, optionally with a reason.
|
|
1046 *
|
|
1047 * @param chat The chat.
|
|
1048 * @param user The user that is being removed.
|
|
1049 * @param reason The optional reason given for the removal. Can be @c NULL.
|
|
1050 */
|
|
1051 void gaim_chat_remove_user(struct gaim_chat *chat, const char *user,
|
|
1052 const char *reason);
|
|
1053
|
|
1054 /**
|
|
1055 * Finds a chat with the specified chat ID.
|
|
1056 *
|
|
1057 * @param gc The gaim_connection.
|
|
1058 * @param id The chat ID.
|
|
1059 *
|
|
1060 * @return The chat conversation.
|
|
1061 */
|
|
1062 struct gaim_conversation *gaim_find_chat(struct gaim_connection *gc, int id);
|
|
1063
|
|
1064 /*@}*/
|
|
1065
|
|
1066 #endif /* _CONVERSATION_H_ */
|