Mercurial > pidgin.yaz
comparison src/conversation.h @ 11581:9b3833da6840
[gaim-migrate @ 13851]
goodbye GaimConvWindow.
Still some problems with this patch:
- Scarey warnings console with gaim -d when closing tab
- I tried to seperate gtkconv and gtkconvwin, but failed,
as a result it has its own header, but the code is in the same
file, which is rather weird. Also some code got moved around
for no good reason. Feel free to move it back or reorganize it.
- I broke the gesters plugin, and just disabled it. Hopefully someone
with more time will fix it, it shouldn't take long, but I didn't
feel like bothering.
- This list is incomplete.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Sun, 02 Oct 2005 00:32:49 +0000 |
parents | 16b0da1f376f |
children | 38bbb0f15453 |
comparison
equal
deleted
inserted
replaced
11580:24169af08585 | 11581:9b3833da6840 |
---|---|
29 | 29 |
30 /**************************************************************************/ | 30 /**************************************************************************/ |
31 /** Data Structures */ | 31 /** Data Structures */ |
32 /**************************************************************************/ | 32 /**************************************************************************/ |
33 | 33 |
34 typedef struct _GaimConvWindowUiOps GaimConvWindowUiOps; | 34 |
35 typedef struct _GaimConvWindow GaimConvWindow; | |
36 typedef struct _GaimConversationUiOps GaimConversationUiOps; | 35 typedef struct _GaimConversationUiOps GaimConversationUiOps; |
37 typedef struct _GaimConversation GaimConversation; | 36 typedef struct _GaimConversation GaimConversation; |
38 typedef struct _GaimConvIm GaimConvIm; | 37 typedef struct _GaimConvIm GaimConvIm; |
39 typedef struct _GaimConvChat GaimConvChat; | 38 typedef struct _GaimConvChat GaimConvChat; |
40 typedef struct _GaimConvChatBuddy GaimConvChatBuddy; | 39 typedef struct _GaimConvChatBuddy GaimConvChatBuddy; |
133 GAIM_CBFLAGS_VOICE = 0x0001, /**< Voiced user or "Participant" */ | 132 GAIM_CBFLAGS_VOICE = 0x0001, /**< Voiced user or "Participant" */ |
134 GAIM_CBFLAGS_HALFOP = 0x0002, /**< Half-op */ | 133 GAIM_CBFLAGS_HALFOP = 0x0002, /**< Half-op */ |
135 GAIM_CBFLAGS_OP = 0x0004, /**< Channel Op or Moderator */ | 134 GAIM_CBFLAGS_OP = 0x0004, /**< Channel Op or Moderator */ |
136 GAIM_CBFLAGS_FOUNDER = 0x0008, /**< Channel Founder */ | 135 GAIM_CBFLAGS_FOUNDER = 0x0008, /**< Channel Founder */ |
137 GAIM_CBFLAGS_TYPING = 0x0010, /**< Currently typing */ | 136 GAIM_CBFLAGS_TYPING = 0x0010, /**< Currently typing */ |
138 | 137 |
139 | 138 |
140 } GaimConvChatBuddyFlags; | 139 } GaimConvChatBuddyFlags; |
141 | 140 |
142 #include "account.h" | 141 #include "account.h" |
143 #include "buddyicon.h" | 142 #include "buddyicon.h" |
144 #include "log.h" | 143 #include "log.h" |
145 #include "server.h" | 144 #include "server.h" |
146 | 145 |
147 /** | 146 /** |
148 * Conversation window operations. | |
149 * | |
150 * Any UI representing a window must assign a filled-out gaim_conv_window_ops | |
151 * structure to the GaimConvWindow. | |
152 */ | |
153 struct _GaimConvWindowUiOps | |
154 { | |
155 GaimConversationUiOps *(*get_conversation_ui_ops)(void); | |
156 | |
157 void (*new_window)(GaimConvWindow *win); | |
158 void (*destroy_window)(GaimConvWindow *win); | |
159 | |
160 void (*show)(GaimConvWindow *win); | |
161 void (*hide)(GaimConvWindow *win); | |
162 void (*raise)(GaimConvWindow *win); | |
163 | |
164 void (*switch_conversation)(GaimConvWindow *win, GaimConversation *conv); | |
165 void (*add_conversation)(GaimConvWindow *win, GaimConversation *conv); | |
166 void (*remove_conversation)(GaimConvWindow *win, GaimConversation *conv); | |
167 | |
168 GaimConversation *(*get_active_conversation)(const GaimConvWindow *win); | |
169 gboolean (*has_focus)(GaimConvWindow *win); | |
170 }; | |
171 | |
172 /** | |
173 * Conversation operations and events. | 147 * Conversation operations and events. |
174 * | 148 * |
175 * Any UI representing a conversation must assign a filled-out | 149 * Any UI representing a conversation must assign a filled-out |
176 * GaimConversationUiOps structure to the GaimConversation. | 150 * GaimConversationUiOps structure to the GaimConversation. |
177 */ | 151 */ |
178 struct _GaimConversationUiOps | 152 struct _GaimConversationUiOps |
179 { | 153 { |
154 void (*create_conversation)(GaimConversation *conv); | |
180 void (*destroy_conversation)(GaimConversation *conv); | 155 void (*destroy_conversation)(GaimConversation *conv); |
181 void (*write_chat)(GaimConversation *conv, const char *who, | 156 void (*write_chat)(GaimConversation *conv, const char *who, |
182 const char *message, GaimMessageFlags flags, | 157 const char *message, GaimMessageFlags flags, |
183 time_t mtime); | 158 time_t mtime); |
184 void (*write_im)(GaimConversation *conv, const char *who, | 159 void (*write_im)(GaimConversation *conv, const char *who, |
193 const char *new_name, const char *new_alias); | 168 const char *new_name, const char *new_alias); |
194 void (*chat_remove_user)(GaimConversation *conv, const char *user); | 169 void (*chat_remove_user)(GaimConversation *conv, const char *user); |
195 void (*chat_remove_users)(GaimConversation *conv, GList *users); | 170 void (*chat_remove_users)(GaimConversation *conv, GList *users); |
196 void (*chat_update_user)(GaimConversation *conv, const char *user); | 171 void (*chat_update_user)(GaimConversation *conv, const char *user); |
197 | 172 |
198 void (*update_progress)(GaimConversation *conv, float percent); | |
199 | 173 |
200 gboolean (*has_focus)(GaimConversation *conv); | 174 gboolean (*has_focus)(GaimConversation *conv); |
201 | 175 |
202 /* Custom Smileys */ | 176 /* Custom Smileys */ |
203 gboolean (*custom_smiley_add)(GaimConversation *conv, const char *smile); | 177 gboolean (*custom_smiley_add)(GaimConversation *conv, const char *smile); |
206 void (*custom_smiley_close)(GaimConversation *conv, const char *smile); | 180 void (*custom_smiley_close)(GaimConversation *conv, const char *smile); |
207 | 181 |
208 /* Events */ | 182 /* Events */ |
209 void (*updated)(GaimConversation *conv, GaimConvUpdateType type); | 183 void (*updated)(GaimConversation *conv, GaimConvUpdateType type); |
210 | 184 |
211 }; | |
212 | |
213 /** | |
214 * A core representation of a graphical window containing one or more | |
215 * conversations. | |
216 */ | |
217 struct _GaimConvWindow | |
218 { | |
219 GList *conversations; /**< The conversations in the window. */ | |
220 size_t conversation_count; /**< The number of conversations. */ | |
221 | |
222 GaimConvWindowUiOps *ui_ops; /**< UI-specific window operations. */ | |
223 void *ui_data; /**< UI-specific data. */ | |
224 }; | 185 }; |
225 | 186 |
226 /** | 187 /** |
227 * Data specific to Instant Messages. | 188 * Data specific to Instant Messages. |
228 */ | 189 */ |
265 }; | 226 }; |
266 | 227 |
267 /** | 228 /** |
268 * A core representation of a conversation between two or more people. | 229 * A core representation of a conversation between two or more people. |
269 * | 230 * |
270 * The conversation can be an IM or a chat. Each conversation is kept | 231 * The conversation can be an IM or a chat. |
271 * in a GaimConvWindow and has a UI representation. | |
272 */ | 232 */ |
273 struct _GaimConversation | 233 struct _GaimConversation |
274 { | 234 { |
275 GaimConversationType type; /**< The type of conversation. */ | 235 GaimConversationType type; /**< The type of conversation. */ |
276 | 236 |
277 GaimAccount *account; /**< The user using this conversation. */ | 237 GaimAccount *account; /**< The user using this conversation. */ |
278 GaimConvWindow *window; /**< The parent window. */ | 238 |
279 | |
280 int conversation_pos; /**< The position in the window's list. */ | |
281 | 239 |
282 char *name; /**< The name of the conversation. */ | 240 char *name; /**< The name of the conversation. */ |
283 char *title; /**< The window title. */ | 241 char *title; /**< The window title. */ |
284 | 242 |
285 gboolean logging; /**< The status of logging. */ | 243 gboolean logging; /**< The status of logging. */ |
305 | 263 |
306 GaimConnectionFlags features; /**< The supported features */ | 264 GaimConnectionFlags features; /**< The supported features */ |
307 | 265 |
308 }; | 266 }; |
309 | 267 |
310 typedef void (*GaimConvPlacementFunc)(GaimConversation *); | |
311 | |
312 #ifdef __cplusplus | 268 #ifdef __cplusplus |
313 extern "C" { | 269 extern "C" { |
314 #endif | 270 #endif |
315 | |
316 /**************************************************************************/ | |
317 /** @name Conversation Window API */ | |
318 /**************************************************************************/ | |
319 /*@{*/ | |
320 | |
321 /** | |
322 * Creates a new conversation window. | |
323 * | |
324 * This window is added to the list of windows, but is not shown until | |
325 * gaim_conv_window_show() is called. | |
326 * | |
327 * @return The new conversation window. | |
328 */ | |
329 GaimConvWindow *gaim_conv_window_new(void); | |
330 | |
331 /** | |
332 * Destroys the specified conversation window and all conversations in it. | |
333 * | |
334 * @param win The window to destroy. | |
335 */ | |
336 void gaim_conv_window_destroy(GaimConvWindow *win); | |
337 | |
338 /** | |
339 * Shows the specified conversation window. | |
340 * | |
341 * @param win The window. | |
342 */ | |
343 void gaim_conv_window_show(GaimConvWindow *win); | |
344 | |
345 /** | |
346 * Hides the specified conversation window. | |
347 * | |
348 * @param win The window. | |
349 */ | |
350 void gaim_conv_window_hide(GaimConvWindow *win); | |
351 | |
352 /** | |
353 * Raises the specified conversation window. | |
354 * | |
355 * @param win The window. | |
356 */ | |
357 void gaim_conv_window_raise(GaimConvWindow *win); | |
358 | |
359 /** | |
360 * Sets the specified window's UI window operations structure. | |
361 * | |
362 * @param win The window. | |
363 * @param ops The UI window operations structure. | |
364 */ | |
365 void gaim_conv_window_set_ui_ops(GaimConvWindow *win, | |
366 GaimConvWindowUiOps *ops); | |
367 | |
368 /** | |
369 * Returns the specified window's UI window operations structure. | |
370 * | |
371 * @param win The window. | |
372 * | |
373 * @return The UI window operations structure. | |
374 */ | |
375 GaimConvWindowUiOps *gaim_conv_window_get_ui_ops(const GaimConvWindow *win); | |
376 | |
377 /** | |
378 * Adds a conversation to this window. | |
379 * | |
380 * If the conversation already has a parent window, this will do nothing. | |
381 * | |
382 * @param win The window. | |
383 * @param conv The conversation. | |
384 * | |
385 * @return The new index of the conversation in the window. | |
386 */ | |
387 int gaim_conv_window_add_conversation(GaimConvWindow *win, | |
388 GaimConversation *conv); | |
389 | |
390 /** | |
391 * Removes the conversation from the window. | |
392 * | |
393 * @param win The window. | |
394 * @param conv The conversation. | |
395 * | |
396 * @return The conversation removed. | |
397 */ | |
398 GaimConversation *gaim_conv_window_remove_conversation(GaimConvWindow *win, | |
399 GaimConversation *conv); | |
400 /** | |
401 * Returns the number of conversations in the window. | |
402 * | |
403 * @param win The window. | |
404 * | |
405 * @return The number of conversations. | |
406 */ | |
407 size_t gaim_conv_window_get_conversation_count(const GaimConvWindow *win); | |
408 | |
409 /** | |
410 * Switches the active conversation to the one at the specified index. | |
411 * | |
412 * @param win The window. | |
413 * @param conv The converstion to switch to. | |
414 */ | |
415 void gaim_conv_window_switch_conversation(GaimConvWindow *win, | |
416 GaimConversation *conv); | |
417 | |
418 /** | |
419 * Returns the active conversation in the window. | |
420 * | |
421 * @param win The window. | |
422 * | |
423 * @return The active conversation. | |
424 */ | |
425 GaimConversation *gaim_conv_window_get_active_conversation( | |
426 const GaimConvWindow *win); | |
427 | |
428 /** | |
429 * Determines if a conversation window has focus | |
430 * | |
431 * @param win The window. | |
432 * | |
433 * @return @c TRUE if the conversation window has focus, @c FALSE if | |
434 * it does not or the UI does not have a concept of window focus | |
435 */ | |
436 gboolean gaim_conv_window_has_focus(GaimConvWindow *win); | |
437 | |
438 /** | |
439 * Returns the list of conversations in the specified window. | |
440 * | |
441 * @param win The window. | |
442 * | |
443 * @return The list of conversations. | |
444 */ | |
445 GList *gaim_conv_window_get_conversations(const GaimConvWindow *win); | |
446 | |
447 /** | |
448 * Returns a list of all windows. | |
449 * | |
450 * @return A list of windows. | |
451 */ | |
452 GList *gaim_get_windows(void); | |
453 | |
454 /** | |
455 * Returns the first window containing a conversation of the specified type. | |
456 * | |
457 * @param type The conversation type. | |
458 * | |
459 * @return The window if found, or @c NULL if not found. | |
460 */ | |
461 GaimConvWindow *gaim_get_first_window_with_type(GaimConversationType type); | |
462 /** | |
463 * Returns the last window containing a conversation of the specified type. | |
464 * | |
465 * @param type The conversation type. | |
466 * | |
467 * @return The window if found, or @c NULL if not found. | |
468 */ | |
469 GaimConvWindow *gaim_get_last_window_with_type(GaimConversationType type); | |
470 | |
471 /*@}*/ | |
472 | 271 |
473 /**************************************************************************/ | 272 /**************************************************************************/ |
474 /** @name Conversation API */ | 273 /** @name Conversation API */ |
475 /**************************************************************************/ | 274 /**************************************************************************/ |
476 /*@{*/ | 275 /*@{*/ |
517 */ | 316 */ |
518 void gaim_conversation_set_ui_ops(GaimConversation *conv, | 317 void gaim_conversation_set_ui_ops(GaimConversation *conv, |
519 GaimConversationUiOps *ops); | 318 GaimConversationUiOps *ops); |
520 | 319 |
521 /** | 320 /** |
321 * Sets the default conversation UI operations structure. | |
322 * | |
323 * @param ops The UI conversation operations structure. | |
324 */ | |
325 void gaim_conversations_set_ui_ops(GaimConversationUiOps *ops); | |
326 | |
327 /** | |
522 * Returns the specified conversation's UI operations structure. | 328 * Returns the specified conversation's UI operations structure. |
523 * | 329 * |
524 * @param conv The conversation. | 330 * @param conv The conversation. |
525 * | 331 * |
526 * @return The operations structure. | 332 * @return The operations structure. |
648 * @param conv The conversation. | 454 * @param conv The conversation. |
649 * | 455 * |
650 * @return The conversation's send history. | 456 * @return The conversation's send history. |
651 */ | 457 */ |
652 GList *gaim_conversation_get_send_history(const GaimConversation *conv); | 458 GList *gaim_conversation_get_send_history(const GaimConversation *conv); |
653 | |
654 /** | |
655 * Returns the specified conversation's parent window. | |
656 * | |
657 * @param conv The conversation. | |
658 * | |
659 * @return The conversation's parent window. | |
660 */ | |
661 GaimConvWindow *gaim_conversation_get_window(const GaimConversation *conv); | |
662 | 459 |
663 /** | 460 /** |
664 * Returns the specified conversation's IM-specific data. | 461 * Returns the specified conversation's IM-specific data. |
665 * | 462 * |
666 * If the conversation type is not GAIM_CONV_TYPE_IM, this will return @c NULL. | 463 * If the conversation type is not GAIM_CONV_TYPE_IM, this will return @c NULL. |
778 | 575 |
779 /** | 576 /** |
780 Get the features supported by the given conversation. | 577 Get the features supported by the given conversation. |
781 @param conv The conversation | 578 @param conv The conversation |
782 */ | 579 */ |
783 GaimConnectionFlags gaim_conversation_get_features(GaimConversation *conv); | 580 GaimConnectionFlags gaim_conversation_get_features(GaimConversation *conv); |
784 | |
785 | |
786 /** | |
787 * Updates the progress bar on a conversation window | |
788 * (if one exists in the UI). | |
789 * | |
790 * This is used for loading images typically. | |
791 * | |
792 * @param conv The conversation. | |
793 * @param percent The percentage. | |
794 */ | |
795 void gaim_conversation_update_progress(GaimConversation *conv, float percent); | |
796 | 581 |
797 /** | 582 /** |
798 * Determines if a conversation has focus | 583 * Determines if a conversation has focus |
799 * | 584 * |
800 * @param conv The conversation. | 585 * @param conv The conversation. |
959 const char *message, GaimMessageFlags flags, | 744 const char *message, GaimMessageFlags flags, |
960 time_t mtime); | 745 time_t mtime); |
961 | 746 |
962 /** | 747 /** |
963 * Presents an IM-error to the user | 748 * Presents an IM-error to the user |
964 * | 749 * |
965 * This is a helper function to find a conversation, write an error to it, and | 750 * This is a helper function to find a conversation, write an error to it, and |
966 * raise the window. If a conversation with this user doesn't already exist, | 751 * raise the window. If a conversation with this user doesn't already exist, |
967 * the function will return FALSE and the calling function can attempt to present | 752 * the function will return FALSE and the calling function can attempt to present |
968 * the error another way (gaim_notify_error, most likely) | 753 * the error another way (gaim_notify_error, most likely) |
969 * | 754 * |
1373 void gaim_conv_chat_cb_destroy(GaimConvChatBuddy *cb); | 1158 void gaim_conv_chat_cb_destroy(GaimConvChatBuddy *cb); |
1374 | 1159 |
1375 /*@}*/ | 1160 /*@}*/ |
1376 | 1161 |
1377 /**************************************************************************/ | 1162 /**************************************************************************/ |
1378 /** @name Conversation Placement API */ | |
1379 /**************************************************************************/ | |
1380 /*@{*/ | |
1381 | |
1382 /** | |
1383 * Returns a GList containing the IDs and Names of the registered placement | |
1384 * functions. | |
1385 * | |
1386 * @return The list of IDs and names. | |
1387 */ | |
1388 GList *gaim_conv_placement_get_options(void); | |
1389 | |
1390 /** | |
1391 * Adds a conversation placement function to the list of possible functions. | |
1392 * | |
1393 * @param id The unique ID of the placement function. | |
1394 * @param name The name of the function. | |
1395 * @param fnc A pointer to the function. | |
1396 */ | |
1397 void gaim_conv_placement_add_fnc(const char *id, const char *name, | |
1398 GaimConvPlacementFunc fnc); | |
1399 | |
1400 /** | |
1401 * Removes a conversation placement function from the list of possible | |
1402 * functions. | |
1403 * | |
1404 * @param id The id of the function. | |
1405 */ | |
1406 void gaim_conv_placement_remove_fnc(const char *id); | |
1407 | |
1408 /** | |
1409 * Returns the name of the conversation placement function at the | |
1410 * specified id. | |
1411 * | |
1412 * @param id The id. | |
1413 * | |
1414 * @return The name of the function, or @c NULL if this id is invalid. | |
1415 */ | |
1416 const char *gaim_conv_placement_get_name(const char *id); | |
1417 | |
1418 /** | |
1419 * Returns a pointer to the conversation placement function at the | |
1420 * specified id. | |
1421 * | |
1422 * @param id The id. | |
1423 * | |
1424 * @return A pointer to the function. | |
1425 */ | |
1426 GaimConvPlacementFunc gaim_conv_placement_get_fnc(const char *id); | |
1427 | |
1428 /** | |
1429 * Sets the current conversation placement function. | |
1430 * | |
1431 * @param func The new conversation placement function. | |
1432 */ | |
1433 void gaim_conv_placement_set_current_func(GaimConvPlacementFunc func); | |
1434 | |
1435 /** | |
1436 * Returns the current conversation placement function. | |
1437 * | |
1438 * @return The current conversation placement function. | |
1439 */ | |
1440 GaimConvPlacementFunc gaim_conv_placement_get_current_func(void); | |
1441 | |
1442 /*@}*/ | |
1443 | |
1444 /**************************************************************************/ | |
1445 /** @name UI Registration Functions */ | |
1446 /**************************************************************************/ | |
1447 /*@{*/ | |
1448 | |
1449 /** | |
1450 * Sets the UI operations structure to be used in all gaim conversation | |
1451 * windows. | |
1452 * | |
1453 * @param ops The UI operations structure. | |
1454 */ | |
1455 void gaim_conversations_set_win_ui_ops(GaimConvWindowUiOps *ops); | |
1456 | |
1457 /** | |
1458 * Returns the gaim window UI operations structure to be used in | |
1459 * new windows. | |
1460 * | |
1461 * @return A filled-out GaimConvWindowUiOps structure. | |
1462 */ | |
1463 GaimConvWindowUiOps *gaim_conversations_get_win_ui_ops(void); | |
1464 | |
1465 | |
1466 /*@}*/ | |
1467 | |
1468 /**************************************************************************/ | |
1469 /** @name Conversations Subsystem */ | 1163 /** @name Conversations Subsystem */ |
1470 /**************************************************************************/ | 1164 /**************************************************************************/ |
1471 /*@{*/ | 1165 /*@{*/ |
1472 | 1166 |
1473 /** | 1167 /** |