libpurple/purplepresence.c

Thu, 26 Oct 2023 21:36:07 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 26 Oct 2023 21:36:07 -0500
changeset 42432
59c8baad6549
parent 42310
eea341b0d614
child 42509
e96a15f7f0d8
permissions
-rw-r--r--

Add some missing since tags and other documentation for presences

Testing Done:
Talked to the turtles.

Reviewed at https://reviews.imfreedom.org/r/2735/

40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
1 /*
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
2 * purple
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
4 *
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
5 * Purple is the legal property of its developers, whose names are too numerous
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
7 * source distribution.
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
8 *
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
12 * (at your option) any later version.
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
13 *
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
17 * GNU General Public License for more details.
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
18 *
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
21 */
40441
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
22
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
23 #include <glib/gi18n-lib.h>
f23c7e772667 Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents: 40439
diff changeset
24
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
25 #include "purplepresence.h"
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
26
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
27 #include "debug.h"
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
28 #include "purpleenums.h"
40439
e9838d634d5e Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents: 40195
diff changeset
29 #include "purpleprivate.h"
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
30
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
31 typedef struct {
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
32 gboolean idle;
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
33 GDateTime *idle_time;
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
34 GDateTime *login_time;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
35
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
36 GHashTable *status_table;
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
37
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
38 PurpleStatus *active_status;
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
39
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
40 PurplePresencePrimitive primitive;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
41 char *message;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
42 char *emoji;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
43 gboolean mobile;
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
44 gboolean notifications_disabled;
39538
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
45 } PurplePresencePrivate;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
46
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
47 enum {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
48 PROP_0,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
49 PROP_IDLE,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
50 PROP_IDLE_TIME,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
51 PROP_LOGIN_TIME,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
52 PROP_ACTIVE_STATUS,
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
53 PROP_PRIMITIVE,
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
54 PROP_MESSAGE,
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
55 PROP_EMOJI,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
56 PROP_MOBILE,
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
57 PROP_NOTIFICATIONS_DISABLED,
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
58 N_PROPERTIES
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
59 };
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
60 static GParamSpec *properties[N_PROPERTIES];
39538
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
61
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
62 G_DEFINE_TYPE_WITH_PRIVATE(PurplePresence, purple_presence, G_TYPE_OBJECT)
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
63
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
64 /******************************************************************************
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
65 * Helpers
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
66 *****************************************************************************/
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
67 static void
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
68 purple_presence_set_active_status(PurplePresence *presence,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
69 PurpleStatus *status)
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
70 {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
71 PurplePresencePrivate *priv = NULL;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
72
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
73 priv = purple_presence_get_instance_private(presence);
39538
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
74
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
75 if(g_set_object(&priv->active_status, status)) {
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
76 GObject *obj = G_OBJECT(presence);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
77
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
78 g_object_freeze_notify(obj);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
79 g_object_notify_by_pspec(obj, properties[PROP_ACTIVE_STATUS]);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
80 g_object_notify_by_pspec(obj, properties[PROP_PRIMITIVE]);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
81 g_object_notify_by_pspec(obj, properties[PROP_MESSAGE]);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
82 g_object_thaw_notify(obj);
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
83 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
84 }
39539
f221f88ff0b0 Use G_DECLARE* for Purple*Presence types.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39538
diff changeset
85
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
86 /******************************************************************************
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
87 * GObject Implementation
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
88 *****************************************************************************/
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
89 static void
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
90 purple_presence_set_property(GObject *obj, guint param_id, const GValue *value,
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
91 GParamSpec *pspec)
34836
289bc0df25bb API changes for PurplePresence. See details.
Ankit Vani <a@nevitus.org>
parents: 34834
diff changeset
92 {
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
93 PurplePresence *presence = PURPLE_PRESENCE(obj);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
94
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
95 switch (param_id) {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
96 case PROP_IDLE:
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
97 purple_presence_set_idle(presence, g_value_get_boolean(value),
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
98 NULL);
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
99 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
100 case PROP_IDLE_TIME:
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
101 purple_presence_set_idle(presence, TRUE, g_value_get_boxed(value));
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
102 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
103 case PROP_LOGIN_TIME:
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
104 purple_presence_set_login_time(presence, g_value_get_boxed(value));
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
105 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
106 case PROP_ACTIVE_STATUS:
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
107 purple_presence_set_active_status(presence,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
108 g_value_get_object(value));
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
109 break;
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
110 case PROP_PRIMITIVE:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
111 purple_presence_set_primitive(presence, g_value_get_enum(value));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
112 break;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
113 case PROP_MESSAGE:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
114 purple_presence_set_message(presence, g_value_get_string(value));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
115 break;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
116 case PROP_EMOJI:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
117 purple_presence_set_emoji(presence, g_value_get_string(value));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
118 break;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
119 case PROP_MOBILE:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
120 purple_presence_set_mobile(presence, g_value_get_boolean(value));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
121 break;
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
122 case PROP_NOTIFICATIONS_DISABLED:
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
123 purple_presence_set_notifications_disabled(presence,
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
124 g_value_get_boolean(value));
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
125 break;
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
126 default:
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
127 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
128 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
129 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
130 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
131
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
132 static void
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
133 purple_presence_get_property(GObject *obj, guint param_id, GValue *value,
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
134 GParamSpec *pspec)
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
135 {
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
136 PurplePresence *presence = PURPLE_PRESENCE(obj);
39538
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
137
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
138 switch (param_id) {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
139 case PROP_IDLE:
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
140 g_value_set_boolean(value, purple_presence_is_idle(presence));
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
141 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
142 case PROP_IDLE_TIME:
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
143 g_value_set_boxed(value, purple_presence_get_idle_time(presence));
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
144 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
145 case PROP_LOGIN_TIME:
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
146 g_value_set_boxed(value, purple_presence_get_login_time(presence));
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
147 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
148 case PROP_ACTIVE_STATUS:
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
149 g_value_set_object(value, purple_presence_get_active_status(presence));
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
150 break;
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
151 case PROP_PRIMITIVE:
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
152 g_value_set_enum(value, purple_presence_get_primitive(presence));
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
153 break;
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
154 case PROP_MESSAGE:
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
155 g_value_set_string(value, purple_presence_get_message(presence));
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
156 break;
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
157 case PROP_EMOJI:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
158 g_value_set_string(value, purple_presence_get_emoji(presence));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
159 break;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
160 case PROP_MOBILE:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
161 g_value_set_boolean(value, purple_presence_get_mobile(presence));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
162 break;
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
163 case PROP_NOTIFICATIONS_DISABLED:
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
164 g_value_set_boolean(value,
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
165 purple_presence_get_notifications_disabled(presence));
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
166 break;
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
167 default:
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
168 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
169 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
170 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
171 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
172
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
173 static void
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
174 purple_presence_init(PurplePresence *presence) {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
175 PurplePresencePrivate *priv = NULL;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
176
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
177 priv = purple_presence_get_instance_private(presence);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
178
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
179 priv->status_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
180 NULL);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
181 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
182
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
183 static void
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
184 purple_presence_finalize(GObject *obj) {
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
185 PurplePresencePrivate *priv = NULL;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
186
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
187 priv = purple_presence_get_instance_private(PURPLE_PRESENCE(obj));
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
188
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
189 g_hash_table_destroy(priv->status_table);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
190 g_clear_object(&priv->active_status);
39539
f221f88ff0b0 Use G_DECLARE* for Purple*Presence types.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39538
diff changeset
191
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
192 g_clear_pointer(&priv->idle_time, g_date_time_unref);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
193 g_clear_pointer(&priv->login_time, g_date_time_unref);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
194
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
195 g_clear_pointer(&priv->message, g_free);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
196 g_clear_pointer(&priv->emoji, g_free);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
197
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
198 G_OBJECT_CLASS(purple_presence_parent_class)->finalize(obj);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
199 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
200
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
201 static void
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
202 purple_presence_class_init(PurplePresenceClass *klass) {
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
203 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
204
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
205 obj_class->get_property = purple_presence_get_property;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
206 obj_class->set_property = purple_presence_set_property;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
207 obj_class->finalize = purple_presence_finalize;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
208
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
209 /**
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
210 * PurplePresence:idle:
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
211 *
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
212 * Whether or not the presence is in an idle state.
42432
59c8baad6549 Add some missing since tags and other documentation for presences
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
213 *
59c8baad6549 Add some missing since tags and other documentation for presences
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
214 * Since: 3.0.0
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
215 */
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
216 properties[PROP_IDLE] = g_param_spec_boolean("idle", "Idle",
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
217 "Whether the presence is in idle state.", FALSE,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
218 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
219
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
220 /**
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
221 * PurplePresence:idle-time:
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
222 *
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
223 * The time when the presence went idle.
42432
59c8baad6549 Add some missing since tags and other documentation for presences
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
224 *
59c8baad6549 Add some missing since tags and other documentation for presences
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
225 * Since: 3.0.0
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
226 */
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
227 properties[PROP_IDLE_TIME] = g_param_spec_boxed(
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
228 "idle-time", "Idle time",
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
229 "The idle time of the presence",
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
230 G_TYPE_DATE_TIME,
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
231 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
35080
58bddd91956c libpurple: use g_object_notify_by_pspec instead of g_object_notify
Ankit Vani <a@nevitus.org>
parents: 35066
diff changeset
232
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
233 /**
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
234 * PurplePresence:login-time:
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
235 *
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
236 * The login-time of the presence.
42432
59c8baad6549 Add some missing since tags and other documentation for presences
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
237 *
59c8baad6549 Add some missing since tags and other documentation for presences
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
238 * Since: 3.0.0
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
239 */
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
240 properties[PROP_LOGIN_TIME] = g_param_spec_boxed(
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
241 "login-time", "Login time",
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
242 "The login time of the presence.",
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
243 G_TYPE_DATE_TIME,
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
244 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
39435
b30e04a71ecf Use G_DEFINE_TYPE_WITH_PRIVATE for Purple*Presence.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
245
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
246 /**
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
247 * PurplePresence:active-status:
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
248 *
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
249 * The currently active status of the presence.
42432
59c8baad6549 Add some missing since tags and other documentation for presences
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
250 *
59c8baad6549 Add some missing since tags and other documentation for presences
Gary Kramlich <grim@reaperworld.com>
parents: 42310
diff changeset
251 * Since: 3.0.0
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
252 */
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
253 properties[PROP_ACTIVE_STATUS] = g_param_spec_object("active-status",
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
254 "Active status",
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
255 "The active status for the presence.", PURPLE_TYPE_STATUS,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
256 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
257
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
258 /**
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
259 * PurplePresence:primitive:
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
260 *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
261 * The [enum@Purple.StatusPrimitive] for this presence.
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
262 *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
263 * Since: 3.0.0
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
264 */
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
265 properties[PROP_PRIMITIVE] = g_param_spec_enum(
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
266 "primitive", "primitive",
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
267 "The primitive for the presence",
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
268 PURPLE_TYPE_PRESENCE_PRIMITIVE,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
269 PURPLE_PRESENCE_PRIMITIVE_OFFLINE,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
270 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
271
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
272 /**
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
273 * PurplePresence:message:
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
274 *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
275 * The status message of the presence.
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
276 *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
277 * Since: 3.0.0
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
278 */
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
279 properties[PROP_MESSAGE] = g_param_spec_string(
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
280 "message", "message",
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
281 "The status message",
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
282 NULL,
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
283 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
284
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
285 /**
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
286 * PurplePresence:emoji:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
287 *
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
288 * The emoji or mood of the presence.
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
289 *
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
290 * Since: 3.0.0
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
291 */
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
292 properties[PROP_EMOJI] = g_param_spec_string(
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
293 "emoji", "emoji",
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
294 "The emoji for the presence.",
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
295 NULL,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
296 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
297
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
298 /**
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
299 * PurplePresence:mobile:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
300 *
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
301 * Whether or not the presence is on a mobile device.
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
302 *
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
303 * Since: 3.0.0
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
304 */
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
305 properties[PROP_MOBILE] = g_param_spec_boolean(
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
306 "mobile", "mobile",
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
307 "Whether or not the presence is on a mobile device.",
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
308 FALSE,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
309 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
310
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
311 /**
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
312 * PurplePresence:notifications-disabled:
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
313 *
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
314 * Whether or not the presence has notifications disabled.
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
315 *
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
316 * Some protocols, like Slack, allow users to set an available schedule. By
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
317 * default it displays that the user has notifications turned off outside
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
318 * of that schedule.
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
319 *
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
320 * Since: 3.0.0
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
321 */
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
322 properties[PROP_NOTIFICATIONS_DISABLED] = g_param_spec_boolean(
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
323 "notifications-disabled", "notifications-disabled",
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
324 "Whether or not this presence has notifications disabled.",
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
325 FALSE,
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
326 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
327
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
328 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
329 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
330
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
331 /******************************************************************************
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
332 * Public API
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
333 *****************************************************************************/
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
334 PurplePresence *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
335 purple_presence_new(void) {
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
336 return g_object_new(PURPLE_TYPE_PRESENCE, NULL);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
337 }
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
338
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
339 void
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
340 purple_presence_set_status_active(PurplePresence *presence,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
341 const gchar *status_id, gboolean active)
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
342 {
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
343 PurpleStatus *status = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
344
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
345 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
346 g_return_if_fail(status_id != NULL);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
347
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
348 status = purple_presence_get_status(presence, status_id);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
349
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
350 g_return_if_fail(PURPLE_IS_STATUS(status));
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
351 /* TODO: Should we do the following? */
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
352 /* g_return_if_fail(active == status->active); */
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
353
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
354 if(purple_status_is_exclusive(status)) {
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
355 if(!active) {
35176
b0659f31989d Update debug categories for new filenames
Ankit Vani <a@nevitus.org>
parents: 35091
diff changeset
356 purple_debug_warning("presence",
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
357 "Attempted to set a non-independent status "
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
358 "(%s) inactive. Only independent statuses "
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
359 "can be specifically marked inactive.",
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
360 status_id);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
361 return;
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
362 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
363 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
364
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
365 purple_status_set_active(status, active);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
366 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
367
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
368 void
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
369 purple_presence_switch_status(PurplePresence *presence, const gchar *status_id)
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
370 {
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
371 purple_presence_set_status_active(presence, status_id, TRUE);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
372 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
373
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
374 void
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
375 purple_presence_set_idle(PurplePresence *presence, gboolean idle,
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
376 GDateTime *idle_time)
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
377 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
378 PurplePresencePrivate *priv = NULL;
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
379 PurplePresenceClass *klass = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
380 gboolean old_idle;
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
381 GObject *obj = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
382
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
383 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
384
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
385 priv = purple_presence_get_instance_private(presence);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
386 klass = PURPLE_PRESENCE_GET_CLASS(presence);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
387
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
388 if (priv->idle == idle && priv->idle_time == idle_time) {
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
389 return;
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
390 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
391
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
392 old_idle = priv->idle;
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
393 priv->idle = idle;
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
394
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
395 g_clear_pointer(&priv->idle_time, g_date_time_unref);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
396 if(idle && idle_time != NULL) {
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
397 priv->idle_time = g_date_time_ref(idle_time);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
398 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
399
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
400 obj = G_OBJECT(presence);
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
401 g_object_freeze_notify(obj);
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
402 g_object_notify_by_pspec(obj, properties[PROP_IDLE]);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
403 g_object_notify_by_pspec(obj, properties[PROP_IDLE_TIME]);
35066
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
404 g_object_thaw_notify(obj);
f997e5384f79 libpurple: Use G_PARAM_STATIC_STRINGS and ensure g_object_notify is always called
Ankit Vani <a@nevitus.org>
parents: 35058
diff changeset
405
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
406 if(klass->update_idle) {
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
407 klass->update_idle(presence, old_idle);
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
408 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
409 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
410
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
411 void
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
412 purple_presence_set_login_time(PurplePresence *presence, GDateTime *login_time)
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
413 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
414 PurplePresencePrivate *priv = NULL;
34847
770ba2679b24 Refactored presence.c and status.c to use the GObject PurplePresence API
Ankit Vani <a@nevitus.org>
parents: 34846
diff changeset
415
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
416 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
417
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
418 priv = purple_presence_get_instance_private(presence);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
419
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
420 if(priv->login_time != NULL && login_time != NULL) {
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
421 if(g_date_time_equal(priv->login_time, login_time)) {
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
422 return;
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
423 }
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
424 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
425
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
426 if(priv->login_time != NULL) {
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
427 g_date_time_unref(priv->login_time);
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
428 }
35013
4718438d053b Cleaned up properties and added g_object_notify calls for everything else
Ankit Vani <a@nevitus.org>
parents: 34986
diff changeset
429
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
430 if(login_time != NULL) {
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
431 priv->login_time = g_date_time_ref(login_time);
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
432 } else {
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
433 priv->login_time = NULL;
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
434 }
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
435
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
436 g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_LOGIN_TIME]);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
437 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
438
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
439 GList *
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
440 purple_presence_get_statuses(PurplePresence *presence) {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
441 PurplePresenceClass *klass = NULL;
34847
770ba2679b24 Refactored presence.c and status.c to use the GObject PurplePresence API
Ankit Vani <a@nevitus.org>
parents: 34846
diff changeset
442
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
443 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), NULL);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
444
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
445 klass = PURPLE_PRESENCE_GET_CLASS(presence);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
446 if(klass && klass->get_statuses) {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
447 return klass->get_statuses(presence);
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
448 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
449
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
450 return NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
451 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
452
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
453 PurpleStatus *
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
454 purple_presence_get_status(PurplePresence *presence, const gchar *status_id) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
455 PurplePresencePrivate *priv = NULL;
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
456 PurpleStatus *status = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
457 GList *l = NULL;
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
458
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
459 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), NULL);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
460 g_return_val_if_fail(status_id != NULL, NULL);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
461
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
462 priv = purple_presence_get_instance_private(presence);
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
463
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
464 /* What's the purpose of this hash table? */
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
465 status = (PurpleStatus *)g_hash_table_lookup(priv->status_table,
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
466 status_id);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
467
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
468 if(status == NULL) {
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
469 for(l = purple_presence_get_statuses(presence);
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
470 l != NULL && status == NULL; l = l->next)
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
471 {
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
472 PurpleStatus *temp_status = l->data;
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
473
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
474 if (purple_strequal(status_id, purple_status_get_id(temp_status))) {
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
475 status = temp_status;
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
476 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
477 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
478
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
479 if(status != NULL) {
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
480 g_hash_table_insert(priv->status_table,
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
481 g_strdup(purple_status_get_id(status)), status);
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
482 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
483 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
484
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
485 return status;
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
486 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
487
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
488 PurpleStatus *
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
489 purple_presence_get_active_status(PurplePresence *presence) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
490 PurplePresencePrivate *priv = NULL;
34847
770ba2679b24 Refactored presence.c and status.c to use the GObject PurplePresence API
Ankit Vani <a@nevitus.org>
parents: 34846
diff changeset
491
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
492 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), NULL);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
493
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
494 priv = purple_presence_get_instance_private(presence);
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
495
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
496 return priv->active_status;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
497 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
498
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
499 gboolean
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
500 purple_presence_is_available(PurplePresence *presence) {
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
501 PurpleStatus *status = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
502
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
503 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
504
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
505 status = purple_presence_get_active_status(presence);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
506
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
507 return ((status != NULL && purple_status_is_available(status)) &&
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
508 !purple_presence_is_idle(presence));
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
509 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
510
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
511 gboolean
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
512 purple_presence_is_online(PurplePresence *presence) {
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
513 PurpleStatus *status = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
514
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
515 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
516
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
517 if((status = purple_presence_get_active_status(presence)) == NULL) {
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
518 return FALSE;
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
519 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
520
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
521 return purple_status_is_online(status);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
522 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
523
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
524 gboolean
39435
b30e04a71ecf Use G_DEFINE_TYPE_WITH_PRIVATE for Purple*Presence.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
525 purple_presence_is_status_active(PurplePresence *presence,
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
526 const gchar *status_id)
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
527 {
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
528 PurpleStatus *status = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
529
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
530 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
531 g_return_val_if_fail(status_id != NULL, FALSE);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
532
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
533 status = purple_presence_get_status(presence, status_id);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
534
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
535 return (status != NULL && purple_status_is_active(status));
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
536 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
537
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
538 gboolean
39435
b30e04a71ecf Use G_DEFINE_TYPE_WITH_PRIVATE for Purple*Presence.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39352
diff changeset
539 purple_presence_is_status_primitive_active(PurplePresence *presence,
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
540 PurpleStatusPrimitive primitive)
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
541 {
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
542 GList *l = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
543
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
544 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
545 g_return_val_if_fail(primitive != PURPLE_STATUS_UNSET, FALSE);
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
546
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
547 for(l = purple_presence_get_statuses(presence); l != NULL; l = l->next) {
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
548 PurpleStatus *temp_status = l->data;
34855
9c289149eed4 Global replaces according to GObject status API
Ankit Vani <a@nevitus.org>
parents: 34852
diff changeset
549 PurpleStatusType *type = purple_status_get_status_type(temp_status);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
550
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
551 if(purple_status_type_get_primitive(type) == primitive &&
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
552 purple_status_is_active(temp_status))
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
553 {
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
554 return TRUE;
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
555 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
556 }
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
557
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
558 return FALSE;
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
559 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
560
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
561 gboolean
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
562 purple_presence_is_idle(PurplePresence *presence) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
563 PurplePresencePrivate *priv = NULL;
34847
770ba2679b24 Refactored presence.c and status.c to use the GObject PurplePresence API
Ankit Vani <a@nevitus.org>
parents: 34846
diff changeset
564
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
565 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
566
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
567 if(!purple_presence_is_online(presence)) {
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
568 return FALSE;
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
569 }
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
570
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
571 priv = purple_presence_get_instance_private(presence);
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
572
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
573 return priv->idle;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
574 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
575
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
576 GDateTime *
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
577 purple_presence_get_idle_time(PurplePresence *presence) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
578 PurplePresencePrivate *priv = NULL;
34847
770ba2679b24 Refactored presence.c and status.c to use the GObject PurplePresence API
Ankit Vani <a@nevitus.org>
parents: 34846
diff changeset
579
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
580 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), NULL);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
581
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
582 priv = purple_presence_get_instance_private(presence);
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
583
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
584 return priv->idle_time;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
585 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
586
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
587 GDateTime *
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
588 purple_presence_get_login_time(PurplePresence *presence) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
589 PurplePresencePrivate *priv = NULL;
34847
770ba2679b24 Refactored presence.c and status.c to use the GObject PurplePresence API
Ankit Vani <a@nevitus.org>
parents: 34846
diff changeset
590
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
591 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), 0);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
592
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
593 priv = purple_presence_get_instance_private(presence);
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
594
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
595 return priv->login_time;
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
596 }
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
597
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
598 gint
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
599 purple_presence_compare(PurplePresence *presence1, PurplePresence *presence2) {
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
600 PurplePresencePrimitive primitive1 = PURPLE_PRESENCE_PRIMITIVE_OFFLINE;
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
601 PurplePresencePrimitive primitive2 = PURPLE_PRESENCE_PRIMITIVE_OFFLINE;
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
602 GDateTime *idle1 = NULL;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
603 GDateTime *idle2 = NULL;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
604 GDateTime *now = NULL;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
605 GTimeSpan diff1 = 0;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
606 GTimeSpan diff2 = 0;
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
607
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
608 if(presence1 == presence2) {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
609 return 0;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
610 } else if (presence1 == NULL) {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
611 return 1;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
612 } else if (presence2 == NULL) {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
613 return -1;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
614 }
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
615
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
616 primitive1 = purple_presence_get_primitive(presence1);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
617 primitive2 = purple_presence_get_primitive(presence2);
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
618
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
619 if(primitive1 != PURPLE_PRESENCE_PRIMITIVE_OFFLINE &&
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
620 primitive2 == PURPLE_PRESENCE_PRIMITIVE_OFFLINE)
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
621 {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
622 return -1;
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
623 } else if(primitive1 == PURPLE_PRESENCE_PRIMITIVE_OFFLINE &&
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
624 primitive2 != PURPLE_PRESENCE_PRIMITIVE_OFFLINE)
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
625 {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
626 return 1;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
627 }
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
628
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
629 idle1 = purple_presence_get_idle_time(presence1);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
630 idle2 = purple_presence_get_idle_time(presence2);
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
631
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
632 if(idle1 == NULL && idle2 == NULL) {
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
633 return 0;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
634 } else if(idle1 == NULL && idle2 != NULL) {
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
635 return -1;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
636 } else if(idle1 != NULL && idle2 == NULL) {
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
637 return 1;
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
638 }
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
639
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
640 now = g_date_time_new_now_local();
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
641 diff1 = g_date_time_difference(now, idle1);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
642 diff2 = g_date_time_difference(now, idle2);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
643 g_date_time_unref(now);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
644
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
645 if(diff1 > diff2) {
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
646 return 1;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
647 } else if (diff1 < diff2) {
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
648 return -1;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
649 }
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
650
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
651 return 0;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
652 }
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
653
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
654 PurplePresencePrimitive
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
655 purple_presence_get_primitive(PurplePresence *presence) {
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
656 PurplePresencePrivate *priv = NULL;
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
657
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
658 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence),
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
659 PURPLE_PRESENCE_PRIMITIVE_OFFLINE);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
660
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
661 priv = purple_presence_get_instance_private(presence);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
662
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
663 return priv->primitive;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
664 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
665
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
666 void
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
667 purple_presence_set_primitive(PurplePresence *presence,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
668 PurplePresencePrimitive primitive)
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
669 {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
670 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
671
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
672 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
673
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
674 priv = purple_presence_get_instance_private(presence);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
675
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
676 if(priv->primitive != primitive) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
677 priv->primitive = primitive;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
678
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
679 g_object_notify_by_pspec(G_OBJECT(presence),
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
680 properties[PROP_PRIMITIVE]);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
681 }
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
682 }
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
683
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
684 const char *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
685 purple_presence_get_message(PurplePresence *presence) {
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
686 PurplePresencePrivate *priv = NULL;
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
687
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
688 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), NULL);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
689
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
690 priv = purple_presence_get_instance_private(presence);
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
691
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
692 if(priv->message != NULL) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
693 return priv->message;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
694 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
695
42200
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
696 if(priv->active_status == NULL) {
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
697 return NULL;
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
698 }
c68c3ce47da8 Fix some issues where we were triggering GWarnings with presence
Gary Kramlich <grim@reaperworld.com>
parents: 42177
diff changeset
699
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
700 return purple_status_get_attr_string(priv->active_status, "message");
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
701 }
42173
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
702
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
703 void
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
704 purple_presence_set_message(PurplePresence *presence, const char *message) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
705 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
706
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
707 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
708
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
709 priv = purple_presence_get_instance_private(presence);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
710
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
711 if(!purple_strequal(priv->message, message)) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
712 g_free(priv->message);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
713 priv->message = g_strdup(message);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
714
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
715 g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_MESSAGE]);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
716 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
717 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
718
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
719 const char *
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
720 purple_presence_get_emoji(PurplePresence *presence) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
721 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
722
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
723 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), NULL);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
724
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
725 priv = purple_presence_get_instance_private(presence);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
726
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
727 return priv->emoji;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
728 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
729
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
730 void
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
731 purple_presence_set_emoji(PurplePresence *presence, const char *emoji) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
732 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
733
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
734 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
735
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
736 priv = purple_presence_get_instance_private(presence);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
737
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
738 if(!purple_strequal(priv->emoji, emoji)) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
739 g_free(priv->emoji);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
740 priv->emoji = g_strdup(emoji);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
741
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
742 g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_EMOJI]);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
743 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
744 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
745
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
746 gboolean
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
747 purple_presence_get_mobile(PurplePresence *presence) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
748 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
749
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
750 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
751
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
752 priv = purple_presence_get_instance_private(presence);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
753
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
754 return priv->mobile;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
755 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
756
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
757 void
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
758 purple_presence_set_mobile(PurplePresence *presence, gboolean mobile) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
759 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
760
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
761 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
762
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
763 priv = purple_presence_get_instance_private(presence);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
764
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
765 if(priv->mobile != mobile) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
766 priv->mobile = mobile;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
767
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
768 g_object_notify_by_pspec(G_OBJECT(presence), properties[PROP_MOBILE]);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
769 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
770 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
771
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
772 gboolean
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
773 purple_presence_get_notifications_disabled(PurplePresence *presence) {
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
774 PurplePresencePrivate *priv = NULL;
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
775
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
776 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
777
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
778 priv = purple_presence_get_instance_private(presence);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
779
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
780 return priv->notifications_disabled;
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
781 }
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
782
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
783 void
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
784 purple_presence_set_notifications_disabled(PurplePresence *presence,
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
785 gboolean notifications_disabled)
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
786 {
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
787 PurplePresencePrivate *priv = NULL;
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
788
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
789 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
790
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
791 priv = purple_presence_get_instance_private(presence);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
792
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
793 if(priv->notifications_disabled != notifications_disabled) {
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
794 priv->notifications_disabled = notifications_disabled;
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
795
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
796 g_object_notify_by_pspec(G_OBJECT(presence),
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
797 properties[PROP_NOTIFICATIONS_DISABLED]);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
798 }
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
799 }
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
800
42173
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
801 const char *
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
802 purple_presence_primitive_to_string(PurplePresencePrimitive primitive) {
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
803 switch(primitive) {
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
804 case PURPLE_PRESENCE_PRIMITIVE_OFFLINE:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
805 return _("Offline");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
806 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
807 case PURPLE_PRESENCE_PRIMITIVE_AVAILABLE:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
808 return _("Available");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
809 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
810 case PURPLE_PRESENCE_PRIMITIVE_IDLE:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
811 return _("Idle");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
812 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
813 case PURPLE_PRESENCE_PRIMITIVE_INVISIBLE:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
814 return _("Invisible");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
815 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
816 case PURPLE_PRESENCE_PRIMITIVE_AWAY:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
817 return _("Away");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
818 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
819 case PURPLE_PRESENCE_PRIMITIVE_EXTENDED_AWAY:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
820 return _("Do not disturb");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
821 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
822 case PURPLE_PRESENCE_PRIMITIVE_STREAMING:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
823 return _("Streaming");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
824 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
825 default:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
826 return _("Unknown");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
827 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
828 }
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
829 }

mercurial