comparison src/protocols/oscar/oscar.c @ 4173:b66f960bfe60

[gaim-migrate @ 4403] So type is actually 1 byte, and not 2. Something about an ass out of u and me. This should make multi-recipient ICQ messages work. It also fixes a little mistake that caused ICQ URLs, auth requests, pager messages, emails, and ICQ cotact sending thingies to not show up. I don't think that bug existed for more than a more days. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 02 Jan 2003 22:22:38 +0000
parents 481c51159627
children 9325df841a40
comparison
equal deleted inserted replaced
4172:88ebcfcc3217 4173:b66f960bfe60
2076 return 1; 2076 return 1;
2077 2077
2078 debug_printf("Received a channel 4 message of type %d.\n", args->type); 2078 debug_printf("Received a channel 4 message of type %d.\n", args->type);
2079 2079
2080 /* Split up the message at the delimeter character, then convert each string to UTF-8 */ 2080 /* Split up the message at the delimeter character, then convert each string to UTF-8 */
2081 msg1 = g_strsplit(args->msg, "\177", 0); 2081 msg1 = g_strsplit(args->msg, "\376", 0);
2082 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* AAA */ 2082 msg2 = (gchar **)g_malloc(10*sizeof(gchar *)); /* AAA */
2083 for (i=0; msg1[i]; i++) { 2083 for (i=0; msg1[i]; i++) {
2084 strip_linefeed(msg1[i]); 2084 strip_linefeed(msg1[i]);
2085 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err); 2085 msg2[i] = g_convert(msg1[i], strlen(msg1[i]), "UTF-8", "ISO-8859-1", NULL, NULL, &err);
2086 if (err) 2086 if (err)
2087 debug_printf("Error converting a string from ISO-8859-1 to UTF-8 in oscar ICBM channel 4 parsing\n"); 2087 debug_printf("Error converting a string from ISO-8859-1 to UTF-8 in oscar ICBM channel 4 parsing\n");
2088 } 2088 }
2089 msg2[i] = NULL; 2089 msg2[i] = NULL;
2090 2090
2091 switch (args->type) { 2091 switch (args->type) {
2092 case 0x0001: { /* MacICQ message or basic offline message */ 2092 case 0x01: { /* MacICQ message or basic offline message */
2093 if (i >= 1) { 2093 if (i >= 1) {
2094 gchar *uin = g_strdup_printf("%lu", args->uin); 2094 gchar *uin = g_strdup_printf("%lu", args->uin);
2095 if (t) { /* This is an offline message */ 2095 if (t) { /* This is an offline message */
2096 /* I think this timestamp is in UTC, or something */ 2096 /* I think this timestamp is in UTC, or something */
2097 serv_got_im(gc, uin, msg2[0], 0, t, -1); 2097 serv_got_im(gc, uin, msg2[0], 0, t, -1);
2100 } 2100 }
2101 g_free(uin); 2101 g_free(uin);
2102 } 2102 }
2103 } break; 2103 } break;
2104 2104
2105 case 0x0004: { /* Someone sent you a URL */ 2105 case 0x04: { /* Someone sent you a URL */
2106 if (i >= 2) { 2106 if (i >= 2) {
2107 gchar *uin = g_strdup_printf("%lu", args->uin); 2107 gchar *uin = g_strdup_printf("%lu", args->uin);
2108 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]); 2108 gchar *message = g_strdup_printf("<A HREF=\"%s\">%s</A>", msg2[1], msg2[0]);
2109 serv_got_im(gc, uin, message, 0, time(NULL), -1); 2109 serv_got_im(gc, uin, message, 0, time(NULL), -1);
2110 g_free(uin); 2110 g_free(uin);
2111 g_free(message); 2111 g_free(message);
2112 } 2112 }
2113 } break; 2113 } break;
2114 2114
2115 case 0x0006: { /* Someone requested authorization */ 2115 case 0x06: { /* Someone requested authorization */
2116 if (i >= 6) { 2116 if (i >= 6) {
2117 struct channel4_data *data = g_new(struct channel4_data, 1); 2117 struct channel4_data *data = g_new(struct channel4_data, 1);
2118 char *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason: %s"), args->uin, msg2[5] ? msg2[5] : _("No reason given.")); 2118 char *dialog_msg = g_strdup_printf(_("The user %lu wants to add you to their buddy list for the following reason: %s"), args->uin, msg2[5] ? msg2[5] : _("No reason given."));
2119 debug_printf("Received an authorization request from UIN %lu\n", args->uin); 2119 debug_printf("Received an authorization request from UIN %lu\n", args->uin);
2120 data->gc = gc; 2120 data->gc = gc;
2122 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_icq_authgrant, _("Deny"), gaim_icq_authdeny); 2122 do_ask_dialog(_("Authorization Request"), dialog_msg, data, _("Authorize"), gaim_icq_authgrant, _("Deny"), gaim_icq_authdeny);
2123 g_free(dialog_msg); 2123 g_free(dialog_msg);
2124 } 2124 }
2125 } break; 2125 } break;
2126 2126
2127 case 0x0007: { /* Someone has denied you authorization */ 2127 case 0x07: { /* Someone has denied you authorization */
2128 if (i >= 1) { 2128 if (i >= 1) {
2129 char *dialog_msg = g_strdup_printf(_("The user %lu has denied your request to add them to your contact list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given.")); 2129 char *dialog_msg = g_strdup_printf(_("The user %lu has denied your request to add them to your contact list for the following reason:\n%s"), args->uin, msg2[0] ? msg2[0] : _("No reason given."));
2130 do_error_dialog(_("ICQ authorization denied."), dialog_msg, GAIM_ERROR); 2130 do_error_dialog(_("ICQ authorization denied."), dialog_msg, GAIM_ERROR);
2131 g_free(dialog_msg); 2131 g_free(dialog_msg);
2132 } 2132 }
2133 } break; 2133 } break;
2134 2134
2135 case 0x0008: { /* Someone has granted you authorization */ 2135 case 0x08: { /* Someone has granted you authorization */
2136 char *dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin); 2136 char *dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin);
2137 do_error_dialog("ICQ authorization accepted.", dialog_msg, GAIM_INFO); 2137 do_error_dialog("ICQ authorization accepted.", dialog_msg, GAIM_INFO);
2138 g_free(dialog_msg); 2138 g_free(dialog_msg);
2139 } break; 2139 } break;
2140 2140
2141 case 0x000d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */ 2141 case 0x0d: { /* Someone has sent you a pager message from http://www.icq.com/your_uin */
2142 if (i >= 6) { 2142 if (i >= 6) {
2143 char *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]); 2143 char *dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), msg2[0], msg2[3], msg2[5]);
2144 do_error_dialog("ICQ Page", dialog_msg, GAIM_INFO); 2144 do_error_dialog("ICQ Page", dialog_msg, GAIM_INFO);
2145 g_free(dialog_msg); 2145 g_free(dialog_msg);
2146 } 2146 }
2147 } break; 2147 } break;
2148 2148
2149 case 0x000e: { /* Someone has emailed you at your_uin@pager.icq.com */ 2149 case 0x0e: { /* Someone has emailed you at your_uin@pager.icq.com */
2150 if (i >= 6) { 2150 if (i >= 6) {
2151 char *dialog_msg = g_strdup_printf(_("You have received an ICQ email\n\n1=%s\n2=%s\n3=%s\n4=%s\n5=%s\n6=%s\n"), msg2[0], msg2[1], msg2[2], msg2[3], msg2[4], msg2[5]); 2151 char *dialog_msg = g_strdup_printf(_("You have received an ICQ email\n\n1=%s\n2=%s\n3=%s\n4=%s\n5=%s\n6=%s\n"), msg2[0], msg2[1], msg2[2], msg2[3], msg2[4], msg2[5]);
2152 do_error_dialog("ICQ Email", dialog_msg, GAIM_INFO); 2152 do_error_dialog("ICQ Email", dialog_msg, GAIM_INFO);
2153 g_free(dialog_msg); 2153 g_free(dialog_msg);
2154 } 2154 }
2155 } break; 2155 } break;
2156 2156
2157 case 0x0012: { 2157 case 0x12: {
2158 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ 2158 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
2159 /* Someone added you to their contact list? */
2159 } break; 2160 } break;
2160 2161
2161 case 0x0013: { /* Someone has sent you some ICQ contacts */ 2162 case 0x13: { /* Someone has sent you some ICQ contacts */
2162 int i, num; 2163 int i, num;
2163 gchar **text; 2164 gchar **text;
2164 text = g_strsplit(args->msg, "\177", 0); 2165 text = g_strsplit(args->msg, "\376", 0);
2165 if (text) { 2166 if (text) {
2166 num = 0; 2167 num = 0;
2167 for (i=0; i<strlen(text[0]); i++) 2168 for (i=0; i<strlen(text[0]); i++)
2168 num = num*10 + text[0][i]-48; 2169 num = num*10 + text[0][i]-48;
2169 for (i=0; i<num; i++) { 2170 for (i=0; i<num; i++) {
2177 } 2178 }
2178 g_strfreev(text); 2179 g_strfreev(text);
2179 } 2180 }
2180 } break; 2181 } break;
2181 2182
2182 case 0x001a: { /* Someone has sent you a greeting card or requested contacts? */ 2183 case 0x1a: { /* Someone has sent you a greeting card or requested contacts? */
2183 /* This is boring and silly. */ 2184 /* This is boring and silly. */
2184 } break; 2185 } break;
2185 2186
2186 default: { 2187 default: {
2187 debug_printf("Received a channel 4 message of unknown type (type 0x%04d).\n", args->type); 2188 debug_printf("Received a channel 4 message of unknown type (type 0x%02d).\n", args->type);
2188 } break; 2189 } break;
2189 } 2190 }
2190 2191
2191 g_strfreev(msg1); 2192 g_strfreev(msg1);
2192 g_strfreev(msg2); 2193 g_strfreev(msg2);
3266 va_end(ap); 3267 va_end(ap);
3267 3268
3268 debug_printf("Received offline message. Converting to channel 4 ICBM...\n"); 3269 debug_printf("Received offline message. Converting to channel 4 ICBM...\n");
3269 args.uin = msg->sender; 3270 args.uin = msg->sender;
3270 args.type = msg->type; 3271 args.type = msg->type;
3272 args.flags = msg->flags;
3271 args.msglen = msg->msglen; 3273 args.msglen = msg->msglen;
3272 args.msg = msg->msg; 3274 args.msg = msg->msg;
3273 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0); 3275 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
3274 incomingim_chan4(sess, fr->conn, NULL, &args, t); 3276 incomingim_chan4(sess, fr->conn, NULL, &args, t);
3275 3277