changeset 29854:a0fb6798d87c

Made it compile again. Changed aim_info.flag to guint64, to avoid loss of precition, I hope this won't break it... Re-introduced a couple of UI callbacks lost in earlier merges
author Marcus Lundblad <ml@update.uu.se>
date Sun, 07 Feb 2010 21:11:56 +0000
parents c3b735f8f490
children 3370fc087d6c
files libpurple/protocols/gg/gg.c libpurple/protocols/jabber/libxmpp.c libpurple/protocols/oscar/family_buddy.c libpurple/protocols/oscar/family_icbm.c libpurple/protocols/oscar/family_locate.c libpurple/protocols/oscar/libicq.c libpurple/protocols/oscar/oscar.c libpurple/protocols/oscar/oscar.h libpurple/request.h pidgin/gtkblist.c
diffstat 10 files changed, 133 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/gg/gg.c	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/protocols/gg/gg.c	Sun Feb 07 21:11:56 2010 +0000
@@ -2465,7 +2465,8 @@
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	NULL,                           /* get_account_text_table */
 	NULL,                           /* initiate_media */
-	NULL                            /* can_do_media */
+	NULL,                            /* can_do_media */
+	NULL 				/* get_moods */
 };
 
 static PurplePluginInfo info = {
--- a/libpurple/protocols/jabber/libxmpp.c	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/protocols/jabber/libxmpp.c	Sun Feb 07 21:11:56 2010 +0000
@@ -126,6 +126,7 @@
 	NULL, /* get_account_text_table */
 	jabber_initiate_media,          /* initiate_media */
 	jabber_get_media_caps,                  /* get_media_caps */
+	NULL  							/* get_moods */
 };
 
 static gboolean load_plugin(PurplePlugin *plugin)
--- a/libpurple/protocols/oscar/family_buddy.c	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/protocols/oscar/family_buddy.c	Sun Feb 07 21:11:56 2010 +0000
@@ -224,13 +224,13 @@
 	if (snac->subtype == SNAC_SUBTYPE_BUDDY_ONCOMING &&
 	    userinfo.capabilities & OSCAR_CAPABILITY_XTRAZ) {
 		PurpleAccount *account = purple_connection_get_account(od->gc);
-		PurpleBuddy *buddy = purple_find_buddy(account, userinfo.sn);
+		PurpleBuddy *buddy = purple_find_buddy(account, userinfo.bn);
 
 		if (buddy) {
 			PurplePresence *presence = purple_buddy_get_presence(buddy);
 
 			if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOOD))
-				icq_im_xstatus_request(od, userinfo.sn);
+				icq_im_xstatus_request(od, userinfo.bn);
 		}
 	}
 	aim_info_free(&userinfo);
--- a/libpurple/protocols/oscar/family_icbm.c	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/protocols/oscar/family_icbm.c	Sun Feb 07 21:11:56 2010 +0000
@@ -2675,10 +2675,10 @@
 					}
  					purple_debug_misc("oscar", "X-Status reply: %s\n", (const char*)xml);
  					account = purple_connection_get_account(od->gc);
- 					buddy = purple_find_buddy(account, sn);
+ 					buddy = purple_find_buddy(account, bn);
  					presence = purple_buddy_get_presence(buddy);
  					status = purple_presence_get_active_status(presence);
