annotate src/gaim-remote.c @ 10940:999555fbbbd9

[gaim-migrate @ 12730] this is the other jabber ft thing, which went into oldstatus for 1.3.0 committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Thu, 26 May 2005 03:54:25 +0000
parents b4b9dabdd7c7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
1 /*
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
2 * gaim-remote
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
3 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7724
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7724
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7724
diff changeset
6 * source distribution.
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
7 *
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
24 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5859
diff changeset
25
3533
6c32036050cf [gaim-migrate @ 3607]
Sean Egan <seanegan@gmail.com>
parents: 3480
diff changeset
26 #include <getopt.h>
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
27
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
28 #include <gaim-remote/remote.h>
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
30 /* To be implemented:
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
31 " info Show information about connected accounts\n"
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
32 " list Print buddy list\n"
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
33 " ison Show presence state of your buddy\n"
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
34 " convo Open a new conversation window\n"
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
35 " add Add buddy to buddy list\n"
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
36 " remove Remove buddy from list\n"
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
37 " -q, --quiet Send message without showing a conversation\n"
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
38 " window\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
39 */
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
40
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
41 static struct option longopts[] = {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
42 {"message", required_argument, NULL, 'm'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
43 {"to", required_argument, NULL, 't'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 {"protocol",required_argument, NULL, 'p'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 {"from", required_argument, NULL, 'f'},
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
46 {"session", required_argument, NULL, 's'},
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 {"quiet", no_argument, NULL, 'q'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 {"help", no_argument, NULL, 'h'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 {0,0,0,0}
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
50 };
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 struct remoteopts {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 char *command;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 char *uri;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
55 gboolean help, quiet;
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
56 char *message, *to, *from, *protocol, *session;
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
57 /*int protocol;*/
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58 };
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
59 struct remoteopts opts;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
61 /*
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
62 * Prints a message to the terminal/shell/console.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
63 * We try to convert "text" from UTF-8 to the user's locale.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
64 * If that fails then UTF-8 is used as a fallback.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
65 *
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
66 * If channel is 1, the message is printed to stdout.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
67 * if channel is 2, the message is printed to stderr.
10395
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
68 */
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
69 static void
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
70 message(char *text, int channel)
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
71 {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
72 char *text_conv = NULL,*text_output;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
73 GError *error = NULL;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
74
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
75 text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
76
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
77 if (text_conv == NULL) {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
78 g_warning("%s\n", error->message);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
79 g_error_free(error);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
80 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
81
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
82 text_output = (text_conv ? text_conv : text);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
84 switch (channel) {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
85 case 1:
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
86 puts(text_output);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
87 break;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
88 case 2:
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
89 fputs(text_output, stderr);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
90 break;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
91 default:
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
92 break;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
93 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
94
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
95 if (text_conv)
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
96 g_free(text_conv);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
97 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
98
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
99 static void
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
100 show_remote_usage(const char *name)
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
101 {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
102 char *text = NULL;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
103
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
104 text = g_strdup_printf(_("Usage: %s command [OPTIONS] [URI]\n\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
105 " COMMANDS:\n"
10395
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
106 " send Send message\n"
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
107 " uri Handle AIM: URI\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
108 " away Popup the away dialog with the default message\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
109 " back Remove the away dialog\n"
10395
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
110 " logout Log out all accounts\n"
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
111 " quit Close running copy of Gaim\n"
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
112 "\n"
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
113 " OPTIONS:\n"
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
114 " -m, --message=MESG Message to send or show in conversation window\n"
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
115 " -t, --to=SCREENNAME Select a target for command\n"
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
116 " -p, --protocol=PROTO Specify protocol to use\n"
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
117 " -f, --from=SCREENNAME Specify screen name to use\n"
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
118 " -s, --session=SESSION Specify which Gaim session to use\n"
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
119 " -h, --help [command] Show help for command\n"), name);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
120
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
121 message(text, 1);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
122 g_free(text);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
123
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
124 return;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
125 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
126
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
127 int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
128 get_options(int argc, char *argv[])
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 int i;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
131
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 memset(&opts, 0, sizeof(opts));
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
133 /*opts.protocol = -1;*/
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
134
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
135 while ((i=getopt_long(argc, argv, "m:t:p:f:s:qh", longopts, NULL)) != -1) {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 switch (i) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 case 'm':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 opts.message = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 case 't':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 opts.to = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 case 'p':
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
144 opts.protocol = optarg;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 case 'f':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 opts.from = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 break;
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
149 case 's':
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
150 opts.session = optarg;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
151 break;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 case 'q':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 opts.quiet = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 case 'h':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 opts.help = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 }
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
160
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 /* We must have non getopt'ed argument-- the command */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 if (optind < argc)
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 opts.command = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
166
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
167 if (opts.help)
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
168 return 0;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
169
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 /* And we can have another argument--the URI. */
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
171 /* but only if we're using the uri command. */
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
172 if (!strcmp(opts.command, "uri")) {
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
173 if (argc-optind == 1)
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 opts.uri = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 return 1;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
177 } else if (optind == argc)
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
178 return 0;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
179 else
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
180 return 1;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
181
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
182 return 0;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
183 }
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
184
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
185 static int
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
186 open_session() {
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
187 int fd = 0, session = 0;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
188 char *msg;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
189
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
190 if (opts.session != NULL)
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
191 session = atoi(opts.session);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
192
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
193 fd = gaim_remote_session_connect(session);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
194 if (fd < 0) {
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
195 msg = g_strdup_printf(_("Gaim not running (on session %d)\nIs the \"Remote Control\" plugin loaded?\n"), session);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
196 message(msg, 2);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
197 g_free(msg);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
198 return -1;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
199 }
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
200
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
201 return fd;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
202 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
203
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
204 static int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
205 send_generic_command(guchar type, guchar subtype) {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206 int fd = 0;
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
207 GaimRemotePacket *p = NULL;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
208
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
209 fd = open_session();
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
210 if (fd < 0) {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
211 return 1;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
212 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
213 p = gaim_remote_packet_new(type, subtype);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
214 gaim_remote_session_send_packet(fd, p);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
215 close(fd);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
216 gaim_remote_packet_free(p);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
217
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
218 return 0;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
219 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
220
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
221 static int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
222 send_command_uri() {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
223 int fd = 0;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
224 GaimRemotePacket *p = NULL;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
225
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
226 fd = open_session();
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
227 if (fd < 0) {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
228 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
229 }
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
230 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
231 gaim_remote_packet_append_string(p, opts.uri);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
232 gaim_remote_session_send_packet(fd, p);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233 close(fd);
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
234 gaim_remote_packet_free(p);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
235
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
236 return 0;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
237 }
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
238
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
239 static int
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
240 send_command_send() {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
241 int fd = 0;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
242 GaimRemotePacket *p = NULL;
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
243 char temp[10003]; /* TODO: Future implementation should send packets instead */
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
244
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
245 fd = open_session();
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
246 if (fd < 0) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
247 return 1;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
248 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
249 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_SEND);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
250
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
251 /*
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
252 * Format is as follows:
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
253 * Each string has a 4 character 'header' containing the length of the string
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
254 * The strings are: To, From, Protocol name, Message
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
255 * Following the message is the quiet flag, expressed in a single int (0/1)
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
256 * Because the header is 4 characters long, there is a 9999 char limit on any
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
257 * given string, though none of these strings should be exceeding this.
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
258 * -JBS
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
259 */
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
260
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
261 if (opts.to && *opts.to && opts.from && *opts.from &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
262 opts.protocol && *opts.protocol && opts.message && *opts.message &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
263 (strlen(opts.to) < 10000) && (strlen(opts.from) < 10000) &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
264 (strlen(opts.protocol) < 20) && (strlen(opts.message) < 10000) )
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
265 {
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10086
diff changeset
266 sprintf(temp, "%04zd%s", strlen(opts.to), opts.to);
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
267 gaim_remote_packet_append_string(p, temp);
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10086
diff changeset
268 sprintf(temp, "%04zd%s", strlen(opts.from), opts.from);
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
269 gaim_remote_packet_append_string(p, temp);
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10086
diff changeset
270 sprintf(temp, "%04zd%s", strlen(opts.protocol), opts.protocol);
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
271 gaim_remote_packet_append_string(p, temp);
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10086
diff changeset
272 sprintf(temp, "%04zd%s", strlen(opts.message), opts.message);
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
273 gaim_remote_packet_append_string(p, temp);
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
274 sprintf(temp, "%d", 0); /* quiet flag - off for now */
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
275 gaim_remote_packet_append_string(p, temp);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
276
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
277 gaim_remote_session_send_packet (fd, p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
278 close(fd);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
279 gaim_remote_packet_free(p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
280 return 0;
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
281 } else {
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
282 message(_("Insufficient arguments (-t, -f, -p, & -m are all required) or arguments greater than 9999 chars\n"), 2);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
283 close(fd);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
284 gaim_remote_packet_free(p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
285 return 1;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
286 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
287 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
288
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
289 static void
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
290 show_longhelp( char *name, char *command)
9608
204f5d66a863 [gaim-migrate @ 10451]
Luke Schierer <lschiere@pidgin.im>
parents: 9184
diff changeset
291 {
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
292 if (!strcmp(command, "uri")) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
293 message(_("\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
294 "Using AIM: URIs:\n"
8152
82aeed3c90f0 [gaim-migrate @ 8864]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
295 "Sending an IM to a screen name:\n"
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
296 " gaim-remote uri 'aim:goim?screenname=Penguin&message=hello+world'\n"
8152
82aeed3c90f0 [gaim-migrate @ 8864]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
297 "In this case, 'Penguin' is the screen name we wish to IM, and 'hello world'\n"
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
298 "is the message to be sent. '+' must be used in place of spaces.\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
299 "Please note the quoting used above - if you run this from a shell the '&'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
300 "needs to be escaped, or the command will stop at that point.\n"
8152
82aeed3c90f0 [gaim-migrate @ 8864]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
301 "Also,the following will just open a conversation window to a screen name,\n"
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
302 "with no message:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
303 " gaim-remote uri 'aim:goim?screenname=Penguin'\n\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
304 "Joining a chat:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
305 " gaim-remote uri 'aim:gochat?roomname=PenguinLounge'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
306 "...joins the 'PenguinLounge' chat room.\n\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
307 "Adding a buddy to your buddy list:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
308 " gaim-remote uri 'aim:addbuddy?screenname=Penguin'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
309 "...prompts you to add 'Penguin' to your buddy list.\n"), 1);
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
310 }
9695
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
311
10395
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
312 else if (!strcmp(command, "logout")) {
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
313 message(_("\nLog out all accounts\n"), 1);
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
314 }
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
315
9695
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
316 else if (!strcmp(command, "quit")) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
317 message(_("\nClose running copy of Gaim\n"), 1);
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
318 }
9695
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
319
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
320 else if (!strcmp(command, "away")) {
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
321 message(_("\nMark all accounts as \"away\" with the default message.\n"), 1);
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
322 }
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
323
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
324 else if (!strcmp(command, "back")) {
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
325 message(_("\nSet all accounts as not away.\n"), 1);
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
326 }
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
327
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
328 else if (!strcmp(command, "send")) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
329 message(_("\nSend instant message\n"), 1);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
330 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
331
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
332 else {
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
333 show_remote_usage(name);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
334 }
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
335 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
336
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
337 int main(int argc, char *argv[])
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
338 {
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
339 #ifdef ENABLE_NLS
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
340 setlocale (LC_ALL, "");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
341 bindtextdomain(PACKAGE, LOCALEDIR);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
342 bind_textdomain_codeset(PACKAGE, "UTF-8");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
343 textdomain(PACKAGE);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
344 #endif
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
345
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
346 if (get_options(argc, argv)) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
347 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
348 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
349 }
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
350
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
351 if (!strcmp(opts.command, "uri")) {
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
352 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
353 show_longhelp(argv[0], "uri");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
354 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
355 return send_command_uri();
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
356 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
357
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
358 else if (!strcmp(opts.command, "send")) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
359 if (opts.help)
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
360 show_longhelp(argv[0], "send");
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
361 else
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
362 return send_command_send();
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
363 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
364
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
365 else if (!strcmp(opts.command, "away")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
366 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
367 show_longhelp(argv[0], "away");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
368 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
369 return send_generic_command(CUI_TYPE_USER, CUI_USER_AWAY);
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
370 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
371
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
372 else if (!strcmp(opts.command, "back")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
373 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
374 show_longhelp(argv[0], "back");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
375 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
376 return send_generic_command(CUI_TYPE_USER, CUI_USER_BACK);
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
377 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
378
10395
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
379 else if (!strcmp(opts.command, "logout")) {
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
380 if (opts.help)
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
381 show_longhelp(argv[0], "logout");
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
382 else
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
383 return send_generic_command(CUI_TYPE_USER, CUI_USER_LOGOUT);
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
384 }
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
385
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
386 else if (!strcmp(opts.command, "quit")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
387 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
388 show_longhelp(argv[0], "quit");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
389 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
390 return send_generic_command(CUI_TYPE_META, CUI_META_QUIT);
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
391 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
392
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
393 else {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
394 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
395 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
396 }
10395
b4b9dabdd7c7 [gaim-migrate @ 11624]
Mark Doliner <mark@kingant.net>
parents: 10112
diff changeset
397
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
398 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
399 }