comparison src/protocols/oscar/oscar.c @ 4075:2221f6801577

[gaim-migrate @ 4290] Most of this is changing offline message parsing so it uses the channel 4 ICBM code, since it's basically the same. This fixes the receiving of offline URLs. I also added handling for those pager/web message thingies, and partial support for email messages. I would finish it, but I can't get stupid ICQ to email me any more. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 14 Dec 2002 22:48:38 +0000
parents 4f3fb54ee669
children 91c4bd698d39
comparison
equal deleted inserted replaced
4074:3ccbdf8e7f8d 4075:2221f6801577
2041 free(data->uin); 2041 free(data->uin);
2042 free(data->nick); 2042 free(data->nick);
2043 g_free(data); 2043 g_free(data);
2044 } 2044 }
2045 2045
2046 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args) { 2046 static int incomingim_chan4(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *userinfo, struct aim_incomingim_ch4_args *args, time_t t) {
2047 struct gaim_connection *gc = sess->aux_data; 2047 struct gaim_connection *gc = sess->aux_data;
2048 2048
2049 debug_printf("Received a channel 4 message of type (type 0x%04d).\n", args->type);
2049 switch (args->type) { 2050 switch (args->type) {
2050 case 0x0001: { /* An almost-normal instant message. Mac ICQ sends this. It's peculiar. */ 2051 case 0x0001: { /* MacICQ message or basic offline message */
2051 gchar *uin, *message; 2052 gchar *uin, *message;
2052 uin = g_strdup_printf("%lu", args->uin); 2053 uin = g_strdup_printf("%lu", args->uin);
2053 message = g_strdup(args->msg); 2054 message = g_strdup(args->msg);
2054 strip_linefeed(message); 2055 strip_linefeed(message);
2055 serv_got_im(gc, uin, message, 0, time(NULL), -1); 2056 if (t) {
2057 /* This is an offline message */
2058 /* I think this timestamp is in UTC, or something */
2059 serv_got_im(gc, uin, message, 0, t, -1);
2060 } else {
2061 /* This is a message from MacICQ/Miranda */
2062 serv_got_im(gc, uin, message, 0, time(NULL), -1);
2063 }
2056 g_free(uin); 2064 g_free(uin);
2057 g_free(message); 2065 g_free(message);
2058 } break; 2066 } break;
2059 2067
2060 case 0x0004: { /* Someone sent you a URL */ 2068 case 0x0004: { /* Someone sent you a URL */
2084 2092
2085 case 0x0008: { /* Someone has granted you authorization */ 2093 case 0x0008: { /* Someone has granted you authorization */
2086 char *dialog_msg; 2094 char *dialog_msg;
2087 dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin); 2095 dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), args->uin);
2088 do_error_dialog("ICQ authorization accepted.", dialog_msg, GAIM_INFO); 2096 do_error_dialog("ICQ authorization accepted.", dialog_msg, GAIM_INFO);
2097 g_free(dialog_msg);
2098 } break;
2099
2100 case 0x000d: { /* Someone has sent you a pager message from http://web.icq.com/wwp/1,,,00.html?Uin=your_uin */
2101 char *dialog_msg;
2102 gchar **text;
2103 text = g_strsplit(args->msg, "þ", 0);
2104 dialog_msg = g_strdup_printf(_("You have received an ICQ page\n\nFrom: %s [%s]\n%s"), text[0], text[3], text[5]);
2105 do_error_dialog("ICQ Page", dialog_msg, GAIM_INFO);
2106 g_strfreev(text);
2107 g_free(dialog_msg);
2108 } break;
2109
2110 case 0x000e: { /* Someone has emailed you at your_uin@pager.icq.com */
2111 char *dialog_msg;
2112 gchar **text;
2113 text = g_strsplit(args->msg, "þ", 0);
2114 /* 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"), text[0], text[1], text[2], text[3], text[4], text[5]); */
2115 dialog_msg = g_strdup_printf(_("You have received an ICQ email\n\nFrom: Not yet"));
2116 do_error_dialog("ICQ Email", dialog_msg, GAIM_INFO);
2117 g_strfreev(text);
2089 g_free(dialog_msg); 2118 g_free(dialog_msg);
2090 } break; 2119 } break;
2091 2120
2092 case 0x0012: { 2121 case 0x0012: {
2093 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */ 2122 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
2112 } 2141 }
2113 g_strfreev(text); 2142 g_strfreev(text);
2114 } 2143 }
2115 } break; 2144 } break;
2116 2145
2117 case 0x001a: { /* Someone has requested that you send them from ICQ contacts */ 2146 case 0x001a: { /* Someone has sent you a greeting card or requested contacts? */
2118 /* This is boring and silly. */ 2147 /* This is boring and silly. */
2119 } break; 2148 } break;
2120 2149
2121 default: { 2150 default: {
2122 debug_printf("Received a channel 4 message of unknown type (type 0x%04d).\n", args->type); 2151 debug_printf("Received a channel 4 message of unknown type (type 0x%04d).\n", args->type);
2149 } break; 2178 } break;
2150 2179
2151 case 4: { /* ICQ */ 2180 case 4: { /* ICQ */
2152 struct aim_incomingim_ch4_args *args; 2181 struct aim_incomingim_ch4_args *args;
2153 args = va_arg(ap, struct aim_incomingim_ch4_args *); 2182 args = va_arg(ap, struct aim_incomingim_ch4_args *);
2154 ret = incomingim_chan4(sess, fr->conn, userinfo, args); 2183 ret = incomingim_chan4(sess, fr->conn, userinfo, args, 0);
2155 } break; 2184 } break;
2156 2185
2157 default: { 2186 default: {
2158 debug_printf("ICBM received on unsupported channel (channel 0x%04d).", channel); 2187 debug_printf("ICBM received on unsupported channel (channel 0x%04d).", channel);
2159 } break; 2188 } break;
3140 } 3169 }
3141 3170
3142 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) { 3171 static int gaim_offlinemsg(aim_session_t *sess, aim_frame_t *fr, ...) {
3143 va_list ap; 3172 va_list ap;
3144 struct aim_icq_offlinemsg *msg; 3173 struct aim_icq_offlinemsg *msg;
3145 struct gaim_connection *gc = sess->aux_data; 3174 struct aim_incomingim_ch4_args args;
3175 time_t t;
3146 3176
3147 va_start(ap, fr); 3177 va_start(ap, fr);
3148 msg = va_arg(ap, struct aim_icq_offlinemsg *); 3178 msg = va_arg(ap, struct aim_icq_offlinemsg *);
3149 va_end(ap); 3179 va_end(ap);
3150 3180
3151 debug_printf("Received offline message of type 0x%04x\n", msg->type); 3181 debug_printf("Received offline message. Converting to channel 4 ICBM...\n");
3152 3182 args.uin = msg->sender;
3153 switch (msg->type) { 3183 args.type = msg->type;
3154 case 0x0001: { /* Basic offline message */ 3184 args.msg = msg->msg;
3155 char sender[32]; 3185 t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
3156 char *dialog_msg = g_strdup(msg->msg); 3186 incomingim_chan4(sess, fr->conn, NULL, &args, t);
3157 time_t t = get_time(msg->year, msg->month, msg->day, msg->hour, msg->minute, 0);
3158 g_snprintf(sender, sizeof(sender), "%lu", msg->sender);
3159 strip_linefeed(dialog_msg);
3160 serv_got_im(gc, sender, dialog_msg, 0, t, -1);
3161 g_free(dialog_msg);
3162 } break;
3163
3164 case 0x0006: { /* Authorization request */
3165 gaim_icq_authask(gc, msg->sender, msg->msg);
3166 } break;
3167
3168 case 0x0007: { /* Someone has denied you authorization */
3169 char *dialog_msg;
3170 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"), msg->sender, msg->msg ? msg->msg : _("No reason given."));
3171 do_error_dialog(_("ICQ Authorization denied"), dialog_msg, GAIM_ERROR);
3172 g_free(dialog_msg);
3173 } break;
3174
3175 case 0x0008: { /* Someone has granted you authorization */
3176 char *dialog_msg;
3177 dialog_msg = g_strdup_printf(_("The user %lu has granted your request to add them to your contact list."), msg->sender);
3178 do_error_dialog(_("ICQ Authorization Granted"), dialog_msg, GAIM_INFO);
3179 g_free(dialog_msg);
3180 } break;
3181
3182 case 0x0012: {
3183 /* Ack for authorizing/denying someone. Or possibly an ack for sending any system notice */
3184 } break;
3185
3186 default: {
3187 debug_printf("unknown offline message type 0x%04x\n", msg->type);
3188 }
3189 }
3190 3187
3191 return 1; 3188 return 1;
3192 } 3189 }
3193 3190
3194 static int gaim_offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...) 3191 static int gaim_offlinemsgdone(aim_session_t *sess, aim_frame_t *fr, ...)