2 * @file jutil.h utility functions
6 * Purple is the legal property of its developers, whose names are too numerous
7 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 #ifndef PURPLE_JABBER_JUTIL_H
26 #define PURPLE_JABBER_JUTIL_H
35 JABBER_BUDDY_STATE_UNKNOWN
= -2,
36 JABBER_BUDDY_STATE_ERROR
= -1,
37 JABBER_BUDDY_STATE_UNAVAILABLE
= 0,
38 JABBER_BUDDY_STATE_ONLINE
,
39 JABBER_BUDDY_STATE_CHAT
,
40 JABBER_BUDDY_STATE_AWAY
,
41 JABBER_BUDDY_STATE_XA
,
42 JABBER_BUDDY_STATE_DND
47 JabberID
* jabber_id_new(const char *str
);
50 * Compare two JIDs for equality. In addition to the node and domain,
51 * the resources of the two JIDs must also be equal (or both absent).
53 gboolean
jabber_id_equal(const JabberID
*jid1
, const JabberID
*jid2
);
55 void jabber_id_free(JabberID
*jid
);
57 char *jabber_get_domain(const char *jid
);
58 char *jabber_get_resource(const char *jid
);
59 char *jabber_get_bare_jid(const char *jid
);
60 char *jabber_id_get_bare_jid(const JabberID
*jid
);
61 char *jabber_id_get_full_jid(const JabberID
*jid
);
62 JabberID
*jabber_id_to_bare_jid(const JabberID
*jid
);
64 gboolean
jabber_jid_is_domain(const char *jid
);
66 const char *jabber_normalize(const PurpleAccount
*account
, const char *in
);
68 /* Returns true if JID is the bare JID of our server. */
69 gboolean
jabber_is_own_server(JabberStream
*js
, const char *jid
);
71 /* Returns true if JID is the bare JID of our account. */
72 gboolean
jabber_is_own_account(JabberStream
*js
, const char *jid
);
74 gboolean
jabber_nodeprep_validate(const char *);
75 gboolean
jabber_domain_validate(const char *);
76 gboolean
jabber_resourceprep_validate(const char *);
79 * Apply the SASLprep profile of stringprep to the string passed in.
81 * @returns A newly allocated string containing the normalized version
82 * of the input, or NULL if an error occurred (the string could
85 char *jabber_saslprep(const char *);
87 /* state -> readable name */
88 const char *jabber_buddy_state_get_name(JabberBuddyState state
);
89 /* state -> core id */
90 const char *jabber_buddy_state_get_status_id(JabberBuddyState state
);
91 /* state -> show attr (for presence stanza) */
92 const char *jabber_buddy_state_get_show(JabberBuddyState state
);
93 /* core id -> state */
94 JabberBuddyState
jabber_buddy_status_id_get_state(const char *id
);
95 /* show attr (presence stanza) -> state */
96 JabberBuddyState
jabber_buddy_show_get_state(const char *id
);
98 #endif /* PURPLE_JABBER_JUTIL_H */