Mercurial > pidgin
comparison src/protocols/oscar/oscar.c @ 12216:4d3119205a33
[gaim-migrate @ 14518]
Remove GaimConvImFlags and GaimConvChatFlags - use GaimMessageFlags
everywhere instead.
Add a new GAIM_MESSAGE_IMAGES flag, and set it when sending a message
containing images.
When sending a message, the core will now always send "html" to the prpls,
just like it expects to receive html from the prpls for received messages.
This will allow text prpls such as SILC to support IM images and differentiate
them from user input. Previously gaim_unescape_html() was used before passing
the message to the prpl, now the prpl does this itself if it needs it.
I think I updated all the prpls correctly, but I'm not so sure about sametime.
committer: Tailor Script <tailor@pidgin.im>
author | Stu Tomlinson <stu@nosnilmot.com> |
---|---|
date | Thu, 24 Nov 2005 20:47:46 +0000 |
parents | 2de8b6772d00 |
children | d3cb077caf3e |
comparison
equal
deleted
inserted
replaced
12215:31b91bfab029 | 12216:4d3119205a33 |
---|---|
1247 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> | 1247 * <DATA ID="2" SIZE="65978">datadatadatadata</DATA> |
1248 * </BINARY> | 1248 * </BINARY> |
1249 */ | 1249 */ |
1250 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { | 1250 static int gaim_odc_incoming(aim_session_t *sess, aim_frame_t *fr, ...) { |
1251 GaimConnection *gc = sess->aux_data; | 1251 GaimConnection *gc = sess->aux_data; |
1252 GaimConvImFlags imflags = 0; | 1252 GaimMessageFlags imflags = 0; |
1253 gchar *utf8; | 1253 gchar *utf8; |
1254 GString *newmsg = g_string_new(""); | 1254 GString *newmsg = g_string_new(""); |
1255 GSList *images = NULL; | 1255 GSList *images = NULL; |
1256 va_list ap; | 1256 va_list ap; |
1257 const char *sn, *msg, *msgend, *binary; | 1257 const char *sn, *msg, *msgend, *binary; |
1269 | 1269 |
1270 gaim_debug_info("oscar", | 1270 gaim_debug_info("oscar", |
1271 "Got DirectIM message from %s\n", sn); | 1271 "Got DirectIM message from %s\n", sn); |
1272 | 1272 |
1273 if (isawaymsg) | 1273 if (isawaymsg) |
1274 imflags |= GAIM_CONV_IM_AUTO_RESP; | 1274 imflags |= GAIM_MESSAGE_AUTO_RESP; |
1275 | 1275 |
1276 /* message has a binary trailer */ | 1276 /* message has a binary trailer */ |
1277 if ((binary = gaim_strcasestr(msg, "<binary>"))) { | 1277 if ((binary = gaim_strcasestr(msg, "<binary>"))) { |
1278 GData *attribs; | 1278 GData *attribs; |
1279 const char *tmp, *start, *end, *last = NULL; | 1279 const char *tmp, *start, *end, *last = NULL; |
1348 if (last++ && (last < binary)) | 1348 if (last++ && (last < binary)) |
1349 newmsg = g_string_append_len(newmsg, last, binary - last); | 1349 newmsg = g_string_append_len(newmsg, last, binary - last); |
1350 | 1350 |
1351 /* set the flag if we caught any images */ | 1351 /* set the flag if we caught any images */ |
1352 if (images) | 1352 if (images) |
1353 imflags |= GAIM_CONV_IM_IMAGES; | 1353 imflags |= GAIM_MESSAGE_IMAGES; |
1354 } else { | 1354 } else { |
1355 g_string_append_len(newmsg, msg, len); | 1355 g_string_append_len(newmsg, msg, len); |
1356 } | 1356 } |
1357 | 1357 |
1358 /* Convert to UTF8 */ | 1358 /* Convert to UTF8 */ |
1403 else | 1403 else |
1404 serv_got_typing_stopped(gc, sn); | 1404 serv_got_typing_stopped(gc, sn); |
1405 return 1; | 1405 return 1; |
1406 } | 1406 } |
1407 | 1407 |
1408 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimConvImFlags imflags) { | 1408 static int gaim_odc_send_im(aim_session_t *sess, aim_conn_t *conn, const char *message, GaimMessageFlags imflags) { |
1409 char *buf; | 1409 char *buf; |
1410 size_t len; | 1410 size_t len; |
1411 int ret; | 1411 int ret; |
1412 GString *msg = g_string_new("<HTML><BODY>"); | 1412 GString *msg = g_string_new("<HTML><BODY>"); |
1413 GString *data = g_string_new("</BODY></HTML><BINARY>"); | 1413 GString *data = g_string_new("</BODY></HTML><BINARY>"); |
1476 g_string_free(msg, FALSE); | 1476 g_string_free(msg, FALSE); |
1477 g_string_free(data, TRUE); | 1477 g_string_free(data, TRUE); |
1478 | 1478 |
1479 | 1479 |
1480 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ | 1480 /* XXX - The last parameter below is the encoding. Let Paco-Paco do something with it. */ |
1481 if (imflags & GAIM_CONV_IM_AUTO_RESP) | 1481 if (imflags & GAIM_MESSAGE_AUTO_RESP) |
1482 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); | 1482 ret = aim_odc_send_im(sess, conn, buf, len, 0, 1); |
1483 else | 1483 else |
1484 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); | 1484 ret = aim_odc_send_im(sess, conn, buf, len, 0, 0); |
1485 | 1485 |
1486 g_free(buf); | 1486 g_free(buf); |
3890 | 3890 |
3891 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { | 3891 static int incomingim_chan1(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch1_args *args) { |
3892 GaimConnection *gc = sess->aux_data; | 3892 GaimConnection *gc = sess->aux_data; |
3893 OscarData *od = gc->proto_data; | 3893 OscarData *od = gc->proto_data; |
3894 GaimAccount *account = gaim_connection_get_account(gc); | 3894 GaimAccount *account = gaim_connection_get_account(gc); |
3895 GaimConvImFlags flags = 0; | 3895 GaimMessageFlags flags = 0; |
3896 struct buddyinfo *bi; | 3896 struct buddyinfo *bi; |
3897 char *iconfile; | 3897 char *iconfile; |
3898 GString *message; | 3898 GString *message; |
3899 gchar *tmp; | 3899 gchar *tmp; |
3900 aim_mpmsg_section_t *curpart; | 3900 aim_mpmsg_section_t *curpart; |
3910 bi = g_new0(struct buddyinfo, 1); | 3910 bi = g_new0(struct buddyinfo, 1); |
3911 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); | 3911 g_hash_table_insert(od->buddyinfo, g_strdup(gaim_normalize(account, userinfo->sn)), bi); |
3912 } | 3912 } |
3913 | 3913 |
3914 if (args->icbmflags & AIM_IMFLAGS_AWAY) | 3914 if (args->icbmflags & AIM_IMFLAGS_AWAY) |
3915 flags |= GAIM_CONV_IM_AUTO_RESP; | 3915 flags |= GAIM_MESSAGE_AUTO_RESP; |
3916 | 3916 |
3917 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) | 3917 if (args->icbmflags & AIM_IMFLAGS_TYPINGNOT) |
3918 bi->typingnot = TRUE; | 3918 bi->typingnot = TRUE; |
3919 else | 3919 else |
3920 bi->typingnot = FALSE; | 3920 bi->typingnot = FALSE; |
6318 } | 6318 } |
6319 } | 6319 } |
6320 return 0; | 6320 return 0; |
6321 } | 6321 } |
6322 | 6322 |
6323 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimConvImFlags); | 6323 static int gaim_odc_send_im(aim_session_t *, aim_conn_t *, const char *, GaimMessageFlags); |
6324 | 6324 |
6325 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimConvImFlags imflags) { | 6325 static int oscar_send_im(GaimConnection *gc, const char *name, const char *message, GaimMessageFlags imflags) { |
6326 OscarData *od = (OscarData *)gc->proto_data; | 6326 OscarData *od = (OscarData *)gc->proto_data; |
6327 GaimAccount *account = gaim_connection_get_account(gc); | 6327 GaimAccount *account = gaim_connection_get_account(gc); |
6328 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); | 6328 struct oscar_direct_im *dim = oscar_direct_im_find(od, name); |
6329 int ret = 0; | 6329 int ret = 0; |
6330 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); | 6330 char *iconfile = gaim_buddy_icons_get_full_path(gaim_account_get_buddy_icon(account)); |
6374 args.flags |= AIM_IMFLAGS_OFFLINE; | 6374 args.flags |= AIM_IMFLAGS_OFFLINE; |
6375 } else { | 6375 } else { |
6376 args.features = features_aim; | 6376 args.features = features_aim; |
6377 args.featureslen = sizeof(features_aim); | 6377 args.featureslen = sizeof(features_aim); |
6378 | 6378 |
6379 if (imflags & GAIM_CONV_IM_AUTO_RESP) | 6379 if (imflags & GAIM_MESSAGE_AUTO_RESP) |
6380 args.flags |= AIM_IMFLAGS_AWAY; | 6380 args.flags |= AIM_IMFLAGS_AWAY; |
6381 } | 6381 } |
6382 | 6382 |
6383 if (bi->ico_need) { | 6383 if (bi->ico_need) { |
6384 gaim_debug_info("oscar", | 6384 gaim_debug_info("oscar", |
6426 * and use \r\n as the newline character. | 6426 * and use \r\n as the newline character. |
6427 */ | 6427 */ |
6428 if (aim_sn_is_icq(gaim_account_get_username(account))) { | 6428 if (aim_sn_is_icq(gaim_account_get_username(account))) { |
6429 if (aim_sn_is_icq(name)) | 6429 if (aim_sn_is_icq(name)) |
6430 /* From ICQ to ICQ */ | 6430 /* From ICQ to ICQ */ |
6431 tmpmsg = g_strdup(message); | 6431 tmpmsg = gaim_unescape_html(message); |
6432 else | 6432 else |
6433 /* From ICQ to AIM */ | 6433 /* From ICQ to AIM */ |
6434 tmpmsg = g_markup_escape_text(message, -1); | 6434 tmpmsg = g_strdup(message); |
6435 } else { | 6435 } else { |
6436 /* From AIM to AIM and AIM to ICQ */ | 6436 /* From AIM to AIM and AIM to ICQ */ |
6437 tmpmsg = g_strdup(message); | 6437 tmpmsg = g_strdup(message); |
6438 } | 6438 } |
6439 len = strlen(tmpmsg); | 6439 len = strlen(tmpmsg); |
7431 | 7431 |
7432 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); | 7432 cc = find_oscar_chat(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv))); |
7433 oscar_chat_kill(gc, cc); | 7433 oscar_chat_kill(gc, cc); |
7434 } | 7434 } |
7435 | 7435 |
7436 static int oscar_send_chat(GaimConnection *gc, int id, const char *message) { | 7436 static int oscar_send_chat(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags) { |
7437 OscarData *od = (OscarData *)gc->proto_data; | 7437 OscarData *od = (OscarData *)gc->proto_data; |
7438 GaimConversation *conv = NULL; | 7438 GaimConversation *conv = NULL; |
7439 struct chat_connection *c = NULL; | 7439 struct chat_connection *c = NULL; |
7440 char *buf, *buf2; | 7440 char *buf, *buf2; |
7441 fu16_t charset, charsubset; | 7441 fu16_t charset, charsubset; |