thrasher_buddy_add_request: Alias may not be known yet.
[thrasher.git] / thpresence.c
blobbe5921e457b926a2f42f68d9c227b5acbf3856ab
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 PurplePresence *presence = purple_presence_new_for_account(pa);
40 PurpleStatus *status = purple_status_new(type, presence);
41 if (message && purple_status_get_attr_value(status, "message")) {
42 /* Don't add message if not supported by this status. */
43 purple_account_set_status(pa, status_id, TRUE, "message", message, NULL);
45 else
46 purple_account_set_status(pa, status_id, TRUE, NULL);