comparison src/server.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 e75ef7aa913e
children 3ef381cdc47e
comparison
equal deleted inserted replaced
12215:31b91bfab029 12216:4d3119205a33
111 111
112 return lar; 112 return lar;
113 } 113 }
114 114
115 int serv_send_im(GaimConnection *gc, const char *name, const char *message, 115 int serv_send_im(GaimConnection *gc, const char *name, const char *message,
116 GaimConvImFlags imflags) 116 GaimMessageFlags flags)
117 { 117 {
118 GaimConversation *conv; 118 GaimConversation *conv;
119 GaimAccount *account; 119 GaimAccount *account;
120 GaimPresence *presence; 120 GaimPresence *presence;
121 GaimPluginProtocolInfo *prpl_info = NULL; 121 GaimPluginProtocolInfo *prpl_info = NULL;
129 presence = gaim_account_get_presence(account); 129 presence = gaim_account_get_presence(account);
130 130
131 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account); 131 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, gc->account);
132 132
133 if (prpl_info && prpl_info->send_im) 133 if (prpl_info && prpl_info->send_im)
134 val = prpl_info->send_im(gc, name, message, imflags); 134 val = prpl_info->send_im(gc, name, message, flags);
135 135
136 /* Only update the last_sent_time if the user actually sent the message */ 136 /* Only update the last_sent_time if the user actually sent the message */
137 if (!(imflags & GAIM_CONV_IM_AUTO_RESP)) 137 if (!(flags & GAIM_MESSAGE_AUTO_RESP))
138 time(&gc->last_sent_time); 138 time(&gc->last_sent_time);
139 139
140 /* 140 /*
141 * XXX - If "only auto-reply when away & idle" is set, then shouldn't 141 * XXX - If "only auto-reply when away & idle" is set, then shouldn't
142 * this only reset lar->sent if we're away AND idle? 142 * this only reset lar->sent if we're away AND idle?
398 398
399 if (prpl_info && prpl_info->chat_whisper) 399 if (prpl_info && prpl_info->chat_whisper)
400 prpl_info->chat_whisper(g, id, who, message); 400 prpl_info->chat_whisper(g, id, who, message);
401 } 401 }
402 402
403 int serv_chat_send(GaimConnection *gc, int id, const char *message) 403 int serv_chat_send(GaimConnection *gc, int id, const char *message, GaimMessageFlags flags)
404 { 404 {
405 int val = -EINVAL; 405 int val = -EINVAL;
406 GaimPluginProtocolInfo *prpl_info = NULL; 406 GaimPluginProtocolInfo *prpl_info = NULL;
407 407
408 if (gc->prpl != NULL) 408 if (gc->prpl != NULL)
409 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); 409 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl);
410 410
411 if (prpl_info && prpl_info->chat_send) 411 if (prpl_info && prpl_info->chat_send)
412 val = prpl_info->chat_send(gc, id, message); 412 val = prpl_info->chat_send(gc, id, message, flags);
413 413
414 time(&gc->last_sent_time); 414 time(&gc->last_sent_time);
415 415
416 return val; 416 return val;
417 } 417 }
431 /* 431 /*
432 * woo. i'm actually going to comment this function. isn't that fun. make 432 * woo. i'm actually going to comment this function. isn't that fun. make
433 * sure to follow along, kids 433 * sure to follow along, kids
434 */ 434 */
435 void serv_got_im(GaimConnection *gc, const char *who, const char *msg, 435 void serv_got_im(GaimConnection *gc, const char *who, const char *msg,
436 GaimConvImFlags imflags, time_t mtime) 436 GaimMessageFlags flags, time_t mtime)
437 { 437 {
438 GaimAccount *account; 438 GaimAccount *account;
439 GaimConversation *cnv; 439 GaimConversation *cnv;
440 GaimPresence *presence; 440 GaimPresence *presence;
441 GaimStatus *status; 441 GaimStatus *status;
442 GaimMessageFlags msgflags;
443 char *message, *name; 442 char *message, *name;
444 char *angel, *buffy; 443 char *angel, *buffy;
445 int plugin_return; 444 int plugin_return;
446 445
447 g_return_if_fail(msg != NULL); 446 g_return_if_fail(msg != NULL);
465 angel = g_strdup(who); 464 angel = g_strdup(who);
466 465
467 plugin_return = GPOINTER_TO_INT( 466 plugin_return = GPOINTER_TO_INT(
468 gaim_signal_emit_return_1(gaim_conversations_get_handle(), 467 gaim_signal_emit_return_1(gaim_conversations_get_handle(),
469 "receiving-im-msg", gc->account, 468 "receiving-im-msg", gc->account,
470 &angel, &buffy, cnv, &imflags)); 469 &angel, &buffy, cnv, &flags));
471 470
472 if (!buffy || !angel || plugin_return) { 471 if (!buffy || !angel || plugin_return) {
473 if (buffy) 472 if (buffy)
474 g_free(buffy); 473 g_free(buffy);
475 if (angel) 474 if (angel)
479 478
480 name = angel; 479 name = angel;
481 message = buffy; 480 message = buffy;
482 481
483 gaim_signal_emit(gaim_conversations_get_handle(), "received-im-msg", gc->account, 482 gaim_signal_emit(gaim_conversations_get_handle(), "received-im-msg", gc->account,
484 name, message, cnv, imflags); 483 name, message, cnv, flags);
485 484
486 /* Make sure URLs are clickable */ 485 /* Make sure URLs are clickable */
487 buffy = gaim_markup_linkify(message); 486 buffy = gaim_markup_linkify(message);
488 g_free(message); 487 g_free(message);
489 message = buffy; 488 message = buffy;
490 489
491 /* 490 /*
492 * Um. When we call gaim_conversation_write with the message we received, 491 * XXX: Should we be setting this here, or relying on prpls to set it?
493 * it's nice to pass whether or not it was an auto-response. So if it
494 * was an auto-response, we set the appropriate flag. This is just so
495 * prpls don't have to know about GAIM_MESSAGE_* (though some do anyway).
496 */ 492 */
497 msgflags = GAIM_MESSAGE_RECV; 493 flags |= GAIM_MESSAGE_RECV;
498 if (imflags & GAIM_CONV_IM_AUTO_RESP)
499 msgflags |= GAIM_MESSAGE_AUTO_RESP;
500 494
501 /* 495 /*
502 * Alright. Two cases for how to handle this. Either we're away or 496 * Alright. Two cases for how to handle this. Either we're away or
503 * we're not. If we're not, then it's easy. If we are, then there 497 * we're not. If we're not, then it's easy. If we are, then there
504 * are three or four different ways of handling it and different 498 * are three or four different ways of handling it and different
514 const char *away_msg; 508 const char *away_msg;
515 509
516 if (cnv == NULL) 510 if (cnv == NULL)
517 cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); 511 cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name);
518 512
519 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime); 513 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, flags, mtime);
520 514
521 /* 515 /*
522 * Don't autorespond if: 516 * Don't autorespond if:
523 * 517 *
524 * - it's not supported on this connection 518 * - it's not supported on this connection
567 if ((away_msg == NULL) || (*away_msg == '\0')) 561 if ((away_msg == NULL) || (*away_msg == '\0'))
568 return; 562 return;
569 563
570 /* Move this to oscar.c! */ 564 /* Move this to oscar.c! */
571 buffy = gaim_str_sub_away_formatters(away_msg, alias); 565 buffy = gaim_str_sub_away_formatters(away_msg, alias);
572 serv_send_im(gc, name, buffy, GAIM_CONV_IM_AUTO_RESP); 566 serv_send_im(gc, name, buffy, GAIM_MESSAGE_AUTO_RESP);
573 567
574 #if 0 568 #if 0
575 if (!cnv && awayqueue && 569 if (!cnv && awayqueue &&
576 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { 570 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) {
577 571
605 */ 599 */
606 600
607 if (cnv == NULL) 601 if (cnv == NULL)
608 cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gc->account, name); 602 cnv = gaim_conversation_new(GAIM_CONV_TYPE_IM, gc->account, name);
609 603
610 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, msgflags, mtime); 604 gaim_conv_im_write(GAIM_CONV_IM(cnv), NULL, message, flags, mtime);
611 } 605 }
612 606
613 g_free(name); 607 g_free(name);
614 g_free(message); 608 g_free(message);
615 } 609 }
789 783
790 gaim_conv_chat_left(GAIM_CONV_CHAT(conv)); 784 gaim_conv_chat_left(GAIM_CONV_CHAT(conv));
791 } 785 }
792 786
793 void serv_got_chat_in(GaimConnection *g, int id, const char *who, 787 void serv_got_chat_in(GaimConnection *g, int id, const char *who,
794 GaimConvChatFlags chatflags, const char *message, time_t mtime) 788 GaimMessageFlags flags, const char *message, time_t mtime)
795 { 789 {
796 GaimMessageFlags msgflags = 0;
797 GSList *bcs; 790 GSList *bcs;
798 GaimConversation *conv = NULL; 791 GaimConversation *conv = NULL;
799 GaimConvChat *chat = NULL; 792 GaimConvChat *chat = NULL;
800 char *buf; 793 char *buf;
801 char *buffy, *angel; 794 char *buffy, *angel;
828 angel = g_strdup(who); 821 angel = g_strdup(who);
829 822
830 plugin_return = GPOINTER_TO_INT( 823 plugin_return = GPOINTER_TO_INT(
831 gaim_signal_emit_return_1(gaim_conversations_get_handle(), 824 gaim_signal_emit_return_1(gaim_conversations_get_handle(),
832 "receiving-chat-msg", g->account, 825 "receiving-chat-msg", g->account,
833 &angel, &buffy, conv, &chatflags)); 826 &angel, &buffy, conv, &flags));
834 827
835 if (!buffy || !angel || plugin_return) { 828 if (!buffy || !angel || plugin_return) {
836 if (buffy) 829 if (buffy)
837 g_free(buffy); 830 g_free(buffy);
838 if (angel) 831 if (angel)
841 } 834 }
842 who = angel; 835 who = angel;
843 message = buffy; 836 message = buffy;
844 837
845 gaim_signal_emit(gaim_conversations_get_handle(), "received-chat-msg", g->account, 838 gaim_signal_emit(gaim_conversations_get_handle(), "received-chat-msg", g->account,
846 who, message, conv, chatflags); 839 who, message, conv, flags);
847 840
848 /* Make sure URLs are clickable */ 841 /* Make sure URLs are clickable */
849 buf = gaim_markup_linkify(message); 842 buf = gaim_markup_linkify(message);
850 843
851 if (chatflags & GAIM_CONV_CHAT_WHISPER) 844 gaim_conv_chat_write(chat, who, buf, flags, mtime);
852 msgflags |= GAIM_MESSAGE_WHISPER;
853 if (chatflags & GAIM_CONV_CHAT_DELAYED)
854 msgflags |= GAIM_MESSAGE_DELAYED;
855 if (chatflags & GAIM_CONV_CHAT_ALERT)
856 msgflags |= GAIM_MESSAGE_NICK;
857
858 gaim_conv_chat_write(chat, who, buf, msgflags, mtime);
859 845
860 g_free(angel); 846 g_free(angel);
861 g_free(buf); 847 g_free(buf);
862 g_free(buffy); 848 g_free(buffy);
863 } 849 }