changeset 312:3069be4c291e

[gaim-migrate @ 322] I don't know why I did this. I have homework due in 15 hours that I haven't started yet, and it's in a language I don't know and it's a project I don't understand. If my teacher knew about this, he would be pissed. He looks pissed all the time, even when he's not. When he smiles he looks devilish. Maybe I only think that because literally half the class flunked the midterm. I am not joking about that. More people got F's than A, B, and C combined. It's 2 am and the homework's due at 5 tomorrow so what do I do? Get chat to work. Wow. That's going to look good on my resume. "Why did you flunk this class?" "Because I was getting chat in Instant Messenger to work." Not that that's not something to be proud of, but I wonder which is more important to employers. The big battle, experience versus education. Just because you got good grades in college doesn't mean you're smarter than someone who flunked, it just means you put in the effort necessary to get a better grade and the other person didn't. Maybe the person who flunked was working on real honest-to-god actually *used* software, as opposed to some stupid tree that only gets used for a fringe branch of computer science that doesn't offer much more than a normal heap or binary search tree offers. Maybe the person was out there reverse-engineering protocols and allowing cross- platform communication to occur, creating interoperability and causing a greater demand not only for the product, but for the platform it runs on! Given the choices, who would you pick? Someone who was told how to code a tree and managed to get it to work, or someone who increases your userbase and marketability? Enough of my rant for a while. I've had waaaaay too much sugar (gummy candy is deadly). committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Fri, 02 Jun 2000 09:11:48 +0000
parents 0a8b4edc4732
children f6406aeb2691
files ChangeLog libfaim/CHANGES.gaim libfaim/README.gaim src/gaim.h src/oscar.c src/server.c
diffstat 6 files changed, 82 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Jun 02 06:08:29 2000 +0000
+++ b/ChangeLog	Fri Jun 02 09:11:48 2000 +0000
@@ -8,6 +8,7 @@
 	* More fixes for the change on the AOL sign-on process. 
 	* Fixed bug where GAIM sometimes doesn't find a font to use.
 	* Per-conversation font and color dialogs (thanks fflewddur)
+	* Chat in oscar works
 
 version 0.9.17 (05/31/2000):
 	* Automagic feature to check for new versions has been removed
--- a/libfaim/CHANGES.gaim	Fri Jun 02 06:08:29 2000 +0000
+++ b/libfaim/CHANGES.gaim	Fri Jun 02 09:11:48 2000 +0000
@@ -1,3 +1,10 @@
+
+Fri Jun  2 08:53:53 UTC 2000 EWarmenhoven
+	- Well, I got chat working again.
+	- Added struct chat_connection to keep track of file descriptors and
+	  input watchers.
+	- Added oscar_chats to keep track of chat_connection's.
+	- It still doesn't work well, nor all the time. But at least it works.
 
 Thu Jun  1 09:36:04 UTC 2000 EWarmenhoven
 	- The buddy list and permit/deny list get set before you finish signing
--- a/libfaim/README.gaim	Fri Jun 02 06:08:29 2000 +0000
+++ b/libfaim/README.gaim	Fri Jun 02 09:11:48 2000 +0000
@@ -45,6 +45,10 @@
 	to me anyway)
 Telling the server who's on your permit/deny lists
 Chat:
+ - joining rooms
+ - leaving rooms
+ - talking
+ - inviting someone
  - getting invited
  - refreshing the chatlist in the preferences dialog
 
@@ -52,10 +56,6 @@
 ==============================
 Warning users/getting warned
 Chat:
- - joining rooms
- - leaving rooms
- - talking
- - inviting someone
  - whispering (this will never happen)
 Getting/setting dir info
 Changing your password
@@ -66,9 +66,10 @@
 - Oscar doesn't do whispering in chat rooms any more (and hasn't for quite a
 while, evidently). So if you want to "whisper" to someone, just IM them.
 