- 					purple_prpl_got_user_status(account, sn,
+ 					purple_prpl_got_user_status(account, bn,
   					    purple_status_get_id(status), "message", xml, NULL);
 		   		} else {
 			 		purple_debug_misc("oscar", "X-Status: Can't get XML reply string\n");
--- a/libpurple/protocols/oscar/family_locate.c	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/protocols/oscar/family_locate.c	Sun Feb 07 21:11:56 2010 +0000
@@ -45,7 +45,7 @@
  * But, eh.
  */
 static const struct {
-	guint32 flag;
+	guint64 flag;
 	guint8 data[16];
 } aim_caps[] = {
 
@@ -928,11 +928,11 @@
 
 			mood = aim_receive_custom_icon(od, bs, length);
 			if (mood)
-				purple_prpl_got_user_status(account, outinfo->sn, "mood",
+				purple_prpl_got_user_status(account, outinfo->bn, "mood",
 						PURPLE_MOOD_NAME, mood,
 						NULL);
 			else
-				purple_prpl_got_user_status_deactive(account, outinfo->sn, "mood");
+				purple_prpl_got_user_status_deactive(account, outinfo->bn, "mood");
 
 		} else if (type == 0x000e) {
 			/*
@@ -1093,11 +1093,11 @@
 						g_free(icqmood);
 
 						if (mood)
-							purple_prpl_got_user_status(account, outinfo->sn, "mood",
+							purple_prpl_got_user_status(account, outinfo->bn, "mood",
 									PURPLE_MOOD_NAME, mood,
 									NULL);
 						else
-							purple_prpl_got_user_status_deactive(account, outinfo->sn, "mood");
+							purple_prpl_got_user_status_deactive(account, outinfo->bn, "mood");
 					} break;
 				}
 
@@ -1507,11 +1507,11 @@
 
 		mood = aim_receive_custom_icon(od, &cbs, tlv->length);
 		if (mood)
-			purple_prpl_got_user_status(account, userinfo->sn, "mood",
+			purple_prpl_got_user_status(account, userinfo->bn, "mood",
 					PURPLE_MOOD_NAME, mood,
 					NULL);
 		else
-			purple_prpl_got_user_status_deactive(account, userinfo->sn, "mood");
+			purple_prpl_got_user_status_deactive(account, userinfo->bn, "mood");
 	}
 	aim_tlvlist_free(tlvlist);
 
--- a/libpurple/protocols/oscar/libicq.c	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/protocols/oscar/libicq.c	Sun Feb 07 21:11:56 2010 +0000
@@ -108,7 +108,7 @@
 	sizeof(PurplePluginProtocolInfo),       /* struct_size */
 	icq_get_account_text_table, /* get_account_text_table */
 	NULL,					/* initiate_media */
-	NULL					/* can_do_media */
+	NULL,					/* can_do_media */
 	oscar_get_purple_moods, /* get_moods */
 };
 
--- a/libpurple/protocols/oscar/oscar.c	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Sun Feb 07 21:11:56 2010 +0000
@@ -232,7 +232,6 @@
 void oscar_set_info(PurpleConnection *gc, const char *info);
 static void oscar_set_info_and_status(PurpleAccount *account, gboolean setinfo, const char *rawinfo, gboolean setstatus, PurpleStatus *status);
 static void oscar_set_extendedstatus(PurpleConnection *gc);
-static void oscar_format_username(PurpleConnection *gc, const char *nick);
 static gboolean purple_ssi_rerequestdata(gpointer data);
 
 static void oscar_free_name_data(struct name_data *data) {
@@ -680,7 +679,7 @@
 {
 	GString *str;
 	const gchar *tmp;
-	guint bit = 1;
+	guint64 bit = 1;
 
 	str = g_string_new("");
 
@@ -801,7 +800,7 @@
 	else if (state & AIM_ICQ_STATE_DEPRESSION)
 		return g_strdup(_("Depression"));
 	else if (state & AIM_ICQ_STATE_ATHOME)
-		return g_strdup_(_("At home"));
+		return g_strdup(_("At home"));
 	else if (state & AIM_ICQ_STATE_ATWORK)
 		return g_strdup(_("At work"));
 	else if (state & AIM_ICQ_STATE_LUNCH)
@@ -2730,18 +2729,18 @@
 		purple_debug_info("oscar", "Sending X-Status Reply\n");
 
 		if(args->info.rtfmsg.msgtype == 26)
-			icq_relay_xstatus(od, userinfo->sn, args->cookie);
+			icq_relay_xstatus(od, userinfo->bn, args->cookie);
 		
 		if(args->info.rtfmsg.msgtype == 1)
 		{
 			if(rtfmsg)
 			{
-				serv_got_im(gc, userinfo->sn, rtfmsg, flags,
+				serv_got_im(gc, userinfo->bn, rtfmsg, flags,
 				            time(NULL));
 			}
 			else
 			{
-				serv_got_im(gc, userinfo->sn,
+				serv_got_im(gc, userinfo->bn,
 				            args->info.rtfmsg.rtfmsg, flags,
 				            time(NULL));
 			}
@@ -5164,10 +5163,12 @@
 	if (!purple_account_is_connected(account))
 		return;
 
+	pc = purple_account_get_connection(account);
+	od = purple_connection_get_protocol_data(pc);
+
 	/* There's no need to do the stuff below for mood updates. */
 	if (purple_status_type_get_primitive(purple_status_get_type(status)) == PURPLE_STATUS_MOOD) {
-		PurpleConnection *gc = purple_account_get_connection(account);
-		aim_locate_setcaps((OscarData *)gc->proto_data, purple_caps);
+		aim_locate_setcaps(od, purple_caps);
 		return;
 	}
 
@@ -6723,6 +6724,21 @@
 	icq_im_xstatus_request(gc->proto_data, purple_buddy_get_name(buddy));
 }
 
+static void
+oscar_get_aim_info_cb(PurpleBlistNode *node, gpointer ignore)
+{
+	PurpleBuddy *buddy;
+	PurpleConnection *gc;
+
+	g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
+
+	buddy = (PurpleBuddy *)node;
+	gc = purple_account_get_connection(purple_buddy_get_account(buddy));
+
+	aim_locate_getinfoshort(purple_connection_get_protocol_data(gc),
+			purple_buddy_get_name(buddy), 0x00000003);
+}
+
 static GList *
 oscar_buddy_menu(PurpleBuddy *buddy) {
 
--- a/libpurple/protocols/oscar/oscar.h	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.h	Sun Feb 07 21:11:56 2010 +0000
@@ -379,10 +379,8 @@
 	OSCAR_CAPABILITY_XTRAZ                = 0x40000000,
 	OSCAR_CAPABILITY_GENERICUNKNOWN       = 0x80000000,
 #warning Fix OSCAR_CAPABILITY_LAST situation
-#if 0
 	// TODO: We're out of bits.  Rework things that depend on this or remove some capability. (Or, ensure this is a 64-bit type.)
-	OSCAR_CAPABILITY_LAST                 = 0x100000000
-#endif
+	OSCAR_CAPABILITY_LAST                 = 0x100000000	
 } OscarCapability;
 
 /*
@@ -1158,7 +1156,6 @@
 void aim_info_free(aim_userinfo_t *);
 int aim_info_extract(OscarData *od, ByteStream *bs, aim_userinfo_t *);
 int aim_putuserinfo(ByteStream *bs, aim_userinfo_t *info);
-#endif
 PurpleMood* icq_get_purple_moods(PurpleAccount *account);
 const char* icq_get_custom_icon_description(const char *mood);
 guint8* icq_get_custom_icon_data(const char *mood);
@@ -1491,7 +1488,7 @@
 int aim_tlvlist_add_16(GSList **list, const guint16 type, const guint16 value);
 int aim_tlvlist_add_32(GSList **list, const guint16 type, const guint32 value);
 int aim_tlvlist_add_str(GSList **list, const guint16 type, const char *value);
-int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint32 caps);
+int aim_tlvlist_add_caps(GSList **list, const guint16 type, const guint32 caps, const char *mood);
 int aim_tlvlist_add_userinfo(GSList **list, guint16 type, aim_userinfo_t *userinfo);
 int aim_tlvlist_add_chatroom(GSList **list, guint16 type, guint16 exchange, const char *roomname, guint16 instance);
 int aim_tlvlist_add_frozentlvlist(GSList **list, guint16 type, GSList **tl);
--- a/libpurple/request.h	Sun Feb 07 19:40:49 2010 +0000
+++ b/libpurple/request.h	Sun Feb 07 21:11:56 2010 +0000
@@ -948,7 +948,6 @@
 void *purple_request_field_list_get_data(const PurpleRequestField *field,
 									   const char *text);
 
-#if !(defined PURPLE_DISABLE_DEPRECATED) || (defined _PURPLE_REQUEST_C_)
 /**
  * Adds an item to a list field.
  *
@@ -960,7 +959,6 @@
  */
 void purple_request_field_list_add(PurpleRequestField *field,
 								 const char *item, void *data);
-#endif
 
 /**
  * Adds an item to a list field.
--- a/pidgin/gtkblist.c	Sun Feb 07 19:40:49 2010 +0000
+++ b/pidgin/gtkblist.c	Sun Feb 07 21:11:56 2010 +0000
@@ -3830,7 +3830,7 @@
 	PurplePluginProtocolInfo *prpl_info;
 	const char *name = NULL;
 	char *filename, *path;
-	PurplePresence *presence = NULL;
+	PurplePresence *p = NULL;
 	PurpleStatus *tune;
 
 	if(PURPLE_BLIST_NODE_IS_CONTACT(node)) {
@@ -3841,8 +3841,8 @@
 	} else if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
 		buddy = (PurpleBuddy*)node;
 		gtkbuddynode = node->ui_data;
-		presence = purple_buddy_get_presence(buddy);
-		if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOBILE)) {
+		p = purple_buddy_get_presence(buddy);
+		if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
 			/* This emblem comes from the small emoticon set now,
 			 * to reduce duplication. */
 			path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes",
@@ -3868,10 +3868,10 @@
 
 	/* If we came through the contact code flow above, we didn't need
 	 * to get the presence until now. */
-	if (presence == NULL)
-		presence = purple_buddy_get_presence(buddy);
-
-	if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOBILE)) {
+	if (p == NULL)
+		p = purple_buddy_get_presence(buddy);
+
+	if (purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOBILE)) {
 		/* This emblem comes from the small emoticon set now, to reduce duplication. */
 		path = g_build_filename(DATADIR, "pixmaps", "pidgin", "emotes", "small", "mobile.png", NULL);
 		return _pidgin_blist_get_cached_emblem(path);
@@ -3908,10 +3908,10 @@
 	if (name == NULL) {
 		PurpleStatus *status;
 
-		if (!purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_MOOD))
+		if (!purple_presence_is_status_primitive_active(p, PURPLE_STATUS_MOOD))
 			return NULL;
 
-		status = purple_presence_get_status(presence, "mood");
+		status = purple_presence_get_status(p, "mood");
 		name = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
 		
 		if (!(name && *name))
@@ -7949,6 +7949,88 @@
 	purple_account_set_enabled(account, PIDGIN_UI, FALSE);
 }
 
+static void
+edit_mood_cb(PurpleConnection *gc, PurpleRequestFields *fields)
+{
+	PurpleRequestField *f;
+	GList *l;
+
+	f = purple_request_fields_get_field(fields, "mood");
+	l = purple_request_field_list_get_selected(f);
+
+	if (l) {
+		const char *mood = purple_request_field_list_get_data(f, l->data);
+		PurpleAccount *account = purple_connection_get_account(gc);
+
+		if (mood != NULL) {
+			purple_account_set_status(account, "mood", TRUE,
+			                          PURPLE_MOOD_NAME, mood,
+			                          NULL);
+		} else {
+			purple_account_set_status(account, "mood", FALSE, NULL);
+		}
+	}
+}
+
+static void
+set_mood_cb(GtkWidget *widget, PurpleAccount *account)
+{
+	PurplePresence *presence = purple_account_get_presence(account);
+	PurpleStatus *status = purple_presence_get_status(presence, "mood");
+	const char *current_mood;
+	PurpleRequestFields *fields;
+	PurpleRequestFieldGroup *g;
+	PurpleRequestField *f;
+	char* na_fn;
+	PurpleConnection *gc = purple_account_get_connection(account);
+	PurplePluginProtocolInfo *prpl_info;
+	PurpleMood *mood;
+
+	g_return_if_fail(gc->prpl != NULL);
+	prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl);
+
+	current_mood = purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
+
+	fields = purple_request_fields_new();
+	g = purple_request_field_group_new(NULL);
+	f = purple_request_field_list_new("mood", _("Please select your mood from the list"));
+
+	na_fn = g_build_filename("pixmaps", "pidgin", "emblems", "16", "not-authorized.png", NULL);
+
+	purple_request_field_list_add_icon(f, _("None"), na_fn, NULL);
+	if (current_mood == NULL)
+		purple_request_field_list_add_selected(f, _("None"));
+
+	g_free(na_fn);
+
+	/* TODO: rlaager wants this sorted. */
+	for (mood = prpl_info->get_moods(account);
+	     mood->mood != NULL ; mood++) {
+		char *path;
+
+		if (mood->mood == NULL || mood->description == NULL)
+			continue;
+
+		path = get_mood_icon_path(mood->mood);
+		purple_request_field_list_add_icon(f, _(mood->description),
+				path, (gpointer)mood->mood);
+		g_free(path);
+
+		if (current_mood && !strcmp(current_mood, mood->mood))
+			purple_request_field_list_add_selected(f, _(mood->description));
+	}
+	purple_request_field_group_add_field(g, f);
+
+	purple_request_fields_add_group(fields, g);
+
+	purple_request_fields(gc, _("Edit User Mood"), _("Edit User Mood"),
+                              NULL, fields,
+                              _("OK"), G_CALLBACK(edit_mood_cb),
+                              _("Cancel"), NULL,
+                              purple_connection_get_account(gc),
+                              NULL, NULL, gc);
+}
+
 void
 pidgin_blist_update_accounts_menu(void)
 {
@@ -8028,7 +8110,7 @@
 		PurpleAccount *account = NULL;
 		GdkPixbuf *pixbuf = NULL;
 		PurplePlugin *plugin = NULL;
-		PurplePluginProtocolInfo *prpl_info
+		PurplePluginProtocolInfo *prpl_info;
 
 		account = accounts->data;