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 PurplePresence
*presence
;
30 PurpleStatusType
*type
;
31 char *status_id
= NULL
;
33 /* Get the status_id so we can create a new type */
36 case PURPLE_STATUS_UNSET
:
37 /* See PURPLE_STATUS_EXTENDED_AWAY */
38 status_id
= g_strdup("away");
40 case PURPLE_STATUS_OFFLINE
:
41 status_id
= g_strdup("offline");
43 case PURPLE_STATUS_AVAILABLE
:
44 status_id
= g_strdup("available");
46 case PURPLE_STATUS_UNAVAILABLE
:
47 status_id
= g_strdup("unavailable");
49 case PURPLE_STATUS_INVISIBLE
:
50 /* Currently unsupported */
52 case PURPLE_STATUS_AWAY
:
53 status_id
= g_strdup("away");
55 case PURPLE_STATUS_EXTENDED_AWAY
:
56 /* We need to do the abstraction in Perl, but for now we're doing it painfully here... */
57 status_id
= g_strdup("away");
59 case PURPLE_STATUS_MOBILE
:
60 /* Currently unsupported */
62 case PURPLE_STATUS_TUNE
:
63 /* Currently unsupported */
65 case PURPLE_STATUS_NUM_PRIMITIVES
:
70 /* No reason to trip statuses if we don't have a status_id */
73 /* Create a new status */
75 type
= purple_status_type_new_with_attrs(primitive
, status_id
, status_id
,
76 TRUE
, TRUE
, TRUE
, "message",
78 purple_value_new(PURPLE_TYPE_STRING
),
81 type
= purple_status_type_new(primitive
, status_id
, status_id
, TRUE
);
83 /* Wrap these two calls together */
84 presence
= purple_presence_new_for_account(pa
);
85 status
= purple_status_new(type
, presence
);
87 /* Flip the status on */
89 purple_account_set_status(pa
, status_id
, TRUE
, "message", message
, NULL
);
91 purple_account_set_status(pa
, status_id
, TRUE
, NULL
);