annotate src/gaim-remote.c @ 10313:455c0830d108

[gaim-migrate @ 11511] " There was a mistake in the name of this header file. Actually it was declared as #include "gaim-disclosure.h" when it should have been #include "gtkgaim-disclosure.h"..." --Norberto Lopes I don't have the evolution stuff installed, so i didn't notice this. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Fri, 03 Dec 2004 12:19:03 +0000
parents 1a91e814e9d8
children b4b9dabdd7c7
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.
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
68 */
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"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
106 " uri Handle AIM: URI\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
107 " away Popup the away dialog with the default message\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
108 " back Remove the away dialog\n"
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
109 " send Send message\n"
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
110 " quit Close running copy of Gaim\n\n"
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
111 " OPTIONS:\n"
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
112 " -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
113 " -t, --to=SCREENNAME Select a target for command\n"
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
114 " -p, --protocol=PROTO Specify protocol to use\n"
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
115 " -f, --from=SCREENNAME Specify screen name to use\n"
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
116 " -s, --session=SESSION Specify which Gaim session to use\n"
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
117 " -h, --help [command] Show help for command\n"), name);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
118
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
119 message(text, 1);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
120 g_free(text);
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 return;
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
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
125 int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
126 get_options(int argc, char *argv[])
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
127 {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128 int i;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
129
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 memset(&opts, 0, sizeof(opts));
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
131 /*opts.protocol = -1;*/
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
132
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
133 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
134 switch (i) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 case 'm':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 opts.message = optarg;
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 't':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 opts.to = optarg;
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 case 'p':
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
142 opts.protocol = optarg;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 case 'f':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 opts.from = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146 break;
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
147 case 's':
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
148 opts.session = optarg;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
149 break;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
150 case 'q':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
151 opts.quiet = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
152 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153 case 'h':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
154 opts.help = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
155 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
156 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157 }
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
158
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
159 /* We must have non getopt'ed argument-- the command */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
160 if (optind < argc)
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
161 opts.command = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
163 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
164
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
165 if (opts.help)
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
166 return 0;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
167
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
168 /* And we can have another argument--the URI. */
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
169 /* but only if we're using the uri command. */
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
170 if (!strcmp(opts.command, "uri")) {
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
171 if (argc-optind == 1)
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
172 opts.uri = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
174 return 1;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
175 } else if (optind == argc)
6643
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
176 return 0;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
177 else
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
178 return 1;
0dfe02111e20 [gaim-migrate @ 7168]
Luke Schierer <lschiere@pidgin.im>
parents: 5872
diff changeset
179
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
180 return 0;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
181 }
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
182
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
183 static int
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
184 open_session() {
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
185 int fd = 0, session = 0;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
186 char *msg;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
187
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
188 if (opts.session != NULL)
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
189 session = atoi(opts.session);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
190
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
191 fd = gaim_remote_session_connect(session);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
192 if (fd < 0) {
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
193 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
194 message(msg, 2);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
195 g_free(msg);
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
196 return -1;
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
197 }
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
198
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
199 return fd;
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
200 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
201
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
202 static int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
203 send_generic_command(guchar type, guchar subtype) {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
204 int fd = 0;
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
205 GaimRemotePacket *p = NULL;
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
206
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
207 fd = open_session();
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
208 if (fd < 0) {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
209 return 1;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
210 }
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
211 p = gaim_remote_packet_new(type, subtype);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
212 gaim_remote_session_send_packet(fd, p);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
213 close(fd);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
214 gaim_remote_packet_free(p);
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
215
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
216 return 0;
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
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
219 static int
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
220 send_command_uri() {
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
221 int fd = 0;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
222 GaimRemotePacket *p = NULL;
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
223
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
224 fd = open_session();
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
225 if (fd < 0) {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
226 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
227 }
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
228 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
229 gaim_remote_packet_append_string(p, opts.uri);
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
230 gaim_remote_session_send_packet(fd, p);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
231 close(fd);
5859
022786c7ab53 [gaim-migrate @ 6290]
Christian Hammond <chipx86@chipx86.com>
parents: 5124
diff changeset
232 gaim_remote_packet_free(p);
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
233
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
234 return 0;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
235 }
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
236
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
237 static int
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
238 send_command_send() {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
239 int fd = 0;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
240 GaimRemotePacket *p = NULL;
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
241 char temp[10003]; /* TODO: Future implementation should send packets instead */
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
242
10086
6cd2b467e303 [gaim-migrate @ 11097]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10005
diff changeset
243 fd = open_session();
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
244 if (fd < 0) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
245 return 1;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
246 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
247 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_SEND);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
248
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
249 /*
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
250 * Format is as follows:
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
251 * 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
252 * The strings are: To, From, Protocol name, Message
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
253 * 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
254 * 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
255 * given string, though none of these strings should be exceeding this.
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
256 * -JBS
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
257 */
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
258
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
259 if (opts.to && *opts.to && opts.from && *opts.from &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
260 opts.protocol && *opts.protocol && opts.message && *opts.message &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
261 (strlen(opts.to) < 10000) && (strlen(opts.from) < 10000) &&
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
262 (strlen(opts.protocol) < 20) && (strlen(opts.message) < 10000) )
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
263 {
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10086
diff changeset
264 sprintf(temp, "%04zd%s", strlen(opts.to), opts.to);
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
265 gaim_remote_packet_append_string(p, temp);
10112
1a91e814e9d8 [gaim-migrate @ 11145]
Nathan Walp <nwalp@pidgin.im>
parents: 10086
diff changeset
266 sprintf(temp, "%04zd%s", strlen(opts.from), opts.from);
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.protocol), opts.protocol);
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.message), opts.message);
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
271 gaim_remote_packet_append_string(p, temp);
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
272 sprintf(temp, "%d", 0); /* quiet flag - off for now */
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
273 gaim_remote_packet_append_string(p, temp);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
274
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
275 gaim_remote_session_send_packet (fd, p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
276 close(fd);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
277 gaim_remote_packet_free(p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
278 return 0;
10005
c892b6dbc341 [gaim-migrate @ 10922]
Mark Doliner <mark@kingant.net>
parents: 10003
diff changeset
279 } else {
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
280 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
281 close(fd);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
282 gaim_remote_packet_free(p);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
283 return 1;
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
284 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
285 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
286
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
287 static void
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
288 show_longhelp( char *name, char *command)
9608
204f5d66a863 [gaim-migrate @ 10451]
Luke Schierer <lschiere@pidgin.im>
parents: 9184
diff changeset
289 {
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
290 if (!strcmp(command, "uri")) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
291 message(_("\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
292 "Using AIM: URIs:\n"
8152
82aeed3c90f0 [gaim-migrate @ 8864]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
293 "Sending an IM to a screen name:\n"
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
294 " 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
295 "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
296 "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
297 "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
298 "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
299 "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
300 "with no message:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
301 " gaim-remote uri 'aim:goim?screenname=Penguin'\n\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
302 "Joining a chat:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
303 " gaim-remote uri 'aim:gochat?roomname=PenguinLounge'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
304 "...joins the 'PenguinLounge' chat room.\n\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
305 "Adding a buddy to your buddy list:\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
306 " gaim-remote uri 'aim:addbuddy?screenname=Penguin'\n"
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
307 "...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
308 }
9695
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
309
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
310 else if (!strcmp(command, "quit")) {
7724
613b20c69d2c [gaim-migrate @ 8369]
Luke Schierer <lschiere@pidgin.im>
parents: 6643
diff changeset
311 message(_("\nClose running copy of Gaim\n"), 1);
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
312 }
9695
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
313
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
314 else if (!strcmp(command, "away")) {
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
315 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
316 }
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
317
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
318 else if (!strcmp(command, "back")) {
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
319 message(_("\nSet all accounts as not away.\n"), 1);
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
320 }
89110d3665df [gaim-migrate @ 10550]
Mark Doliner <mark@kingant.net>
parents: 9674
diff changeset
321
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
322 else if (!strcmp(command, "send")) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
323 message(_("\nSend instant message\n"), 1);
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
324 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
325
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
326 else {
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
327 show_remote_usage(name);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
328 }
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
329 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
330
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
331 int main(int argc, char *argv[])
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
332 {
5116
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
333 #ifdef ENABLE_NLS
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
334 setlocale (LC_ALL, "");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
335 bindtextdomain(PACKAGE, LOCALEDIR);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
336 bind_textdomain_codeset(PACKAGE, "UTF-8");
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
337 textdomain(PACKAGE);
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
338 #endif
c081a81ee013 [gaim-migrate @ 5479]
Luke Schierer <lschiere@pidgin.im>
parents: 4242
diff changeset
339
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
340 if (get_options(argc, argv)) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
341 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
342 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
343 }
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
344
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
345 if (!strcmp(opts.command, "uri")) {
9674
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], "uri");
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_command_uri();
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
10003
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
352 else if (!strcmp(opts.command, "send")) {
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
353 if (opts.help)
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
354 show_longhelp(argv[0], "send");
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
355 else
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
356 return send_command_send();
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
357 }
33431f91e4a8 [gaim-migrate @ 10920]
Luke Schierer <lschiere@pidgin.im>
parents: 9752
diff changeset
358
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
359 else if (!strcmp(opts.command, "away")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
360 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
361 show_longhelp(argv[0], "away");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
362 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
363 return send_generic_command(CUI_TYPE_USER, CUI_USER_AWAY);
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
364 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
365
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
366 else if (!strcmp(opts.command, "back")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
367 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
368 show_longhelp(argv[0], "back");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
369 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
370 return send_generic_command(CUI_TYPE_USER, CUI_USER_BACK);
9674
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
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
373 else if (!strcmp(opts.command, "quit")) {
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
374 if (opts.help)
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
375 show_longhelp(argv[0], "quit");
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
376 else
9752
8793c7127c80 [gaim-migrate @ 10619]
Mark Doliner <mark@kingant.net>
parents: 9695
diff changeset
377 return send_generic_command(CUI_TYPE_META, CUI_META_QUIT);
9674
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
378 }
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
379
a049733e41f3 [gaim-migrate @ 10526]
Mark Doliner <mark@kingant.net>
parents: 9608
diff changeset
380 else {
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
381 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
382 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
383 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
384
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
385 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
386 }