Thu, 03 Apr 2003 04:30:05 +0000
[gaim-migrate @ 5303]
This fixes the renaming of groups on the sever-side.
Thanks to The Nathan Walp for pointing it out.
Thanks to The Sean for making a totally sweet buddy list.
Thanks to Ethan for just being totally sweet in general.
And thanks to Alf for trying to hard to eat cats.
I also took out an unused function from oscar.c
| 3480 | 1 | /* |
| 2 | * gaim-remote | |
| 3 | * | |
| 4 | * Copyright (C) 2002, Sean Egan <bj91704@binghamton.edu> | |
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
5 | * Features/functionality added (C) 2002, John B. Silvestri <silvestrij@mville.edu> |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
6 | * 'quit', long help for URIs |
| 3480 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | * | |
| 22 | */ | |
| 23 | ||
| 24 | #include "gaim.h" | |
| 3533 | 25 | #include <getopt.h> |
| 3867 | 26 | #include <unistd.h> |
| 4235 | 27 | #include <string.h> |
| 3480 | 28 | #include "gaim-socket.h" |
| 29 | ||
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
30 | void show_remote_usage(char *name) |
| 3480 | 31 | { |
| 32 | printf(_("Usage: %s command [OPTIONS] [URI]\n\n" | |
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
33 | |
| 3480 | 34 | " COMMANDS:\n" |
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
35 | " uri Handle AIM: URI\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
36 | " quit Close running copy of Gaim\n\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
37 | |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
38 | " OPTIONS:\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
39 | " -h, --help [commmand] Show help for command\n"), name); |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
40 | return; |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
41 | } |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
42 | |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
43 | /*To be implemented: |
| 3480 | 44 | " info Show information about connected accounts\n" |
| 45 | " list Print buddy list\n" | |
| 46 | " ison Show presence state of your buddy\n" | |
| 47 | " convo Open a new conversation window\n" | |
| 48 | " send Send message\n" | |
| 49 | " add Add buddy to buddy list\n" | |
|
3559
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
50 | " remove Remove buddy from list\n" |
| 3480 | 51 | " -m, --message=MESG Message to send or show in conversation window\n" |
| 52 | " -t, --to=SCREENNAME Select a target for command\n" | |
| 53 | " -p, --protocol=PROTO Specify protocol to use\n" | |
| 54 | " -f, --from=SCREENNAME Specify screenname to use\n" | |
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
55 | " -q, --quiet Send message without showing a conversation\n" |
| 3480 | 56 | " window\n" |
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
57 | */ |
| 3480 | 58 | |
| 59 | static struct option longopts[] = { | |
| 60 | {"message", required_argument, NULL, 'm'}, | |
| 61 | {"to", required_argument, NULL, 't'}, | |
| 62 | {"protocol",required_argument, NULL, 'p'}, | |
| 63 | {"from", required_argument, NULL, 'f'}, | |
| 64 | {"quiet", no_argument, NULL, 'q'}, | |
| 65 | {"help", no_argument, NULL, 'h'}, | |
| 66 | {0,0,0,0} | |
| 67 | }; | |
| 68 | ||
| 69 | struct remoteopts { | |
| 70 | char *command; | |
| 71 | char *uri; | |
| 72 | gboolean help, quiet; | |
| 73 | char *message, *to, *from; | |
| 74 | int protocol; | |
| 75 | }; | |
| 76 | ||
| 77 | ||
| 78 | struct remoteopts opts; | |
| 79 | int get_options(int argc, char *argv[]) | |
| 80 | { | |
| 81 | int i; | |
| 82 | memset(&opts, 0, sizeof(opts)); | |
| 83 | opts.protocol = -1; | |
| 84 | while ((i=getopt_long(argc, argv, "m:t:p:f:qh", longopts, NULL)) != -1) { | |
| 85 | switch (i) { | |
| 86 | case 'm': | |
| 87 | opts.message = optarg; | |
| 88 | break; | |
| 89 | case 't': | |
| 90 | opts.to = optarg; | |
| 91 | break; | |
| 92 | case 'p': | |
| 93 | /* Do stuff here. */ | |
| 94 | break; | |
| 95 | case 'f': | |
| 96 | opts.from = optarg; | |
| 97 | break; | |
| 98 | case 'q': | |
| 99 | opts.quiet = TRUE; | |
| 100 | break; | |
| 101 | case 'h': | |
| 102 | opts.help = TRUE; | |
| 103 | break; | |
| 104 | } | |
| 105 | } | |
| 106 | ||
| 107 | /* We must have non getopt'ed argument-- the command */ | |
| 108 | if (optind < argc) | |
| 109 | opts.command = g_strdup(argv[optind++]); | |
| 110 | else | |
| 111 | return 1; | |
| 112 | ||
| 113 | /* And we can have another argument--the URI. */ | |
| 114 | if (optind < argc) { | |
| 115 | /* but only if we're using the uri command. */ | |
| 116 | if (!strcmp(opts.command, "uri")) | |
| 117 | opts.uri = g_strdup(argv[optind++]); | |
| 118 | else | |
| 119 | return 1; | |
| 120 | ||
| 121 | /* and we can't have any others. */ | |
| 122 | if (optind < argc) | |
| 123 | return 1; | |
| 124 | } | |
| 125 | ||
| 126 | return 0; | |
| 127 | } | |
| 128 | ||
| 129 | ||
| 130 | int command_uri() { | |
| 131 | int fd = 0; | |
| 132 | struct gaim_cui_packet *p = NULL; | |
| 133 | fd = gaim_connect_to_session(0); | |
| 134 | if (!fd) { | |
| 135 | fprintf(stderr, "Gaim not running (on session 0)\n"); | |
| 136 | return 1; | |
| 137 | } | |
| 138 | p = cui_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI); | |
| 139 | cui_packet_append_string(p, opts.uri); | |
| 140 | cui_send_packet (fd, p); | |
| 141 | close(fd); | |
| 142 | cui_packet_free(p); | |
| 143 | return 0; | |
| 144 | } | |
| 145 | ||
|
3559
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
146 | int command_quit() { |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
147 | int fd = 0; |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
148 | struct gaim_cui_packet *p = NULL; |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
149 | fd = gaim_connect_to_session(0); |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
150 | if (!fd) { |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
151 | fprintf(stderr, "Gaim not running (on session 0)\n"); |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
152 | return 1; |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
153 | } |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
154 | p = cui_packet_new(CUI_TYPE_META, CUI_META_QUIT); |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
155 | cui_send_packet (fd, p); |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
156 | close(fd); |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
157 | cui_packet_free(p); |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
158 | return 0; |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
159 | } |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
160 | |
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
161 | void show_longhelp_uri(){ |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
162 | printf ("\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
163 | |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
164 | "Using AIM: URIs:\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
165 | "Sending an IM to a screenname:\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
166 | " gaim-remote uri 'aim:goim?screenname=Penguin&message=hello+world'\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
167 | "In this case, 'Penguin' is the screenname we wish to IM, and 'hello world'\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
168 | "is the message to be sent. '+' must be used in place of spaces.\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
169 | "Please note the quoting used above - if you run this from a shell the '&'\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
170 | "needs to be escaped, or the command will stop at that point.\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
171 | "Also,the following will just open a conversation window to a screenname,\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
172 | "with no message:\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
173 | " gaim-remote uri aim:goim?screenname=Penguin\n\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
174 | "Joining a chat:\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
175 | " gaim-remote uri aim:gochat?roomname=PenguinLounge\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
176 | "...joins the 'PenguinLounge' chat room.\n\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
177 | "Adding a buddy to your buddy list:\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
178 | " gaim-remote uri aim:addbuddy?screenname=Penguin\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
179 | "...prompts you to add 'Penguin' to your buddy list.\n" |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
180 | ); |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
181 | return; |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
182 | } |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
183 | |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
184 | /* Work in progress - JBS |
| 3867 | 185 | int command_info(){ |
| 186 | fprintf(stderr, "Info not yet implemented\n"); | |
| 187 | return 1; | |
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
188 | }*/ |
| 3480 | 189 | |
|
3559
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
190 | int main (int argc, char *argv[]) |
| 3480 | 191 | { |
| 192 | ||
| 193 | if (get_options(argc, argv)) { | |
| 194 | show_remote_usage(argv[0]); | |
| 195 | return 0; | |
| 196 | } | |
| 197 | ||
| 198 | ||
| 199 | if (!strcmp(opts.command, "uri")) { | |
|
4242
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
200 | if(opts.help){ |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
201 | show_longhelp_uri(); |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
202 | }else{ |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
203 | return command_uri(); |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
204 | } |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
205 | /* } else if (!strcmp(opts.command, "info")) { |
|
48cfe2669548
[gaim-migrate @ 4492]
John Silvestri <john.silvestri@gmail.com>
parents:
4235
diff
changeset
|
206 | return command_info();*/ |
|
3559
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
207 | } else if (!strcmp(opts.command, "quit")) { |
|
329d9448fa45
[gaim-migrate @ 3653]
John Silvestri <john.silvestri@gmail.com>
parents:
3533
diff
changeset
|
208 | return command_quit(); |
| 3480 | 209 | } else { |
| 210 | show_remote_usage(argv[0]); | |
| 211 | return 1; | |
| 212 | } | |
| 213 | ||
| 214 | return 0; | |
| 215 | } |