1
/* has-presence.c generated by valac 0.11.2.25-30b2-dirty, the Vala compiler
2
* generated from has-presence.vala, do not modify */
5
* Copyright (C) 2010 Collabora Ltd.
7
* This library is free software: you can redistribute it and/or modify
8
* it under the terms of the GNU Lesser General Public License as published by
9
* the Free Software Foundation, either version 2.1 of the License, or
10
* (at your option) any later version.
12
* This library is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public License
18
* along with this library. If not, see <http://www.gnu.org/licenses/>.
21
* Travis Reitter <travis.reitter@collabora.co.uk>
25
#include <glib-object.h>
30
#define FOLKS_TYPE_PRESENCE_TYPE (folks_presence_type_get_type ())
32
#define FOLKS_TYPE_HAS_PRESENCE (folks_has_presence_get_type ())
33
#define FOLKS_HAS_PRESENCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), FOLKS_TYPE_HAS_PRESENCE, FolksHasPresence))
34
#define FOLKS_IS_HAS_PRESENCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), FOLKS_TYPE_HAS_PRESENCE))
35
#define FOLKS_HAS_PRESENCE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), FOLKS_TYPE_HAS_PRESENCE, FolksHasPresenceIface))
37
typedef struct _FolksHasPresence FolksHasPresence;
38
typedef struct _FolksHasPresenceIface FolksHasPresenceIface;
41
FOLKS_PRESENCE_TYPE_UNSET,
42
FOLKS_PRESENCE_TYPE_OFFLINE,
43
FOLKS_PRESENCE_TYPE_AVAILABLE,
44
FOLKS_PRESENCE_TYPE_AWAY,
45
FOLKS_PRESENCE_TYPE_EXTENDED_AWAY,
46
FOLKS_PRESENCE_TYPE_HIDDEN,
47
FOLKS_PRESENCE_TYPE_BUSY,
48
FOLKS_PRESENCE_TYPE_UNKNOWN,
49
FOLKS_PRESENCE_TYPE_ERROR
52
struct _FolksHasPresenceIface {
53
GTypeInterface parent_iface;
54
FolksPresenceType (*get_presence_type) (FolksHasPresence* self);
55
void (*set_presence_type) (FolksHasPresence* self, FolksPresenceType value);
56
const gchar* (*get_presence_message) (FolksHasPresence* self);
57
void (*set_presence_message) (FolksHasPresence* self, const gchar* value);
62
GType folks_presence_type_get_type (void) G_GNUC_CONST;
63
GType folks_has_presence_get_type (void) G_GNUC_CONST;
64
static guint folks_has_presence_type_availability (FolksPresenceType type);
65
gint folks_has_presence_typecmp (FolksPresenceType type_a, FolksPresenceType type_b);
66
gboolean folks_has_presence_is_online (FolksHasPresence* self);
67
FolksPresenceType folks_has_presence_get_presence_type (FolksHasPresence* self);
68
void folks_has_presence_set_presence_type (FolksHasPresence* self, FolksPresenceType value);
69
const gchar* folks_has_presence_get_presence_message (FolksHasPresence* self);
70
void folks_has_presence_set_presence_message (FolksHasPresence* self, const gchar* value);
74
* The possible presence states an object implementing {@link HasPresence} could
77
* These closely follow the
78
* [[http://telepathy.freedesktop.org/spec/Connection_Interface_Simple_Presence.html#Connection_Presence_Type|SimplePresence]]
79
* interface in the Telepathy specification.
81
GType folks_presence_type_get_type (void) {
82
static volatile gsize folks_presence_type_type_id__volatile = 0;
83
if (g_once_init_enter (&folks_presence_type_type_id__volatile)) {
84
static const GEnumValue values[] = {{FOLKS_PRESENCE_TYPE_UNSET, "FOLKS_PRESENCE_TYPE_UNSET", "unset"}, {FOLKS_PRESENCE_TYPE_OFFLINE, "FOLKS_PRESENCE_TYPE_OFFLINE", "offline"}, {FOLKS_PRESENCE_TYPE_AVAILABLE, "FOLKS_PRESENCE_TYPE_AVAILABLE", "available"}, {FOLKS_PRESENCE_TYPE_AWAY, "FOLKS_PRESENCE_TYPE_AWAY", "away"}, {FOLKS_PRESENCE_TYPE_EXTENDED_AWAY, "FOLKS_PRESENCE_TYPE_EXTENDED_AWAY", "extended-away"}, {FOLKS_PRESENCE_TYPE_HIDDEN, "FOLKS_PRESENCE_TYPE_HIDDEN", "hidden"}, {FOLKS_PRESENCE_TYPE_BUSY, "FOLKS_PRESENCE_TYPE_BUSY", "busy"}, {FOLKS_PRESENCE_TYPE_UNKNOWN, "FOLKS_PRESENCE_TYPE_UNKNOWN", "unknown"}, {FOLKS_PRESENCE_TYPE_ERROR, "FOLKS_PRESENCE_TYPE_ERROR", "error"}, {0, NULL, NULL}};
85
GType folks_presence_type_type_id;
86
folks_presence_type_type_id = g_enum_register_static ("FolksPresenceType", values);
87
g_once_init_leave (&folks_presence_type_type_id__volatile, folks_presence_type_type_id);
89
return folks_presence_type_type_id__volatile;
93
static guint folks_has_presence_type_availability (FolksPresenceType type) {
96
case FOLKS_PRESENCE_TYPE_UNSET:
101
case FOLKS_PRESENCE_TYPE_UNKNOWN:
106
case FOLKS_PRESENCE_TYPE_ERROR:
111
case FOLKS_PRESENCE_TYPE_OFFLINE:
116
case FOLKS_PRESENCE_TYPE_HIDDEN:
121
case FOLKS_PRESENCE_TYPE_EXTENDED_AWAY:
126
case FOLKS_PRESENCE_TYPE_AWAY:
131
case FOLKS_PRESENCE_TYPE_BUSY:
136
case FOLKS_PRESENCE_TYPE_AVAILABLE:
151
* Compare two {@link PresenceType}s.
153
* `0` will be returned if the types are equal, a positive number will be
154
* returned if `type_a` is more available than `type_b`, and a negative
155
* number will be returned if the opposite is true.
157
* @param type_a the first {@link PresenceType} to compare
158
* @param type_b the second {@link PresenceType} to compare
159
* @return a number representing the similarity of the two types
162
gint folks_has_presence_typecmp (FolksPresenceType type_a, FolksPresenceType type_b) {
166
_tmp0_ = folks_has_presence_type_availability (type_a);
167
_tmp1_ = folks_has_presence_type_availability (type_b);
168
result = ((gint) _tmp0_) - ((gint) _tmp1_);
174
* Whether the contact is online.
176
* This will be `true` if the contact's presence type is higher than
177
* {@link PresenceType.OFFLINE}, as determined by {@link HasPresence.typecmp}.
179
* @return `true` if the contact is online, `false` otherwise
181
gboolean folks_has_presence_is_online (FolksHasPresence* self) {
182
gboolean result = FALSE;
183
FolksPresenceType _tmp0_;
185
_tmp0_ = folks_has_presence_get_presence_type (self);
186
_tmp1_ = folks_has_presence_typecmp (_tmp0_, FOLKS_PRESENCE_TYPE_OFFLINE);
192
FolksPresenceType folks_has_presence_get_presence_type (FolksHasPresence* self) {
193
return FOLKS_HAS_PRESENCE_GET_INTERFACE (self)->get_presence_type (self);
197
void folks_has_presence_set_presence_type (FolksHasPresence* self, FolksPresenceType value) {
198
FOLKS_HAS_PRESENCE_GET_INTERFACE (self)->set_presence_type (self, value);
202
const gchar* folks_has_presence_get_presence_message (FolksHasPresence* self) {
203
return FOLKS_HAS_PRESENCE_GET_INTERFACE (self)->get_presence_message (self);
207
void folks_has_presence_set_presence_message (FolksHasPresence* self, const gchar* value) {
208
FOLKS_HAS_PRESENCE_GET_INTERFACE (self)->set_presence_message (self, value);
212
static void folks_has_presence_base_init (FolksHasPresenceIface * iface) {
213
static gboolean initialized = FALSE;
217
* The contact's presence type.
219
* Each contact can have one and only one presence type at any one time,
220
* representing their availability for communication. The default presence
221
* type is {@link PresenceType.UNSET}.
223
g_object_interface_install_property (iface, g_param_spec_enum ("presence-type", "presence-type", "presence-type", FOLKS_TYPE_PRESENCE_TYPE, FOLKS_PRESENCE_TYPE_UNSET, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
225
* The contact's presence message.
227
* This is a short message written by the contact to add detail to their
228
* presence type ({@link Folks.HasPresence.presence_type}). If the contact
229
* hasn't set a message, it will be an empty string.
231
g_object_interface_install_property (iface, g_param_spec_string ("presence-message", "presence-message", "presence-message", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
237
* Interface exposing a {@link Persona}'s or {@link Individual}'s presence;
238
* their current availability, such as for chatting.
240
* If the {@link Backend} providing the {@link Persona} doesn't support
241
* presence, the {@link Persona}'s `presence_type` will be set to
242
* {@link PresenceType.UNSET} and their `presence_message` will be an empty
245
GType folks_has_presence_get_type (void) {
246
static volatile gsize folks_has_presence_type_id__volatile = 0;
247
if (g_once_init_enter (&folks_has_presence_type_id__volatile)) {
248
static const GTypeInfo g_define_type_info = { sizeof (FolksHasPresenceIface), (GBaseInitFunc) folks_has_presence_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
249
GType folks_has_presence_type_id;
250
folks_has_presence_type_id = g_type_register_static (G_TYPE_INTERFACE, "FolksHasPresence", &g_define_type_info, 0);
251
g_type_interface_add_prerequisite (folks_has_presence_type_id, G_TYPE_OBJECT);
252
g_once_init_leave (&folks_has_presence_type_id__volatile, folks_has_presence_type_id);
254
return folks_has_presence_type_id__volatile;