orangesquid (os) wrote,
orangesquid
os

wireless status display in pork aim client

pork (a console AIM client) has no built-in support for displaying whether a user is on a mobile device or not. This can get rather frustrating.
I wrote a patch against pork 0.99.6 (the version I was using.. I don't have a patch that works against 0.99.8.1, the latest version, yet) that will display a "flags:" line in the /whois (which shows the symbol []' to represent a box with an antenna) and will convert the first asterisk found in the TEXT_BUDDY_{ACTIVE,AWAY,IDLE} strings (used in displaying the buddy list) to a dash. It's crude and needs improvement, but it's very useful. (It was a quick hack!) Unified diff follows...

diff -ru pork-0.99.6.orig/src/pork_aim.c pork-0.99.6/src/pork_aim.c
--- pork-0.99.6.orig/src/pork_aim.c	2004-10-28 22:00:31.000000000 -0400
+++ pork-0.99.6/src/pork_aim.c	2010-10-19 21:16:31.766476552 -0400
@@ -160,6 +160,7 @@
 							u_int32_t idle_time,
 							u_int32_t online_since,
 							u_int32_t member_since,
+							fu16_t flags,
 							int print_all)
 {
 	char output[8192];
@@ -169,6 +170,24 @@
 		fill_format_str(OPT_FORMAT_WHOIS_NAME, output, sizeof(output),
 			user, warn_level, idle_time, online_since, member_since);
 		screen_win_msg(imwindow, 0, 0, 1, "%s", output);
+		snprintf(output, sizeof(output),
+			"flags: %s%s%s%s %s%s%s%s %s%s%s %s%s%s",
+			flags & AIM_FLAG_AOL ? "/o\\ " : "",
+			flags & AIM_FLAG_ICQ ? ">o< " : "",
+			flags & AIM_FLAG_OSCAR_PAY ? "$ " : "",
+			flags & AIM_FLAG_FREE ? "!$ " : "",
+			flags & AIM_FLAG_ALLUSERS ? "* " : "",
+			flags & AIM_FLAG_ADMINISTRATOR ? "# " : "",
+			flags & AIM_FLAG_UNCONFIRMED ? "!@ " : "",
+			flags & AIM_FLAG_ABINTERNAL ? "[:] " : "",
+			flags & AIM_FLAG_ACTIVEBUDDY ? "^_^ " : "",
+			flags & AIM_FLAG_AWAY ? ":-$ " : "",
+			flags & AIM_FLAG_WIRELESS ? "[]' " : "",
+			flags & AIM_FLAG_UNKNOWN100 ? "1? " : "",
+			flags & AIM_FLAG_UNKNOWN100 ? "2? " : "",
+			flags & AIM_FLAG_UNKNOWN100 ? "8? " : "");
+		output[sizeof(output) - 1] = '\0';
+		screen_win_msg(imwindow, 0, 0, 1, "%s", output);
 
 		if (idle_time > 0) {
 			fill_format_str(OPT_FORMAT_WHOIS_IDLE, output, sizeof(output),
@@ -1782,7 +1801,8 @@
 	}
 
 	aim_print_info(userinfo->sn, profile, away_msg, warn_level,
-		idle_time, online_since, member_since, print_all);
+		idle_time, online_since, member_since, userinfo->flags,
+		print_all);
 
 	free(away_msg);
 	free(profile);
@@ -2308,7 +2328,7 @@
 static int aim_whois(struct pork_acct *acct, char *buddy) {
 	struct aim_priv *priv = acct->data;
 
-	return (aim_locate_getinfoshort(&priv->aim_session, buddy, 0x00000003));
+	return (aim_locate_getinfoshort(&priv->aim_session, buddy, 0x0000000f));
 }
 
 static void aim_kill_pending_chats(struct pork_acct *acct) {
@@ -2662,6 +2682,11 @@
 {
 	aim_userinfo_t *userinfo = data;
 
+	buddy->wireless = !!(userinfo->flags & AIM_FLAG_WIRELESS);
+/* debug...
+	fprintf(stderr, "%s %d %d %d\n", userinfo->sn, userinfo->flags,
+		userinfo->flags & AIM_FLAG_WIRELESS, buddy->wireless);
+*/
 	buddy->signon_time = userinfo->onlinesince;
 	buddy->warn_level = (float) userinfo->warnlevel / 10;
 
diff -ru pork-0.99.6.orig/src/pork_buddy.c pork-0.99.6/src/pork_buddy.c
--- pork-0.99.6.orig/src/pork_buddy.c	2004-01-01 05:03:11.000000000 -0500
+++ pork-0.99.6/src/pork_buddy.c	2010-10-19 21:01:52.240476552 -0400
@@ -366,6 +366,7 @@
 	buddy->signon_time = 0;
 	buddy->idle_time = 0;
 	buddy->warn_level = 0;
+	buddy->wireless = 0; /* ... */
 	buddy->group->num_online--;
 
 	blist_del(acct->blist, buddy);
Only in pork-0.99.6/src: pork_buddy.c~
diff -ru pork-0.99.6.orig/src/pork_buddy.h pork-0.99.6/src/pork_buddy.h
--- pork-0.99.6.orig/src/pork_buddy.h	2004-01-01 05:03:11.000000000 -0500
+++ pork-0.99.6/src/pork_buddy.h	2010-10-19 21:00:50.424476552 -0400
@@ -51,6 +51,7 @@
 	u_int32_t notify:1;
 	u_int32_t ignore:1;
 	u_int32_t type:6;
+	u_int32_t wireless:1;
 	u_int32_t last_seen;
 	dlist_t *blist_line;
 };
diff -ru pork-0.99.6.orig/src/pork_format.c pork-0.99.6/src/pork_format.c
--- pork-0.99.6.orig/src/pork_format.c	2004-10-26 12:09:27.000000000 -0400
+++ pork-0.99.6/src/pork_format.c	2010-10-19 21:16:13.753476552 -0400
@@ -698,8 +698,17 @@
 				status_text = opt_get_str(OPT_TEXT_BUDDY_IDLE);
 			else
 				status_text = "%p?%x";
-
 			ret = xstrncpy(buf, status_text, len);
+			/* auto-convert one asterisk to a dash for wireless */
+			if(buddy->wireless) {
+				char *c;
+				for(c = buf ; *c ; ++c)
+					if(*c == '*') {
+						*c = '-';
+						break;
+					}
+			}
+
 			break;
 		}
 
diff -ru pork-0.99.6.orig/src/pork_set.h pork-0.99.6/src/pork_set.h
--- pork-0.99.6.orig/src/pork_set.h	2004-10-29 10:24:03.000000000 -0400
+++ pork-0.99.6/src/pork_set.h	2010-08-12 22:08:24.857000072 -0400
@@ -231,6 +231,19 @@
 
 #define OPT_FORMAT_OFFSET OPT_FORMAT_ACTION_RECV
 
+struct global_var {
+	char *name;
+	u_int32_t type:31;
+	u_int32_t dynamic:1;
+	int (*set)(u_int32_t, char *);
+	void (*updated)(void);
+	union {
+		u_int32_t i;
+		u_int32_t b;
+		char c;
+		char *s;
+	} val;
+};
 extern struct global_var global_var[OPT_NUM_OPTS];
 
 /*
@@ -253,19 +266,6 @@
 
 struct imwindow;
 
-struct global_var {
-	char *name;
-	u_int32_t type:31;
-	u_int32_t dynamic:1;
-	int (*set)(u_int32_t, char *);
-	void (*updated)(void);
-	union {
-		u_int32_t i;
-		u_int32_t b;
-		char c;
-		char *s;
-	} val;
-};
 
 struct window_opts {
 	union {

Tags: aim, patch, pork
Subscribe
  • Post a new comment

    Error

    default userpic

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 1 comment