changeset 7285:a50eea7628cb

[gaim-migrate @ 7866] -Renamed some old functions to aim_buddylist_bleh to fit in with some of the other stuff. -Removed AIM_SESS_FLAGS_bleh and replaced sess->flags with sess->nonblocking -Made the oscar.c libfaim printf handler use a dynamic buffer instead of static committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 16 Oct 2003 22:21:55 +0000
parents 9152f58ab5ee
children 0b961945c8ae
files src/protocols/oscar/aim.h src/protocols/oscar/buddylist.c src/protocols/oscar/conn.c src/protocols/oscar/oscar.c
diffstat 4 files changed, 36 insertions(+), 40 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/oscar/aim.h	Thu Oct 16 22:19:33 2003 +0000
+++ b/src/protocols/oscar/aim.h	Thu Oct 16 22:21:55 2003 +0000
@@ -79,6 +79,10 @@
 #define TRUE (!FALSE)
 #endif
 
+#ifndef bool
+#define bool fu8_t
+#endif
+
 /* 
  * Current Maximum Length for Screen Names (not including NULL) 
  *
@@ -374,10 +378,6 @@
 	struct aim_msgcookie_s *next;
 } aim_msgcookie_t;
 
-/* Values for sess->flags */
-#define AIM_SESS_FLAGS_NONBLOCKCONNECT   0x00000004
-#define AIM_SESS_FLAGS_DONTTIMEOUTONICBM 0x00000008
-
 /*
  * AIM Session: The main client-data interface.  
  *
@@ -433,7 +433,7 @@
 		char password[128];
 	} socksproxy;
 
-	fu32_t flags; /* AIM_SESS_FLAGS_ */
+	bool nonblocking;
 
 	int debug;
 	void (*debugcb)(struct aim_session_s *sess, int level, const char *format, va_list va); /* same as faim_debugging_callback_t */
@@ -583,7 +583,7 @@
 
 typedef void (*faim_debugging_callback_t)(aim_session_t *sess, int level, const char *format, va_list va);
 faim_export int aim_setdebuggingcb(aim_session_t *sess, faim_debugging_callback_t);
-faim_export void aim_session_init(aim_session_t *, fu32_t flags, int debuglevel);
+faim_export void aim_session_init(aim_session_t *, bool nonblocking, int debuglevel);
 faim_export void aim_session_kill(aim_session_t *);
 faim_export void aim_setupproxy(aim_session_t *sess, const char *server, const char *username, const char *password);
 faim_export aim_conn_t *aim_getconn_type(aim_session_t *, int type);
@@ -592,7 +592,7 @@
 
 
 
-/* service.c */
+/* 0x0001 - service.c */
 faim_export int aim_srv_setavailmsg(aim_session_t *sess, char *msg);
 
 
@@ -614,13 +614,11 @@
 faim_export int aim_flap_nop(aim_session_t *sess, aim_conn_t *conn);
 faim_export int aim_bos_setidle(aim_session_t *, aim_conn_t *, fu32_t);
 faim_export int aim_bos_changevisibility(aim_session_t *, aim_conn_t *, int, const char *);
-faim_export int aim_bos_setbuddylist(aim_session_t *, aim_conn_t *, const char *);
 faim_export int aim_bos_setgroupperm(aim_session_t *, aim_conn_t *, fu32_t mask);
 faim_export int aim_bos_setprivacyflags(aim_session_t *, aim_conn_t *, fu32_t);
 faim_export int aim_reqpersonalinfo(aim_session_t *, aim_conn_t *);
 faim_export int aim_reqservice(aim_session_t *, aim_conn_t *, fu16_t);
 faim_export int aim_bos_reqrights(aim_session_t *, aim_conn_t *);
-faim_export int aim_bos_reqbuddyrights(aim_session_t *, aim_conn_t *);
 faim_export int aim_setextstatus(aim_session_t *sess, fu32_t status);
 
 #define AIM_CLIENTTYPE_UNKNOWN  0x0000
@@ -1082,10 +1080,12 @@
 
 
 /* 0x0003 - buddylist.c */
