Wed, 15 Jun 2022 00:32:22 -0500
Phase 1 of the Notifications API
* Created PurpleNotification with unit tests.
* Created PurpleNotificationManager with unit tests.
Testing Done:
Ran the unit tests and ran Pidgin in the devenv.
Bugs closed: PIDGIN-17633
Reviewed at https://reviews.imfreedom.org/r/1502/
|
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 program is free software; you can redistribute it and/or modify |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
6 | * it under the terms of the GNU General Public License as published by |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
7 | * the Free Software Foundation; either version 2 of the License, or |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
8 | * (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 program 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 |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
13 | * GNU 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 General Public License |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
16 | * along with this program; 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 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
19 | #if !defined(PURPLE_GLOBAL_HEADER_INSIDE) && !defined(PURPLE_COMPILATION) |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
20 | # error "only <purple.h> may be included directly" |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #endif |
|
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 | #ifndef PURPLE_NOTIFICATION_MANAGER_H |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | #define PURPLE_NOTIFICATION_MANAGER_H |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
25 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | #include <glib.h> |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include <glib-object.h> |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
29 | #include "account.h" |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
30 | #include <purplenotification.h> |
|
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 | G_BEGIN_DECLS |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
33 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | #define PURPLE_TYPE_NOTIFICATION_MANAGER (purple_notification_manager_get_type()) |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | G_DECLARE_FINAL_TYPE(PurpleNotificationManager, purple_notification_manager, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | PURPLE, NOTIFICATION_MANAGER, GObject) |
|
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 | /** |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | * PurpleNotificationManager: |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
40 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | * Purple Notification Manager manages all notifications between protocols and |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | * plugins and how the user interface interacts with them. |
|
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 | * Since: 3.0.0 |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | /** |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | * purple_notification_manager_get_default: |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
49 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
50 | * Gets the default [class@NotificationManager] instance. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
51 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | * Returns: (transfer none): The default instance. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
54 | * Since: 3.0.0 |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | PurpleNotificationManager *purple_notification_manager_get_default(void); |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | /** |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
59 | * purple_notification_manager_add: |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | * @manager: The instance. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
61 | * @notification: (transfer full): The [class@Notification] to add. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
63 | * Adds @notification into @manager. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | * Since: 3.0.0 |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | void purple_notification_manager_add(PurpleNotificationManager *manager, PurpleNotification *notification); |
|
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 | /** |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | * purple_notification_manager_remove: |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
71 | * @manager: The instance. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
72 | * @id: The identifier of the notification to remove. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
73 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | * Removes @notification from @manager. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | * Returns: %TRUE if @notification was successfully removed from @manager, |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | * %FALSE otherwise. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
78 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
79 | * Since: 3.0.0 |
|
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 | gboolean purple_notification_manager_remove(PurpleNotificationManager *manager, const gchar *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 | * purple_notification_manager_get_unread_count: |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
85 | * @manager: The instance. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
87 | * Gets the number of currently unread notifications. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
88 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
89 | * Returns: The number of unread notifications. |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
90 | * |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | * Since: 3.0.0 |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | */ |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | guint purple_notification_manager_get_unread_count(PurpleNotificationManager *manager); |
|
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 | G_END_DECLS |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | |
|
d563b345a096
Phase 1 of the Notifications API
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
97 | #endif /* PURPLE_NOTIFICATION_MANAGER_H */ |