annotate src/gaim-remote.c @ 10007:267a2b69e36e

[gaim-migrate @ 10924] Better i18nability and more uniform code? committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Fri, 10 Sep 2004 04:30:37 +0000
parents c892b6dbc341
children 6cd2b467e303
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'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 {"quiet", no_argument, NULL, 'q'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 {"help", no_argument, NULL, 'h'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 {0,0,0,0}
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 };
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 struct remoteopts {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 char *command;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 char *uri;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 gboolean help, quiet;
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
55 char *message, *to, *from, *protocol;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
56 /*int protocol;*/
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
57 };
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
58 struct remoteopts opts;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
60 /*
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
61 * Prints a message to the terminal/shell/console.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
62 * 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
63 * If that fails then UTF-8 is used as a fallback.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
64 *
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
65 * If channel is 1, the message is printed to stdout.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
66 * if channel is 2, the message is printed to stderr.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
67 */
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
68 static void
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
69 message(char *text, int channel)
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
70 {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
71 char *text_conv = NULL,*text_output;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
72 GError *error = NULL;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
73
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
74 text_conv = g_locale_from_utf8(text, -1, NULL, NULL, &error);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
75
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
76 if (text_conv == NULL) {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
77 g_warning("%s\n", error->message);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
78 g_error_free(error);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
79 }
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 text_output = (text_conv ? text_conv : text);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
83 switch (channel) {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
84 case 1:
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
85 puts(text_output);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
86 break;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
87 case 2:
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
88 fputs(text_output, stderr);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
89 break;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
90 default:
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
91 break;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
92 }
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 if (text_conv)
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
95 g_free(text_conv);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
96 }
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 static void
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
99 show_remote_usage(const char *name)
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
100 {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
101 char *text = NULL;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
102
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
103 text = g_strdup_printf(_("Usage: %s command [OPTIONS] [URI]\n\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
104 " COMMANDS:\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
105 " uri Handle AIM: URI\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
106 " away Popup the away dialog with the default message\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
107 " back Remove the away dialog\n"
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
108 " send Send message\n"
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
109 " quit Close running copy of Gaim\n\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
110 " OPTIONS:\n"
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
111 " -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
112 " -t, --to=SCREENNAME Select a target for command\n"
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
113 " -p, --protocol=PROTO Specify protocol to use\n"
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
114 " -f, --from=SCREENNAME Specify screen name to use\n"
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
115 " -h, --help [command] Show help for command\n"), name);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
116
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
117 message(text, 1);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
118 g_free(text);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
119
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
120 return;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
121 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
122
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
123 int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
124 get_options(int argc, char *argv[])
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 int i;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
127
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 memset(&opts, 0, sizeof(opts));
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
129 /*opts.protocol = -1;*/
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
130
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 while ((i=getopt_long(argc, argv, "m:t:p:f:qh", longopts, NULL)) != -1) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 switch (i) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 case 'm':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 opts.message = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 case 't':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 opts.to = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 case 'p':
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
140 opts.protocol = optarg;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 case 'f':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 opts.from = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 case 'q':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 opts.quiet = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 case 'h':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 opts.help = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 /* We must have non getopt'ed argument-- the command */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 if (optind < argc)
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 opts.command = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
160 if (opts.help)
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
161 return 0;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
162
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 /* And we can have another argument--the URI. */
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
164 /* but only if we're using the uri command. */
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
165 if (!strcmp(opts.command, "uri")) {
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
166 if (argc-optind == 1)
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 opts.uri = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 return 1;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
170 } else if (optind == argc)
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
171 return 0;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
172 else
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
173 return 1;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
174
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
175 return 0;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
177
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
178 static int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
179 send_generic_command(guchar type, guchar subtype) {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 int fd = 0;
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
181 GaimRemotePacket *p = NULL;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
182
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
183 fd = gaim_remote_session_connect(0);
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
184 if (fd < 0) {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
185 message(_("Gaim not running (on session 0)\nIs the \"Remote Control\" plugin loaded?\n"), 2);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
186 return 1;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
187 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
188 p = gaim_remote_packet_new(type, subtype);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
189 gaim_remote_session_send_packet(fd, p);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
190 close(fd);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
191 gaim_remote_packet_free(p);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
192
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
193 return 0;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
194 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
195
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
196 static int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
197 send_command_uri() {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
198 int fd = 0;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
199 GaimRemotePacket *p = NULL;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
200
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
201 fd = gaim_remote_session_connect(0);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
202 if (fd < 0) {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
203 message(_("Gaim not running (on session 0)\nIs the \"Remote Control\" plugin loaded?\n"), 2);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 }
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
206 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
207 gaim_remote_packet_append_string(p, opts.uri);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
208 gaim_remote_session_send_packet(fd, p);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 close(fd);
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
210 gaim_remote_packet_free(p);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
212 return 0;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
213 }
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
214
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
215 static int
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
216 send_command_send() {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
217 int fd = 0;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
218 GaimRemotePacket *p = NULL;
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
219 char temp[10003]; /* TODO: Future implementation should send packets instead */
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
220
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
221 fd = gaim_remote_session_connect(0);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
222 if (fd < 0) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
223 message(_("Gaim not running (on session 0)\nIs the \"Remote Control\" plugin loaded?\n"), 2);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
224 return 1;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
225 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
226 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_SEND);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
227
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
228 /*
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
229 * Format is as follows:
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
230 * 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
231 * The strings are: To, From, Protocol name, Message
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
232 * 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
233 * 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
234 * given string, though none of these strings should be exceeding this.
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
235 * -JBS
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
236 */
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
237
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
238 if (opts.to && *opts.to && opts.from && *opts.from &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
239 opts.protocol && *opts.protocol && opts.message && *opts.message &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
240 (strlen(opts.to) < 10000) && (strlen(opts.from) < 10000) &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
241 (strlen(opts.protocol) < 20) && (strlen(opts.message) < 10000) )
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
242 {
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
243 sprintf(temp, "%04d%s", strlen(opts.to), opts.to);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
244 gaim_remote_packet_append_string(p, temp);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
245 sprintf(temp, "%04d%s", strlen(opts.from), opts.from);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
246 gaim_remote_packet_append_string(p, temp);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
247 sprintf(temp, "%04d%s", strlen(opts.protocol), opts.protocol);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
248 gaim_remote_packet_append_string(p, temp);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
249 sprintf(temp, "%04d%s", strlen(opts.message), opts.message);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
250 gaim_remote_packet_append_string(p, temp);
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
251 sprintf(temp, "%d", 0); /* quiet flag - off for now */
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
252 gaim_remote_packet_append_string(p, temp);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
253
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
254 gaim_remote_session_send_packet (fd, p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
255 close(fd);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
256 gaim_remote_packet_free(p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
257 return 0;
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
258 } else {
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
259 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
260 close(fd);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
261 gaim_remote_packet_free(p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
262 return 1;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
263 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
264 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
265
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
266 static void
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
267 show_longhelp( char *name, char *command)
9608
204f5d66a863 [gaim-migrate @ 10451]
Luke Schierer <lschiere@pidgin.im>
parents: 9184
diff changeset
268 {
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
269 if (!strcmp(command, "uri")) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
270 message(_("\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
271 "Using AIM: URIs:\n"
8152
82aeed3c90f0 [gaim-migrate @ 8864]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
272 "Sending an IM to a screen name:\n"
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
273 " 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
274 "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
275 "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
276 "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
277 "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
278 "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
279 "with no message:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
280 " gaim-remote uri 'aim:goim?screenname=Penguin'\n\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
281 "Joining a chat:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
282 " gaim-remote uri 'aim:gochat?roomname=PenguinLounge'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
283 "...joins the 'PenguinLounge' chat room.\n\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
284 "Adding a buddy to your buddy list:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
285 " gaim-remote uri 'aim:addbuddy?screenname=Penguin'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
286 "...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
287 }
9695
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
288
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
289 else if (!strcmp(command, "quit")) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
290 message(_("\nClose running copy of Gaim\n"), 1);
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
291 }
9695
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
292
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
293 else if (!strcmp(command, "away")) {
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
294 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
295 }
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
296
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
297 else if (!strcmp(command, "back")) {
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
298 message(_("\nSet all accounts as not away.\n"), 1);
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
299 }
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
300
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
301 else if (!strcmp(command, "send")) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
302 message(_("\nSend instant message\n"), 1);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
303 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
304
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
305 else {
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
306 show_remote_usage(name);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
307 }
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
308 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
309
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
310 int main(int argc, char *argv[])
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 {
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
312 #ifdef ENABLE_NLS
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
313 setlocale (LC_ALL, "");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
314 bindtextdomain(PACKAGE, LOCALEDIR);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
315 bind_textdomain_codeset(PACKAGE, "UTF-8");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
316 textdomain(PACKAGE);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
317 #endif
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
318
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
319 if (get_options(argc, argv)) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
320 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
321 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
322 }
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
323
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
324 if (!strcmp(opts.command, "uri")) {
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
325 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
326 show_longhelp(argv[0], "uri");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
327 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
328 return send_command_uri();
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
329 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
330
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
331 else if (!strcmp(opts.command, "send")) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
332 if (opts.help)
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
333 show_longhelp(argv[0], "send");
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
334 else
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
335 return send_command_send();
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
336 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
337
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
338 else if (!strcmp(opts.command, "away")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
339 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
340 show_longhelp(argv[0], "away");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
341 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
342 return send_generic_command(CUI_TYPE_USER, CUI_USER_AWAY);
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
343 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
344
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
345 else if (!strcmp(opts.command, "back")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
346 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
347 show_longhelp(argv[0], "back");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
348 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
349 return send_generic_command(CUI_TYPE_USER, CUI_USER_BACK);
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
350 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
351
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
352 else if (!strcmp(opts.command, "quit")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
353 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
354 show_longhelp(argv[0], "quit");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
355 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
356 return send_generic_command(CUI_TYPE_META, CUI_META_QUIT);
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
357 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
358
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
359 else {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
360 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
361 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
362 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
363
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
365 }