libpurple/purplenotification.c

Tue, 13 Aug 2024 03:03:05 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Tue, 13 Aug 2024 03:03:05 -0500
changeset 42867
e16b8726d9b5
parent 42805
3e77e81168a5
child 42909
440ed16de928
permissions
-rw-r--r--

Echo out pings and pongs as well as the RPL_ISUPPORT message

Testing Done:
Connected to a local ergo server and verified that the `RPL_ISUPPORT` message and `PING`s and `PONG`s were displayed in the status window.

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

41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Purple - Internet Messaging Library
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
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
5 * Purple is the legal property of its developers, whose names are too numerous
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
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
7 * source distribution.
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
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.
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
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.
eddde70cedd8 Create a test for verifying license headers and correct the ones that were wrong
Gary Kramlich <grim@reaperworld.com>
parents: 42584
diff changeset
18 *
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/>.
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
23 #include <glib/gi18n-lib.h>
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
24
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 #include "purplenotification.h"
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 #include "purpleenums.h"
42725
ceb13f1de2d2 Remove PurpleBuddy
Gary Kramlich <grim@reaperworld.com>
parents: 42648
diff changeset
28 #include "util.h"
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
30 typedef struct {
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
31 char *id;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 PurpleNotificationType type;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 PurpleAccount *account;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 GDateTime *created_timestamp;
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
36 char *title;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
37 char *subtitle;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
38
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
39 char *icon_name;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 gboolean read;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 gboolean interactive;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 gpointer data;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 GDestroyNotify data_destroy_func;
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
45
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
46 gboolean deleted;
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
47 } PurpleNotificationPrivate;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 enum {
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
50 SIG_DELETED,
42584
687260353985 Make signal and property enums and initializers consistent
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42576
diff changeset
51 N_SIGNALS,
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
52 };
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
53 static guint signals[N_SIGNALS] = {0, };
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
54
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
55 enum {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 PROP_0,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 PROP_ID,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 PROP_TYPE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PROP_ACCOUNT,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 PROP_CREATED_TIMESTAMP,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 PROP_TITLE,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
62 PROP_SUBTITLE,
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 PROP_ICON_NAME,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 PROP_READ,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 PROP_INTERACTIVE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 PROP_DATA,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 PROP_DATA_DESTROY_FUNC,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 N_PROPERTIES,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 };
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
72 G_DEFINE_TYPE_WITH_PRIVATE(PurpleNotification, purple_notification,
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
73 G_TYPE_OBJECT)
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 * Helpers
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 purple_notification_set_id(PurpleNotification *notification, const gchar *id) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
80 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
81
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
84 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
85
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 if(id == NULL) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
87 priv->id = g_uuid_string_random();
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 } else {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
89 priv->id = g_strdup(id);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 g_object_notify_by_pspec(G_OBJECT(notification), properties[PROP_ID]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 purple_notification_set_notification_type(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 PurpleNotificationType type)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
99 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
100
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
103 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
104
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
105 priv->type = type;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 g_object_notify_by_pspec(G_OBJECT(notification), properties[PROP_TYPE]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 purple_notification_set_account(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 PurpleAccount *account)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
114 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
115
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
118 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
119
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
120 if(g_set_object(&priv->account, account)) {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 properties[PROP_ACCOUNT]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 purple_notification_set_data(PurpleNotification *notification, gpointer data) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
128 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
129
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
132 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
133
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
134 priv->data = data;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136 g_object_notify_by_pspec(G_OBJECT(notification), properties[PROP_DATA]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 purple_notification_set_data_destroy_func(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 GDestroyNotify data_destroy_func)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
143 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
144
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
147 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
148
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
149 priv->data_destroy_func = data_destroy_func;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 properties[PROP_DATA_DESTROY_FUNC]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 * GObject Implementation
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 purple_notification_get_property(GObject *obj, guint param_id, GValue *value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 GParamSpec *pspec)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 switch(param_id) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 case PROP_ID:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 g_value_set_string(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 purple_notification_get_id(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 case PROP_TYPE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 g_value_set_enum(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 purple_notification_get_notification_type(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 case PROP_ACCOUNT:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 g_value_set_object(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 purple_notification_get_account(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 case PROP_CREATED_TIMESTAMP:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 g_value_set_boxed(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 purple_notification_get_created_timestamp(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 case PROP_TITLE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 g_value_set_string(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 purple_notification_get_title(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 break;
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
185 case PROP_SUBTITLE:
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
186 g_value_set_string(value,
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
187 purple_notification_get_subtitle(notification));
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
188 break;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 case PROP_ICON_NAME:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 g_value_set_string(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 purple_notification_get_icon_name(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 case PROP_READ:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 g_value_set_boolean(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 purple_notification_get_read(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 case PROP_INTERACTIVE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 g_value_set_boolean(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 purple_notification_get_interactive(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 case PROP_DATA:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 g_value_set_pointer(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 purple_notification_get_data(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 default:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 purple_notification_set_property(GObject *obj, guint param_id,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 const GValue *value, GParamSpec *pspec)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 switch(param_id) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 case PROP_ID:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 purple_notification_set_id(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 g_value_get_string(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 case PROP_TYPE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 purple_notification_set_notification_type(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 g_value_get_enum(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 case PROP_ACCOUNT:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 purple_notification_set_account(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 g_value_get_object(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
229 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 case PROP_CREATED_TIMESTAMP:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 purple_notification_set_created_timestamp(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 g_value_get_boxed(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 case PROP_TITLE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 purple_notification_set_title(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 g_value_get_string(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 break;
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
238 case PROP_SUBTITLE:
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
239 purple_notification_set_subtitle(notification,
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
240 g_value_get_string(value));
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
241 break;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 case PROP_ICON_NAME:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 purple_notification_set_icon_name(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 g_value_get_string(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 case PROP_READ:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247 purple_notification_set_read(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 g_value_get_boolean(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 case PROP_INTERACTIVE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 purple_notification_set_interactive(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 g_value_get_boolean(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 case PROP_DATA:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 purple_notification_set_data(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 g_value_get_pointer(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 case PROP_DATA_DESTROY_FUNC:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259 purple_notification_set_data_destroy_func(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 g_value_get_pointer(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 default:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269 purple_notification_finalize(GObject *obj) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
271 PurpleNotificationPrivate *priv = NULL;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
273 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
274
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
275 g_clear_pointer(&priv->id, g_free);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
276 g_clear_object(&priv->account);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
278 g_clear_pointer(&priv->created_timestamp, g_date_time_unref);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
279 g_clear_pointer(&priv->title, g_free);
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
280 g_clear_pointer(&priv->subtitle, g_free);
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
281 g_clear_pointer(&priv->icon_name, g_free);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
283 if(priv->data_destroy_func != NULL) {
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
284 priv->data_destroy_func(priv->data);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 G_OBJECT_CLASS(purple_notification_parent_class)->finalize(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 purple_notification_init(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
292 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
293
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
294 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
295
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 purple_notification_set_id(notification, NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
298 if(priv->created_timestamp == NULL) {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 purple_notification_set_created_timestamp(notification, NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
303 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
304 purple_notification_class_init(PurpleNotificationClass *klass) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 obj_class->get_property = purple_notification_get_property;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 obj_class->set_property = purple_notification_set_property;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 obj_class->finalize = purple_notification_finalize;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
312 * PurpleNotification::deleted:
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
313 * @notification: The instance.
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
314 *
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
315 * Emitted when the notification is deleted. This is typically done by a
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
316 * user interface calling [method@PurpleNotification.delete].
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
317 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
318 * Since: 3.0
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
319 */
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
320 signals[SIG_DELETED] = g_signal_new_class_handler(
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
321 "deleted",
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
322 G_OBJECT_CLASS_TYPE(klass),
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
323 G_SIGNAL_RUN_LAST,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
324 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
325 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
326 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
327 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
328 G_TYPE_NONE,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
329 0);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
330
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
331 /**
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
332 * PurpleNotification:id:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
334 * The ID of the notification. Used for things that need to address it.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
335 * This is auto populated at creation time.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
337 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 properties[PROP_ID] = g_param_spec_string(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 "id", "id",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 "The identifier of the notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 NULL,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
343 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
345 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
346 * PurpleNotification:type:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 * The [enum@NotificationType] of this notification.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
350 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 properties[PROP_TYPE] = g_param_spec_enum(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 "type", "type",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 "The type of notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 PURPLE_TYPE_NOTIFICATION_TYPE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 PURPLE_NOTIFICATION_TYPE_UNKNOWN,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
358
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
359 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
360 * PurpleNotification:account:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
361 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
362 * An optional [class@Account] that this notification is for.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
363 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
364 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
365 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
366 properties[PROP_ACCOUNT] = g_param_spec_object(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 "account", "account",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 "The optional account that this notification is for.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 PURPLE_TYPE_ACCOUNT,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
373 * PurpleNotification:created-timestamp:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
375 * The creation time of this notification. This always represented as UTC
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 * internally, and will be set to UTC now by default.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
378 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380 properties[PROP_CREATED_TIMESTAMP] = g_param_spec_boxed(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 "created-timestamp", "created-timestamp",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 "The timestamp when this notification was created.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 G_TYPE_DATE_TIME,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
384 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
387 * PurpleNotification:title:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
388 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 * An optional title for this notification. A user interface may or may not
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 * choose to use this when displaying the notification. Regardless, this
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391 * should be a translated string.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
393 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 properties[PROP_TITLE] = g_param_spec_string(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 "title", "title",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 "The title for the notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 NULL,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
399 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
400
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
401 /**
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
402 * PurpleNotification:subtitle:
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
403 *
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
404 * An optional subtitle for this notification. A user interface may or may
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
405 * not choose to use this when displaying the notification. Regardless,
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
406 * this should be a translated string.
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
407 *
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
408 * Since: 3.0
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
409 */
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
410 properties[PROP_SUBTITLE] = g_param_spec_string(
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
411 "subtitle", "subtitle",
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
412 "The subtitle for the notification.",
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
413 NULL,
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
414 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
415
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
416 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
417 * PurpleNotification:icon-name:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
418 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
419 * The icon-name in the icon theme to use for the notification. A user
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 * interface may or may not choose to use this when display the
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421 * notification.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
423 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
424 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
425 properties[PROP_ICON_NAME] = g_param_spec_string(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
426 "icon-name", "icon-name",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
427 "The icon name for the notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 NULL,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
429 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
430
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
431 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
432 * PurpleNotification:read:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
434 * Whether or not the notification has been read.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
436 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438 properties[PROP_READ] = g_param_spec_boolean(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
439 "read", "read",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440 "Whether or not the notification has been read.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441 FALSE,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
442 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
443
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
444 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
445 * PurpleNotification:interactive:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
446 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
447 * Whether or not the notification can be interacted with.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
448 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
449 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
450 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
451 properties[PROP_INTERACTIVE] = g_param_spec_boolean(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
452 "interactive", "interactive",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
453 "Whether or not the notification can be interacted with.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
454 FALSE,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
455 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
456
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
457 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
458 * PurpleNotification:data:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
459 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
460 * Data specific to the [enum@NotificationType] for the notification.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
461 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
462 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
463 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
464 properties[PROP_DATA] = g_param_spec_pointer(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
465 "data", "data",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
466 "The type specific data for the notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
467 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
468
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
469 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
470 * PurpleNotification:data-destroy-func:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
471 *
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
472 * A function to call to free [property@PurpleNotification:data].
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
473 *
42614
b75a5bbf6c35 Remove the micro version from since tags for libpurple part 3
Gary Kramlich <grim@reaperworld.com>
parents: 42594
diff changeset
474 * Since: 3.0
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
475 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
476 properties[PROP_DATA_DESTROY_FUNC] = g_param_spec_pointer(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
477 "data-destroy-func", "data-destroy-func",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
478 "The destroy function to clean up the data property.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
479 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
480
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
481 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
482
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
483 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
484
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
485 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
486 * Public API
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
487 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
488 PurpleNotification *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
489 purple_notification_new(PurpleNotificationType type, PurpleAccount *account,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
490 gpointer data, GDestroyNotify data_destroy_func)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
491 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
492 return g_object_new(PURPLE_TYPE_NOTIFICATION,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
493 "type", type,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
494 "account", account,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
495 "data", data,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
496 "data-destroy-func", data_destroy_func,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
497 NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
498 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
499
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
500 PurpleNotification *
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
501 purple_notification_new_from_add_contact_request(PurpleAddContactRequest *request)
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
502 {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
503 PurpleAccount *account = NULL;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
504 PurpleNotification *notification = NULL;
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
505 char *title = NULL;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
506 const char *alias = NULL;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
507 const char *username = NULL;
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
508
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
509 g_return_val_if_fail(PURPLE_IS_ADD_CONTACT_REQUEST(request), NULL);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
510
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
511 account = purple_add_contact_request_get_account(request);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
512 notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_ADD_CONTACT,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
513 account, request, g_object_unref);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
514
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
515 username = purple_add_contact_request_get_username(request);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
516 alias = purple_add_contact_request_get_alias(request);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
518 if(alias != NULL && *alias != '\0') {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
519 title = g_strdup_printf(_("%s (%s) added %s to their contact list"),
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
520 alias, username,
42805
3e77e81168a5 Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
521 purple_account_get_username(account));
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
522 } else {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
523 title = g_strdup_printf(_("%s added %s to their contact list"),
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41819
diff changeset
524 username,
42805
3e77e81168a5 Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
525 purple_account_get_username(account));
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
526 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
527
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
528 purple_notification_set_title(notification, title);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
529 g_free(title);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
530
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
531 return notification;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
532 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
533
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
534 PurpleNotification *
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
535 purple_notification_new_from_authorization_request(PurpleAuthorizationRequest *authorization_request)
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
536 {
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
537 PurpleAccount *account = NULL;
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
538 PurpleNotification *notification = NULL;
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
539 char *title = NULL;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
540 const char *alias = NULL;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
541 const char *username = NULL;
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
542
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
543 g_return_val_if_fail(PURPLE_IS_AUTHORIZATION_REQUEST(authorization_request),
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
544 NULL);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
545
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
546 account = purple_authorization_request_get_account(authorization_request);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
547 notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_AUTHORIZATION_REQUEST,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
548 account, authorization_request,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
549 g_object_unref);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
550
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
551 username = purple_authorization_request_get_username(authorization_request);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
552 alias = purple_authorization_request_get_alias(authorization_request);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
553
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
554 if(alias != NULL && *alias != '\0') {
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
555 title = g_strdup_printf(_("%s (%s) would like to add %s to their"
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
556 " contact list"),
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
557 alias, username,
42805
3e77e81168a5 Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
558 purple_account_get_username(account));
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
559 } else {
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
560 title = g_strdup_printf(_("%s would like to add %s to their contact"
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
561 " list"),
41976
49969fa9a664 Update libpurple for the deprecations in the account api
Gary Kramlich <grim@reaperworld.com>
parents: 41819
diff changeset
562 username,
42805
3e77e81168a5 Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
563 purple_account_get_username(account));
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
564 }
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
565
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
566 purple_notification_set_title(notification, title);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
567 g_free(title);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
568
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
569 return notification;
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
570 }
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
571
41819
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
572 PurpleNotification *
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
573 purple_notification_new_from_connection_error(PurpleAccount *account,
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
574 PurpleConnectionErrorInfo *info)
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
575 {
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
576 PurpleNotification *notification = NULL;
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
577 PurpleProtocol *protocol = NULL;
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
578 char *title = NULL;
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
579 const char *username = NULL;
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
580
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
581 g_return_val_if_fail(PURPLE_IS_ACCOUNT(account), NULL);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
582 g_return_val_if_fail(info != NULL, NULL);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
583
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
584 notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_CONNECTION_ERROR,
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
585 account, info, NULL);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
586
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
587 /* Set the title of the notification. */
42805
3e77e81168a5 Update libpurple to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents: 42767
diff changeset
588 username = purple_account_get_username(account);
41819
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
589 if(purple_account_get_enabled(account)) {
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
590 title = g_strdup_printf(_("%s disconnected"), username);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
591 } else {
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
592 title = g_strdup_printf(_("%s disabled"), username);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
593 }
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
594 purple_notification_set_title(notification, title);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
595 g_free(title);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
596
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
597 /* Add the protocol's icon as the notification's icon. */
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
598 protocol = purple_account_get_protocol(account);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
599 if(PURPLE_IS_PROTOCOL(protocol)) {
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
600 const char *icon_name = purple_protocol_get_icon_name(protocol);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
601
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
602 if(icon_name != NULL) {
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
603 purple_notification_set_icon_name(notification, icon_name);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
604 }
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
605 }
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
606
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
607 return notification;
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
608 }
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
609
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
610 const char *
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
611 purple_notification_get_id(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
612 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
613
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
614 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
615
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
616 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
617
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
618 return priv->id;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
619 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
620
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
621 PurpleNotificationType
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
622 purple_notification_get_notification_type(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
623 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
624
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
625 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
626 PURPLE_NOTIFICATION_TYPE_UNKNOWN);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
627
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
628 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
629
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
630 return priv->type;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
631 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
632
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
633 PurpleAccount *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
634 purple_notification_get_account(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
635 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
636
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
637 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
638
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
639 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
640
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
641 return priv->account;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
642 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
643
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
644 GDateTime *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
645 purple_notification_get_created_timestamp(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
646 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
647
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
648 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
649
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
650 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
651
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
652 return priv->created_timestamp;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
653 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
654
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
655 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
656 purple_notification_set_created_timestamp(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
657 GDateTime *timestamp)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
658 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
659 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
660
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
661 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
662
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
663 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
664
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
665 g_clear_pointer(&priv->created_timestamp, g_date_time_unref);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
666
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
667 if(timestamp == NULL) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
668 priv->created_timestamp = g_date_time_new_now_utc();
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
669 } else {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
670 priv->created_timestamp = g_date_time_to_utc(timestamp);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
671 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
672
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
673 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
674 properties[PROP_CREATED_TIMESTAMP]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
675 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
676
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
677 const char *
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
678 purple_notification_get_title(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
679 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
680
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
681 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
682
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
683 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
684
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
685 return priv->title;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
686 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
687
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
688 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
689 purple_notification_set_title(PurpleNotification *notification,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
690 const char *title)
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
691 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
692 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
693
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
694 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
695
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
696 priv = purple_notification_get_instance_private(notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
697
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42725
diff changeset
698 if(g_set_str(&priv->title, title)) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
699 g_object_notify_by_pspec(G_OBJECT(notification),
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
700 properties[PROP_TITLE]);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
701 }
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
702 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
703
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
704 const char *
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
705 purple_notification_get_subtitle(PurpleNotification *notification) {
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
706 PurpleNotificationPrivate *priv = NULL;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
707
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
708 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
709
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
710 priv = purple_notification_get_instance_private(notification);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
711
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
712 return priv->subtitle;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
713 }
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
714
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
715 void
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
716 purple_notification_set_subtitle(PurpleNotification *notification,
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
717 const char *subtitle)
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
718 {
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
719 PurpleNotificationPrivate *priv = NULL;
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
720
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
721 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
722
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
723 priv = purple_notification_get_instance_private(notification);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
724
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42725
diff changeset
725 if(g_set_str(&priv->subtitle, subtitle)) {
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
726 g_object_notify_by_pspec(G_OBJECT(notification),
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
727 properties[PROP_SUBTITLE]);
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
728 }
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
729 }
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
730
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
731 const char *
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
732 purple_notification_get_icon_name(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
733 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
734
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
735 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
736
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
737 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
738
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
739 return priv->icon_name;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
740 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
741
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
742 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
743 purple_notification_set_icon_name(PurpleNotification *notification,
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
744 const char *icon_name)
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
745 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
746 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
747
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
748 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
749
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
750 priv = purple_notification_get_instance_private(notification);
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
751
42767
8cf1d11b59c1 Use g_set_str everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 42725
diff changeset
752 if(g_set_str(&priv->icon_name, icon_name)) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
753 g_object_notify_by_pspec(G_OBJECT(notification),
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
754 properties[PROP_ICON_NAME]);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
755 }
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
756
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
757 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
758
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
759 gboolean
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
760 purple_notification_get_read(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
761 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
762
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
763 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), FALSE);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
764
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
765 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
766
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
767 return priv->read;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
768 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
769
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
770 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
771 purple_notification_set_read(PurpleNotification *notification, gboolean read) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
772 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
773
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
774 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
775
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
776 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
777
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
778 if(priv->read != read) {
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
779 priv->read = read;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
780
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
781 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
782 properties[PROP_READ]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
783 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
784 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
785
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
786 gboolean
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
787 purple_notification_get_interactive(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
788 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
789
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
790 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), FALSE);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
791
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
792 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
793
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
794 return priv->interactive;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
795 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
796
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
797 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
798 purple_notification_set_interactive(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
799 gboolean interactive)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
800 {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
801 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
802
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
803 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
804
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
805 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
806
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
807 if(priv->interactive != interactive) {
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
808 priv->interactive = interactive;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
809
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
810 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
811 properties[PROP_INTERACTIVE]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
812 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
813 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
814
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
815 gpointer
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
816 purple_notification_get_data(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
817 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
818
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
819 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification), NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
820
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
821 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
822
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
823 return priv->data;
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
824 }
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
825
42648
70d33d4dac09 Add a subtitle property to PurpleNotification
Gary Kramlich <grim@reaperworld.com>
parents: 42630
diff changeset
826 int
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
827 purple_notification_compare(gconstpointer a, gconstpointer b) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
828 PurpleNotification *notification_a = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
829 PurpleNotification *notification_b = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
830 PurpleNotificationPrivate *priv_a = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
831 PurpleNotificationPrivate *priv_b = NULL;
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
832
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
833 if(a == NULL && b == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
834 return 0;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
835 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
836
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
837 if(a == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
838 return -1;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
839 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
840
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
841 if(b == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
842 return 1;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
843 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
844
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
845 notification_a = (PurpleNotification *)a;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
846 notification_b = (PurpleNotification *)b;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
847
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
848 priv_a = purple_notification_get_instance_private(notification_a);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
849 priv_b = purple_notification_get_instance_private(notification_b);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
850
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
851 return g_date_time_compare(priv_a->created_timestamp,
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
852 priv_b->created_timestamp);
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
853 }
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
854
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
855 void
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
856 purple_notification_delete(PurpleNotification *notification) {
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
857 PurpleNotificationPrivate *priv = NULL;
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
858
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
859 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
860
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
861 priv = purple_notification_get_instance_private(notification);
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
862
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
863 /* Calling this multiple times is a programming error. */
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
864 g_return_if_fail(priv->deleted == FALSE);
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
865
42630
4895793f3298 Make PurpleNotification derivable
Gary Kramlich <grim@reaperworld.com>
parents: 42614
diff changeset
866 priv->deleted = TRUE;
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
867
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
868 g_signal_emit(notification, signals[SIG_DELETED], 0);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
869 }

mercurial