-- Chat is really funny. I have no idea what's going on with it. I'm not sure I
-want to know. I'm not worried about it, I never use chat. It's not exactly high-
-priority.
+- Chat works, to a degree. I'm not sure that you can create rooms, but I think
+you can. I'm not sure that you can be in more than one room at once, but I
+think you can. I'm not sure that you can leave the chat room and still have
+gaim be stable, but I think you can.
 
 - The permit list sometimes has problems when you start gaim, but if you change
 to it in the middle of a session there don't seem to be any problems.
--- a/src/gaim.h	Fri Jun 02 06:08:29 2000 +0000
+++ b/src/gaim.h	Fri Jun 02 09:11:48 2000 +0000
@@ -213,6 +213,13 @@
         int exchange;
 };
 
+struct chat_connection {
+	char *name;
+	int fd; /* this is redundant since we have the conn below */
+	struct aim_conn_t *conn;
+	int inpa;
+};
+
 struct debug_window {
 	GtkWidget *window;
 	GtkWidget *entry;
@@ -341,7 +348,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 321 $"
+#define REVISION "gaim:$Revision: 322 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -364,6 +371,7 @@
 #ifdef USE_OSCAR
 extern struct aim_session_t *gaim_sess;
 extern struct aim_conn_t    *gaim_conn;
+extern GList *oscar_chats;
 #endif
 
 /* Globals in server.c */
@@ -565,7 +573,7 @@
 /* Functions in oscar.c */
 extern int oscar_login(char *, char *);
 extern void oscar_close();
-extern int oscar_send_im(char *, char *, int);
+extern struct chat_connection *find_oscar_chat(char *name);
 
 /* Functions in toc.c */
 extern void toc_close();
--- a/src/oscar.c	Fri Jun 02 06:08:29 2000 +0000
+++ b/src/oscar.c	Fri Jun 02 09:11:48 2000 +0000
@@ -43,9 +43,27 @@
 struct aim_conn_t    *gaim_conn;
 int gaim_caps = AIM_CAPS_CHAT | AIM_CAPS_SENDFILE | AIM_CAPS_GETFILE;
 
+GList *oscar_chats = NULL;
+
+struct chat_connection *find_oscar_chat(char *name) {
+	GList *g = oscar_chats;
+	struct chat_connection *c = NULL;
+
+	while (g) {
+		c = (struct chat_connection *)g->data;
+		if (!strcmp(name, c->name))
+			break;
+		g = g->next;
+		c = NULL;
+	}
+
+	return c;
+}
+
 static int gaim_parse_auth_resp  (struct aim_session_t *, struct command_rx_struct *, ...);
 static int gaim_auth_server_ready(struct aim_session_t *, struct command_rx_struct *, ...);
 static int gaim_server_ready     (struct aim_session_t *, struct command_rx_struct *, ...);
+static int gaim_chat_server_ready(struct aim_session_t *, struct command_rx_struct *, ...);
 static int gaim_handle_redirect  (struct aim_session_t *, struct command_rx_struct *, ...);
 static int gaim_parse_oncoming   (struct aim_session_t *, struct command_rx_struct *, ...);
 static int gaim_parse_offgoing   (struct aim_session_t *, struct command_rx_struct *, ...);
@@ -269,7 +287,6 @@
 
 int gaim_server_ready(struct aim_session_t *sess,
 		      struct command_rx_struct *command, ...) {
-	static int id = 1;
 	switch (command->conn->type) {
 	case AIM_CONN_TYPE_BOS:
 		aim_bos_reqrate(sess, command->conn);
@@ -287,17 +304,6 @@
 		aim_chatnav_clientready(sess, command->conn);
 		aim_chatnav_reqrights(sess, command->conn);
 		break;
-	case AIM_CONN_TYPE_CHAT:
-		debug_print("chat: got server ready\n");
-		aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0);
-		aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0);
-		aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0);
-		aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0);
-		aim_bos_reqrate(sess, command->conn);
-		aim_bos_ackrateresp(sess, command->conn);
-		aim_chat_clientready(sess, command->conn);
-		serv_got_joined_chat(id++, aim_chat_getname(command->conn));
-		break;
 	default: /* huh? */
 		sprintf(debug_buff, "server ready: got unexpected connection type %04x\n", command->conn->type);
 		debug_print(debug_buff);
