libpurple/purplenotification.c

Mon, 12 Dec 2022 23:38:47 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Mon, 12 Dec 2022 23:38:47 -0600
changeset 41966
c7bcaf2f41ef
parent 41819
4461c8ec4d65
child 41976
49969fa9a664
permissions
-rw-r--r--

Create PurpleAvatar to represent avatars

Testing Done:
Ran the unit tests and manually verified the docs.

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

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 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 * Lesser General Public License for more details.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
19 #include <glib/gi18n-lib.h>
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
20
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 #include "purplenotification.h"
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "purpleenums.h"
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 struct _PurpleNotification {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 GObject parent;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 gchar *id;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 PurpleNotificationType type;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 PurpleAccount *account;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 GDateTime *created_timestamp;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 gchar *title;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 gchar *icon_name;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 gboolean read;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 gboolean interactive;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 gpointer data;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 GDestroyNotify data_destroy_func;
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
40
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
41 gboolean deleted;
41433
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
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 enum {
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
45 SIG_DELETED,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
46 N_SIGNALS
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
47 };
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
48 static guint signals[N_SIGNALS] = {0, };
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
49
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
50 enum {
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 PROP_0,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 PROP_ID,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 PROP_TYPE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 PROP_ACCOUNT,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 PROP_CREATED_TIMESTAMP,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 PROP_TITLE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 PROP_ICON_NAME,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 PROP_READ,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 PROP_INTERACTIVE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 PROP_DATA,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 PROP_DATA_DESTROY_FUNC,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 N_PROPERTIES,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 };
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 G_DEFINE_TYPE(PurpleNotification, purple_notification, G_TYPE_OBJECT)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 * Helpers
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 purple_notification_set_id(PurpleNotification *notification, const gchar *id) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
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 if(id == NULL) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 notification->id = g_uuid_string_random();
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 } else {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 notification->id = g_strdup(id);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 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
82 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 purple_notification_set_notification_type(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 PurpleNotificationType type)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 notification->type = type;
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_TYPE]);
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_account(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 PurpleAccount *account)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 if(g_set_object(&notification->account, account)) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 properties[PROP_ACCOUNT]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 }
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 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108 purple_notification_set_data(PurpleNotification *notification, gpointer data) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 notification->data = data;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 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
114 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
116 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
117 purple_notification_set_data_destroy_func(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118 GDestroyNotify data_destroy_func)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
121
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 notification->data_destroy_func = data_destroy_func;
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 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 properties[PROP_DATA_DESTROY_FUNC]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 * GObject Implementation
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 *****************************************************************************/
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 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
133 GParamSpec *pspec)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
136
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 switch(param_id) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 case PROP_ID:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
139 g_value_set_string(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 purple_notification_get_id(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
141 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 case PROP_TYPE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 g_value_set_enum(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 purple_notification_get_notification_type(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 case PROP_ACCOUNT:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 g_value_set_object(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 purple_notification_get_account(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 case PROP_CREATED_TIMESTAMP:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 g_value_set_boxed(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
152 purple_notification_get_created_timestamp(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 case PROP_TITLE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155 g_value_set_string(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 purple_notification_get_title(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158 case PROP_ICON_NAME:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 g_value_set_string(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 purple_notification_get_icon_name(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
162 case PROP_READ:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 g_value_set_boolean(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 purple_notification_get_read(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 case PROP_INTERACTIVE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167 g_value_set_boolean(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 purple_notification_get_interactive(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 case PROP_DATA:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 g_value_set_pointer(value,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 purple_notification_get_data(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
173 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 default:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 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
176 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
180 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
181 purple_notification_set_property(GObject *obj, guint param_id,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 const GValue *value, GParamSpec *pspec)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 switch(param_id) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 case PROP_ID:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
188 purple_notification_set_id(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 g_value_get_string(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 case PROP_TYPE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 purple_notification_set_notification_type(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 g_value_get_enum(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 case PROP_ACCOUNT:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 purple_notification_set_account(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 g_value_get_object(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 case PROP_CREATED_TIMESTAMP:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 purple_notification_set_created_timestamp(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 g_value_get_boxed(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 case PROP_TITLE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 purple_notification_set_title(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205 g_value_get_string(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 case PROP_ICON_NAME:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 purple_notification_set_icon_name(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 g_value_get_string(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 case PROP_READ:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
212 purple_notification_set_read(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 g_value_get_boolean(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 case PROP_INTERACTIVE:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 purple_notification_set_interactive(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 g_value_get_boolean(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 case PROP_DATA:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 purple_notification_set_data(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
221 g_value_get_pointer(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
222 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
223 case PROP_DATA_DESTROY_FUNC:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
224 purple_notification_set_data_destroy_func(notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
225 g_value_get_pointer(value));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
226 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 default:
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 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
229 break;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
230 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 purple_notification_finalize(GObject *obj) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 PurpleNotification *notification = PURPLE_NOTIFICATION(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 g_clear_pointer(&notification->id, g_free);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 g_clear_object(&notification->account);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 g_clear_pointer(&notification->created_timestamp, g_date_time_unref);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 g_clear_pointer(&notification->title, g_free);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 g_clear_pointer(&notification->icon_name, g_free);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244 if(notification->data_destroy_func != NULL) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 notification->data_destroy_func(notification->data);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
246 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
247
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
248 G_OBJECT_CLASS(purple_notification_parent_class)->finalize(obj);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 purple_notification_init(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
253 purple_notification_set_id(notification, NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
255 if(notification->created_timestamp == NULL) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
256 purple_notification_set_created_timestamp(notification, NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
257 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
258 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
259
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
260 static void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
261 purple_notification_class_init(PurpleNotificationClass *klass) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
262 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
263
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 obj_class->get_property = purple_notification_get_property;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 obj_class->set_property = purple_notification_set_property;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 obj_class->finalize = purple_notification_finalize;
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 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
269 * PurpleNotification::deleted:
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
270 * @notification: The instance.
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
271 *
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
272 * 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
273 * user interface calling [method@PurpleNotification.delete].
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
274 *
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
275 * Since: 3.0.0
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
276 */
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
277 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
278 "deleted",
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
279 G_OBJECT_CLASS_TYPE(klass),
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
280 G_SIGNAL_RUN_LAST,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
281 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
282 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
283 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
284 NULL,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
285 G_TYPE_NONE,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
286 0);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
287
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
288 /**
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
289 * PurpleNotification:id:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 * 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
292 * This is auto populated at creation time.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 properties[PROP_ID] = g_param_spec_string(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297 "id", "id",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 "The identifier of the notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS
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 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
304 * PurpleNotification:type:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
306 * The [enum@NotificationType] of this notification.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
307 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 properties[PROP_TYPE] = g_param_spec_enum(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311 "type", "type",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 "The type of notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 PURPLE_TYPE_NOTIFICATION_TYPE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 PURPLE_NOTIFICATION_TYPE_UNKNOWN,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 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
316
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
318 * PurpleNotification:account:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
319 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 * An optional [class@Account] that this notification is for.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 properties[PROP_ACCOUNT] = g_param_spec_object(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
325 "account", "account",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
326 "The optional account that this notification is for.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327 PURPLE_TYPE_ACCOUNT,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
328 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
329
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
330 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
331 * PurpleNotification:created-timestamp:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
332 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
333 * 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
334 * 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
335 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
336 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
337 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
338 properties[PROP_CREATED_TIMESTAMP] = g_param_spec_boxed(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
339 "created-timestamp", "created-timestamp",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
340 "The timestamp when this notification was created.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
341 G_TYPE_DATE_TIME,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
342 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
343
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
344 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
345 * PurpleNotification:title:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
346 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
347 * 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
348 * 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
349 * should be a translated string.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
350 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
351 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
352 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
353 properties[PROP_TITLE] = g_param_spec_string(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
354 "title", "title",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
355 "The title for the notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
356 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
357 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | 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:icon-name:
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 * 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
363 * 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
364 * notification.
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 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
367 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
368 properties[PROP_ICON_NAME] = g_param_spec_string(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
369 "icon-name", "icon-name",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
370 "The icon name for the notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
371 NULL,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
372 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
373
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
374 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
375 * PurpleNotification:read:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
376 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
377 * Whether or not the notification has been read.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
378 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
379 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
380 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
381 properties[PROP_READ] = g_param_spec_boolean(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
382 "read", "read",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
383 "Whether or not the notification has been read.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
384 FALSE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
385 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
386
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
387 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
388 * PurpleNotification:interactive:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
389 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
390 * Whether or not the notification can be interacted with.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
391 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
392 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
393 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
394 properties[PROP_INTERACTIVE] = g_param_spec_boolean(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
395 "interactive", "interactive",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 "Whether or not the notification can be interacted with.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
397 FALSE,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
398 G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
399
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
400 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
401 * PurpleNotification:data:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
402 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
403 * Data specific to the [enum@NotificationType] for the notification.
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
404 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
405 * Since: 3.0.0
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
406 */
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
407 properties[PROP_DATA] = g_param_spec_pointer(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
408 "data", "data",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
409 "The type specific data for the notification.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
410 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
411
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
412 /**
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
413 * PurpleNotification:data-destroy-func:
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
414 *
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
415 * 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
416 *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
417 * Since: 3.0.0
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 properties[PROP_DATA_DESTROY_FUNC] = g_param_spec_pointer(
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
420 "data-destroy-func", "data-destroy-func",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
421 "The destroy function to clean up the data property.",
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
422 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
423
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
424 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
425
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
426 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
427
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
428 /******************************************************************************
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
429 * Public API
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 PurpleNotification *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
432 purple_notification_new(PurpleNotificationType type, PurpleAccount *account,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
433 gpointer data, GDestroyNotify data_destroy_func)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
434 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
435 return g_object_new(PURPLE_TYPE_NOTIFICATION,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
436 "type", type,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
437 "account", account,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
438 "data", data,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
439 "data-destroy-func", data_destroy_func,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
440 NULL);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
441 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
442
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
443 PurpleNotification *
41517
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
444 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
445 {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
446 PurpleAccount *account = NULL;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
447 PurpleNotification *notification = NULL;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
448 gchar *title = NULL;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
449 const gchar *alias = NULL, *username = NULL;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
450
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
451 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
452
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
453 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
454 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
455 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
456
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
457 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
458 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
459
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
460 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
461 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
462 alias, username,
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
463 purple_account_get_username(account));
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
464 } else {
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
465 title = g_strdup_printf(_("%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
466 username, purple_account_get_username(account));
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
467 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
468
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
469 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
470 g_free(title);
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
471
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
472 return notification;
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
473 }
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
474
5bafe75d3907 Replace the request_add Account UiOp with a new AddContact notification
Gary Kramlich <grim@reaperworld.com>
parents: 41514
diff changeset
475 PurpleNotification *
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
476 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
477 {
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
478 PurpleAccount *account = NULL;
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
479 PurpleNotification *notification = NULL;
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
480 gchar *title = NULL;
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
481 const gchar *alias = NULL, *username = NULL;
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
482
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
483 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
484 NULL);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
485
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
486 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
487 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
488 account, authorization_request,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
489 g_object_unref);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
490
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
491 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
492 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
493
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
494 if(alias != NULL && *alias != '\0') {
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
495 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
496 " contact list"),
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
497 alias, username,
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
498 purple_account_get_username(account));
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
499 } else {
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
500 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
501 " list"),
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
502 username, purple_account_get_username(account));
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
503 }
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
504
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
505 purple_notification_set_title(notification, title);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
506 g_free(title);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
507
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
508 return notification;
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
509 }
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
510
41819
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
511 PurpleNotification *
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
512 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
513 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
514 {
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
515 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
516 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
517 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
518 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
519
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
520 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
521 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
522
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
523 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
524 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
525
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
526 /* Set the title of the notification. */
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
527 username = purple_account_get_username(account);
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
528 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
529 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
530 } else {
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
531 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
532 }
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
533 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
534 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
535
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
536 /* 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
537 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
538 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
539 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
540
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
541 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
542 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
543 }
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
544 }
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
545
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
546 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
547 }
4461c8ec4d65 Create purple_notification_new_from_connection_error to clean up the accounts code
Gary Kramlich <grim@reaperworld.com>
parents: 41517
diff changeset
548
41433
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
549 const gchar *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
550 purple_notification_get_id(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
551 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
552
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
553 return notification->id;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
554 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
555
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
556 PurpleNotificationType
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
557 purple_notification_get_notification_type(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
558 g_return_val_if_fail(PURPLE_IS_NOTIFICATION(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
559 PURPLE_NOTIFICATION_TYPE_UNKNOWN);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
560
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
561 return notification->type;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
562 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
563
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
564 PurpleAccount *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
565 purple_notification_get_account(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
566 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
567
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
568 return notification->account;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
569 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
570
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
571 GDateTime *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
572 purple_notification_get_created_timestamp(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
573 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
574
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
575 return notification->created_timestamp;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
576 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
577
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
578 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
579 purple_notification_set_created_timestamp(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
580 GDateTime *timestamp)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
581 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
582 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
583
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
584 g_clear_pointer(&notification->created_timestamp, g_date_time_unref);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
585
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
586 if(timestamp == NULL) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
587 notification->created_timestamp = g_date_time_new_now_utc();
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
588 } else {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
589 notification->created_timestamp = g_date_time_to_utc(timestamp);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
590 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
591
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
592 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
593 properties[PROP_CREATED_TIMESTAMP]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
594 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
595
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
596 const gchar *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
597 purple_notification_get_title(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
598 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
599
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
600 return notification->title;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
601 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
602
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
603 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
604 purple_notification_set_title(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
605 const gchar *title)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
606 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
607 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
608
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
609 g_free(notification->title);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
610 notification->title = g_strdup(title);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
611
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
612 g_object_notify_by_pspec(G_OBJECT(notification), properties[PROP_TITLE]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
613 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
614
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
615 const gchar *
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
616 purple_notification_get_icon_name(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
617 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
618
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
619 return notification->icon_name;
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
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
622 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
623 purple_notification_set_icon_name(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
624 const gchar *icon_name)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
625 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
626 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
627
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
628 g_free(notification->icon_name);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
629 notification->icon_name = g_strdup(icon_name);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
630
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
631 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
632 properties[PROP_ICON_NAME]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
633 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
634
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
635 gboolean
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
636 purple_notification_get_read(PurpleNotification *notification) {
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), FALSE);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
638
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
639 return notification->read;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
640 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
641
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
642 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
643 purple_notification_set_read(PurpleNotification *notification, gboolean read) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
644 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
645
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
646 if(notification->read != read) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
647 notification->read = read;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
648
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
649 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
650 properties[PROP_READ]);
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
651 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
652 }
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 gboolean
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
655 purple_notification_get_interactive(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
656 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
657
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
658 return notification->interactive;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
659 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
660
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
661 void
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
662 purple_notification_set_interactive(PurpleNotification *notification,
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
663 gboolean interactive)
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
664 {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
665 g_return_if_fail(PURPLE_IS_NOTIFICATION(notification));
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(notification->interactive != interactive) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
668 notification->interactive = interactive;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
669
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
670 g_object_notify_by_pspec(G_OBJECT(notification),
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
671 properties[PROP_INTERACTIVE]);
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 }
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
674
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
675 gpointer
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
676 purple_notification_get_data(PurpleNotification *notification) {
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
677 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
678
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
679 return notification->data;
d563b345a096 Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
680 }
41438
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
681
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
682 gint
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
683 purple_notification_compare(gconstpointer a, gconstpointer b) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
684 PurpleNotification *notification_a = NULL, *notification_b = NULL;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
685
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
686 if(a == NULL && b == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
687 return 0;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
688 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
689
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
690 if(a == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
691 return -1;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
692 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
693
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
694 if(b == NULL) {
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
695 return 1;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
696 }
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
697
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
698 notification_a = (PurpleNotification *)a;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
699 notification_b = (PurpleNotification *)b;
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
700
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
701 return g_date_time_compare(notification_a->created_timestamp,
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
702 notification_b->created_timestamp);
86beaec0fa35 Create and add notifications for account errors.
Gary Kramlich <grim@reaperworld.com>
parents: 41433
diff changeset
703 }
41514
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
704
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
705 void
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
706 purple_notification_delete(PurpleNotification *notification) {
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
707 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
708
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
709 /* Calling this multiple times is a programming error. */
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
710 g_return_if_fail(notification->deleted == FALSE);
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
711
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
712 notification->deleted = TRUE;
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
713
a96768bacb59 Create PurpleAuthorizationRequest and use it for notifications.
Gary Kramlich <grim@reaperworld.com>
parents: 41438
diff changeset
714 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
715 }

mercurial