-/* 0x0004 */ faim_export int aim_add_buddy(aim_session_t *, aim_conn_t *, const char *);
-/* 0x0005 */ faim_export int aim_remove_buddy(aim_session_t *, aim_conn_t *, const char *);
-/* 0x000b */ faim_export int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info);
-/* 0x000c */ faim_export int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn);
+/* 0x0002 */ faim_export int aim_buddylist_reqrights(aim_session_t *, aim_conn_t *);
+/* 0x0004 */ faim_export int aim_buddylist_set(aim_session_t *, aim_conn_t *, const char *);
+/* 0x0004 */ faim_export int aim_buddylist_addbuddy(aim_session_t *, aim_conn_t *, const char *);
+/* 0x0005 */ faim_export int aim_buddylist_removebuddy(aim_session_t *, aim_conn_t *, const char *);
+/* 0x000b */ faim_export int aim_buddylist_oncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info);
+/* 0x000c */ faim_export int aim_buddylist_offgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn);
 
 
 
--- a/src/protocols/oscar/buddylist.c	Thu Oct 16 22:19:33 2003 +0000
+++ b/src/protocols/oscar/buddylist.c	Thu Oct 16 22:21:55 2003 +0000
@@ -14,7 +14,7 @@
  * Request Buddy List rights.
  *
  */
-faim_export int aim_bos_reqbuddyrights(aim_session_t *sess, aim_conn_t *conn)
+faim_export int aim_buddylist_reqrights(aim_session_t *sess, aim_conn_t *conn)
 {
 	return aim_genericreq_n_snacid(sess, conn, 0x0003, 0x0002);
 }
@@ -73,7 +73,7 @@
  * XXX This should just be an extension of setbuddylist()
  *
  */
