comparison src/gaim-remote.c @ 6643:0dfe02111e20

[gaim-migrate @ 7168] since it seems i cannot get Silvestrij's patch in for this release, bjoernv writes: " I found a number of bugs in src/gaim-remote.c. My patch contains: - parameter processing fix in gaim-remote (gaim-remote no longer segfaults on "gaim-remote uri") - gaim-remote now has correct error messages and return codes, if connection to gaim fails (gaim-remote is not longer silent, if gaim-remote uri 'aim:goim?screenname=Penguin&message=hello+world' failes, because gaim is not running)" committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 28 Aug 2003 14:39:27 +0000
parents 059d95c67cda
children 613b20c69d2c
comparison
equal deleted inserted replaced
6642:8e03e9b54440 6643:0dfe02111e20
109 if (optind < argc) 109 if (optind < argc)
110 opts.command = g_strdup(argv[optind++]); 110 opts.command = g_strdup(argv[optind++]);
111 else 111 else
112 return 1; 112 return 1;
113 113
114 if(opts.help)
115 return 0;
116
114 /* And we can have another argument--the URI. */ 117 /* And we can have another argument--the URI. */
115 if (optind < argc) { 118 /* but only if we're using the uri command. */
116 /* but only if we're using the uri command. */ 119 if (!strcmp(opts.command, "uri")) {
117 if (!strcmp(opts.command, "uri")) 120 if(argc-optind==1)
118 opts.uri = g_strdup(argv[optind++]); 121 opts.uri = g_strdup(argv[optind++]);
119 else 122 else
120 return 1; 123 return 1;
121 124 }
122 /* and we can't have any others. */ 125 else if(optind==argc)
123 if (optind < argc) 126 return 0;
124 return 1; 127 else
125 } 128 return 1;
126 129
127 return 0; 130 return 0;
128 } 131 }
129 132
130 133
131 int command_uri() { 134 int command_uri() {
132 int fd = 0; 135 int fd = 0;
133 GaimRemotePacket *p = NULL; 136 GaimRemotePacket *p = NULL;
134 fd = gaim_remote_session_connect(0); 137 fd = gaim_remote_session_connect(0);
135 if (!fd) { 138 if (fd<0) {
136 fprintf(stderr, _("Gaim not running (on session 0)\n")); 139 fprintf(stderr, _("Gaim not running (on session 0)\n"));
137 return 1; 140 return 1;
138 } 141 }
139 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI); 142 p = gaim_remote_packet_new(CUI_TYPE_REMOTE, CUI_REMOTE_URI);
140 gaim_remote_packet_append_string(p, opts.uri); 143 gaim_remote_packet_append_string(p, opts.uri);
146 149
147 int command_quit() { 150 int command_quit() {
148 int fd = 0; 151 int fd = 0;
149 GaimRemotePacket *p = NULL; 152 GaimRemotePacket *p = NULL;
150 fd = gaim_remote_session_connect(0); 153 fd = gaim_remote_session_connect(0);
151 if (!fd) { 154 if (fd<0) {
152 fprintf(stderr, _("Gaim not running (on session 0)\n")); 155 fprintf(stderr, _("Gaim not running (on session 0)\n"));
153 return 1; 156 return 1;
154 } 157 }
155 p = gaim_remote_packet_new(CUI_TYPE_META, CUI_META_QUIT); 158 p = gaim_remote_packet_new(CUI_TYPE_META, CUI_META_QUIT);
156 gaim_remote_session_send_packet(fd, p); 159 gaim_remote_session_send_packet(fd, p);