Mercurial > pidgin.yaz
diff libpurple/protocols/jabber/adhoccommands.c @ 18691:54a5fbeadd7c
Now showing ad-hoc commands of other clients connected to the same account in the account menu (per XEP-0146). Since it is becoming messy in that menu, I also prefixed all ad-hoc commands with the node this command belongs to in [], which is the resource name for clients and the domain name for the server. Examples: "[home] Set status" for clients and "[jabber.org] Send message to all connected users" for servers.
author | Andreas Monitzer <pidgin@monitzer.com> |
---|---|
date | Fri, 13 Jul 2007 15:34:16 +0000 |
parents | 49fe31a64716 |
children | c72d2458b22e |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/adhoccommands.c Thu Jul 12 03:24:55 2007 +0000 +++ b/libpurple/protocols/jabber/adhoccommands.c Fri Jul 13 15:34:16 2007 +0000 @@ -262,11 +262,34 @@ void jabber_adhoc_init_server_commands(JabberStream *js, GList **m) { GList *cmdlst; + JabberBuddy *jb; + /* also add commands for other clients connected to the same account on another resource */ + char *accountname = g_strdup_printf("%s@%s", js->user->node, js->user->domain); + if((jb = jabber_buddy_find(js, accountname, TRUE))) { + GList *iter; + for(iter = jb->resources; iter; iter = g_list_next(iter)) { + JabberBuddyResource *jbr = iter->data; + GList *riter; + for(riter = jbr->commands; riter; riter = g_list_next(riter)) { + JabberAdHocCommands *cmd = riter->data; + char *cmdname = g_strdup_printf("[%s] %s",jbr->name,cmd->name); + PurplePluginAction *act = purple_plugin_action_new(cmdname, jabber_adhoc_server_execute); + act->user_data = cmd; + *m = g_list_append(*m, act); + g_free(cmdname); + } + } + } + g_free(accountname); + + /* now add server commands */ for(cmdlst = js->commands; cmdlst; cmdlst = g_list_next(cmdlst)) { JabberAdHocCommands *cmd = cmdlst->data; - PurplePluginAction *act = purple_plugin_action_new(cmd->name, jabber_adhoc_server_execute); + char *cmdname = g_strdup_printf("[%s] %s",js->user->domain,cmd->name); + PurplePluginAction *act = purple_plugin_action_new(cmdname, jabber_adhoc_server_execute); act->user_data = cmd; *m = g_list_append(*m, act); + g_free(cmdname); } }