conversation.h

Go to the documentation of this file.
00001 
00027 #ifndef _GAIM_CONVERSATION_H_
00028 #define _GAIM_CONVERSATION_H_
00029 
00030 /**************************************************************************/
00032 /**************************************************************************/
00033 
00034 typedef struct _GaimConvWindowUiOps   GaimConvWindowUiOps;
00035 typedef struct _GaimConvWindow        GaimConvWindow;
00036 typedef struct _GaimConversationUiOps GaimConversationUiOps;
00037 typedef struct _GaimConversation      GaimConversation;
00038 typedef struct _GaimConvIm            GaimConvIm;
00039 typedef struct _GaimConvChat          GaimConvChat;
00040 typedef struct _GaimConvChatBuddy     GaimConvChatBuddy;
00041 
00045 typedef enum
00046 {
00047     GAIM_CONV_UNKNOWN = 0, 
00048     GAIM_CONV_IM,          
00049     GAIM_CONV_CHAT,        
00050     GAIM_CONV_MISC         
00052 } GaimConversationType;
00053 
00057 typedef enum
00058 {
00059     GAIM_UNSEEN_NONE = 0,  
00060     GAIM_UNSEEN_TEXT,      
00061     GAIM_UNSEEN_NICK,      
00062     GAIM_UNSEEN_EVENT      
00064 } GaimUnseenState;
00065 
00069 typedef enum
00070 {
00071     GAIM_CONV_UPDATE_ADD = 0, 
00073     GAIM_CONV_UPDATE_REMOVE,  
00075     GAIM_CONV_UPDATE_ACCOUNT, 
00076     GAIM_CONV_UPDATE_TYPING,  
00077     GAIM_CONV_UPDATE_UNSEEN,  
00078     GAIM_CONV_UPDATE_LOGGING, 
00080     GAIM_CONV_UPDATE_TOPIC,   
00081     /*
00082      * XXX These need to go when we implement a more generic core/UI event
00083      * system.
00084      */
00085     GAIM_CONV_ACCOUNT_ONLINE,  
00086     GAIM_CONV_ACCOUNT_OFFLINE, 
00087     GAIM_CONV_UPDATE_AWAY,     
00088     GAIM_CONV_UPDATE_ICON,     
00089     GAIM_CONV_UPDATE_TITLE,
00090     GAIM_CONV_UPDATE_CHATLEFT,
00091 
00092     GAIM_CONV_UPDATE_FEATURES, 
00094 } GaimConvUpdateType;
00095 
00099 typedef enum
00100 {
00101     GAIM_NOT_TYPING = 0,  
00102     GAIM_TYPING,          
00103     GAIM_TYPED            
00105 } GaimTypingState;
00106 
00110 typedef enum
00111 {
00112     GAIM_MESSAGE_SEND      = 0x0001, 
00113     GAIM_MESSAGE_RECV      = 0x0002, 
00114     GAIM_MESSAGE_SYSTEM    = 0x0004, 
00115     GAIM_MESSAGE_AUTO_RESP = 0x0008, 
00116     GAIM_MESSAGE_COLORIZE  = 0x0010, 
00117     GAIM_MESSAGE_NICK      = 0x0020, 
00118     GAIM_MESSAGE_NO_LOG    = 0x0040, 
00119     GAIM_MESSAGE_WHISPER   = 0x0080, 
00120     GAIM_MESSAGE_ERROR     = 0x0200, 
00121     GAIM_MESSAGE_DELAYED   = 0x0400  
00122 } GaimMessageFlags;
00123 
00127 typedef enum
00128 {
00129     GAIM_CBFLAGS_NONE          = 0x0000, 
00130     GAIM_CBFLAGS_VOICE         = 0x0001, 
00131     GAIM_CBFLAGS_HALFOP        = 0x0002, 
00132     GAIM_CBFLAGS_OP            = 0x0004, 
00133     GAIM_CBFLAGS_FOUNDER       = 0x0008  
00134 } GaimConvChatBuddyFlags;
00135 
00136 #include "account.h"
00137 #include "buddyicon.h"
00138 #include "log.h"
00139 #include "server.h"
00140 
00147 struct _GaimConvWindowUiOps
00148 {
00149     GaimConversationUiOps *(*get_conversation_ui_ops)(void);
00150 
00151     void (*new_window)(GaimConvWindow *win);
00152     void (*destroy_window)(GaimConvWindow *win);
00153 
00154     void (*show)(GaimConvWindow *win);
00155     void (*hide)(GaimConvWindow *win);
00156     void (*raise)(GaimConvWindow *win);
00157     void (*flash)(GaimConvWindow *win);
00158 
00159     void (*switch_conversation)(GaimConvWindow *win, unsigned int index);
00160     void (*add_conversation)(GaimConvWindow *win, GaimConversation *conv);
00161     void (*remove_conversation)(GaimConvWindow *win, GaimConversation *conv);
00162     void (*move_conversation)(GaimConvWindow *win, GaimConversation *conv,
00163                               unsigned int newIndex);
00164 
00165     int (*get_active_index)(const GaimConvWindow *win);
00166     gboolean (*has_focus)(GaimConvWindow *win);
00167 };
00168 
00175 struct _GaimConversationUiOps
00176 {
00177     void (*destroy_conversation)(GaimConversation *conv);
00178     void (*write_chat)(GaimConversation *conv, const char *who,
00179                        const char *message, GaimMessageFlags flags,
00180                        time_t mtime);
00181     void (*write_im)(GaimConversation *conv, const char *who,
00182                      const char *message, GaimMessageFlags flags,
00183                      time_t mtime);
00184     void (*write_conv)(GaimConversation *conv, const char *who,
00185                        const char *message, GaimMessageFlags flags,
00186                        time_t mtime);
00187 
00188     void (*chat_add_user)(GaimConversation *conv, const char *user, gboolean new_arrival);
00189     void (*chat_add_users)(GaimConversation *conv, GList *users);
00190     void (*chat_rename_user)(GaimConversation *conv,
00191                              const char *old_name, const char *new_name);
00192     void (*chat_remove_user)(GaimConversation *conv, const char *user);
00193     void (*chat_remove_users)(GaimConversation *conv, GList *users);
00194     void (*chat_update_user)(GaimConversation *conv, const char *user);
00195 
00196     void (*update_progress)(GaimConversation *conv, float percent);
00197 
00198     gboolean (*has_focus)(GaimConversation *conv);
00199 
00200     /* Events */
00201     void (*updated)(GaimConversation *conv, GaimConvUpdateType type);
00202 
00203 };
00204 
00209 struct _GaimConvWindow
00210 {
00211     GList *conversations;              
00212     size_t conversation_count;         
00214     GaimConvWindowUiOps *ui_ops;       
00215     void *ui_data;                     
00216 };
00217 
00221 struct _GaimConvIm
00222 {
00223     GaimConversation *conv;            
00225     GaimTypingState typing_state;      
00226     guint  typing_timeout;             
00227     time_t type_again;                 
00228     guint  type_again_timeout;         
00230     GaimBuddyIcon *icon;               
00231 };
00232 
00236 struct _GaimConvChat
00237 {
00238     GaimConversation *conv;          
00240     GList *in_room;                  
00241     GList *ignored;                  
00242     char  *who;                      
00243     char  *topic;                    
00244     int    id;                       
00245     char *nick;                      
00247     gboolean left;                   
00248 };
00249 
00253 struct _GaimConvChatBuddy
00254 {
00255     char *name;                      
00256     GaimConvChatBuddyFlags flags;    
00257 };
00258 
00265 struct _GaimConversation
00266 {
00267     GaimConversationType type;  
00269     GaimAccount *account;       
00270     GaimConvWindow *window;     
00272     int conversation_pos;       
00274     char *name;                 
00275     char *title;                
00277     gboolean logging;           
00279     GaimLog *log;               
00281     GList *send_history;        
00282     GString *history;           
00284     GaimUnseenState unseen;     
00286     union
00287     {
00288         GaimConvIm   *im;       
00289         GaimConvChat *chat;     
00290         void *misc;             
00292     } u;
00293 
00294     GaimConversationUiOps *ui_ops;           
00295     void *ui_data;                           
00297     GHashTable *data;                        
00299     GaimConnectionFlags features; 
00301 };
00302 
00303 typedef void (*GaimConvPlacementFunc)(GaimConversation *);
00304 
00305 #ifdef __cplusplus
00306 extern "C" {
00307 #endif
00308 
00309 /**************************************************************************/
00311 /**************************************************************************/
00322 GaimConvWindow *gaim_conv_window_new(void);
00323 
00329 void gaim_conv_window_destroy(GaimConvWindow *win);
00330 
00336 void gaim_conv_window_show(GaimConvWindow *win);
00337 
00343 void gaim_conv_window_hide(GaimConvWindow *win);
00344 
00350 void gaim_conv_window_raise(GaimConvWindow *win);
00351 
00357 void gaim_conv_window_flash(GaimConvWindow *win);
00358 
00365 void gaim_conv_window_set_ui_ops(GaimConvWindow *win,
00366                                  GaimConvWindowUiOps *ops);
00367 
00375 GaimConvWindowUiOps *gaim_conv_window_get_ui_ops(const GaimConvWindow *win);
00376 
00387 int gaim_conv_window_add_conversation(GaimConvWindow *win,
00388                                       GaimConversation *conv);
00389 
00400 GaimConversation *gaim_conv_window_remove_conversation(GaimConvWindow *win,
00401                                                        unsigned int index);
00402 
00410 void gaim_conv_window_move_conversation(GaimConvWindow *win,
00411                                         unsigned int index,
00412                                         unsigned int new_index);
00413 
00424 GaimConversation *gaim_conv_window_get_conversation_at(
00425         const GaimConvWindow *win, unsigned int index);
00426 
00434 size_t gaim_conv_window_get_conversation_count(const GaimConvWindow *win);
00435 
00444 void gaim_conv_window_switch_conversation(GaimConvWindow *win,
00445                                           unsigned int index);
00446 
00454 GaimConversation *gaim_conv_window_get_active_conversation(
00455         const GaimConvWindow *win);
00456 
00465 gboolean gaim_conv_window_has_focus(GaimConvWindow *win);
00466 
00474 GList *gaim_conv_window_get_conversations(const GaimConvWindow *win);
00475 
00481 GList *gaim_get_windows(void);
00482 
00490 GaimConvWindow *gaim_get_first_window_with_type(GaimConversationType type);
00498 GaimConvWindow *gaim_get_last_window_with_type(GaimConversationType type);
00499 
00502 /**************************************************************************/
00504 /**************************************************************************/
00517 GaimConversation *gaim_conversation_new(GaimConversationType type,
00518                                         GaimAccount *account,
00519                                         const char *name);
00520 
00530 void gaim_conversation_destroy(GaimConversation *conv);
00531 
00539 GaimConversationType gaim_conversation_get_type(const GaimConversation *conv);
00540 
00547 void gaim_conversation_set_ui_ops(GaimConversation *conv,
00548                                   GaimConversationUiOps *ops);
00549 
00557 GaimConversationUiOps *gaim_conversation_get_ui_ops(
00558         const GaimConversation *conv);
00559 
00569 void gaim_conversation_set_account(GaimConversation *conv,
00570                                    GaimAccount *account);
00571 
00582 GaimAccount *gaim_conversation_get_account(const GaimConversation *conv);
00583 
00593 GaimConnection *gaim_conversation_get_gc(const GaimConversation *conv);
00594 
00601 void gaim_conversation_set_title(GaimConversation *conv, const char *title);
00602 
00610 const char *gaim_conversation_get_title(const GaimConversation *conv);
00611 
00620 void gaim_conversation_autoset_title(GaimConversation *conv);
00621 
00629 int gaim_conversation_get_index(const GaimConversation *conv);
00630 
00637 void gaim_conversation_set_unseen(GaimConversation *conv,
00638                                   GaimUnseenState state);
00639 
00647 GaimUnseenState gaim_conversation_get_unseen(const GaimConversation *conv);
00648 
00655 void gaim_conversation_set_name(GaimConversation *conv, const char *name);
00656 
00664 const char *gaim_conversation_get_name(const GaimConversation *conv);
00665 
00672 void gaim_conversation_set_logging(GaimConversation *conv, gboolean log);
00673 
00681 gboolean gaim_conversation_is_logging(const GaimConversation *conv);
00682 
00690 GList *gaim_conversation_get_send_history(const GaimConversation *conv);
00691 
00698 void gaim_conversation_set_history(GaimConversation *conv, GString *history);
00699 
00707 GString *gaim_conversation_get_history(const GaimConversation *conv);
00708 
00716 GaimConvWindow *gaim_conversation_get_window(const GaimConversation *conv);
00717 
00727 GaimConvIm *gaim_conversation_get_im_data(const GaimConversation *conv);
00728 
00729 #define GAIM_CONV_IM(c) (gaim_conversation_get_im_data(c))
00730 
00740 GaimConvChat *gaim_conversation_get_chat_data(const GaimConversation *conv);
00741 
00742 #define GAIM_CONV_CHAT(c) (gaim_conversation_get_chat_data(c))
00743 
00751 void gaim_conversation_set_data(GaimConversation *conv, const char *key,
00752                                 gpointer data);
00753 
00762 gpointer gaim_conversation_get_data(GaimConversation *conv, const char *key);
00763 
00771 GList *gaim_get_conversations(void);
00772 
00778 GList *gaim_get_ims(void);
00779 
00785 GList *gaim_get_chats(void);
00786 
00794 GaimConversation *gaim_find_conversation(const char *name);
00795 
00804 GaimConversation *gaim_find_conversation_with_account(
00805         const char *name, const GaimAccount *account);
00806 
00827 void gaim_conversation_write(GaimConversation *conv, const char *who,
00828         const char *message, GaimMessageFlags flags,
00829         time_t mtime);
00830 
00831 
00837 void gaim_conversation_set_features(GaimConversation *conv,
00838         GaimConnectionFlags features);
00839 
00840 
00845 GaimConnectionFlags gaim_conversation_get_features(GaimConversation *conv);         
00846 
00847 
00857 void gaim_conversation_update_progress(GaimConversation *conv, float percent);
00858 
00867 gboolean gaim_conversation_has_focus(GaimConversation *conv);
00868 
00875 void gaim_conversation_update(GaimConversation *conv, GaimConvUpdateType type);
00876 
00882 void gaim_conversation_foreach(void (*func)(GaimConversation *conv));
00883 
00887 /**************************************************************************/
00889 /**************************************************************************/
00899 GaimConversation *gaim_conv_im_get_conversation(const GaimConvIm *im);
00900 
00912 void gaim_conv_im_set_icon(GaimConvIm *im, GaimBuddyIcon *icon);
00913 
00921 GaimBuddyIcon *gaim_conv_im_get_icon(const GaimConvIm *im);
00922 
00929 void gaim_conv_im_set_typing_state(GaimConvIm *im, GaimTypingState state);
00930 
00938 GaimTypingState gaim_conv_im_get_typing_state(const GaimConvIm *im);
00939 
00946 void gaim_conv_im_start_typing_timeout(GaimConvIm *im, int timeout);
00947 
00953 void gaim_conv_im_stop_typing_timeout(GaimConvIm *im);
00954 
00962 guint gaim_conv_im_get_typing_timeout(const GaimConvIm *im);
00963 
00970 void gaim_conv_im_set_type_again(GaimConvIm *im, time_t val);
00971 
00979 time_t gaim_conv_im_get_type_again(const GaimConvIm *im);
00980 
00986 void gaim_conv_im_start_type_again_timeout(GaimConvIm *im);
00987 
00993 void gaim_conv_im_stop_type_again_timeout(GaimConvIm *im);
00994 
01002 guint gaim_conv_im_get_type_again_timeout(const GaimConvIm *im);
01003 
01009 void gaim_conv_im_update_typing(GaimConvIm *im);
01010 
01020 void gaim_conv_im_write(GaimConvIm *im, const char *who,
01021                         const char *message, GaimMessageFlags flags,
01022                         time_t mtime);
01023 
01037 gboolean gaim_conv_present_error(const char *who, GaimAccount *account, const char *what);
01038 
01045 void gaim_conv_im_send(GaimConvIm *im, const char *message);
01046 
01050 /**************************************************************************/
01052 /**************************************************************************/
01062 GaimConversation *gaim_conv_chat_get_conversation(const GaimConvChat *chat);
01063 
01076 GList *gaim_conv_chat_set_users(GaimConvChat *chat, GList *users);
01077 
01085 GList *gaim_conv_chat_get_users(const GaimConvChat *chat);
01086 
01093 void gaim_conv_chat_ignore(GaimConvChat *chat, const char *name);
01094 
01101 void gaim_conv_chat_unignore(GaimConvChat *chat, const char *name);
01102 
01111 GList *gaim_conv_chat_set_ignored(GaimConvChat *chat, GList *ignored);
01112 
01120 GList *gaim_conv_chat_get_ignored(const GaimConvChat *chat);
01121 
01136 const char *gaim_conv_chat_get_ignored_user(const GaimConvChat *chat,
01137                                             const char *user);
01138 
01147 gboolean gaim_conv_chat_is_user_ignored(const GaimConvChat *chat,
01148                                         const char *user);
01149 
01157 void gaim_conv_chat_set_topic(GaimConvChat *chat, const char *who,
01158                               const char *topic);
01159 
01167 const char *gaim_conv_chat_get_topic(const GaimConvChat *chat);
01168 
01175 void gaim_conv_chat_set_id(GaimConvChat *chat, int id);
01176 
01184 int gaim_conv_chat_get_id(const GaimConvChat *chat);
01185 
01195 void gaim_conv_chat_write(GaimConvChat *chat, const char *who,
01196                           const char *message, GaimMessageFlags flags,
01197                           time_t mtime);
01198 
01205 void gaim_conv_chat_send(GaimConvChat *chat, const char *message);
01206 
01216 void gaim_conv_chat_add_user(GaimConvChat *chat, const char *user,
01217                              const char *extra_msg, GaimConvChatBuddyFlags flags,
01218                              gboolean new_arrival);
01219 
01230 void gaim_conv_chat_add_users(GaimConvChat *chat, GList *users, GList *flags);
01231 
01239 void gaim_conv_chat_rename_user(GaimConvChat *chat, const char *old_user,
01240                                 const char *new_user);
01241 
01251 void gaim_conv_chat_remove_user(GaimConvChat *chat, const char *user,
01252                                 const char *reason);
01253 
01261 void gaim_conv_chat_remove_users(GaimConvChat *chat, GList *users,
01262                                  const char *reason);
01263 
01272 gboolean gaim_conv_chat_find_user(GaimConvChat *chat, const char *user);
01273 
01281 void gaim_conv_chat_user_set_flags(GaimConvChat *chat, const char *user,
01282                                    GaimConvChatBuddyFlags flags);
01283 
01292 GaimConvChatBuddyFlags gaim_conv_chat_user_get_flags(GaimConvChat *chat,
01293                                                      const char *user);
01294 
01300 void gaim_conv_chat_clear_users(GaimConvChat *chat);
01301 
01308 void gaim_conv_chat_set_nick(GaimConvChat *chat, const char *nick);
01309 
01316 const char *gaim_conv_chat_get_nick(GaimConvChat *chat);
01317 
01326 GaimConversation *gaim_find_chat(const GaimConnection *gc, int id);
01327 
01334 void gaim_conv_chat_left(GaimConvChat *chat);
01335 
01345 gboolean gaim_conv_chat_has_left(GaimConvChat *chat);
01346 
01355 GaimConvChatBuddy *gaim_conv_chat_cb_new(const char *name,
01356                                         GaimConvChatBuddyFlags flags);
01357 
01364 GaimConvChatBuddy *gaim_conv_chat_cb_find(GaimConvChat *chat, const char *name);
01365 
01373 const char *gaim_conv_chat_cb_get_name(GaimConvChatBuddy *cb);
01374 
01380 void gaim_conv_chat_cb_destroy(GaimConvChatBuddy *cb);
01381 
01384 /**************************************************************************/
01386 /**************************************************************************/
01395 GList *gaim_conv_placement_get_options(void);
01396 
01404 void gaim_conv_placement_add_fnc(const char *id, const char *name,
01405                                  GaimConvPlacementFunc fnc);
01406 
01413 void gaim_conv_placement_remove_fnc(const char *id);
01414 
01423 const char *gaim_conv_placement_get_name(const char *id);
01424 
01433 GaimConvPlacementFunc gaim_conv_placement_get_fnc(const char *id);
01434 
01440 void gaim_conv_placement_set_current_func(GaimConvPlacementFunc func);
01441 
01447 GaimConvPlacementFunc gaim_conv_placement_get_current_func(void);
01448 
01457 const char *gaim_conv_placement_get_fnc_id(GaimConvPlacementFunc fnc);
01458 
01461 /**************************************************************************/
01463 /**************************************************************************/
01472 void gaim_conversations_set_win_ui_ops(GaimConvWindowUiOps *ops);
01473 
01480 GaimConvWindowUiOps *gaim_conversations_get_win_ui_ops(void);
01481 
01482 
01485 /**************************************************************************/
01487 /**************************************************************************/
01495 void *gaim_conversations_get_handle(void);
01496 
01500 void gaim_conversations_init(void);
01501 
01505 void gaim_conversations_uninit(void);
01506 
01509 #ifdef __cplusplus
01510 }
01511 #endif
01512 
01513 #endif /* _GAIM_CONVERSATION_H_ */

Generated on Sun Feb 18 08:38:28 2007 for gaim by  doxygen 1.5.1