Changeset 5ebff60 for protocols/nogaim.h
- Timestamp:
- 2015-02-20T22:50:54Z (9 years ago)
- Branches:
- master
- Children:
- 0b9daac, 3d45471, 7733b8c
- Parents:
- af359b4
- git-author:
- Indent <please@…> (19-02-15 05:47:20)
- git-committer:
- dequis <dx@…> (20-02-15 22:50:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.h
raf359b4 r5ebff60 1 1 /********************************************************************\ 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * … … 39 39 #define _NOGAIM_H 40 40 41 #if (__sun)41 #if (__sun) 42 42 #include <inttypes.h> 43 43 #else … … 72 72 73 73 /* ok. now the fun begins. first we create a connection structure */ 74 struct im_connection 75 { 74 struct im_connection { 76 75 account_t *acc; 77 76 uint32_t flags; 78 77 79 78 /* each connection then can have its own protocol-specific data */ 80 79 void *proto_data; 81 80 82 81 /* all connections need an input watcher */ 83 82 int inpa; 84 83 guint keepalive; 85 84 86 85 /* buddy list stuff. there is still a global groups for the buddy list, but 87 86 * we need to maintain our own set of buddies, and our own permit/deny lists */ … … 89 88 GSList *deny; 90 89 int permdeny; 91 90 92 91 char *away; 93 92 94 93 /* BitlBee */ 95 94 bee_t *bee; 96 95 97 96 GSList *groupchats; 98 97 }; … … 107 106 GList *in_room; 108 107 //GList *ignored; 109 108 110 109 //struct groupchat *next; 111 110 /* The title variable contains the ID you gave when you created the … … 153 152 * it should be used for anything else. You are supposed to use the 154 153 * set_add() function to add new settings. */ 155 void (* init) 154 void (* init) (account_t *); 156 155 /* The typical usage of the login() function: 157 156 * - Create an im_connection using imcb_new() from the account_t parameter. … … 160 159 * - Use proxy_connect() to connect to the server. 161 160 */ 162 void (* login) 161 void (* login) (account_t *); 163 162 /* Implementing this function is optional. */ 164 void (* keepalive) 163 void (* keepalive) (struct im_connection *); 165 164 /* In this function you should: 166 165 * - Tell the server about you are logging out. … … 168 167 * properly do so. 169 168 */ 170 void (* logout) 171 169 void (* logout) (struct im_connection *); 170 172 171 /* This function is called when the user wants to send a message to a handle. 173 172 * - 'to' is a handle, not a nick 174 173 * - 'flags' may be ignored 175 174 */ 176 int (* buddy_msg)(struct im_connection *, char *to, char *message, int flags);175 int (* buddy_msg) (struct im_connection *, char *to, char *message, int flags); 177 176 /* This function is called then the user uses the /away IRC command. 178 177 * - 'state' contains the away reason. 179 178 * - 'message' may be ignored if your protocol does not support it. 180 179 */ 181 void (* set_away) 180 void (* set_away) (struct im_connection *, char *state, char *message); 182 181 /* Implementing this function is optional. */ 183 182 void (* get_away) (struct im_connection *, char *who); 184 183 /* Implementing this function is optional. */ 185 int (* send_typing)(struct im_connection *, char *who, int flags);186 184 int (* send_typing) (struct im_connection *, char *who, int flags); 185 187 186 /* 'name' is a handle to add/remove. For now BitlBee doesn't really 188 187 * handle groups, just set it to NULL, so you can ignore that 189 188 * parameter. */ 190 void (* add_buddy) 191 void (* remove_buddy) 192 189 void (* add_buddy) (struct im_connection *, char *name, char *group); 190 void (* remove_buddy) (struct im_connection *, char *name, char *group); 191 193 192 /* Block list stuff. Implementing these are optional. */ 194 void (* add_permit) 195 void (* add_deny) 196 void (* rem_permit) 197 void (* rem_deny) 193 void (* add_permit) (struct im_connection *, char *who); 194 void (* add_deny) (struct im_connection *, char *who); 195 void (* rem_permit) (struct im_connection *, char *who); 196 void (* rem_deny) (struct im_connection *, char *who); 198 197 /* Doesn't actually have UI hooks. Not used at all, can be removed. */ 199 198 void (* set_permit_deny)(struct im_connection *); 200 199 201 200 /* Request profile info. Free-formatted stuff, the IM module gives back 202 201 this info via imcb_log(). Implementing these are optional. */ 203 void (* get_info) 202 void (* get_info) (struct im_connection *, char *who); 204 203 /* set_my_name is *DEPRECATED*, not used by the UI anymore. Use the 205 204 display_name setting instead. */ 206 void (* set_my_name) 207 void (* set_name) 208 205 void (* set_my_name) (struct im_connection *, char *name); 206 void (* set_name) (struct im_connection *, char *who, char *name); 207 209 208 /* Group chat stuff. */ 210 209 /* This is called when the user uses the /invite IRC command. … … 212 211 * - 'message' is a handle to invite 213 212 */ 214 void (* chat_invite) 213 void (* chat_invite) (struct groupchat *, char *who, char *message); 215 214 /* This is called when the user uses the /kick IRC command. 216 215 * - 'who' is a handle to kick 217 216 * - 'message' is a kick message or NULL 218 217 */ 219 void (* chat_kick) 218 void (* chat_kick) (struct groupchat *, char *who, const char *message); 220 219 /* This is called when the user uses the /part IRC command in a group 221 220 * chat. You just should tell the user about it, nothing more. */ 222 void (* chat_leave) 221 void (* chat_leave) (struct groupchat *); 223 222 /* This is called when the user sends a message to the groupchat. 224 223 * 'flags' may be ignored. */ 225 void (* chat_msg) 224 void (* chat_msg) (struct groupchat *, char *message, int flags); 226 225 /* This is called when the user uses the /join #nick IRC command. 227 226 * - 'who' is the handle of the nick 228 227 */ 229 228 struct groupchat * 230 (* chat_with)(struct im_connection *, char *who);229 (* chat_with) (struct im_connection *, char *who); 231 230 /* This is used when the user uses the /join #channel IRC command. If 232 231 * your protocol does not support publicly named group chats, then do 233 232 * not implement this. */ 234 233 struct groupchat * 235 (* chat_join)(struct im_connection *, const char *room,236 234 (* chat_join) (struct im_connection *, const char *room, 235 const char *nick, const char *password, set_t **sets); 237 236 /* Change the topic, if supported. Note that BitlBee expects the IM 238 237 server to confirm the topic change with a regular topic change 239 238 event. If it doesn't do that, you have to fake it to make it 240 239 visible to the user. */ 241 void (* chat_topic) 242 240 void (* chat_topic) (struct groupchat *, char *topic); 241 243 242 /* If your protocol module needs any special info for joining chatrooms 244 243 other than a roomname + nickname, add them here. */ 245 void (* chat_add_settings) 246 void (* chat_free_settings) 247 244 void (* chat_add_settings) (account_t *acc, set_t **head); 245 void (* chat_free_settings) (account_t *acc, set_t **head); 246 248 247 /* You can tell what away states your protocol supports, so that 249 248 * BitlBee will try to map the IRC away reasons to them. If your 250 249 * protocol doesn't have any, just return one generic "Away". */ 251 250 GList *(* away_states)(struct im_connection *ic); 252 251 253 252 /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* 254 253 * - Most protocols will just want to set this to g_strcasecmp().*/ … … 256 255 257 256 /* Implement these callbacks if you want to use imcb_ask_auth() */ 258 void (* auth_allow) 259 void (* auth_deny) 257 void (* auth_allow) (struct im_connection *, const char *who); 258 void (* auth_deny) (struct im_connection *, const char *who); 260 259 261 260 /* Incoming transfer request */ 262 void (* transfer_request) (struct im_connection *, file_transfer_t *ft, char *handle 263 261 void (* transfer_request) (struct im_connection *, file_transfer_t *ft, char *handle); 262 264 263 void (* buddy_data_add) (struct bee_user *bu); 265 264 void (* buddy_data_free) (struct bee_user *bu); 266 265 267 266 GList *(* buddy_action_list) (struct bee_user *bu); 268 267 void *(* buddy_action) (struct bee_user *bu, const char *action, char * const args[], void *data); 269 268 270 269 /* If null, equivalent to handle_cmp( ic->acc->user, who ) */ 271 270 gboolean (* handle_is_self) (struct im_connection *, const char *who); … … 282 281 void nogaim_init(); 283 282 G_MODULE_EXPORT GSList *get_connections(); 284 G_MODULE_EXPORT struct prpl *find_protocol( const char *name);283 G_MODULE_EXPORT struct prpl *find_protocol(const char *name); 285 284 /* When registering a new protocol, you should allocate space for a new prpl 286 285 * struct, initialize it (set the function pointers to point to your 287 286 * functions), finally call this function. */ 288 G_MODULE_EXPORT void register_protocol( struct prpl *);287 G_MODULE_EXPORT void register_protocol(struct prpl *); 289 288 290 289 /* Connection management. */ 291 290 /* You will need this function in prpl->login() to get an im_connection from 292 291 * the account_t parameter. */ 293 G_MODULE_EXPORT struct im_connection *imcb_new( account_t *acc);294 G_MODULE_EXPORT void imc_free( struct im_connection *ic);292 G_MODULE_EXPORT struct im_connection *imcb_new(account_t *acc); 293 G_MODULE_EXPORT void imc_free(struct im_connection *ic); 295 294 /* Once you're connected, you should call this function, so that the user will 296 295 * see the success. */ 297 G_MODULE_EXPORT void imcb_connected( struct im_connection *ic);296 G_MODULE_EXPORT void imcb_connected(struct im_connection *ic); 298 297 /* This can be used to disconnect when something went wrong (ie. read error 299 298 * from the server). You probably want to set the second parameter to TRUE. */ 300 G_MODULE_EXPORT void imc_logout( struct im_connection *ic, int allow_reconnect);299 G_MODULE_EXPORT void imc_logout(struct im_connection *ic, int allow_reconnect); 301 300 302 301 /* Communicating with the user. */ 303 302 /* A printf()-like function to tell the user anything you want. */ 304 G_MODULE_EXPORT void imcb_log( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3);303 G_MODULE_EXPORT void imcb_log(struct im_connection *ic, char *format, ...) G_GNUC_PRINTF(2, 3); 305 304 /* To tell the user an error, ie. before logging out when an error occurs. */ 306 G_MODULE_EXPORT void imcb_error( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3);305 G_MODULE_EXPORT void imcb_error(struct im_connection *ic, char *format, ...) G_GNUC_PRINTF(2, 3); 307 306 308 307 /* To ask a your about something. … … 311 310 * - 'doit' or 'dont' will be called depending of the answer of the user. 312 311 */ 313 G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, query_callback doit, query_callback dont ); 314 G_MODULE_EXPORT void imcb_ask_with_free( struct im_connection *ic, char *msg, void *data, query_callback doit, query_callback dont, query_callback myfree ); 312 G_MODULE_EXPORT void imcb_ask(struct im_connection *ic, char *msg, void *data, query_callback doit, 313 query_callback dont); 314 G_MODULE_EXPORT void imcb_ask_with_free(struct im_connection *ic, char *msg, void *data, query_callback doit, 315 query_callback dont, query_callback myfree); 315 316 316 317 /* Two common questions you may want to ask: … … 318 319 * - X is not in your contact list, want to add? 319 320 */ 320 G_MODULE_EXPORT void imcb_ask_auth( struct im_connection *ic, const char *handle, const char *realname);321 G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, const char *handle, const char *realname);321 G_MODULE_EXPORT void imcb_ask_auth(struct im_connection *ic, const char *handle, const char *realname); 322 G_MODULE_EXPORT void imcb_ask_add(struct im_connection *ic, const char *handle, const char *realname); 322 323 323 324 /* Buddy management */ … … 325 326 * user, usually after a login, or if the user added a buddy and the IM 326 327 * server confirms that the add was successful. Don't forget to do this! */ 327 G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, const char *handle, const char *group);328 G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, const char *handle, char *group);329 G_MODULE_EXPORT struct buddy *imcb_find_buddy( struct im_connection *ic, char *handle);330 G_MODULE_EXPORT void imcb_rename_buddy( struct im_connection *ic, const char *handle, const char *realname);331 G_MODULE_EXPORT void imcb_buddy_nick_hint( struct im_connection *ic, const char *handle, const char *nick);332 G_MODULE_EXPORT void imcb_buddy_action_response( bee_user_t *bu, const char *action, char * const args[], void *data);333 334 G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, const char *handle, uint32_t flags);335 G_MODULE_EXPORT struct bee_user *imcb_buddy_by_handle( struct im_connection *ic, const char *handle);336 G_MODULE_EXPORT void imcb_clean_handle( struct im_connection *ic, char *handle);328 G_MODULE_EXPORT void imcb_add_buddy(struct im_connection *ic, const char *handle, const char *group); 329 G_MODULE_EXPORT void imcb_remove_buddy(struct im_connection *ic, const char *handle, char *group); 330 G_MODULE_EXPORT struct buddy *imcb_find_buddy(struct im_connection *ic, char *handle); 331 G_MODULE_EXPORT void imcb_rename_buddy(struct im_connection *ic, const char *handle, const char *realname); 332 G_MODULE_EXPORT void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const char *nick); 333 G_MODULE_EXPORT void imcb_buddy_action_response(bee_user_t *bu, const char *action, char * const args[], void *data); 334 335 G_MODULE_EXPORT void imcb_buddy_typing(struct im_connection *ic, const char *handle, uint32_t flags); 336 G_MODULE_EXPORT struct bee_user *imcb_buddy_by_handle(struct im_connection *ic, const char *handle); 337 G_MODULE_EXPORT void imcb_clean_handle(struct im_connection *ic, char *handle); 337 338 338 339 /* Actions, or whatever. */ 339 int imc_away_send_update( struct im_connection *ic);340 int imc_chat_msg( struct groupchat *c, char *msg, int flags);341 342 void imc_add_allow( struct im_connection *ic, char *handle);343 void imc_rem_allow( struct im_connection *ic, char *handle);344 void imc_add_block( struct im_connection *ic, char *handle);345 void imc_rem_block( struct im_connection *ic, char *handle);340 int imc_away_send_update(struct im_connection *ic); 341 int imc_chat_msg(struct groupchat *c, char *msg, int flags); 342 343 void imc_add_allow(struct im_connection *ic, char *handle); 344 void imc_rem_allow(struct im_connection *ic, char *handle); 345 void imc_add_block(struct im_connection *ic, char *handle); 346 void imc_rem_block(struct im_connection *ic, char *handle); 346 347 347 348 /* Misc. stuff */ 348 char *set_eval_timezone( set_t *set, char *value);349 gboolean auto_reconnect( gpointer data, gint fd, b_input_condition cond);350 void cancel_auto_reconnect( struct account *a);349 char *set_eval_timezone(set_t *set, char *value); 350 gboolean auto_reconnect(gpointer data, gint fd, b_input_condition cond); 351 void cancel_auto_reconnect(struct account *a); 351 352 352 353 #endif
Note: See TracChangeset
for help on using the changeset viewer.