Changeset acd61b9
- Timestamp:
- 2007-10-08T00:04:33Z (17 years ago)
- Branches:
- master
- Children:
- 2896674
- Parents:
- 9334cc2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.h
r9334cc2 racd61b9 98 98 99 99 /* stuff used just for chat */ 100 /* The in_room variable is a list of handles (not nicks!), kind of 101 * "nick list". This is how you can check who is in the group chat 102 * already, for example to avoid adding somebody two times. */ 100 103 GList *in_room; 101 104 GList *ignored; … … 104 107 struct groupchat *next; 105 108 char *channel; 109 /* The title variable contains the ID you gave when you created the 110 * chat using imcb_chat_new(). */ 106 111 char *title; 107 112 char joined; 113 /* This is for you, you can add your own structure here to extend this 114 * structure for your protocol's needs. */ 108 115 void *data; 109 116 }; … … 124 131 struct prpl { 125 132 int options; 133 /* You should set this to the name of your protocol. 134 * - The user sees this name ie. when imcb_log() is used. */ 126 135 const char *name; 127 136 128 137 /* Added this one to be able to add per-account settings, don't think 129 it should be used for anything else. */ 138 * it should be used for anything else. You are supposed to use the 139 * set_add() function to add new settings. */ 130 140 void (* init) (account_t *); 131 /* These should all be pretty obvious. */ 141 /* The typical usage of the login() function: 142 * - Create an im_connection using imcb_new() from the account_t parameter. 143 * - Initialize your myproto_data struct - you should store all your protocol-specific data there. 144 * - Save your custom structure to im_connection->proto_data. 145 * - Use proxy_connect() to connect to the server. 146 */ 132 147 void (* login) (account_t *); 148 /* Implementing this function is optional. */ 133 149 void (* keepalive) (struct im_connection *); 150 /* In this function you should: 151 * - Tell the server about you are logging out. 152 * - g_free() your myproto_data struct as BitlBee does not know how to 153 * properly do so. 154 */ 134 155 void (* logout) (struct im_connection *); 135 156 157 /* This function is called when the user wants to send a message to a handle. 158 * - 'to' is a handle, not a nick 159 * - 'flags' may be ignored 160 */ 136 161 int (* buddy_msg) (struct im_connection *, char *to, char *message, int flags); 162 /* This function is called then the user uses the /away IRC command. 163 * - 'state' contains the away reason. 164 * - 'message' may be ignored if your protocol does not support it. 165 */ 137 166 void (* set_away) (struct im_connection *, char *state, char *message); 167 /* Implementing this function is optional. */ 138 168 void (* get_away) (struct im_connection *, char *who); 169 /* Implementing this function is optional. */ 139 170 int (* send_typing) (struct im_connection *, char *who, int flags); 140 171 141 /* For now BitlBee doesn't really handle groups, just set it to NULL. */ 172 /* 'name' is a handle to add/remove. For now BitlBee doesn't really 173 * handle groups, just set it to NULL, so you can ignore that 174 * parameter. */ 142 175 void (* add_buddy) (struct im_connection *, char *name, char *group); 143 176 void (* remove_buddy) (struct im_connection *, char *name, char *group); 144 177 145 /* Block list stuff. */178 /* Block list stuff. Implementing these are optional. */ 146 179 void (* add_permit) (struct im_connection *, char *who); 147 180 void (* add_deny) (struct im_connection *, char *who); … … 152 185 153 186 /* Request profile info. Free-formatted stuff, the IM module gives back 154 this info via imcb_log(). */187 this info via imcb_log(). Implementing these are optional. */ 155 188 void (* get_info) (struct im_connection *, char *who); 156 189 void (* set_my_name) (struct im_connection *, char *name); … … 158 191 159 192 /* Group chat stuff. */ 193 /* This is called when the user uses the /invite IRC command. 194 * - 'who' may be ignored 195 * - 'message' is a handle to invite 196 */ 160 197 void (* chat_invite) (struct groupchat *, char *who, char *message); 198 /* This is called when the user uses the /part IRC command in a group 199 * chat. You just should tell the user about it, nothing more. */ 161 200 void (* chat_leave) (struct groupchat *); 201 /* This is called when the user sends a message to the groupchat. 202 * 'flags' may be ignored. */ 162 203 void (* chat_msg) (struct groupchat *, char *message, int flags); 204 /* This is called when the user uses the /join #nick IRC command. 205 * - 'who' is the handle of the nick 206 */ 163 207 struct groupchat * 164 208 (* chat_with) (struct im_connection *, char *who); 209 /* This is used when the user uses the /join #channel IRC command. If 210 * your protocol does not support publicly named group chats, then do 211 * not implement this. */ 165 212 struct groupchat * 166 213 (* chat_join) (struct im_connection *, char *room, char *nick, char *password); 167 214 215 /* You can tell what away states your protocol supports, so that 216 * BitlBee will try to map the IRC away reasons to them, or use 217 * GAIM_AWAY_CUSTOM when calling skype_set_away(). */ 168 218 GList *(* away_states)(struct im_connection *ic); 169 219 170 /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* */ 220 /* Mainly for AOL, since they think "Bung hole" == "Bu ngho le". *sigh* 221 * - Most protocols will just want to set this to g_strcasecmp().*/ 171 222 int (* handle_cmp) (const char *who1, const char *who2); 172 223 }; … … 176 227 G_MODULE_EXPORT GSList *get_connections(); 177 228 G_MODULE_EXPORT struct prpl *find_protocol( const char *name ); 229 /* When registering a new protocol, you should allocate space for a new prpl 230 * struct, initialize it (set the function pointers to point to your 231 * functions), finally call this function. */ 178 232 G_MODULE_EXPORT void register_protocol( struct prpl * ); 179 233 180 234 /* Connection management. */ 235 /* You will need this function in prpl->login() to get an im_connection from 236 * the account_t parameter. */ 181 237 G_MODULE_EXPORT struct im_connection *imcb_new( account_t *acc ); 182 238 G_MODULE_EXPORT void imcb_free( struct im_connection *ic ); 239 /* Once you're connected, you should call this function, so that the user will 240 * see the success. */ 183 241 G_MODULE_EXPORT void imcb_connected( struct im_connection *ic ); 242 /* This can be used to disconnect when something went wrong (ie. read error 243 * from the server). You probably want to set the second parameter to TRUE. */ 184 244 G_MODULE_EXPORT void imc_logout( struct im_connection *ic, int allow_reconnect ); 185 245 186 246 /* Communicating with the user. */ 247 /* A printf()-like function to tell the user anything you want. */ 187 248 G_MODULE_EXPORT void imcb_log( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 249 /* To tell the user an error, ie. before logging out when an error occurs. */ 188 250 G_MODULE_EXPORT void imcb_error( struct im_connection *ic, char *format, ... ) G_GNUC_PRINTF( 2, 3 ); 251 /* To ask a your about something. 252 * - 'msg' is the question. 253 * - 'data' can be your custom struct - it will be passed to the callbacks. 254 * - 'doit' or 'dont' will be called depending of the answer of the user. 255 */ 189 256 G_MODULE_EXPORT void imcb_ask( struct im_connection *ic, char *msg, void *data, void *doit, void *dont ); 190 257 G_MODULE_EXPORT void imcb_ask_add( struct im_connection *ic, char *handle, const char *realname ); 191 258 192 259 /* Buddy management */ 260 /* This function should be called for each handle which are visible to the 261 * user, usually after a login. */ 193 262 G_MODULE_EXPORT void imcb_add_buddy( struct im_connection *ic, char *handle, char *group ); 194 263 G_MODULE_EXPORT void imcb_remove_buddy( struct im_connection *ic, char *handle, char *group ); … … 197 266 198 267 /* Buddy activity */ 268 /* To manipulate the status of a handle. 269 * - flags can be |='d with OPT_* constants. You will need at least: 270 * OPT_LOGGED_IN and OPT_AWAY. 271 * - 'state' and 'message' can be NULL */ 199 272 G_MODULE_EXPORT void imcb_buddy_status( struct im_connection *ic, const char *handle, int flags, const char *state, const char *message ); 200 273 /* Not implemented yet! */ G_MODULE_EXPORT void imcb_buddy_times( struct im_connection *ic, const char *handle, time_t login, time_t idle ); 274 /* Call when a handle says something. 'flags' and 'sent_at may be just 0. */ 201 275 G_MODULE_EXPORT void imcb_buddy_msg( struct im_connection *ic, char *handle, char *msg, u_int32_t flags, time_t sent_at ); 202 276 G_MODULE_EXPORT void imcb_buddy_typing( struct im_connection *ic, char *handle, u_int32_t flags ); … … 204 278 /* Groupchats */ 205 279 G_MODULE_EXPORT void imcb_chat_invited( struct im_connection *ic, char *handle, char *who, char *msg, GList *data ); 280 /* These two functions are to create a group chat. 281 * - imcb_chat_new(): the 'handle' parameter identifies the chat, like the 282 * channel name on IRC. 283 * - After you have a groupchat pointer, you should add the handles, finally 284 * the user her/himself. At that point the group chat will be visible to the 285 * user, too. */ 206 286 G_MODULE_EXPORT struct groupchat *imcb_chat_new( struct im_connection *ic, char *handle ); 207 287 G_MODULE_EXPORT void imcb_chat_add_buddy( struct groupchat *b, char *handle ); 288 /* To remove a handle from a group chat. Reason can be NULL. */ 208 289 G_MODULE_EXPORT void imcb_chat_remove_buddy( struct groupchat *b, char *handle, char *reason ); 290 /* To tell BitlBee 'who' said 'msg' in 'c'. 'flags' and 'sent_at' can be 0. */ 209 291 G_MODULE_EXPORT void imcb_chat_msg( struct groupchat *c, char *who, char *msg, u_int32_t flags, time_t sent_at ); 210 292 G_MODULE_EXPORT void imcb_chat_removed( struct groupchat *c );
Note: See TracChangeset
for help on using the changeset viewer.