libpurple/plugins/purple-toast.c

Thu, 13 Jul 2017 22:37:07 -0500

author
Gary Kramlich <grim@reaperworld.com>
date
Thu, 13 Jul 2017 22:37:07 -0500
changeset 39848
1b71616683fb
parent 39846
350689bfebfc
child 39849
53f4bb432329
permissions
-rw-r--r--

Get buddy icons working

39846
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 #include <glib.h>
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 #include <gmodule.h>
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 #include <gplugin.h>
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 #include <purple.h>
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6
39848
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
7 /* make the compiler happy... */
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
8 G_MODULE_EXPORT GPluginPluginInfo *gplugin_query(GError **error);
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
9 G_MODULE_EXPORT gboolean gplugin_load(GPluginPlugin *plugin, GError **error);
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
10 G_MODULE_EXPORT gboolean gplugin_unload(GPluginPlugin *plugin, GError **error);
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
11
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
12
39846
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 static GApplication *
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 _purple_toast_get_application(void) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 static GApplication *application = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 if(G_UNLIKELY(application == NULL)) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 application = g_application_get_default();
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 if(application == NULL) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 application = g_application_new(NULL, G_APPLICATION_FLAGS_NONE);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 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
23 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 return application;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 static void
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 _purple_toast_show_notification(const gchar *title,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31 const gchar *body,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 GIcon *icon)
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 GNotification *notification = g_notification_new(title);
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 g_message("title: %s", title);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 g_message("body: %s", body);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 g_message("icon: %p", icon);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 g_notification_set_body(notification, body);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 if(G_IS_ICON(icon))
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 g_notification_set_icon(notification, icon);
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 g_application_send_notification(_purple_toast_get_application(),
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 NULL,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 notification);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 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
50 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 static GIcon *
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 _purple_toast_find_icon(PurpleAccount *account,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 PurpleBuddy *buddy,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 const gchar *sender)
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 GIcon *icon = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 if(PURPLE_IS_BUDDY(buddy)) {
39848
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
60 PurpleBuddyIcon *buddy_icon = purple_buddy_get_icon(buddy);
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
61
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
62 if(buddy_icon) {
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
63 const gchar *filename = NULL;
39846
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64
39848
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
65 filename = purple_buddy_icon_get_full_path(buddy_icon);
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
66 if(filename != NULL) {
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
67 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
68
39848
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
69 icon = g_file_icon_new(file);
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
70
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
71 g_object_unref(file);
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
72 }
39846
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 } else {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 PurpleImage *image = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 const gchar *path = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 image = purple_buddy_icons_find_account_icon(account);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 if(PURPLE_IS_IMAGE(image)) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 path = purple_image_get_path(image);
39848
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
81 g_message("toast path: %p", path);
39846
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 if(path) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 GFile *file = g_file_new_for_path(path);
39848
1b71616683fb Get buddy icons working
Gary Kramlich <grim@reaperworld.com>
parents: 39846
diff changeset
84 g_message("toast file: %p", file);
39846
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 icon = g_file_icon_new(file);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 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
87 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 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
89 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 if(!G_IS_ICON(icon)) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 }
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 g_message("toast icon : %p", icon);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 return icon;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 static void
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 _purple_toast_im_message_received(PurpleAccount *account,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 const gchar *sender,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 const gchar *message,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 PurpleConversation *conv,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 PurpleMessageFlags flags,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 gpointer data)
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 PurpleBuddy *buddy = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 GIcon *icon = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 const gchar *title = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 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
114 title = PURPLE_IS_BUDDY(buddy) ? purple_buddy_get_alias(buddy) : sender;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
115 icon = _purple_toast_find_icon(account, buddy, sender);
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 _purple_toast_show_notification(title, message, icon);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
118
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
119 if(G_IS_ICON(icon)) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
120 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
121 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
122 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
123
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
124 static void
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
125 _purple_toast_chat_message_received(PurpleAccount *account,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
126 char *sender,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
127 char *message,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
128 PurpleConversation *conv,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
129 PurpleMessageFlags flags,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
130 gpointer data)
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
131 {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
132 PurpleBuddy *buddy = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
133 GIcon *icon = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
134 gchar *title = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
135 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
136
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
137 /* figure out the title */
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
138 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
139 if(chat_name) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
140 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
141
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
142 if(chat)
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
143 chat_name = purple_chat_get_name(chat);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
144 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
145
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
146 from = sender;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 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
148 if(PURPLE_IS_BUDDY(buddy))
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 from = purple_buddy_get_alias(buddy);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
151 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
152
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
153 /* figure out the icon */
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
154 icon = _purple_toast_find_icon(account, buddy, sender);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
155
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
156 /* show the notification */
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
157 _purple_toast_show_notification(title, message, icon);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
158
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
159 /* clean up our memory */
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
160 g_free(title);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
161 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
162 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
164 G_MODULE_EXPORT GPluginPluginInfo *
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
165 gplugin_query(GError **error) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
166 PurplePluginInfo *info = NULL;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
167
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
168 const gchar * const authors[] = {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 "Gary Kramlich <grim@reaperworld.com>",
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170 NULL
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 };
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 info = purple_plugin_info_new(
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
174 "id", "purple/toast",
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
175 "abi-version", PURPLE_ABI_VERSION,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
176 "name", "Purple Toast",
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
177 "version", "0.0.1",
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
178 "authors", authors,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
179 NULL
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
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
182 return GPLUGIN_PLUGIN_INFO(info);
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
185 G_MODULE_EXPORT gboolean
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
186 gplugin_load(GPluginPlugin *plugin, GError **error) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
187 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
188
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
189 purple_signal_connect(conv_handle,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 "received-im-msg",
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191 plugin,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 PURPLE_CALLBACK(_purple_toast_im_message_received),
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 NULL
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 );
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 purple_signal_connect(conv_handle,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 "received-chat-msg",
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 plugin,
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 PURPLE_CALLBACK(_purple_toast_chat_message_received),
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
200 NULL
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
201 );
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203 return TRUE;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 }
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
205
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
206 G_MODULE_EXPORT gboolean
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
207 gplugin_unload(GPluginPlugin *plugin, GError **error) {
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
208 return TRUE;
350689bfebfc Add purple-toast and add it to meson and autotools
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209 }

mercurial