libpurple/purplepresence.c

Sat, 27 Apr 2024 23:53:20 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 27 Apr 2024 23:53:20 -0500
changeset 42747
801025bad2e1
parent 42725
ceb13f1de2d2
child 42748
939814cb9972
permissions
-rw-r--r--

Make PurplePresence final and other clean ups

This also makes purple_presence_set_idle to only take a boolean value, but also
add purple_presence_set_idle_time that takes a GDateTime.

Cleaned up property declarations as well.

Testing Done:
Ran with the turtles.

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

40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
1 /*
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
2 * Purple - Internet Messaging Library
40575
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
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
34834
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 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
9 * This library is free software; you can redistribute it and/or modify it
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
10 * under the terms of the GNU General Public License as published by the Free
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
11 * Software Foundation; either version 2 of the License, or (at your option)
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
12 * any later version.
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
13 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
14 * This library is distributed in the hope that it will be useful, but WITHOUT
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
16 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
17 * more details.
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
18 *
42594
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
19 * You should have received a copy of the GNU General Public License along with
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
20 * this library; 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
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
25 #include <birb.h>
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
26
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
27 #include "purplepresence.h"
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
28
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
29 #include "debug.h"
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
30 #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
31 #include "purpleprivate.h"
42725
ceb13f1de2d2 Remove PurpleBuddy
Gary Kramlich <grim@reaperworld.com>
parents: 42705
diff changeset
32 #include "util.h"
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
33
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
34 struct _PurplePresence {
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
35 GObject parent;
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
36 };
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
37
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
38 typedef struct {
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
39 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
40 GDateTime *login_time;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
41
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
42 PurplePresencePrimitive primitive;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
43 char *message;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
44 char *emoji;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
45 gboolean mobile;
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
46 gboolean notifications_disabled;
39538
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
47 } PurplePresencePrivate;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
48
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
49 enum {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
50 PROP_0,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
51 PROP_IDLE,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
52 PROP_IDLE_TIME,
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
53 PROP_LOGIN_TIME,
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
54 PROP_PRIMITIVE,
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
55 PROP_MESSAGE,
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
56 PROP_EMOJI,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
57 PROP_MOBILE,
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
58 PROP_NOTIFICATIONS_DISABLED,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42509
diff changeset
59 N_PROPERTIES,
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
60 };
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42509
diff changeset
61 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
39538
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
62
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
63 G_DEFINE_FINAL_TYPE_WITH_PRIVATE(PurplePresence, purple_presence,
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
64 G_TYPE_OBJECT)
39538
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
65
40537
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 * GObject Implementation
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
68 *****************************************************************************/
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
69 static void
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
70 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
71 GParamSpec *pspec)
34836
289bc0df25bb API changes for PurplePresence. See details.
Ankit Vani <a@nevitus.org>
parents: 34834
diff changeset
72 {
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
73 PurplePresence *presence = PURPLE_PRESENCE(obj);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
74
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
75 switch (param_id) {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
76 case PROP_IDLE:
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
77 purple_presence_set_idle(presence, g_value_get_boolean(value));
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
78 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
79 case PROP_IDLE_TIME:
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
80 purple_presence_set_idle_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
81 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
82 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
83 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
84 break;
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
85 case PROP_PRIMITIVE:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
86 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
87 break;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
88 case PROP_MESSAGE:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
89 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
90 break;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
91 case PROP_EMOJI:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
92 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
93 break;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
94 case PROP_MOBILE:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
95 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
96 break;
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
97 case PROP_NOTIFICATIONS_DISABLED:
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
98 purple_presence_set_notifications_disabled(presence,
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
99 g_value_get_boolean(value));
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
100 break;
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
101 default:
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
102 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
103 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
104 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
105 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
106
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
107 static void
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
108 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
109 GParamSpec *pspec)
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
110 {
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
111 PurplePresence *presence = PURPLE_PRESENCE(obj);
39538
00ee7c55cd54 Re-group presence type definitions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39435
diff changeset
112
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
113 switch (param_id) {
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
114 case PROP_IDLE:
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
115 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
116 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
117 case PROP_IDLE_TIME:
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
118 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
119 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
120 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
121 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
122 break;
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
123 case PROP_PRIMITIVE:
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
124 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
125 break;
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
126 case PROP_MESSAGE:
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
127 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
128 break;
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
129 case PROP_EMOJI:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
130 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
131 break;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
132 case PROP_MOBILE:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
133 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
134 break;
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
135 case PROP_NOTIFICATIONS_DISABLED:
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
136 g_value_set_boolean(value,
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
137 purple_presence_get_notifications_disabled(presence));
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
138 break;
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
139 default:
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
140 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
141 break;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
142 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
143 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
144
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
145 static void
42705
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
146 purple_presence_init(G_GNUC_UNUSED PurplePresence *presence) {
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
147 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
148
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
149 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
150 purple_presence_finalize(GObject *obj) {
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
151 PurplePresencePrivate *priv = NULL;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
152
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
153 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
154
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
155 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
156 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
157
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
158 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
159 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
160
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
161 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
162 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
163
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
164 static void
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
165 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
166 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
167
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
168 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
169 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
170 obj_class->finalize = purple_presence_finalize;
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
171
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
172 /**
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
173 * PurplePresence:idle:
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
174 *
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
175 * 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
176 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
177 * Since: 3.0
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
178 */
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
179 properties[PROP_IDLE] = g_param_spec_boolean(
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
180 "idle", "idle",
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
181 "Whether the presence is in idle state.",
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
182 FALSE,
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
183 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
184
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
185 /**
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
186 * 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
187 *
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
188 * 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
189 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
190 * Since: 3.0
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
191 */
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
192 properties[PROP_IDLE_TIME] = g_param_spec_boxed(
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
193 "idle-time", "idle-time",
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
194 "The idle time of the presence",
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
195 G_TYPE_DATE_TIME,
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
196 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
197
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
198 /**
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
199 * 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
200 *
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
201 * 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
202 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
203 * Since: 3.0
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
204 */
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
205 properties[PROP_LOGIN_TIME] = g_param_spec_boxed(
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
206 "login-time", "login-time",
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
207 "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
208 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
209 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
210
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
211 /**
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
212 * PurplePresence:primitive:
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
213 *
42705
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
214 * The [enum@Purple.PresencePrimitive] for this presence.
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
215 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
216 * Since: 3.0
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
217 */
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
218 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
219 "primitive", "primitive",
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
220 "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
221 PURPLE_TYPE_PRESENCE_PRIMITIVE,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
222 PURPLE_PRESENCE_PRIMITIVE_OFFLINE,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
223 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
224
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
225 /**
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
226 * PurplePresence:message:
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
227 *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
228 * 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
229 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
230 * Since: 3.0
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
231 */
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
232 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
233 "message", "message",
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
234 "The status message",
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
235 NULL,
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
236 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
237
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
238 /**
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
239 * PurplePresence:emoji:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
240 *
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
241 * 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
242 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
243 * Since: 3.0
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
244 */
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
245 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
246 "emoji", "emoji",
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
247 "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
248 NULL,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
249 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
250
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
251 /**
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
252 * PurplePresence:mobile:
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
253 *
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
254 * 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
255 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
256 * Since: 3.0
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
257 */
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
258 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
259 "mobile", "mobile",
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
260 "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
261 FALSE,
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
262 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
263
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
264 /**
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
265 * PurplePresence:notifications-disabled:
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
266 *
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
267 * 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
268 *
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
269 * 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
270 * 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
271 * of that schedule.
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
272 *
42615
2f3308794a8f Remove the micro version from since tags for libpurple part 4
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
273 * Since: 3.0
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
274 */
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
275 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
276 "notifications-disabled", "notifications-disabled",
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
277 "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
278 FALSE,
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
279 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
280
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
281 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
282 }
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
283
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
284 /******************************************************************************
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
285 * Public API
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
286 *****************************************************************************/
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
287 PurplePresence *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
288 purple_presence_new(void) {
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
289 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
290 }
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
291
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
292 void
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
293 purple_presence_set_idle_time(PurplePresence *presence, GDateTime *idle_time) {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
294 PurplePresencePrivate *priv = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
295
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
296 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
297
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
298 priv = purple_presence_get_instance_private(presence);
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
299
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
300 if(birb_date_time_set(&priv->idle_time, idle_time)) {
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
301 GObject *obj = G_OBJECT(presence);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
302
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
303 g_object_freeze_notify(obj);
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
304 g_object_notify_by_pspec(obj, properties[PROP_IDLE]);
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
305 g_object_notify_by_pspec(obj, properties[PROP_IDLE_TIME]);
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
306 g_object_thaw_notify(obj);
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
307 }
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
308 }
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
309
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
310 void
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
311 purple_presence_set_idle(PurplePresence *presence, gboolean idle) {
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
312 GDateTime *idle_time = NULL;
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
313
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
314 g_return_if_fail(PURPLE_IS_PRESENCE(presence));
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
315
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
316 if(idle) {
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
317 idle_time = g_date_time_new_now_local();
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
318 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
319
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
320 purple_presence_set_idle_time(presence, idle_time);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
321 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
322
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
323 void
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
324 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
325 {
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
326 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
327
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
328 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
329
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
330 priv = purple_presence_get_instance_private(presence);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
331
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
332 if(birb_date_time_set(&priv->login_time, login_time)) {
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
333 g_object_notify_by_pspec(G_OBJECT(presence),
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
334 properties[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
335 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
336 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
337
42705
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
338 gboolean
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
339 purple_presence_is_available(PurplePresence *presence) {
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
340 PurplePresencePrivate *priv = NULL;
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
341
42705
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
342 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
343
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
344 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
345
42705
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
346 return priv->primitive == PURPLE_PRESENCE_PRIMITIVE_AVAILABLE;
34834
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
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
349 gboolean
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
350 purple_presence_is_online(PurplePresence *presence) {
42705
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
351 PurplePresencePrivate *priv = NULL;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
352
34983
81638be26f41 Check types of GObjects instead of just for NULL values
Ankit Vani <a@nevitus.org>
parents: 34864
diff changeset
353 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
354
42705
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
355 priv = purple_presence_get_instance_private(presence);
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
356
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
357 switch(priv->primitive) {
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
358 case PURPLE_PRESENCE_PRIMITIVE_AVAILABLE:
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
359 case PURPLE_PRESENCE_PRIMITIVE_IDLE:
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
360 case PURPLE_PRESENCE_PRIMITIVE_INVISIBLE:
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
361 case PURPLE_PRESENCE_PRIMITIVE_AWAY:
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
362 case PURPLE_PRESENCE_PRIMITIVE_DO_NOT_DISTURB:
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
363 case PURPLE_PRESENCE_PRIMITIVE_STREAMING:
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
364 return TRUE;
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
365 case PURPLE_PRESENCE_PRIMITIVE_OFFLINE:
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
366 default:
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
367 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
368 }
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
369 }
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 gboolean
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
372 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
373 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
374
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
375 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), FALSE);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
376
40575
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
377 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
378 return FALSE;
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
379 }
b82c365e04e8 Rename presence.[ch] to purplepresence.[ch], fix some docs, and other tweaks.
Gary Kramlich <grim@reaperworld.com>
parents: 40537
diff changeset
380
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
381 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
382
42747
801025bad2e1 Make PurplePresence final and other clean ups
Gary Kramlich <grim@reaperworld.com>
parents: 42725
diff changeset
383 return (priv->idle_time != NULL);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
384 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
385
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
386 GDateTime *
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
387 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
388 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
389
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
390 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), NULL);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
391
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
392 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
393
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
394 return priv->idle_time;
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
395 }
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
396
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
397 GDateTime *
40537
fbf29150c28c Move PurpleAccountPresence and PurpleBuddyPresence to their own files
Gary Kramlich <grim@reaperworld.com>
parents: 40441
diff changeset
398 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
399 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
400
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
401 g_return_val_if_fail(PURPLE_IS_PRESENCE(presence), 0);
34834
f45f0745da61 Started GObjectification of PurplePresence.
Ankit Vani <a@nevitus.org>
parents:
diff changeset
402
39782
db027c5e1463 Fix broken `priv != NULL` checks in libpurple.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 39675
diff changeset
403 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
404
41963
d140e4f6bb02 Move the PurplePresence::login-time property from time_t to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 41740
diff changeset
405 return priv->login_time;
34846
dea8dd8343d5 Added GObject code to presenses.c.
Ankit Vani <a@nevitus.org>
parents: 34840
diff changeset
406 }
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
407
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
408 gint
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
409 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
410 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
411 PurplePresencePrimitive primitive2 = PURPLE_PRESENCE_PRIMITIVE_OFFLINE;
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
412 GDateTime *idle1 = NULL;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
413 GDateTime *idle2 = NULL;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
414 GDateTime *now = NULL;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
415 GTimeSpan diff1 = 0;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
416 GTimeSpan diff2 = 0;
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
417
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
418 if(presence1 == presence2) {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
419 return 0;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
420 } else if (presence1 == NULL) {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
421 return 1;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
422 } else if (presence2 == NULL) {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
423 return -1;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
424 }
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
425
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
426 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
427 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
428
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
429 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
430 primitive2 == PURPLE_PRESENCE_PRIMITIVE_OFFLINE)
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
431 {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
432 return -1;
42270
1bdd57a0c0d1 Propagate notify signals from the priority contact of a person
Gary Kramlich <grim@reaperworld.com>
parents: 42200
diff changeset
433 } 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
434 primitive2 != PURPLE_PRESENCE_PRIMITIVE_OFFLINE)
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
435 {
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
436 return 1;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
437 }
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
438
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
439 idle1 = purple_presence_get_idle_time(presence1);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
440 idle2 = purple_presence_get_idle_time(presence2);
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
441
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
442 if(idle1 == NULL && idle2 == NULL) {
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
443 return 0;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
444 } else if(idle1 == NULL && idle2 != NULL) {
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
445 return -1;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
446 } else if(idle1 != NULL && idle2 == NULL) {
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
447 return 1;
42071
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
448 }
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
449
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
450 now = g_date_time_new_now_local();
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
451 diff1 = g_date_time_difference(now, idle1);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
452 diff2 = g_date_time_difference(now, idle2);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
453 g_date_time_unref(now);
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
454
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
455 if(diff1 > diff2) {
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
456 return 1;
a719f0f3c600 Convert idle_time in PurplePresence to GDateTime
Gary Kramlich <grim@reaperworld.com>
parents: 42051
diff changeset
457 } else if (diff1 < diff2) {
41740
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
458 return -1;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
459 }
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
460
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
461 return 0;
d8fcd2907c3d Add purple_presence_compare
Gary Kramlich <grim@reaperworld.com>
parents: 40575
diff changeset
462 }
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
463
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
464 PurplePresencePrimitive
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
465 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
466 PurplePresencePrivate *priv = NULL;
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
467
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
468 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
469 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
470
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
471 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
472
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
473 return priv->primitive;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
474 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
475
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
476 void
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
477 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
478 PurplePresencePrimitive primitive)
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
479 {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
480 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
481
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
482 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
483
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
484 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
485
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
486 if(priv->primitive != primitive) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
487 priv->primitive = primitive;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
488
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
489 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
490 properties[PROP_PRIMITIVE]);
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
491 }
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
492 }
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
493
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
494 const char *
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
495 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
496 PurplePresencePrivate *priv = NULL;
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
497
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
498 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
499
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
500 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
501
42705
e78a46048ae7 Remove the old status API
Gary Kramlich <grim@reaperworld.com>
parents: 42615
diff changeset
502 return priv->message;
42051
18adb1710a54 Add read-only properties for primitive and message to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 41963
diff changeset
503 }
42173
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
504
42177
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
505 void
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
506 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
507 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
508
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
509 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
510
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
511 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
512
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
513 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
514 g_free(priv->message);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
515 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
516
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
517 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
518 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
519 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
520
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
521 const char *
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
522 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
523 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
524
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
525 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
526
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
527 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
528
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
529 return priv->emoji;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
530 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
531
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
532 void
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
533 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
534 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
535
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
536 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
537
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
538 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
539
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
540 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
541 g_free(priv->emoji);
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
542 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
543
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
544 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
545 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
546 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
547
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
548 gboolean
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
549 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
550 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
551
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
552 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
553
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
554 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
555
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
556 return priv->mobile;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
557 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
558
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
559 void
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
560 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
561 PurplePresencePrivate *priv = NULL;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
562
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
563 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
564
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
565 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
566
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
567 if(priv->mobile != mobile) {
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
568 priv->mobile = mobile;
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
569
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
570 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
571 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
572 }
d5722fdbdf86 Add "new-status" properties to PurplePresence with fallbacks were applicable
Gary Kramlich <grim@reaperworld.com>
parents: 42173
diff changeset
573
42310
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
574 gboolean
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
575 purple_presence_get_notifications_disabled(PurplePresence *presence) {
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
576 PurplePresencePrivate *priv = NULL;
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
577
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
578 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
579
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
580 priv = purple_presence_get_instance_private(presence);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
581
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
582 return priv->notifications_disabled;
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
583 }
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
584
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
585 void
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
586 purple_presence_set_notifications_disabled(PurplePresence *presence,
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
587 gboolean notifications_disabled)
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
588 {
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
589 PurplePresencePrivate *priv = NULL;
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
590
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
591 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
592
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
593 priv = purple_presence_get_instance_private(presence);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
594
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
595 if(priv->notifications_disabled != notifications_disabled) {
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
596 priv->notifications_disabled = notifications_disabled;
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
597
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
598 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
599 properties[PROP_NOTIFICATIONS_DISABLED]);
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
600 }
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
601 }
eea341b0d614 Add a notifications-disabled property to PurplePresence
Gary Kramlich <grim@reaperworld.com>
parents: 42270
diff changeset
602
42173
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
603 const char *
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
604 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
605 switch(primitive) {
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
606 case PURPLE_PRESENCE_PRIMITIVE_OFFLINE:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
607 return _("Offline");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
608 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
609 case PURPLE_PRESENCE_PRIMITIVE_AVAILABLE:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
610 return _("Available");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
611 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
612 case PURPLE_PRESENCE_PRIMITIVE_IDLE:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
613 return _("Idle");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
614 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
615 case PURPLE_PRESENCE_PRIMITIVE_INVISIBLE:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
616 return _("Invisible");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
617 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
618 case PURPLE_PRESENCE_PRIMITIVE_AWAY:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
619 return _("Away");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
620 break;
42509
e96a15f7f0d8 Rename PURPLE_PRESENCE_EXTENDED_AWAY to PURPLE_PRESENCE_DO_NOT_DISTURB
Gary Kramlich <grim@reaperworld.com>
parents: 42432
diff changeset
621 case PURPLE_PRESENCE_PRIMITIVE_DO_NOT_DISTURB:
42173
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
622 return _("Do not disturb");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
623 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
624 case PURPLE_PRESENCE_PRIMITIVE_STREAMING:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
625 return _("Streaming");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
626 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
627 default:
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
628 return _("Unknown");
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
629 break;
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
630 }
50558d740eff Add purple_presence_primitive_to_string for easier display
Gary Kramlich <grim@reaperworld.com>
parents: 42071
diff changeset
631 }

mercurial