-faim_export int aim_add_buddy(aim_session_t *sess, aim_conn_t *conn, const char *sn)
+faim_export int aim_buddylist_addbuddy(aim_session_t *sess, aim_conn_t *conn, const char *sn)
 {
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
@@ -105,7 +105,7 @@
  * XXX Clean this up.  
  *
  */
-faim_export int aim_bos_setbuddylist(aim_session_t *sess, aim_conn_t *conn, const char *buddy_list)
+faim_export int aim_buddylist_set(aim_session_t *sess, aim_conn_t *conn, const char *buddy_list)
 {
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
@@ -153,7 +153,7 @@
  * the same as setbuddylist() but with a different snac subtype).
  *
  */
-faim_export int aim_remove_buddy(aim_session_t *sess, aim_conn_t *conn, const char *sn)
+faim_export int aim_buddylist_removebuddy(aim_session_t *sess, aim_conn_t *conn, const char *sn)
 {
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
@@ -181,7 +181,7 @@
  * XXX Why would we send this?
  *
  */
-faim_export int aim_sendbuddyoncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info)
+faim_export int aim_buddylist_oncoming(aim_session_t *sess, aim_conn_t *conn, aim_userinfo_t *info)
 {
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
@@ -208,7 +208,7 @@
  * XXX Why would we send this?
  *
  */
-faim_export int aim_sendbuddyoffgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn)
+faim_export int aim_buddylist_offgoing(aim_session_t *sess, aim_conn_t *conn, const char *sn)
 {
 	aim_frame_t *fr;
 	aim_snacid_t snacid;
--- a/src/protocols/oscar/conn.c	Thu Oct 16 22:19:33 2003 +0000
+++ b/src/protocols/oscar/conn.c	Thu Oct 16 22:21:55 2003 +0000
@@ -532,11 +532,11 @@
 
 		fd = socket(hp->h_addrtype, SOCK_STREAM, 0);
 
-		if (sess->flags & AIM_SESS_FLAGS_NONBLOCKCONNECT)
+		if (sess->nonblocking)
 			fcntl(fd, F_SETFL, O_NONBLOCK); /* XXX save flags */
 
 		if (connect(fd, (struct sockaddr *)&sa, sizeof(struct sockaddr_in)) < 0) {
-			if (sess->flags & AIM_SESS_FLAGS_NONBLOCKCONNECT) {
+			if (sess->nonblocking) {
 				if ((errno == EINPROGRESS) || (errno == EINTR)) {
 					if (statusret)
 						*statusret |= AIM_CONN_STATUS_INPROGRESS;
@@ -856,10 +856,10 @@
  * stuff in the aim_session_t struct.
  *
  * @param sess Session to initialize.
- * @param flags Flags to use. nAny of %AIM_SESS_FLAGS %OR'd together.
+ * @param nonblocking Set to true if you want connections to be non-blocking.
  * @param debuglevel Level of debugging output (zero is least).
  */
-faim_export void aim_session_init(aim_session_t *sess, fu32_t flags, int debuglevel)
+faim_export void aim_session_init(aim_session_t *sess, bool nonblocking, int debuglevel)
 {
 
 	if (!sess)
@@ -879,7 +879,7 @@
 	sess->locate.waiting_for_response = FALSE;
 	sess->snacid_next = 0x00000001;
 
-	sess->flags = 0;
+	sess->nonblocking = nonblocking;
 	sess->debug = debuglevel;
 	sess->debugcb = defaultdebugcb;
 
@@ -895,8 +895,6 @@
 
 	sess->authinfo = NULL;
 
-	sess->flags |= flags;
-
 	/*
 	 * This must always be set.  Default to the queue-based
 	 * version for back-compatibility.  
--- a/src/protocols/oscar/oscar.c	Thu Oct 16 22:19:33 2003 +0000
+++ b/src/protocols/oscar/oscar.c	Thu Oct 16 22:21:55 2003 +0000
@@ -494,7 +494,6 @@
 	OscarData *od;
 
 	if (!gc) {
-		/* gc is null. we return, else we seg SIGSEG on next line. */
 		gaim_debug(GAIM_DEBUG_INFO, "oscar",
 				   "oscar callback for closed connection (1).\n");
 		return;
@@ -601,17 +600,15 @@
 }
 
 static void oscar_debug(aim_session_t *sess, int level, const char *format, va_list va) {
-	char *s = g_strdup_vprintf(format, va);
-	char buf[256];
-	char *t;
 	GaimConnection *gc = sess->aux_data;
-
-	g_snprintf(buf, sizeof(buf), "%s %d: ", gaim_account_get_username(gaim_connection_get_account(gc)), level);
-	t = g_strconcat(buf, s, NULL);
-	gaim_debug(GAIM_DEBUG_INFO, "oscar", t);
-	if (t[strlen(t)-1] != '\n')
+	gchar *s = g_strdup_vprintf(format, va);
+	gchar *buf;
+
+	buf = g_strdup_printf("%s %d: %s", gaim_account_get_username(gaim_connection_get_account(gc)), level, s);
+	gaim_debug(GAIM_DEBUG_INFO, "oscar", buf);
+	if (buf[strlen(buf)-1] != '\n')
 		gaim_debug(GAIM_DEBUG_INFO, NULL, "\n");
-	g_free(t);
+	g_free(buf);
 	g_free(s);
 }
 
@@ -663,7 +660,7 @@
 	od->buddyinfo = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, oscar_free_buddyinfo);
 
 	sess = g_new0(aim_session_t, 1);
-	aim_session_init(sess, AIM_SESS_FLAGS_NONBLOCKCONNECT, 0);
+	aim_session_init(sess, TRUE, 0);
 	aim_setdebuggingcb(sess, oscar_debug);
 	/*
 	 * We need an immediate queue because we don't use a while-loop 
@@ -1178,6 +1175,7 @@
 	return 1;
 }
 
+/* XXX - Should use gaim_url_fetch for the below stuff */
 struct pieceofcrap {
 	GaimConnection *gc;
 	unsigned long offset;
@@ -3680,7 +3678,7 @@
 #endif
 
 	aim_locate_reqrights(sess);
-	aim_bos_reqbuddyrights(sess, fr->conn);
+	aim_buddylist_reqrights(sess, fr->conn);
 	aim_im_reqparams(sess);
 	aim_bos_reqrights(sess, fr->conn); /* XXX - Don't call this with ssi? */
 
@@ -4614,13 +4612,13 @@
 	int n=0;
 	while (buddies) {
 		if (n > MSG_LEN - 18) {
-			aim_bos_setbuddylist(od->sess, od->conn, buf);
+			aim_buddylist_set(od->sess, od->conn, buf);
 			n = 0;
 		}
 		n += g_snprintf(buf + n, sizeof(buf) - n, "%s&", (char *)buddies->data);
 		buddies = buddies->next;
 	}
-	aim_bos_setbuddylist(od->sess, od->conn, buf);
+	aim_buddylist_set(od->sess, od->conn, buf);
 #else
 	if (od->sess->ssi.received_data) {
 		while (buddies) {