Mercurial > pidgin.yaz
comparison src/gtkconv.c @ 9597:d6f398e80b32
[gaim-migrate @ 10440]
denyri added a void *data argument to most of the command related
functions. This makes it easier for language binding and such.
committer: Tailor Script <tailor@pidgin.im>
author | Tim Ringenbach <marv@pidgin.im> |
---|---|
date | Mon, 26 Jul 2004 03:27:03 +0000 |
parents | 7b3212aa698c |
children | 00e678a71a7f |
comparison
equal
deleted
inserted
replaced
9596:7b3212aa698c | 9597:d6f398e80b32 |
---|---|
286 return "/"; | 286 return "/"; |
287 } | 287 } |
288 | 288 |
289 static GaimCmdRet | 289 static GaimCmdRet |
290 me_command_cb(GaimConversation *conv, | 290 me_command_cb(GaimConversation *conv, |
291 const char *cmd, char **args, char **error) | 291 const char *cmd, char **args, char **error, void *data) |
292 { | 292 { |
293 char *tmp; | 293 char *tmp; |
294 | 294 |
295 tmp = g_strdup_printf("/me %s", args[0]); | 295 tmp = g_strdup_printf("/me %s", args[0]); |
296 | 296 |
303 return GAIM_CMD_RET_OK; | 303 return GAIM_CMD_RET_OK; |
304 } | 304 } |
305 | 305 |
306 static GaimCmdRet | 306 static GaimCmdRet |
307 debug_command_cb(GaimConversation *conv, | 307 debug_command_cb(GaimConversation *conv, |
308 const char *cmd, char **args, char **error) | 308 const char *cmd, char **args, char **error, void *data) |
309 { | 309 { |
310 char *tmp, *markup; | 310 char *tmp, *markup; |
311 GaimCmdStatus status; | 311 GaimCmdStatus status; |
312 | 312 |
313 if (!g_ascii_strcasecmp(args[0], "version")) { | 313 if (!g_ascii_strcasecmp(args[0], "version")) { |
326 } | 326 } |
327 } | 327 } |
328 | 328 |
329 static GaimCmdRet | 329 static GaimCmdRet |
330 help_command_cb(GaimConversation *conv, | 330 help_command_cb(GaimConversation *conv, |
331 const char *cmd, char **args, char **error) | 331 const char *cmd, char **args, char **error, void *data) |
332 { | 332 { |
333 GList *l, *text; | |
333 GString *s; | 334 GString *s; |
334 GList *cmds, *l; | 335 |
335 | 336 if (args[0] != NULL) { |
336 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | 337 s = g_string_new(""); |
337 "The following commands are available in this context:\n")); | 338 text = gaim_cmd_help(conv, args[0]); |
338 | 339 |
339 cmds = gaim_cmd_list(conv); | 340 if (text) { |
340 for (l = cmds; l; l = l->next) | 341 for (l = text; l; l = l->next) |
341 if (l->next) | 342 if (l->next) |
342 g_string_append_printf(s, "%s, ", (char *)l->data); | 343 g_string_append_printf(s, "/%s\n", (char *)l->data); |
343 else | 344 else |
344 g_string_append_printf(s, "%s.", (char *)l->data); | 345 g_string_append_printf(s, "/%s", (char *)l->data); |
346 } else { | |
347 g_string_append(s, _("No such command (in this context).")); | |
348 } | |
349 } else { | |
350 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
351 "The following commands are available in this context:\n")); | |
352 | |
353 text = gaim_cmd_list(conv); | |
354 for (l = text; l; l = l->next) | |
355 if (l->next) | |
356 g_string_append_printf(s, "%s, ", (char *)l->data); | |
357 else | |
358 g_string_append_printf(s, "%s.", (char *)l->data); | |
359 } | |
345 | 360 |
346 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | 361 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); |
347 g_string_free(s, TRUE); | 362 g_string_free(s, TRUE); |
348 g_list_free(cmds); | |
349 | |
350 return GAIM_CMD_STATUS_OK; | |
351 } | |
352 | |
353 static GaimCmdRet | |
354 help_arg_command_cb(GaimConversation *conv, | |
355 const char *cmd, char **args, char **error) | |
356 { | |
357 GList *help, *l; | |
358 GString *s; | |
359 | |
360 s = g_string_new(""); | |
361 help = gaim_cmd_help(conv, args[0]); | |
362 | |
363 if (help) { | |
364 for (l = help; l; l = l->next) | |
365 if (l->next) | |
366 g_string_append_printf(s, "/%s\n", (char *)l->data); | |
367 else | |
368 g_string_append_printf(s, "/%s", (char *)l->data); | |
369 } else { | |
370 g_string_append(s, _("No such command (in this context).")); | |
371 } | |
372 | |
373 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
374 g_string_free(s, TRUE); | |
375 g_list_free(help); | |
376 | 363 |
377 return GAIM_CMD_STATUS_OK; | 364 return GAIM_CMD_STATUS_OK; |
378 } | 365 } |
379 | 366 |
380 static void | 367 static void |
6316 /********************************************************************** | 6303 /********************************************************************** |
6317 * Register commands | 6304 * Register commands |
6318 **********************************************************************/ | 6305 **********************************************************************/ |
6319 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, | 6306 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6320 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | 6307 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
6321 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat.")); | 6308 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
6322 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, | 6309 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6323 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | 6310 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
6324 debug_command_cb, _("debug <option>: Send various debug information to the current conversation.")); | 6311 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
6325 | |
6326 gaim_cmd_register("help", "", GAIM_CMD_P_DEFAULT, | |
6327 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6328 help_command_cb, _("help: List available commands.")); | |
6329 | 6312 |
6330 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, | 6313 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
6331 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | 6314 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6332 help_arg_command_cb, _("help <command>: Help on a specific command.")); | 6315 help_command_cb, _("help <command>: Help on a specific command."), NULL); |
6333 } | 6316 } |
6334 | 6317 |
6335 void | 6318 void |
6336 gaim_gtk_conversations_uninit(void) | 6319 gaim_gtk_conversations_uninit(void) |
6337 { | 6320 { |