4 * Copyright (C) 2002, Sean Egan <bj91704@binghamton.edu>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 #include "gaim-socket.h"
27 void show_remote_usage(char *name
)
29 printf(_("Usage: %s command [OPTIONS] [URI]\n\n"
32 " uri Handle AIM:// URI\n"
33 " info Show information about connected accounts\n"
34 " list Print buddy list\n"
35 " ison Show presence state of your buddy\n"
36 " convo Open a new conversation window\n"
37 " send Send message\n"
38 " add Add buddy to buddy list\n"
39 " remove Remove buddy from list\n"
40 " quit Close running copy of Gaim\n\n"
43 " -m, --message=MESG Message to send or show in conversation window\n"
44 " -t, --to=SCREENNAME Select a target for command\n"
45 " -p, --protocol=PROTO Specify protocol to use\n"
46 " -f, --from=SCREENNAME Specify screenname to use\n"
47 " -q, --quiet Send message without showing a conversation\n"
49 " -h, --help Show help for command\n"), name
);
53 static struct option longopts
[] = {
54 {"message", required_argument
, NULL
, 'm'},
55 {"to", required_argument
, NULL
, 't'},
56 {"protocol",required_argument
, NULL
, 'p'},
57 {"from", required_argument
, NULL
, 'f'},
58 {"quiet", no_argument
, NULL
, 'q'},
59 {"help", no_argument
, NULL
, 'h'},
67 char *message
, *to
, *from
;
72 struct remoteopts opts
;
73 int get_options(int argc
, char *argv
[])
76 memset(&opts
, 0, sizeof(opts
));
78 while ((i
=getopt_long(argc
, argv
, "m:t:p:f:qh", longopts
, NULL
)) != -1) {
81 opts
.message
= optarg
;
101 /* We must have non getopt'ed argument-- the command */
103 opts
.command
= g_strdup(argv
[optind
++]);
107 /* And we can have another argument--the URI. */
109 /* but only if we're using the uri command. */
110 if (!strcmp(opts
.command
, "uri"))
111 opts
.uri
= g_strdup(argv
[optind
++]);
115 /* and we can't have any others. */
126 struct gaim_cui_packet
*p
= NULL
;
127 fd
= gaim_connect_to_session(0);
129 fprintf(stderr
, "Gaim not running (on session 0)\n");
132 p
= cui_packet_new(CUI_TYPE_REMOTE
, CUI_REMOTE_URI
);
133 cui_packet_append_string(p
, opts
.uri
);
134 cui_send_packet (fd
, p
);
142 struct gaim_cui_packet
*p
= NULL
;
143 fd
= gaim_connect_to_session(0);
145 fprintf(stderr
, "Gaim not running (on session 0)\n");
148 p
= cui_packet_new(CUI_TYPE_META
, CUI_META_QUIT
);
149 cui_send_packet (fd
, p
);
156 fprintf(stderr
, "Info not yet implemented\n");
160 int main (int argc
, char *argv
[])
163 if (get_options(argc
, argv
)) {
164 show_remote_usage(argv
[0]);
169 if (!strcmp(opts
.command
, "uri")) {
170 return command_uri();
171 } else if (!strcmp(opts
.command
, "info")) {
172 return command_info();
173 } else if (!strcmp(opts
.command
, "quit")) {
174 return command_quit();
176 show_remote_usage(argv
[0]);