comparison plugins/icq/tcpchathandle.c @ 1432:4c510ca3563f

[gaim-migrate @ 1442] icqlib 1.1.5 committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 28 Jan 2001 01:52:27 +0000
parents 0a766047b4fd
children 8ed70631ed15
comparison
equal deleted inserted replaced
1431:0137bacd63c8 1432:4c510ca3563f
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* 2 /*
3 $Id: tcpchathandle.c 1319 2000-12-19 10:08:29Z warmenhoven $ 3 $Id: tcpchathandle.c 1442 2001-01-28 01:52:27Z warmenhoven $
4 $Log$ 4 $Log$
5 Revision 1.2 2000/12/19 10:08:29 warmenhoven 5 Revision 1.3 2001/01/28 01:52:27 warmenhoven
6 Yay, new icqlib 6 icqlib 1.1.5
7
8 Revision 1.9 2001/01/17 01:29:17 bills
9 Rework chat and file session interfaces; implement socket notifications.
7 10
8 Revision 1.8 2000/07/24 03:10:08 bills 11 Revision 1.8 2000/07/24 03:10:08 bills
9 added support for real nickname during TCP transactions like file and 12 added support for real nickname during TCP transactions like file and
10 chat, instead of using Bill all the time (hmm, where'd I get that from? :) 13 chat, instead of using Bill all the time (hmm, where'd I get that from? :)
11 14
55 { 58 {
56 icq_TCPLink *pchatlink; 59 icq_TCPLink *pchatlink;
57 icq_ChatSession *pchat; 60 icq_ChatSession *pchat;
58 icq_Packet *p2; 61 icq_Packet *p2;
59 62
60 if(plink->icqlink->icq_RequestNotify) 63 invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink,
61 (*plink->icqlink->icq_RequestNotify)(plink->icqlink, p->id, ICQ_NOTIFY_ACK, 0, 0); 64 p->id, ICQ_NOTIFY_ACK, 0, NULL);
65
62 pchatlink=icq_TCPLinkNew(plink->icqlink); 66 pchatlink=icq_TCPLinkNew(plink->icqlink);
63 pchatlink->type=TCP_LINK_CHAT; 67 pchatlink->type=TCP_LINK_CHAT;
64 pchatlink->id=p->id; 68 pchatlink->id=p->id;
65 69
70 /* once the ack packet has been processed, create a new chat session */
66 pchat=icq_ChatSessionNew(plink->icqlink); 71 pchat=icq_ChatSessionNew(plink->icqlink);
72
67 pchat->id=p->id; 73 pchat->id=p->id;
68 pchat->remote_uin=plink->remote_uin; 74 pchat->remote_uin=plink->remote_uin;
75 pchat->tcplink=pchatlink;
76
77 invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink, p->id,
78 ICQ_NOTIFY_CHATSESSION, sizeof(icq_ChatSession), pchat);
79 invoke_callback(plink->icqlink, icq_RequestNotify)(plink->icqlink, p->id,
80 ICQ_NOTIFY_SUCCESS, 0, NULL);
81
69 icq_ChatSessionSetStatus(pchat, CHAT_STATUS_CONNECTING); 82 icq_ChatSessionSetStatus(pchat, CHAT_STATUS_CONNECTING);
70 icq_TCPLinkConnect(pchatlink, plink->remote_uin, port); 83 icq_TCPLinkConnect(pchatlink, plink->remote_uin, port);
71 84
72 pchatlink->session=pchat; 85 pchatlink->session=pchat;
73 86
121 * GUI is responsible for sending acknowledgement once user accepts 134 * GUI is responsible for sending acknowledgement once user accepts
122 * or denies using icq_TCPSendChatAck */ 135 * or denies using icq_TCPSendChatAck */
123 } 136 }
124 } 137 }
125 138
126 void icq_TCPChatUpdateFont(icq_TCPLink *plink, const char *font, WORD encoding, DWORD style, DWORD size) 139 void icq_TCPChatUpdateFont(icq_ChatSession *psession, const char *font,
127 { 140 WORD encoding, DWORD style, DWORD size)
141 {
142 ICQLINK *icqlink = psession->icqlink;
128 int packet_len, fontlen; 143 int packet_len, fontlen;
129 char *buffer; 144 char *buffer;
130 if(!plink->icqlink->icq_RequestNotify) 145
131 return; 146 buffer = malloc(packet_len = (2 + (fontlen = strlen(font) + 1)) +
132 buffer = malloc(packet_len = (2 + (fontlen = strlen(font) + 1)) + 2 + 1 + (4+1)*2); 147 2 + 1 + (4+1)*2);
133 buffer[0] = '\x11'; 148 buffer[0] = '\x11';
134 *((DWORD *)&buffer[1]) = style; 149 *((DWORD *)&buffer[1]) = style;
135 buffer[5] = '\x12'; 150 buffer[5] = '\x12';
136 *((DWORD *)&buffer[6]) = size; 151 *((DWORD *)&buffer[6]) = size;
137 buffer[10] = '\x10'; 152 buffer[10] = '\x10';
138 *((WORD *)&buffer[11]) = fontlen; 153 *((WORD *)&buffer[11]) = fontlen;
139 strcpy(&buffer[13], font); 154 strcpy(&buffer[13], font);
155
140 icq_RusConv("wk", &buffer[13]); 156 icq_RusConv("wk", &buffer[13]);
157
141 *((WORD *)&buffer[13 + fontlen]) = encoding; 158 *((WORD *)&buffer[13 + fontlen]) = encoding;
142 if(plink->icqlink->icq_RequestNotify) 159
143 (*plink->icqlink->icq_RequestNotify)(plink->icqlink, plink->id, ICQ_NOTIFY_CHATDATA, packet_len, buffer); 160 invoke_callback(icqlink, icq_ChatNotify)(psession, CHAT_NOTIFY_DATA,
161 packet_len, buffer);
162
144 free(buffer); 163 free(buffer);
145 } 164 }
146 165
147 void icq_TCPChatUpdateColors(icq_TCPLink *plink, DWORD foreground, DWORD background) 166 void icq_TCPChatUpdateColors(icq_ChatSession *psession, DWORD foreground,
148 { 167 DWORD background)
168 {
169 ICQLINK *icqlink = psession->icqlink;
149 char buffer[10]; 170 char buffer[10];
150 171
151 if(!plink->icqlink->icq_RequestNotify)
152 return;
153 buffer[0] = '\x00'; 172 buffer[0] = '\x00';
154 *((DWORD *)&buffer[1]) = foreground; 173 *((DWORD *)&buffer[1]) = foreground;
155 buffer[5] = '\x01'; 174 buffer[5] = '\x01';
156 *((DWORD *)&buffer[6]) = background; 175 *((DWORD *)&buffer[6]) = background;
157 if(plink->icqlink->icq_RequestNotify) 176
158 (*plink->icqlink->icq_RequestNotify)(plink->icqlink, plink->id, ICQ_NOTIFY_CHATDATA, 177 invoke_callback(icqlink, icq_ChatNotify)(psession,
159 sizeof(buffer), buffer); 178 CHAT_NOTIFY_DATA, sizeof(buffer), buffer);
160 } 179 }
161 180
162 void icq_TCPProcessChatPacket(icq_Packet *p, icq_TCPLink *plink) 181 void icq_TCPProcessChatPacket(icq_Packet *p, icq_TCPLink *plink)
163 { 182 {
164 DWORD code; 183 DWORD code;
202 fontstyle = icq_PacketRead32(p); 221 fontstyle = icq_PacketRead32(p);
203 font = icq_PacketReadString(p); 222 font = icq_PacketReadString(p);
204 encoding = icq_PacketRead16(p); 223 encoding = icq_PacketRead16(p);
205 } 224 }
206 if(font) 225 if(font)
207 icq_TCPChatUpdateFont(plink, font, encoding, fontstyle, fontsize); 226 icq_TCPChatUpdateFont(pchat, font, encoding, fontstyle, fontsize);
208 icq_ChatSessionSetStatus(pchat, CHAT_STATUS_READY); 227 icq_ChatSessionSetStatus(pchat, CHAT_STATUS_READY);
209 plink->mode|=TCP_LINK_MODE_RAW; 228 plink->mode|=TCP_LINK_MODE_RAW;
210 } 229 }
211 else 230 else
212 if(remote_uin>0xffffff00) 231 if(remote_uin>0xffffff00)
214 remote_uin=icq_PacketRead32(p); 233 remote_uin=icq_PacketRead32(p);
215 user = icq_PacketReadString(p); 234 user = icq_PacketReadString(p);
216 icq_PacketRead16(p); /* Unknown */; 235 icq_PacketRead16(p); /* Unknown */;
217 fg = icq_PacketRead32(p); 236 fg = icq_PacketRead32(p);
218 bg = icq_PacketRead32(p); 237 bg = icq_PacketRead32(p);
219 icq_TCPChatUpdateColors(plink, fg, bg); 238 icq_TCPChatUpdateColors(pchat, fg, bg);
220 239
221 presponse=icq_TCPCreateChatInfo2Packet(plink, plink->icqlink->icq_Nick, 240 presponse=icq_TCPCreateChatInfo2Packet(plink, plink->icqlink->icq_Nick,
222 0x00ffffff, 0x00000000); 241 0x00ffffff, 0x00000000);
223 icq_PacketSend(presponse, plink->socket); 242 icq_PacketSend(presponse, plink->socket);
224 icq_PacketDelete(presponse); 243 icq_PacketDelete(presponse);
227 else 246 else
228 { 247 {
229 user = icq_PacketReadString(p); 248 user = icq_PacketReadString(p);
230 fg = icq_PacketRead32(p); 249 fg = icq_PacketRead32(p);
231 bg = icq_PacketRead32(p); 250 bg = icq_PacketRead32(p);
232 icq_TCPChatUpdateColors(plink, fg, bg); 251 icq_TCPChatUpdateColors(pchat, fg, bg);
233 font = (char *)NULL; 252 font = (char *)NULL;
234 encoding = 0; 253 encoding = 0;
235 fontstyle = 0; 254 fontstyle = 0;
236 fontsize = 0; 255 fontsize = 0;
237 if((code = icq_PacketRead32(p)) == 0x00070004) 256 if((code = icq_PacketRead32(p)) == 0x00070004)
257 fontstyle = icq_PacketRead32(p); 276 fontstyle = icq_PacketRead32(p);
258 font = icq_PacketReadString(p); 277 font = icq_PacketReadString(p);
259 encoding = icq_PacketRead16(p); 278 encoding = icq_PacketRead16(p);
260 } 279 }
261 if(font) 280 if(font)
262 icq_TCPChatUpdateFont(plink, font, encoding, fontstyle, fontsize); 281 icq_TCPChatUpdateFont(pchat, font, encoding, fontstyle, fontsize);
263 presponse=icq_TCPCreateChatFontInfoPacket(plink); 282 presponse=icq_TCPCreateChatFontInfoPacket(plink);
264 icq_PacketSend(presponse, plink->socket); 283 icq_PacketSend(presponse, plink->socket);
265 icq_PacketDelete(presponse); 284 icq_PacketDelete(presponse);
266 /* notify app that chat connection has been established */ 285 /* notify app that chat connection has been established */
267 icq_ChatSessionSetStatus(pchat, CHAT_STATUS_READY); 286 icq_ChatSessionSetStatus(pchat, CHAT_STATUS_READY);