annotate src/gaim-remote.c @ 9062:c6d32e1c0120

[gaim-migrate @ 9838] This adds a couple items to our service enum, and some #if 0'd code that doesn't do anything anyway, and makes us send a couple more flags with im's that don't mean a whole lot. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Tue, 25 May 2004 22:43:29 +0000
parents 8b935eddeb10
children d9640b38a65b
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
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
30 /* writes a message 'text' to screen
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
31 * message tries to convert 'text' from utf-8 to user's locale and
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
32 * uses the original message 'text' as a fallback
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
33 *
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
34 * if channel is 1, the message is printed to stdout
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
35 * if channel is 2, the message is printed to stderr
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
36 */
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
37 void message(char *text,int channel)
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
38 {
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
39 char *text_conv=NULL,*text_output;
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
40 GError *error=NULL;
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
41
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
42 text_conv=g_locale_from_utf8(text,-1,NULL,NULL,&error);
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
43
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
44 if(!text_conv) {
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
45 g_warning("%s\n", error->message);
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
46 g_error_free(error);
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
47 }
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
48
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
49 text_output=(text_conv ? text_conv : text);
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
50
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
51 switch(channel) {
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
52 case 1: puts(text_output); break;
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
53 case 2: fputs(text_output, stderr); break;
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
54 default: break;
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
55 }
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
56
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
57 if(text_conv)
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
58 g_free(text_conv);
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
59 }
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
60
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
61 void show_remote_usage(char *name)
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
63 char *text=NULL;
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
64
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
65 text=g_strdup_printf(_("Usage: %s command [OPTIONS] [URI]\n\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
66
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 " COMMANDS:\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
68 " uri Handle AIM: URI\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
69 " quit Close running copy of Gaim\n\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
70
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
71 " OPTIONS:\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
72 " -h, --help [commmand] Show help for command\n"), name);
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
73
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
74 message(text,1);
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
75 g_free(text);
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
76
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
77 return;
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
78 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
79
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
80 /*To be implemented:
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 " info Show information about connected accounts\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 " list Print buddy list\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 " ison Show presence state of your buddy\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 " convo Open a new conversation window\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
85 " send Send message\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 " add Add buddy to buddy list\n"
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
87 " remove Remove buddy from list\n"
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 " -m, --message=MESG Message to send or show in conversation window\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 " -t, --to=SCREENNAME Select a target for command\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 " -p, --protocol=PROTO Specify protocol to use\n"
8154
064ecf11a36a [gaim-migrate @ 8866]
Mark Doliner <mark@kingant.net>
parents: 8152
diff changeset
91 " -f, --from=SCREENNAME Specify screen name to use\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
92 " -q, --quiet Send message without showing a conversation\n"
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 " window\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
94 */
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 static struct option longopts[] = {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 {"message", required_argument, NULL, 'm'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 {"to", required_argument, NULL, 't'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 {"protocol",required_argument, NULL, 'p'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 {"from", required_argument, NULL, 'f'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 {"quiet", no_argument, NULL, 'q'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 {"help", no_argument, NULL, 'h'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 {0,0,0,0}
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
104 };
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
105
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
106 struct remoteopts {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 char *command;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 char *uri;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 gboolean help, quiet;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 char *message, *to, *from;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 int protocol;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
112 };
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
113
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 struct remoteopts opts;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 int get_options(int argc, char *argv[])
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 int i;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 memset(&opts, 0, sizeof(opts));
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120 opts.protocol = -1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 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
122 switch (i) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 case 'm':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 opts.message = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
125 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126 case 't':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 opts.to = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129 case 'p':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 /* Do stuff here. */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 case 'f':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 opts.from = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 case 'q':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 opts.quiet = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 case 'h':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 opts.help = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 /* We must have non getopt'ed argument-- the command */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 if (optind < argc)
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 opts.command = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
147 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
148 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
150 if(opts.help)
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
151 return 0;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
152
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 /* And we can have another argument--the URI. */
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
154 /* but only if we're using the uri command. */
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
155 if (!strcmp(opts.command, "uri")) {
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
156 if(argc-optind==1)
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 opts.uri = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
158 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 }
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
161 else if(optind==argc)
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
162 return 0;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
163 else
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
164 return 1;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
165
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
166 return 0;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
167 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 int command_uri() {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
170 int fd = 0;
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
171 GaimRemotePacket *p = NULL;
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
172 fd = gaim_remote_session_connect(0);
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
173 if (fd<0) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
174 message(_("Gaim not running (on session 0)\n"),2);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
175 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176 }
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
177 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
178 gaim_remote_packet_append_string(p, opts.uri);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
179 gaim_remote_session_send_packet(fd, p);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 close(fd);
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
181 gaim_remote_packet_free(p);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
182 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
183 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
185 int command_quit() {
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
186 int fd = 0;
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
187 GaimRemotePacket *p = NULL;
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
188 fd = gaim_remote_session_connect(0);
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
189 if (fd<0) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
190 message(_("Gaim not running (on session 0)\n"),2);
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
191 return 1;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
192 }
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
193 p = gaim_remote_packet_new(CUI_TYPE_META, CUI_META_QUIT);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
194 gaim_remote_session_send_packet(fd, p);
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
195 close(fd);
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
196 gaim_remote_packet_free(p);
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
197 return 0;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
198 }
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
199
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
200 void show_longhelp_uri( char *name, char *command)
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
201 {
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
202 if(!strcmp(command, "uri")) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
203 message(_("\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
204 "Using AIM: URIs:\n"
8152
82aeed3c90f0 [gaim-migrate @ 8864]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
205 "Sending an IM to a screen name:\n"
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
206 " 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
207 "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
208 "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
209 "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
210 "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
211 "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
212 "with no message:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
213 " gaim-remote uri 'aim:goim?screenname=Penguin'\n\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
214 "Joining a chat:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
215 " gaim-remote uri 'aim:gochat?roomname=PenguinLounge'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
216 "...joins the 'PenguinLounge' chat room.\n\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
217 "Adding a buddy to your buddy list:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
218 " gaim-remote uri 'aim:addbuddy?screenname=Penguin'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
219 "...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
220 }
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
221 else if(!strcmp(command, "quit")) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
222 message(_("\nClose running copy of Gaim\n"), 1);
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
223 }
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
224 else {
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
225 show_remote_usage(name);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
226 }
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
227 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
228
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
229 /* Work in progress - JBS
3867
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3559
diff changeset
230 int command_info(){
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3559
diff changeset
231 fprintf(stderr, "Info not yet implemented\n");
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3559
diff changeset
232 return 1;
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
233 }*/
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
234
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
235 int main (int argc, char *argv[])
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
236 {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
237
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
238 #ifdef ENABLE_NLS
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
239 setlocale (LC_ALL, "");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
240 bindtextdomain(PACKAGE, LOCALEDIR);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
241 bind_textdomain_codeset(PACKAGE, "UTF-8");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
242 textdomain(PACKAGE);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
243 #endif
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
244
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
245 if (get_options(argc, argv)) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
246 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
247 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
248 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
249
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
250
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
251 if (!strcmp(opts.command, "uri")) {
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
252 if(opts.help){
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
253 show_longhelp_uri(argv[0], "uri");
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
254 }else{
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
255 return command_uri();
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
256 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
257 /* } else if (!strcmp(opts.command, "info")) {
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
258 return command_info();*/
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
259 } else if (!strcmp(opts.command, "quit")) {
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
260 if(opts.help){
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
261 show_longhelp_uri(argv[0], "quit");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
262 }else{
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
263 return command_quit();
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
264 }
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
265 } else {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
266 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
267 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
268 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
269
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
270 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
271 }