Mercurial > pidgin.yaz
comparison libpurple/protocols/zephyr/zephyr.c @ 22076:d60aa8fdad55
Part of a large patch from o_sukhodolsky to fix some build warnings.
Refs #1344
I removed a couple of the changes here, so there are still two warnings.
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Mon, 14 Jan 2008 03:26:47 +0000 |
parents | c38d72677c8a |
children | d5e8ee52ddcc |
comparison
equal
deleted
inserted
replaced
22075:11eb52cb7525 | 22076:d60aa8fdad55 |
---|---|
154 #ifdef WIN32 | 154 #ifdef WIN32 |
155 extern const char *username; | 155 extern const char *username; |
156 #endif | 156 #endif |
157 | 157 |
158 static Code_t zephyr_subscribe_to(zephyr_account* zephyr, char* class, char *instance, char *recipient, char* galaxy) { | 158 static Code_t zephyr_subscribe_to(zephyr_account* zephyr, char* class, char *instance, char *recipient, char* galaxy) { |
159 size_t result; | |
160 Code_t ret_val = -1; | |
159 | 161 |
160 if (use_tzc(zephyr)) { | 162 if (use_tzc(zephyr)) { |
161 /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */ | 163 /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */ |
162 gchar *zsubstr = g_strdup_printf("((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n",class,instance,recipient); | 164 gchar *zsubstr = g_strdup_printf("((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n",class,instance,recipient); |
163 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsubstr,strlen(zsubstr)); | 165 size_t len = strlen(zsubstr); |
166 result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zsubstr,len); | |
167 if (result != len) { | |
168 purple_debug_error("zephyr", "Unable to write a message: %s\n", strerror(errno)); | |
169 } else { | |
170 ret_val = ZERR_NONE; | |
171 } | |
164 g_free(zsubstr); | 172 g_free(zsubstr); |
165 return ZERR_NONE; | |
166 } | 173 } |
167 else { | 174 else { |
168 if (use_zeph02(zephyr)) { | 175 if (use_zeph02(zephyr)) { |
169 ZSubscription_t sub; | 176 ZSubscription_t sub; |
170 sub.zsub_class = class; | 177 sub.zsub_class = class; |
171 sub.zsub_classinst = instance; | 178 sub.zsub_classinst = instance; |
172 sub.zsub_recipient = recipient; | 179 sub.zsub_recipient = recipient; |
173 return ZSubscribeTo(&sub,1,0); | 180 ret_val = ZSubscribeTo(&sub,1,0); |
174 } else { | 181 } |
175 /* This should not happen */ | 182 } |
176 return -1; | 183 return ret_val; |
177 } | |
178 } | |
179 return -1; | |
180 } | 184 } |
181 | 185 |
182 char *local_zephyr_normalize(zephyr_account* zephyr,const char *); | 186 char *local_zephyr_normalize(zephyr_account* zephyr,const char *); |
183 static void zephyr_chat_set_topic(PurpleConnection * gc, int id, const char *topic); | 187 static void zephyr_chat_set_topic(PurpleConnection * gc, int id, const char *topic); |
184 char* zephyr_tzc_deescape_str(const char *message); | 188 char* zephyr_tzc_deescape_str(const char *message); |
1371 g_free(ald.version); | 1375 g_free(ald.version); |
1372 #endif /* WIN32 */ | 1376 #endif /* WIN32 */ |
1373 } else | 1377 } else |
1374 if (use_tzc(zephyr)) { | 1378 if (use_tzc(zephyr)) { |
1375 gchar *zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",chk); | 1379 gchar *zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",chk); |
1376 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr)); | 1380 size_t len = strlen(zlocstr); |
1381 size_t result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,len); | |
1382 if (result != len) { | |
1383 purple_debug_error("zephyr", "Unable to write a message: %s\n", strerror(errno)); | |
1384 } | |
1377 g_free(zlocstr); | 1385 g_free(zlocstr); |
1378 } | 1386 } |
1379 } | 1387 } |
1380 } | 1388 } |
1381 } | 1389 } |
2191 char *html_buf2; | 2199 char *html_buf2; |
2192 html_buf = html_to_zephyr(im); | 2200 html_buf = html_to_zephyr(im); |
2193 html_buf2 = purple_unescape_html(html_buf); | 2201 html_buf2 = purple_unescape_html(html_buf); |
2194 | 2202 |
2195 if(use_tzc(zephyr)) { | 2203 if(use_tzc(zephyr)) { |
2204 size_t len; | |
2205 size_t result; | |
2196 char* zsendstr; | 2206 char* zsendstr; |
2197 /* CMU cclub tzc doesn't grok opcodes for now */ | 2207 /* CMU cclub tzc doesn't grok opcodes for now */ |
2198 char* tzc_sig = zephyr_tzc_escape_msg(sig); | 2208 char* tzc_sig = zephyr_tzc_escape_msg(sig); |
2199 char *tzc_body = zephyr_tzc_escape_msg(html_buf2); | 2209 char *tzc_body = zephyr_tzc_escape_msg(html_buf2); |
2200 zsendstr = g_strdup_printf("((tzcfodder . send) (class . \"%s\") (auth . t) (recipients (\"%s\" . \"%s\")) (message . (\"%s\" \"%s\")) ) \n", | 2210 zsendstr = g_strdup_printf("((tzcfodder . send) (class . \"%s\") (auth . t) (recipients (\"%s\" . \"%s\")) (message . (\"%s\" \"%s\")) ) \n", |
2201 zclass, instance, recipient, tzc_sig, tzc_body); | 2211 zclass, instance, recipient, tzc_sig, tzc_body); |
2202 /* fprintf(stderr,"zsendstr = %s\n",zsendstr); */ | 2212 /* fprintf(stderr,"zsendstr = %s\n",zsendstr); */ |
2203 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsendstr,strlen(zsendstr)); | 2213 len = strlen(zsendstr); |
2214 result = write(zephyr->totzc[ZEPHYR_FD_WRITE], zsendstr, len); | |
2215 if (result != len) { | |
2216 g_free(zsendstr); | |
2217 g_free(html_buf2); | |
2218 g_free(html_buf); | |
2219 return errno; | |
2220 } | |
2204 g_free(zsendstr); | 2221 g_free(zsendstr); |
2205 } else if (use_zeph02(zephyr)) { | 2222 } else if (use_zeph02(zephyr)) { |
2206 ZNotice_t notice; | 2223 ZNotice_t notice; |
2207 char *buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); | 2224 char *buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2); |
2208 memset((char *)¬ice, 0, sizeof(notice)); | 2225 memset((char *)¬ice, 0, sizeof(notice)); |
2219 notice.z_message = buf; | 2236 notice.z_message = buf; |
2220 notice.z_opcode = g_strdup(opcode); | 2237 notice.z_opcode = g_strdup(opcode); |
2221 purple_debug_info("zephyr","About to send notice\n"); | 2238 purple_debug_info("zephyr","About to send notice\n"); |
2222 if (! ZSendNotice(¬ice, ZAUTH) == ZERR_NONE) { | 2239 if (! ZSendNotice(¬ice, ZAUTH) == ZERR_NONE) { |
2223 /* XXX handle errors here */ | 2240 /* XXX handle errors here */ |
2241 g_free(buf); | |
2242 g_free(html_buf2); | |
2243 g_free(html_buf); | |
2224 return 0; | 2244 return 0; |
2225 } | 2245 } |
2226 purple_debug_info("zephyr","notice sent\n"); | 2246 purple_debug_info("zephyr","notice sent\n"); |
2227 g_free(buf); | 2247 g_free(buf); |
2228 } | 2248 } |
2255 static void zephyr_zloc(PurpleConnection *gc, const char *who) | 2275 static void zephyr_zloc(PurpleConnection *gc, const char *who) |
2256 { | 2276 { |
2257 ZAsyncLocateData_t ald; | 2277 ZAsyncLocateData_t ald; |
2258 zephyr_account *zephyr = gc->proto_data; | 2278 zephyr_account *zephyr = gc->proto_data; |
2259 gchar* normalized_who = local_zephyr_normalize(zephyr,who); | 2279 gchar* normalized_who = local_zephyr_normalize(zephyr,who); |
2260 | 2280 |
2261 if (use_zeph02(zephyr)) { | 2281 if (use_zeph02(zephyr)) { |
2262 if (ZRequestLocations(normalized_who, &ald, UNACKED, ZAUTH) == ZERR_NONE) { | 2282 if (ZRequestLocations(normalized_who, &ald, UNACKED, ZAUTH) == ZERR_NONE) { |
2263 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, | 2283 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, |
2264 g_strdup(normalized_who)); | 2284 g_strdup(normalized_who)); |
2265 } else { | 2285 } else { |
2266 /* XXX deal with errors somehow */ | 2286 /* XXX deal with errors somehow */ |
2267 } | 2287 } |
2268 } else if (use_tzc(zephyr)) { | 2288 } else if (use_tzc(zephyr)) { |
2289 size_t len; | |
2290 size_t result; | |
2269 char* zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",normalized_who); | 2291 char* zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",normalized_who); |
2270 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, g_strdup(normalized_who)); | 2292 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, g_strdup(normalized_who)); |
2271 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr)); | 2293 len = strlen(zlocstr); |
2294 result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,len); | |
2295 if (result != len) { | |
2296 purple_debug_error("zephyr", "Unable to write a message: %s\n", strerror(errno)); | |
2297 } | |
2272 g_free(zlocstr); | 2298 g_free(zlocstr); |
2273 } | 2299 } |
2274 } | 2300 } |
2275 | 2301 |
2276 static void zephyr_set_status(PurpleAccount *account, PurpleStatus *status) { | 2302 static void zephyr_set_status(PurpleAccount *account, PurpleStatus *status) { |
2303 size_t len; | |
2304 size_t result; | |
2277 zephyr_account *zephyr = purple_account_get_connection(account)->proto_data; | 2305 zephyr_account *zephyr = purple_account_get_connection(account)->proto_data; |
2278 PurpleStatusPrimitive primitive = purple_status_type_get_primitive(purple_status_get_type(status)); | 2306 PurpleStatusPrimitive primitive = purple_status_type_get_primitive(purple_status_get_type(status)); |
2279 | 2307 |
2280 if (zephyr->away) { | 2308 if (zephyr->away) { |
2281 g_free(zephyr->away); | 2309 g_free(zephyr->away); |
2289 if (use_zeph02(zephyr)) { | 2317 if (use_zeph02(zephyr)) { |
2290 ZSetLocation(zephyr->exposure); | 2318 ZSetLocation(zephyr->exposure); |
2291 } | 2319 } |
2292 else { | 2320 else { |
2293 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,zephyr->exposure); | 2321 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,zephyr->exposure); |
2294 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | 2322 len = strlen(zexpstr); |
2323 result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,len); | |
2324 if (result != len) { | |
2325 purple_debug_error("zephyr", "Unable to write message: %s\n", strerror(errno)); | |
2326 } | |
2295 g_free(zexpstr); | 2327 g_free(zexpstr); |
2296 } | 2328 } |
2297 } | 2329 } |
2298 else if (primitive == PURPLE_STATUS_INVISIBLE) { | 2330 else if (primitive == PURPLE_STATUS_INVISIBLE) { |
2299 /* XXX handle errors */ | 2331 /* XXX handle errors */ |
2300 if (use_zeph02(zephyr)) { | 2332 if (use_zeph02(zephyr)) { |
2301 ZSetLocation(EXPOSE_OPSTAFF); | 2333 ZSetLocation(EXPOSE_OPSTAFF); |
2302 } else { | 2334 } else { |
2303 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,EXPOSE_OPSTAFF); | 2335 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,EXPOSE_OPSTAFF); |
2304 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr)); | 2336 len = strlen(zexpstr); |
2337 result = write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,len); | |
2338 if (result != len) { | |
2339 purple_debug_error("zephyr", "Unable to write message: %s\n", strerror(errno)); | |
2340 } | |
2305 g_free(zexpstr); | 2341 g_free(zexpstr); |
2306 } | 2342 } |
2307 } | 2343 } |
2308 } | 2344 } |
2309 | 2345 |