Mercurial > pidgin.yaz
changeset 10086:6cd2b467e303
[gaim-migrate @ 11097]
Add a --session option to gaim-remote to allow manipulating multiple Gaim
instances
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Sun, 10 Oct 2004 16:47:56 +0000 |
parents | 9c174a7f9afc |
children | 9fdbfe832fac |
files | src/gaim-remote.c |
diffstat | 1 files changed, 31 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/gaim-remote.c Sun Oct 10 16:37:37 2004 +0000 +++ b/src/gaim-remote.c Sun Oct 10 16:47:56 2004 +0000 @@ -43,6 +43,7 @@ {"to", required_argument, NULL, 't'}, {"protocol",required_argument, NULL, 'p'}, {"from", required_argument, NULL, 'f'}, + {"session", required_argument, NULL, 's'}, {"quiet", no_argument, NULL, 'q'}, {"help", no_argument, NULL, 'h'}, {0,0,0,0} @@ -52,7 +53,7 @@ char *command; char *uri; gboolean help, quiet; - char *message, *to, *from, *protocol; + char *message, *to, *from, *protocol, *session; /*int protocol;*/ }; struct remoteopts opts; @@ -112,6 +113,7 @@ " -t, --to=SCREENNAME Select a target for command\n" " -p, --protocol=PROTO Specify protocol to use\n" " -f, --from=SCREENNAME Specify screen name to use\n" + " -s, --session=SESSION Specify which Gaim session to use\n" " -h, --help [command] Show help for command\n"), name); message(text, 1); @@ -128,7 +130,7 @@ memset(&opts, 0, sizeof(opts)); /*opts.protocol = -1;*/ - while ((i=getopt_long(argc, argv, "m:t:p:f:qh", longopts, NULL)) != -1) { + while ((i=getopt_long(argc, argv, "m:t:p:f:s:qh", longopts, NULL)) != -1) { switch (i) { case 'm': opts.message = optarg; @@ -142,6 +144,9 @@ case 'f': opts.from = optarg; break; + case 's': + opts.session = optarg; + break; case 'q': opts.quiet = TRUE; break; @@ -150,7 +155,7 @@ break; } } - + /* We must have non getopt'ed argument-- the command */ if (optind < argc) opts.command = g_strdup(argv[optind++]); @@ -172,7 +177,26 @@ else return 1; - return 0; + return 0; +} + +static int +open_session() { + int fd = 0, session = 0; + char *msg; + + if (opts.session != NULL) + session = atoi(opts.session); + + fd = gaim_remote_session_connect(session); + if (fd < 0) { + msg = g_strdup_printf(_("Gaim not running (on session %d)\nIs the \"Remote Control\" plugin loaded?\n"), session); + message(msg, 2); + g_free(msg); + return -1; + } + + return fd; } static int @@ -180,9 +204,8 @@ int fd = 0; GaimRemotePacket *p = NULL; - fd = gaim_remote_session_connect(0); + fd = open_session(); if (fd < 0) { - message(_("Gaim not running (on session 0)\nIs the \"Remote Control\" plugin loaded?\n"), 2); return 1; } p = gaim_remote_packet_new(type, subtype); @@ -198,9 +221,8 @@ int fd = 0; GaimRemotePacket *p = NULL; - fd = gaim_remote_session_connect(0); + fd = open_session(); if (fd < 0) { - message(_("Gaim not running (on session 0)\nIs the \"Remote Control\" plugin loaded?\n"), 2); return 1; } p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI); @@ -218,9 +240,8 @@ GaimRemotePacket *p = NULL; char temp[10003]; /* TODO: Future implementation should send packets instead */ - fd = gaim_remote_session_connect(0); + fd = open_session(); if (fd < 0) { - message(_("Gaim not running (on session 0)\nIs the \"Remote Control\" plugin loaded?\n"), 2); return 1; } p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_SEND);