Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 11159:bd8ac1d4b2f2
[gaim-migrate @ 13246]
Get rid of a bunch of gcc4 compile warnings in oscar.
Here's what I'm doing:
-For random bits of binary data, use guchar *
-For textual data (not necessarily utf8), use gchar *
This seems to be what glib and gtk do
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 26 Jul 2005 04:34:37 +0000 |
parents | 92453bf9b86b |
children | ccb38cf22483 |
comparison
equal
deleted
inserted
replaced
11158:2c930d591492 | 11159:bd8ac1d4b2f2 |
---|---|
295 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); | 295 static int oscar_sendfile_ack (aim_session_t *, aim_frame_t *, ...); |
296 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); | 296 static int oscar_sendfile_done (aim_session_t *, aim_frame_t *, ...); |
297 | 297 |
298 static gboolean gaim_icon_timerfunc(gpointer data); | 298 static gboolean gaim_icon_timerfunc(gpointer data); |
299 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); | 299 static void oscar_callback(gpointer data, gint source, GaimInputCondition condition); |
300 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie); | 300 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie); |
301 static void oscar_set_info(GaimConnection *gc, const char *text); | 301 static void oscar_set_info(GaimConnection *gc, const char *text); |
302 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); | 302 static void recent_buddies_cb(const char *name, GaimPrefType type, gpointer value, gpointer data); |
303 static void oscar_xfer_init_recv(GaimXfer *xfer); | 303 static void oscar_xfer_init_recv(GaimXfer *xfer); |
304 | 304 |
305 static void oscar_free_name_data(struct name_data *data) { | 305 static void oscar_free_name_data(struct name_data *data) { |
413 | 413 |
414 return utf8; | 414 return utf8; |
415 } | 415 } |
416 | 416 |
417 static gchar * | 417 static gchar * |
418 gaim_plugin_oscar_convert_to_utf8(const fu8_t *data, fu16_t datalen, const char *charsetstr, gboolean fallback) | 418 gaim_plugin_oscar_convert_to_utf8(const gchar *data, gsize datalen, const char *charsetstr, gboolean fallback) |
419 { | 419 { |
420 gchar *ret = NULL; | 420 gchar *ret = NULL; |
421 GError *err = NULL; | 421 GError *err = NULL; |
422 | 422 |
423 if ((charsetstr == NULL) || (*charsetstr == '\0')) | 423 if ((charsetstr == NULL) || (*charsetstr == '\0')) |
452 * that don't correctly send non-ASCII messages. And if Gaim isn't | 452 * that don't correctly send non-ASCII messages. And if Gaim isn't |
453 * able to deal with that crap, then people complain like banshees. | 453 * able to deal with that crap, then people complain like banshees. |
454 * charsetstr1 is always set to what the correct encoding should be. | 454 * charsetstr1 is always set to what the correct encoding should be. |
455 */ | 455 */ |
456 static gchar * | 456 static gchar * |
457 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, fu8_t *data, fu16_t datalen) | 457 gaim_plugin_oscar_decode_im_part(GaimAccount *account, const char *sourcesn, fu16_t charset, fu16_t charsubset, const gchar *data, gsize datalen) |
458 { | 458 { |
459 gchar *ret = NULL; | 459 gchar *ret = NULL; |
460 const gchar *charsetstr1, *charsetstr2; | 460 const gchar *charsetstr1, *charsetstr2; |
461 | 461 |
462 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); | 462 gaim_debug_info("oscar", "Parsing IM part, charset=0x%04hx, charsubset=0x%04hx, datalen=%hd\n", charset, charsubset, datalen); |
1007 if (source < 0) { | 1007 if (source < 0) { |
1008 if (dim->donttryagain) { | 1008 if (dim->donttryagain) { |
1009 oscar_direct_im_disconnect(od, dim); | 1009 oscar_direct_im_disconnect(od, dim); |
1010 return; | 1010 return; |
1011 } else { | 1011 } else { |
1012 fu8_t cookie[8]; | 1012 guchar cookie[8]; |
1013 char *who = g_strdup(dim->name); | 1013 char *who = g_strdup(dim->name); |
1014 const char *tmp = aim_odc_getcookie(dim->conn); | 1014 const guchar *tmp = aim_odc_getcookie(dim->conn); |
1015 | 1015 |
1016 memcpy(cookie, tmp, 8); | 1016 memcpy(cookie, tmp, 8); |
1017 oscar_direct_im_destroy(od, dim); | 1017 oscar_direct_im_destroy(od, dim); |
1018 oscar_direct_im_initiate(gc, who, cookie); | 1018 oscar_direct_im_initiate(gc, who, cookie); |
1019 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | 1019 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); |
1036 } else { | 1036 } else { |
1037 if (dim->donttryagain) { | 1037 if (dim->donttryagain) { |
1038 oscar_direct_im_disconnect(od, dim); | 1038 oscar_direct_im_disconnect(od, dim); |
1039 return; | 1039 return; |
1040 } else { | 1040 } else { |
1041 fu8_t cookie[8]; | 1041 guchar cookie[8]; |
1042 char *who = g_strdup(dim->name); | 1042 char *who = g_strdup(dim->name); |
1043 const char *tmp = aim_odc_getcookie(dim->conn); | 1043 const guchar *tmp = aim_odc_getcookie(dim->conn); |
1044 | 1044 |
1045 memcpy(cookie, tmp, 8); | 1045 memcpy(cookie, tmp, 8); |
1046 oscar_direct_im_destroy(od, dim); | 1046 oscar_direct_im_destroy(od, dim); |
1047 oscar_direct_im_initiate(gc, who, cookie); | 1047 oscar_direct_im_initiate(gc, who, cookie); |
1048 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); | 1048 gaim_debug_info("oscar", "asking direct im initiator to connect to us\n"); |
1496 * this function will also get called if the other side initiate's a direct | 1496 * this function will also get called if the other side initiate's a direct |
1497 * im and we try to connect and fail. in that case cookie will not be null. | 1497 * im and we try to connect and fail. in that case cookie will not be null. |
1498 * | 1498 * |
1499 * note that cookie is an 8 byte string that isn't NULL terminated | 1499 * note that cookie is an 8 byte string that isn't NULL terminated |
1500 */ | 1500 */ |
1501 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const char *cookie) { | 1501 static void oscar_direct_im_initiate(GaimConnection *gc, const char *who, const guchar *cookie) { |
1502 OscarData *od; | 1502 OscarData *od; |
1503 struct oscar_direct_im *dim; | 1503 struct oscar_direct_im *dim; |
1504 int listenfd; | 1504 int listenfd; |
1505 const char *ip; | 1505 const char *ip; |
1506 | 1506 |
2139 aim_oft_destroyinfo(oft_info); | 2139 aim_oft_destroyinfo(oft_info); |
2140 xfer->data = NULL; | 2140 xfer->data = NULL; |
2141 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | 2141 od->file_transfers = g_slist_remove(od->file_transfers, xfer); |
2142 } | 2142 } |
2143 | 2143 |
2144 static void oscar_xfer_ack_recv(GaimXfer *xfer, const char *buffer, size_t size) | 2144 static void oscar_xfer_ack_recv(GaimXfer *xfer, const guchar *buffer, size_t size) |
2145 { | 2145 { |
2146 struct aim_oft_info *oft_info = xfer->data; | 2146 struct aim_oft_info *oft_info = xfer->data; |
2147 | 2147 |
2148 /* Update our rolling checksum. Like Walmart, yo. */ | 2148 /* Update our rolling checksum. Like Walmart, yo. */ |
2149 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); | 2149 oft_info->fh.recvcsum = aim_oft_checksum_chunk(buffer, size, oft_info->fh.recvcsum); |
2209 aim_oft_destroyinfo(oft_info); | 2209 aim_oft_destroyinfo(oft_info); |
2210 xfer->data = NULL; | 2210 xfer->data = NULL; |
2211 od->file_transfers = g_slist_remove(od->file_transfers, xfer); | 2211 od->file_transfers = g_slist_remove(od->file_transfers, xfer); |
2212 } | 2212 } |
2213 | 2213 |
2214 static void oscar_xfer_ack_send(GaimXfer *xfer, const char *buffer, size_t size) | 2214 static void oscar_xfer_ack_send(GaimXfer *xfer, const guchar *buffer, size_t size) |
2215 { | 2215 { |
2216 struct aim_oft_info *oft_info = xfer->data; | 2216 struct aim_oft_info *oft_info = xfer->data; |
2217 | 2217 |
2218 /* I'm not sure I like how we do this. --marv | 2218 /* I'm not sure I like how we do this. --marv |
2219 * I do. AIM file transfers aren't really meant to be thought | 2219 * I do. AIM file transfers aren't really meant to be thought |
3186 | 3186 |
3187 return 1; | 3187 return 1; |
3188 } | 3188 } |
3189 | 3189 |
3190 static void gaim_check_comment(OscarData *od, const char *str) { | 3190 static void gaim_check_comment(OscarData *od, const char *str) { |
3191 if ((str == NULL) || strcmp(str, ck)) | 3191 if ((str == NULL) || strcmp(str, (const char *)ck)) |
3192 aim_locate_setcaps(od->sess, caps_aim); | 3192 aim_locate_setcaps(od->sess, caps_aim); |
3193 else | 3193 else |
3194 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); | 3194 aim_locate_setcaps(od->sess, caps_aim | AIM_CAPS_SECUREIM); |
3195 } | 3195 } |
3196 | 3196 |
3441 (args->icbmflags & AIM_IMFLAGS_BUDDYREQ) && !bi->ico_sent && bi->ico_informed) { | 3441 (args->icbmflags & AIM_IMFLAGS_BUDDYREQ) && !bi->ico_sent && bi->ico_informed) { |
3442 FILE *file; | 3442 FILE *file; |
3443 struct stat st; | 3443 struct stat st; |
3444 | 3444 |
3445 if (!g_stat(iconfile, &st)) { | 3445 if (!g_stat(iconfile, &st)) { |
3446 char *buf = g_malloc(st.st_size); | 3446 guchar *buf = g_malloc(st.st_size); |
3447 file = g_fopen(iconfile, "rb"); | 3447 file = g_fopen(iconfile, "rb"); |
3448 if (file) { | 3448 if (file) { |
3449 /* XXX - Use g_file_get_contents() */ | 3449 /* XXX - Use g_file_get_contents() */ |
3450 int len = fread(buf, 1, st.st_size, file); | 3450 int len = fread(buf, 1, st.st_size, file); |
3451 gaim_debug_info("oscar", | 3451 gaim_debug_info("oscar", |
3465 } | 3465 } |
3466 | 3466 |
3467 message = g_string_new(""); | 3467 message = g_string_new(""); |
3468 curpart = args->mpmsg.parts; | 3468 curpart = args->mpmsg.parts; |
3469 while (curpart != NULL) { | 3469 while (curpart != NULL) { |
3470 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, curpart->charsubset, | 3470 tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset, |
3471 curpart->data, curpart->datalen); | 3471 curpart->charsubset, curpart->data, curpart->datalen); |
3472 if (tmp != NULL) { | 3472 if (tmp != NULL) { |
3473 g_string_append(message, tmp); | 3473 g_string_append(message, tmp); |
3474 g_free(tmp); | 3474 g_free(tmp); |
3475 } | 3475 } |
3476 | 3476 |
4160 g_free(buf); | 4160 g_free(buf); |
4161 | 4161 |
4162 return 1; | 4162 return 1; |
4163 } | 4163 } |
4164 | 4164 |
4165 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const char *cookie) { | 4165 static int gaim_parse_clientauto_ch2(aim_session_t *sess, const char *who, fu16_t reason, const guchar *cookie) { |
4166 GaimConnection *gc = sess->aux_data; | 4166 GaimConnection *gc = sess->aux_data; |
4167 OscarData *od = gc->proto_data; | 4167 OscarData *od = gc->proto_data; |
4168 | 4168 |
4169 /* BBB */ | 4169 /* BBB */ |
4170 switch (reason) { | 4170 switch (reason) { |
4235 chan = (fu16_t)va_arg(ap, unsigned int); | 4235 chan = (fu16_t)va_arg(ap, unsigned int); |
4236 who = va_arg(ap, char *); | 4236 who = va_arg(ap, char *); |
4237 reason = (fu16_t)va_arg(ap, unsigned int); | 4237 reason = (fu16_t)va_arg(ap, unsigned int); |
4238 | 4238 |
4239 if (chan == 0x0002) { /* File transfer declined */ | 4239 if (chan == 0x0002) { /* File transfer declined */ |
4240 char *cookie = va_arg(ap, char *); | 4240 guchar *cookie = va_arg(ap, guchar *); |
4241 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); | 4241 return gaim_parse_clientauto_ch2(sess, who, reason, cookie); |
4242 } else if (chan == 0x0004) { /* ICQ message */ | 4242 } else if (chan == 0x0004) { /* ICQ message */ |
4243 fu32_t state = 0; | 4243 fu32_t state = 0; |
4244 char *msg = NULL; | 4244 char *msg = NULL; |
4245 if (reason == 0x0003) { | 4245 if (reason == 0x0003) { |
4797 struct stat st; | 4797 struct stat st; |
4798 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | 4798 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
4799 if (iconfile == NULL) { | 4799 if (iconfile == NULL) { |
4800 aim_ssi_delicon(od->sess); | 4800 aim_ssi_delicon(od->sess); |
4801 } else if (!g_stat(iconfile, &st)) { | 4801 } else if (!g_stat(iconfile, &st)) { |
4802 char *buf = g_malloc(st.st_size); | 4802 guchar *buf = g_malloc(st.st_size); |
4803 FILE *file = g_fopen(iconfile, "rb"); | 4803 FILE *file = g_fopen(iconfile, "rb"); |
4804 if (file) { | 4804 if (file) { |
4805 /* XXX - Use g_file_get_contents()? */ | 4805 /* XXX - Use g_file_get_contents()? */ |
4806 fread(buf, 1, st.st_size, file); | 4806 fread(buf, 1, st.st_size, file); |
4807 fclose(file); | 4807 fclose(file); |
5643 } | 5643 } |
5644 | 5644 |
5645 if (iconfile && !g_stat(iconfile, &st)) { | 5645 if (iconfile && !g_stat(iconfile, &st)) { |
5646 FILE *file = g_fopen(iconfile, "rb"); | 5646 FILE *file = g_fopen(iconfile, "rb"); |
5647 if (file) { | 5647 if (file) { |
5648 char *buf = g_malloc(st.st_size); | 5648 guchar *buf = g_malloc(st.st_size); |
5649 /* XXX - Use g_file_get_contents()? */ | 5649 /* XXX - Use g_file_get_contents()? */ |
5650 fread(buf, 1, st.st_size, file); | 5650 fread(buf, 1, st.st_size, file); |
5651 fclose(file); | 5651 fclose(file); |
5652 | 5652 |
5653 args.iconlen = st.st_size; | 5653 args.iconlen = st.st_size; |
6870 GaimConnection *gc = sess->aux_data; | 6870 GaimConnection *gc = sess->aux_data; |
6871 OscarData *od = gc->proto_data; | 6871 OscarData *od = gc->proto_data; |
6872 va_list ap; | 6872 va_list ap; |
6873 fu16_t type; | 6873 fu16_t type; |
6874 fu8_t flags = 0, length = 0; | 6874 fu8_t flags = 0, length = 0; |
6875 char *md5 = NULL; | 6875 guchar *md5 = NULL; |
6876 | 6876 |
6877 | 6877 |
6878 va_start(ap, fr); | 6878 va_start(ap, fr); |
6879 type = va_arg(ap, int); | 6879 type = va_arg(ap, int); |
6880 | 6880 |
6881 switch(type) { | 6881 switch(type) { |
6882 case 0x0000: | 6882 case 0x0000: |
6883 case 0x0001: { | 6883 case 0x0001: { |
6884 flags = va_arg(ap, int); | 6884 flags = va_arg(ap, int); |
6885 length = va_arg(ap, int); | 6885 length = va_arg(ap, int); |
6886 md5 = va_arg(ap, char *); | 6886 md5 = va_arg(ap, guchar *); |
6887 | 6887 |
6888 if (flags == 0x41) { | 6888 if (flags == 0x41) { |
6889 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { | 6889 if (!aim_getconn_type(od->sess, AIM_CONN_TYPE_ICON) && !od->iconconnecting) { |
6890 od->iconconnecting = TRUE; | 6890 od->iconconnecting = TRUE; |
6891 od->set_icon = TRUE; | 6891 od->set_icon = TRUE; |
6894 struct stat st; | 6894 struct stat st; |
6895 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); | 6895 const char *iconfile = gaim_account_get_buddy_icon(gaim_connection_get_account(gc)); |
6896 if (iconfile == NULL) { | 6896 if (iconfile == NULL) { |
6897 aim_ssi_delicon(od->sess); | 6897 aim_ssi_delicon(od->sess); |
6898 } else if (!g_stat(iconfile, &st)) { | 6898 } else if (!g_stat(iconfile, &st)) { |
6899 char *buf = g_malloc(st.st_size); | 6899 guchar *buf = g_malloc(st.st_size); |
6900 FILE *file = g_fopen(iconfile, "rb"); | 6900 FILE *file = g_fopen(iconfile, "rb"); |
6901 if (file) { | 6901 if (file) { |
6902 /* XXX - Use g_file_get_contents()? */ | 6902 /* XXX - Use g_file_get_contents()? */ |
6903 fread(buf, 1, st.st_size, file); | 6903 fread(buf, 1, st.st_size, file); |
6904 fclose(file); | 6904 fclose(file); |
7425 struct stat st; | 7425 struct stat st; |
7426 | 7426 |
7427 if (iconfile == NULL) { | 7427 if (iconfile == NULL) { |
7428 aim_ssi_delicon(od->sess); | 7428 aim_ssi_delicon(od->sess); |
7429 } else if (!g_stat(iconfile, &st)) { | 7429 } else if (!g_stat(iconfile, &st)) { |
7430 char *buf = g_malloc(st.st_size); | 7430 guchar *buf = g_malloc(st.st_size); |
7431 file = g_fopen(iconfile, "rb"); | 7431 file = g_fopen(iconfile, "rb"); |
7432 if (file) { | 7432 if (file) { |
7433 md5_state_t *state; | 7433 md5_state_t *state; |
7434 char md5[16]; | 7434 guchar md5[16]; |
7435 /* XXX - Use g_file_get_contents()? */ | 7435 /* XXX - Use g_file_get_contents()? */ |
7436 int len = fread(buf, 1, st.st_size, file); | 7436 int len = fread(buf, 1, st.st_size, file); |
7437 fclose(file); | 7437 fclose(file); |
7438 state = g_malloc(sizeof(md5_state_t)); | 7438 state = g_malloc(sizeof(md5_state_t)); |
7439 md5_init(state); | 7439 md5_init(state); |