pidgin/pidginmessage.c

Fri, 04 Nov 2022 00:47:21 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Fri, 04 Nov 2022 00:47:21 -0500
changeset 41882
e0a90a0a5bb2
parent 41019
f1bdc43bf086
child 41947
7b3312d0760c
permissions
-rw-r--r--

Remove last unused argument in purple_util_format_song_info

Testing Done:
Compiled only.

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

40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
1 /*
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
2 * Pidgin - Internet Messenger
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "pidginmessage.h"
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
25 #include "pidginattachment.h"
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
26 #include "pidgincolor.h"
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
27
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 struct _PidginMessage {
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 GObject parent;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
31 PurpleMessage *message;
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 };
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
34 typedef struct {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
35 TalkatuAttachmentForeachFunc func;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
36 gpointer data;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
37 } PidginMessageAttachmentForeachData;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
38
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 enum {
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 PROP_0,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 PROP_MESSAGE,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 N_PROPERTIES,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 /* overrides */
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 PROP_ID = N_PROPERTIES,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 PROP_CONTENT_TYPE,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 PROP_AUTHOR,
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
47 PROP_AUTHOR_NAME_COLOR,
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 PROP_CONTENTS,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 PROP_TIMESTAMP,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 PROP_EDITED,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 };
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 static GParamSpec *properties[N_PROPERTIES] = {NULL, };
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 /******************************************************************************
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55 * Helpers
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 *****************************************************************************/
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 static void
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
58 pidgin_message_set_message(PidginMessage *message, PurpleMessage *purple_msg) {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
59 if(g_set_object(&message->message, purple_msg)) {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
60 g_object_notify_by_pspec(G_OBJECT(message), properties[PROP_MESSAGE]);
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
64 static GdkRGBA *
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
65 pidgin_message_parse_author_name_color(PidginMessage *message) {
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
66 GdkRGBA *ret = NULL;
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
67 const gchar *color = NULL;
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
68 gboolean set = FALSE;
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
69
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
70 ret = g_new0(GdkRGBA, 1);
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
71
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
72 color = purple_message_get_author_name_color(message->message);
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
73 if(color != NULL && gdk_rgba_parse(ret, color)) {
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
74 set = TRUE;
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
75 }
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
76
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
77 if(!set) {
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
78 const gchar *author = purple_message_get_author_alias(message->message);
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
79
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
80 if(author == NULL) {
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
81 author = purple_message_get_author(message->message);
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
82 }
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
83
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
84 pidgin_color_calculate_for_text(author, ret);
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
85 }
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
86
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
87 return ret;
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
88 }
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
89
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 /******************************************************************************
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 * TalkatuMessage Implementation
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 *****************************************************************************/
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
93 static gboolean
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
94 pidgin_message_add_attachment(TalkatuMessage *tmessage,
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
95 TalkatuAttachment *tattachment)
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
96 {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
97 PidginMessage *pmessage = PIDGIN_MESSAGE(tmessage);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
98 PurpleAttachment *pattachment = NULL;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
99 gboolean ret = FALSE;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
100
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
101 pattachment = purple_attachment_new(
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
102 talkatu_attachment_get_id(tattachment),
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
103 talkatu_attachment_get_content_type(tattachment)
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
104 );
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
105
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
106 ret = purple_message_add_attachment(pmessage->message, pattachment);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
107
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
108 g_object_unref(G_OBJECT(pattachment));
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
109
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
110 return ret;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
111 }
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
112
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
113 static gboolean
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
114 pidgin_message_remove_attachment(TalkatuMessage *tmessage, guint64 id) {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
115 PidginMessage *pmessage = PIDGIN_MESSAGE(tmessage);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
116
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
117 return purple_message_remove_attachment(pmessage->message, id);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
118 }
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
119
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
120 static TalkatuAttachment *
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
121 pidgin_message_get_attachment(TalkatuMessage *tmessage, guint64 id) {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
122 PidginMessage *pmessage = PIDGIN_MESSAGE(tmessage);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
123 PidginAttachment *pidgin_attachment = NULL;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
124 PurpleAttachment *purple_attachment = NULL;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
125
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
126 purple_attachment = purple_message_get_attachment(pmessage->message, id);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
127 pidgin_attachment = pidgin_attachment_new(purple_attachment);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
128 g_object_unref(G_OBJECT(purple_attachment));
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
129
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
130 return TALKATU_ATTACHMENT(pidgin_attachment);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
131 }
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
132
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
133 static void
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
134 pidgin_message_foreach_attachment_helper(PurpleAttachment *attachment,
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
135 gpointer data)
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
136 {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
137 PidginAttachment *pidgin_attachment = NULL;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
138 PidginMessageAttachmentForeachData *d = NULL;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
139
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
140 d = (PidginMessageAttachmentForeachData *)data;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
141 pidgin_attachment = pidgin_attachment_new(attachment);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
142
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
143 d->func(TALKATU_ATTACHMENT(pidgin_attachment), d->data);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
144
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
145 g_object_unref(G_OBJECT(pidgin_attachment));
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
146 }
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
147
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
148 static void
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
149 pidgin_message_foreach_attachment(TalkatuMessage *tmessage,
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
150 TalkatuAttachmentForeachFunc func,
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
151 gpointer data)
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
152 {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
153 PidginMessage *pmessage = PIDGIN_MESSAGE(tmessage);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
154 PidginMessageAttachmentForeachData *d = NULL;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
155
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
156 /* PurpleAttachmentForeachFunc and TalkatuAttachmentForeachFunc may not
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
157 * always have the same signature. So to work around that, we use a helper
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
158 * function that has the signature of PurpleAttachmentForeachFunc but will
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
159 * call the TalkatuAttachmentForeachFunc while also wrapping the
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
160 * PurpleAttachments.
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
161 */
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
162
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
163 d = g_new(PidginMessageAttachmentForeachData, 1);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
164 d->func = func;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
165 d->data = data;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
166
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
167 purple_message_foreach_attachment(
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
168 pmessage->message,
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
169 pidgin_message_foreach_attachment_helper,
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
170 d
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
171 );
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
172
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
173 g_free(d);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
174 }
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
175
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
176 static void
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
177 pidgin_message_clear_attachments(TalkatuMessage *tmessage) {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
178 PidginMessage *pmessage = PIDGIN_MESSAGE(tmessage);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
179
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
180 purple_message_clear_attachments(pmessage->message);
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
181 }
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
182
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
183 static void
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
184 pidgin_message_talkatu_message_init(TalkatuMessageInterface *iface) {
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
185 iface->add_attachment = pidgin_message_add_attachment;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
186 iface->remove_attachment = pidgin_message_remove_attachment;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
187 iface->get_attachment = pidgin_message_get_attachment;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
188 iface->foreach_attachment = pidgin_message_foreach_attachment;
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
189 iface->clear_attachments = pidgin_message_clear_attachments;
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
190 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
191
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 /******************************************************************************
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193 * GObject Implementation
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 *****************************************************************************/
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 G_DEFINE_TYPE_EXTENDED(
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
196 PidginMessage,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 pidgin_message,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198 G_TYPE_OBJECT,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
199 0,
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
200 G_IMPLEMENT_INTERFACE(TALKATU_TYPE_MESSAGE,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
201 pidgin_message_talkatu_message_init)
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
202 );
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
203
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
204 static void
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
205 pidgin_message_get_property(GObject *obj, guint param_id, GValue *value,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
206 GParamSpec *pspec)
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
207 {
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
208 PidginMessage *message = PIDGIN_MESSAGE(obj);
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
209
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
210 switch(param_id) {
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
211 case PROP_MESSAGE:
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
212 g_value_set_object(value, message->message);
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
213 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 case PROP_ID:
41019
f1bdc43bf086 Change PurpleMessage:id to a string and add author-name-color to the property getter/setter.
Gary Kramlich <grim@reaperworld.com>
parents: 40951
diff changeset
215 g_value_set_string(value, purple_message_get_id(message->message));
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
216 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 case PROP_CONTENT_TYPE:
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218 g_value_set_enum(value, TALKATU_CONTENT_TYPE_PLAIN);
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 case PROP_AUTHOR:
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
221 g_value_set_string(value,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
222 purple_message_get_author(message->message));
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
223 break;
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
224 case PROP_AUTHOR_NAME_COLOR:
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
225 g_value_take_boxed(value,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
226 pidgin_message_parse_author_name_color(message));
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
227 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
228 case PROP_CONTENTS:
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
229 g_value_set_string(value,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
230 purple_message_get_contents(message->message));
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
231 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 case PROP_TIMESTAMP:
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
233 g_value_set_boxed(value,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
234 purple_message_get_timestamp(message->message));
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 case PROP_EDITED:
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 g_value_set_boolean(value, FALSE);
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
238 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
239 default:
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
240 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
241 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
242 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
243 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
244
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
245 static void
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
246 pidgin_message_set_property(GObject *obj, guint param_id, const GValue *value,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
247 GParamSpec *pspec)
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
248 {
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
249 PidginMessage *message = PIDGIN_MESSAGE(obj);
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 switch(param_id) {
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252 case PROP_MESSAGE:
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
253 pidgin_message_set_message(message, g_value_get_object(value));
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
254 break;
39704
8f0ffe559ea0 Some additional cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 39702
diff changeset
255 case PROP_ID:
8f0ffe559ea0 Some additional cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 39702
diff changeset
256 case PROP_CONTENT_TYPE:
8f0ffe559ea0 Some additional cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 39702
diff changeset
257 case PROP_TIMESTAMP:
8f0ffe559ea0 Some additional cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 39702
diff changeset
258 case PROP_AUTHOR:
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
259 case PROP_AUTHOR_NAME_COLOR:
39704
8f0ffe559ea0 Some additional cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 39702
diff changeset
260 case PROP_CONTENTS:
8f0ffe559ea0 Some additional cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 39702
diff changeset
261 case PROP_EDITED:
8f0ffe559ea0 Some additional cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 39702
diff changeset
262 /* we don't allow settings these */
8f0ffe559ea0 Some additional cleanups
Gary Kramlich <grim@reaperworld.com>
parents: 39702
diff changeset
263 break;
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
264 default:
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
265 G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec);
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
266 break;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
267 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
268 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
269
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
270 static void
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
271 pidgin_message_init(PidginMessage *message) {
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
272 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
273
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
274 static void
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
275 pidgin_message_finalize(GObject *obj) {
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
276 PidginMessage *message = PIDGIN_MESSAGE(obj);
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
277
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
278 g_clear_object(&message->message);
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
279
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
280 G_OBJECT_CLASS(pidgin_message_parent_class)->finalize(obj);
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
281 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
282
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
283 static void
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
284 pidgin_message_class_init(PidginMessageClass *klass) {
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
285 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
286
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
287 obj_class->get_property = pidgin_message_get_property;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
288 obj_class->set_property = pidgin_message_set_property;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
289 obj_class->finalize = pidgin_message_finalize;
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
290
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
291 /* add our custom properties */
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
292 properties[PROP_MESSAGE] = g_param_spec_object(
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
293 "message", "message", "The purple message",
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
294 PURPLE_TYPE_MESSAGE,
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
295 G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
296 );
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
297
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
298 g_object_class_install_properties(obj_class, N_PROPERTIES, properties);
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
299
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
300 /* add our overridden properties */
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
301 g_object_class_override_property(obj_class, PROP_ID, "id");
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
302 g_object_class_override_property(obj_class, PROP_TIMESTAMP, "timestamp");
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
303 g_object_class_override_property(obj_class, PROP_CONTENT_TYPE,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
304 "content-type");
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
305 g_object_class_override_property(obj_class, PROP_AUTHOR, "author");
40951
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
306 g_object_class_override_property(obj_class, PROP_AUTHOR_NAME_COLOR,
c83bf354d142 Add support for the author-name-color property to PidginMessage and wire it up in PurpleMessage as well
Gary Kramlich <grim@reaperworld.com>
parents: 40541
diff changeset
307 "author-name-color");
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
308 g_object_class_override_property(obj_class, PROP_CONTENTS, "contents");
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
309 g_object_class_override_property(obj_class, PROP_EDITED, "edited");
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
310 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
311
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
312 /******************************************************************************
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
313 * API
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
314 *****************************************************************************/
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
315 PidginMessage *
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
316 pidgin_message_new(PurpleMessage *message) {
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
317 return g_object_new(
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
318 PIDGIN_TYPE_MESSAGE,
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
319 "message", message,
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
320 NULL
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
321 );
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
322 }
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
323
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
324 PurpleMessage *
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
325 pidgin_message_get_message(PidginMessage *message) {
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
326 g_return_val_if_fail(PIDGIN_IS_MESSAGE(message), NULL);
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
327
40526
c8cc1a4c4a02 Add support for message attachments
Gary Kramlich <grim@reaperworld.com>
parents: 39825
diff changeset
328 return message->message;
39702
8102041c0288 Replace gtkconv->webview with a TalkatuHistory
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
329 }

mercurial