diff src/protocols/oscar/im.c @ 8982:a4fd6666bb83

[gaim-migrate @ 9757] Some Direct IM fixes. 1. Let's send our correct ip. We were usually sending localhost, so the other side would try to connect to localhost and immediately fail and so say, hey! I can't connect to you! Connect to me instead! 2. Add some gaim_conversation_writes to keep the user more informed as to what's going on. This changes the libfaim API. libfaim users take note. I removed the util get local ip function, and made the function that used to use it take an ip as an argument instead, so that oscar.c could just call gaim's function, which works better. I also made it possible to specify a cookie to use, because I think I'll need that later. Probably. committer: Tailor Script <tailor@pidgin.im>
author Tim Ringenbach <marv@pidgin.im>
date Thu, 20 May 2004 00:14:14 +0000
parents 8e69a730885c
children 41b97d72e647
line wrap: on
line diff
--- a/src/protocols/oscar/im.c	Thu May 20 00:07:15 2004 +0000
+++ b/src/protocols/oscar/im.c	Thu May 20 00:14:14 2004 +0000
@@ -680,7 +680,7 @@
  * Subtype 0x0006 - Send an "I want to directly connect to you" message
  *
  */
-faim_export int aim_im_sendch2_odcrequest(aim_session_t *sess, fu8_t *cookie, const char *sn, const fu8_t *ip, fu16_t port)
+faim_export int aim_im_sendch2_odcrequest(aim_session_t *sess, fu8_t *cookie, bool usecookie, const char *sn, const fu8_t *ip, fu16_t port)
 {
 	aim_conn_t *conn;
 	aim_frame_t *fr;
@@ -709,11 +709,15 @@
 	 * XXX - have I mentioned these should be generated in msgcookie.c?
 	 *
 	 */
-	for (i = 0; i < 7; i++)
-	       	ck[i] = 0x30 + ((fu8_t) rand() % 10);
+
+	if (cookie && usecookie) /* allow user-specified cookie */
+		memcpy(ck, cookie, 8);
+	else
+		for (i = 0; i < 7; i++)
+			ck[i] = 0x30 + ((fu8_t) rand() % 10);
 	ck[7] = '\0';
 
-	if (cookie)
+	if (cookie && !usecookie)
 		memcpy(cookie, ck, 8);
 
 	/* ICBM header */