Incoming statuses with characters 0x80-0xFF were double-escaped.
[thrasher.git] / thpresence.c
blobf1e4cd7c95a7f94ffc96cd8b9c00e4a84a2470f0
1 /*
2 * Thrasher Bird - XMPP transport via libpurple
3 * Copyright (C) 2008 Barracuda Networks, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with Thrasher Bird; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
19 #include <glib.h>
20 #include "debug.h"
21 #include "status.h"
22 #include "account.h"
23 #include "thpresence.h"
27 void thrasher_set_presence (PurpleAccount *pa, PurpleStatusPrimitive primitive, gchar *message)
29 /* Get the prpl-specific status_id (e.g. UNAVAILABLE may be "dnd"
30 * or "busy" or...). */
31 PurpleStatusType *type
32 = purple_account_get_status_type_with_primitive(pa,
33 primitive);
35 /* Flip the status on if we have a status_id */
36 if (type)
38 const char *status_id = purple_status_type_get_id(type);
39 purple_debug_info("thrasher", "found status with ID: %s\n", status_id);
40 PurplePresence *presence = purple_presence_new_for_account(pa);
41 PurpleStatus *status = purple_status_new(type, presence);
42 if (message && purple_status_get_attr_value(status, "message")) {
43 /* Don't add message if not supported by this status. */
44 purple_account_set_status(pa, status_id, TRUE, "message", message, NULL);
46 else
47 purple_account_set_status(pa, status_id, TRUE, NULL);
49 else {
50 purple_debug_info("thrasher", "No status type found\n");