comparison src/protocols/silc/silc.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 5851a9219bc7
children 029802981b81
comparison
equal deleted inserted replaced
12215:31b91bfab029 12216:4d3119205a33
1060 silc_free(im); 1060 silc_free(im);
1061 silc_free(nickname); 1061 silc_free(nickname);
1062 } 1062 }
1063 1063
1064 static int 1064 static int
1065 silcgaim_send_im(GaimConnection *gc, const char *who, const char *msg, 1065 silcgaim_send_im(GaimConnection *gc, const char *who, const char *message,
1066 GaimConvImFlags flags) 1066 GaimMessageFlags flags)
1067 { 1067 {
1068 SilcGaim sg = gc->proto_data; 1068 SilcGaim sg = gc->proto_data;
1069 SilcClient client = sg->client; 1069 SilcClient client = sg->client;
1070 SilcClientConnection conn = sg->conn; 1070 SilcClientConnection conn = sg->conn;
1071 SilcClientEntry *clients; 1071 SilcClientEntry *clients;
1072 SilcUInt32 clients_count, mflags; 1072 SilcUInt32 clients_count, mflags;
1073 char *nickname; 1073 char *nickname, *msg, *tmp;
1074 int ret; 1074 int ret;
1075 gboolean sign = gaim_account_get_bool(sg->account, "sign-verify", FALSE); 1075 gboolean sign = gaim_account_get_bool(sg->account, "sign-verify", FALSE);
1076 1076
1077 if (!who || !msg) 1077 if (!who || !message)
1078 return 0; 1078 return 0;
1079 1079
1080 mflags = SILC_MESSAGE_FLAG_UTF8; 1080 mflags = SILC_MESSAGE_FLAG_UTF8;
1081
1082 tmp = msg = gaim_unescape_html(message);
1081 1083
1082 if (!g_ascii_strncasecmp(msg, "/me ", 4)) { 1084 if (!g_ascii_strncasecmp(msg, "/me ", 4)) {
1083 msg += 4; 1085 msg += 4;
1084 if (!msg) 1086 if (!*msg) {
1087 g_free(tmp);
1085 return 0; 1088 return 0;
1089 }
1086 mflags |= SILC_MESSAGE_FLAG_ACTION; 1090 mflags |= SILC_MESSAGE_FLAG_ACTION;
1087 } else if (strlen(msg) > 1 && msg[0] == '/') { 1091 } else if (strlen(msg) > 1 && msg[0] == '/') {
1088 if (!silc_client_command_call(client, conn, msg + 1)) 1092 if (!silc_client_command_call(client, conn, msg + 1))
1089 gaim_notify_error(gc, ("Call Command"), _("Cannot call command"), 1093 gaim_notify_error(gc, ("Call Command"), _("Cannot call command"),
1090 _("Unknown command")); 1094 _("Unknown command"));
1095 g_free(tmp);
1091 return 0; 1096 return 0;
1092 } 1097 }
1093 1098
1094 1099
1095 if (!silc_parse_userfqdn(who, &nickname, NULL)) 1100 if (!silc_parse_userfqdn(who, &nickname, NULL)) {
1101 g_free(tmp);
1096 return 0; 1102 return 0;
1103 }
1097 1104
1098 if (sign) 1105 if (sign)
1099 mflags |= SILC_MESSAGE_FLAG_SIGNED; 1106 mflags |= SILC_MESSAGE_FLAG_SIGNED;
1100 1107
1101 /* Find client entry */ 1108 /* Find client entry */
1102 clients = silc_client_get_clients_local(client, conn, nickname, who, 1109 clients = silc_client_get_clients_local(client, conn, nickname, who,
1103 &clients_count); 1110 &clients_count);
1104 if (!clients) { 1111 if (!clients) {
1105 /* Resolve unknown user */ 1112 /* Resolve unknown user */
1106 SilcGaimIM im = silc_calloc(1, sizeof(*im)); 1113 SilcGaimIM im = silc_calloc(1, sizeof(*im));
1107 if (!im) 1114 if (!im) {
1115 g_free(tmp);
1108 return 0; 1116 return 0;
1117 }
1109 im->nick = g_strdup(who); 1118 im->nick = g_strdup(who);
1110 im->message = g_strdup(msg); 1119 im->message = g_strdup(msg);
1111 im->message_len = strlen(im->message); 1120 im->message_len = strlen(im->message);
1112 im->flags = mflags; 1121 im->flags = mflags;
1113 silc_client_get_clients(client, conn, nickname, NULL, 1122 silc_client_get_clients(client, conn, nickname, NULL,
1114 silcgaim_send_im_resolved, im); 1123 silcgaim_send_im_resolved, im);
1115 silc_free(nickname); 1124 silc_free(nickname);
1125 g_free(tmp);
1116 return 0; 1126 return 0;
1117 } 1127 }
1118 1128
1119 /* Send private message directly */ 1129 /* Send private message directly */
1120 ret = silc_client_send_private_message(client, conn, clients[0], 1130 ret = silc_client_send_private_message(client, conn, clients[0],
1121 mflags, (unsigned char *)msg, 1131 mflags, (unsigned char *)msg,
1122 strlen(msg), TRUE); 1132 strlen(msg), TRUE);
1123 1133
1134 g_free(tmp);
1124 silc_free(nickname); 1135 silc_free(nickname);
1125 silc_free(clients); 1136 silc_free(clients);
1126 return ret; 1137 return ret;
1127 } 1138 }
1128 1139