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
22 #include "thpresence.h"
26 void thrasher_set_presence (PurpleAccount
*pa
, PurpleStatusPrimitive primitive
, gchar
*message
)
28 /* Get the prpl-specific status_id (e.g. UNAVAILABLE may be "dnd"
29 * or "busy" or...). */
30 PurpleStatusType
*type
31 = purple_account_get_status_type_with_primitive(pa
,
34 /* Flip the status on if we have a status_id */
37 char *status_id
= purple_status_type_get_id(type
);
38 PurplePresence
*presence
= purple_presence_new_for_account(pa
);
39 PurpleStatus
*status
= purple_status_new(type
, presence
);
40 if (message
&& purple_status_get_attr_value(status
, "message"))
41 /* Don't add message if not supported by this status. */
42 purple_account_set_status(pa
, status_id
, TRUE
, "message", message
, NULL
);
44 purple_account_set_status(pa
, status_id
, TRUE
, NULL
);