annotate src/gaim-remote.c @ 4571:51e988d015ed

[gaim-migrate @ 4852] I don't know if this is gtk's problem or my (our?) misunderstanding of GtkNotebook, but it seems pages that are deleted aren't destroying the child widgets, so we're doing that manually now. It should free up a LOT of memory, and since this is how the old code did it (I think), it should explain the large memory leaks people used to report. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 11 Feb 2003 17:26:16 +0000
parents cf19d8102b34
children c081a81ee013
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 *
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * Copyright (C) 2002, Sean Egan <bj91704@binghamton.edu>
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
5 * Features/functionality added (C) 2002, John B. Silvestri <silvestrij@mville.edu>
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
6 * 'quit', long help for URIs
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
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 #include "gaim.h"
3533
6c32036050cf [gaim-migrate @ 3607]
Sean Egan <seanegan@gmail.com>
parents: 3480
diff changeset
25 #include <getopt.h>
3867
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3559
diff changeset
26 #include <unistd.h>
4235
cba92ec56248 [gaim-migrate @ 4481]
Mark Doliner <mark@kingant.net>
parents: 3867
diff changeset
27 #include <string.h>
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
28 #include "gaim-socket.h"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
29
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
30 void show_remote_usage(char *name)
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
31 {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
32 printf(_("Usage: %s command [OPTIONS] [URI]\n\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
33
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
34 " COMMANDS:\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
35 " uri Handle AIM: URI\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
36 " quit Close running copy of Gaim\n\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
37
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
38 " OPTIONS:\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
39 " -h, --help [commmand] Show help for command\n"), name);
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
40 return;
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
41 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
42
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
43 /*To be implemented:
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
44 " info Show information about connected accounts\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
45 " list Print buddy list\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
46 " ison Show presence state of your buddy\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
47 " convo Open a new conversation window\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
48 " send Send message\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
49 " add Add buddy to buddy list\n"
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
50 " remove Remove buddy from list\n"
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
51 " -m, --message=MESG Message to send or show in conversation window\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
52 " -t, --to=SCREENNAME Select a target for command\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
53 " -p, --protocol=PROTO Specify protocol to use\n"
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
54 " -f, --from=SCREENNAME Specify screenname to use\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
55 " -q, --quiet Send message without showing a conversation\n"
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
56 " window\n"
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
57 */
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
58
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
59 static struct option longopts[] = {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
60 {"message", required_argument, NULL, 'm'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
61 {"to", required_argument, NULL, 't'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
62 {"protocol",required_argument, NULL, 'p'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
63 {"from", required_argument, NULL, 'f'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
64 {"quiet", no_argument, NULL, 'q'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
65 {"help", no_argument, NULL, 'h'},
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
66 {0,0,0,0}
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
67 };
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
68
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
69 struct remoteopts {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
70 char *command;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
71 char *uri;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
72 gboolean help, quiet;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73 char *message, *to, *from;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
74 int protocol;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
75 };
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
77
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
78 struct remoteopts opts;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
79 int get_options(int argc, char *argv[])
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
80 {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
81 int i;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
82 memset(&opts, 0, sizeof(opts));
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
83 opts.protocol = -1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
84 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
85 switch (i) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
86 case 'm':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
87 opts.message = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
88 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
89 case 't':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
90 opts.to = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
91 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
92 case 'p':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
93 /* Do stuff here. */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
94 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
95 case 'f':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
96 opts.from = optarg;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
97 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
98 case 'q':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
99 opts.quiet = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
100 break;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
101 case 'h':
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
102 opts.help = TRUE;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
103 break;
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
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
107 /* We must have non getopt'ed argument-- the command */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
108 if (optind < argc)
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
109 opts.command = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
110 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
111 return 1;
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 /* And we can have another argument--the URI. */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
114 if (optind < argc) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
115 /* but only if we're using the uri command. */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
116 if (!strcmp(opts.command, "uri"))
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
117 opts.uri = g_strdup(argv[optind++]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
118 else
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
119 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
120
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121 /* and we can't have any others. */
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
122 if (optind < argc)
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
123 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
124 }
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 return 0;
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
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
129
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
130 int command_uri() {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
131 int fd = 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
132 struct gaim_cui_packet *p = NULL;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133 fd = gaim_connect_to_session(0);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
134 if (!fd) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
135 fprintf(stderr, "Gaim not running (on session 0)\n");
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
136 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
137 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
138 p = cui_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
139 cui_packet_append_string(p, opts.uri);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
140 cui_send_packet (fd, p);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
141 close(fd);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
142 cui_packet_free(p);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
144 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
146 int command_quit() {
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
147 int fd = 0;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
148 struct gaim_cui_packet *p = NULL;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
149 fd = gaim_connect_to_session(0);
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
150 if (!fd) {
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
151 fprintf(stderr, "Gaim not running (on session 0)\n");
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
152 return 1;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
153 }
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
154 p = cui_packet_new(CUI_TYPE_META, CUI_META_QUIT);
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
155 cui_send_packet (fd, p);
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
156 close(fd);
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
157 cui_packet_free(p);
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
158 return 0;
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
159 }
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
160
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
161 void show_longhelp_uri(){
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
162 printf ("\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
163
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
164 "Using AIM: URIs:\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
165 "Sending an IM to a screenname:\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
166 " gaim-remote uri 'aim:goim?screenname=Penguin&message=hello+world'\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
167 "In this case, 'Penguin' is the screenname we wish to IM, and 'hello world'\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
168 "is the message to be sent. '+' must be used in place of spaces.\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
169 "Please note the quoting used above - if you run this from a shell the '&'\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
170 "needs to be escaped, or the command will stop at that point.\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
171 "Also,the following will just open a conversation window to a screenname,\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
172 "with no message:\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
173 " gaim-remote uri aim:goim?screenname=Penguin\n\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
174 "Joining a chat:\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
175 " gaim-remote uri aim:gochat?roomname=PenguinLounge\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
176 "...joins the 'PenguinLounge' chat room.\n\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
177 "Adding a buddy to your buddy list:\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
178 " gaim-remote uri aim:addbuddy?screenname=Penguin\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
179 "...prompts you to add 'Penguin' to your buddy list.\n"
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
180 );
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
181 return;
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
182 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
183
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
184 /* Work in progress - JBS
3867
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3559
diff changeset
185 int command_info(){
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3559
diff changeset
186 fprintf(stderr, "Info not yet implemented\n");
43e396e94095 [gaim-migrate @ 4019]
Rob Flynn <gaim@robflynn.com>
parents: 3559
diff changeset
187 return 1;
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
188 }*/
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
189
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
190 int main (int argc, char *argv[])
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
191 {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
192
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
193 if (get_options(argc, argv)) {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
194 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
195 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
196 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
197
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
198
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
199 if (!strcmp(opts.command, "uri")) {
4242
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
200 if(opts.help){
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
201 show_longhelp_uri();
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
202 }else{
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
203 return command_uri();
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
204 }
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
205 /* } else if (!strcmp(opts.command, "info")) {
cf19d8102b34 [gaim-migrate @ 4492]
Luke Schierer <lschiere@pidgin.im>
parents: 4235
diff changeset
206 return command_info();*/
3559
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
207 } else if (!strcmp(opts.command, "quit")) {
119b8950a1c8 [gaim-migrate @ 3653]
Sean Egan <seanegan@gmail.com>
parents: 3533
diff changeset
208 return command_quit();
3480
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
209 } else {
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
210 show_remote_usage(argv[0]);
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
211 return 1;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
212 }
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
213
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
214 return 0;
fc28f412e74d [gaim-migrate @ 3534]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
215 }