@@ -306,6 +312,20 @@
 	return 1;
 }
 
+int gaim_chat_server_ready(struct aim_session_t *sess,
+			   struct command_rx_struct *command, ...) {
+	static int id = 1;
+	debug_print("chat: got server ready\n");
+	aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERJOIN, gaim_chat_join, 0);
+	aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_USERLEAVE, gaim_chat_leave, 0);
+	aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_ROOMINFOUPDATE, gaim_chat_info_update, 0);
+	aim_conn_addhandler(sess, command->conn, AIM_CB_FAM_CHT, AIM_CB_CHT_INCOMINGMSG, gaim_chat_incoming_msg, 0);
+	aim_bos_reqrate(sess, command->conn);
+	aim_bos_ackrateresp(sess, command->conn);
+	aim_chat_clientready(sess, command->conn);
+	serv_got_joined_chat(id++, aim_chat_getname(command->conn));
+}
+
 extern void gaim_setup();
 extern int  bud_list_cache_exists();
 extern void do_import(GtkWidget *w, void *dummy);
@@ -387,6 +407,7 @@
 		{
 		struct aim_conn_t *tstconn = aim_newconn(sess, AIM_CONN_TYPE_CHAT, ip);
 		char *roomname = va_arg(ap, char *);
+		struct chat_connection *ccon;
 		if (tstconn == NULL || tstconn->status >= AIM_CONN_STATUS_RESOLVERR) {
 			debug_print("unable to connect to chat server\n");
 			return 1;
@@ -394,8 +415,19 @@
 		sprintf(debug_buff, "Connected to chat room %s\n", roomname);
 		debug_print(debug_buff);
 
+		ccon = g_new0(struct chat_connection, 1);
+		ccon->conn = tstconn;
+		ccon->fd = tstconn->fd;
+		ccon->name = g_strdup(roomname);
+		
+		ccon->inpa = gdk_input_add(tstconn->fd,
+				GDK_INPUT_READ | GDK_INPUT_EXCEPTION,
+				oscar_callback, tstconn);
+
+		oscar_chats = g_list_append(oscar_chats, ccon);
+		
 		aim_chat_attachname(tstconn, roomname);
-		aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_server_ready, 0);
+		aim_conn_addhandler(sess, tstconn, 0x0001, 0x0003, gaim_chat_server_ready, 0);
 		aim_auth_sendcookie(sess, tstconn, cookie);
 		}
 		break;
@@ -632,6 +664,7 @@
 				i++;
 			}
 			}
+			aim_conn_close(command->conn);
 			break;
 		default:
 			va_end(ap);
--- a/src/server.c	Fri Jun 02 06:08:29 2000 +0000
+++ b/src/server.c	Fri Jun 02 09:11:48 2000 +0000
@@ -484,6 +484,8 @@
 #else
 	sprintf(debug_buff, "Attempting to join chat room %s.\n", name);
 	debug_print(debug_buff);
+	/* aim_bos_reqservice(gaim_sess, gaim_conn, AIM_CONN_TYPE_CHATNAV); */
+	aim_chatnav_createroom(gaim_sess, aim_getconn_type(gaim_sess, AIM_CONN_TYPE_CHATNAV), name, 0x0004);
 	aim_chat_join(gaim_sess, gaim_conn, 0x0004, name);
 #endif
 }
@@ -523,6 +525,7 @@
 #else
 	GList *bcs = buddy_chats;
 	struct buddy_chat *b = NULL;
+	struct chat_connection *c = NULL;
 
 	while (bcs) {
 		b = (struct buddy_chat *)bcs->data;
@@ -536,6 +539,13 @@
 		return;
 
 	aim_chat_leaveroom(gaim_sess, b->name);
+	c = find_oscar_chat(b->name);
+	if (c != NULL) {
+		oscar_chats = g_list_remove(oscar_chats, c);
+		gdk_input_remove(c->inpa);
+		g_free(c->name);
+		g_free(c);
+	}
 #endif
 }