Wed, 19 Jul 2023 23:29:37 -0500
Require GTK 4.10 and GLib 2.76
Due to the deprecations in GTK 4.10 we're moving to it immediately so that we
don't end up having to deal with deprecation warnings forever (again).
Also, we're taking this opportunity to require the last glib minor version as
well as if you have GTK 4.10, you most likely have GLib 2.76 as well.
Testing Done:
Compiled.
Reviewed at https://reviews.imfreedom.org/r/2526/
|
39849
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
1 | /* pidgin |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
2 | * |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
3 | * Pidgin is the legal property of its developers, whose names are too numerous |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
4 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
5 | * source distribution. |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
6 | * |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
7 | * This program is free software; you can redistribute it and/or modify |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
8 | * it under the terms of the GNU General Public License as published by |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
9 | * the Free Software Foundation; either version 2 of the License, or |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
10 | * (at your option) any later version. |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
11 | * |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
12 | * This program is distributed in the hope that it will be useful, |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
15 | * GNU General Public License for more details. |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
16 | * |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
17 | * You should have received a copy of the GNU General Public License |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
18 | * along with this program; if not, write to the Free Software |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
20 | */ |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
21 | #include <glib.h> |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
22 | #include <gmodule.h> |
|
40882
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
23 | |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
24 | #include <gplugin.h> |
|
40882
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
25 | #include <gplugin-native.h> |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
26 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
27 | #include <purple.h> |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
28 | |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
29 | /****************************************************************************** |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
30 | * Helpers |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
31 | *****************************************************************************/ |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
32 | static GApplication * |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
33 | purple_toast_get_application(void) { |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
34 | static GApplication *application = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
35 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
36 | if(G_UNLIKELY(application == NULL)) { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
37 | application = g_application_get_default(); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
38 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
39 | if(application == NULL) { |
|
41876
984f389775cb
Fix deprecation warning with GLib 2.74
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41663
diff
changeset
|
40 | application = g_application_new(NULL, G_APPLICATION_DEFAULT_FLAGS); |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
41 | g_application_register(application, NULL, NULL); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
44 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
45 | return application; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
46 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
47 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
48 | static void |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
49 | purple_toast_show_notification(const gchar *title, |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
50 | const gchar *body, |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
51 | GIcon *icon) |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
52 | { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
53 | GNotification *notification = g_notification_new(title); |
|
39851
061774fb138e
strip the html out of messages as we're not rendering it.
Gary Kramlich <grim@reaperworld.com>
parents:
39850
diff
changeset
|
54 | gchar *stripped = purple_markup_strip_html(body); |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
55 | |
|
39851
061774fb138e
strip the html out of messages as we're not rendering it.
Gary Kramlich <grim@reaperworld.com>
parents:
39850
diff
changeset
|
56 | g_notification_set_body(notification, stripped); |
|
061774fb138e
strip the html out of messages as we're not rendering it.
Gary Kramlich <grim@reaperworld.com>
parents:
39850
diff
changeset
|
57 | g_free(stripped); |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
58 | |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
59 | if(G_IS_ICON(icon)) { |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | g_notification_set_icon(notification, icon); |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
61 | } |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
62 | |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
63 | g_application_send_notification(purple_toast_get_application(), |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
64 | NULL, |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
65 | notification); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
66 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
67 | g_object_unref(G_OBJECT(notification)); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
68 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
69 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
70 | static GIcon * |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
71 | purple_toast_find_icon(PurpleAccount *account, |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
72 | PurpleBuddy *buddy, |
|
42076
76417a1fa9b2
Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41876
diff
changeset
|
73 | G_GNUC_UNUSED const gchar *sender) |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
74 | { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
75 | GIcon *icon = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
76 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
77 | if(PURPLE_IS_BUDDY(buddy)) { |
|
39848
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
78 | PurpleBuddyIcon *buddy_icon = purple_buddy_get_icon(buddy); |
|
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
79 | |
|
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
80 | if(buddy_icon) { |
|
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
81 | const gchar *filename = NULL; |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
82 | |
|
39848
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
83 | filename = purple_buddy_icon_get_full_path(buddy_icon); |
|
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
84 | if(filename != NULL) { |
|
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
85 | GFile *file = g_file_new_for_path(filename); |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
86 | |
|
39848
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
87 | icon = g_file_icon_new(file); |
|
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
88 | |
|
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
89 | g_object_unref(file); |
|
1b71616683fb
Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents:
39846
diff
changeset
|
90 | } |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
91 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
92 | } else { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
93 | PurpleImage *image = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
94 | const gchar *path = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
95 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
96 | image = purple_buddy_icons_find_account_icon(account); |
|
39849
53f4bb432329
Add a COPYRIGHT header and remove some extra whitespace
Gary Kramlich <grim@reaperworld.com>
parents:
39848
diff
changeset
|
97 | if(PURPLE_IS_IMAGE(image)) { |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
98 | path = purple_image_get_path(image); |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
99 | |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
100 | if(path) { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
101 | GFile *file = g_file_new_for_path(path); |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
102 | |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
103 | icon = g_file_icon_new(file); |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
104 | |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
105 | g_object_unref(G_OBJECT(file)); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
106 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
107 | g_object_unref(G_OBJECT(image)); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
108 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
109 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
110 | |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
111 | /* We should probably have a fallback, but we need a libpurple or |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
112 | * pidgin icon or something to make that happen. |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
113 | */ |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
114 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
115 | return icon; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
116 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
117 | |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
118 | /****************************************************************************** |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
119 | * Callbacks |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
120 | *****************************************************************************/ |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
121 | static void |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
122 | purple_toast_im_message_received(PurpleAccount *account, |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
123 | const gchar *sender, |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
124 | const gchar *message, |
|
42076
76417a1fa9b2
Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41876
diff
changeset
|
125 | G_GNUC_UNUSED PurpleConversation *conv, |
|
76417a1fa9b2
Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41876
diff
changeset
|
126 | G_GNUC_UNUSED PurpleMessageFlags flags, |
|
76417a1fa9b2
Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41876
diff
changeset
|
127 | G_GNUC_UNUSED gpointer data) |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
128 | { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
129 | PurpleBuddy *buddy = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
130 | GIcon *icon = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
131 | const gchar *title = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
132 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
133 | buddy = purple_blist_find_buddy(account, sender); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
134 | title = PURPLE_IS_BUDDY(buddy) ? purple_buddy_get_alias(buddy) : sender; |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
135 | icon = purple_toast_find_icon(account, buddy, sender); |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
136 | |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
137 | purple_toast_show_notification(title, message, icon); |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
138 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
139 | if(G_IS_ICON(icon)) { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
140 | g_object_unref(G_OBJECT(icon)); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
141 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
142 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
143 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
144 | static void |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
145 | purple_toast_chat_message_received(PurpleAccount *account, |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
146 | gchar *sender, |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
147 | gchar *message, |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
148 | PurpleConversation *conv, |
|
42076
76417a1fa9b2
Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41876
diff
changeset
|
149 | G_GNUC_UNUSED PurpleMessageFlags flags, |
|
76417a1fa9b2
Mark unused parameters as such for all of the purple plugins
Gary Kramlich <grim@reaperworld.com>
parents:
41876
diff
changeset
|
150 | G_GNUC_UNUSED gpointer data) |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
151 | { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
152 | PurpleBuddy *buddy = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
153 | GIcon *icon = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
154 | gchar *title = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
155 | const gchar *chat_name = NULL, *from = NULL; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
156 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
157 | /* figure out the title */ |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
158 | chat_name = purple_conversation_get_name(PURPLE_CONVERSATION(conv)); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
159 | if(chat_name) { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
160 | PurpleChat *chat = purple_blist_find_chat(account, chat_name); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
161 | |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
162 | if(chat) { |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
163 | chat_name = purple_chat_get_name(chat); |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
164 | } |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
165 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
166 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
167 | from = sender; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
168 | buddy = purple_blist_find_buddy(account, sender); |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
169 | if(PURPLE_IS_BUDDY(buddy)) { |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
170 | from = purple_buddy_get_alias(buddy); |
|
39850
387c2315f7da
Remove some debug logging and update some coding standards
Gary Kramlich <grim@reaperworld.com>
parents:
39849
diff
changeset
|
171 | } |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
172 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
173 | title = g_strdup_printf("%s : %s", chat_name, from); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
174 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
175 | /* figure out the icon */ |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
176 | icon = purple_toast_find_icon(account, buddy, sender); |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
177 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
178 | /* show the notification */ |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
179 | purple_toast_show_notification(title, message, icon); |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
180 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
181 | /* clean up our memory */ |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
182 | g_free(title); |
|
39853
bb96b42b4a07
Add a needed null check
Gary Kramlich <grim@reaperworld.com>
parents:
39852
diff
changeset
|
183 | |
|
bb96b42b4a07
Add a needed null check
Gary Kramlich <grim@reaperworld.com>
parents:
39852
diff
changeset
|
184 | if(G_IS_ICON(icon)) { |
|
bb96b42b4a07
Add a needed null check
Gary Kramlich <grim@reaperworld.com>
parents:
39852
diff
changeset
|
185 | g_object_unref(G_OBJECT(icon)); |
|
bb96b42b4a07
Add a needed null check
Gary Kramlich <grim@reaperworld.com>
parents:
39852
diff
changeset
|
186 | } |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
187 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
188 | |
|
39852
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
189 | /****************************************************************************** |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
190 | * Plugin Exports |
|
90bfc0af16d1
Don't use _'s for static function names
Gary Kramlich <grim@reaperworld.com>
parents:
39851
diff
changeset
|
191 | *****************************************************************************/ |
|
40882
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
192 | static GPluginPluginInfo * |
|
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
193 | purple_toast_query(G_GNUC_UNUSED GError **error) { |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
194 | const gchar * const authors[] = { |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
195 | "Gary Kramlich <grim@reaperworld.com>", |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
196 | NULL |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
197 | }; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
198 | |
|
40945
bbeb2e98ea5b
Use GPLUGIN_NATIVE_PLUGIN_DECLARE for all libpurple plugins and remove PURPLE_PLUGIN_INIT
Gary Kramlich <grim@reaperworld.com>
parents:
40882
diff
changeset
|
199 | return purple_plugin_info_new( |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
200 | "id", "purple/toast", |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
201 | "abi-version", PURPLE_ABI_VERSION, |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
202 | "name", "Purple Toast", |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
203 | "version", "0.0.1", |
|
40264
d253f767f6cc
fix various memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents:
39853
diff
changeset
|
204 | "summary", "Toast notifications", |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
205 | "authors", authors, |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
206 | NULL |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
207 | ); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
208 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
209 | |
|
40882
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
210 | static gboolean |
|
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
211 | purple_toast_load(GPluginPlugin *plugin, G_GNUC_UNUSED GError **error) { |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
212 | gpointer conv_handle = purple_conversations_get_handle(); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
213 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
214 | purple_signal_connect(conv_handle, |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
215 | "received-im-msg", |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
216 | plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
217 | G_CALLBACK(purple_toast_im_message_received), |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
218 | NULL |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
219 | ); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
220 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
221 | purple_signal_connect(conv_handle, |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
222 | "received-chat-msg", |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
223 | plugin, |
|
41314
0dc72eacd8bf
Replace PURPLE_CALLBACK by G_CALLBACK
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41078
diff
changeset
|
224 | G_CALLBACK(purple_toast_chat_message_received), |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
225 | NULL |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
226 | ); |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
227 | |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
228 | return TRUE; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
229 | } |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
230 | |
|
40882
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
231 | static gboolean |
|
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
232 | purple_toast_unload(G_GNUC_UNUSED GPluginPlugin *plugin, |
|
41078
84e48180ef67
Update to gplugin 0.35.0
Gary Kramlich <grim@reaperworld.com>
parents:
40945
diff
changeset
|
233 | G_GNUC_UNUSED gboolean shutdown, |
|
40882
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
234 | G_GNUC_UNUSED GError **error) |
|
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
235 | { |
|
39846
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
236 | return TRUE; |
|
350689bfebfc
Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
237 | } |
|
40882
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
238 | |
|
77df4bdbc750
Port the plugins that were manually specific GPlugin exports to the new GPlugin declare macro
Gary Kramlich <grim@reaperworld.com>
parents:
40264
diff
changeset
|
239 | GPLUGIN_NATIVE_PLUGIN_DECLARE(purple_toast) |